Merge pull request #123 from OHermesJunior/media-exit-anim

Make exit animation follow slide direction on media activities.
This commit is contained in:
Docile-Alligator 2020-06-16 12:27:54 +08:00 committed by GitHub
commit 268ea4f9d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 52 additions and 6 deletions

View File

@ -36,6 +36,7 @@ import com.bumptech.glide.load.resource.gif.GifDrawable;
import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target; import com.bumptech.glide.request.target.Target;
import com.thefuntasty.hauler.DragDirection;
import com.thefuntasty.hauler.HaulerView; import com.thefuntasty.hauler.HaulerView;
import java.io.File; import java.io.File;
@ -117,7 +118,11 @@ public class ViewGIFActivity extends AppCompatActivity {
actionBar.setHomeAsUpIndicator(upArrow); actionBar.setHomeAsUpIndicator(upArrow);
actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.transparentActionBarAndExoPlayerControllerColor))); 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); glide = Glide.with(this);

View File

@ -43,6 +43,7 @@ import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.CustomTarget; import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.target.Target; import com.bumptech.glide.request.target.Target;
import com.bumptech.glide.request.transition.Transition; import com.bumptech.glide.request.transition.Transition;
import com.thefuntasty.hauler.DragDirection;
import com.thefuntasty.hauler.HaulerView; import com.thefuntasty.hauler.HaulerView;
import java.io.File; import java.io.File;
@ -138,7 +139,11 @@ public class ViewImageActivity extends AppCompatActivity implements SetAsWallpap
setTitle(""); 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 -> { mLoadErrorLinearLayout.setOnClickListener(view -> {
mProgressBar.setVisibility(View.VISIBLE); mProgressBar.setVisibility(View.VISIBLE);

View File

@ -32,6 +32,7 @@ import androidx.viewpager.widget.ViewPager;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.CustomTarget; import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition; import com.bumptech.glide.request.transition.Transition;
import com.thefuntasty.hauler.DragDirection;
import com.thefuntasty.hauler.HaulerView; import com.thefuntasty.hauler.HaulerView;
import org.json.JSONArray; import org.json.JSONArray;
@ -140,7 +141,11 @@ public class ViewImgurMediaActivity extends AppCompatActivity implements SetAsWa
images = savedInstanceState.getParcelableArrayList(IMGUR_IMAGES_STATE); 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) { if (images == null) {
fetchImgurMedia(imgurId); fetchImgurMedia(imgurId);
@ -447,6 +452,7 @@ public class ViewImgurMediaActivity extends AppCompatActivity implements SetAsWa
interface ParseImgurImagesAsyncTaskListener { interface ParseImgurImagesAsyncTaskListener {
void success(ArrayList<ImgurMedia> images); void success(ArrayList<ImgurMedia> images);
void failed(); void failed();
} }
@ -501,6 +507,7 @@ public class ViewImgurMediaActivity extends AppCompatActivity implements SetAsWa
interface ParseImgurImageAsyncTaskListener { interface ParseImgurImageAsyncTaskListener {
void success(ImgurMedia image); void success(ImgurMedia image);
void failed(); void failed();
} }

View File

@ -47,6 +47,7 @@ import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory; import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import com.thefuntasty.hauler.DragDirection;
import com.thefuntasty.hauler.HaulerView; import com.thefuntasty.hauler.HaulerView;
import java.io.File; import java.io.File;
@ -160,7 +161,11 @@ public class ViewVideoActivity extends AppCompatActivity {
params.rightMargin = getResources().getDimensionPixelSize(resourceId); 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(); Intent intent = getIntent();
mVideoUri = intent.getData(); mVideoUri = intent.getData();

View File

@ -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>

View File

@ -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>