Bug 1382049 - Make inner classes static when possible. r=nalexander, r=sebastian

This avoids an implicit this field and can help GC. Found via error-prone.

--HG--
extra : rebase_source : 6d91bfcb98a05c94c13fc41fd0b5b14f1404ddcf
This commit is contained in:
Andrew Gaul 2017-07-18 16:51:30 -07:00
parent dfaf24241e
commit 7ee6e2a506
24 changed files with 30 additions and 30 deletions

View File

@ -85,7 +85,7 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback {
@WebRTCJNITarget
private static native Context GetContext();
private class CameraThread extends Thread {
private static final class CameraThread extends Thread {
private Exchanger<Handler> handlerExchanger;
public CameraThread(Exchanger<Handler> handlerExchanger) {
this.handlerExchanger = handlerExchanger;

View File

@ -3165,7 +3165,7 @@ public class BrowserApp extends GeckoApp
/**
* Hides certain UI elements (e.g. button toast) when the user touches the main layout.
*/
private class HideOnTouchListener implements TouchEventInterceptor {
private static final class HideOnTouchListener implements TouchEventInterceptor {
@Override
public boolean onInterceptTouchEvent(View view, MotionEvent event) {
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {

View File

@ -39,7 +39,7 @@ public class EditBookmarkDialog {
/**
* A private struct to make it easier to pass bookmark data across threads
*/
private class Bookmark {
private static final class Bookmark {
final int id;
final String title;
final String url;
@ -61,7 +61,7 @@ public class EditBookmarkDialog {
* Callers can also assign a paired partner to the TextWatcher, and callers will check
* that both are enabled before enabling the ok button.
*/
private class EditBookmarkTextWatcher implements TextWatcher {
private static class EditBookmarkTextWatcher implements TextWatcher {
// A stored reference to the dialog containing the text field being watched
protected AlertDialog mDialog;
@ -101,7 +101,7 @@ public class EditBookmarkDialog {
* A version of the EditBookmarkTextWatcher for the url field of the dialog.
* Only checks if the field is empty or not.
*/
private class LocationTextWatcher extends EditBookmarkTextWatcher {
private static final class LocationTextWatcher extends EditBookmarkTextWatcher {
public LocationTextWatcher(AlertDialog aDialog) {
super(aDialog);
}
@ -118,7 +118,7 @@ public class EditBookmarkDialog {
* A version of the EditBookmarkTextWatcher for the keyword field of the dialog.
* Checks if the field has any (non leading or trailing) spaces.
*/
private class KeywordTextWatcher extends EditBookmarkTextWatcher {
private static final class KeywordTextWatcher extends EditBookmarkTextWatcher {
public KeywordTextWatcher(AlertDialog aDialog) {
super(aDialog);
}

View File

@ -398,7 +398,7 @@ public class FormAssistPopup extends RelativeLayout implements BundleEventListen
});
}
private class AutoCompleteListAdapter extends ArrayAdapter<Pair<String, String>> {
private static final class AutoCompleteListAdapter extends ArrayAdapter<Pair<String, String>> {
private final LayoutInflater mInflater;
private final int mTextViewResourceId;

View File

@ -347,7 +347,7 @@ public abstract class GeckoApp extends GeckoActivity
protected void openQueuedTabs() {};
@SuppressWarnings("serial")
class SessionRestoreException extends Exception {
static final class SessionRestoreException extends Exception {
public SessionRestoreException(Exception e) {
super(e);
}

View File

@ -20,7 +20,7 @@ import android.util.Log;
public abstract class SessionParser {
private static final String LOGTAG = "GeckoSessionParser";
public class SessionTab {
public static final class SessionTab {
final private String mTitle;
final private String mUrl;
final private JSONObject mTabObject;

View File

@ -33,7 +33,7 @@ public class PropertyAnimator implements Runnable {
HEIGHT
}
private class ElementHolder {
private static final class ElementHolder {
View view;
Property property;
float from;

View File

@ -496,7 +496,7 @@ public class BookmarkEditFragment extends DialogFragment implements SelectFolder
/**
* This text watcher enables the menu item if the dialog contains valid information, or disables otherwise.
*/
private class BookmarkTextWatcher implements TextWatcher {
private static final class BookmarkTextWatcher implements TextWatcher {
// A stored reference to the dialog containing the text field being watched.
private final WeakReference<MenuItem> doneItemWeakReference;

View File

@ -2496,7 +2496,7 @@ public class BrowserDatabaseHelper extends SQLiteOpenHelper {
public void updateForNewTable(ContentValues bookmark);
}
private class BookmarkMigrator3to4 implements BookmarkMigrator {
private static final class BookmarkMigrator3to4 implements BookmarkMigrator {
@Override
public void updateForNewTable(ContentValues bookmark) {
Integer isFolder = bookmark.getAsInteger("folder");

View File

@ -25,7 +25,7 @@ import android.util.SparseArray;
public class PanelInfoManager implements BundleEventListener {
private static final String LOGTAG = "GeckoPanelInfoManager";
public class PanelInfo {
public static final class PanelInfo {
private final String mId;
private final String mTitle;
private final GeckoBundle mBundleData;

View File

@ -30,7 +30,7 @@ public class GeckoMenuInflater extends MenuInflater {
private final Context mContext;
// Private class to hold the parsed menu item.
private class ParsedItem {
private static final class ParsedItem {
public int id;
public int order;
public CharSequence title;

View File

@ -1184,7 +1184,7 @@ public class GeckoPreferences
return layout;
}
private class PasswordTextWatcher implements TextWatcher {
private static final class PasswordTextWatcher implements TextWatcher {
EditText input1;
EditText input2;
AlertDialog dialog;
@ -1212,7 +1212,7 @@ public class GeckoPreferences
public void onTextChanged(CharSequence s, int start, int before, int count) { }
}
private class EmptyTextWatcher implements TextWatcher {
private static final class EmptyTextWatcher implements TextWatcher {
EditText input;
AlertDialog dialog;

View File

@ -110,7 +110,7 @@ public class IconGridInput extends PromptInput implements OnItemClickListener {
return true;
}
private class IconGridAdapter extends ArrayAdapter<IconGridItem> {
private static final class IconGridAdapter extends ArrayAdapter<IconGridItem> {
public IconGridAdapter(Context context, int resource, List<IconGridItem> items) {
super(context, resource, items);
}

View File

@ -783,7 +783,7 @@ public class UpdateService extends IntentService {
editor.commit();
}
private class UpdateInfo {
private static final class UpdateInfo {
public URI uri;
public String buildID;
public String hashFunction;

View File

@ -976,7 +976,7 @@ public class ActivityChooserModel extends DataSetObservable {
/**
* Represents an activity.
*/
public final class ActivityResolveInfo implements Comparable<ActivityResolveInfo> {
public static final class ActivityResolveInfo implements Comparable<ActivityResolveInfo> {
/**
* The {@link ResolveInfo} of the activity.
@ -1039,7 +1039,7 @@ public class ActivityChooserModel extends DataSetObservable {
/**
* Default activity sorter implementation.
*/
private final class DefaultSorter implements ActivitySorter {
private static final class DefaultSorter implements ActivitySorter {
private static final float WEIGHT_DECAY_COEFFICIENT = 0.95f;
private final Map<String, ActivityResolveInfo> mPackageNameToActivityMap =

View File

@ -152,7 +152,7 @@ public class FadedHorizontalScrollView extends HorizontalScrollView {
mVerticalFadeBordersDirty = false;
}
private class FadePaint extends Paint {
private static final class FadePaint extends Paint {
public final Matrix matrix;
public final Shader fade;

View File

@ -11,7 +11,7 @@ import org.mozilla.gecko.sync.Utils;
public abstract class State {
public static final long CURRENT_VERSION = 3L;
public class NotASessionTokenState extends Exception {
public static final class NotASessionTokenState extends Exception {
private static final long serialVersionUID = 8628129091996684799L;

View File

@ -86,7 +86,7 @@ public class JSONRecordFetcher {
}
}
private class LatchedJSONRecordFetchDelegate implements JSONRecordFetchDelegate {
private static final class LatchedJSONRecordFetchDelegate implements JSONRecordFetchDelegate {
public ExtendedJSONObject body = null;
public Exception exception = null;
private final CountDownLatch latch;
@ -142,4 +142,4 @@ public class JSONRecordFetcher {
throw new Exception("Unknown error.");
}
}
}

View File

@ -9,7 +9,7 @@ import org.mozilla.gecko.sync.repositories.delegates.RepositorySessionCreationDe
public abstract class MiddlewareRepository extends Repository {
public abstract class SessionCreationDelegate implements
public static abstract class SessionCreationDelegate implements
RepositorySessionCreationDelegate {
// We call through to our inner repository, so we don't need our own

View File

@ -79,7 +79,7 @@ public abstract class MiddlewareRepositorySession extends RepositorySession {
inner.begin(new MiddlewareRepositorySessionBeginDelegate(this, delegate));
}
public class MiddlewareRepositorySessionFinishDelegate implements RepositorySessionFinishDelegate {
public static final class MiddlewareRepositorySessionFinishDelegate implements RepositorySessionFinishDelegate {
private final MiddlewareRepositorySession outerSession;
private final RepositorySessionFinishDelegate next;

View File

@ -35,7 +35,7 @@ import java.net.URISyntaxException;
*/
public class SyncStorageRecordRequest extends SyncStorageRequest {
public class SyncStorageRecordResourceDelegate extends SyncStorageResourceDelegate {
public static final class SyncStorageRecordResourceDelegate extends SyncStorageResourceDelegate {
SyncStorageRecordResourceDelegate(SyncStorageRequest request) {
super(request);
}

View File

@ -95,7 +95,7 @@ public class SyncStorageRequest implements Resource {
/**
* A ResourceDelegate that mediates between Resource-level notifications and the SyncStorageRequest.
*/
public class SyncStorageResourceDelegate extends BaseResourceDelegate {
public static class SyncStorageResourceDelegate extends BaseResourceDelegate {
private static final String LOG_TAG = "SSResourceDelegate";
protected SyncStorageRequest request;

View File

@ -90,7 +90,7 @@ public class FormHistoryServerSyncStage extends ServerSyncStage {
);
}
public class FormHistoryRecordFactory extends RecordFactory {
public static final class FormHistoryRecordFactory extends RecordFactory {
@Override
public Record createRecord(Record record) {

View File

@ -282,7 +282,7 @@ public abstract class ServerSyncStage extends AbstractSessionManagingSyncStage i
}
// Not thread-safe. Use with caution.
private class WipeWaiter {
private static final class WipeWaiter {
public boolean sessionSucceeded = true;
public boolean wipeSucceeded = true;
public Exception error;