类com.squareup.leakcanary.RefWatcher源码实例Demo

下面列出了怎么用com.squareup.leakcanary.RefWatcher的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Hands-Chopping   文件: GlobalConfiguration.java
@Override
public void injectFragmentLifecycle(Context context, List<FragmentManager.FragmentLifecycleCallbacks> lifecycles) {
    //当所有模块集成到宿主 App 时, 在 App 中已经执行了以下代码, 所以不需要再执行
    if (BuildConfig.IS_BUILD_MODULE) {
        lifecycles.add(new FragmentManager.FragmentLifecycleCallbacks() {
            @Override
            public void onFragmentDestroyed(FragmentManager fm, android.support.v4.app.Fragment f) {
                ((RefWatcher) ArmsUtils
                        .obtainAppComponentFromContext(f.getActivity())
                        .extras()
                        .get(RefWatcher.class.getName()))
                        .watch(f);
            }
        });
    }
}
 
源代码2 项目: QuickLyric   文件: LyricsViewFragment.java
@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);
}
 
源代码3 项目: RIBs   文件: SampleApplication.java
/**
 * 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();
}
 
源代码4 项目: lifecycle-component   文件: GlobalConfiguration.java
@Override
public void injectFragmentLifecycle(Context context, List<FragmentManager.FragmentLifecycleCallbacks> lifecycles) {
    lifecycles.add(new FragmentManager.FragmentLifecycleCallbacks() {
        @Override
        public void onFragmentDestroyed(FragmentManager fm, Fragment f) {
            ((RefWatcher) ArmsUtils
                    .obtainAppComponentFromContext(f.getActivity())
                    .extras()
                    .get(RefWatcher.class.getName()))
                    .watch(f);
        }
    });
}
 
源代码5 项目: QuickLyric   文件: RecentTracksFragment.java
@Override
public void onDestroy() {
    RefWatcher refWatcher = App.getRefWatcher(getActivity());
    refWatcher.watch(this);
    EventBus.getDefault().unregister(this);
    super.onDestroy();

}
 
源代码6 项目: Hands-Chopping   文件: GlobalConfiguration.java
@Override
public void injectFragmentLifecycle(Context context, List<FragmentManager.FragmentLifecycleCallbacks> lifecycles) {
    lifecycles.add(new FragmentManager.FragmentLifecycleCallbacks() {
        @Override
        public void onFragmentDestroyed(FragmentManager fm, Fragment f) {
            ((RefWatcher) ArmsUtils
                    .obtainAppComponentFromContext(f.getActivity())
                    .extras()
                    .get(RefWatcher.class.getName()))
                    .watch(f);
        }
    });
}
 
源代码7 项目: AndroidViewModel   文件: PagerFragment.java
@Override
public void onDestroy() {
    super.onDestroy();

    // watch for memory leaks
    RefWatcher refWatcher = SampleApplication.getRefWatcher(requireActivity());
    refWatcher.watch(this);
}
 
源代码8 项目: QuickLyric   文件: SearchFragment.java
@Override
public void onDestroy() {
    ((SearchPagerAdapter) ((SearchActivity) getActivity()).getViewPager().getAdapter()).removeFragment(this);
    super.onDestroy();
    RefWatcher refWatcher = App.getRefWatcher(getActivity());
    refWatcher.watch(this);
}
 
源代码9 项目: AcDisplay   文件: ActivityBaseInternal.java
void onDestroy() {
    mCheckout = null;
    if (mInputMethodResetRequest) performInputMethodServiceReset();
    // Watch for the activity to detect possible leaks.
    RefWatcher refWatcher = AppHeap.getRefWatcher();
    refWatcher.watch(this);
}
 
源代码10 项目: MarkdownEditors   文件: BaseApplication.java
public static RefWatcher getRefWatcher(Context context) {
    if (context == null) {
        return null;
    }
    BaseApplication application = (BaseApplication) context.getApplicationContext();
    if (application.hasMemoryLeak()) {
        return application.refWatcher;
    }
    return null;
}
 
源代码11 项目: MarkdownEditors   文件: BaseFragment.java
@Override
public void onDestroy() {
    super.onDestroy();
    if (BuildConfig.DEBUG) {//Debug的时候检查内存泄露
        RefWatcher refWatcher = BaseApplication.getRefWatcher(mContext);
        if (refWatcher != null) {
            refWatcher.watch(this);
        }
    }
}
 
@Override
public void onDestroy() {
  stopScanning();
  mainMenu = null;
  myDevices.onDestroy();
  myDevices = null;
  super.onDestroy();

  // Make sure we don't leak this fragment.
  RefWatcher watcher = WhistlePunkApplication.getAppServices(getActivity()).getRefWatcher();
  watcher.watch(this);
}
 
源代码13 项目: Loop   文件: BaseFragment.java
@Override
public void onDestroy() {
    super.onDestroy();

    RefWatcher refWatcher = LoopApplication.getRefWatcher(getActivity());
    refWatcher.watch(this);
}
 
源代码14 项目: Upchain-wallet   文件: UpChainWalletApp.java
public static RefWatcher getRefWatcher(Context context) {
    UpChainWalletApp application = (UpChainWalletApp) context.getApplicationContext();
    return application.refWatcher;
}
 
源代码15 项目: scissors   文件: App.java
public static RefWatcher getRefWatcher(Context context) {
    App application = (App) context.getApplicationContext();
    return application.refWatcher;
}
 
源代码16 项目: Yuan-WanAndroid   文件: BaseFragment.java
@Override
public void onDestroy() {
    super.onDestroy();
    RefWatcher refWatcher = App.getRefWatcher(mActivity);
    refWatcher.watch(this);
}
 
源代码17 项目: Yuan-WanAndroid   文件: App.java
public static RefWatcher getRefWatcher(Context context) {
    App application =(App) context.getApplicationContext();
    return application.mRefWatcher;
}
 
源代码18 项目: DoraemonKit   文件: AndroidOFragmentRefWatcher.java
AndroidOFragmentRefWatcher(RefWatcher refWatcher) {
  this.refWatcher = refWatcher;
}
 
源代码19 项目: DoraemonKit   文件: SupportFragmentRefWatcher.java
SupportFragmentRefWatcher(RefWatcher refWatcher) {
  this.refWatcher = refWatcher;
}
 
源代码20 项目: BlueBoard   文件: BaseFragment.java
@Override
public void onDestroyView() {
    super.onDestroyView();
    RefWatcher refWatcher = MyApplication.getRefWatcher(getActivity());
    refWatcher.watch(this);
}
 
源代码21 项目: TikTok   文件: AppLifecyclesImpl.java
@Override
public void onCreate(@NonNull Application application) {
    if (LeakCanary.isInAnalyzerProcess(application)) {
        // This process is dedicated to LeakCanary for heap analysis.
        // You should not init your app in this process.
        return;
    }
    //leakCanary内存泄露检查
    ArmsUtils.obtainAppComponentFromContext(application).extras().put(RefWatcher.class.getName(), BuildConfig.USE_CANARY ? LeakCanary.install(application) : RefWatcher.DISABLED);

    ARouter.openLog();     // 打印日志
    ARouter.openDebug();   // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险)
    ARouter.init(application); // 尽可能早,推荐在Application中初始化
    //bugly
    CrashReport.initCrashReport(application, "c6dc9a5939", true);

    RxToast.init(application)
            .setBackgroundColor("#CC000000")
            .setTextColor("#FFFFFF")
            .setGravity(Gravity.CENTER)
            .setPadding(16, 16, 12, 12)
            .setMaxLines(2)
            .setTextSize(12)
            .setZ(30)
            .setMaxLines(3)
            .apply();

    DoraemonKit.install(application);
    // H5任意门功能需要,非必须
    DoraemonKit.setWebDoorCallback(new WebDoorManager.WebDoorCallback() {
        @Override
        public void overrideUrlLoading(Context context, String s) {
            // 使用自己的H5容器打开这个链接
            // 使用自己的H5容器打开这个链接
            WebView webView = new WebView(context);


            webView.loadUrl(s);

        }
    });


}
 
源代码22 项目: BlueBoard   文件: MyApplication.java
public static RefWatcher getRefWatcher(Context context) {
    MyApplication application = (MyApplication) context.getApplicationContext();
    return application.refWatcher;
}
 
@Override
public void onDestroy() {
    super.onDestroy();
    RefWatcher refWatcher = WanAndroidApp.getRefWatcher(_mActivity);
    refWatcher.watch(this);
}
 
@Override
public void onDestroy() {
    super.onDestroy();
    RefWatcher refWatcher = WanAndroidApp.getRefWatcher(getActivity());
    refWatcher.watch(this);
}
 
源代码25 项目: Awesome-WanAndroid   文件: WanAndroidApp.java
public static RefWatcher getRefWatcher(Context context) {
    WanAndroidApp application = (WanAndroidApp) context.getApplicationContext();
    return application.refWatcher;
}
 
源代码26 项目: AndroidViewModel   文件: SampleApplication.java
public static RefWatcher getRefWatcher(Context context) {
    SampleApplication application = (SampleApplication) context.getApplicationContext();
    return application.refWatcher;
}
 
源代码27 项目: AcDisplay   文件: LeakWatchDialogFragment.java
@Override
public void onDestroy() {
    super.onDestroy();
    RefWatcher refWatcher = AppHeap.getRefWatcher();
    refWatcher.watch(this);
}
 
源代码28 项目: leakcanary-for-eclipse   文件: LeakCanaryWrapper.java
public static RefWatcher install(Application application) {
    return RefWatcher.DISABLED;
}
 
源代码29 项目: Dainty   文件: DaintyApplication.java
public static RefWatcher getRefWatcher(Context context) {
    DaintyApplication application = (DaintyApplication) context.getApplicationContext();
    return application.refWatcher;
}
 
源代码30 项目: Protein   文件: DebugProteinApp.java
@Override
protected RefWatcher installLeakCanary() {
    return LeakCanary.refWatcher(this)
            .watchDelay(10, TimeUnit.SECONDS)
            .buildAndInstall();
}