Don't stretch the image
* Even computer is not so easy to process that
This commit is contained in:
1 parent
746abe91ec
commit
4c8cb4eb97
9 files changed
+17
-153
No files matched your search
@@ -1340,7 +1340,6 @@ public class DownloadsScene extends ToolbarScene
|
||||
args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GALLERY_INFO);
|
||||
args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, list.get(index));
|
||||
Announcer announcer = new Announcer(GalleryDetailScene.class).setArgs(args);
|
||||
announcer.setTranHelper(new EnterGalleryDetailTransaction(thumb));
|
||||
startScene(announcer);
|
||||
} else if (start == v) {
|
||||
Intent intent = new Intent(activity, DownloadService.class);
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.ehviewer.ui.scene;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.transition.TransitionInflater;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.scene.TransitionHelper;
|
||||
|
||||
class EnterGalleryDetailTransaction implements TransitionHelper {
|
||||
|
||||
private final View mThumb;
|
||||
|
||||
public EnterGalleryDetailTransaction(View thumb) {
|
||||
mThumb = thumb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTransition(Context context, FragmentTransaction transaction,
|
||||
Fragment exit, Fragment enter) {
|
||||
if (mThumb == null || !(enter instanceof GalleryDetailScene)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String transitionName = ViewCompat.getTransitionName(mThumb);
|
||||
if (transitionName != null) {
|
||||
exit.setSharedElementReturnTransition(
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_move));
|
||||
exit.setExitTransition(
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_fade));
|
||||
enter.setSharedElementEnterTransition(
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_move));
|
||||
enter.setEnterTransition(
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_fade));
|
||||
transaction.addSharedElement(mThumb, transitionName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -550,10 +550,6 @@ public class FavoritesScene extends BaseScene implements
|
||||
args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GALLERY_INFO);
|
||||
args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, gi);
|
||||
Announcer announcer = new Announcer(GalleryDetailScene.class).setArgs(args);
|
||||
View thumb;
|
||||
if (null != (thumb = view.findViewById(R.id.thumb))) {
|
||||
announcer.setTranHelper(new EnterGalleryDetailTransaction(thumb));
|
||||
}
|
||||
startScene(announcer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1543,17 +1543,6 @@ public class GalleryDetailScene extends ToolbarScene implements View.OnClickList
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (mViewTransition != null && mThumb != null &&
|
||||
mViewTransition.getShownViewIndex() == 0 && mThumb.isShown()) {
|
||||
int[] location = new int[2];
|
||||
mThumb.getLocationInWindow(location);
|
||||
// Only show transaction when thumb can be seen
|
||||
if (location[1] + mThumb.getHeight() > 0) {
|
||||
setTransitionName();
|
||||
finish(new ExitTransaction(mThumb));
|
||||
return;
|
||||
}
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
@@ -1715,38 +1704,6 @@ public class GalleryDetailScene extends ToolbarScene implements View.OnClickList
|
||||
private @interface State {
|
||||
}
|
||||
|
||||
private static class ExitTransaction implements TransitionHelper {
|
||||
|
||||
private final View mThumb;
|
||||
|
||||
public ExitTransaction(View thumb) {
|
||||
mThumb = thumb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTransition(Context context,
|
||||
FragmentTransaction transaction, Fragment exit, Fragment enter) {
|
||||
if (!(enter instanceof GalleryListScene) && !(enter instanceof DownloadsScene) &&
|
||||
!(enter instanceof FavoritesScene) && !(enter instanceof HistoryScene)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String transitionName = ViewCompat.getTransitionName(mThumb);
|
||||
if (transitionName != null) {
|
||||
exit.setSharedElementReturnTransition(
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_move));
|
||||
exit.setExitTransition(
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_fade));
|
||||
enter.setSharedElementEnterTransition(
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_move));
|
||||
enter.setEnterTransition(
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_fade));
|
||||
transaction.addSharedElement(mThumb, transitionName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static class GetGalleryDetailListener extends EhCallback<GalleryDetailScene, GalleryDetail> {
|
||||
|
||||
public GetGalleryDetailListener(Context context, int stageId, String sceneTag) {
|
||||
|
||||
@@ -903,10 +903,6 @@ public final class GalleryListScene extends BaseScene
|
||||
args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GALLERY_INFO);
|
||||
args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, gi);
|
||||
Announcer announcer = new Announcer(GalleryDetailScene.class).setArgs(args);
|
||||
View thumb;
|
||||
if (null != (thumb = view.findViewById(R.id.thumb))) {
|
||||
announcer.setTranHelper(new EnterGalleryDetailTransaction(thumb));
|
||||
}
|
||||
startScene(announcer);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -342,10 +342,6 @@ public class HistoryScene extends ToolbarScene {
|
||||
args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GALLERY_INFO);
|
||||
args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, mLazyList.get(position));
|
||||
Announcer announcer = new Announcer(GalleryDetailScene.class).setArgs(args);
|
||||
View thumb;
|
||||
if (null != (thumb = view.findViewById(R.id.thumb))) {
|
||||
announcer.setTranHelper(new EnterGalleryDetailTransaction(thumb));
|
||||
}
|
||||
startScene(announcer);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ public final class Announcer {
|
||||
|
||||
Class<?> clazz;
|
||||
Bundle args;
|
||||
TransitionHelper tranHelper;
|
||||
SceneFragment requestFrom;
|
||||
int requestCode;
|
||||
|
||||
@@ -43,11 +42,6 @@ public final class Announcer {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Announcer setTranHelper(TransitionHelper tranHelper) {
|
||||
this.tranHelper = tranHelper;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Announcer setRequestCode(SceneFragment requestFrom, int requestCode) {
|
||||
this.requestFrom = requestFrom;
|
||||
this.requestCode = requestCode;
|
||||
|
||||
@@ -72,13 +72,9 @@ public class SceneFragment extends Fragment {
|
||||
}
|
||||
|
||||
public void finish() {
|
||||
finish(null);
|
||||
}
|
||||
|
||||
public void finish(TransitionHelper transitionHelper) {
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity instanceof StageActivity) {
|
||||
((StageActivity) activity).finishScene(this, transitionHelper);
|
||||
((StageActivity) activity).finishScene(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -252,7 +252,6 @@ public abstract class StageActivity extends EhActivity {
|
||||
public void startScene(Announcer announcer, boolean horizontal) {
|
||||
Class<?> clazz = announcer.clazz;
|
||||
Bundle args = announcer.args;
|
||||
TransitionHelper tranHelper = announcer.tranHelper;
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
int launchMode = getSceneLaunchMode(clazz);
|
||||
|
||||
@@ -351,23 +350,20 @@ public abstract class StageActivity extends EhActivity {
|
||||
FragmentTransaction transaction = fragmentManager.beginTransaction();
|
||||
// Animation
|
||||
if (currentScene != null) {
|
||||
if (tranHelper == null || !tranHelper.onTransition(
|
||||
this, transaction, currentScene, newScene)) {
|
||||
// Clear shared item
|
||||
currentScene.setSharedElementEnterTransition(null);
|
||||
currentScene.setSharedElementReturnTransition(null);
|
||||
currentScene.setEnterTransition(null);
|
||||
currentScene.setExitTransition(null);
|
||||
newScene.setSharedElementEnterTransition(null);
|
||||
newScene.setSharedElementReturnTransition(null);
|
||||
newScene.setEnterTransition(null);
|
||||
newScene.setExitTransition(null);
|
||||
// Set default animation
|
||||
if (horizontal) {
|
||||
transaction.setCustomAnimations(R.anim.scene_open_enter_horizontal, R.anim.scene_open_exit);
|
||||
} else {
|
||||
transaction.setCustomAnimations(R.anim.scene_open_enter, R.anim.scene_open_exit);
|
||||
}
|
||||
// Clear shared item
|
||||
currentScene.setSharedElementEnterTransition(null);
|
||||
currentScene.setSharedElementReturnTransition(null);
|
||||
currentScene.setEnterTransition(null);
|
||||
currentScene.setExitTransition(null);
|
||||
newScene.setSharedElementEnterTransition(null);
|
||||
newScene.setSharedElementReturnTransition(null);
|
||||
newScene.setEnterTransition(null);
|
||||
newScene.setExitTransition(null);
|
||||
// Set default animation
|
||||
if (horizontal) {
|
||||
transaction.setCustomAnimations(R.anim.scene_open_enter_horizontal, R.anim.scene_open_exit);
|
||||
} else {
|
||||
transaction.setCustomAnimations(R.anim.scene_open_enter, R.anim.scene_open_exit);
|
||||
}
|
||||
// Detach current scene
|
||||
if (!currentScene.isDetached()) {
|
||||
@@ -480,14 +476,10 @@ public abstract class StageActivity extends EhActivity {
|
||||
}
|
||||
|
||||
public void finishScene(SceneFragment scene) {
|
||||
finishScene(scene, null);
|
||||
finishScene(scene.getTag());
|
||||
}
|
||||
|
||||
public void finishScene(SceneFragment scene, TransitionHelper transitionHelper) {
|
||||
finishScene(scene.getTag(), transitionHelper);
|
||||
}
|
||||
|
||||
private void finishScene(String tag, TransitionHelper transitionHelper) {
|
||||
private void finishScene(String tag) {
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
|
||||
// Get scene
|
||||
@@ -519,8 +511,6 @@ public abstract class StageActivity extends EhActivity {
|
||||
|
||||
FragmentTransaction transaction = fragmentManager.beginTransaction();
|
||||
if (next != null) {
|
||||
if (transitionHelper == null || !transitionHelper.onTransition(
|
||||
this, transaction, scene, next)) {
|
||||
// Clear shared item
|
||||
scene.setSharedElementEnterTransition(null);
|
||||
scene.setSharedElementReturnTransition(null);
|
||||
@@ -532,7 +522,6 @@ public abstract class StageActivity extends EhActivity {
|
||||
next.setExitTransition(null);
|
||||
// Do not show animate if it is not the first fragment
|
||||
transaction.setCustomAnimations(R.anim.scene_close_enter, R.anim.scene_close_exit);
|
||||
}
|
||||
// Attach fragment
|
||||
transaction.attach(next);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user