mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-27 08:16:36 +03:00
Create empty MangaCatalogue
This commit is contained in:
parent
684c5e98d3
commit
68f1102c40
10 changed files with 136 additions and 8 deletions
|
@ -39,6 +39,15 @@
|
|||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="eu.kanade.mangafeed.ui.activity.MainActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.activity.MangaCatalogueActivity"
|
||||
android:label="@string/title_activity_manga_catalogue"
|
||||
android:parentActivityName=".ui.activity.CatalogueActivity"
|
||||
android:theme="@style/AppTheme" >
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="eu.kanade.mangafeed.ui.activity.CatalogueActivity" />
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
|
|
@ -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();
|
||||
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package eu.kanade.mangafeed.view;
|
||||
|
||||
public interface MangaCatalogueView extends BaseView {
|
||||
void setTitle(String title);
|
||||
}
|
16
app/src/main/res/layout/activity_manga_catalogue.xml
Normal file
16
app/src/main/res/layout/activity_manga_catalogue.xml
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" android:fitsSystemWindows="true"
|
||||
tools:context="eu.kanade.mangafeed.ui.activity.CatalogueActivity">
|
||||
|
||||
<include
|
||||
android:id="@+id/toolbar"
|
||||
layout="@layout/toolbar"/>
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in a new issue