mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-03 23:58:55 +01:00 
			
		
		
		
	Description scrollable and show real manga status.
This commit is contained in:
		@@ -1,10 +1,13 @@
 | 
			
		||||
package eu.kanade.mangafeed.data.database.models;
 | 
			
		||||
 | 
			
		||||
import android.content.Context;
 | 
			
		||||
 | 
			
		||||
import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteColumn;
 | 
			
		||||
import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteType;
 | 
			
		||||
 | 
			
		||||
import java.io.Serializable;
 | 
			
		||||
 | 
			
		||||
import eu.kanade.mangafeed.R;
 | 
			
		||||
import eu.kanade.mangafeed.data.database.tables.MangaTable;
 | 
			
		||||
import eu.kanade.mangafeed.util.UrlUtil;
 | 
			
		||||
 | 
			
		||||
@@ -104,6 +107,19 @@ public class Manga implements Serializable {
 | 
			
		||||
        initialized = true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getStatus(Context context) {
 | 
			
		||||
        switch (status) {
 | 
			
		||||
            case ONGOING:
 | 
			
		||||
                return context.getString(R.string.ongoing);
 | 
			
		||||
            case COMPLETED:
 | 
			
		||||
                return context.getString(R.string.completed);
 | 
			
		||||
            case LICENSED:
 | 
			
		||||
                return context.getString(R.string.licensed);
 | 
			
		||||
            default:
 | 
			
		||||
                return context.getString(R.string.unknown);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean equals(Object o) {
 | 
			
		||||
        if (this == o) return true;
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,6 @@ import android.support.v7.widget.GridLayoutManager;
 | 
			
		||||
import android.support.v7.widget.SearchView;
 | 
			
		||||
import android.support.v7.widget.Toolbar;
 | 
			
		||||
import android.text.TextUtils;
 | 
			
		||||
import android.util.Pair;
 | 
			
		||||
import android.view.LayoutInflater;
 | 
			
		||||
import android.view.Menu;
 | 
			
		||||
import android.view.MenuInflater;
 | 
			
		||||
@@ -41,7 +40,8 @@ import rx.android.schedulers.AndroidSchedulers;
 | 
			
		||||
import rx.subjects.PublishSubject;
 | 
			
		||||
 | 
			
		||||
@RequiresPresenter(CataloguePresenter.class)
 | 
			
		||||
public class CatalogueFragment extends BaseRxFragment<CataloguePresenter> implements FlexibleViewHolder.OnListItemClickListener {
 | 
			
		||||
public class CatalogueFragment extends BaseRxFragment<CataloguePresenter>
 | 
			
		||||
        implements FlexibleViewHolder.OnListItemClickListener {
 | 
			
		||||
 | 
			
		||||
    @Bind(R.id.recycler) AutofitRecyclerView recycler;
 | 
			
		||||
    @Bind(R.id.progress) ProgressBar progress;
 | 
			
		||||
@@ -207,13 +207,13 @@ public class CatalogueFragment extends BaseRxFragment<CataloguePresenter> implem
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void onAddPage(Pair<Integer, List<Manga>> pair) {
 | 
			
		||||
    public void onAddPage(int page, List<Manga> mangas) {
 | 
			
		||||
        hideProgressBar();
 | 
			
		||||
        if (pair.first == 0) {
 | 
			
		||||
        if (page == 1) {
 | 
			
		||||
            adapter.clear();
 | 
			
		||||
            scrollListener.resetScroll();
 | 
			
		||||
        }
 | 
			
		||||
        adapter.addItems(pair.second);
 | 
			
		||||
        adapter.addItems(mangas);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void onAddPageError() {
 | 
			
		||||
 
 | 
			
		||||
@@ -57,15 +57,8 @@ public class CataloguePresenter extends BasePresenter<CatalogueFragment> {
 | 
			
		||||
        mangaDetailSubject = PublishSubject.create();
 | 
			
		||||
 | 
			
		||||
        restartableReplay(GET_MANGA_LIST,
 | 
			
		||||
                () -> pager.pages().concatMap(
 | 
			
		||||
                        page -> getMangaObs(page + 1)
 | 
			
		||||
                                .map(mangas -> Pair.create(page, mangas))
 | 
			
		||||
                                .doOnNext(pair -> {
 | 
			
		||||
                                    if (mangaDetailSubject != null)
 | 
			
		||||
                                        mangaDetailSubject.onNext(pair.second);
 | 
			
		||||
                                })
 | 
			
		||||
                                .observeOn(AndroidSchedulers.mainThread())),
 | 
			
		||||
                CatalogueFragment::onAddPage,
 | 
			
		||||
                () -> pager.pages().concatMap(page -> getMangasPageObservable(page + 1)),
 | 
			
		||||
                (view, pair) -> view.onAddPage(pair.first, pair.second),
 | 
			
		||||
                (view, error) -> {
 | 
			
		||||
                    view.onAddPageError();
 | 
			
		||||
                    Timber.e(error.getMessage());
 | 
			
		||||
@@ -116,7 +109,7 @@ public class CataloguePresenter extends BasePresenter<CatalogueFragment> {
 | 
			
		||||
            pager.requestNext(++currentPage);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private Observable<List<Manga>> getMangaObs(int page) {
 | 
			
		||||
    private Observable<Pair<Integer, List<Manga>>> getMangasPageObservable(int page) {
 | 
			
		||||
        MangasPage nextMangasPage = new MangasPage(page);
 | 
			
		||||
        if (page != 1) {
 | 
			
		||||
            nextMangasPage.url = lastMangasPage.nextPageUrl;
 | 
			
		||||
@@ -130,7 +123,13 @@ public class CataloguePresenter extends BasePresenter<CatalogueFragment> {
 | 
			
		||||
                .doOnNext(mangasPage -> lastMangasPage = mangasPage)
 | 
			
		||||
                .flatMap(mangasPage -> Observable.from(mangasPage.mangas))
 | 
			
		||||
                .map(this::networkToLocalManga)
 | 
			
		||||
                .toList();
 | 
			
		||||
                .toList()
 | 
			
		||||
                .map(mangas -> Pair.create(page, mangas))
 | 
			
		||||
                .doOnNext(pair -> {
 | 
			
		||||
                    if (mangaDetailSubject != null)
 | 
			
		||||
                        mangaDetailSubject.onNext(pair.second);
 | 
			
		||||
                })
 | 
			
		||||
                .observeOn(AndroidSchedulers.mainThread());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private Manga networkToLocalManga(Manga networkManga) {
 | 
			
		||||
 
 | 
			
		||||
@@ -73,7 +73,7 @@ public class MangaInfoFragment extends BaseRxFragment<MangaInfoPresenter> {
 | 
			
		||||
        artist.setText(manga.artist);
 | 
			
		||||
        author.setText(manga.author);
 | 
			
		||||
        genres.setText(manga.genre);
 | 
			
		||||
        status.setText("Ongoing"); //TODO
 | 
			
		||||
        status.setText(manga.getStatus(getActivity()));
 | 
			
		||||
        description.setText(manga.description);
 | 
			
		||||
 | 
			
		||||
        setFavoriteText(manga.favorite);
 | 
			
		||||
 
 | 
			
		||||
@@ -212,14 +212,20 @@
 | 
			
		||||
                    android:singleLine="false"
 | 
			
		||||
                    android:text="@string/description" />
 | 
			
		||||
 | 
			
		||||
                <TextView
 | 
			
		||||
                    android:id="@+id/manga_summary"
 | 
			
		||||
                    style="@style/manga_detail_text"
 | 
			
		||||
                <ScrollView
 | 
			
		||||
                    android:layout_width="match_parent"
 | 
			
		||||
                    android:layout_height="match_parent"
 | 
			
		||||
                    android:focusable="false"
 | 
			
		||||
                    android:focusableInTouchMode="false"
 | 
			
		||||
                    android:singleLine="false" />
 | 
			
		||||
                    android:layout_height="match_parent">
 | 
			
		||||
 | 
			
		||||
                    <TextView
 | 
			
		||||
                        android:id="@+id/manga_summary"
 | 
			
		||||
                        style="@style/manga_detail_text"
 | 
			
		||||
                        android:layout_width="match_parent"
 | 
			
		||||
                        android:layout_height="wrap_content"
 | 
			
		||||
                        android:focusable="false"
 | 
			
		||||
                        android:focusableInTouchMode="false"
 | 
			
		||||
                        android:singleLine="false" />
 | 
			
		||||
 | 
			
		||||
                </ScrollView>
 | 
			
		||||
 | 
			
		||||
            </LinearLayout>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -123,8 +123,11 @@
 | 
			
		||||
    <string name="chapters">Chapters</string>
 | 
			
		||||
    <string name="genres">Genres</string>
 | 
			
		||||
    <string name="artist">Artist</string>
 | 
			
		||||
    <string name="status">Status</string>
 | 
			
		||||
    <string name="description">Description</string>
 | 
			
		||||
    <string name="status">Status</string>
 | 
			
		||||
    <string name="ongoing">Ongoing</string>
 | 
			
		||||
    <string name="unknown">Unknown</string>
 | 
			
		||||
    <string name="licensed">Licensed</string>
 | 
			
		||||
    <string name="add_to_library">Add to library</string>
 | 
			
		||||
    <string name="remove_from_library">Remove from library</string>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user