YoKeyword / Fragmentation

[DEPRECATED] A powerful library that manage Fragment for Android
Apache License 2.0
9.72k stars 2.11k forks source link

继承SwipeBackFragment的Fragment,用手指滑动关闭时,前一个页面显示为空白,当手指松开,动画完成后,屏幕闪一下,才会显示前一个页面 #57

Closed aresa7796 closed 8 years ago

aresa7796 commented 8 years ago

BackFragment.java BaseBackFragment extends SwipeBackFragment; public class BackFragment extends BaseBackFragment { @Override public int getContentViewId() { return R.layout.home_layout; }

@Override
protected void initAllMembersView(Bundle savedInstanceState) {
}

@Override
protected void onEnterAnimationEnd(Bundle savedInstanceState) {
    super.onEnterAnimationEnd(savedInstanceState);
    // 入场动画结束后执行  优化,防动画卡顿
}

@Override
public void onDestroyView() {
    super.onDestroyView();
}

public static BackFragment newInstance() {

    Bundle args = new Bundle();

    BackFragment fragment = new BackFragment();
    fragment.setArguments(args);
    return fragment;
}

}

public class ManiFragment extends BaseFragment {

@BindView(R.id.viewpager)
ViewPager viewPager;
@BindView(R.id.bottom_bar)
SmartTabLayout bottomBar;
String[] tabNames = new String[]{"首页","发现", "我的"};
int[] tabIcons = new int[]{R.drawable.home_selector,R.drawable.home_selector, R.drawable.my_selector};

@Override
public int getContentViewId() {
    return R.layout.main_layout;
}

@Override
protected void initAllMembersView(Bundle savedInstanceState) {
    FragmentPagerItems pages = new FragmentPagerItems(getContext());
    for (int i = 0; i < tabNames.length; i++) {
        if(i == 1){
            pages.add(FragmentPagerItem.of(tabNames[i],tabIcons[i], MyFragment.class));
        }else{
            pages.add(FragmentPagerItem.of(tabNames[i],tabIcons[i], HomeFragment.class));
        }

    }

    bottomBar.setCustomTabView(new ImageTextTabProvider(getContext()));
    FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
            getFragmentManager(), pages);

    viewPager.setAdapter(adapter);
    bottomBar.setViewPager(viewPager);

    RxBus.get().register(this);
}

@Override
public void onDestroyView() {
    super.onDestroyView();
    RxBus.get().unregister(this);
}

public static ManiFragment newInstance() {

    Bundle args = new Bundle();

    ManiFragment fragment = new ManiFragment();
    fragment.setArguments(args);
    return fragment;
}

@Subscribe
public void onStartFragment(StartBrotherEvent event){
    start(event.targetFragment);
}

@Override
public FragmentAnimator onCreateFragmentAnimator() {
    // 设置横向(和安卓4.x动画相同)
    return new DefaultHorizontalAnimator();
}

} device-2016-08-12-163036

YoKeyword commented 8 years ago

1.每个SwipeBack的Fragment都会这样吗?
2.还是只有这个页面?
3.每次都这样吗?

参照下Demo以及README,以及重点查看下栈视图是否正常~

aresa7796 commented 8 years ago

我找到原因了,查了一下栈试图,是层级不对