动画集合后, 记住页面

public class FragmentThree extends Fragment {

    private SharedPreferences.Editor editor;
    private SharedPreferences preferences;
    Handler handler = new Handler();

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        View view = View.inflate(getActivity(), R.layout.frag_three, null);

        ImageView iv = view.findViewById(R.id.iv);

        // 动画集合
        AnimationSet animationSet = new AnimationSet(true);
        // 透明度
        AlphaAnimation alphaAnimation = new AlphaAnimation(1f, 0.2f);
        animationSet.addAnimation(alphaAnimation);

        // 缩放
        ScaleAnimation scaleAnimation = new ScaleAnimation(1f, 2f, 1f, 0.5f);
        animationSet.addAnimation(scaleAnimation);

        // 旋转
        RotateAnimation rotateAnimation = new RotateAnimation(0f, 90f, 0.5f, 0.5f);
        animationSet.addAnimation(rotateAnimation);

        // 设置动画时间
        animationSet.setDuration(3000);
        animationSet.setFillAfter(true);
        iv.setAnimation(animationSet);

        preferences = getActivity().getSharedPreferences("config", MODE_PRIVATE);
        editor = preferences.edit();
// 记住页面
        final Boolean flag = preferences.getBoolean("flag", false);

        handler.postDelayed(new Runnable() {
            @Override
            public void run() {

                if (flag == false) {
                    editor.putBoolean("flag", true);
                    editor.commit();
                    Intent intent = new Intent(getActivity(), OtherActivity.class);
                    startActivity(intent);
                    getActivity().finish();
                }

            }
        }, 4000);

        return view;
    }
}



/*****************************************************/

记住上面的页面   下次直接从第一个页面跳转

public class FragmentOne extends Fragment {


    private SharedPreferences.Editor editor;
    private SharedPreferences preferences;


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {


        // 加载布局
                View view = View.inflate(getActivity(), R.layout.frag_one,null);


        //
        preferences = getActivity().getSharedPreferences("config",MODE_PRIVATE);
        editor = preferences.edit();


        final Boolean flag = preferences.getBoolean("flag",false);


        if(flag){
            Intent intent = new Intent(getActivity(), OtherActivity.class);
            startActivity(intent);
            getActivity().finish();
        }


        return view;
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值