Removing unnecessary ActivityContextDelegate
Bug: 393703968 Flag: EXEMPT refactor Test: Presubmit Change-Id: Ib95b26de000a2fe8204fdbc46c8a9da4f65c7eab
This commit is contained in:
@@ -481,10 +481,8 @@ public abstract class BaseActivity extends Activity implements ActivityContext,
|
||||
public static <T extends BaseActivity> T fromContext(Context context) {
|
||||
if (context instanceof BaseActivity) {
|
||||
return (T) context;
|
||||
} else if (context instanceof ActivityContextDelegate) {
|
||||
return (T) ((ActivityContextDelegate) context).mDelegate;
|
||||
} else if (context instanceof ContextWrapper) {
|
||||
return fromContext(((ContextWrapper) context).getBaseContext());
|
||||
} else if (context instanceof ContextWrapper cw) {
|
||||
return fromContext(cw.getBaseContext());
|
||||
} else {
|
||||
throw new IllegalArgumentException("Cannot find BaseActivity in parent tree");
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.launcher3.recyclerview
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import android.view.ContextThemeWrapper
|
||||
import android.view.InflateException
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import androidx.annotation.VisibleForTesting.Companion.PROTECTED
|
||||
@@ -33,8 +34,6 @@ import com.android.launcher3.util.Executors.MAIN_EXECUTOR
|
||||
import com.android.launcher3.util.Executors.VIEW_PREINFLATION_EXECUTOR
|
||||
import com.android.launcher3.util.Themes
|
||||
import com.android.launcher3.views.ActivityContext
|
||||
import com.android.launcher3.views.ActivityContext.ActivityContextDelegate
|
||||
import java.lang.IllegalStateException
|
||||
|
||||
const val PREINFLATE_ICONS_ROW_COUNT = 4
|
||||
const val EXTRA_ICONS_COUNT = 2
|
||||
@@ -80,11 +79,9 @@ class AllAppsRecyclerViewPool<T> : RecycledViewPool() where T : Context, T : Act
|
||||
// create a separate AssetManager obj internally to avoid lock contention with
|
||||
// AssetManager obj that is associated with the launcher context on the main thread.
|
||||
val allAppsPreInflationContext =
|
||||
ActivityContextDelegate(
|
||||
context.createConfigurationContext(context.resources.configuration),
|
||||
Themes.getActivityThemeRes(context),
|
||||
context,
|
||||
)
|
||||
ContextThemeWrapper(context, Themes.getActivityThemeRes(context)).apply {
|
||||
applyOverrideConfiguration(context.resources.configuration)
|
||||
}
|
||||
|
||||
// Because we perform onCreateViewHolder() on worker thread, we need a separate
|
||||
// adapter/inflator object as they are not thread-safe. Note that the adapter
|
||||
|
||||
@@ -43,7 +43,6 @@ import android.os.IBinder;
|
||||
import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.Display;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -552,21 +551,10 @@ public interface ActivityContext {
|
||||
static <T extends Context & ActivityContext> T lookupContextNoThrow(Context context) {
|
||||
if (context instanceof ActivityContext) {
|
||||
return (T) context;
|
||||
} else if (context instanceof ActivityContextDelegate acd) {
|
||||
return (T) acd.mDelegate;
|
||||
} else if (context instanceof ContextWrapper) {
|
||||
return lookupContextNoThrow(((ContextWrapper) context).getBaseContext());
|
||||
} else if (context instanceof ContextWrapper cw) {
|
||||
return lookupContextNoThrow(cw.getBaseContext());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class ActivityContextDelegate extends ContextThemeWrapper {
|
||||
public final ActivityContext mDelegate;
|
||||
|
||||
public ActivityContextDelegate(Context base, int themeResId, ActivityContext delegate) {
|
||||
super(base, themeResId);
|
||||
mDelegate = delegate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user