mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-11 13:30:48 +01:00
Minor changes
This commit is contained in:
parent
a54425f47d
commit
27b95e9d73
4 changed files with 39 additions and 25 deletions
|
@ -24,6 +24,7 @@ import butterknife.Bind;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import eu.kanade.tachiyomi.R;
|
import eu.kanade.tachiyomi.R;
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter;
|
import eu.kanade.tachiyomi.data.database.models.Chapter;
|
||||||
|
import eu.kanade.tachiyomi.data.database.models.Manga;
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadService;
|
import eu.kanade.tachiyomi.data.download.DownloadService;
|
||||||
import eu.kanade.tachiyomi.data.download.model.Download;
|
import eu.kanade.tachiyomi.data.download.model.Download;
|
||||||
import eu.kanade.tachiyomi.ui.base.adapter.FlexibleViewHolder;
|
import eu.kanade.tachiyomi.ui.base.adapter.FlexibleViewHolder;
|
||||||
|
@ -71,26 +72,14 @@ public class ChaptersFragment extends BaseRxFragment<ChaptersPresenter> implemen
|
||||||
// Init RecyclerView and adapter
|
// Init RecyclerView and adapter
|
||||||
linearLayout = new LinearLayoutManager(getActivity());
|
linearLayout = new LinearLayoutManager(getActivity());
|
||||||
recyclerView.setLayoutManager(linearLayout);
|
recyclerView.setLayoutManager(linearLayout);
|
||||||
recyclerView.addItemDecoration(new DividerItemDecoration(ContextCompat.getDrawable(getContext(), R.drawable.line_divider)));
|
recyclerView.addItemDecoration(new DividerItemDecoration(
|
||||||
|
ContextCompat.getDrawable(getContext(), R.drawable.line_divider)));
|
||||||
recyclerView.setHasFixedSize(true);
|
recyclerView.setHasFixedSize(true);
|
||||||
adapter = new ChaptersAdapter(this);
|
adapter = new ChaptersAdapter(this);
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
// Set initial values
|
|
||||||
setReadFilter();
|
|
||||||
setDownloadedFilter();
|
|
||||||
setSortIcon();
|
|
||||||
|
|
||||||
// Init listeners
|
|
||||||
swipeRefresh.setOnRefreshListener(this::fetchChapters);
|
swipeRefresh.setOnRefreshListener(this::fetchChapters);
|
||||||
readCb.setOnCheckedChangeListener((arg, isChecked) ->
|
|
||||||
getPresenter().setReadFilter(isChecked));
|
|
||||||
downloadedCb.setOnCheckedChangeListener((v, isChecked) ->
|
|
||||||
getPresenter().setDownloadedFilter(isChecked));
|
|
||||||
sortBtn.setOnClickListener(v -> {
|
|
||||||
getPresenter().revertSortOrder();
|
|
||||||
setSortIcon();
|
|
||||||
});
|
|
||||||
nextUnreadBtn.setOnClickListener(v -> {
|
nextUnreadBtn.setOnClickListener(v -> {
|
||||||
Chapter chapter = getPresenter().getNextUnreadChapter();
|
Chapter chapter = getPresenter().getNextUnreadChapter();
|
||||||
if (chapter != null) {
|
if (chapter != null) {
|
||||||
|
@ -103,6 +92,28 @@ public class ChaptersFragment extends BaseRxFragment<ChaptersPresenter> implemen
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onNextManga(Manga manga) {
|
||||||
|
// Remove listeners before setting the values
|
||||||
|
readCb.setOnCheckedChangeListener(null);
|
||||||
|
downloadedCb.setOnCheckedChangeListener(null);
|
||||||
|
sortBtn.setOnClickListener(null);
|
||||||
|
|
||||||
|
// Set initial values
|
||||||
|
setReadFilter();
|
||||||
|
setDownloadedFilter();
|
||||||
|
setSortIcon();
|
||||||
|
|
||||||
|
// Init listeners
|
||||||
|
readCb.setOnCheckedChangeListener((arg, isChecked) ->
|
||||||
|
getPresenter().setReadFilter(isChecked));
|
||||||
|
downloadedCb.setOnCheckedChangeListener((v, isChecked) ->
|
||||||
|
getPresenter().setDownloadedFilter(isChecked));
|
||||||
|
sortBtn.setOnClickListener(v -> {
|
||||||
|
getPresenter().revertSortOrder();
|
||||||
|
setSortIcon();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void onNextChapters(List<Chapter> chapters) {
|
public void onNextChapters(List<Chapter> chapters) {
|
||||||
// If the list is empty, fetch chapters from source if the conditions are met
|
// If the list is empty, fetch chapters from source if the conditions are met
|
||||||
// We use presenter chapters instead because they are always unfiltered
|
// We use presenter chapters instead because they are always unfiltered
|
||||||
|
|
|
@ -45,9 +45,10 @@ public class ChaptersPresenter extends BasePresenter<ChaptersFragment> {
|
||||||
|
|
||||||
private PublishSubject<List<Chapter>> chaptersSubject;
|
private PublishSubject<List<Chapter>> chaptersSubject;
|
||||||
|
|
||||||
private static final int DB_CHAPTERS = 1;
|
private static final int GET_MANGA = 1;
|
||||||
private static final int FETCH_CHAPTERS = 2;
|
private static final int DB_CHAPTERS = 2;
|
||||||
private static final int CHAPTER_STATUS_CHANGES = 3;
|
private static final int FETCH_CHAPTERS = 3;
|
||||||
|
private static final int CHAPTER_STATUS_CHANGES = 4;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedState) {
|
protected void onCreate(Bundle savedState) {
|
||||||
|
@ -59,6 +60,10 @@ public class ChaptersPresenter extends BasePresenter<ChaptersFragment> {
|
||||||
|
|
||||||
chaptersSubject = PublishSubject.create();
|
chaptersSubject = PublishSubject.create();
|
||||||
|
|
||||||
|
restartableLatestCache(GET_MANGA,
|
||||||
|
() -> Observable.just(manga),
|
||||||
|
ChaptersFragment::onNextManga);
|
||||||
|
|
||||||
restartableLatestCache(DB_CHAPTERS,
|
restartableLatestCache(DB_CHAPTERS,
|
||||||
this::getDbChaptersObs,
|
this::getDbChaptersObs,
|
||||||
ChaptersFragment::onNextChapters);
|
ChaptersFragment::onNextChapters);
|
||||||
|
@ -77,6 +82,7 @@ public class ChaptersPresenter extends BasePresenter<ChaptersFragment> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onProcessRestart() {
|
private void onProcessRestart() {
|
||||||
|
stop(GET_MANGA);
|
||||||
stop(DB_CHAPTERS);
|
stop(DB_CHAPTERS);
|
||||||
stop(FETCH_CHAPTERS);
|
stop(FETCH_CHAPTERS);
|
||||||
stop(CHAPTER_STATUS_CHANGES);
|
stop(CHAPTER_STATUS_CHANGES);
|
||||||
|
@ -92,6 +98,7 @@ public class ChaptersPresenter extends BasePresenter<ChaptersFragment> {
|
||||||
@EventBusHook
|
@EventBusHook
|
||||||
public void onEventMainThread(MangaEvent event) {
|
public void onEventMainThread(MangaEvent event) {
|
||||||
this.manga = event.manga;
|
this.manga = event.manga;
|
||||||
|
start(GET_MANGA);
|
||||||
|
|
||||||
if (isUnsubscribed(DB_CHAPTERS)) {
|
if (isUnsubscribed(DB_CHAPTERS)) {
|
||||||
source = sourceManager.get(manga.source);
|
source = sourceManager.get(manga.source);
|
||||||
|
|
|
@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.ui.manga.info;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
import android.util.Pair;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -63,9 +62,7 @@ public class MangaInfoFragment extends BaseRxFragment<MangaInfoPresenter> {
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onNextManga(Pair<Manga,Source> info) {
|
public void onNextManga(Manga manga, Source source) {
|
||||||
Manga manga = info.first;
|
|
||||||
Source source = info.second;
|
|
||||||
if (manga.initialized) {
|
if (manga.initialized) {
|
||||||
setMangaInfo(manga, source);
|
setMangaInfo(manga, source);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package eu.kanade.tachiyomi.ui.manga.info;
|
package eu.kanade.tachiyomi.ui.manga.info;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Pair;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
@ -41,8 +40,8 @@ public class MangaInfoPresenter extends BasePresenter<MangaInfoFragment> {
|
||||||
}
|
}
|
||||||
|
|
||||||
restartableLatestCache(GET_MANGA,
|
restartableLatestCache(GET_MANGA,
|
||||||
() -> Observable.just(new Pair<>(manga, source)),
|
() -> Observable.just(manga),
|
||||||
MangaInfoFragment::onNextManga);
|
(view, manga) -> view.onNextManga(manga, source));
|
||||||
|
|
||||||
restartableLatestCache(GET_CHAPTER_COUNT,
|
restartableLatestCache(GET_CHAPTER_COUNT,
|
||||||
() -> Observable.just(count),
|
() -> Observable.just(count),
|
||||||
|
|
Loading…
Reference in a new issue