mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-10 12:47:26 +01:00
Add broken webtoon viewer (not sure if it will be possible with RecyclerView)
This commit is contained in:
parent
d3c83f0bf2
commit
0a9b84ea11
@ -0,0 +1,70 @@
|
||||
package eu.kanade.mangafeed.ui.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
|
||||
import com.davemorrissey.labs.subscaleview.ImageSource;
|
||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import eu.kanade.mangafeed.R;
|
||||
import eu.kanade.mangafeed.data.models.Page;
|
||||
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;
|
||||
|
||||
public class WebtoonAdapter extends BaseEasyRecyclerAdapter<Page> {
|
||||
|
||||
List<Page> pages;
|
||||
|
||||
public WebtoonAdapter(Context context) {
|
||||
super(context, ImageViewHolder.class);
|
||||
pages = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page getItem(int position) {
|
||||
return pages.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return pages.size();
|
||||
}
|
||||
|
||||
public void setPages(List<Page> pages) {
|
||||
this.pages = pages;
|
||||
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;
|
||||
|
||||
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);
|
||||
imageView.setZoomEnabled(false);
|
||||
imageView.setPanEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetValues(Page page, PositionInfo positionInfo) {
|
||||
if (page.getImagePath() != null)
|
||||
imageView.setImage(ImageSource.uri(page.getImagePath()).tilingDisabled());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package eu.kanade.mangafeed.ui.viewer;
|
||||
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import eu.kanade.mangafeed.data.models.Page;
|
||||
import eu.kanade.mangafeed.ui.activity.ReaderActivity;
|
||||
import eu.kanade.mangafeed.ui.adapter.WebtoonAdapter;
|
||||
import eu.kanade.mangafeed.ui.viewer.base.BaseViewer;
|
||||
|
||||
public class WebtoonViewer extends BaseViewer {
|
||||
|
||||
private RecyclerView recycler;
|
||||
private WebtoonAdapter adapter;
|
||||
|
||||
public WebtoonViewer(ReaderActivity activity, FrameLayout container) {
|
||||
super(activity, container);
|
||||
|
||||
recycler = new RecyclerView(activity);
|
||||
recycler.setLayoutManager(new LinearLayoutManager(activity));
|
||||
adapter = new WebtoonAdapter(activity);
|
||||
recycler.setAdapter(adapter);
|
||||
|
||||
container.addView(recycler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalPages() {
|
||||
return adapter.getItemCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onImageReady(Page page) {
|
||||
adapter.setPage(getPosFromPage(page), page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageListReady(List<Page> pages) {
|
||||
adapter.setPages(pages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onImageTouch(MotionEvent motionEvent) {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -32,7 +32,7 @@ public abstract class BaseViewer {
|
||||
}
|
||||
|
||||
public abstract int getTotalPages();
|
||||
public abstract void onImageReady(Page page);
|
||||
public abstract void onPageListReady(List<Page> pages);
|
||||
public abstract void onImageReady(Page page);
|
||||
public abstract boolean onImageTouch(MotionEvent motionEvent);
|
||||
}
|
||||
|
5
app/src/main/res/layout/chapter_image.xml
Normal file
5
app/src/main/res/layout/chapter_image.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/page_image_view" />
|
@ -13,9 +13,6 @@
|
||||
android:layout_gravity="center_vertical|center_horizontal"
|
||||
android:visibility="gone" />
|
||||
|
||||
<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/page_image_view" />
|
||||
<include layout="@layout/chapter_image"/>
|
||||
|
||||
</FrameLayout>
|
7
app/src/main/res/layout/viewer_webtoon.xml
Normal file
7
app/src/main/res/layout/viewer_webtoon.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v7.widget.RecyclerView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</android.support.v7.widget.RecyclerView>
|
Loading…
Reference in New Issue
Block a user