Animation transitions for left/right navigation

pull/147/head
M66B 7 years ago
parent d2e0344f1e
commit 03173c4651

@ -1096,6 +1096,9 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
} }
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.setCustomAnimations(
android.R.anim.fade_in, android.R.anim.fade_in,
android.R.anim.fade_out, android.R.anim.fade_out);
fragmentTransaction.replace(pane, fragment).addToBackStack("thread"); fragmentTransaction.replace(pane, fragment).addToBackStack("thread");
fragmentTransaction.commit(); fragmentTransaction.commit();
} }

@ -73,6 +73,7 @@ import androidx.appcompat.widget.PopupMenu;
import androidx.appcompat.widget.SearchView; import androidx.appcompat.widget.SearchView;
import androidx.constraintlayout.widget.Group; import androidx.constraintlayout.widget.Group;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction; import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Lifecycle; import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.Observer; import androidx.lifecycle.Observer;
@ -112,6 +113,7 @@ public class FragmentMessages extends FragmentBase {
private String thread; private String thread;
private long id; private long id;
private String search; private String search;
private boolean pane;
private boolean threading; private boolean threading;
private boolean pull; private boolean pull;
@ -169,6 +171,7 @@ public class FragmentMessages extends FragmentBase {
thread = args.getString("thread"); thread = args.getString("thread");
id = args.getLong("id", -1); id = args.getLong("id", -1);
search = args.getString("search"); search = args.getString("search");
pane = args.getBoolean("pane", false);
if (TextUtils.isEmpty(search)) if (TextUtils.isEmpty(search))
if (thread == null) if (thread == null)
@ -304,16 +307,16 @@ public class FragmentMessages extends FragmentBase {
activity.setSwipeListener(new SwipeListener.ISwipeListener() { activity.setSwipeListener(new SwipeListener.ISwipeListener() {
@Override @Override
public boolean onSwipeRight() { public boolean onSwipeRight() {
if (next != null) if (previous != null)
navigate(next); navigate(previous, true);
return (next != null); return (previous != null);
} }
@Override @Override
public boolean onSwipeLeft() { public boolean onSwipeLeft() {
if (previous != null) if (next != null)
navigate(previous); navigate(next, false);
return (previous != null); return (next != null);
} }
}); });
@ -379,11 +382,11 @@ public class FragmentMessages extends FragmentBase {
return true; return true;
case R.id.action_prev: case R.id.action_prev:
navigate(previous); navigate(previous, true);
return true; return true;
case R.id.action_next: case R.id.action_next:
navigate(next); navigate(next, false);
return true; return true;
default: default:
@ -2134,12 +2137,12 @@ public class FragmentMessages extends FragmentBase {
finish(); finish();
else { else {
Log.i("Navigating to last next=" + closeNext); Log.i("Navigating to last next=" + closeNext);
navigate(closeNext); navigate(closeNext, false);
} }
} }
} }
private void navigate(long id) { private void navigate(long id, final boolean left) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("id", id); args.putLong("id", id);
new SimpleTask<EntityMessage>() { new SimpleTask<EntityMessage>() {
@ -2156,12 +2159,25 @@ public class FragmentMessages extends FragmentBase {
return; return;
} }
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext()); getFragmentManager().popBackStack("thread", FragmentManager.POP_BACK_STACK_INCLUSIVE);
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_THREAD) Bundle nargs = new Bundle();
.putExtra("account", message.account) nargs.putLong("account", message.account);
.putExtra("thread", message.thread) nargs.putString("thread", message.thread);
.putExtra("id", message.id)); nargs.putLong("id", message.id);
nargs.putBoolean("pane", pane);
FragmentMessages fragment = new FragmentMessages();
fragment.setArguments(nargs);
int res = (pane ? R.id.content_pane : R.id.content_frame);
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.setCustomAnimations(
left ? R.anim.enter_from_left : R.anim.enter_from_right,
left ? R.anim.exit_to_right : R.anim.exit_to_left,
android.R.anim.fade_out, android.R.anim.fade_out);
fragmentTransaction.replace(res, fragment).addToBackStack("thread");
fragmentTransaction.commit();
} }
@Override @Override

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:duration="@android:integer/config_longAnimTime"
android:fromXDelta="-100%"
android:fromYDelta="0%"
android:toXDelta="0%"
android:toYDelta="0%" />
</set>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:duration="@android:integer/config_longAnimTime"
android:fromXDelta="100%"
android:fromYDelta="0%"
android:toXDelta="0%"
android:toYDelta="0%" />
</set>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:duration="@android:integer/config_longAnimTime"
android:fromXDelta="0%"
android:fromYDelta="0%"
android:toXDelta="-100%"
android:toYDelta="0%" />
</set>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:duration="@android:integer/config_longAnimTime"
android:fromXDelta="0%"
android:fromYDelta="0%"
android:toXDelta="100%"
android:toYDelta="0%" />
</set>
Loading…
Cancel
Save