Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't change tag of fragment YxpStarLoadDialog{a60c8e0 #7 1568169695869}: was 1568169695869 now 1568169696411 #33

Open
zhuzhushang opened this issue Sep 11, 2019 · 1 comment

Comments

@zhuzhushang
Copy link

    public BaseNiceDialog show(FragmentManager manager) {
        FragmentTransaction ft = manager.beginTransaction();
        if (this.isAdded()) {
            ft.remove(this).commit();
        }
        ft.add(this, String.valueOf(System.currentTimeMillis()));
        ft.commitAllowingStateLoss();
        return this;
    }
09-11 10:41:36.413  5744  5744 E AndroidRuntime: FATAL EXCEPTION: main
09-11 10:41:36.413  5744  5744 E AndroidRuntime: Process: com.noahedu.intelligentguidestudy, PID: 5744
09-11 10:41:36.413  5744  5744 E AndroidRuntime: java.lang.IllegalStateException: Can't change tag of fragment YxpStarLoadDialog{a60c8e0 #7 1568169695869}: was 1568169695869 now 1568169696411
09-11 10:41:36.413  5744  5744 E AndroidRuntime: 	at android.support.v4.app.BackStackRecord.doAddOp(BackStackRecord.java:393)
09-11 10:41:36.413  5744  5744 E AndroidRuntime: 	at android.support.v4.app.BackStackRecord.add(BackStackRecord.java:363)
09-11 10:41:36.413  5744  5744 E AndroidRuntime: 	at com.othershe.nicedialog.BaseNiceDialog.show(BaseNiceDialog.java:177)
09-11 10:41:36.413  5744  5744 E AndroidRuntime: 	at com.noahedu.youyou.view.widget.wbeview.MyWebView.showLoadDialog(MyWebView.java:588)
09-11 10:41:36.413  5744  5744 E AndroidRuntime: 	at com.noahedu.youyou.view.widget.wbeview.MyWebView$WebClient$2.run(MyWebView.java:518)
09-11 10:41:36.413  5744  5744 E AndroidRuntime: 	at android.app.Activity.runOnUiThread(Activity.java:5969)
09-11 10:41:36.413  5744  5744 E AndroidRuntime: 	at com.noahedu.youyou.view.widget.wbeview.MyWebView$WebClient.onPageStarted(MyWebView.java:515)
09-11 10:41:36.413  5744  5744 E AndroidRuntime: 	at com.android.webview.chromium.WebViewContentsClientAdapter.onPageStarted(WebViewContentsClientAdapter.java:517)
09-11 10:41:36.413  5744  5744 E AndroidRuntime: 	at org.chromium.android_webview.AwContentsClientCallbackHelper$MyHandler.handleMessage(AwContentsClientCallbackHelper.java:144)
09-11 10:41:36.413  5744  5744 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:110)
09-11 10:41:36.413  5744  5744 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:203)
09-11 10:41:36.413  5744  5744 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:6293)
09-11 10:41:36.413  5744  5744 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
09-11 10:41:36.413  5744  5744 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1084)
09-11 10:41:36.413  5744  5744 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:945)
--------- beginning of system

ft.remove(this).commit();
此方法并不是同步的,当两次show很快的时候,就可能出现这个错。所以可以做下处理,比如换成ft.remove(this).commitNow();

@cultivation-of-taoism
Copy link

ft.add(this, String.valueOf(System.currentTimeMillis()));
每次添加都会改变一下tag值,将这个tag值固定一下应该就可以了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants