diff options
author | Hermes Junior <ohermesjunior@gmail.com> | 2020-06-15 13:24:15 +0000 |
---|---|---|
committer | OHermesJunior <ohermesjunior@gmail.com> | 2020-06-15 13:24:15 +0000 |
commit | 87d4e8d85f86dce1ce681198e88109ff4071fca0 (patch) | |
tree | a8799fec6dc655ef2794221202131363485db7b2 /app | |
parent | e8e85b963143d111b13373ea225fe948e316de8e (diff) | |
download | infinity-for-reddit-87d4e8d85f86dce1ce681198e88109ff4071fca0.tar infinity-for-reddit-87d4e8d85f86dce1ce681198e88109ff4071fca0.tar.gz infinity-for-reddit-87d4e8d85f86dce1ce681198e88109ff4071fca0.tar.bz2 infinity-for-reddit-87d4e8d85f86dce1ce681198e88109ff4071fca0.tar.lz infinity-for-reddit-87d4e8d85f86dce1ce681198e88109ff4071fca0.tar.xz infinity-for-reddit-87d4e8d85f86dce1ce681198e88109ff4071fca0.tar.zst infinity-for-reddit-87d4e8d85f86dce1ce681198e88109ff4071fca0.zip |
Make exit animation follow slide direction on media activities.
Diffstat (limited to '')
6 files changed, 52 insertions, 6 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewGIFActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewGIFActivity.java index a1802a90..cc48a870 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewGIFActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewGIFActivity.java @@ -36,6 +36,7 @@ import com.bumptech.glide.load.resource.gif.GifDrawable; import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.target.Target; +import com.thefuntasty.hauler.DragDirection; import com.thefuntasty.hauler.HaulerView; import java.io.File; @@ -117,7 +118,11 @@ public class ViewGIFActivity extends AppCompatActivity { actionBar.setHomeAsUpIndicator(upArrow); actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.transparentActionBarAndExoPlayerControllerColor))); - mHaulerView.setOnDragDismissedListener(dragDirection -> finish()); + mHaulerView.setOnDragDismissedListener(dragDirection -> { + int slide = dragDirection == DragDirection.UP ? R.anim.slide_out_up : R.anim.slide_out_down; + finish(); + overridePendingTransition(0, slide); + }); glide = Glide.with(this); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java index 76acf253..0dacbb43 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java @@ -43,6 +43,7 @@ import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.target.CustomTarget; import com.bumptech.glide.request.target.Target; import com.bumptech.glide.request.transition.Transition; +import com.thefuntasty.hauler.DragDirection; import com.thefuntasty.hauler.HaulerView; import java.io.File; @@ -139,7 +140,11 @@ public class ViewImageActivity extends AppCompatActivity implements SetAsWallpap setTitle(""); } - mHaulerView.setOnDragDismissedListener(dragDirection -> finish()); + mHaulerView.setOnDragDismissedListener(dragDirection -> { + int slide = dragDirection == DragDirection.UP ? R.anim.slide_out_up : R.anim.slide_out_down; + finish(); + overridePendingTransition(0, slide); + }); mLoadErrorLinearLayout.setOnClickListener(view -> { mProgressBar.setVisibility(View.VISIBLE); @@ -238,7 +243,7 @@ public class ViewImageActivity extends AppCompatActivity implements SetAsWallpap @Override public void saveSuccess(File imageFile) { Uri uri = FileProvider.getUriForFile(ViewImageActivity.this, - BuildConfig.APPLICATION_ID + ".provider",imageFile); + BuildConfig.APPLICATION_ID + ".provider", imageFile); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java index c4b0e38d..bae1fdf3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java @@ -32,6 +32,7 @@ import androidx.viewpager.widget.ViewPager; import com.bumptech.glide.Glide; import com.bumptech.glide.request.target.CustomTarget; import com.bumptech.glide.request.transition.Transition; +import com.thefuntasty.hauler.DragDirection; import com.thefuntasty.hauler.HaulerView; import org.json.JSONArray; @@ -140,7 +141,11 @@ public class ViewImgurMediaActivity extends AppCompatActivity implements SetAsWa images = savedInstanceState.getParcelableArrayList(IMGUR_IMAGES_STATE); } - haulerView.setOnDragDismissedListener(dragDirection -> finish()); + haulerView.setOnDragDismissedListener(dragDirection -> { + int slide = dragDirection == DragDirection.UP ? R.anim.slide_out_up : R.anim.slide_out_down; + finish(); + overridePendingTransition(0, slide); + }); if (images == null) { fetchImgurMedia(imgurId); @@ -439,6 +444,7 @@ public class ViewImgurMediaActivity extends AppCompatActivity implements SetAsWa interface ParseImgurImagesAsyncTaskListener { void success(ArrayList<ImgurMedia> images); + void failed(); } @@ -493,6 +499,7 @@ public class ViewImgurMediaActivity extends AppCompatActivity implements SetAsWa interface ParseImgurImageAsyncTaskListener { void success(ImgurMedia image); + void failed(); } @@ -533,4 +540,4 @@ public class ViewImgurMediaActivity extends AppCompatActivity implements SetAsWa } } } -}
\ No newline at end of file +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java index 1bccf67b..dad6ff0c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java @@ -47,6 +47,7 @@ import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory; import com.google.android.exoplayer2.util.Util; +import com.thefuntasty.hauler.DragDirection; import com.thefuntasty.hauler.HaulerView; import java.io.File; @@ -160,7 +161,11 @@ public class ViewVideoActivity extends AppCompatActivity { params.rightMargin = getResources().getDimensionPixelSize(resourceId); } - haulerView.setOnDragDismissedListener(dragDirection -> finish()); + haulerView.setOnDragDismissedListener(dragDirection -> { + int slide = dragDirection == DragDirection.UP ? R.anim.slide_out_up : R.anim.slide_out_down; + finish(); + overridePendingTransition(0, slide); + }); Intent intent = getIntent(); mVideoUri = intent.getData(); diff --git a/app/src/main/res/anim/slide_out_down.xml b/app/src/main/res/anim/slide_out_down.xml new file mode 100644 index 00000000..4c64d6c4 --- /dev/null +++ b/app/src/main/res/anim/slide_out_down.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> + +<set xmlns:android="http://schemas.android.com/apk/res/android"> + <translate + android:duration="@android:integer/config_shortAnimTime" + android:fromYDelta="0" + android:toYDelta="+50%p" /> + <alpha + android:duration="@android:integer/config_shortAnimTime" + android:fromAlpha="1.0" + android:toAlpha="0.0" /> +</set> diff --git a/app/src/main/res/anim/slide_out_up.xml b/app/src/main/res/anim/slide_out_up.xml new file mode 100644 index 00000000..945e2b7e --- /dev/null +++ b/app/src/main/res/anim/slide_out_up.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> + +<set xmlns:android="http://schemas.android.com/apk/res/android"> + <translate + android:duration="@android:integer/config_shortAnimTime" + android:fromYDelta="0" + android:toYDelta="-50%p" /> + <alpha + android:duration="@android:integer/config_shortAnimTime" + android:fromAlpha="1.0" + android:toAlpha="0.0" /> +</set> |