From 68f1102c40690aecf30f99fb4cb28632666b3662 Mon Sep 17 00:00:00 2001 From: inorichi Date: Thu, 15 Oct 2015 01:51:35 +0200 Subject: [PATCH] Create empty MangaCatalogue --- app/src/main/AndroidManifest.xml | 9 ++++ .../eu/kanade/mangafeed/AppComponent.java | 3 ++ .../presenter/CataloguePresenter.java | 12 ++++- .../presenter/MangaCataloguePresenter.java | 29 ++++++++++++ .../ui/activity/CatalogueActivity.java | 20 +++++--- .../ui/activity/MangaCatalogueActivity.java | 47 +++++++++++++++++++ .../kanade/mangafeed/view/CatalogueView.java | 3 +- .../mangafeed/view/MangaCatalogueView.java | 5 ++ ...alogue_list.xml => activity_catalogue.xml} | 0 .../res/layout/activity_manga_catalogue.xml | 16 +++++++ 10 files changed, 136 insertions(+), 8 deletions(-) create mode 100644 app/src/main/java/eu/kanade/mangafeed/presenter/MangaCataloguePresenter.java create mode 100644 app/src/main/java/eu/kanade/mangafeed/ui/activity/MangaCatalogueActivity.java create mode 100644 app/src/main/java/eu/kanade/mangafeed/view/MangaCatalogueView.java rename app/src/main/res/layout/{activity_catalogue_list.xml => activity_catalogue.xml} (100%) create mode 100644 app/src/main/res/layout/activity_manga_catalogue.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2243c8de4..a6a08d1aa 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -39,6 +39,15 @@ 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 377fed849..204e41f52 100644 --- a/app/src/main/java/eu/kanade/mangafeed/AppComponent.java +++ b/app/src/main/java/eu/kanade/mangafeed/AppComponent.java @@ -7,6 +7,7 @@ import javax.inject.Singleton; import dagger.Component; import eu.kanade.mangafeed.data.DataModule; import eu.kanade.mangafeed.presenter.CataloguePresenter; +import eu.kanade.mangafeed.presenter.MangaCataloguePresenter; import eu.kanade.mangafeed.presenter.SourcePresenter; import eu.kanade.mangafeed.presenter.LibraryPresenter; import eu.kanade.mangafeed.presenter.MangaDetailPresenter; @@ -24,6 +25,8 @@ public interface AppComponent { void inject(MangaDetailPresenter mangaDetailPresenter); void inject(SourcePresenter sourcePresenter); void inject(CataloguePresenter cataloguePresenter); + void inject(MangaCataloguePresenter mangaCataloguePresenter); Application application(); + } 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 a9da3ada4..6f989bce8 100644 --- a/app/src/main/java/eu/kanade/mangafeed/presenter/CataloguePresenter.java +++ b/app/src/main/java/eu/kanade/mangafeed/presenter/CataloguePresenter.java @@ -11,11 +11,13 @@ import java.util.concurrent.TimeUnit; import javax.inject.Inject; +import de.greenrobot.event.EventBus; 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.MangaCatalogueActivity; import eu.kanade.mangafeed.ui.adapter.CatalogueHolder; import eu.kanade.mangafeed.view.CatalogueView; import rx.Observable; @@ -65,13 +67,14 @@ public class CataloguePresenter extends BasePresenter { private void initializeSource() { int sourceId = view.getIntent().getIntExtra(Intent.EXTRA_UID, -1); selectedSource = sourceManager.get(sourceId); - view.setSourceTitle(selectedSource.getName()); + view.setTitle(selectedSource.getName()); } private void initializeAdapter() { adapter = new EasyAdapter<>(view.getActivity(), CatalogueHolder.class); view.setAdapter(adapter); view.setScrollListener(); + view.setMangaClickListener(); } private void initializeSearch() { @@ -171,6 +174,13 @@ public class CataloguePresenter extends BasePresenter { return localManga; } + public void onMangaClick(int position) { + Intent intent = new Intent(view.getActivity(), MangaCatalogueActivity.class); + Manga selectedManga = adapter.getItem(position); + EventBus.getDefault().postSticky(selectedManga); + view.getActivity().startActivity(intent); + } + public void onQueryTextChange(String query) { if (mSearchViewPublishSubject != null) mSearchViewPublishSubject.onNext(Observable.just(query)); diff --git a/app/src/main/java/eu/kanade/mangafeed/presenter/MangaCataloguePresenter.java b/app/src/main/java/eu/kanade/mangafeed/presenter/MangaCataloguePresenter.java new file mode 100644 index 000000000..9505bb94d --- /dev/null +++ b/app/src/main/java/eu/kanade/mangafeed/presenter/MangaCataloguePresenter.java @@ -0,0 +1,29 @@ +package eu.kanade.mangafeed.presenter; + +import eu.kanade.mangafeed.App; +import eu.kanade.mangafeed.data.models.Manga; +import eu.kanade.mangafeed.view.MangaCatalogueView; + +public class MangaCataloguePresenter extends BasePresenter { + + private MangaCatalogueView view; + private Manga manga; + + public MangaCataloguePresenter(MangaCatalogueView view) { + this.view = view; + App.getComponent(view.getActivity()).inject(this); + } + + public void initialize() { + + } + + public void onEventMainThread(Manga manga) { + this.manga = manga; + initializeManga(); + } + + private void initializeManga() { + view.setTitle(manga.title); + } +} 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 c4258bdd5..15a138905 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 @@ -33,12 +33,12 @@ public class CatalogueActivity extends BaseActivity implements CatalogueView { private CataloguePresenter presenter; - private EndlessScrollListener scrollListener; + private EndlessScrollListener scroll_listener; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_catalogue_list); + setContentView(R.layout.activity_catalogue); ButterKnife.bind(this); setupToolbar(toolbar); @@ -80,7 +80,7 @@ public class CatalogueActivity extends BaseActivity implements CatalogueView { // CatalogueView @Override - public void setSourceTitle(String title) { + public void setTitle(String title) { setToolbarTitle(title); } @@ -89,9 +89,17 @@ public class CatalogueActivity extends BaseActivity implements CatalogueView { manga_list.setAdapter(adapter); } + @Override + public void setMangaClickListener() { + manga_list.setOnItemClickListener( + (parent, view, position, id) -> + presenter.onMangaClick(position) + ); + } + @Override public void setScrollListener() { - scrollListener = new EndlessScrollListener() { + scroll_listener = new EndlessScrollListener() { @Override public boolean onLoadMore(int page, int totalItemsCount) { presenter.loadMoreMangas(page); @@ -99,12 +107,12 @@ public class CatalogueActivity extends BaseActivity implements CatalogueView { } }; - manga_list.setOnScrollListener(scrollListener); + manga_list.setOnScrollListener(scroll_listener); } @Override public void resetScrollListener() { - scrollListener.resetScroll(); + scroll_listener.resetScroll(); } @Override 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 new file mode 100644 index 000000000..44a6915d0 --- /dev/null +++ b/app/src/main/java/eu/kanade/mangafeed/ui/activity/MangaCatalogueActivity.java @@ -0,0 +1,47 @@ +package eu.kanade.mangafeed.ui.activity; + +import android.os.Bundle; +import android.support.v7.widget.Toolbar; + +import butterknife.Bind; +import butterknife.ButterKnife; +import eu.kanade.mangafeed.R; +import eu.kanade.mangafeed.presenter.MangaCataloguePresenter; +import eu.kanade.mangafeed.view.MangaCatalogueView; + +public class MangaCatalogueActivity extends BaseActivity implements MangaCatalogueView { + + @Bind(R.id.toolbar) + Toolbar toolbar; + + private MangaCataloguePresenter presenter; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_manga_catalogue); + ButterKnife.bind(this); + + setupToolbar(toolbar); + + presenter = new MangaCataloguePresenter(this); + presenter.initialize(); + } + + @Override + public void onStart() { + super.onStart(); + presenter.registerForStickyEvents(); + } + + @Override + public void onStop() { + presenter.unregisterForEvents(); + super.onStop(); + } + + @Override + public void setTitle(String title) { + setToolbarTitle(title); + } +} 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 2dc691c78..2fe9299a8 100644 --- a/app/src/main/java/eu/kanade/mangafeed/view/CatalogueView.java +++ b/app/src/main/java/eu/kanade/mangafeed/view/CatalogueView.java @@ -7,8 +7,9 @@ import uk.co.ribot.easyadapter.EasyAdapter; public interface CatalogueView extends BaseView { Intent getIntent(); - void setSourceTitle(String title); + void setTitle(String title); void setAdapter(EasyAdapter adapter); + void setMangaClickListener(); void setScrollListener(); void resetScrollListener(); void showProgressBar(); diff --git a/app/src/main/java/eu/kanade/mangafeed/view/MangaCatalogueView.java b/app/src/main/java/eu/kanade/mangafeed/view/MangaCatalogueView.java new file mode 100644 index 000000000..d31db7078 --- /dev/null +++ b/app/src/main/java/eu/kanade/mangafeed/view/MangaCatalogueView.java @@ -0,0 +1,5 @@ +package eu.kanade.mangafeed.view; + +public interface MangaCatalogueView extends BaseView { + void setTitle(String title); +} diff --git a/app/src/main/res/layout/activity_catalogue_list.xml b/app/src/main/res/layout/activity_catalogue.xml similarity index 100% rename from app/src/main/res/layout/activity_catalogue_list.xml rename to app/src/main/res/layout/activity_catalogue.xml diff --git a/app/src/main/res/layout/activity_manga_catalogue.xml b/app/src/main/res/layout/activity_manga_catalogue.xml new file mode 100644 index 000000000..c61734fa6 --- /dev/null +++ b/app/src/main/res/layout/activity_manga_catalogue.xml @@ -0,0 +1,16 @@ + + + + + + + + \ No newline at end of file