Merge "[Settings] Avoid from crash UI when querying data usage" into tm-dev am: 5ef52de6b2 am: 3444d7a8c2

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/17950069

Change-Id: Icdde7b07efbdbeeb80c917c03ac0dc073d2fce8c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Bonian Chen
2022-05-02 08:32:32 +00:00
committed by Automerger Merge Worker

View File

@@ -48,6 +48,7 @@ import android.widget.ImageView;
import android.widget.Spinner; import android.widget.Spinner;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import androidx.lifecycle.Lifecycle;
import androidx.loader.app.LoaderManager.LoaderCallbacks; import androidx.loader.app.LoaderManager.LoaderCallbacks;
import androidx.loader.content.Loader; import androidx.loader.content.Loader;
import androidx.preference.Preference; import androidx.preference.Preference;
@@ -514,6 +515,17 @@ public class DataUsageList extends DataUsageBaseFragment
+ cycle.end + "]"); + cycle.end + "]");
} }
// Avoid from updating UI after #onStop.
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
return;
}
// Avoid from updating UI when async query still on-going.
// This could happen when a request from #onMobileDataEnabledChange.
if (mCycleData == null) {
return;
}
// update chart to show selected cycle, and update detail data // update chart to show selected cycle, and update detail data
// to match updated sweep bounds. // to match updated sweep bounds.
mChart.setNetworkCycleData(mCycleData.get(position)); mChart.setNetworkCycleData(mCycleData.get(position));