From f5276521bde408e07a1f8ff779c4d9947f234dcb Mon Sep 17 00:00:00 2001 From: tornaco Date: Sun, 24 Oct 2021 21:10:14 +0800 Subject: [PATCH] [app] refresh nav ui after one key boost delayed --- .../thanos/main/PrebuiltFeatureFragment.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/android/app/src/main/java/github/tornaco/android/thanos/main/PrebuiltFeatureFragment.java b/android/app/src/main/java/github/tornaco/android/thanos/main/PrebuiltFeatureFragment.java index 8f8513536..047b654a9 100644 --- a/android/app/src/main/java/github/tornaco/android/thanos/main/PrebuiltFeatureFragment.java +++ b/android/app/src/main/java/github/tornaco/android/thanos/main/PrebuiltFeatureFragment.java @@ -1,7 +1,10 @@ package github.tornaco.android.thanos.main; +import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; @@ -54,6 +57,14 @@ public class PrebuiltFeatureFragment extends NavFragment private FragmentPrebuiltFeaturesBinding prebuiltFeaturesBinding; private NavViewModel navViewModel; + private Handler uiHandler; + + @Override + public void onAttach(Context context) { + super.onAttach(context); + this.uiHandler = new Handler(Looper.getMainLooper()); + } + @Nullable @Override public View onCreateView( @@ -98,6 +109,8 @@ public void onClick(@NonNull Tile tile) { return; } navViewModel.cleanUpBackgroundTasks(); + // Delay 1.5s to refresh + uiHandler.postDelayed(() -> navViewModel.start(), 1500); break; case R.id.id_background_start: StartRestrictActivity.start(getActivity());