當前位置: 首頁>>代碼示例>>Java>>正文


Java RefWatcher類代碼示例

本文整理匯總了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();
    }

}
 
開發者ID:hushengjun,項目名稱:FastAndroid,代碼行數:19,代碼來源:BaseApp.java

示例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();
}
 
開發者ID:uber,項目名稱:RIBs,代碼行數:23,代碼來源:SampleApplication.java

示例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);
}
 
開發者ID:eduardb,項目名稱:ClujBike,代碼行數:17,代碼來源:ClujBikeApp.java

示例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);
}
 
開發者ID:AndroidKnife,項目名稱:Tiger-Pro,代碼行數:18,代碼來源:BaseFragment.java

示例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();
}
 
開發者ID:Art2Cat,項目名稱:MoonlightNote,代碼行數:21,代碼來源:MoonlightDetailFragment.java

示例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);
}
 
開發者ID:QuickLyric,項目名稱:QuickLyric,代碼行數:19,代碼來源:LyricsViewFragment.java

示例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;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:WEFragment.java

示例8: onDestroy

import com.squareup.leakcanary.RefWatcher; //導入依賴的package包/類
@Override
protected void onDestroy() {
    isDestroyed = true;
    super.onDestroy();

    RefWatcher refWatcher = CCApplication.refWatcher;
    refWatcher.watch(this);
}
 
開發者ID:CodingCodersCode,項目名稱:EvolvingNetLib,代碼行數:9,代碼來源:MainActivity.java

示例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);
        }
    });
}
 
開發者ID:RockyQu,項目名稱:MVVMFrames,代碼行數:10,代碼來源:AppConfiguration.java

示例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);
}
 
開發者ID:VK2012,項目名稱:AppCommonFrame,代碼行數:8,代碼來源:EventBusActivity.java

示例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);
}
 
開發者ID:VK2012,項目名稱:AppCommonFrame,代碼行數:8,代碼來源:EventBusFragment.java

示例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);
}
 
開發者ID:VK2012,項目名稱:AppCommonFrame,代碼行數:9,代碼來源:BaseFragment.java

示例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
    }
 
開發者ID:Superingxz,項目名稱:MoligyMvpArms,代碼行數:33,代碼來源:AppLifecyclesImpl.java

示例14: onDestroy

import com.squareup.leakcanary.RefWatcher; //導入依賴的package包/類
@Override
public void onDestroy() {
    super.onDestroy();

    RefWatcher refWatcher = MAVApplication.getRefWatcher(getActivity());
    refWatcher.watch(this);
}
 
開發者ID:SalmanTKhan,項目名稱:MyAnimeViewer,代碼行數:8,代碼來源:BaseFragment.java

示例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();
    }
}
 
開發者ID:miguoer,項目名稱:ApplicationCollention,代碼行數:11,代碼來源:BaseActivity.java


注:本文中的com.squareup.leakcanary.RefWatcher類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。