|
@@ -14,6 +14,7 @@ import javax.inject.Inject;
|
|
|
|
|
|
import butterknife.Bind;
|
|
|
import butterknife.ButterKnife;
|
|
|
+import de.greenrobot.event.EventBus;
|
|
|
import eu.kanade.tachiyomi.App;
|
|
|
import eu.kanade.tachiyomi.R;
|
|
|
import eu.kanade.tachiyomi.data.database.models.Manga;
|
|
@@ -30,21 +31,21 @@ public class MangaActivity extends BaseRxActivity<MangaPresenter> {
|
|
|
|
|
|
@Bind(R.id.toolbar) Toolbar toolbar;
|
|
|
@Bind(R.id.tabs) TabLayout tabs;
|
|
|
- @Bind(R.id.view_pager) ViewPager view_pager;
|
|
|
+ @Bind(R.id.view_pager) ViewPager viewPager;
|
|
|
|
|
|
@Inject PreferencesHelper preferences;
|
|
|
@Inject MangaSyncManager mangaSyncManager;
|
|
|
|
|
|
private MangaDetailAdapter adapter;
|
|
|
- private long manga_id;
|
|
|
- private boolean is_online;
|
|
|
+ private boolean isOnline;
|
|
|
|
|
|
- public final static String MANGA_ID = "manga_id";
|
|
|
public final static String MANGA_ONLINE = "manga_online";
|
|
|
|
|
|
public static Intent newIntent(Context context, Manga manga) {
|
|
|
Intent intent = new Intent(context, MangaActivity.class);
|
|
|
- intent.putExtra(MANGA_ID, manga.id);
|
|
|
+ if (manga != null) {
|
|
|
+ EventBus.getDefault().postSticky(manga);
|
|
|
+ }
|
|
|
return intent;
|
|
|
}
|
|
|
|
|
@@ -59,23 +60,19 @@ public class MangaActivity extends BaseRxActivity<MangaPresenter> {
|
|
|
|
|
|
Intent intent = getIntent();
|
|
|
|
|
|
- manga_id = intent.getLongExtra(MANGA_ID, -1);
|
|
|
- is_online = intent.getBooleanExtra(MANGA_ONLINE, false);
|
|
|
+ isOnline = intent.getBooleanExtra(MANGA_ONLINE, false);
|
|
|
|
|
|
setupViewPager();
|
|
|
-
|
|
|
- if (savedState == null)
|
|
|
- getPresenter().queryManga(manga_id);
|
|
|
}
|
|
|
|
|
|
private void setupViewPager() {
|
|
|
adapter = new MangaDetailAdapter(getSupportFragmentManager(), this);
|
|
|
|
|
|
- view_pager.setAdapter(adapter);
|
|
|
- tabs.setupWithViewPager(view_pager);
|
|
|
+ viewPager.setAdapter(adapter);
|
|
|
+ tabs.setupWithViewPager(viewPager);
|
|
|
|
|
|
- if (!is_online)
|
|
|
- view_pager.setCurrentItem(MangaDetailAdapter.CHAPTERS_FRAGMENT);
|
|
|
+ if (!isOnline)
|
|
|
+ viewPager.setCurrentItem(MangaDetailAdapter.CHAPTERS_FRAGMENT);
|
|
|
}
|
|
|
|
|
|
public void setManga(Manga manga) {
|
|
@@ -83,7 +80,7 @@ public class MangaActivity extends BaseRxActivity<MangaPresenter> {
|
|
|
}
|
|
|
|
|
|
public boolean isCatalogueManga() {
|
|
|
- return is_online;
|
|
|
+ return isOnline;
|
|
|
}
|
|
|
|
|
|
class MangaDetailAdapter extends FragmentPagerAdapter {
|
|
@@ -104,7 +101,7 @@ public class MangaActivity extends BaseRxActivity<MangaPresenter> {
|
|
|
};
|
|
|
|
|
|
pageCount = 2;
|
|
|
- if (!is_online && mangaSyncManager.getMyAnimeList().isLogged())
|
|
|
+ if (!isOnline && mangaSyncManager.getMyAnimeList().isLogged())
|
|
|
pageCount++;
|
|
|
}
|
|
|
|