Expand null check to include isAdded()
check
Also, don't call `getActivity()` in the separate thread. Instead, use the `Activity` which we have already checked and ensured is not null.
This commit is contained in:
parent
3c33e55fd3
commit
7421d33c3a
@ -82,18 +82,14 @@ public class AvailableAppsFragment extends AppListFragment implements
|
|||||||
// me that "Only the original thread that created a view
|
// me that "Only the original thread that created a view
|
||||||
// hierarchy can touch its views."
|
// hierarchy can touch its views."
|
||||||
final Activity activity = getActivity();
|
final Activity activity = getActivity();
|
||||||
// this nullguard is temporary, this Fragment really needs to merged into the Activity
|
if (!isAdded() || adapter == null || activity == null) {
|
||||||
if (activity == null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (adapter == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
adapter.clear();
|
adapter.clear();
|
||||||
categories = AppProvider.Helper.categories(getActivity());
|
categories = AppProvider.Helper.categories(activity);
|
||||||
ArrayAdapterCompat.addAll(adapter, translateCategories(categories));
|
ArrayAdapterCompat.addAll(adapter, translateCategories(categories));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user