From 684c5e98d33962952254121ebcdecf67c4f25bb6 Mon Sep 17 00:00:00 2001 From: inorichi Date: Wed, 14 Oct 2015 13:39:07 +0200 Subject: [PATCH] Rename classes --- app/src/main/AndroidManifest.xml | 2 +- .../eu/kanade/mangafeed/AppComponent.java | 4 +- .../presenter/CatalogueListPresenter.java | 227 ------------------ .../presenter/CataloguePresenter.java | 215 +++++++++++++++-- .../mangafeed/presenter/SourcePresenter.java | 44 ++++ ...stActivity.java => CatalogueActivity.java} | 12 +- .../mangafeed/ui/activity/MainActivity.java | 4 +- ...ueListHolder.java => CatalogueHolder.java} | 4 +- .../mangafeed/ui/adapter/LibraryAdapter.java | 4 +- ...logueFragment.java => SourceFragment.java} | 16 +- .../mangafeed/view/CatalogueListView.java | 18 -- .../kanade/mangafeed/view/CatalogueView.java | 12 +- .../eu/kanade/mangafeed/view/SourceView.java | 8 + .../res/layout/activity_catalogue_list.xml | 2 +- .../main/res/layout/fragment_catalogue.xml | 2 +- 15 files changed, 287 insertions(+), 287 deletions(-) delete mode 100644 app/src/main/java/eu/kanade/mangafeed/presenter/CatalogueListPresenter.java create mode 100644 app/src/main/java/eu/kanade/mangafeed/presenter/SourcePresenter.java rename app/src/main/java/eu/kanade/mangafeed/ui/activity/{CatalogueListActivity.java => CatalogueActivity.java} (91%) rename app/src/main/java/eu/kanade/mangafeed/ui/adapter/{CatalogueListHolder.java => CatalogueHolder.java} (91%) rename app/src/main/java/eu/kanade/mangafeed/ui/fragment/{CatalogueFragment.java => SourceFragment.java} (78%) delete mode 100644 app/src/main/java/eu/kanade/mangafeed/view/CatalogueListView.java create mode 100644 app/src/main/java/eu/kanade/mangafeed/view/SourceView.java diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7ecbaca6a3..2243c8de4c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -31,7 +31,7 @@ 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 093531a658..377fed8491 100644 --- a/app/src/main/java/eu/kanade/mangafeed/AppComponent.java +++ b/app/src/main/java/eu/kanade/mangafeed/AppComponent.java @@ -6,8 +6,8 @@ import javax.inject.Singleton; import dagger.Component; import eu.kanade.mangafeed.data.DataModule; -import eu.kanade.mangafeed.presenter.CatalogueListPresenter; import eu.kanade.mangafeed.presenter.CataloguePresenter; +import eu.kanade.mangafeed.presenter.SourcePresenter; import eu.kanade.mangafeed.presenter.LibraryPresenter; import eu.kanade.mangafeed.presenter.MangaDetailPresenter; @@ -22,8 +22,8 @@ public interface AppComponent { void inject(LibraryPresenter libraryPresenter); void inject(MangaDetailPresenter mangaDetailPresenter); + void inject(SourcePresenter sourcePresenter); void inject(CataloguePresenter cataloguePresenter); - void inject(CatalogueListPresenter catalogueListPresenter); Application application(); } diff --git a/app/src/main/java/eu/kanade/mangafeed/presenter/CatalogueListPresenter.java b/app/src/main/java/eu/kanade/mangafeed/presenter/CatalogueListPresenter.java deleted file mode 100644 index ba8f1a52b7..0000000000 --- a/app/src/main/java/eu/kanade/mangafeed/presenter/CatalogueListPresenter.java +++ /dev/null @@ -1,227 +0,0 @@ -package eu.kanade.mangafeed.presenter; - -import android.content.Intent; -import android.widget.ImageView; - -import com.bumptech.glide.Glide; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; - -import javax.inject.Inject; - -import eu.kanade.mangafeed.App; -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.adapter.CatalogueListHolder; -import eu.kanade.mangafeed.view.CatalogueListView; -import rx.Observable; -import rx.Subscription; -import rx.android.schedulers.AndroidSchedulers; -import rx.schedulers.Schedulers; -import rx.subjects.PublishSubject; -import timber.log.Timber; -import uk.co.ribot.easyadapter.EasyAdapter; - -public class CatalogueListPresenter extends BasePresenter { - - CatalogueListView view; - EasyAdapter adapter; - Source selectedSource; - - @Inject SourceManager sourceManager; - @Inject DatabaseHelper db; - - private String mSearchName; - private boolean mSearchMode; - private final int SEARCH_TIMEOUT = 1000; - - private Subscription mMangaFetchSubscription; - private Subscription mMangaSearchSubscription; - private Subscription mSearchViewSubscription; - private Subscription mMangaDetailFetchSubscription; - private PublishSubject> mSearchViewPublishSubject; - private PublishSubject>> mMangaDetailPublishSubject; - - - public CatalogueListPresenter(CatalogueListView view) { - this.view = view; - App.getComponent(view.getActivity()).inject(this); - } - - public void initialize() { - initializeSource(); - initializeAdapter(); - initializeSearch(); - initializeMangaDetailsLoader(); - - view.showProgressBar(); - getMangasFromSource(1); - } - - private void initializeSource() { - int sourceId = view.getIntent().getIntExtra(Intent.EXTRA_UID, -1); - selectedSource = sourceManager.get(sourceId); - view.setSourceTitle(selectedSource.getName()); - } - - private void initializeAdapter() { - adapter = new EasyAdapter<>(view.getActivity(), CatalogueListHolder.class); - view.setAdapter(adapter); - view.setScrollListener(); - } - - private void initializeSearch() { - mSearchName = ""; - mSearchMode = false; - mSearchViewPublishSubject = PublishSubject.create(); - - mSearchViewSubscription = Observable.switchOnNext(mSearchViewPublishSubject) - .debounce(SEARCH_TIMEOUT, TimeUnit.MILLISECONDS) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe( - this::queryFromSearch, - error -> Timber.e(error.getCause(), error.getMessage())); - - subscriptions.add(mSearchViewSubscription); - } - - private void initializeMangaDetailsLoader() { - mMangaDetailPublishSubject = PublishSubject.create(); - - mMangaDetailFetchSubscription = Observable.switchOnNext(mMangaDetailPublishSubject) - .subscribeOn(Schedulers.io()) - .flatMap(Observable::from) - .filter(manga -> !manga.initialized) - .buffer(3) - .concatMap(localMangas -> { - List> mangaObservables = new ArrayList<>(); - for (Manga manga : localMangas) { - Observable tempObs = selectedSource.pullMangaFromNetwork(manga.url) - .subscribeOn(Schedulers.io()) - .flatMap(networkManga -> { - Manga.copyFromNetwork(manga, networkManga); - db.insertMangaBlock(manga); - return Observable.just(manga); - }); - mangaObservables.add(tempObs); - } - return Observable.merge(mangaObservables); - }) - .filter(manga -> manga.initialized) - .onBackpressureBuffer() - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(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); - } - }); - - subscriptions.add(mMangaDetailFetchSubscription); - } - - public void getMangasFromSource(int page) { - subscriptions.remove(mMangaFetchSubscription); - - mMangaFetchSubscription = getMangasSubscriber( - selectedSource.pullPopularMangasFromNetwork(page)); - - subscriptions.add(mMangaFetchSubscription); - } - - public void getMangasFromSearch(int page) { - subscriptions.remove(mMangaSearchSubscription); - - mMangaSearchSubscription = getMangasSubscriber( - selectedSource.searchMangasFromNetwork(mSearchName, page)); - - subscriptions.add(mMangaSearchSubscription); - } - - private Subscription getMangasSubscriber(Observable> mangas) { - return mangas - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .flatMap(Observable::from) - .map(this::networkToLocalManga) - .toList() - .subscribe(newMangas -> { - view.hideProgressBar(); - adapter.addItems(newMangas); - if (mMangaDetailPublishSubject != null) - mMangaDetailPublishSubject.onNext(Observable.just(newMangas)); - }); - } - - private Manga networkToLocalManga(Manga networkManga) { - Manga localManga = db.getMangaBlock(networkManga.url); - if (localManga == null) { - db.insertMangaBlock(networkManga); - localManga = db.getMangaBlock(networkManga.url); - } - return localManga; - } - - public void onQueryTextChange(String query) { - if (mSearchViewPublishSubject != null) - mSearchViewPublishSubject.onNext(Observable.just(query)); - } - - private void queryFromSearch(String query) { - // If search button clicked - if (mSearchName.equals("") && query.equals("")) { - return; - } - // If going to search mode - else if (mSearchName.equals("") && !query.equals("")) { - mSearchMode = true; - } - // If going to normal mode - else if (!mSearchName.equals("") && query.equals("")) { - mSearchMode = false; - } - - mSearchName = query; - adapter.getItems().clear(); - view.showProgressBar(); - view.resetScrollListener(); - loadMoreMangas(1); - } - - public void loadMoreMangas(int page) { - if (page > 1) { - view.showGridProgressBar(); - } - if (mSearchMode) { - getMangasFromSearch(page); - } else { - getMangasFromSource(page); - } - } - - 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 void updateImage(ImageView imageView, String thumbnail) { - Glide.with(view.getActivity()) - .load(thumbnail) - .centerCrop() - .into(imageView); - } - -} 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 5f28b625ae..a9da3ada4b 100644 --- a/app/src/main/java/eu/kanade/mangafeed/presenter/CataloguePresenter.java +++ b/app/src/main/java/eu/kanade/mangafeed/presenter/CataloguePresenter.java @@ -1,44 +1,227 @@ package eu.kanade.mangafeed.presenter; import android.content.Intent; +import android.widget.ImageView; + +import com.bumptech.glide.Glide; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; import javax.inject.Inject; import eu.kanade.mangafeed.App; +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.CatalogueListActivity; -import eu.kanade.mangafeed.ui.adapter.SourceHolder; +import eu.kanade.mangafeed.ui.adapter.CatalogueHolder; import eu.kanade.mangafeed.view.CatalogueView; +import rx.Observable; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; +import rx.subjects.PublishSubject; +import timber.log.Timber; import uk.co.ribot.easyadapter.EasyAdapter; +public class CataloguePresenter extends BasePresenter { -public class CataloguePresenter { - - private CatalogueView view; + CatalogueView view; + EasyAdapter adapter; + Source selectedSource; @Inject SourceManager sourceManager; + @Inject DatabaseHelper db; + + private String mSearchName; + private boolean mSearchMode; + private final int SEARCH_TIMEOUT = 1000; + + private Subscription mMangaFetchSubscription; + private Subscription mMangaSearchSubscription; + private Subscription mSearchViewSubscription; + private Subscription mMangaDetailFetchSubscription; + private PublishSubject> mSearchViewPublishSubject; + private PublishSubject>> mMangaDetailPublishSubject; - EasyAdapter adapter; public CataloguePresenter(CatalogueView view) { this.view = view; App.getComponent(view.getActivity()).inject(this); } - public void initializeSources() { - adapter = new EasyAdapter<>( - view.getActivity(), - SourceHolder.class, - sourceManager.getSources()); + public void initialize() { + initializeSource(); + initializeAdapter(); + initializeSearch(); + initializeMangaDetailsLoader(); + view.showProgressBar(); + getMangasFromSource(1); + } + + private void initializeSource() { + int sourceId = view.getIntent().getIntExtra(Intent.EXTRA_UID, -1); + selectedSource = sourceManager.get(sourceId); + view.setSourceTitle(selectedSource.getName()); + } + + private void initializeAdapter() { + adapter = new EasyAdapter<>(view.getActivity(), CatalogueHolder.class); view.setAdapter(adapter); - view.setSourceClickListener(); + view.setScrollListener(); } - public void onSourceClick(int position) { - Intent intent = new Intent(view.getActivity(), CatalogueListActivity.class); - intent.putExtra(Intent.EXTRA_UID, adapter.getItem(position).getSource()); - view.getActivity().startActivity(intent); + private void initializeSearch() { + mSearchName = ""; + mSearchMode = false; + mSearchViewPublishSubject = PublishSubject.create(); + + mSearchViewSubscription = Observable.switchOnNext(mSearchViewPublishSubject) + .debounce(SEARCH_TIMEOUT, TimeUnit.MILLISECONDS) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe( + this::queryFromSearch, + error -> Timber.e(error.getCause(), error.getMessage())); + + subscriptions.add(mSearchViewSubscription); } + + private void initializeMangaDetailsLoader() { + mMangaDetailPublishSubject = PublishSubject.create(); + + mMangaDetailFetchSubscription = Observable.switchOnNext(mMangaDetailPublishSubject) + .subscribeOn(Schedulers.io()) + .flatMap(Observable::from) + .filter(manga -> !manga.initialized) + .buffer(3) + .concatMap(localMangas -> { + List> mangaObservables = new ArrayList<>(); + for (Manga manga : localMangas) { + Observable tempObs = selectedSource.pullMangaFromNetwork(manga.url) + .subscribeOn(Schedulers.io()) + .flatMap(networkManga -> { + Manga.copyFromNetwork(manga, networkManga); + db.insertMangaBlock(manga); + return Observable.just(manga); + }); + mangaObservables.add(tempObs); + } + return Observable.merge(mangaObservables); + }) + .filter(manga -> manga.initialized) + .onBackpressureBuffer() + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(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); + } + }); + + subscriptions.add(mMangaDetailFetchSubscription); + } + + public void getMangasFromSource(int page) { + subscriptions.remove(mMangaFetchSubscription); + + mMangaFetchSubscription = getMangasSubscriber( + selectedSource.pullPopularMangasFromNetwork(page)); + + subscriptions.add(mMangaFetchSubscription); + } + + public void getMangasFromSearch(int page) { + subscriptions.remove(mMangaSearchSubscription); + + mMangaSearchSubscription = getMangasSubscriber( + selectedSource.searchMangasFromNetwork(mSearchName, page)); + + subscriptions.add(mMangaSearchSubscription); + } + + private Subscription getMangasSubscriber(Observable> mangas) { + return mangas + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .flatMap(Observable::from) + .map(this::networkToLocalManga) + .toList() + .subscribe(newMangas -> { + view.hideProgressBar(); + adapter.addItems(newMangas); + if (mMangaDetailPublishSubject != null) + mMangaDetailPublishSubject.onNext(Observable.just(newMangas)); + }); + } + + private Manga networkToLocalManga(Manga networkManga) { + Manga localManga = db.getMangaBlock(networkManga.url); + if (localManga == null) { + db.insertMangaBlock(networkManga); + localManga = db.getMangaBlock(networkManga.url); + } + return localManga; + } + + public void onQueryTextChange(String query) { + if (mSearchViewPublishSubject != null) + mSearchViewPublishSubject.onNext(Observable.just(query)); + } + + private void queryFromSearch(String query) { + // If search button clicked + if (mSearchName.equals("") && query.equals("")) { + return; + } + // If going to search mode + else if (mSearchName.equals("") && !query.equals("")) { + mSearchMode = true; + } + // If going to normal mode + else if (!mSearchName.equals("") && query.equals("")) { + mSearchMode = false; + } + + mSearchName = query; + adapter.getItems().clear(); + view.showProgressBar(); + view.resetScrollListener(); + loadMoreMangas(1); + } + + public void loadMoreMangas(int page) { + if (page > 1) { + view.showGridProgressBar(); + } + if (mSearchMode) { + getMangasFromSearch(page); + } else { + getMangasFromSource(page); + } + } + + 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 void updateImage(ImageView imageView, String thumbnail) { + Glide.with(view.getActivity()) + .load(thumbnail) + .centerCrop() + .into(imageView); + } + } diff --git a/app/src/main/java/eu/kanade/mangafeed/presenter/SourcePresenter.java b/app/src/main/java/eu/kanade/mangafeed/presenter/SourcePresenter.java new file mode 100644 index 0000000000..edd9294e0b --- /dev/null +++ b/app/src/main/java/eu/kanade/mangafeed/presenter/SourcePresenter.java @@ -0,0 +1,44 @@ +package eu.kanade.mangafeed.presenter; + +import android.content.Intent; + +import javax.inject.Inject; + +import eu.kanade.mangafeed.App; +import eu.kanade.mangafeed.data.helpers.SourceManager; +import eu.kanade.mangafeed.sources.Source; +import eu.kanade.mangafeed.ui.activity.CatalogueActivity; +import eu.kanade.mangafeed.ui.adapter.SourceHolder; +import eu.kanade.mangafeed.view.SourceView; +import uk.co.ribot.easyadapter.EasyAdapter; + + +public class SourcePresenter { + + private SourceView view; + + @Inject SourceManager sourceManager; + + EasyAdapter adapter; + + public SourcePresenter(SourceView view) { + this.view = view; + App.getComponent(view.getActivity()).inject(this); + } + + public void initializeSources() { + adapter = new EasyAdapter<>( + view.getActivity(), + SourceHolder.class, + sourceManager.getSources()); + + view.setAdapter(adapter); + view.setSourceClickListener(); + } + + public void onSourceClick(int position) { + Intent intent = new Intent(view.getActivity(), CatalogueActivity.class); + intent.putExtra(Intent.EXTRA_UID, adapter.getItem(position).getSource()); + view.getActivity().startActivity(intent); + } +} diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/activity/CatalogueListActivity.java b/app/src/main/java/eu/kanade/mangafeed/ui/activity/CatalogueActivity.java similarity index 91% rename from app/src/main/java/eu/kanade/mangafeed/ui/activity/CatalogueListActivity.java rename to app/src/main/java/eu/kanade/mangafeed/ui/activity/CatalogueActivity.java index 977eb369a5..c4258bdd5f 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/activity/CatalogueListActivity.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/activity/CatalogueActivity.java @@ -12,12 +12,12 @@ import android.widget.ProgressBar; import butterknife.Bind; import butterknife.ButterKnife; import eu.kanade.mangafeed.R; -import eu.kanade.mangafeed.presenter.CatalogueListPresenter; -import eu.kanade.mangafeed.view.CatalogueListView; +import eu.kanade.mangafeed.presenter.CataloguePresenter; +import eu.kanade.mangafeed.view.CatalogueView; import eu.kanade.mangafeed.widget.EndlessScrollListener; import uk.co.ribot.easyadapter.EasyAdapter; -public class CatalogueListActivity extends BaseActivity implements CatalogueListView { +public class CatalogueActivity extends BaseActivity implements CatalogueView { @Bind(R.id.toolbar) Toolbar toolbar; @@ -31,7 +31,7 @@ public class CatalogueListActivity extends BaseActivity implements CatalogueList @Bind(R.id.progress_grid) ProgressBar progress_grid; - private CatalogueListPresenter presenter; + private CataloguePresenter presenter; private EndlessScrollListener scrollListener; @@ -43,7 +43,7 @@ public class CatalogueListActivity extends BaseActivity implements CatalogueList setupToolbar(toolbar); - presenter = new CatalogueListPresenter(this); + presenter = new CataloguePresenter(this); presenter.initialize(); } @@ -77,7 +77,7 @@ public class CatalogueListActivity extends BaseActivity implements CatalogueList }); } - // CatalogueListView + // CatalogueView @Override public void setSourceTitle(String title) { diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/activity/MainActivity.java b/app/src/main/java/eu/kanade/mangafeed/ui/activity/MainActivity.java index 42d3929fd5..90f0a7d004 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/activity/MainActivity.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/activity/MainActivity.java @@ -13,7 +13,7 @@ import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; import butterknife.Bind; import butterknife.ButterKnife; import eu.kanade.mangafeed.R; -import eu.kanade.mangafeed.ui.fragment.CatalogueFragment; +import eu.kanade.mangafeed.ui.fragment.SourceFragment; import eu.kanade.mangafeed.ui.fragment.LibraryFragment; public class MainActivity extends BaseActivity { @@ -65,7 +65,7 @@ public class MainActivity extends BaseActivity { case R.id.nav_drawer_recent_updates: break; case R.id.nav_drawer_catalogues: - setFragment(CatalogueFragment.newInstance()); + setFragment(SourceFragment.newInstance()); break; case R.id.nav_drawer_settings: break; diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/adapter/CatalogueListHolder.java b/app/src/main/java/eu/kanade/mangafeed/ui/adapter/CatalogueHolder.java similarity index 91% rename from app/src/main/java/eu/kanade/mangafeed/ui/adapter/CatalogueListHolder.java rename to app/src/main/java/eu/kanade/mangafeed/ui/adapter/CatalogueHolder.java index 435d5c0629..461e92b88f 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/adapter/CatalogueListHolder.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/adapter/CatalogueHolder.java @@ -15,7 +15,7 @@ import uk.co.ribot.easyadapter.annotations.LayoutId; import uk.co.ribot.easyadapter.annotations.ViewId; @LayoutId(R.layout.item_catalogue) -public class CatalogueListHolder extends ItemViewHolder { +public class CatalogueHolder extends ItemViewHolder { @ViewId(R.id.catalogue_title) TextView title; @@ -23,7 +23,7 @@ public class CatalogueListHolder extends ItemViewHolder { @ViewId(R.id.catalogue_thumbnail) ImageView image; - public CatalogueListHolder(View view) { + public CatalogueHolder(View view) { super(view); } diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/adapter/LibraryAdapter.java b/app/src/main/java/eu/kanade/mangafeed/ui/adapter/LibraryAdapter.java index 3ab091eb83..9e9cd0aebd 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/adapter/LibraryAdapter.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/adapter/LibraryAdapter.java @@ -17,7 +17,7 @@ public class LibraryAdapter extends EasyAdapter implements Filterable { public LibraryAdapter(Context context) { super(context, LibraryHolder.class); - filter = new CatalogueFilter(); + filter = new LibraryFilter(); } public void setNewItems(List list) { @@ -30,7 +30,7 @@ public class LibraryAdapter extends EasyAdapter implements Filterable { return filter; } - private class CatalogueFilter extends Filter { + private class LibraryFilter extends Filter { @Override protected FilterResults performFiltering(CharSequence charSequence) { FilterResults results = new FilterResults(); diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/fragment/CatalogueFragment.java b/app/src/main/java/eu/kanade/mangafeed/ui/fragment/SourceFragment.java similarity index 78% rename from app/src/main/java/eu/kanade/mangafeed/ui/fragment/CatalogueFragment.java rename to app/src/main/java/eu/kanade/mangafeed/ui/fragment/SourceFragment.java index f05a91e5af..03731cf66f 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/fragment/CatalogueFragment.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/fragment/SourceFragment.java @@ -9,22 +9,22 @@ import android.widget.ListView; import butterknife.Bind; import butterknife.ButterKnife; import eu.kanade.mangafeed.R; -import eu.kanade.mangafeed.presenter.CataloguePresenter; +import eu.kanade.mangafeed.presenter.SourcePresenter; import eu.kanade.mangafeed.ui.activity.MainActivity; -import eu.kanade.mangafeed.view.CatalogueView; +import eu.kanade.mangafeed.view.SourceView; import uk.co.ribot.easyadapter.EasyAdapter; -public class CatalogueFragment extends BaseFragment implements CatalogueView { +public class SourceFragment extends BaseFragment implements SourceView { - private CataloguePresenter presenter; + private SourcePresenter presenter; private MainActivity activity; @Bind(R.id.catalogue_list) ListView source_list; - public static CatalogueFragment newInstance() { - CatalogueFragment fragment = new CatalogueFragment(); + public static SourceFragment newInstance() { + SourceFragment fragment = new SourceFragment(); Bundle args = new Bundle(); fragment.setArguments(args); return fragment; @@ -34,7 +34,7 @@ public class CatalogueFragment extends BaseFragment implements CatalogueView { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - presenter = new CataloguePresenter(this); + presenter = new SourcePresenter(this); activity = (MainActivity)getActivity(); } @@ -50,7 +50,7 @@ public class CatalogueFragment extends BaseFragment implements CatalogueView { return view; } - // CatalogueView + // SourceView @Override public void setAdapter(EasyAdapter adapter) { diff --git a/app/src/main/java/eu/kanade/mangafeed/view/CatalogueListView.java b/app/src/main/java/eu/kanade/mangafeed/view/CatalogueListView.java deleted file mode 100644 index 6a1aa9949c..0000000000 --- a/app/src/main/java/eu/kanade/mangafeed/view/CatalogueListView.java +++ /dev/null @@ -1,18 +0,0 @@ -package eu.kanade.mangafeed.view; - -import android.content.Intent; -import android.widget.ImageView; - -import uk.co.ribot.easyadapter.EasyAdapter; - -public interface CatalogueListView extends BaseView { - Intent getIntent(); - void setSourceTitle(String title); - void setAdapter(EasyAdapter adapter); - void setScrollListener(); - void resetScrollListener(); - void showProgressBar(); - void showGridProgressBar(); - void hideProgressBar(); - ImageView getImageView(int position); -} diff --git a/app/src/main/java/eu/kanade/mangafeed/view/CatalogueView.java b/app/src/main/java/eu/kanade/mangafeed/view/CatalogueView.java index 8b15f42175..2dc691c78a 100644 --- a/app/src/main/java/eu/kanade/mangafeed/view/CatalogueView.java +++ b/app/src/main/java/eu/kanade/mangafeed/view/CatalogueView.java @@ -1,8 +1,18 @@ package eu.kanade.mangafeed.view; +import android.content.Intent; +import android.widget.ImageView; + import uk.co.ribot.easyadapter.EasyAdapter; public interface CatalogueView extends BaseView { + Intent getIntent(); + void setSourceTitle(String title); void setAdapter(EasyAdapter adapter); - void setSourceClickListener(); + void setScrollListener(); + void resetScrollListener(); + void showProgressBar(); + void showGridProgressBar(); + void hideProgressBar(); + ImageView getImageView(int position); } diff --git a/app/src/main/java/eu/kanade/mangafeed/view/SourceView.java b/app/src/main/java/eu/kanade/mangafeed/view/SourceView.java new file mode 100644 index 0000000000..ca0f773cdc --- /dev/null +++ b/app/src/main/java/eu/kanade/mangafeed/view/SourceView.java @@ -0,0 +1,8 @@ +package eu.kanade.mangafeed.view; + +import uk.co.ribot.easyadapter.EasyAdapter; + +public interface SourceView extends BaseView { + void setAdapter(EasyAdapter adapter); + void setSourceClickListener(); +} diff --git a/app/src/main/res/layout/activity_catalogue_list.xml b/app/src/main/res/layout/activity_catalogue_list.xml index 9442f64c91..3d9d53f2eb 100644 --- a/app/src/main/res/layout/activity_catalogue_list.xml +++ b/app/src/main/res/layout/activity_catalogue_list.xml @@ -5,7 +5,7 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" - tools:context="eu.kanade.mangafeed.ui.activity.CatalogueListActivity"> + tools:context="eu.kanade.mangafeed.ui.activity.CatalogueActivity"> + tools:context="eu.kanade.mangafeed.ui.fragment.SourceFragment">