YoKeyword / Fragmentation

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

有没有办法专门pop一个指定fragment? #1232

Closed mikilangkilo closed 4 years ago

mikilangkilo commented 4 years ago

Issues Guideline

Following information can help us to resolve the issue faster.

In addition, we do not accept issues unrelated to Fragmentation.

我们接了fragmentation,使用isupportfragment来做的插入。

但是发现只有pop()是回退的操作,因此在basefragment里面的onbackpressed()中执行了pop()做回退。

结果目前发现在monkey过程中,快速点击造成onbackpressed执行了2次,同时执行了2次pop,导致多回退了一个fragment。

请问有没有办法单独pop一个指定的当前的fragment?

mikilangkilo commented 4 years ago

TransactionDelegate 这个类的的pop()方法中

void pop(final FragmentManager fm) {
        enqueue(fm, new Action(Action.ACTION_POP, fm) {
            @Override
            public void run() {
                handleAfterSaveInStateTransactionException(fm, "pop()");
                FragmentationMagician.popBackStackAllowingStateLoss(fm);
                removeTopFragment(fm);
            }
        });
    }

发现主要问题是这里没有做判断topfragment是否是当前framgent,导致当前fragment变动,快速点击触发的多余的action还是会执行。

另外大大真的不维护了吗??

JantHsueh commented 4 years ago

@GWYloved 这个应该是防抖动的操作,你的项目有使用SupportActivity(继承或者实现的方式)吗?

另外这个库,我在继续维护,已经发布了新版本https://github.com/YoKeyword/Fragmentation/issues/1237