merge
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.mogo.eagle.core.utilcode.mogo;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_UTIL;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.os.Build;
|
||||
@@ -7,7 +9,7 @@ import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -79,7 +81,7 @@ public class TelephoneUtil {
|
||||
if (getMobileDataEnabledMethod != null) {
|
||||
getMobileDataEnabledMethod.setAccessible(true);
|
||||
boolean result = (Boolean) getMobileDataEnabledMethod.invoke(iConMgr);
|
||||
Logger.d("TelephoneUtil", "getMobileDataEnabled = " + result);
|
||||
CallerLogger.INSTANCE.d(M_UTIL + "TelephoneUtil", "getMobileDataEnabled = " + result);
|
||||
return result;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -92,7 +94,7 @@ public class TelephoneUtil {
|
||||
Method getDataEnabled = telephonyService.getClass().getDeclaredMethod("getDataEnabled");
|
||||
if (null != getDataEnabled) {
|
||||
boolean result = (Boolean) getDataEnabled.invoke(telephonyService);
|
||||
Logger.d("TelephoneUtil", "getDataEnabled = " + result);
|
||||
CallerLogger.INSTANCE.d(M_UTIL + "TelephoneUtil", "getDataEnabled = " + result);
|
||||
return result;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -119,7 +121,7 @@ public class TelephoneUtil {
|
||||
if (setMobileDataEnabledMethod != null) {
|
||||
setMobileDataEnabledMethod.setAccessible(true);
|
||||
setMobileDataEnabledMethod.invoke(iConMgr, enable);
|
||||
Logger.d("TelephoneUtil", "setMobileDataEnabled = " + enable);
|
||||
CallerLogger.INSTANCE.d(M_UTIL + "TelephoneUtil", "setMobileDataEnabled = " + enable);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -131,7 +133,7 @@ public class TelephoneUtil {
|
||||
Method setDataEnabledMethod = telephonyService.getClass().getDeclaredMethod("setDataEnabled", boolean.class);
|
||||
if (null != setDataEnabledMethod) {
|
||||
setDataEnabledMethod.invoke(telephonyService, enable);
|
||||
Logger.d("TelephoneUtil", "setDataEnabled = " + enable);
|
||||
CallerLogger.INSTANCE.d(M_UTIL + "TelephoneUtil", "setDataEnabled = " + enable);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.mogo.eagle.core.utilcode.mogo.glide;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_UTIL;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.renderscript.Allocation;
|
||||
@@ -7,16 +9,17 @@ import android.renderscript.Element;
|
||||
import android.renderscript.RenderScript;
|
||||
import android.renderscript.ScriptIntrinsicBlur;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
|
||||
/**
|
||||
* 使用Glide加载图片时,使该图片进行高斯模糊
|
||||
* 基本用法:Glide.with(this).load(userInfo.headImgurl).apply(RequestOptions.bitmapTransform(GlideBlurTransformation(this))).into(ivCardBg)
|
||||
* 如果想用多个Transform可以使用{@link com.bumptech.glide.load.MultiTransformation} 进行Transform的融合
|
||||
* 如果想用多个Transform可以使用{@link com.bumptech.glide.load.MultiTransformation} 进行Transform的融合
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class GlideBlurTransformation extends CenterCrop {
|
||||
@@ -26,6 +29,7 @@ public class GlideBlurTransformation extends CenterCrop {
|
||||
private Context context;
|
||||
private float blurRadius;
|
||||
private float outScale;
|
||||
|
||||
public GlideBlurTransformation(Context context) {
|
||||
this(context, DEFAULT_BLUR_RADIUS);
|
||||
}
|
||||
@@ -44,7 +48,7 @@ public class GlideBlurTransformation extends CenterCrop {
|
||||
protected Bitmap transform(@NonNull BitmapPool pool, @NonNull Bitmap toTransform,
|
||||
int outWidth, int outHeight) {
|
||||
Bitmap bitmap = super.transform(pool, toTransform, outWidth, outHeight);
|
||||
Logger.d("GlideBlurTransformation", "transform=== blurRadius: " + blurRadius + " " +
|
||||
CallerLogger.INSTANCE.d(M_UTIL + "GlideBlurTransformation", "transform=== blurRadius: " + blurRadius + " " +
|
||||
"outScale: " + outScale);
|
||||
return blurBitmap(bitmap, blurRadius, (int) (outWidth * outScale), (int) (outHeight * outScale));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.mogo.eagle.core.utilcode.mogo.logger
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.Scene.Companion.scene
|
||||
|
||||
object CallerLogger {
|
||||
|
||||
fun i(tag: String, message: Any? = null) {
|
||||
if (scene.check(tag)) {
|
||||
Logger.i(tag, message.toString(), null)
|
||||
}
|
||||
}
|
||||
|
||||
fun d(tag: String, message: Any? = null) {
|
||||
if (scene.check(tag)) {
|
||||
Logger.d(tag, message.toString(), null)
|
||||
}
|
||||
}
|
||||
|
||||
fun w(tag: String, message: Any? = null) {
|
||||
if (scene.check(tag)) {
|
||||
Logger.w(tag, message.toString(), null)
|
||||
}
|
||||
}
|
||||
|
||||
fun e(tag: String, message: Any? = null) {
|
||||
if (scene.check(tag)) {
|
||||
Logger.e(tag, message.toString(), null)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.mogo.eagle.core.utilcode.mogo.logger.scene
|
||||
|
||||
import android.util.ArrayMap
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_ADAS_IMPL
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_DEVA
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_NETWORK
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OTHER
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OLD_ROUTE
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* 场景日志,提供场景过滤服务
|
||||
*/
|
||||
class Scene {
|
||||
|
||||
companion object {
|
||||
|
||||
private val sceneCache: MutableMap<String, SceneLogCache> =
|
||||
Collections.synchronizedMap(ArrayMap())
|
||||
|
||||
val scene: Scene by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
Scene()
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
//初始化网络
|
||||
val networkMap = SceneLogCache(mutableMapOf(), true)
|
||||
sceneCache[M_NETWORK] = networkMap
|
||||
|
||||
//初始化ADAS
|
||||
val adasMap = SceneLogCache(mutableMapOf(), true)
|
||||
sceneCache[M_ADAS_IMPL] = adasMap
|
||||
|
||||
//初始化deva
|
||||
val devaMap = SceneLogCache(mutableMapOf(), true)
|
||||
sceneCache[M_DEVA] = devaMap
|
||||
|
||||
//初始化路径规划
|
||||
val routeMap = SceneLogCache(mutableMapOf(), true)
|
||||
sceneCache[M_OLD_ROUTE] = routeMap
|
||||
|
||||
//初始化其他模块,方便定位索引
|
||||
val otherMap = SceneLogCache(mutableMapOf(), true)
|
||||
sceneCache[M_OTHER] = otherMap
|
||||
|
||||
//todo 1. SceneLogCache增加模块名称,提供场景需要
|
||||
//todo 2. 对特定场景提供数据, 网约车,调度...
|
||||
|
||||
}
|
||||
|
||||
fun check(tag: String): Boolean {
|
||||
return if (canLog()) {
|
||||
classifyLog(tag)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
//前置收口
|
||||
private fun canLog(): Boolean {
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* log分类,现阶段通过控制模块等级来限制,后续有需要再细分至模块对应类层级
|
||||
*/
|
||||
private fun classifyLog(tag: String): Boolean {
|
||||
var moduleName: String? = null
|
||||
var businessName: String? = null
|
||||
if (tag.contains("_")) {
|
||||
val tagSplit = tag.split("_")
|
||||
moduleName = tagSplit[0]
|
||||
if (tagSplit.size > 1) {
|
||||
businessName = tagSplit[1]
|
||||
}
|
||||
}
|
||||
|
||||
if (moduleName.isNullOrEmpty()) {
|
||||
val otherLogCache = sceneCache[M_OTHER]
|
||||
otherLogCache!!.tagMap!![tag] = true
|
||||
return otherLogCache.logger
|
||||
}
|
||||
|
||||
//此处存在用户自定义方式,可根据过滤找到对应不符合标准的模块
|
||||
var logCache = sceneCache[moduleName]
|
||||
if (logCache == null) {
|
||||
logCache = SceneLogCache(mutableMapOf(), true)
|
||||
businessName?.let {
|
||||
logCache.tagMap!![it] = true
|
||||
}
|
||||
}
|
||||
sceneCache[moduleName] = logCache
|
||||
return logCache.logger
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.mogo.eagle.core.utilcode.mogo.logger.scene
|
||||
|
||||
class SceneConstant {
|
||||
|
||||
companion object {
|
||||
|
||||
//核心module
|
||||
const val M_NETWORK = "CORE-NETWORK_"
|
||||
const val M_UTIL = "CORE-UTIL_"
|
||||
|
||||
//core业务module
|
||||
const val M_ADAS_IMPL = "CORE-ADAS_"
|
||||
const val M_CORDER = "CORE-CORDER_"
|
||||
const val M_CHAT = "CORE-CHAT_"
|
||||
const val M_DEVA = "CORE-DEVA_"
|
||||
const val M_DISPATCH = "CORE-DISPATCH_"
|
||||
const val M_HMI = "CORE-HMI_"
|
||||
const val M_MAIN = "CORE-MAIN_"
|
||||
const val M_MAP = "CORE-MAP_"
|
||||
const val M_MONITOR = "CORE-MONITOR_"
|
||||
const val M_NOTICE = "CORE-NOTICE_"
|
||||
const val M_OBU = "CORE-OBU_"
|
||||
const val M_V2X = "CORE-V2X_"
|
||||
|
||||
//旧module
|
||||
const val M_OLD_ROUTE = "OLD-ROUTE-SERVICE_"
|
||||
const val M_OLD_OTHER = "OLD-OTHER-SERVICE_"
|
||||
const val M_OTHER = "ALL_OLD-MODULES_"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.mogo.eagle.core.utilcode.mogo.logger.scene
|
||||
|
||||
class SceneLogCache {
|
||||
|
||||
var tagMap:MutableMap<String,Boolean>? = null
|
||||
var logger:Boolean = true
|
||||
|
||||
constructor(tagMap: MutableMap<String, Boolean>?, logger: Boolean) {
|
||||
this.tagMap = tagMap
|
||||
this.logger = logger
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.mogo.eagle.core.utilcode.mogo.sqlite;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_UTIL;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.utils.sqlite.annotation.DbField;
|
||||
import com.mogo.utils.sqlite.annotation.DbTable;
|
||||
|
||||
@@ -55,7 +57,7 @@ public class SQLBaseDao<T> implements SQLIDao<T> {
|
||||
|
||||
//执行Sql进行自动建表
|
||||
String createTableSql = getCreateTableSql();
|
||||
Logger.d(TAG, "执行SQL:" + createTableSql);
|
||||
CallerLogger.INSTANCE.d(M_UTIL + TAG, "执行SQL:" + createTableSql);
|
||||
sqLiteDatabase.execSQL(createTableSql);
|
||||
|
||||
//初始化缓存空间
|
||||
@@ -391,7 +393,7 @@ public class SQLBaseDao<T> implements SQLIDao<T> {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Logger.d(TAG, "contentValues:" + contentValues);
|
||||
CallerLogger.INSTANCE.d(M_UTIL + TAG, "contentValues:" + contentValues);
|
||||
return contentValues;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.utils.sqlite.proxy
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_UTIL
|
||||
import java.lang.reflect.InvocationHandler
|
||||
import java.lang.reflect.Method
|
||||
import java.lang.reflect.Proxy
|
||||
@@ -12,6 +13,10 @@ import java.lang.reflect.Proxy
|
||||
|
||||
class BaseDaoProxyLog : InvocationHandler {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "BaseDaoProxyLog"
|
||||
}
|
||||
|
||||
private var target: Any? = null
|
||||
|
||||
/**
|
||||
@@ -24,8 +29,8 @@ class BaseDaoProxyLog : InvocationHandler {
|
||||
this.target = target
|
||||
//取得代理对象
|
||||
return Proxy.newProxyInstance(
|
||||
target.javaClass.classLoader,
|
||||
target.javaClass.interfaces, this
|
||||
target.javaClass.classLoader,
|
||||
target.javaClass.interfaces, this
|
||||
)
|
||||
}
|
||||
|
||||
@@ -39,11 +44,11 @@ class BaseDaoProxyLog : InvocationHandler {
|
||||
@Throws(Throwable::class)
|
||||
override fun invoke(proxy: Any, method: Method, args: Array<Any>): Any? {
|
||||
//反射方法前调用
|
||||
Logger.i("SQL数据库管理", "当前执行>>${method.name}>>")
|
||||
CallerLogger.i("$M_UTIL$TAG", "SQL数据库管理 当前执行>>${method.name}>>")
|
||||
//反射执行方法 相当于调用target.sayHelllo;
|
||||
val result: Any? = method.invoke(target, *args)
|
||||
//反射方法后调用.
|
||||
Logger.i("SQL数据库管理", "执行结果>>$result")
|
||||
CallerLogger.i("$M_UTIL$TAG", "SQL数据库管理 执行结果>>$result")
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ package com.mogo.eagle.core.utilcode.mogo.toast;
|
||||
* @Version 1.1
|
||||
*/
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_UTIL;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
@@ -17,14 +19,13 @@ import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.LifecycleEventObserver;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.kotlin.ExtensionsKt;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
|
||||
|
||||
/**
|
||||
@@ -40,111 +41,111 @@ public final class TipToast {
|
||||
private static Context sContext;
|
||||
private static ToastViewGenerator sGenerator;
|
||||
|
||||
public static void init( Context context, ToastViewGenerator generator ) {
|
||||
public static void init(Context context, ToastViewGenerator generator) {
|
||||
TipToast.sContext = context.getApplicationContext();
|
||||
sHandler = new Handler( context.getMainLooper() );
|
||||
sHandler = new Handler(context.getMainLooper());
|
||||
sGenerator = generator;
|
||||
}
|
||||
|
||||
public static void recycle() {
|
||||
sContext = null;
|
||||
sHandler = null;
|
||||
if ( sToast != null ) {
|
||||
if (sToast != null) {
|
||||
sToast.cancel();
|
||||
sToast = null;
|
||||
}
|
||||
sGenerator = null;
|
||||
}
|
||||
|
||||
private static void tip( final String message, int duration ,TipDrawable tipDrawable) {
|
||||
if ( !checkParams() ) {
|
||||
private static void tip(final String message, int duration, TipDrawable tipDrawable) {
|
||||
if (!checkParams()) {
|
||||
return;
|
||||
}
|
||||
if ( TextUtils.isEmpty( message ) ) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
return;
|
||||
}
|
||||
new ToastThread(new StringToastRunnable(sContext, message, duration, tipDrawable)).start();
|
||||
}
|
||||
|
||||
private static void tip( final int msgId, int duration,TipDrawable tipDrawable ) {
|
||||
if ( !checkParams() ) {
|
||||
private static void tip(final int msgId, int duration, TipDrawable tipDrawable) {
|
||||
if (!checkParams()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if ( TextUtils.isEmpty( ResourcesHelper.getString( sContext, msgId ) ) ) {
|
||||
if (TextUtils.isEmpty(ResourcesHelper.getString(sContext, msgId))) {
|
||||
return;
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
} catch (Exception e) {
|
||||
return;
|
||||
}
|
||||
tip( ResourcesHelper.getString( sContext, msgId ), duration ,tipDrawable);
|
||||
tip(ResourcesHelper.getString(sContext, msgId), duration, tipDrawable);
|
||||
}
|
||||
|
||||
private static boolean checkParams() {
|
||||
if ( sContext == null ) {
|
||||
Logger.e( TAG, "context can't be null." );
|
||||
if (sContext == null) {
|
||||
CallerLogger.INSTANCE.e(M_UTIL + TAG, "context can't be null.");
|
||||
return false;
|
||||
}
|
||||
if ( sHandler == null ) {
|
||||
Logger.e( TAG, "sHandler can't be null." );
|
||||
if (sHandler == null) {
|
||||
CallerLogger.INSTANCE.e(M_UTIL + TAG, "sHandler can't be null.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void tip( final String message ) {
|
||||
tip( message, Toast.LENGTH_SHORT,null );
|
||||
public static void tip(final String message) {
|
||||
tip(message, Toast.LENGTH_SHORT, null);
|
||||
}
|
||||
|
||||
public static void tip( final int msgId ) {
|
||||
tip( msgId, Toast.LENGTH_SHORT ,null);
|
||||
public static void tip(final int msgId) {
|
||||
tip(msgId, Toast.LENGTH_SHORT, null);
|
||||
}
|
||||
|
||||
public static void longTip( String message ) {
|
||||
tip( message, Toast.LENGTH_LONG ,null);
|
||||
public static void longTip(String message) {
|
||||
tip(message, Toast.LENGTH_LONG, null);
|
||||
}
|
||||
|
||||
public static void longTip( int msgId ) {
|
||||
tip( msgId, Toast.LENGTH_LONG ,null);
|
||||
public static void longTip(int msgId) {
|
||||
tip(msgId, Toast.LENGTH_LONG, null);
|
||||
}
|
||||
|
||||
public static void shortTip( String message ) {
|
||||
tip( message, Toast.LENGTH_SHORT ,null);
|
||||
public static void shortTip(String message) {
|
||||
tip(message, Toast.LENGTH_SHORT, null);
|
||||
}
|
||||
|
||||
public static void shortTip( int msgId ) {
|
||||
tip( msgId, Toast.LENGTH_SHORT ,null);
|
||||
public static void shortTip(int msgId) {
|
||||
tip(msgId, Toast.LENGTH_SHORT, null);
|
||||
}
|
||||
|
||||
// -===带图片的方法===-
|
||||
|
||||
public static void tip( final String message,TipDrawable tipDrawable ) {
|
||||
tip( message, Toast.LENGTH_SHORT,tipDrawable );
|
||||
public static void tip(final String message, TipDrawable tipDrawable) {
|
||||
tip(message, Toast.LENGTH_SHORT, tipDrawable);
|
||||
}
|
||||
|
||||
public static void tip( final int msgId,TipDrawable tipDrawable ) {
|
||||
tip( msgId, Toast.LENGTH_SHORT ,tipDrawable);
|
||||
public static void tip(final int msgId, TipDrawable tipDrawable) {
|
||||
tip(msgId, Toast.LENGTH_SHORT, tipDrawable);
|
||||
}
|
||||
|
||||
public static void longTip( String message,TipDrawable tipDrawable ) {
|
||||
tip( message, Toast.LENGTH_LONG ,tipDrawable);
|
||||
public static void longTip(String message, TipDrawable tipDrawable) {
|
||||
tip(message, Toast.LENGTH_LONG, tipDrawable);
|
||||
}
|
||||
|
||||
public static void longTip( int msgId ,TipDrawable tipDrawable) {
|
||||
tip( msgId, Toast.LENGTH_LONG ,tipDrawable);
|
||||
public static void longTip(int msgId, TipDrawable tipDrawable) {
|
||||
tip(msgId, Toast.LENGTH_LONG, tipDrawable);
|
||||
}
|
||||
|
||||
public static void shortTip( String message,TipDrawable tipDrawable ) {
|
||||
tip( message, Toast.LENGTH_SHORT ,tipDrawable);
|
||||
public static void shortTip(String message, TipDrawable tipDrawable) {
|
||||
tip(message, Toast.LENGTH_SHORT, tipDrawable);
|
||||
}
|
||||
|
||||
public static void shortTip( int msgId,TipDrawable tipDrawable ) {
|
||||
tip( msgId, Toast.LENGTH_SHORT ,tipDrawable);
|
||||
public static void shortTip(int msgId, TipDrawable tipDrawable) {
|
||||
tip(msgId, Toast.LENGTH_SHORT, tipDrawable);
|
||||
}
|
||||
|
||||
static class ToastThread extends Thread {
|
||||
public ToastThread( Runnable runnable ) {
|
||||
super( runnable );
|
||||
public ToastThread(Runnable runnable) {
|
||||
super(runnable);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -156,7 +157,7 @@ public final class TipToast {
|
||||
int duration;
|
||||
TipDrawable tipDrawable;
|
||||
|
||||
public StringToastRunnable( Context context, String msg, int duration,TipDrawable tipDrawable ) {
|
||||
public StringToastRunnable(Context context, String msg, int duration, TipDrawable tipDrawable) {
|
||||
this.context = context;
|
||||
this.msg = msg;
|
||||
this.duration = duration;
|
||||
@@ -166,33 +167,33 @@ public final class TipToast {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if ( sHandler == null ) {
|
||||
if (sHandler == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
sHandler.post(() -> {
|
||||
synchronized ( sSyncObject ) {
|
||||
if ( context == null ) {
|
||||
synchronized (sSyncObject) {
|
||||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
if ( sToast != null) {
|
||||
if (sToast != null) {
|
||||
View view = sToast.getView();
|
||||
if (view != null && ViewCompat.isAttachedToWindow(view)) {
|
||||
sToast.cancel();
|
||||
}
|
||||
}
|
||||
if ( sGenerator == null ) {
|
||||
sToast = Toast.makeText( context, msg, duration );
|
||||
if (sGenerator == null) {
|
||||
sToast = Toast.makeText(context, msg, duration);
|
||||
} else {
|
||||
sToast = new Toast( context );
|
||||
final View view = sGenerator.make( context, msg, tipDrawable );
|
||||
sToast = new Toast(context);
|
||||
final View view = sGenerator.make(context, msg, tipDrawable);
|
||||
|
||||
if ( view != null ) {
|
||||
sToast.setView( view );
|
||||
sToast.setGravity( sGenerator.gravity(), sGenerator.xOffset(), sGenerator.yOffset() );
|
||||
sToast.setDuration( duration );
|
||||
if (view != null) {
|
||||
sToast.setView(view);
|
||||
sToast.setGravity(sGenerator.gravity(), sGenerator.xOffset(), sGenerator.yOffset());
|
||||
sToast.setDuration(duration);
|
||||
} else {
|
||||
sToast = Toast.makeText( context, msg, duration );
|
||||
sToast = Toast.makeText(context, msg, duration);
|
||||
}
|
||||
}
|
||||
View view = sToast.getView();
|
||||
@@ -204,7 +205,7 @@ public final class TipToast {
|
||||
}
|
||||
});
|
||||
}
|
||||
if ( sToast != null ) {
|
||||
if (sToast != null) {
|
||||
sToast.show();
|
||||
}
|
||||
}
|
||||
@@ -213,7 +214,7 @@ public final class TipToast {
|
||||
}
|
||||
|
||||
public interface ToastViewGenerator {
|
||||
View make( Context context, String message,TipDrawable tipDrawable );
|
||||
View make(Context context, String message, TipDrawable tipDrawable);
|
||||
|
||||
default int gravity() {
|
||||
return Gravity.CENTER;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.mogo.eagle.core.utilcode.util;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_UTIL;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.content.ComponentName;
|
||||
@@ -15,7 +17,6 @@ import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -24,6 +25,8 @@ import java.util.List;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* author: Blankj
|
||||
@@ -40,16 +43,16 @@ public final class AppUtils {
|
||||
throw new UnsupportedOperationException("u can't instantiate me...");
|
||||
}
|
||||
|
||||
public static String getCustomMapSDKVersion(Context context){
|
||||
return getApplicationMetaValue(context,MOGO_MAP_SDK_VERSION);
|
||||
public static String getCustomMapSDKVersion(Context context) {
|
||||
return getApplicationMetaValue(context, MOGO_MAP_SDK_VERSION);
|
||||
}
|
||||
|
||||
private static String getApplicationMetaValue(Context context,String metaName){
|
||||
private static String getApplicationMetaValue(Context context, String metaName) {
|
||||
try {
|
||||
ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(),PackageManager.GET_META_DATA);
|
||||
ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
|
||||
Bundle bundle = applicationInfo.metaData;
|
||||
if (bundle != null){
|
||||
return bundle.getString(metaName);
|
||||
if (bundle != null) {
|
||||
return bundle.getString(metaName);
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
@@ -57,23 +60,23 @@ public final class AppUtils {
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String getApplicationLabel( Context context, String pkgName ) {
|
||||
public static String getApplicationLabel(Context context, String pkgName) {
|
||||
try {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
ApplicationInfo appInfo = pm.getApplicationInfo( pkgName, PackageManager.GET_META_DATA );
|
||||
return pm.getApplicationLabel( appInfo ).toString();
|
||||
} catch ( Exception e ) {
|
||||
ApplicationInfo appInfo = pm.getApplicationInfo(pkgName, PackageManager.GET_META_DATA);
|
||||
return pm.getApplicationLabel(appInfo).toString();
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isAppForeground( Context context ) {
|
||||
if ( context != null ) {
|
||||
ActivityManager activityManager = ( ActivityManager ) context.getSystemService( Context.ACTIVITY_SERVICE );
|
||||
List< ActivityManager.RunningAppProcessInfo > processes = activityManager.getRunningAppProcesses();
|
||||
for ( ActivityManager.RunningAppProcessInfo processInfo : processes ) {
|
||||
if ( processInfo.processName.equals( context.getPackageName() ) ) {
|
||||
if ( processInfo.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND ) {
|
||||
public static boolean isAppForeground(Context context) {
|
||||
if (context != null) {
|
||||
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
List<ActivityManager.RunningAppProcessInfo> processes = activityManager.getRunningAppProcesses();
|
||||
for (ActivityManager.RunningAppProcessInfo processInfo : processes) {
|
||||
if (processInfo.processName.equals(context.getPackageName())) {
|
||||
if (processInfo.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -82,13 +85,13 @@ public final class AppUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isAppForeground( Context context, String pkg ) {
|
||||
if ( context != null ) {
|
||||
ActivityManager activityManager = ( ActivityManager ) context.getSystemService( Context.ACTIVITY_SERVICE );
|
||||
List< ActivityManager.RunningAppProcessInfo > processes = activityManager.getRunningAppProcesses();
|
||||
for ( ActivityManager.RunningAppProcessInfo processInfo : processes ) {
|
||||
if ( processInfo.processName.equals( pkg ) ) {
|
||||
if ( processInfo.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND ) {
|
||||
public static boolean isAppForeground(Context context, String pkg) {
|
||||
if (context != null) {
|
||||
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
List<ActivityManager.RunningAppProcessInfo> processes = activityManager.getRunningAppProcesses();
|
||||
for (ActivityManager.RunningAppProcessInfo processInfo : processes) {
|
||||
if (processInfo.processName.equals(pkg)) {
|
||||
if (processInfo.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -98,13 +101,13 @@ public final class AppUtils {
|
||||
}
|
||||
|
||||
//获取已安装应用的 uid,-1 表示未安装此应用或程序异常
|
||||
public static int getPackageUid( Context context, String packageName ) {
|
||||
public static int getPackageUid(Context context, String packageName) {
|
||||
try {
|
||||
ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo( packageName, 0 );
|
||||
if ( applicationInfo != null ) {
|
||||
ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(packageName, 0);
|
||||
if (applicationInfo != null) {
|
||||
return applicationInfo.uid;
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
} catch (Exception e) {
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
@@ -118,15 +121,15 @@ public final class AppUtils {
|
||||
* @param uid 已安装应用的 uid
|
||||
* @return true 表示正在运行,false 表示没有运行
|
||||
*/
|
||||
public static boolean isProcessRunning( Context context, int uid ) {
|
||||
if ( context == null ) {
|
||||
public static boolean isProcessRunning(Context context, int uid) {
|
||||
if (context == null) {
|
||||
return false;
|
||||
}
|
||||
ActivityManager am = ( ActivityManager ) context.getSystemService( Context.ACTIVITY_SERVICE );
|
||||
List< ActivityManager.RunningServiceInfo > runningServiceInfos = am.getRunningServices( 200 );
|
||||
if ( runningServiceInfos.size() > 0 ) {
|
||||
for ( ActivityManager.RunningServiceInfo appProcess : runningServiceInfos ) {
|
||||
if ( uid == appProcess.uid ) {
|
||||
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
List<ActivityManager.RunningServiceInfo> runningServiceInfos = am.getRunningServices(200);
|
||||
if (runningServiceInfos.size() > 0) {
|
||||
for (ActivityManager.RunningServiceInfo appProcess : runningServiceInfos) {
|
||||
if (uid == appProcess.uid) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -343,7 +346,7 @@ public final class AppUtils {
|
||||
if (UtilsBridge.isSpace(packageName)) return;
|
||||
Intent launchAppIntent = UtilsBridge.getLaunchAppIntent(packageName);
|
||||
if (launchAppIntent == null) {
|
||||
Log.e("AppUtils", "Didn't exist launcher activity.");
|
||||
CallerLogger.INSTANCE.e(M_UTIL + "AppUtils", "Didn't exist launcher activity.");
|
||||
return;
|
||||
}
|
||||
Utils.getApp().startActivity(launchAppIntent);
|
||||
@@ -364,7 +367,7 @@ public final class AppUtils {
|
||||
public static void relaunchApp(final boolean isKillProcess) {
|
||||
Intent intent = UtilsBridge.getLaunchAppIntent(Utils.getApp().getPackageName());
|
||||
if (intent == null) {
|
||||
Log.e("AppUtils", "Didn't exist launcher activity.");
|
||||
CallerLogger.INSTANCE.e(M_UTIL + "AppUtils", "Didn't exist launcher activity.");
|
||||
return;
|
||||
}
|
||||
intent.addFlags(
|
||||
@@ -779,30 +782,30 @@ public final class AppUtils {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static boolean isApplicationBroughtToBackground( final Context context ) {
|
||||
ActivityManager am = ( ActivityManager ) context.getSystemService( Context.ACTIVITY_SERVICE );
|
||||
List< ActivityManager.RunningTaskInfo > tasks = am.getRunningTasks( 1 );
|
||||
if ( !tasks.isEmpty() ) {
|
||||
ComponentName topActivity = tasks.get( 0 ).topActivity;
|
||||
if ( !topActivity.getPackageName().equals( context.getPackageName() ) ) {
|
||||
public static boolean isApplicationBroughtToBackground(final Context context) {
|
||||
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
List<ActivityManager.RunningTaskInfo> tasks = am.getRunningTasks(1);
|
||||
if (!tasks.isEmpty()) {
|
||||
ComponentName topActivity = tasks.get(0).topActivity;
|
||||
if (!topActivity.getPackageName().equals(context.getPackageName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isAppInstalled( Context context, String pkg ) {
|
||||
public static boolean isAppInstalled(Context context, String pkg) {
|
||||
PackageInfo packageInfo;
|
||||
if ( TextUtils.isEmpty( pkg ) ) {
|
||||
if (TextUtils.isEmpty(pkg)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
packageInfo = context.getPackageManager().getPackageInfo( pkg, 0 );
|
||||
} catch ( PackageManager.NameNotFoundException e ) {
|
||||
packageInfo = context.getPackageManager().getPackageInfo(pkg, 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
packageInfo = null;
|
||||
e.printStackTrace();
|
||||
}
|
||||
if ( packageInfo == null ) {
|
||||
if (packageInfo == null) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
@@ -810,7 +813,6 @@ public final class AppUtils {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return the application's information.
|
||||
* <ul>
|
||||
@@ -926,13 +928,13 @@ public final class AppUtils {
|
||||
*/
|
||||
public static class AppInfo {
|
||||
|
||||
private String packageName;
|
||||
private String name;
|
||||
private String packageName;
|
||||
private String name;
|
||||
private Drawable icon;
|
||||
private String packagePath;
|
||||
private String versionName;
|
||||
private int versionCode;
|
||||
private boolean isSystem;
|
||||
private String packagePath;
|
||||
private String versionName;
|
||||
private int versionCode;
|
||||
private boolean isSystem;
|
||||
|
||||
public Drawable getIcon() {
|
||||
return icon;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.mogo.eagle.core.utilcode.util;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_UTIL;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ContentUris;
|
||||
import android.content.Context;
|
||||
@@ -22,9 +24,9 @@ import android.provider.DocumentsContract;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
|
||||
import com.elegant.utils.IOUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
@@ -121,14 +123,14 @@ public class BitmapHelper {
|
||||
if ( quality == 100 ) {
|
||||
fullSize = bos.size();
|
||||
}
|
||||
Log.i( TAG, "quality<---->size, " + quality + "<---->" + bos.size() / 1024 );
|
||||
CallerLogger.INSTANCE.i( M_UTIL + TAG, "quality<---->size, " + quality + "<---->" + bos.size() / 1024 );
|
||||
}
|
||||
while ( bos.size() > maxSizeOfBytes && ( quality -= ( fullSize > ONE_MB ) ? 10 : 5 ) >= 0 );
|
||||
|
||||
result = bos.toByteArray();
|
||||
|
||||
final long end = System.currentTimeMillis();
|
||||
Log.i( TAG,
|
||||
CallerLogger.INSTANCE.i( M_UTIL + TAG,
|
||||
"bitmap to bytes costs " + ( end - start ) + "ms, \n" +
|
||||
"bitmap full size is " + ( fullSize / 1024 ) + "kb, \n" +
|
||||
"bitmap final size is " + ( bos.size() / 1024 ) + "kb, \n" +
|
||||
@@ -295,7 +297,7 @@ public class BitmapHelper {
|
||||
sampleSize = sampleSize << 1;
|
||||
}
|
||||
|
||||
Log.i( TAG, "sample size is " + sampleSize );
|
||||
CallerLogger.INSTANCE.i( M_UTIL + TAG, "sample size is " + sampleSize );
|
||||
return sampleSize;
|
||||
}
|
||||
|
||||
@@ -336,7 +338,7 @@ public class BitmapHelper {
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Log.i( TAG, "ExifInterface, degree is " + degree );
|
||||
CallerLogger.INSTANCE.i( M_UTIL + TAG, "ExifInterface, degree is " + degree );
|
||||
|
||||
return degree;
|
||||
}
|
||||
@@ -414,7 +416,7 @@ public class BitmapHelper {
|
||||
final long start = System.currentTimeMillis();
|
||||
|
||||
if ( bitmap == null || file == null ) {
|
||||
Log.i( TAG, "保存失败, bitmap or file is null." );
|
||||
CallerLogger.INSTANCE.i( M_UTIL + TAG, "保存失败, bitmap or file is null." );
|
||||
return;
|
||||
}
|
||||
if ( file.getParentFile() != null && !file.getParentFile().exists() ) {
|
||||
@@ -428,13 +430,13 @@ public class BitmapHelper {
|
||||
fos.close();
|
||||
|
||||
if ( file.exists() ) {
|
||||
Log.i( TAG, "保存成功" );
|
||||
CallerLogger.INSTANCE.i(M_UTIL + TAG, "保存成功" );
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Log.i( TAG, "saving picture costs " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
CallerLogger.INSTANCE.i( M_UTIL + TAG, "saving picture costs " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.eagle.core.utilcode.util;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_UTIL;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -19,6 +20,8 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* author: Blankj
|
||||
@@ -118,7 +121,7 @@ public final class BusUtils {
|
||||
isNeedRecordTags = true;
|
||||
}
|
||||
if (buses.contains(bus)) {
|
||||
Log.w(TAG, "The bus of <" + bus + "> already registered.");
|
||||
CallerLogger.INSTANCE.w(M_UTIL + TAG, "The bus of <" + bus + "> already registered.");
|
||||
return;
|
||||
} else {
|
||||
buses.add(bus);
|
||||
@@ -168,7 +171,7 @@ public final class BusUtils {
|
||||
private void consumeSticky(final Object bus, final String tag, final Object arg) {
|
||||
List<BusInfo> busInfoList = mTag_BusInfoListMap.get(tag);
|
||||
if (busInfoList == null) {
|
||||
Log.e(TAG, "The bus of tag <" + tag + "> is not exists.");
|
||||
CallerLogger.INSTANCE.e(M_UTIL + TAG, "The bus of tag <" + tag + "> is not exists.");
|
||||
return;
|
||||
}
|
||||
for (BusInfo busInfo : busInfoList) {
|
||||
@@ -195,7 +198,7 @@ public final class BusUtils {
|
||||
synchronized (mClassName_BusesMap) {
|
||||
Set<Object> buses = mClassName_BusesMap.get(className);
|
||||
if (buses == null || !buses.contains(bus)) {
|
||||
Log.e(TAG, "The bus of <" + bus + "> was not registered before.");
|
||||
CallerLogger.INSTANCE.e(M_UTIL + TAG, "The bus of <" + bus + "> was not registered before.");
|
||||
return;
|
||||
}
|
||||
buses.remove(bus);
|
||||
@@ -209,9 +212,9 @@ public final class BusUtils {
|
||||
private void postInner(final String tag, final Object arg, final boolean sticky) {
|
||||
List<BusInfo> busInfoList = mTag_BusInfoListMap.get(tag);
|
||||
if (busInfoList == null) {
|
||||
Log.e(TAG, "The bus of tag <" + tag + "> is not exists.");
|
||||
CallerLogger.INSTANCE.e(M_UTIL + TAG, "The bus of tag <" + tag + "> is not exists.");
|
||||
if (mTag_BusInfoListMap.isEmpty()) {
|
||||
Log.e(TAG, "Please check whether the bus plugin is applied.");
|
||||
CallerLogger.INSTANCE.e(M_UTIL + TAG, "Please check whether the bus plugin is applied.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -316,7 +319,7 @@ public final class BusUtils {
|
||||
}
|
||||
if (buses.size() == 0) {
|
||||
if (!sticky) {
|
||||
Log.e(TAG, "The " + busInfo + " was not registered before.");
|
||||
CallerLogger.INSTANCE.e(M_UTIL + TAG, "The " + busInfo + " was not registered before.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -347,7 +350,7 @@ public final class BusUtils {
|
||||
private void postStickyInner(final String tag, final Object arg) {
|
||||
List<BusInfo> busInfoList = mTag_BusInfoListMap.get(tag);
|
||||
if (busInfoList == null) {
|
||||
Log.e(TAG, "The bus of tag <" + tag + "> is not exists.");
|
||||
CallerLogger.INSTANCE.e(M_UTIL + TAG, "The bus of tag <" + tag + "> is not exists.");
|
||||
return;
|
||||
}
|
||||
// 获取多对象,然后消费各个 busInfoList
|
||||
@@ -371,7 +374,7 @@ public final class BusUtils {
|
||||
private void removeStickyInner(final String tag) {
|
||||
List<BusInfo> busInfoList = mTag_BusInfoListMap.get(tag);
|
||||
if (busInfoList == null) {
|
||||
Log.e(TAG, "The bus of tag <" + tag + "> is not exists.");
|
||||
CallerLogger.INSTANCE.e(M_UTIL + TAG, "The bus of tag <" + tag + "> is not exists.");
|
||||
return;
|
||||
}
|
||||
for (BusInfo busInfo : busInfoList) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.mogo.eagle.core.utilcode.util;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_UTIL;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
@@ -14,7 +16,6 @@ import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.StateListDrawable;
|
||||
import android.os.Build;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
import android.util.StateSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.TouchDelegate;
|
||||
@@ -24,6 +25,8 @@ import androidx.annotation.IntRange;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.view.ViewCompat;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* author: Blankj
|
||||
@@ -358,7 +361,7 @@ public class ClickUtils {
|
||||
final int expandSizeBottom) {
|
||||
final View parentView = (View) view.getParent();
|
||||
if (parentView == null) {
|
||||
Log.e("ClickUtils", "expandClickArea must have parent view.");
|
||||
CallerLogger.INSTANCE.e(M_UTIL + "ClickUtils", "expandClickArea must have parent view.");
|
||||
return;
|
||||
}
|
||||
parentView.post(new Runnable() {
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
package com.mogo.eagle.core.utilcode.util;//package com.blankj.utilcode.util;
|
||||
//
|
||||
//import android.app.Activity;
|
||||
//import android.app.Dialog;
|
||||
//import android.content.Context;
|
||||
//import android.content.ContextWrapper;
|
||||
//import android.graphics.drawable.ColorDrawable;
|
||||
//import android.os.Build;
|
||||
//import android.support.annotation.LayoutRes;
|
||||
//import android.support.annotation.NonNull;
|
||||
//import android.util.Log;
|
||||
//import android.view.LayoutInflater;
|
||||
//import android.view.View;
|
||||
//import android.view.Window;
|
||||
//
|
||||
//import java.util.HashMap;
|
||||
//import java.util.TreeSet;
|
||||
//
|
||||
///**
|
||||
// * <pre>
|
||||
// * author: blankj
|
||||
// * blog : http://blankj.com
|
||||
// * time : 2019/08/26
|
||||
// * desc : utils about dialog
|
||||
// * </pre>
|
||||
// */
|
||||
//public class DialogUtils {
|
||||
//
|
||||
// private DialogUtils() {
|
||||
// throw new UnsupportedOperationException("u can't instantiate me...");
|
||||
// }
|
||||
//
|
||||
// public static void show(final Dialog dialog) {
|
||||
// if (dialog == null) return;
|
||||
// Utils.runOnUiThread(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// Activity activity = getActivityByContext(dialog.getContext());
|
||||
// if (!isActivityAlive(activity)) return;
|
||||
// dialog.show();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// public static void dismiss(final Dialog dialog) {
|
||||
// if (dialog == null) return;
|
||||
// Utils.runOnUiThread(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// dialog.dismiss();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// public static void show(final Utils.TransActivityDelegate delegate) {
|
||||
// Utils.TransActivity.start(null, delegate);
|
||||
// }
|
||||
//
|
||||
// public static Dialog create(Activity activity, @LayoutRes int layoutId) {
|
||||
// Dialog dialog = new Dialog(activity);
|
||||
// View dialogContent = LayoutInflater.from(activity).inflate(layoutId, null);
|
||||
//
|
||||
// dialog.setContentView(dialogContent);
|
||||
// Window window = dialog.getWindow();
|
||||
// if (window != null) {
|
||||
// window.setBackgroundDrawable(new ColorDrawable(0));
|
||||
// }
|
||||
//
|
||||
// return dialog;
|
||||
// }
|
||||
//
|
||||
// private static boolean isActivityAlive(final Activity activity) {
|
||||
// return activity != null && !activity.isFinishing()
|
||||
// && (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1 || !activity.isDestroyed());
|
||||
// }
|
||||
//
|
||||
// private static Activity getActivityByContext(Context context) {
|
||||
// if (context instanceof Activity) return (Activity) context;
|
||||
// while (context instanceof ContextWrapper) {
|
||||
// if (context instanceof Activity) {
|
||||
// return (Activity) context;
|
||||
// }
|
||||
// context = ((ContextWrapper) context).getBaseContext();
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// public static final class UtilsDialog extends Dialog {
|
||||
//
|
||||
// private int mPriority = 5;
|
||||
//
|
||||
// public UtilsDialog(@NonNull Context context) {
|
||||
// this(context, 0);
|
||||
// }
|
||||
//
|
||||
// public UtilsDialog(@NonNull Context context, int themeResId) {
|
||||
// super(context, themeResId);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void show() {
|
||||
// Utils.runOnUiThread(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// Activity activity = getActivityByContext(getContext());
|
||||
// if (!isActivityAlive(activity)) {
|
||||
// Log.w("DialogUtils", "Activity is not alive.");
|
||||
// return;
|
||||
// }
|
||||
// UtilsDialog.super.show();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void dismiss() {
|
||||
// Utils.runOnUiThread(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// UtilsDialog.super.dismiss();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// public void show(int priority) {
|
||||
// mPriority = priority;
|
||||
// show();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.mogo.eagle.core.utilcode.util;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_UTIL;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
@@ -157,7 +160,7 @@ public final class FileIOUtils {
|
||||
final boolean append,
|
||||
final OnProgressUpdateListener listener) {
|
||||
if (is == null || !UtilsBridge.createOrExistsFile(file)) {
|
||||
Log.e("FileIOUtils", "create file <" + file + "> failed.");
|
||||
CallerLogger.INSTANCE.e(M_UTIL + "FileIOUtils", "create file <" + file + "> failed.");
|
||||
return false;
|
||||
}
|
||||
OutputStream os = null;
|
||||
@@ -377,18 +380,18 @@ public final class FileIOUtils {
|
||||
final boolean append,
|
||||
final boolean isForce) {
|
||||
if (bytes == null) {
|
||||
Log.e("FileIOUtils", "bytes is null.");
|
||||
CallerLogger.INSTANCE.e(M_UTIL + "FileIOUtils", "bytes is null.");
|
||||
return false;
|
||||
}
|
||||
if (!UtilsBridge.createOrExistsFile(file)) {
|
||||
Log.e("FileIOUtils", "create file <" + file + "> failed.");
|
||||
CallerLogger.INSTANCE.e(M_UTIL + "FileIOUtils", "create file <" + file + "> failed.");
|
||||
return false;
|
||||
}
|
||||
FileChannel fc = null;
|
||||
try {
|
||||
fc = new FileOutputStream(file, append).getChannel();
|
||||
if (fc == null) {
|
||||
Log.e("FileIOUtils", "fc is null.");
|
||||
CallerLogger.INSTANCE.e(M_UTIL + "FileIOUtils", "fc is null.");
|
||||
return false;
|
||||
}
|
||||
fc.position(fc.size());
|
||||
@@ -467,14 +470,14 @@ public final class FileIOUtils {
|
||||
final boolean append,
|
||||
final boolean isForce) {
|
||||
if (bytes == null || !UtilsBridge.createOrExistsFile(file)) {
|
||||
Log.e("FileIOUtils", "create file <" + file + "> failed.");
|
||||
CallerLogger.INSTANCE.e(M_UTIL + "FileIOUtils", "create file <" + file + "> failed.");
|
||||
return false;
|
||||
}
|
||||
FileChannel fc = null;
|
||||
try {
|
||||
fc = new FileOutputStream(file, append).getChannel();
|
||||
if (fc == null) {
|
||||
Log.e("FileIOUtils", "fc is null.");
|
||||
CallerLogger.INSTANCE.e(M_UTIL + "FileIOUtils", "fc is null.");
|
||||
return false;
|
||||
}
|
||||
MappedByteBuffer mbb = fc.map(FileChannel.MapMode.READ_WRITE, fc.size(), bytes.length);
|
||||
@@ -544,7 +547,7 @@ public final class FileIOUtils {
|
||||
final boolean append) {
|
||||
if (file == null || content == null) return false;
|
||||
if (!UtilsBridge.createOrExistsFile(file)) {
|
||||
Log.e("FileIOUtils", "create file <" + file + "> failed.");
|
||||
CallerLogger.INSTANCE.e(M_UTIL + "FileIOUtils", "create file <" + file + "> failed.");
|
||||
return false;
|
||||
}
|
||||
BufferedWriter bw = null;
|
||||
@@ -869,7 +872,7 @@ public final class FileIOUtils {
|
||||
try {
|
||||
fc = new RandomAccessFile(file, "r").getChannel();
|
||||
if (fc == null) {
|
||||
Log.e("FileIOUtils", "fc is null.");
|
||||
CallerLogger.INSTANCE.e(M_UTIL + "FileIOUtils", "fc is null.");
|
||||
return new byte[0];
|
||||
}
|
||||
ByteBuffer byteBuffer = ByteBuffer.allocate((int) fc.size());
|
||||
@@ -913,7 +916,7 @@ public final class FileIOUtils {
|
||||
try {
|
||||
fc = new RandomAccessFile(file, "r").getChannel();
|
||||
if (fc == null) {
|
||||
Log.e("FileIOUtils", "fc is null.");
|
||||
CallerLogger.INSTANCE.e(M_UTIL + "FileIOUtils", "fc is null.");
|
||||
return new byte[0];
|
||||
}
|
||||
int size = (int) fc.size();
|
||||
|
||||
Reference in New Issue
Block a user