Removing some synthetic method creation

> Make package-private and @Thunk all private methods and constructors accessed from inner classes.

Change-Id: Ie5913860a0c33e48e9bf68f9b5b1699f64c2f174
This commit is contained in:
Sunny Goyal
2015-06-02 09:38:28 -07:00
parent c1cd23b4a7
commit 316490e636
20 changed files with 62 additions and 59 deletions
@@ -64,7 +64,7 @@ public abstract class ButtonDropTarget extends TextView
protected Drawable mDrawable;
private AnimatorSet mCurrentColorAnim;
private ColorMatrix mSrcFilter, mDstFilter, mCurrentFilter;
@Thunk ColorMatrix mSrcFilter, mDstFilter, mCurrentFilter;
public ButtonDropTarget(Context context, AttributeSet attrs) {
+2 -4
View File
@@ -130,10 +130,8 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
private final ClickShadowView mTouchFeedbackView;
@Thunk HashMap<CellLayout.LayoutParams, Animator> mReorderAnimators = new
HashMap<CellLayout.LayoutParams, Animator>();
private HashMap<View, ReorderPreviewAnimation>
mShakeAnimators = new HashMap<View, ReorderPreviewAnimation>();
@Thunk HashMap<CellLayout.LayoutParams, Animator> mReorderAnimators = new HashMap<>();
@Thunk HashMap<View, ReorderPreviewAnimation> mShakeAnimators = new HashMap<>();
private boolean mItemPlacementDirty = false;
@@ -26,6 +26,7 @@ import android.util.Log;
import com.android.launcher3.AutoInstallsLayout.LayoutParserCallback;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.backup.BackupProtos.Favorite;
import com.android.launcher3.util.Thunk;
import org.xmlpull.v1.XmlPullParserException;
@@ -44,8 +45,8 @@ public class CommonAppTypeParser implements LayoutParserCallback {
private final long mItemId;
private final int mResId;
private final Context mContext;
@Thunk final int mResId;
@Thunk final Context mContext;
ContentValues parsedValues;
Intent parsedIntent;
+2 -2
View File
@@ -44,7 +44,7 @@ public class DragView extends View {
private Bitmap mBitmap;
private Bitmap mCrossFadeBitmap;
private Paint mPaint;
@Thunk Paint mPaint;
private int mRegistrationX;
private int mRegistrationY;
@@ -62,7 +62,7 @@ public class DragView extends View {
// size. This is ignored for non-icons.
private float mIntrinsicIconScale = 1f;
private float[] mCurrentFilter;
@Thunk float[] mCurrentFilter;
private ValueAnimator mFilterAnimator;
/**
+1 -1
View File
@@ -426,7 +426,7 @@ public class FocusHelper {
/**
* Private helper method to get the CellLayoutChildren given a CellLayout index.
*/
private static ShortcutAndWidgetContainer getCellLayoutChildrenForIndex(
@Thunk static ShortcutAndWidgetContainer getCellLayoutChildrenForIndex(
ViewGroup container, int i) {
CellLayout parent = (CellLayout) container.getChildAt(i);
return parent.getShortcutsAndWidgets();
+9 -9
View File
@@ -69,7 +69,7 @@ public class IconCache {
private static final int LOW_RES_SCALE_FACTOR = 8;
private static final Object ICON_UPDATE_TOKEN = new Object();
@Thunk static final Object ICON_UPDATE_TOKEN = new Object();
@Thunk static class CacheEntry {
public Bitmap icon;
@@ -79,18 +79,18 @@ public class IconCache {
}
private final HashMap<UserHandleCompat, Bitmap> mDefaultIcons = new HashMap<>();
private final MainThreadExecutor mMainThreadExecutor = new MainThreadExecutor();
@Thunk final MainThreadExecutor mMainThreadExecutor = new MainThreadExecutor();
private final Context mContext;
private final PackageManager mPackageManager;
private final UserManagerCompat mUserManager;
@Thunk final UserManagerCompat mUserManager;
private final LauncherAppsCompat mLauncherApps;
private final HashMap<ComponentKey, CacheEntry> mCache =
new HashMap<ComponentKey, CacheEntry>(INITIAL_ICON_CACHE_CAPACITY);
private final int mIconDpi;
private final IconDB mIconDb;
@Thunk final IconDB mIconDb;
private final Handler mWorkerHandler;
@Thunk final Handler mWorkerHandler;
public IconCache(Context context, InvariantDeviceProfile inv) {
ActivityManager activityManager =
@@ -320,7 +320,7 @@ public class IconCache {
}
}
private void addIconToDBAndMemCache(LauncherActivityInfoCompat app, PackageInfo info,
@Thunk void addIconToDBAndMemCache(LauncherActivityInfoCompat app, PackageInfo info,
long userSerial) {
// Reuse the existing entry if it already exists in the DB. This ensures that we do not
// create bitmap if it was already created during loader.
@@ -342,7 +342,7 @@ public class IconCache {
SQLiteDatabase.CONFLICT_REPLACE);
}
private ContentValues updateCacheAndGetContentValues(LauncherActivityInfoCompat app,
@Thunk ContentValues updateCacheAndGetContentValues(LauncherActivityInfoCompat app,
boolean replaceExisting) {
final ComponentKey key = new ComponentKey(app.getComponentName(), app.getUser());
CacheEntry entry = null;
@@ -688,14 +688,14 @@ public class IconCache {
* LauncherActivityInfoCompat list. Items are updated/added one at a time, so that the
* worker thread doesn't get blocked.
*/
private class SerializedIconUpdateTask implements Runnable {
@Thunk class SerializedIconUpdateTask implements Runnable {
private final long mUserSerial;
private final HashMap<String, PackageInfo> mPkgInfoMap;
private final Stack<LauncherActivityInfoCompat> mAppsToAdd;
private final Stack<LauncherActivityInfoCompat> mAppsToUpdate;
private final HashSet<String> mUpdatedPackages = new HashSet<String>();
private SerializedIconUpdateTask(long userSerial, HashMap<String, PackageInfo> pkgInfoMap,
@Thunk SerializedIconUpdateTask(long userSerial, HashMap<String, PackageInfo> pkgInfoMap,
Stack<LauncherActivityInfoCompat> appsToAdd,
Stack<LauncherActivityInfoCompat> appsToUpdate) {
mUserSerial = userSerial;
+2 -2
View File
@@ -265,7 +265,7 @@ public class Launcher extends Activity
private int[] mTmpAddItemCellCoordinates = new int[2];
private Hotseat mHotseat;
@Thunk Hotseat mHotseat;
private ViewGroup mOverviewPanel;
private View mAllAppsButton;
@@ -402,7 +402,7 @@ public class Launcher extends Activity
FocusIndicatorView mFocusHandler;
private boolean mRotationEnabled = false;
@Thunk boolean mRotationEnabled = false;
private boolean mPreferenceObserverRegistered = false;
final private SharedPreferences.OnSharedPreferenceChangeListener mSettingsObserver =
@@ -51,13 +51,13 @@ import com.android.launcher3.backup.BackupProtos.Screen;
import com.android.launcher3.backup.BackupProtos.Widget;
import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.util.Thunk;
import com.google.protobuf.nano.InvalidProtocolBufferNanoException;
import com.google.protobuf.nano.MessageNano;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -135,7 +135,7 @@ public class LauncherBackupHelper implements BackupHelper {
private static final int SCREEN_RANK_INDEX = 2;
private final Context mContext;
@Thunk final Context mContext;
private final HashSet<String> mExistingKeys;
private final ArrayList<Key> mKeys;
private final ItemTypeMatcher[] mItemTypeMatchers;
@@ -1157,15 +1157,15 @@ public class LauncherBackupHelper implements BackupHelper {
.getSerialNumberForUser(UserHandleCompat.myUserHandle());
}
private class InvalidBackupException extends IOException {
@Thunk class InvalidBackupException extends IOException {
private static final long serialVersionUID = 8931456637211665082L;
private InvalidBackupException(Throwable cause) {
@Thunk InvalidBackupException(Throwable cause) {
super(cause);
}
public InvalidBackupException(String reason) {
@Thunk InvalidBackupException(String reason) {
super(reason);
}
}
+2 -2
View File
@@ -275,7 +275,7 @@ public class LauncherModel extends BroadcastReceiver
/**
* Runs the specified runnable after the loader is complete
*/
private void runAfterBindCompletes(Runnable r) {
@Thunk void runAfterBindCompletes(Runnable r) {
if (isLoadingWorkspace() || !mHasLoaderCompletedOnce) {
synchronized (mBindCompleteRunnables) {
mBindCompleteRunnables.add(r);
@@ -3350,7 +3350,7 @@ public class LauncherModel extends BroadcastReceiver
*
* @see #loadAndBindWidgetsAndShortcuts
*/
private WidgetsModel createWidgetsModel(Context context, boolean refresh) {
@Thunk WidgetsModel createWidgetsModel(Context context, boolean refresh) {
PackageManager packageManager = context.getPackageManager();
final ArrayList<Object> widgetsAndShortcuts = new ArrayList<Object>();
widgetsAndShortcuts.addAll(getWidgetProviders(context, refresh));
@@ -88,7 +88,7 @@ public class LauncherProvider extends ContentProvider {
static final Uri CONTENT_APPWIDGET_RESET_URI =
Uri.parse("content://" + AUTHORITY + "/appWidgetReset");
private DatabaseHelper mOpenHelper;
@Thunk DatabaseHelper mOpenHelper;
@Override
public boolean onCreate() {
@@ -665,7 +665,7 @@ public class LauncherProvider extends ContentProvider {
* Replaces all shortcuts of type {@link Favorites#ITEM_TYPE_SHORTCUT} which have a valid
* launcher activity target with {@link Favorites#ITEM_TYPE_APPLICATION}.
*/
private void convertShortcutsToLauncherActivities(SQLiteDatabase db) {
@Thunk void convertShortcutsToLauncherActivities(SQLiteDatabase db) {
db.beginTransaction();
Cursor c = null;
SQLiteStatement updateStmt = null;
+5 -4
View File
@@ -22,11 +22,13 @@ import android.animation.AnimatorSet;
import android.animation.LayoutTransition;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
@@ -45,9 +47,7 @@ import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.Interpolator;
import com.android.launcher3.util.Thunk;
import java.util.ArrayList;
/**
@@ -186,7 +186,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
// We use the min scale to determine how much to expand the actually PagedView measured
// dimensions such that when we are zoomed out, the view is not clipped
private static int REORDERING_DROP_REPOSITION_DURATION = 200;
private static int REORDERING_REORDER_REPOSITION_DURATION = 300;
@Thunk static int REORDERING_REORDER_REPOSITION_DURATION = 300;
private static int REORDERING_SIDE_PAGE_HOVER_TIMEOUT = 80;
private float mMinScale = 1f;
@@ -956,7 +956,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
return 0;
}
private void updateMaxScrollX() {
@Thunk void updateMaxScrollX() {
int childCount = getChildCount();
if (childCount > 0) {
final int index = mIsRtl ? 0 : childCount - 1;
@@ -2322,6 +2322,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
private static final int ANIM_TAG_KEY = 100;
/* Accessibility */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
@@ -56,7 +56,7 @@ public class WidgetPreviewLoader {
* Weak reference objects, do not prevent their referents from being made finalizable,
* finalized, and then reclaimed.
*/
private Set<Bitmap> mUnusedBitmaps =
@Thunk Set<Bitmap> mUnusedBitmaps =
Collections.newSetFromMap(new WeakHashMap<Bitmap, Boolean>());
private final Context mContext;
@@ -67,7 +67,7 @@ public class WidgetPreviewLoader {
private final InvariantDeviceProfile mDeviceProfile;
private final MainThreadExecutor mMainThreadExecutor = new MainThreadExecutor();
private final Handler mWorkerHandler;
@Thunk final Handler mWorkerHandler;
public WidgetPreviewLoader(Context context, InvariantDeviceProfile inv, IconCache iconCache) {
mContext = context;
@@ -290,7 +290,7 @@ public class WidgetPreviewLoader {
/**
* Reads the preview bitmap from the DB or null if the preview is not in the DB.
*/
private Bitmap readFromDb(WidgetCacheKey key, Bitmap recycle, PreviewLoadTask loadTask) {
@Thunk Bitmap readFromDb(WidgetCacheKey key, Bitmap recycle, PreviewLoadTask loadTask) {
Cursor cursor = null;
try {
cursor = mDb.getReadableDatabase().query(
@@ -329,7 +329,7 @@ public class WidgetPreviewLoader {
return null;
}
private Bitmap generatePreview(Launcher launcher, Object info, Bitmap recycle,
@Thunk Bitmap generatePreview(Launcher launcher, Object info, Bitmap recycle,
int previewWidth, int previewHeight) {
if (info instanceof LauncherAppWidgetProviderInfo) {
return generateWidgetPreview(launcher, (LauncherAppWidgetProviderInfo) info,
@@ -512,7 +512,7 @@ public class WidgetPreviewLoader {
/**
* @return an array of containing versionCode and lastUpdatedTime for the package.
*/
private long[] getPackageVersion(String packageName) {
@Thunk long[] getPackageVersion(String packageName) {
synchronized (mPackageVersions) {
long[] versions = mPackageVersions.get(packageName);
if (versions == null) {
@@ -561,14 +561,13 @@ public class WidgetPreviewLoader {
}
public class PreviewLoadTask extends AsyncTask<Void, Void, Bitmap> {
private final WidgetCacheKey mKey;
@Thunk final WidgetCacheKey mKey;
private final Object mInfo;
private final int mPreviewHeight;
private final int mPreviewWidth;
private final WidgetCell mCaller;
private long[] mVersions;
private Bitmap mBitmapToRecycle;
@Thunk long[] mVersions;
@Thunk Bitmap mBitmapToRecycle;
PreviewLoadTask(WidgetCacheKey key, Object info, int previewWidth,
int previewHeight, WidgetCell caller) {
@@ -674,7 +673,7 @@ public class WidgetPreviewLoader {
private static final class WidgetCacheKey extends ComponentKey {
// TODO: remove dependency on size
private final String size;
@Thunk final String size;
public WidgetCacheKey(ComponentName componentName, UserHandleCompat user, String size) {
super(componentName, user);
@@ -251,7 +251,7 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate {
return actions;
}
private void performResizeAction(int action, View host, LauncherAppWidgetInfo info) {
@Thunk void performResizeAction(int action, View host, LauncherAppWidgetInfo info) {
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) host.getLayoutParams();
CellLayout layout = (CellLayout) host.getParent().getParent();
layout.markCellsAsUnoccupiedForView(host);
@@ -191,14 +191,14 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
private RecyclerView.LayoutManager mLayoutManager;
private RecyclerView.ItemDecoration mItemDecoration;
private FrameLayout mContentView;
@Thunk FrameLayout mContentView;
@Thunk AllAppsRecyclerView mAppsRecyclerView;
private ViewGroup mPredictionBarView;
@Thunk ViewGroup mPredictionBarView;
private View mHeaderView;
private View mSearchBarContainerView;
@Thunk View mSearchBarContainerView;
private View mSearchButtonView;
private View mDismissSearchButtonView;
private AllAppsSearchEditView mSearchBarEditView;
@Thunk AllAppsSearchEditView mSearchBarEditView;
private HeaderElevationController mElevationController;
@@ -215,7 +215,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
private int mContainerInset;
private int mPredictionBarHeight;
private int mLastRecyclerViewScrollPos = -1;
private boolean mFocusPredictionBarOnFirstBind;
@Thunk boolean mFocusPredictionBarOnFirstBind;
private CheckLongPressHelper mPredictionIconCheckForLongPress;
private View mPredictionIconUnderTouch;
@@ -936,7 +936,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
/**
* Hides the search field.
*/
private void hideSearchField(boolean animated, final boolean returnFocusToRecyclerView) {
@Thunk void hideSearchField(boolean animated, final boolean returnFocusToRecyclerView) {
mSearchManager.cancel(true);
final boolean resetTextField = mSearchBarEditView.getText().toString().length() > 0;
@@ -1001,7 +1001,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
/**
* Returns an input method manager.
*/
private InputMethodManager getInputMethodManager() {
@Thunk InputMethodManager getInputMethodManager() {
return (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
}
}
@@ -288,7 +288,7 @@ class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.ViewHol
private GridLayoutManager mGridLayoutMgr;
private GridSpanSizer mGridSizer;
private GridItemDecoration mItemDecoration;
private PredictionBarSpacerCallbacks mPredictionBarCb;
@Thunk PredictionBarSpacerCallbacks mPredictionBarCb;
private View.OnTouchListener mTouchListener;
private View.OnClickListener mIconClickListener;
private View.OnLongClickListener mIconLongClickListener;
@@ -27,6 +27,7 @@ import com.android.launcher3.LauncherAppState;
import com.android.launcher3.compat.AlphabeticIndexCompat;
import com.android.launcher3.model.AbstractUserComparator;
import com.android.launcher3.model.AppNameComparator;
import com.android.launcher3.util.Thunk;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.StandardCharsets;
@@ -151,7 +152,7 @@ public class AlphabeticalAppsList {
* The logic we use to merge sections on tablets. Currently, we don't show section names on
* tablet layouts, so just merge all the sections indiscriminately.
*/
private static class TabletMergeAlgorithm implements MergeAlgorithm {
@Thunk static class TabletMergeAlgorithm implements MergeAlgorithm {
@Override
public boolean continueMerging(SectionInfo section, SectionInfo withSection,
@@ -19,6 +19,7 @@ import android.content.Context;
import com.android.launcher3.AppInfo;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.util.Thunk;
import java.text.Collator;
import java.util.Comparator;
@@ -82,7 +83,7 @@ public class AppNameComparator {
/**
* Compares two titles with the same return value semantics as Comparator.
*/
private int compareTitles(String titleA, String titleB) {
@Thunk int compareTitles(String titleA, String titleB) {
// Ensure that we de-prioritize any titles that don't start with a linguistic letter or digit
boolean aStartsWithLetter = Character.isLetterOrDigit(titleA.codePointAt(0));
boolean bStartsWithLetter = Character.isLetterOrDigit(titleB.codePointAt(0));
@@ -43,7 +43,7 @@ public class LongArrayMap<E> extends LongSparseArray<E> implements Iterable<E> {
return new ValueIterator();
}
private class ValueIterator implements Iterator<E> {
@Thunk class ValueIterator implements Iterator<E> {
private int mNextIndex = 0;
@@ -15,6 +15,7 @@ import com.android.launcher3.DragLayer;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppWidgetProviderInfo;
import com.android.launcher3.compat.AppWidgetManagerCompat;
import com.android.launcher3.util.Thunk;
public class WidgetHostViewLoader {
@@ -38,7 +39,7 @@ public class WidgetHostViewLoader {
PendingAddWidgetInfo mCreateWidgetInfo = null;
// TODO: technically, this class should not have to know the existence of the launcher.
private Launcher mLauncher;
@Thunk Launcher mLauncher;
private Handler mHandler;
public WidgetHostViewLoader(Launcher launcher) {
@@ -188,7 +189,7 @@ public class WidgetHostViewLoader {
return options;
}
private void setState(int state) {
@Thunk void setState(int state) {
if (DEBUG) {
Log.d(TAG, String.format(" state [%d -> %d]", mState, state));
}
@@ -46,6 +46,7 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.WidgetPreviewLoader;
import com.android.launcher3.Workspace;
import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.util.Thunk;
/**
* The widgets list view container.
@@ -60,7 +61,7 @@ public class WidgetsContainerView extends BaseContainerView
private static final int PRELOAD_SCREEN_HEIGHT_MULTIPLE = 1;
/* Global instances that are used inside this container. */
private Launcher mLauncher;
@Thunk Launcher mLauncher;
private DragController mDragController;
private IconCache mIconCache;