mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-17 15:39:16 +01:00
Improve reader gestures. Upgrade gradle and retrolambda.
This commit is contained in:
parent
c803b91223
commit
a05cc934d0
@ -7,7 +7,6 @@ import android.os.Build;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -82,14 +81,6 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|||||||
initializeSettings();
|
initializeSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
readerMenu.destroy();
|
|
||||||
if (viewer != null)
|
|
||||||
viewer.destroy();
|
|
||||||
super.onDestroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@ -103,6 +94,14 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
readerMenu.destroy();
|
||||||
|
if (viewer != null)
|
||||||
|
viewer.destroy();
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
Icepick.saveInstanceState(readerMenu, outState);
|
Icepick.saveInstanceState(readerMenu, outState);
|
||||||
@ -146,10 +145,6 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|||||||
viewer.setSelectedPage(pageIndex);
|
viewer.setSelectedPage(pageIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onImageSingleTap(MotionEvent motionEvent) {
|
|
||||||
return viewer.onImageTouch(motionEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onCenterSingleTap() {
|
public void onCenterSingleTap() {
|
||||||
readerMenu.toggle();
|
readerMenu.toggle();
|
||||||
}
|
}
|
||||||
@ -262,4 +257,8 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|||||||
return preferences;
|
return preferences;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BaseReader getViewer() {
|
||||||
|
return viewer;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -181,15 +181,14 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
|||||||
nextChapterPageList = pages;
|
nextChapterPageList = pages;
|
||||||
// Preload at most 5 pages
|
// Preload at most 5 pages
|
||||||
int pagesToPreload = Math.min(pages.size(), 5);
|
int pagesToPreload = Math.min(pages.size(), 5);
|
||||||
return Observable.from(pages)
|
return Observable.from(pages).take(pagesToPreload);
|
||||||
.take(pagesToPreload)
|
})
|
||||||
.concatMap(page -> page.getImageUrl() == null ?
|
.concatMap(page -> page.getImageUrl() == null ?
|
||||||
source.getImageUrlFromPage(page) :
|
source.getImageUrlFromPage(page) :
|
||||||
Observable.just(page))
|
Observable.just(page))
|
||||||
.doOnCompleted(this::stopPreloadingNextChapter);
|
|
||||||
})
|
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread());
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.doOnCompleted(this::stopPreloadingNextChapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loads the given chapter
|
// Loads the given chapter
|
||||||
|
@ -3,6 +3,7 @@ package eu.kanade.mangafeed.ui.reader.viewer.common;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
@ -18,7 +19,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
|
|
||||||
import butterknife.Bind;
|
import butterknife.Bind;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import butterknife.OnClick;
|
|
||||||
import de.greenrobot.event.EventBus;
|
import de.greenrobot.event.EventBus;
|
||||||
import eu.kanade.mangafeed.R;
|
import eu.kanade.mangafeed.R;
|
||||||
import eu.kanade.mangafeed.data.source.model.Page;
|
import eu.kanade.mangafeed.data.source.model.Page;
|
||||||
@ -37,7 +37,6 @@ public class ViewPagerReaderFragment extends BaseFragment {
|
|||||||
@Bind(R.id.progress_container) LinearLayout progressContainer;
|
@Bind(R.id.progress_container) LinearLayout progressContainer;
|
||||||
@Bind(R.id.progress) ProgressBar progressBar;
|
@Bind(R.id.progress) ProgressBar progressBar;
|
||||||
@Bind(R.id.progress_text) TextView progressText;
|
@Bind(R.id.progress_text) TextView progressText;
|
||||||
@Bind(R.id.image_error) TextView errorText;
|
|
||||||
@Bind(R.id.retry_button) Button retryButton;
|
@Bind(R.id.retry_button) Button retryButton;
|
||||||
|
|
||||||
private Page page;
|
private Page page;
|
||||||
@ -59,7 +58,16 @@ public class ViewPagerReaderFragment extends BaseFragment {
|
|||||||
imageView.setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_INSIDE);
|
imageView.setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_INSIDE);
|
||||||
imageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CENTER_INSIDE);
|
imageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CENTER_INSIDE);
|
||||||
imageView.setOnTouchListener((v, motionEvent) ->
|
imageView.setOnTouchListener((v, motionEvent) ->
|
||||||
((ReaderActivity) getActivity()).onImageSingleTap(motionEvent));
|
((ReaderActivity) getActivity()).getViewer().onImageTouch(motionEvent));
|
||||||
|
|
||||||
|
retryButton.setOnTouchListener((v, event) -> {
|
||||||
|
if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||||
|
if (page != null)
|
||||||
|
EventBus.getDefault().postSticky(new RetryPageEvent(page));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
@ -86,11 +94,6 @@ public class ViewPagerReaderFragment extends BaseFragment {
|
|||||||
this.page = page;
|
this.page = page;
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.retry_button)
|
|
||||||
void retry() {
|
|
||||||
EventBus.getDefault().postSticky(new RetryPageEvent(page));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showImage() {
|
private void showImage() {
|
||||||
if (page == null || page.getImagePath() == null)
|
if (page == null || page.getImagePath() == null)
|
||||||
return;
|
return;
|
||||||
@ -112,12 +115,10 @@ public class ViewPagerReaderFragment extends BaseFragment {
|
|||||||
|
|
||||||
private void showError() {
|
private void showError() {
|
||||||
progressContainer.setVisibility(View.GONE);
|
progressContainer.setVisibility(View.GONE);
|
||||||
errorText.setVisibility(View.VISIBLE);
|
|
||||||
retryButton.setVisibility(View.VISIBLE);
|
retryButton.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hideError() {
|
private void hideError() {
|
||||||
errorText.setVisibility(View.GONE);
|
|
||||||
retryButton.setVisibility(View.GONE);
|
retryButton.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +26,6 @@ public class HorizontalViewPager extends ViewPager {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||||
try {
|
try {
|
||||||
gestureDetector.onTouchEvent(ev);
|
|
||||||
|
|
||||||
if ((ev.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
|
if ((ev.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
|
||||||
if (this.getCurrentItem() == 0 || this.getCurrentItem() == this.getAdapter().getCount() - 1) {
|
if (this.getCurrentItem() == 0 || this.getCurrentItem() == this.getAdapter().getCount() - 1) {
|
||||||
startDragX = ev.getX();
|
startDragX = ev.getX();
|
||||||
@ -85,7 +83,6 @@ public class HorizontalViewPager extends ViewPager {
|
|||||||
|
|
||||||
public interface OnChapterBoundariesOutListener {
|
public interface OnChapterBoundariesOutListener {
|
||||||
void onFirstPageOutEvent();
|
void onFirstPageOutEvent();
|
||||||
|
|
||||||
void onLastPageOutEvent();
|
void onLastPageOutEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,8 +25,6 @@ public class VerticalViewPager extends fr.castorflex.android.verticalviewpager.V
|
|||||||
@Override
|
@Override
|
||||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||||
try {
|
try {
|
||||||
gestureDetector.onTouchEvent(ev);
|
|
||||||
|
|
||||||
if ((ev.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
|
if ((ev.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
|
||||||
if (this.getCurrentItem() == 0 || this.getCurrentItem() == this.getAdapter().getCount() - 1) {
|
if (this.getCurrentItem() == 0 || this.getCurrentItem() == this.getAdapter().getCount() - 1) {
|
||||||
startDragY = ev.getY();
|
startDragY = ev.getY();
|
||||||
@ -84,7 +82,6 @@ public class VerticalViewPager extends fr.castorflex.android.verticalviewpager.V
|
|||||||
|
|
||||||
public interface OnChapterBoundariesOutListener {
|
public interface OnChapterBoundariesOutListener {
|
||||||
void onFirstPageOutEvent();
|
void onFirstPageOutEvent();
|
||||||
|
|
||||||
void onLastPageOutEvent();
|
void onLastPageOutEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,15 +30,6 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:id="@+id/image_error"
|
|
||||||
android:text=":("
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:textSize="32sp"
|
|
||||||
android:visibility="gone"/>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -6,9 +6,9 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:1.3.0'
|
classpath 'com.android.tools.build:gradle:1.5.0'
|
||||||
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.7'
|
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.7'
|
||||||
classpath 'me.tatarka:gradle-retrolambda:3.2.3'
|
classpath 'me.tatarka:gradle-retrolambda:3.2.4'
|
||||||
classpath 'com.github.ben-manes:gradle-versions-plugin:0.11.3'
|
classpath 'com.github.ben-manes:gradle-versions-plugin:0.11.3'
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
Loading…
Reference in New Issue
Block a user