add animation to setting fragment

pull/21/head
fengyuecanzhu 3 years ago
parent e52aeb1c15
commit 17e25d6c85
  1. 47
      app/src/main/java/xyz/fycz/myreader/ui/activity/MoreSettingActivity.java
  2. 15
      app/src/main/res/anim/fragment_enter.xml
  3. 15
      app/src/main/res/anim/fragment_enter_pop.xml
  4. 15
      app/src/main/res/anim/fragment_exit.xml
  5. 15
      app/src/main/res/anim/fragment_exit_pop.xml

@ -11,6 +11,8 @@ import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.NumberPicker;
@ -103,6 +105,9 @@ public class MoreSettingActivity extends BaseActivity<ActivityMoreSettingBinding
// 是否前往webdav设置
private boolean isWebDav;
private Animation enterAnim;
private Animation exitAnim;
@Override
protected void bindView() {
binding = ActivityMoreSettingBinding.inflate(getLayoutInflater());
@ -130,6 +135,8 @@ public class MoreSettingActivity extends BaseActivity<ActivityMoreSettingBinding
enType = mSetting.isEnType();
threadNum = SharedPreUtils.getInstance().getInt(getString(R.string.threadNum), 8);
isWebDav = getIntent().getBooleanExtra(APPCONST.WEB_DAV, false);
enterAnim = AnimationUtils.loadAnimation(this, R.anim.fragment_enter_pop);
exitAnim = AnimationUtils.loadAnimation(this, R.anim.fragment_exit_pop);
}
@Override
@ -243,7 +250,15 @@ public class MoreSettingActivity extends BaseActivity<ActivityMoreSettingBinding
super.initClick();
binding.llProxy.setOnClickListener(v -> {
binding.svContent.setVisibility(View.GONE);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
binding.svContent.startAnimation(exitAnim);
FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction()
.setCustomAnimations(
R.anim.fragment_enter,
R.anim.fragment_exit,
R.anim.fragment_enter_pop,
R.anim.fragment_exit_pop
);
if (mProxyFragment == null) {
mProxyFragment = new ProxyFragment();
ft.add(R.id.ll_content, mProxyFragment);
@ -257,7 +272,15 @@ public class MoreSettingActivity extends BaseActivity<ActivityMoreSettingBinding
binding.llWebdav.setOnClickListener(v -> {
binding.svContent.setVisibility(View.GONE);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
binding.svContent.startAnimation(exitAnim);
FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction()
.setCustomAnimations(
R.anim.fragment_enter,
R.anim.fragment_exit,
R.anim.fragment_enter_pop,
R.anim.fragment_exit_pop
);
if (mWebDavFragment == null) {
mWebDavFragment = new WebDavFragment();
ft.add(R.id.ll_content, mWebDavFragment);
@ -609,7 +632,15 @@ public class MoreSettingActivity extends BaseActivity<ActivityMoreSettingBinding
super.finish();
} else {
binding.svContent.setVisibility(View.VISIBLE);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
binding.svContent.startAnimation(enterAnim);
FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction()
.setCustomAnimations(
R.anim.fragment_enter,
R.anim.fragment_exit,
R.anim.fragment_enter_pop,
R.anim.fragment_exit_pop
);
ft.hide(curFragment);
ft.commit();
curFragment = null;
@ -754,7 +785,15 @@ public class MoreSettingActivity extends BaseActivity<ActivityMoreSettingBinding
private void showPrivateBooksFragment() {
binding.svContent.setVisibility(View.GONE);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
binding.svContent.startAnimation(exitAnim);
FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction()
.setCustomAnimations(
R.anim.fragment_enter,
R.anim.fragment_exit,
R.anim.fragment_enter_pop,
R.anim.fragment_exit_pop
);
if (mPrivateBooksFragment == null) {
mPrivateBooksFragment = new PrivateBooksFragment();
ft.add(R.id.ll_content, mPrivateBooksFragment);

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:duration="@android:integer/config_shortAnimTime"
android:fromAlpha="0"
android:toAlpha="1" />
<scale
android:duration="@android:integer/config_shortAnimTime"
android:fromXScale="0.9"
android:fromYScale="0.9"
android:pivotX="50%p"
android:pivotY="50%p"
android:toXScale="1"
android:toYScale="1" />
</set>

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:duration="@android:integer/config_shortAnimTime"
android:fromAlpha="0"
android:toAlpha="1" />
<scale
android:duration="@android:integer/config_shortAnimTime"
android:fromXScale="1.1"
android:fromYScale="1.1"
android:pivotX="50%p"
android:pivotY="50%p"
android:toXScale="1"
android:toYScale="1" />
</set>

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:duration="@android:integer/config_shortAnimTime"
android:fromAlpha="1"
android:toAlpha="0" />
<scale
android:duration="@android:integer/config_shortAnimTime"
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%p"
android:pivotY="50%p"
android:toXScale="1.1"
android:toYScale="1.1" />
</set>

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:duration="@android:integer/config_shortAnimTime"
android:fromAlpha="1"
android:toAlpha="0" />
<scale
android:duration="@android:integer/config_shortAnimTime"
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%p"
android:pivotY="50%p"
android:toXScale="0.9"
android:toYScale="0.9" />
</set>
Loading…
Cancel
Save