Created
August 9, 2012 23:36
-
-
Save gabu/3309048 to your computer and use it in GitHub Desktop.
最近出るようになったLintの警告「This Handler classes should be static or leaks might occur.」を修正したHandlerがこちらになります。 元ネタ: http://stackoverflow.com/a/11408340
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Recipe114Handler mHander; | |
private static class Recipe114Handler extends Handler { | |
private final WeakReference<Recipe114Activity> mActivity; | |
public Recipe114Handler(Recipe114Activity activity) { | |
mActivity = new WeakReference<Recipe114Activity>(activity); | |
} | |
@Override | |
public void handleMessage(Message msg) { | |
Recipe114Activity activity = mActivity.get(); | |
if (activity == null) | |
return; | |
switch (msg.what) { | |
case MSG_UPDATED_STATUS: | |
activity.showToast("つぶやき完了!"); | |
activity.mEditText.setText(""); | |
break; | |
case MSG_ON_EXCEPTION: | |
activity.showToast("失敗しました。。。"); | |
break; | |
} | |
// 共通でプログレスダイアログは閉じる。 | |
activity.dismissProgressDialog(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
コンパイルもできない超断片だけどAndroiderなら何となく読めるよね!