From 87d4e8d85f86dce1ce681198e88109ff4071fca0 Mon Sep 17 00:00:00 2001 From: Hermes Junior Date: Mon, 15 Jun 2020 15:24:15 +0200 Subject: Make exit animation follow slide direction on media activities. --- .../infinityforreddit/Activity/ViewGIFActivity.java | 7 ++++++- .../infinityforreddit/Activity/ViewImageActivity.java | 9 +++++++-- .../infinityforreddit/Activity/ViewImgurMediaActivity.java | 11 +++++++++-- .../infinityforreddit/Activity/ViewVideoActivity.java | 7 ++++++- 4 files changed, 28 insertions(+), 6 deletions(-) (limited to 'app/src/main/java') 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 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(); -- cgit v1.2.3