mirror of
https://git.mihon.tech/mihonapp/mihon
synced 2024-11-21 20:55:41 +03:00
Some improvements to viewers
This commit is contained in:
parent
f2b05e8519
commit
bc83bd7033
7 changed files with 28 additions and 21 deletions
|
@ -15,6 +15,7 @@ import uk.co.ribot.easyadapter.BaseEasyRecyclerAdapter;
|
|||
import uk.co.ribot.easyadapter.ItemViewHolder;
|
||||
import uk.co.ribot.easyadapter.PositionInfo;
|
||||
import uk.co.ribot.easyadapter.annotations.LayoutId;
|
||||
import uk.co.ribot.easyadapter.annotations.ViewId;
|
||||
|
||||
public class WebtoonAdapter extends BaseEasyRecyclerAdapter<Page> {
|
||||
|
||||
|
@ -40,20 +41,13 @@ public class WebtoonAdapter extends BaseEasyRecyclerAdapter<Page> {
|
|||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setPage(int position, Page page) {
|
||||
pages.set(position, page);
|
||||
notifyItemChanged(position);
|
||||
}
|
||||
|
||||
|
||||
@LayoutId(R.layout.chapter_image)
|
||||
static class ImageViewHolder extends ItemViewHolder<Page> {
|
||||
|
||||
SubsamplingScaleImageView imageView;
|
||||
@ViewId(R.id.page_image_view) SubsamplingScaleImageView imageView;
|
||||
|
||||
public ImageViewHolder(View view) {
|
||||
super(view);
|
||||
imageView = (SubsamplingScaleImageView) getView();
|
||||
imageView.setDoubleTapZoomStyle(SubsamplingScaleImageView.ZOOM_FOCUS_FIXED);
|
||||
imageView.setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_INSIDE);
|
||||
imageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CENTER_INSIDE);
|
||||
|
@ -63,8 +57,13 @@ public class WebtoonAdapter extends BaseEasyRecyclerAdapter<Page> {
|
|||
|
||||
@Override
|
||||
public void onSetValues(Page page, PositionInfo positionInfo) {
|
||||
if (page.getImagePath() != null)
|
||||
if (page.getImagePath() != null) {
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
imageView.setImage(ImageSource.uri(page.getImagePath()).tilingDisabled());
|
||||
} else {
|
||||
imageView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package eu.kanade.mangafeed.ui.fragment;
|
|||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -21,13 +20,14 @@ import butterknife.ButterKnife;
|
|||
import eu.kanade.mangafeed.R;
|
||||
import eu.kanade.mangafeed.data.models.Page;
|
||||
import eu.kanade.mangafeed.ui.activity.ReaderActivity;
|
||||
import eu.kanade.mangafeed.ui.fragment.base.BaseFragment;
|
||||
import rx.Observable;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import rx.subjects.PublishSubject;
|
||||
|
||||
public class ReaderPageFragment extends Fragment {
|
||||
public class ReaderPageFragment extends BaseFragment {
|
||||
|
||||
@Bind(R.id.page_image_view) SubsamplingScaleImageView imageView;
|
||||
@Bind(R.id.progress_container) LinearLayout progressContainer;
|
||||
|
|
|
@ -21,7 +21,7 @@ public class RightToLeftViewer extends ViewPagerViewer {
|
|||
ArrayList<Page> inversedPages = new ArrayList<>(pages);
|
||||
Collections.reverse(inversedPages);
|
||||
adapter.setPages(inversedPages);
|
||||
getViewPager().setCurrentItem(adapter.getCount()-1);
|
||||
getViewPager().setCurrentItem(adapter.getCount()-1, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.kanade.mangafeed.ui.viewer;
|
||||
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
|
@ -12,7 +13,6 @@ import eu.kanade.mangafeed.data.models.Page;
|
|||
import eu.kanade.mangafeed.ui.activity.ReaderActivity;
|
||||
import eu.kanade.mangafeed.ui.adapter.ViewerPagerAdapter;
|
||||
import eu.kanade.mangafeed.ui.viewer.base.BaseViewer;
|
||||
import eu.kanade.mangafeed.widget.HorizontalViewPager;
|
||||
import fr.castorflex.android.verticalviewpager.VerticalViewPager;
|
||||
|
||||
public class VerticalViewer extends BaseViewer {
|
||||
|
@ -28,7 +28,7 @@ public class VerticalViewer extends BaseViewer {
|
|||
adapter = new ViewerPagerAdapter(activity.getSupportFragmentManager());
|
||||
viewPager.setAdapter(adapter);
|
||||
viewPager.setOffscreenPageLimit(3);
|
||||
viewPager.setOnPageChangeListener(new HorizontalViewPager.OnPageChangeListener() {
|
||||
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
|
||||
|
|
|
@ -21,7 +21,8 @@ public class WebtoonViewer extends BaseViewer {
|
|||
super(activity, container);
|
||||
|
||||
recycler = new RecyclerView(activity);
|
||||
recycler.setLayoutManager(new LinearLayoutManager(activity));
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(activity);
|
||||
recycler.setLayoutManager(layoutManager);
|
||||
adapter = new WebtoonAdapter(activity);
|
||||
recycler.setAdapter(adapter);
|
||||
|
||||
|
|
|
@ -15,8 +15,7 @@ import eu.kanade.mangafeed.widget.HorizontalViewPager;
|
|||
|
||||
public abstract class ViewPagerViewer extends BaseViewer {
|
||||
|
||||
@Bind(R.id.view_pager)
|
||||
HorizontalViewPager viewPager;
|
||||
@Bind(R.id.view_pager) HorizontalViewPager viewPager;
|
||||
protected ViewerPagerAdapter adapter;
|
||||
|
||||
public ViewPagerViewer(ReaderActivity activity, FrameLayout container) {
|
||||
|
@ -69,7 +68,7 @@ public abstract class ViewPagerViewer extends BaseViewer {
|
|||
|
||||
@Override
|
||||
public void setSelectedPage(int pageNumber) {
|
||||
viewPager.setCurrentItem(getCurrentPageIndex(pageNumber));
|
||||
viewPager.setCurrentItem(getCurrentPageIndex(pageNumber), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/page_image_view" />
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/page_image_view" />
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in a new issue