|
@@ -7,6 +7,7 @@ import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewGroup;
|
|
import android.widget.ProgressBar;
|
|
import android.widget.ProgressBar;
|
|
|
|
+import android.widget.TextView;
|
|
|
|
|
|
import com.davemorrissey.labs.subscaleview.ImageSource;
|
|
import com.davemorrissey.labs.subscaleview.ImageSource;
|
|
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
|
|
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
|
|
@@ -18,19 +19,17 @@ import eu.kanade.mangafeed.data.models.Page;
|
|
import eu.kanade.mangafeed.ui.activity.ReaderActivity;
|
|
import eu.kanade.mangafeed.ui.activity.ReaderActivity;
|
|
|
|
|
|
public class ReaderPageFragment extends Fragment {
|
|
public class ReaderPageFragment extends Fragment {
|
|
- public static final String URL_ARGUMENT_KEY = "UrlArgumentKey";
|
|
|
|
|
|
|
|
@Bind(R.id.page_image_view) SubsamplingScaleImageView imageView;
|
|
@Bind(R.id.page_image_view) SubsamplingScaleImageView imageView;
|
|
@Bind(R.id.progress) ProgressBar progressBar;
|
|
@Bind(R.id.progress) ProgressBar progressBar;
|
|
|
|
+ @Bind(R.id.image_error) TextView errorText;
|
|
|
|
|
|
- private String imagePath;
|
|
|
|
|
|
+ private Page page;
|
|
|
|
|
|
public static ReaderPageFragment newInstance(Page page) {
|
|
public static ReaderPageFragment newInstance(Page page) {
|
|
- ReaderPageFragment newInstance = new ReaderPageFragment();
|
|
|
|
- Bundle arguments = new Bundle();
|
|
|
|
- arguments.putString(URL_ARGUMENT_KEY, page.getImagePath());
|
|
|
|
- newInstance.setArguments(arguments);
|
|
|
|
- return newInstance;
|
|
|
|
|
|
+ ReaderPageFragment fragment = new ReaderPageFragment();
|
|
|
|
+ fragment.setPage(page);
|
|
|
|
+ return fragment;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -38,26 +37,32 @@ public class ReaderPageFragment extends Fragment {
|
|
super.onCreate(savedInstanceState);
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
setRetainInstance(true);
|
|
setRetainInstance(true);
|
|
|
|
+ }
|
|
|
|
|
|
- Bundle arguments = getArguments();
|
|
|
|
- if (arguments != null) {
|
|
|
|
- if (arguments.containsKey(URL_ARGUMENT_KEY)) {
|
|
|
|
- imagePath = arguments.getString(URL_ARGUMENT_KEY);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ public void replacePage(Page page) {
|
|
|
|
+ this.page = page;
|
|
|
|
+ loadImage();
|
|
}
|
|
}
|
|
|
|
|
|
public void setPage(Page page) {
|
|
public void setPage(Page page) {
|
|
- if (!page.getImageUrl().equals(imagePath)) {
|
|
|
|
- imagePath = page.getImagePath();
|
|
|
|
- loadImage();
|
|
|
|
- }
|
|
|
|
|
|
+ this.page = page;
|
|
}
|
|
}
|
|
|
|
|
|
private void loadImage() {
|
|
private void loadImage() {
|
|
- if (imagePath != null) {
|
|
|
|
- progressBar.setVisibility(View.GONE);
|
|
|
|
- imageView.setImage(ImageSource.uri(imagePath).tilingDisabled());
|
|
|
|
|
|
+ if (page == null)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ switch (page.getStatus()) {
|
|
|
|
+ case (Page.READY):
|
|
|
|
+ imageView.setImage(ImageSource.uri(page.getImagePath()).tilingDisabled());
|
|
|
|
+ progressBar.setVisibility(View.GONE);
|
|
|
|
+ break;
|
|
|
|
+ case (Page.DOWNLOAD):
|
|
|
|
+ progressBar.setVisibility(View.VISIBLE);
|
|
|
|
+ break;
|
|
|
|
+ case (Page.ERROR):
|
|
|
|
+ progressBar.setVisibility(View.GONE);
|
|
|
|
+ errorText.setVisibility(View.VISIBLE);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -73,8 +78,6 @@ public class ReaderPageFragment extends Fragment {
|
|
imageView.setOnTouchListener((v, motionEvent) ->
|
|
imageView.setOnTouchListener((v, motionEvent) ->
|
|
((ReaderActivity) getActivity()).onImageTouch(motionEvent));
|
|
((ReaderActivity) getActivity()).onImageTouch(motionEvent));
|
|
|
|
|
|
- progressBar.setVisibility(View.VISIBLE);
|
|
|
|
-
|
|
|
|
loadImage();
|
|
loadImage();
|
|
|
|
|
|
return view;
|
|
return view;
|