本文整理匯總了Java中com.squareup.leakcanary.RefWatcher類的典型用法代碼示例。如果您正苦於以下問題:Java RefWatcher類的具體用法?Java RefWatcher怎麽用?Java RefWatcher使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RefWatcher類屬於com.squareup.leakcanary包,在下文中一共展示了RefWatcher類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import com.squareup.leakcanary.RefWatcher; //導入依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
if (LeakCanary.isInAnalyzerProcess(this)) {
mRefWatcher = RefWatcher.DISABLED;
} else {
mRefWatcher = LeakCanary.install(this);
}
if (isInMainProcess()) {
instance = this;
Thread.setDefaultUncaughtExceptionHandler(new AppCrashHandler(this));
initModule();
}
}
示例2: installLeakCanary
import com.squareup.leakcanary.RefWatcher; //導入依賴的package包/類
/**
* Install leak canary for both activities and RIBs.
*/
private void installLeakCanary() {
final RefWatcher refWatcher = LeakCanary
.refWatcher(this)
.watchDelay(2, TimeUnit.SECONDS)
.buildAndInstall();
LeakCanary.install(this);
RibRefWatcher.getInstance().setReferenceWatcher(new RibRefWatcher.ReferenceWatcher() {
@Override
public void watch(Object object) {
refWatcher.watch(object);
}
@Override
public void logBreadcrumb(String eventType, String data, String parent) {
// Ignore for now. Useful for collecting production analytics.
}
});
RibRefWatcher.getInstance().enableLeakCanary();
}
示例3: onCreate
import com.squareup.leakcanary.RefWatcher; //導入依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
mRefWatcher = LeakCanary.install(this);
if (mRefWatcher == RefWatcher.DISABLED && "leak".equals(BuildConfig.BUILD_TYPE)) {
return;
}
// build the dependency graph
mAppComponent = getAppComponentBuilder().build();
mAppComponent.inject(this);
Timber.plant(mTimberTree);
}
示例4: onDestroy
import com.squareup.leakcanary.RefWatcher; //導入依賴的package包/類
@Override
public void onDestroy() {
if (unbinder != null) {
unbinder.unbind();
}
Fragment fragment = getTargetFragment();
if (fragment != null && fragment instanceof BaseFragment) {
BaseFragment targetFragment = (BaseFragment) fragment;
targetFragment.onFragmentResult(getTargetRequestCode());
}
if (mainView != null && mainView.getParent() != null) {
((ViewGroup) mainView.getParent()).removeView(mainView);
}
super.onDestroy();
RefWatcher refWatcher = MVPApplication.getRefWatcher(getActivity());
refWatcher.watch(this);
}
示例5: onDestroy
import com.squareup.leakcanary.RefWatcher; //導入依賴的package包/類
@Override
public void onDestroy() {
if (mInputMethodManager != null) {
mInputMethodManager.hideSoftInputFromWindow(mActivity.getWindow().getDecorView().getWindowToken(), 0);
}
revertUI();
mAudioPlayer.releasePlayer();
// remove FragmentOnTouchListener
if (mFragmentOnTouchListener != null) {
((MoonlightActivity) mActivity).unregisterFragmentOnTouchListener(mFragmentOnTouchListener);
}
RefWatcher refWatcher = MoonlightApplication.getRefWatcher(mActivity);
refWatcher.watch(this);
release();
super.onDestroy();
}
示例6: onDestroy
import com.squareup.leakcanary.RefWatcher; //導入依賴的package包/類
@Override
public void onDestroy() {
unregisterUpdateBroadcastReceiver();
threadCancelled = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && networkCallback != null)
try {
((ConnectivityManager) getActivity().getApplicationContext()
.getSystemService(Context.CONNECTIVITY_SERVICE)).unregisterNetworkCallback(networkCallback);
} catch (IllegalArgumentException ignored) {
}
if (Build.VERSION.SDK_INT >= 21 && sessionListener != null) {
((MediaSessionManager) getActivity().getSystemService(Context.MEDIA_SESSION_SERVICE))
.removeOnActiveSessionsChangedListener((OnActiveSessionsChangedListener) sessionListener);
}
super.onDestroy();
RefWatcher refWatcher = App.getRefWatcher(getActivity());
refWatcher.watch(this);
}
示例7: onDestroy
import com.squareup.leakcanary.RefWatcher; //導入依賴的package包/類
@Override
public void onDestroy() {
super.onDestroy();
RefWatcher watcher = WEApplication.getRefWatcher(getActivity());//使用leakCanary檢測fragment的內存泄漏
if (watcher != null) {
watcher.watch(this);
}
this.mWeApplication =null;
}
示例8: onDestroy
import com.squareup.leakcanary.RefWatcher; //導入依賴的package包/類
@Override
protected void onDestroy() {
isDestroyed = true;
super.onDestroy();
RefWatcher refWatcher = CCApplication.refWatcher;
refWatcher.watch(this);
}
示例9: injectFragmentLifecycle
import com.squareup.leakcanary.RefWatcher; //導入依賴的package包/類
@Override
public void injectFragmentLifecycle(Context context, List<FragmentManager.FragmentLifecycleCallbacks> lifecycles) {
lifecycles.add(new FragmentManager.FragmentLifecycleCallbacks() {
@Override
public void onFragmentDestroyed(FragmentManager fm, Fragment f) {
((RefWatcher) ((App) f.getActivity().getApplication()).getAppComponent().extras().get(RefWatcher.class.getName())).watch(this);
}
});
}
示例10: onDestroy
import com.squareup.leakcanary.RefWatcher; //導入依賴的package包/類
@Override
protected void onDestroy() {
EventBus.getDefault().unregister(this);
super.onDestroy();
RefWatcher refWatcher = BaseApp.getRefWatcher(this);
refWatcher.watch(this);
}
示例11: onDestroy
import com.squareup.leakcanary.RefWatcher; //導入依賴的package包/類
@Override
public void onDestroy() {
EventBus.getDefault().unregister(this);
super.onDestroy();
RefWatcher refWatcher = BaseApp.getRefWatcher(getActivity());
refWatcher.watch(this);
}
示例12: onDestroy
import com.squareup.leakcanary.RefWatcher; //導入依賴的package包/類
@Override
public void onDestroy() {
super.onDestroy();
if(mToast != null)
mToast.cancel();
RefWatcher refWatcher = BaseApp.getRefWatcher(getActivity());
refWatcher.watch(this);
}
示例13: onCreate
import com.squareup.leakcanary.RefWatcher; //導入依賴的package包/類
@Override
public void onCreate(Application application) {
if (BuildConfig.LOG_DEBUG) {//Timber初始化
//Timber 是一個日誌框架容器,外部使用統一的Api,內部可以動態的切換成任何日誌框架(打印策略)進行日誌打印
//並且支持添加多個日誌框架(打印策略),做到外部調用一次 Api,內部卻可以做到同時使用多個策略
//比如添加三個策略,一個打印日誌,一個將日誌保存本地,一個將日誌上傳服務器
Timber.plant(new Timber.DebugTree());
// 如果你想將框架切換為 Logger 來打印日誌,請使用下麵的代碼,如想切換為其他日誌框架請根據下麵的方式擴展
// Logger.addLogAdapter(new AndroidLogAdapter());
// Timber.plant(new Timber.DebugTree() {
// @Override
// protected void log(int priority, String tag, String message, Throwable t) {
// Logger.log(priority, tag, message, t);
// }
// });
ButterKnife.setDebug(true);
}
//leakCanary內存泄露檢查
ArmsUtils.obtainAppComponentFromContext(application).extras().put(RefWatcher.class.getName(), BuildConfig.USE_CANARY ? LeakCanary.install(application) : RefWatcher.DISABLED);
//擴展 AppManager 的遠程遙控功能
ArmsUtils.obtainAppComponentFromContext(application).appManager().setHandleListener((appManager, message) -> {
switch (message.what) {
//case 0:
//do something ...
// break;
}
});
//Usage:
//Message msg = new Message();
//msg.what = 0;
//AppManager.post(msg); like EventBus
}
示例14: onDestroy
import com.squareup.leakcanary.RefWatcher; //導入依賴的package包/類
@Override
public void onDestroy() {
super.onDestroy();
RefWatcher refWatcher = MAVApplication.getRefWatcher(getActivity());
refWatcher.watch(this);
}
示例15: onDestroy
import com.squareup.leakcanary.RefWatcher; //導入依賴的package包/類
@Override
protected void onDestroy() {
super.onDestroy();
//銷毀Activity時,檢測內存泄露
RefWatcher refWatcher = MyApplication.getRefWatcher(this);
refWatcher.watch(this);
if (presenter != null) {
presenter.detachView();
}
}