Add JSR305 annotation to LeakGuardHandlerWrapper
Change-Id: I7456200af739db4510c5549b7bc894fb48749455
This commit is contained in:
parent
95f100ba40
commit
c4ffa235e5
6 changed files with 20 additions and 11 deletions
|
@ -303,7 +303,7 @@ public class TextDecorator {
|
|||
*/
|
||||
private static final class LayoutInvalidator {
|
||||
private final HandlerImpl mHandler;
|
||||
public LayoutInvalidator(final TextDecorator ownerInstance) {
|
||||
public LayoutInvalidator(@Nonnull final TextDecorator ownerInstance) {
|
||||
mHandler = new HandlerImpl(ownerInstance);
|
||||
}
|
||||
|
||||
|
@ -311,7 +311,7 @@ public class TextDecorator {
|
|||
|
||||
private static final class HandlerImpl
|
||||
extends LeakGuardHandlerWrapper<TextDecorator> {
|
||||
public HandlerImpl(final TextDecorator ownerInstance) {
|
||||
public HandlerImpl(@Nonnull final TextDecorator ownerInstance) {
|
||||
super(ownerInstance);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@ import com.android.inputmethod.keyboard.internal.DrawingHandler.Callbacks;
|
|||
import com.android.inputmethod.latin.SuggestedWords;
|
||||
import com.android.inputmethod.latin.utils.LeakGuardHandlerWrapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
// TODO: Separate this class into KeyPreviewHandler and BatchInputPreviewHandler or so.
|
||||
public class DrawingHandler extends LeakGuardHandlerWrapper<Callbacks> {
|
||||
public interface Callbacks {
|
||||
|
@ -34,7 +36,7 @@ public class DrawingHandler extends LeakGuardHandlerWrapper<Callbacks> {
|
|||
private static final int MSG_DISMISS_KEY_PREVIEW = 0;
|
||||
private static final int MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT = 1;
|
||||
|
||||
public DrawingHandler(final Callbacks ownerInstance) {
|
||||
public DrawingHandler(@Nonnull final Callbacks ownerInstance) {
|
||||
super(ownerInstance);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ import com.android.inputmethod.keyboard.internal.TimerHandler.Callbacks;
|
|||
import com.android.inputmethod.latin.Constants;
|
||||
import com.android.inputmethod.latin.utils.LeakGuardHandlerWrapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
// TODO: Separate this class into KeyTimerHandler and BatchInputTimerHandler or so.
|
||||
public final class TimerHandler extends LeakGuardHandlerWrapper<Callbacks> implements TimerProxy {
|
||||
public interface Callbacks {
|
||||
|
@ -45,7 +47,7 @@ public final class TimerHandler extends LeakGuardHandlerWrapper<Callbacks> imple
|
|||
private final int mIgnoreAltCodeKeyTimeout;
|
||||
private final int mGestureRecognitionUpdateTime;
|
||||
|
||||
public TimerHandler(final Callbacks ownerInstance, final int ignoreAltCodeKeyTimeout,
|
||||
public TimerHandler(@Nonnull final Callbacks ownerInstance, final int ignoreAltCodeKeyTimeout,
|
||||
final int gestureRecognitionUpdateTime) {
|
||||
super(ownerInstance);
|
||||
mIgnoreAltCodeKeyTimeout = ignoreAltCodeKeyTimeout;
|
||||
|
|
|
@ -110,6 +110,8 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Input method implementation for Qwerty'ish keyboard.
|
||||
*/
|
||||
|
@ -208,7 +210,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
private int mDelayInMillisecondsToUpdateSuggestions;
|
||||
private int mDelayInMillisecondsToUpdateShiftState;
|
||||
|
||||
public UIHandler(final LatinIME ownerInstance) {
|
||||
public UIHandler(@Nonnull final LatinIME ownerInstance) {
|
||||
super(ownerInstance);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,8 @@ import com.android.inputmethod.latin.utils.UncachedInputMethodManagerUtils;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
// TODO: Use Fragment to implement welcome screen and setup steps.
|
||||
public final class SetupWizardActivity extends Activity implements View.OnClickListener {
|
||||
static final String TAG = SetupWizardActivity.class.getSimpleName();
|
||||
|
@ -82,7 +84,7 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL
|
|||
|
||||
private final InputMethodManager mImmInHandler;
|
||||
|
||||
public SettingsPoolingHandler(final SetupWizardActivity ownerInstance,
|
||||
public SettingsPoolingHandler(@Nonnull final SetupWizardActivity ownerInstance,
|
||||
final InputMethodManager imm) {
|
||||
super(ownerInstance);
|
||||
mImmInHandler = imm;
|
||||
|
|
|
@ -21,21 +21,22 @@ import android.os.Looper;
|
|||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class LeakGuardHandlerWrapper<T> extends Handler {
|
||||
private final WeakReference<T> mOwnerInstanceRef;
|
||||
|
||||
public LeakGuardHandlerWrapper(final T ownerInstance) {
|
||||
public LeakGuardHandlerWrapper(@Nonnull final T ownerInstance) {
|
||||
this(ownerInstance, Looper.myLooper());
|
||||
}
|
||||
|
||||
public LeakGuardHandlerWrapper(final T ownerInstance, final Looper looper) {
|
||||
public LeakGuardHandlerWrapper(@Nonnull final T ownerInstance, final Looper looper) {
|
||||
super(looper);
|
||||
if (ownerInstance == null) {
|
||||
throw new NullPointerException("ownerInstance is null");
|
||||
}
|
||||
mOwnerInstanceRef = new WeakReference<>(ownerInstance);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public T getOwnerInstance() {
|
||||
return mOwnerInstanceRef.get();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue