diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index bd15ddba9e..1252175863 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -41,15 +41,6 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="eu.kanade.mangafeed.ui.activity.MainActivity" />
-
-
-
diff --git a/app/src/main/java/eu/kanade/mangafeed/AppComponent.java b/app/src/main/java/eu/kanade/mangafeed/AppComponent.java
index 825ac29ef7..42f9492880 100644
--- a/app/src/main/java/eu/kanade/mangafeed/AppComponent.java
+++ b/app/src/main/java/eu/kanade/mangafeed/AppComponent.java
@@ -8,7 +8,6 @@ import dagger.Component;
import eu.kanade.mangafeed.data.DataModule;
import eu.kanade.mangafeed.presenter.CataloguePresenter;
import eu.kanade.mangafeed.presenter.LibraryPresenter;
-import eu.kanade.mangafeed.presenter.MangaCataloguePresenter;
import eu.kanade.mangafeed.presenter.MangaChaptersPresenter;
import eu.kanade.mangafeed.presenter.MangaDetailPresenter;
import eu.kanade.mangafeed.presenter.MangaInfoPresenter;
@@ -27,7 +26,6 @@ public interface AppComponent {
void inject(MangaDetailPresenter mangaDetailPresenter);
void inject(SourcePresenter sourcePresenter);
void inject(CataloguePresenter cataloguePresenter);
- void inject(MangaCataloguePresenter mangaCataloguePresenter);
void inject(MangaInfoPresenter mangaInfoPresenter);
void inject(MangaChaptersPresenter mangaChaptersPresenter);
diff --git a/app/src/main/java/eu/kanade/mangafeed/presenter/CataloguePresenter.java b/app/src/main/java/eu/kanade/mangafeed/presenter/CataloguePresenter.java
index 35069cc1fc..ce909d7e6c 100644
--- a/app/src/main/java/eu/kanade/mangafeed/presenter/CataloguePresenter.java
+++ b/app/src/main/java/eu/kanade/mangafeed/presenter/CataloguePresenter.java
@@ -1,11 +1,7 @@
package eu.kanade.mangafeed.presenter;
-import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
-import android.widget.ImageView;
-
-import com.bumptech.glide.Glide;
import java.util.ArrayList;
import java.util.List;
@@ -13,13 +9,11 @@ import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
-import de.greenrobot.event.EventBus;
import eu.kanade.mangafeed.data.helpers.DatabaseHelper;
import eu.kanade.mangafeed.data.helpers.SourceManager;
import eu.kanade.mangafeed.data.models.Manga;
import eu.kanade.mangafeed.sources.Source;
import eu.kanade.mangafeed.ui.activity.CatalogueActivity;
-import eu.kanade.mangafeed.ui.activity.MangaCatalogueActivity;
import nucleus.presenter.RxPresenter;
import rx.Observable;
import rx.Subscription;
@@ -135,16 +129,7 @@ public class CataloguePresenter extends RxPresenter {
.onBackpressureBuffer()
.observeOn(AndroidSchedulers.mainThread())
.compose(deliverReplay())
- .subscribe(this.split((view, manga) -> {
- // Get manga index in the adapter
- int index = getMangaIndex(manga);
- // Get the image view associated with the manga.
- // If it's null (not visible in the screen) there's no need to update the image.
- ImageView imageView = view.getImageView(index);
- if (imageView != null) {
- updateImage(imageView, manga.thumbnail_url);
- }
- }));
+ .subscribe(this.split(CatalogueActivity::updateImage));
add(mMangaDetailFetchSubscription);
}
@@ -188,13 +173,6 @@ public class CataloguePresenter extends RxPresenter {
return localManga;
}
- public void onMangaClick(int position) {
- Intent intent = new Intent(getView().getActivity(), MangaCatalogueActivity.class);
- Manga selectedManga = getView().getAdapter().getItem(position);
- EventBus.getDefault().postSticky(selectedManga);
- getView().getActivity().startActivity(intent);
- }
-
public void onQueryTextChange(String query) {
if (mSearchViewPublishSubject != null)
mSearchViewPublishSubject.onNext(Observable.just(query));
@@ -235,20 +213,4 @@ public class CataloguePresenter extends RxPresenter {
mCurrentPage = page;
}
- private int getMangaIndex(Manga manga) {
- for (int i = 0; i < getView().getAdapter().getCount(); i++) {
- if (manga.id == getView().getAdapter().getItem(i).id) {
- return i;
- }
- }
- return -1;
- }
-
- private void updateImage(ImageView imageView, String thumbnail) {
- Glide.with(getView().getActivity())
- .load(thumbnail)
- .centerCrop()
- .into(imageView);
- }
-
}
diff --git a/app/src/main/java/eu/kanade/mangafeed/presenter/MangaCataloguePresenter.java b/app/src/main/java/eu/kanade/mangafeed/presenter/MangaCataloguePresenter.java
deleted file mode 100644
index 72141b24cb..0000000000
--- a/app/src/main/java/eu/kanade/mangafeed/presenter/MangaCataloguePresenter.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package eu.kanade.mangafeed.presenter;
-
-import eu.kanade.mangafeed.ui.activity.MangaCatalogueActivity;
-
-public class MangaCataloguePresenter extends BasePresenter {
-
-}
diff --git a/app/src/main/java/eu/kanade/mangafeed/presenter/MangaDetailPresenter.java b/app/src/main/java/eu/kanade/mangafeed/presenter/MangaDetailPresenter.java
index 0833f067da..c88bf4e042 100644
--- a/app/src/main/java/eu/kanade/mangafeed/presenter/MangaDetailPresenter.java
+++ b/app/src/main/java/eu/kanade/mangafeed/presenter/MangaDetailPresenter.java
@@ -1,26 +1,7 @@
package eu.kanade.mangafeed.presenter;
-import javax.inject.Inject;
-
-import eu.kanade.mangafeed.data.helpers.DatabaseHelper;
-import eu.kanade.mangafeed.data.models.Manga;
import eu.kanade.mangafeed.ui.activity.MangaDetailActivity;
-import eu.kanade.mangafeed.view.MangaDetailView;
public class MangaDetailPresenter extends BasePresenter {
- private MangaDetailView view;
-
- @Inject
- DatabaseHelper db;
-
- public void onEventMainThread(Manga manga) {
- view.loadManga(manga);
- initializeChapters(manga);
- }
-
- public void initializeChapters(Manga manga) {
- db.getChapters(manga)
- .subscribe(view::setChapters);
- }
}
diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/activity/CatalogueActivity.java b/app/src/main/java/eu/kanade/mangafeed/ui/activity/CatalogueActivity.java
index fe39bd2466..480204880e 100644
--- a/app/src/main/java/eu/kanade/mangafeed/ui/activity/CatalogueActivity.java
+++ b/app/src/main/java/eu/kanade/mangafeed/ui/activity/CatalogueActivity.java
@@ -11,10 +11,13 @@ import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ProgressBar;
+import com.bumptech.glide.Glide;
+
import java.util.List;
import butterknife.Bind;
import butterknife.ButterKnife;
+import butterknife.OnItemClick;
import eu.kanade.mangafeed.R;
import eu.kanade.mangafeed.data.models.Manga;
import eu.kanade.mangafeed.presenter.CataloguePresenter;
@@ -58,7 +61,6 @@ public class CatalogueActivity extends BaseActivity {
setupToolbar(toolbar);
initializeAdapter();
- initializeClickListener();
initializeScrollListener();
}
@@ -95,11 +97,12 @@ public class CatalogueActivity extends BaseActivity {
manga_list.setAdapter(adapter);
}
- public void initializeClickListener() {
- manga_list.setOnItemClickListener(
- (parent, view, position, id) ->
- getPresenter().onMangaClick(position)
- );
+ @OnItemClick(R.id.gridView)
+ public void onMangaClick(int position) {
+ Manga selectedManga = adapter.getItem(position);
+
+ Intent intent = MangaDetailActivity.newIntent(this, selectedManga);
+ startActivity(intent);
}
public void initializeScrollListener() {
@@ -139,7 +142,20 @@ public class CatalogueActivity extends BaseActivity {
progress_grid.setVisibility(ProgressBar.GONE);
}
- public ImageView getImageView(int position) {
+ public void onMangasNext(List newMangas) {
+ adapter.addItems(newMangas);
+ }
+
+ private int getMangaIndex(Manga manga) {
+ for (int i = 0; i < adapter.getCount(); i++) {
+ if (manga.id == adapter.getItem(i).id) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ private ImageView getImageView(int position) {
View v = manga_list.getChildAt(position -
manga_list.getFirstVisiblePosition());
@@ -149,7 +165,13 @@ public class CatalogueActivity extends BaseActivity {
return (ImageView) v.findViewById(R.id.catalogue_thumbnail);
}
- public void onMangasNext(List newMangas) {
- adapter.addItems(newMangas);
+ public void updateImage(Manga manga) {
+ ImageView imageView = getImageView(getMangaIndex(manga));
+ if (imageView != null) {
+ Glide.with(this)
+ .load(manga.thumbnail_url)
+ .centerCrop()
+ .into(imageView);
+ }
}
}
diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/activity/MangaCatalogueActivity.java b/app/src/main/java/eu/kanade/mangafeed/ui/activity/MangaCatalogueActivity.java
deleted file mode 100644
index 461b8a7281..0000000000
--- a/app/src/main/java/eu/kanade/mangafeed/ui/activity/MangaCatalogueActivity.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package eu.kanade.mangafeed.ui.activity;
-
-import android.os.Bundle;
-import android.support.v7.widget.Toolbar;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import com.bumptech.glide.Glide;
-import com.bumptech.glide.load.engine.DiskCacheStrategy;
-
-import butterknife.Bind;
-import butterknife.ButterKnife;
-import eu.kanade.mangafeed.R;
-import eu.kanade.mangafeed.data.models.Manga;
-import eu.kanade.mangafeed.presenter.MangaCataloguePresenter;
-import nucleus.factory.RequiresPresenter;
-
-@RequiresPresenter(MangaCataloguePresenter.class)
-public class MangaCatalogueActivity extends BaseActivity {
-
- @Bind(R.id.toolbar) Toolbar toolbar;
-
- @Bind(R.id.manga_artist) TextView mArtist;
- @Bind(R.id.manga_author) TextView mAuthor;
- @Bind(R.id.manga_chapters) TextView mChapters;
- @Bind(R.id.manga_genres) TextView mGenres;
- @Bind(R.id.manga_status) TextView mStatus;
- @Bind(R.id.manga_summary) TextView mDescription;
- @Bind(R.id.manga_cover) ImageView mCover;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_manga_catalogue);
- ButterKnife.bind(this);
-
- setupToolbar(toolbar);
- }
-
- public void setMangaInfo(Manga manga) {
- mArtist.setText(manga.artist);
- mAuthor.setText(manga.author);
- mChapters.setText("0"); // TODO
- mGenres.setText(manga.genre);
- mStatus.setText("Ongoing"); //TODO
- mDescription.setText(manga.description);
-
- Glide.with(getActivity())
- .load(manga.thumbnail_url)
- .diskCacheStrategy(DiskCacheStrategy.RESULT)
- .centerCrop()
- .into(mCover);
- }
-
-
-}