com.didichuxing.doraemonkit.DoraemonKit Java Examples
The following examples show how to use
com.didichuxing.doraemonkit.DoraemonKit.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainIconDokitView.java From DoraemonKit with Apache License 2.0 | 6 votes |
@Override public void onViewCreated(FrameLayout view) { //设置id便于查找 getRootView().setId(R.id.float_icon_id); //设置icon 点击事件 getRootView().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //统计入口 DataPickManager.getInstance().addData("dokit_sdk_home_ck_entry"); DoraemonKit.showToolPanel(); } }); }
Example #2
Source File: BlockMonitorManager.java From DoraemonKit with Apache License 2.0 | 6 votes |
public void start() { if (mIsRunning) { LogHelper.i(TAG, "start when manager is running"); return; } if (DoraemonKit.APPLICATION == null) { LogHelper.e(TAG, "start fail, context is null"); return; } // 卡顿检测和跳转耗时统计都使用了Printer的方式,无法同时工作 TimeCounterManager.get().stop(); mContext = DoraemonKit.APPLICATION.getApplicationContext(); if (mMonitorCore == null) { mMonitorCore = new MonitorCore(); } mIsRunning = true; Looper.getMainLooper().setMessageLogging(mMonitorCore); }
Example #3
Source File: DbDebugFragment.java From DoraemonKit with Apache License 2.0 | 6 votes |
private void initView() throws Exception { if (!DebugDB.isServerRunning()) { DebugDB.initialize(DoraemonKit.APPLICATION, new DebugDBFactory()); DebugDB.initialize(DoraemonKit.APPLICATION, new DebugDBEncryptFactory()); } HomeTitleBar titleBar = findViewById(R.id.title_bar); titleBar.setListener(new HomeTitleBar.OnTitleBarClickListener() { @Override public void onRightClick() { finish(); } }); TextView tvTip = findViewById(R.id.tv_tip); tvTip.setText(Html.fromHtml(getResources().getString(R.string.dk_kit_db_debug_desc))); tvIp = findViewById(R.id.tv_ip); if (DebugDB.isServerRunning()) { tvIp.setText("" + DebugDB.getAddressLog().replace("Open ", "").replace("in your browser", "")); } else { tvIp.setText("servse is not start"); } }
Example #4
Source File: DokitViewManager.java From DoraemonKit with Apache License 2.0 | 6 votes |
public DokitDatabase getDb() { if (mDB != null) { return mDB; } mDB = Room.databaseBuilder(DoraemonKit.APPLICATION, DokitDatabase.class, "dokit-database") //下面注释表示允许主线程进行数据库操作,但是不推荐这样做。 //他可能造成主线程lock以及anr //所以我们的操作都是在新线程完成的 .allowMainThreadQueries() .build(); return mDB; }
Example #5
Source File: SystemDokitViewManager.java From DoraemonKit with Apache License 2.0 | 6 votes |
@Override public void onActivityCreate(Activity activity) { //判断是否有MainIcon if (DokitConstant.AWAYS_SHOW_MAIN_ICON && !DoraemonKit.isShow()) { DoraemonKit.show(); } //如果倒计时浮标没显示则重新添加 AbsDokitView countDownDokitView = getDokitView(activity, CountDownDokitView.class.getSimpleName()); if (countDownDokitView == null) { if (activity instanceof UniversalActivity) { return; } attachCountDownDokitView(activity); } else { if (activity instanceof UniversalActivity) { DokitViewManager.getInstance().detach(CountDownDokitView.class.getSimpleName()); } else { //重置倒计时 ((CountDownDokitView) countDownDokitView).resetTime(); } } }
Example #6
Source File: UIUtils.java From DoraemonKit with Apache License 2.0 | 6 votes |
public static int getRealHeightPixels() { WindowManager windowManager = (WindowManager) DoraemonKit.APPLICATION.getSystemService(Context.WINDOW_SERVICE); int height = 0; Display display = windowManager.getDefaultDisplay(); DisplayMetrics dm = new DisplayMetrics(); Class c; try { c = Class.forName("android.view.Display"); Method method = c.getMethod("getRealMetrics", DisplayMetrics.class); method.invoke(display, dm); height = dm.heightPixels; } catch (Exception e) { LogHelper.d(TAG, e.toString()); } return height; }
Example #7
Source File: AopApp.java From DoraemonKit with Apache License 2.0 | 6 votes |
@Override public void onCreate() { super.onCreate(); List<AbstractKit> kits = new ArrayList<>(); kits.add(new DemoKit()); //测试环境:a49842eeebeb1989b3f9565eb12c276b //线上环境:749a0600b5e48dd77cf8ee680be7b1b7 //new AopTest().test(); ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this) .setDiskCacheEnabled(false) .build(); Fresco.initialize(this, config); //是否显示入口icon // DoraemonKit.setAwaysShowMainIcon(false); DoraemonKit.disableUpload(); DoraemonKit.install(this, "749a0600b5e48dd77cf8ee680be7b1b7"); //DoraemonKit.install(this, kits, "70e78c27f9174d68668d8a66a2b66483") }
Example #8
Source File: MyApplication.java From AndroidAnimationExercise with Apache License 2.0 | 5 votes |
@Override @DebugLog public void onCreate() { super.onCreate(); Debug.startMethodTracing("sample"); MultiDex.install(this); Stetho.initializeWithDefaults(this); if (BuildConfig.DEBUG) { ARouter.openLog(); ARouter.openDebug(); } ARouter.init(this); Fresco.initialize(this); String dir = MMKV.initialize(this); Log.e("application", "onCreate: mmkv.dir==" + dir); WebView.setWebContentsDebuggingEnabled(true); DoraemonKit.disableUpload(); DoraemonKit.install(this); // DoraemonKit.hide(); logLifeCycleCallBacks(); Debug.stopMethodTracing(); }
Example #9
Source File: NormalDokitViewManager.java From DoraemonKit with Apache License 2.0 | 5 votes |
/** * 新建activity * * @param activity */ @Override public void onActivityCreate(Activity activity) { if (mGlobalSingleDokitViews == null) { LogHelper.e(TAG, "resumeAndAttachDokitViews 方法执行异常"); return; } //将所有的dokitView添加到新建的Activity中去 for (GlobalSingleDokitViewInfo dokitViewInfo : mGlobalSingleDokitViews.values()) { //如果不是性能kitView 则不显示 if (activity instanceof UniversalActivity && dokitViewInfo.getAbsDokitViewClass() != PerformanceDokitView.class) { continue; } //是否过滤掉 入口icon if (!DokitConstant.AWAYS_SHOW_MAIN_ICON && dokitViewInfo.getAbsDokitViewClass() == MainIconDokitView.class) { DokitConstant.MAIN_ICON_HAS_SHOW = false; continue; } if (dokitViewInfo.getAbsDokitViewClass() == MainIconDokitView.class) { DokitConstant.MAIN_ICON_HAS_SHOW = true; } DokitIntent dokitIntent = new DokitIntent(dokitViewInfo.getAbsDokitViewClass()); dokitIntent.mode = DokitIntent.MODE_SINGLE_INSTANCE; dokitIntent.bundle = dokitViewInfo.getBundle(); attach(dokitIntent); } //判断是否有MainIcon if (DokitConstant.AWAYS_SHOW_MAIN_ICON && !DoraemonKit.isShow()) { DoraemonKit.show(); } //倒计时DokitView attachCountDownDokitView(activity); }
Example #10
Source File: ImageCapture.java From DoraemonKit with Apache License 2.0 | 5 votes |
public void init(Context context, Bundle bundle, ColorPickerDokitView colorPickerDokitView) throws Exception { this.mColorPickerDokitView = colorPickerDokitView; PackageManager packageManager = DoraemonKit.APPLICATION.getPackageManager(); ApplicationInfo applicationInfo = packageManager.getApplicationInfo(AppUtils.getAppPackageName(), 0); //适配Android Q if (applicationInfo.targetSdkVersion >= 29) { if (ColorPickManager.getInstance().getMediaProjection() != null) { colorPickerDokitView.onScreenServiceReady(); } else { try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { Intent intent = new Intent(context, ScreenRecorderService.class); intent.putExtra("data", bundle.getParcelable("data")); context.startForegroundService(intent); } } catch (Exception e) { e.printStackTrace(); } } } else { mMediaProjectionManager = (MediaProjectionManager) context.getSystemService(Context.MEDIA_PROJECTION_SERVICE); if (mMediaProjectionManager != null) { mMediaProjection = mMediaProjectionManager.getMediaProjection(Activity.RESULT_OK, (Intent) bundle.getParcelable("data")); initImageRead(mMediaProjection); } } }
Example #11
Source File: TestApp.java From TikTok with Apache License 2.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); ARouter.openLog(); // 打印日志 ARouter.openDebug(); // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险) ARouter.init(this); // 尽可能早,推荐在Application中初始化 RxToast.init(this) .setBackgroundColor("#CC000000") .setTextColor("#FFFFFF") .setGravity(Gravity.CENTER) .setPadding(16, 16, 12, 12) .setMaxLines(2) .setTextSize(12) .setZ(30) .setMaxLines(3) .apply(); Utils.init(this); DoraemonKit.install(this); // H5任意门功能需要,非必须 DoraemonKit.setWebDoorCallback(new WebDoorManager.WebDoorCallback() { @Override public void overrideUrlLoading(Context context, String s) { // 使用自己的H5容器打开这个链接 WebView webView = new WebView(context); webView.loadUrl(s); } }); }
Example #12
Source File: DokitUtil.java From DoraemonKit with Apache License 2.0 | 5 votes |
@StringRes public static int getStringId(String str) { try { Resources r = DoraemonKit.APPLICATION.getResources(); return r.getIdentifier(str, "string", DoraemonKit.APPLICATION.getPackageName()); } catch (Exception e) { LogHelper.e("getStringId", "getStringId===>" + str); } return -1; }
Example #13
Source File: UIUtils.java From DoraemonKit with Apache License 2.0 | 5 votes |
public static int getWidthPixels() { DisplayMetrics metrics = new DisplayMetrics(); WindowManager windowManager = (WindowManager) DoraemonKit.APPLICATION.getSystemService(Context.WINDOW_SERVICE); if (windowManager == null) { return 0; } windowManager.getDefaultDisplay().getMetrics(metrics); return metrics.widthPixels; }
Example #14
Source File: TestApp.java From TikTok with Apache License 2.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); ARouter.openLog(); // 打印日志 ARouter.openDebug(); // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险) ARouter.init(this); // 尽可能早,推荐在Application中初始化 RxToast.init(this) .setBackgroundColor("#CC000000") .setTextColor("#FFFFFF") .setGravity(Gravity.CENTER) .setPadding(16, 16, 12, 12) .setMaxLines(2) .setTextSize(12) .setZ(30) .setMaxLines(3) .apply(); Utils.init(this); DoraemonKit.install(this); // H5任意门功能需要,非必须 DoraemonKit.setWebDoorCallback(new WebDoorManager.WebDoorCallback() { @Override public void overrideUrlLoading(Context context, String s) { // 使用自己的H5容器打开这个链接 } }); }
Example #15
Source File: DokitUtil.java From DoraemonKit with Apache License 2.0 | 4 votes |
public static String getString(@StringRes int stringId) { return DoraemonKit.APPLICATION.getString(stringId); }
Example #16
Source File: AppLifecyclesImpl.java From TikTok with Apache License 2.0 | 4 votes |
@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); } }); }
Example #17
Source File: UIUtils.java From DoraemonKit with Apache License 2.0 | 4 votes |
public static int getStatusBarHeight() { Resources resources = DoraemonKit.APPLICATION.getResources(); int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android"); int height = resources.getDimensionPixelSize(resourceId); return height; }
Example #18
Source File: LargeImageListAdapter.java From DoraemonKit with Apache License 2.0 | 4 votes |
@Override public void bind(final LargeImageInfo largeImageInfo) { try { int resourceUrl = Integer.parseInt(largeImageInfo.getUrl()); DokitPicasso.with(DoraemonKit.APPLICATION) .load(resourceUrl) .memoryPolicy(MemoryPolicy.NO_CACHE) .resize(ConvertUtils.dp2px(100), ConvertUtils.dp2px(100)) .centerCrop() .into(iv); tvLink.setText("resource id:" + resourceUrl); } catch (Exception e) { DokitPicasso.with(DoraemonKit.APPLICATION) .load(largeImageInfo.getUrl()) .memoryPolicy(MemoryPolicy.NO_CACHE) .resize(ConvertUtils.dp2px(100), ConvertUtils.dp2px(100)) .centerCrop() .into(iv); tvLink.setText(largeImageInfo.getUrl()); } if (largeImageInfo.getMemorySize() == 0) { tvFrameWork.setText(String.format("framework:%s", "network")); tvMemorySize.setVisibility(View.GONE); tvSize.setVisibility(View.GONE); } else { tvFrameWork.setText(String.format("framework:%s", largeImageInfo.getFramework())); tvMemorySize.setVisibility(View.VISIBLE); tvSize.setVisibility(View.VISIBLE); } if (largeImageInfo.getFileSize() == 0) { tvFileSize.setVisibility(View.GONE); } else { tvFileSize.setVisibility(View.VISIBLE); } tvFileSize.setText(String.format("fileSize:%s", mDecimalFormat.format(largeImageInfo.getFileSize()) + "KB")); tvMemorySize.setText(String.format("memorySize:%s", mDecimalFormat.format(largeImageInfo.getMemorySize()) + "MB")); tvSize.setText(String.format("width:%s height:%s", largeImageInfo.getWidth(), largeImageInfo.getHeight())); btnCopy.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ClipboardUtils.copyUri(Uri.parse(largeImageInfo.getUrl())); ToastUtils.showShort("image url has copied"); } }); }
Example #19
Source File: LogInfoDokitView.java From DoraemonKit with Apache License 2.0 | 4 votes |
/** * 将日志信息保存到文件 * * @param operateType 100 保存到本地 101 保存到本地并分享 */ private void export2File(final int operateType) { ToastUtils.showShort("日志保存中,请稍后..."); final String logPath = PathUtils.getInternalAppFilesPath() + File.separator + AppUtils.getAppName() + "_" + TimeUtils.getNowString(new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss")) + ".log"; final File logFile = new File(logPath); ThreadUtils.executeByCpu(new ThreadUtils.Task<Boolean>() { @Override public Boolean doInBackground() throws Throwable { try { List<LogLine> logLines = new ArrayList<>(mLogItemAdapter.getTrueValues()); for (LogLine logLine : logLines) { String strLog = logLine.getProcessId() + " " + " " + logLine.getTimestamp() + " " + logLine.getTag() + " " + logLine.getLogLevelText() + " " + logLine.getLogOutput() + "\n"; FileIOUtils.writeFileFromString(logFile, strLog, true); } return true; } catch (Exception e) { e.printStackTrace(); return false; } } @Override public void onSuccess(Boolean result) { if (result) { ToastUtils.showShort("文件保存在:" + logPath); //分享 if (operateType == 101) { FileUtil.systemShare(DoraemonKit.APPLICATION, logFile); } } } @Override public void onCancel() { if (logFile.exists()) { FileUtils.delete(logFile); } ToastUtils.showShort("日志保存失败"); } @Override public void onFail(Throwable t) { if (logFile.exists()) { FileUtils.delete(logFile); } ToastUtils.showShort("日志保存失败"); } }); }
Example #20
Source File: AppStartInfoFragment.java From DoraemonKit with Apache License 2.0 | 4 votes |
/** * 将启动信息保存到文件并分享 */ private void export2File(final String info) { if (TextUtils.isEmpty(info)) { ToastUtils.showShort("启动信息为空"); return; } ToastUtils.showShort("启动信息保存中,请稍后..."); final String logPath = PathUtils.getInternalAppFilesPath() + File.separator + AppUtils.getAppName() + "_" + "app_launch.log"; final File logFile = new File(logPath); ThreadUtils.executeByCpu(new ThreadUtils.Task<Boolean>() { @Override public Boolean doInBackground() throws Throwable { try { FileIOUtils.writeFileFromString(logFile, info, false); return true; } catch (Exception e) { e.printStackTrace(); return false; } } @Override public void onSuccess(Boolean result) { if (result) { ToastUtils.showShort("启动信息文件保存在:" + logPath); //分享 FileUtil.systemShare(DoraemonKit.APPLICATION, logFile); } } @Override public void onCancel() { if (logFile.exists()) { FileUtils.delete(logFile); } ToastUtils.showShort("启动信息保存失败"); } @Override public void onFail(Throwable t) { if (logFile.exists()) { FileUtils.delete(logFile); } ToastUtils.showShort("启动信息保存失败"); } }); }