github 地址 学习地址
https://github.com/badoo/android-weak-handler
注:如何对内存要求优化非常高的app 可以干掉系统的handler 用Weak Handler 处理
dependencies {
compile 'com.badoo.mobile:android-weak-handler:1.1'
}
import com.badoo.mobile.util.WeakHandler; public class ExampleActivity extends Activity { private WeakHandler mHandler; // We still need at least one hard reference to WeakHandler protected void onCreate(Bundle savedInstanceState) { mHandler = new WeakHandler(); ... } private void onClick(View view) { mHandler.postDelayed(new Runnable() { view.setVisibility(View.INVISIBLE); }, 5000); } }
原理看下