mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-26 05:51:30 +00:00
Create presenter and view for CatalogueList
This commit is contained in:
parent
18be01e4c5
commit
381bedf68d
5 changed files with 55 additions and 9 deletions
|
@ -6,6 +6,7 @@ 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.LibraryPresenter;
|
||||
import eu.kanade.mangafeed.presenter.MangaDetailPresenter;
|
||||
|
@ -25,6 +26,7 @@ public interface AppComponent {
|
|||
void inject(LibraryPresenter libraryPresenter);
|
||||
void inject(MangaDetailPresenter mangaDetailPresenter);
|
||||
void inject(CataloguePresenter cataloguePresenter);
|
||||
void inject(CatalogueListPresenter catalogueListPresenter);
|
||||
|
||||
Application application();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
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.view.CatalogueListView;
|
||||
|
||||
public class CatalogueListPresenter {
|
||||
|
||||
CatalogueListView view;
|
||||
|
||||
@Inject SourceManager sourceManager;
|
||||
|
||||
public CatalogueListPresenter(CatalogueListView view) {
|
||||
this.view = view;
|
||||
App.getComponent(view.getActivity()).inject(this);
|
||||
}
|
||||
|
||||
public void initializeSource() {
|
||||
Intent intent = view.getIntent();
|
||||
int sourceId = intent.getIntExtra(Intent.EXTRA_UID, -1);
|
||||
view.setSource(sourceManager.get(sourceId));
|
||||
}
|
||||
}
|
|
@ -1,23 +1,23 @@
|
|||
package eu.kanade.mangafeed.ui.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
import eu.kanade.mangafeed.R;
|
||||
import eu.kanade.mangafeed.presenter.CatalogueListPresenter;
|
||||
import eu.kanade.mangafeed.sources.Source;
|
||||
import eu.kanade.mangafeed.view.CatalogueListView;
|
||||
|
||||
public class CatalogueListActivity extends BaseActivity {
|
||||
public class CatalogueListActivity extends BaseActivity implements CatalogueListView {
|
||||
|
||||
@Bind(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
|
||||
private CatalogueListPresenter presenter;
|
||||
private Source source;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -25,6 +25,14 @@ public class CatalogueListActivity extends BaseActivity {
|
|||
ButterKnife.bind(this);
|
||||
|
||||
setupToolbar(toolbar);
|
||||
|
||||
presenter = new CatalogueListPresenter(this);
|
||||
presenter.initializeSource();
|
||||
}
|
||||
|
||||
|
||||
public void setSource(Source source) {
|
||||
this.source = source;
|
||||
setToolbarTitle(source.getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -47,7 +47,6 @@ public class CatalogueFragment extends BaseFragment implements CatalogueView {
|
|||
ButterKnife.bind(this, view);
|
||||
|
||||
presenter.initializeSources();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package eu.kanade.mangafeed.view;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
import eu.kanade.mangafeed.sources.Source;
|
||||
|
||||
public interface CatalogueListView extends BaseView {
|
||||
Intent getIntent();
|
||||
void setSource(Source source);
|
||||
}
|
Loading…
Reference in a new issue