Skip to content

Commit

Permalink
fix crash in sample
Browse files Browse the repository at this point in the history
  • Loading branch information
MaksTuev committed Jul 26, 2016
1 parent 82fe9b5 commit b5c103c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/**
* View for Book screen
*/
class BookFragmentView extends MvpFragmentV4View {
public class BookFragmentView extends MvpFragmentV4View {
private static final String EXTRA_BOOK_ID = "EXTRA_BOOK_ID";

@Inject
Expand All @@ -35,7 +35,7 @@ class BookFragmentView extends MvpFragmentV4View {
private ImageView coverIv;
private Button downloadBtn;
private View readBtn;
private TextView desctiptionTv;
private TextView descriptionTv;
private SwipeRefreshLayout swipeRefreshLayout;
private Handler handler = new Handler();
private View contentContainer;
Expand Down Expand Up @@ -98,7 +98,7 @@ private void findViews(View view) {
coverIv = (ImageView) view.findViewById(R.id.book_cover_iv);
downloadBtn = (Button)view.findViewById(R.id.book_download_btn);
readBtn = view.findViewById(R.id.book_read_btn);
desctiptionTv = (TextView) view.findViewById(R.id.book_description_tv);
descriptionTv = (TextView) view.findViewById(R.id.book_description_tv);
swipeRefreshLayout = (SwipeRefreshLayout)view.findViewById(R.id.book_swr);
}

Expand All @@ -112,7 +112,7 @@ public void showData(FullBookModel fullBookModel) {
.placeholder(R.drawable.book_placeholder)
.error(R.drawable.book_placeholder)
.into(coverIv);
desctiptionTv.setText(fullBookModel.getDescription());
descriptionTv.setText(fullBookModel.getDescription());

if (book.isDownloaded()) {
downloadBtn.setVisibility(View.GONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;

import javax.inject.Inject;

Expand Down Expand Up @@ -116,17 +115,16 @@ private void observeChangingBooks() {
}

private void updateBook(Book newBook) {
int bookIndex = 0;
for (ListIterator<Book> it = books.listIterator(); it.hasNext(); ) {
Book book = it.next();
for(int i = 0; i<books.size(); i++){
Book book = books.get(i);
if (book.getId().equals(newBook.getId())) {
bookIndex = it.previousIndex();
books.set(i, newBook);
getView().updateBooksData(books);
getView().notifyItemChanged(i);
break;
}

}
books.set(bookIndex, newBook);
getView().updateBooksData(books);
getView().notifyItemChanged(bookIndex);
}

public void downloadBook(Book book) {
Expand Down

0 comments on commit b5c103c

Please sign in to comment.