模块代码迁移

将foudations包下的mogo-utils模块下的代码迁移到core包下的mogo-core-utils模块下
注:远程依赖库网约车模块目前使用的是foudations包下的mogo-utils模块下Logger,
目前看项目中无该网约车模块功能,暂时注释掉该模块
This commit is contained in:
xuxinchao
2021-12-28 14:52:30 +08:00
parent 4b93315959
commit 8682f9bcb2
379 changed files with 1423 additions and 2705 deletions

View File

@@ -11,13 +11,13 @@ import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
import com.mogo.eagle.core.function.main.MainMoGoApplication;
import com.mogo.eagle.core.utilcode.mogo.logger.LogLevel;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
import com.mogo.eagle.core.utilcode.util.AppUtils;
import com.mogo.eagle.core.utilcode.util.CommonUtils;
import com.mogo.module.v2x.utils.ObuConfig;
import com.mogo.test.crashreport.CrashReportConstants;
import com.mogo.utils.AppUtils;
import com.mogo.utils.CommonUtils;
import com.mogo.utils.logger.LogLevel;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.storage.SharedPrefsMgr;
import java.util.HashMap;
import java.util.Map;

View File

@@ -12,6 +12,7 @@ import com.mogo.eagle.core.function.check.net.CheckNetWork.checkNetWork
import com.mogo.eagle.core.function.check.net.CheckResultData
import com.mogo.eagle.core.function.check.view.CheckActivity
import com.mogo.eagle.core.function.check.view.CheckDialog
import com.mogo.eagle.core.utilcode.util.ActivityLifecycleManager
import com.mogo.eagle.core.utilcode.util.ActivityUtils
import com.mogo.eagle.core.utilcode.util.AppUtils
import com.mogo.eagle.core.utilcode.util.LogUtils
@@ -19,7 +20,6 @@ import com.mogo.module.common.MogoApisHandler
import com.mogo.module.service.receiver.MogoReceiver
import com.mogo.service.statusmanager.IMogoStatusChangedListener
import com.mogo.service.statusmanager.StatusDescriptor
import com.mogo.utils.ActivityLifecycleManager
import java.util.concurrent.ConcurrentHashMap
/**

View File

@@ -9,13 +9,13 @@ import com.mogo.commons.AbsMogoApplication
import com.mogo.commons.debug.DebugConfig
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsListenerManager
import com.mogo.eagle.core.network.NetConfig
import com.mogo.eagle.core.utilcode.mogo.logger.LogLevel
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast
import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.mogo.eagle.core.utilcode.util.TimeUtils
import com.mogo.module.common.MogoApisHandler
import com.mogo.service.cloud.socket.IMogoOnMessageListener
import com.mogo.utils.logger.LogLevel
import com.mogo.utils.logger.Logger
import com.zhidao.loglib.bean.RemoteLogPushContent
import com.zhidao.loglib.call.LogInfoManagerFactory
import com.zhidao.loglib.core.ILogListener

View File

@@ -5,8 +5,8 @@ import android.view.View
import com.mogo.eagle.core.function.hmi.notification.enums.SidePattern
import com.mogo.eagle.core.function.hmi.notification.interfaces.OnFloatAnimator
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
import com.mogo.utils.WindowUtils
import com.mogo.utils.logger.Logger
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.eagle.core.utilcode.util.WindowUtils
/**
* @author donghongyu

View File

@@ -12,12 +12,11 @@ import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.WindowManager
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.function.hmi.notification.anim.AnimatorManager
import com.mogo.eagle.core.function.hmi.notification.enums.ShowPattern
import com.mogo.eagle.core.function.hmi.notification.widget.ParentFrameLayout
import com.mogo.utils.WindowUtils
import com.mogo.utils.logger.Logger
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.eagle.core.utilcode.util.WindowUtils
/**
* @author donghongyu

View File

@@ -7,7 +7,7 @@ import android.view.View
import android.view.WindowManager
import com.mogo.eagle.core.function.hmi.notification.enums.SidePattern
import com.mogo.eagle.core.function.hmi.notification.interfaces.OnFloatAnimator
import com.mogo.utils.WindowUtils
import com.mogo.eagle.core.utilcode.util.WindowUtils
import kotlin.math.min
/**

View File

@@ -4,15 +4,11 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.module.common.enums.EventTypeEnum
import com.mogo.eagle.core.function.hmi.WaringConst
import com.mogo.service.IMogoServiceApis
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.data.notice.NoticeNormalData
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWaringProvider
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.utilcode.util.SharedPrefs
import com.mogo.utils.logger.Logger
/**
* 用于普通云公告的测试

View File

@@ -7,8 +7,8 @@ import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.hmi.WaringConst
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.service.IMogoServiceApis
import com.mogo.utils.logger.Logger
/**
* V2X 预警广播接收。用于跨应用,跨进程,内部也可以通过这种方式 控制限速标志

View File

@@ -7,8 +7,8 @@ import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.hmi.WaringConst
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.service.IMogoServiceApis
import com.mogo.utils.logger.Logger
/**
* V2X 预警广播接收。用于跨应用,跨进程,内部也可以通过这种方式 触发红绿灯场景

View File

@@ -7,9 +7,9 @@ import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.hmi.WaringConst
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.module.common.enums.EventTypeEnum
import com.mogo.service.IMogoServiceApis
import com.mogo.utils.logger.Logger
/**
* V2X 预警广播接收。用于跨应用,跨进程,内部也可以通过这种方式弹出预警提示框

View File

@@ -31,10 +31,10 @@ import com.mogo.eagle.core.function.hmi.ui.notice.NoticeNormalBannerView
import com.mogo.eagle.core.function.hmi.ui.setting.DebugSettingView
import com.mogo.eagle.core.function.hmi.ui.tools.AutoPilotAndCheckView
import com.mogo.eagle.core.function.hmi.ui.widget.V2XNotificationView
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.module.common.enums.EventTypeEnum
import com.mogo.utils.logger.Logger
import kotlinx.android.synthetic.main.fragment_hmi.*
/**

View File

@@ -23,8 +23,8 @@ import com.mogo.cloud.trafficlive.api.MoGoAiCloudTrafficLive
import com.mogo.eagle.core.data.camera.CameraEntity
import com.mogo.eagle.core.function.call.monitor.CallerMonitorManager
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.eagle.core.widget.media.video.SimpleVideoPlayer
import com.mogo.utils.logger.Logger
import com.shuyu.gsyvideoplayer.GSYVideoManager
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder
import com.shuyu.gsyvideoplayer.model.VideoOptionModel

View File

@@ -17,10 +17,10 @@ import com.mogo.eagle.core.data.notice.NoticeTrafficStylePushData;
import com.mogo.eagle.core.function.hmi.R;
import com.mogo.eagle.core.function.hmi.WaringConst;
import com.mogo.eagle.core.function.hmi.notification.WarningFloat;
import com.mogo.eagle.core.utilcode.mogo.glide.GlideApp;
import com.mogo.eagle.core.utilcode.mogo.glide.GlideRoundedCornersTransform;
import com.mogo.eagle.core.utilcode.util.BitmapHelper;
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
import com.mogo.utils.BitmapHelper;
import com.mogo.utils.glide.GlideApp;
import com.mogo.utils.glide.GlideRoundedCornersTransform;
/**
* @author liujing

View File

@@ -10,15 +10,15 @@ import android.widget.TextView
import androidx.lifecycle.LifecycleObserver
import com.mogo.eagle.core.data.notice.NoticeNormalData
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.utilcode.mogo.glide.GlideApp
import com.mogo.eagle.core.utilcode.mogo.glide.GlideRoundedCornersTransform
import com.mogo.eagle.core.utilcode.util.BitmapHelper
import com.mogo.eagle.core.widget.media.video.NoticeSimpleVideoPlayer
import com.mogo.module.common.MogoApisHandler
import com.mogo.module.common.dialog.BaseFloatDialog
import com.mogo.service.IMogoServiceApis
import com.mogo.service.statusmanager.IMogoStatusChangedListener
import com.mogo.service.statusmanager.StatusDescriptor
import com.mogo.utils.BitmapHelper
import com.mogo.utils.glide.GlideApp
import com.mogo.utils.glide.GlideRoundedCornersTransform
import com.shuyu.gsyvideoplayer.GSYVideoManager
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder
import com.shuyu.gsyvideoplayer.listener.VideoAllCallBack
@@ -122,8 +122,10 @@ class NoticeCheckDialog(context: Context) : BaseFloatDialog(context), LifecycleO
pushVideo?.visibility = View.GONE
pushImageView?.visibility = View.VISIBLE
pushImageView?.let {
GlideApp.with(context).load(noticeNormal.imageUrl).optionalTransform(GlideRoundedCornersTransform(
20f, GlideRoundedCornersTransform.CornerType.ALL)).into(it)
GlideApp.with(context).load(noticeNormal.imageUrl).optionalTransform(
GlideRoundedCornersTransform(
20f, GlideRoundedCornersTransform.CornerType.ALL)
).into(it)
}
}

View File

@@ -12,14 +12,12 @@ import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.mogo.eagle.core.data.notice.NoticeNormalData;
import com.mogo.eagle.core.data.notice.NoticeTrafficStyleInfo;
import com.mogo.eagle.core.data.notice.NoticeTrafficStylePushData;
import com.mogo.eagle.core.function.hmi.R;
import com.mogo.eagle.core.function.hmi.WaringConst;
import com.mogo.eagle.core.function.hmi.notification.WarningFloat;
import com.mogo.eagle.core.utilcode.util.SharedPrefs;
import com.mogo.utils.glide.GlideApp;
import com.mogo.utils.glide.GlideRoundedCornersTransform;
import com.mogo.eagle.core.utilcode.mogo.glide.GlideApp;
import com.mogo.eagle.core.utilcode.mogo.glide.GlideRoundedCornersTransform;
/**
* @author lixiaopeng

View File

@@ -22,6 +22,10 @@ import com.mogo.eagle.core.function.api.notice.NoticeNetCallBack;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager;
import com.mogo.eagle.core.function.call.notice.CallerNoticeManager;
import com.mogo.eagle.core.function.hmi.R;
import com.mogo.eagle.core.utilcode.mogo.glide.GlideApp;
import com.mogo.eagle.core.utilcode.mogo.glide.GlideRoundedCornersTransform;
import com.mogo.eagle.core.utilcode.util.BitmapHelper;
import com.mogo.eagle.core.utilcode.util.DateTimeUtils;
import com.mogo.eagle.core.widget.media.video.NoticeSimpleSmallVideoPlayer;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.dialog.BaseFloatDialog;
@@ -29,11 +33,7 @@ import com.mogo.service.IMogoServiceApis;
import com.mogo.service.imageloader.MogoImageView;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.StatusDescriptor;
import com.mogo.utils.BitmapHelper;
import com.mogo.utils.glide.GlideApp;
import com.mogo.utils.glide.GlideRoundedCornersTransform;
import com.shuyu.gsyvideoplayer.GSYVideoManager;
import com.mogo.utils.DateTimeUtils;
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder;
import com.shuyu.gsyvideoplayer.listener.VideoAllCallBack;
import com.shuyu.gsyvideoplayer.utils.NetworkUtils;

View File

@@ -36,14 +36,9 @@ import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.network.utils.GsonUtil
import com.mogo.eagle.core.utilcode.mogo.logger.LogLevel
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.eagle.core.utilcode.util.AppUtils
import com.mogo.eagle.core.utilcode.util.GsonUtils
import com.mogo.eagle.core.utilcode.util.LogUtils
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
import com.mogo.eagle.core.utilcode.util.*
import com.mogo.map.MogoMap
import com.mogo.utils.DeviceIdUtils
import com.mogo.utils.UiThreadHandler
import com.mogo.utils.storage.SharedPrefsMgr
import kotlinx.android.synthetic.main.view_debug_setting.view.*
/**
@@ -279,13 +274,11 @@ class DebugSettingView @JvmOverloads constructor(
if (isChecked) {
LogUtils.getConfig().isLogSwitch = false
Logger.init(LogLevel.OFF)
com.mogo.utils.logger.Logger.init(com.mogo.utils.logger.LogLevel.OFF)
com.elegant.log.simplelog.Logger.init(com.elegant.log.simplelog.LogLevel.OFF)
com.zhidao.account.sdk.utils.Logger.init(false)
} else {
LogUtils.getConfig().isLogSwitch = true
Logger.init(LogLevel.DEBUG)
com.mogo.utils.logger.Logger.init(com.mogo.utils.logger.LogLevel.DEBUG)
com.elegant.log.simplelog.Logger.init(com.elegant.log.simplelog.LogLevel.DEBUG)
com.zhidao.account.sdk.utils.Logger.init(true)
}

View File

@@ -16,8 +16,8 @@ import com.mogo.eagle.core.function.call.hmi.CallerHmiListenerManager
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.utilcode.util.LogUtils
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import com.mogo.module.common.MogoApisHandler
import com.mogo.utils.UiThreadHandler
import kotlinx.android.synthetic.main.view_autopilot_status.view.*
/**

View File

@@ -1,28 +1,18 @@
package com.mogo.eagle.core.function.hmi.ui.widget
import android.animation.Animator
import android.content.Context
import android.graphics.Color
import android.location.Location
import android.util.AttributeSet
import android.util.Log
import android.view.Gravity
import android.view.View
import android.view.WindowManager
import android.view.animation.OvershootInterpolator
import android.widget.FrameLayout
import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.data.map.MogoLatLng
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.function.hmi.notification.WarningFloat
import com.mogo.eagle.core.function.hmi.notification.anim.DefaultAnimator
import com.mogo.eagle.core.function.hmi.notification.enums.SidePattern
import com.mogo.eagle.core.function.hmi.ui.setting.DebugSettingView
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import com.mogo.map.navi.IMogoCarLocationChangedListener2
import com.mogo.service.IMogoServiceApis
import com.mogo.service.statusmanager.StatusDescriptor
import com.mogo.utils.UiThreadHandler
import java.util.*
/**

View File

@@ -6,7 +6,7 @@ import android.view.LayoutInflater
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import com.mogo.eagle.core.function.hmi.R
import com.mogo.utils.UiThreadHandler
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import kotlinx.android.synthetic.main.view_traffic_light_vr.view.*
/**

View File

@@ -9,7 +9,7 @@ import androidx.annotation.Nullable
import androidx.annotation.StringRes
import androidx.constraintlayout.widget.ConstraintLayout
import com.mogo.eagle.core.function.hmi.R
import com.mogo.utils.UiThreadHandler
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import kotlinx.android.synthetic.main.notification_v2x_msg_vr.view.*
/**

View File

@@ -7,8 +7,8 @@ import android.view.View
import android.widget.RelativeLayout
import com.mogo.eagle.core.data.enums.WarningDirectionEnum
import com.mogo.eagle.core.function.hmi.R
import com.mogo.utils.UiThreadHandler
import com.mogo.utils.logger.Logger
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import kotlinx.android.synthetic.main.module_hmi_warning_v2x.view.*
/**

View File

@@ -5,7 +5,7 @@ import android.util.AttributeSet
import android.view.LayoutInflater
import androidx.constraintlayout.widget.ConstraintLayout
import com.mogo.eagle.core.function.hmi.R
import com.mogo.utils.UiThreadHandler
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import kotlinx.android.synthetic.main.view_vip_identification.view.*
/**

View File

@@ -12,12 +12,12 @@ import androidx.annotation.Nullable;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.eagle.core.function.api.base.IMoGoFunctionProvider;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.eagle.core.utilcode.util.ActivityLifecycleManager;
import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.module.main.MainActivity;
import com.mogo.service.intent.IMogoIntentListener;
import com.mogo.service.statusmanager.StatusDescriptor;
import com.mogo.utils.ActivityLifecycleManager;
import com.mogo.utils.logger.Logger;
/**
* 针对作为Launcher的情况做个性化操作
@@ -79,7 +79,7 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
protected void loadOthersModules() {
super.loadOthersModules();
Logger.d(TAG, "loadOthersModules");
loadOCHModule();
// loadOCHModule();
}
/**

View File

@@ -20,7 +20,10 @@ import com.mogo.eagle.core.data.constants.MogoServicePaths;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.function.notice.PushUIConstants;
import com.mogo.eagle.core.utilcode.mogo.AppLaunchTimeUtils;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
import com.mogo.eagle.core.utilcode.util.DeviceUtils;
import com.mogo.eagle.core.utilcode.util.ProcessUtils;
import com.mogo.map.MapApiPath;
import com.mogo.module.carchatting.card.CallChatConstant;
import com.mogo.module.common.MogoApisHandler;
@@ -34,9 +37,6 @@ import com.mogo.module.v2x.V2XConst;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.cloud.socket.IMogoLifecycleListener;
import com.mogo.test.crashreport.upgrade.UpgradeReportConstants;
import com.mogo.utils.ProcessUtils;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.storage.SharedPrefsMgr;
import com.zhidao.boot.persistent.lib.PersistentManager;
import com.zhidao.support.obu.ami.AmiClientManager;
import com.zhjt.service.chain.core.ChainTraceStarter;

View File

@@ -6,11 +6,10 @@ import android.os.Looper
import android.os.Message
import com.mogo.eagle.core.data.camera.*
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager
import com.mogo.eagle.core.function.monitoring.net.CameraListServices
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.module.common.MogoApisHandler
import com.mogo.module.common.constants.HostConst
import com.mogo.utils.logger.Logger
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers

View File

@@ -68,7 +68,6 @@ dependencies {
implementation rootProject.ext.dependencies.mogo_core_res
implementation rootProject.ext.dependencies.mogo_core_network
implementation rootProject.ext.dependencies.mogo_core_function_call
implementation rootProject.ext.dependencies.mogoutils
} else {
implementation project(":foudations:mogo-commons")
implementation project(':services:mogo-service-api')
@@ -79,7 +78,6 @@ dependencies {
implementation project(':core:mogo-core-res')
implementation project(':core:mogo-core-network')
implementation project(':core:mogo-core-function-call')
implementation project(':foudations:mogo-utils')
}
}

View File

@@ -7,9 +7,9 @@ import com.mogo.eagle.core.data.notice.NoticeNormalData;
import com.mogo.eagle.core.data.notice.NoticeTrafficStylePushData;
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
import com.mogo.eagle.core.network.utils.GsonUtil;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.service.cloud.socket.IMogoOnMessageListener;
import com.mogo.utils.logger.Logger;
/**
* @author Jing

View File

@@ -15,6 +15,7 @@ import com.mogo.eagle.core.function.notice.utils.AnimatorUtilsKt;
import com.mogo.eagle.core.function.notice.view.GlobalToolsKt;
import com.mogo.eagle.core.function.notice.view.PushItemAnimator;
import com.mogo.eagle.core.function.notice.view.SwipeItemLayout;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import com.mogo.module.common.view.OnPreventFastClickListener;
import com.mogo.eagle.core.function.notice.Config;
import com.mogo.eagle.core.function.notice.adapter.PushMessageAdapter;
@@ -23,7 +24,6 @@ import com.mogo.eagle.core.function.notice.repository.PushRepository;
import com.mogo.eagle.core.function.notice.utils.HandlerUtils;
import com.mogo.eagle.core.function.notice.viewmodel.MessageViewModel;
import com.mogo.service.statusmanager.IMogoMsgCenterListener;
import com.mogo.utils.UiThreadHandler;
import org.jetbrains.annotations.NotNull;

View File

@@ -12,7 +12,7 @@ import com.mogo.eagle.core.data.notice.NoticeTrafficStyleInfo;
import com.mogo.eagle.core.function.api.notice.NoticeNetCallBack;
import com.mogo.eagle.core.network.utils.GsonUtil;
import com.mogo.utils.logger.Logger;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import java.util.HashMap;
import java.util.Map;

View File

@@ -11,9 +11,9 @@ import com.mogo.eagle.core.function.notice.model.PushBean
import com.mogo.eagle.core.function.notice.utils.HandlerUtils
import com.mogo.eagle.core.function.notice.view.getApis
import com.mogo.eagle.core.function.notice.viewmodel.PushViewModel
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.service.statusmanager.IMogoStatusChangedListener
import com.mogo.service.statusmanager.StatusDescriptor
import com.mogo.utils.logger.Logger
import java.util.*
import kotlin.collections.HashSet

View File

@@ -6,7 +6,7 @@ import android.content.Intent
import android.util.Log
import com.mogo.eagle.core.data.notice.NoticeTrafficStylePushData
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.utils.logger.Logger
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
/**
* @author Jing

View File

@@ -4,7 +4,7 @@ import android.view.View
import android.view.ViewGroup
import androidx.core.view.get
import androidx.core.view.isNotEmpty
import com.mogo.utils.logger.Logger
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
const val TAG: String = "AnimatorUtils.kt"

View File

@@ -17,11 +17,11 @@ import com.mogo.eagle.core.function.notice.utils.AnalyticsUtils
import com.mogo.eagle.core.function.notice.utils.stringConverterBitmap
import com.mogo.eagle.core.function.notice.view.roundimage.RoundedImageView
import com.mogo.eagle.core.function.notice.viewmodel.PushViewModel
import com.mogo.eagle.core.utilcode.mogo.glide.GlideApp
import com.mogo.eagle.core.utilcode.util.ThreadPoolService
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import com.mogo.service.windowview.IMogoTopViewManager
import com.mogo.service.windowview.IMogoTopViewStatusListener
import com.mogo.utils.ThreadPoolService
import com.mogo.utils.UiThreadHandler
import com.mogo.utils.glide.GlideApp
class FloatView constructor(
private val pushViewModel: PushViewModel,

View File

@@ -5,8 +5,8 @@ import com.alibaba.android.arouter.facade.annotation.Route
import com.mogo.eagle.core.data.constants.MoGoConfig
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.function.api.obu.IMoGoObuProvider
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
import com.mogo.eagle.core.utilcode.util.LogUtils
import com.mogo.utils.storage.SharedPrefsMgr
/**
* @author xiaoyuzhou

View File

@@ -10,12 +10,12 @@ import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.call.obu.CallerObuListenerManager
import com.mogo.eagle.core.function.obu.mogo.utils.TrafficDataConvertUtils
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter
import com.mogo.module.common.drawer.TrafficMarkerDrawer
import com.mogo.module.common.enums.EventTypeEnum
import com.mogo.service.IMogoServiceApis
import com.mogo.service.map.IMogoMapService
import com.mogo.utils.storage.SharedPrefsMgr
import com.zhidao.support.obu.MogoObuManager
import com.zhidao.support.obu.OnMogoObuListener
import com.zhidao.support.obu.constants.ObuConstants

View File

@@ -35,10 +35,10 @@ import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener;
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
import com.mogo.eagle.core.function.smp.utils.MapAssetStyleUtils;
import com.mogo.eagle.core.function.smp.view.ISmallMapDirectionView;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.eagle.core.widget.RoundLayout;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.utils.DrivingDirectionUtils;
import com.mogo.utils.logger.Logger;
import java.util.ArrayList;
import java.util.List;

View File

@@ -18,9 +18,9 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
import com.mogo.eagle.core.function.api.map.smp.IMogoSmallMapProvider;
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.service.adas.IMogoAdasOCHCallback;
import com.mogo.utils.UiThreadHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

View File

@@ -10,11 +10,11 @@ import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.call.trafficlight.CallTrafficLightListenerManager
import com.mogo.eagle.core.function.call.vip.CallVipSetListenerManager
import com.mogo.eagle.core.function.v2x.vip.VipCarManager
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.mogo.map.navi.IMogoCarLocationChangedListener2
import com.mogo.module.common.MogoApisHandler
import com.mogo.module.common.enums.EventTypeEnum
import com.mogo.utils.logger.Logger
import kotlin.math.abs
import kotlin.math.ceil
import kotlin.math.floor

View File

@@ -5,12 +5,10 @@ import android.location.Location;
import com.mogo.eagle.core.data.map.MogoLatLng;
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.logger.Logger;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

View File

@@ -16,9 +16,9 @@ import com.mogo.eagle.core.function.v2x.trafficlight.core.TrafficLightThreadHand
import com.mogo.eagle.core.function.v2x.trafficlight.core.TrafficLightThreadHandler.Companion.MSG_WHAT_STOP_SEARCH_CROSS_ROAD
import com.mogo.eagle.core.function.v2x.trafficlight.core.TrafficLightThreadHandler.Companion.MSG_WHAT_STOP_SEARCH_TRAFFIC_LIGHT
import com.mogo.eagle.core.function.v2x.trafficlight.network.TrafficLightNetWorkModel
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.map.navi.IMogoCarLocationChangedListener2
import com.mogo.module.common.MogoApisHandler
import com.mogo.utils.logger.Logger
class MogoTrafficLightManager : IMogoCarLocationChangedListener2 {

View File

@@ -15,11 +15,11 @@ import com.mogo.eagle.core.function.call.trafficlight.CallTrafficLightListenerMa
import com.mogo.eagle.core.function.call.vip.CallVipSetListenerManager
import com.mogo.eagle.core.function.v2x.trafficlight.core.MogoTrafficLightManager
import com.mogo.eagle.core.function.v2x.vip.network.VipNetWorkModel
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import com.mogo.module.common.MogoApisHandler
import com.mogo.module.common.enums.EventTypeEnum
import com.mogo.service.cloud.socket.IMogoOnMessageListener
import com.mogo.utils.UiThreadHandler
import com.mogo.utils.logger.Logger
import kotlin.math.abs
class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListener,

View File

@@ -38,16 +38,31 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}
kapt.includeCompileClasspath = false
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation rootProject.ext.dependencies.androidxappcompat
kapt rootProject.ext.dependencies.androidxannotation
api rootProject.ext.dependencies.glide
kapt rootProject.ext.dependencies.glidecompiler
implementation rootProject.ext.dependencies.kotlinstdlibjdk7
implementation rootProject.ext.dependencies.androidxannotation
implementation rootProject.ext.dependencies.material
implementation rootProject.ext.dependencies.gson
implementation rootProject.ext.dependencies.glideanno
implementation rootProject.ext.dependencies.glideokhttp3
implementation rootProject.ext.dependencies.coroutinescore
implementation rootProject.ext.dependencies.coroutinesandroid
api rootProject.ext.dependencies.mogoaicloudpassport
api 'ch.hsr:geohash:1.4.0'
api rootProject.ext.dependencies.mogoaicloudnetwork
}
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()

View File

@@ -1,18 +1,12 @@
package com.mogo.utils.glide;
package com.mogo.eagle.core.utilcode.mogo.glide;
import android.content.Context;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.cache.ExternalPreferredCacheDiskCacheFactory;
import com.bumptech.glide.load.engine.cache.LruResourceCache;
import com.bumptech.glide.load.engine.cache.MemoryCache;
import com.bumptech.glide.load.engine.executor.GlideExecutor;
import com.bumptech.glide.module.AppGlideModule;

View File

@@ -1,4 +1,4 @@
package com.mogo.utils.glide;
package com.mogo.eagle.core.utilcode.mogo.glide;
import android.content.Context;
import android.graphics.Bitmap;
@@ -7,11 +7,11 @@ 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.utils.logger.Logger;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import androidx.annotation.NonNull;
/**
* 使用Glide加载图片时使该图片进行高斯模糊

View File

@@ -1,4 +1,4 @@
package com.mogo.utils.glide;
package com.mogo.eagle.core.utilcode.mogo.glide;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
@@ -7,14 +7,14 @@ import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import androidx.annotation.NonNull;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.mogo.utils.BuildConfig;
import com.mogo.eagle.core.utilcode.util.BuildConfig;
import java.security.MessageDigest;
import androidx.annotation.NonNull;
/**
* Glide加载图片使图片变成圆角图片工具
* 基本用法Glide.with(this).load(imgUrl).apply(RequestOptions.bitmapTransform(GlideRoundedCornersTransform(this))).into(imageView)

View File

@@ -1,8 +1,7 @@
package com.mogo.utils.permissions;
package com.mogo.eagle.core.utilcode.mogo.permissions;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;

View File

@@ -1,10 +1,10 @@
package com.mogo.utils.sqlite;
package com.mogo.eagle.core.utilcode.mogo.sqlite;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.mogo.utils.logger.Logger;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.utils.sqlite.annotation.DbField;
import com.mogo.utils.sqlite.annotation.DbTable;

View File

@@ -2,6 +2,8 @@ package com.mogo.utils.sqlite
import android.content.Context
import android.database.sqlite.SQLiteDatabase
import com.mogo.eagle.core.utilcode.mogo.sqlite.SQLBaseDao
import com.mogo.eagle.core.utilcode.mogo.sqlite.SQLIDao
import com.mogo.utils.sqlite.annotation.DbDatabase
import com.mogo.utils.sqlite.proxy.BaseDaoProxyLog

View File

@@ -1,4 +1,4 @@
package com.mogo.utils.sqlite;
package com.mogo.eagle.core.utilcode.mogo.sqlite;
import android.database.sqlite.SQLiteDatabase;

View File

@@ -1,6 +1,6 @@
package com.mogo.utils.sqlite.proxy
import com.mogo.utils.logger.Logger
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import java.lang.reflect.InvocationHandler
import java.lang.reflect.Method
import java.lang.reflect.Proxy

View File

@@ -1,12 +1,12 @@
package com.mogo.utils.storage;
package com.mogo.eagle.core.utilcode.mogo.storage;
import android.content.Context;
import android.content.SharedPreferences;
import androidx.annotation.NonNull;
import java.util.Set;
import androidx.annotation.NonNull;
public class SharedPrefsMgr {
private static final String File_Name = "app_shared_pref";

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.mogo.utils.storage.lrucache;
package com.mogo.eagle.core.utilcode.mogo.storage.lrucache;
import java.io.Closeable;
import java.io.File;

View File

@@ -1,4 +1,4 @@
package com.mogo.utils.storage.lrucache;
package com.mogo.eagle.core.utilcode.mogo.storage.lrucache;
import android.content.Context;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.mogo.utils.storage.lrucache;
package com.mogo.eagle.core.utilcode.mogo.storage.lrucache;
import java.io.BufferedWriter;
import java.io.Closeable;

View File

@@ -1,4 +1,4 @@
package com.mogo.utils.storage.lrucache;
package com.mogo.eagle.core.utilcode.mogo.storage.lrucache;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.mogo.utils.storage.lrucache;
package com.mogo.eagle.core.utilcode.mogo.storage.lrucache;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;

View File

@@ -1,4 +1,4 @@
package com.mogo.utils;
package com.mogo.eagle.core.utilcode.util;
import android.annotation.TargetApi;
import android.app.Activity;

View File

@@ -2,6 +2,7 @@ package com.mogo.eagle.core.utilcode.util;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
@@ -12,6 +13,8 @@ import android.content.pm.SigningInfo;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import java.io.File;
@@ -31,10 +34,106 @@ import androidx.annotation.Nullable;
*/
public final class AppUtils {
private static final String MOGO_MAP_SDK_VERSION = "MAP_SDK_VERSION";
private AppUtils() {
throw new UnsupportedOperationException("u can't instantiate me...");
}
public static String getCustomMapSDKVersion(Context context){
return getApplicationMetaValue(context,MOGO_MAP_SDK_VERSION);
}
private static String getApplicationMetaValue(Context context,String metaName){
try {
ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(),PackageManager.GET_META_DATA);
Bundle bundle = applicationInfo.metaData;
if (bundle != null){
return bundle.getString(metaName);
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return "";
}
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 ) {
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 ) {
return true;
}
}
}
}
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 ) {
return true;
}
}
}
}
return false;
}
//获取已安装应用的 uid-1 表示未安装此应用或程序异常
public static int getPackageUid( Context context, String packageName ) {
try {
ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo( packageName, 0 );
if ( applicationInfo != null ) {
return applicationInfo.uid;
}
} catch ( Exception e ) {
return -1;
}
return -1;
}
/**
* 判断某一 uid 的程序是否有正在运行的进程,即是否存活
* Created by cafeting on 2017/2/4.
*
* @param context 上下文
* @param uid 已安装应用的 uid
* @return true 表示正在运行false 表示没有运行
*/
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 ) {
return true;
}
}
}
return false;
}
/**
* Register the status of application changed listener.
*
@@ -680,6 +779,38 @@ 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() ) ) {
return true;
}
}
return false;
}
public static boolean isAppInstalled( Context context, String pkg ) {
PackageInfo packageInfo;
if ( TextUtils.isEmpty( pkg ) ) {
return false;
}
try {
packageInfo = context.getPackageManager().getPackageInfo( pkg, 0 );
} catch ( PackageManager.NameNotFoundException e ) {
packageInfo = null;
e.printStackTrace();
}
if ( packageInfo == null ) {
return false;
} else {
return true;
}
}
/**
* Return the application's information.
* <ul>

View File

@@ -1,8 +1,9 @@
package com.mogo.utils;
package com.mogo.eagle.core.utilcode.util;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import java.io.BufferedInputStream;
import java.io.InputStream;

View File

@@ -1,4 +1,4 @@
package com.mogo.utils;
package com.mogo.eagle.core.utilcode.util;
import android.annotation.SuppressLint;
import android.content.ContentUris;
@@ -24,6 +24,8 @@ import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
import com.elegant.utils.IOUtils;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
@@ -308,7 +310,7 @@ public class BitmapHelper {
}
/**
* Read a picture's degree from a file, we use {@link ExifInterface} instead of {@link android.media.ExifInterface}
* Read a picture's degree from a file, we use {@link ExifInterface} instead of {@link ExifInterface}
* to avoid some unexpected bugs.
*
* @param filePath file's absolute path which we can read data source of a picture from.

View File

@@ -1,6 +1,11 @@
package com.mogo.eagle.core.utilcode.util;
import android.graphics.Color;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.FloatRange;
@@ -214,4 +219,159 @@ public final class ColorUtils {
public static boolean isLightColor(@ColorInt int color) {
return 0.299 * Color.red(color) + 0.587 * Color.green(color) + 0.114 * Color.blue(color) >= 127.5;
}
/**
* ARGB颜色 转 HEX颜色
*/
public static String argbToHex(int alpha, int red, int green, int blue) {
if (alpha < 0 || alpha > 255
|| red < 0 || red > 255
|| green < 0 || green > 255
|| blue < 0 || blue > 255) {
return "";
}
String alphaStr = Integer.toHexString(alpha);
String redStr = Integer.toHexString(red);
String greenStr = Integer.toHexString(green);
String blueStr = Integer.toHexString(blue);
return ("#" + alphaStr + redStr + greenStr + blueStr).toUpperCase();
}
/**
* HEX颜色 转 ARGB颜色
*/
public static int[] hexToArgb(String hex) {
int[] rgb = new int[4];
if (!Pattern.matches("^#[0-9a-f[A-F]]{8}", hex)) {
return rgb;
}
String alphaStr = hex.substring(1, 3);
String redStr = hex.substring(3, 5);
String greenStr = hex.substring(5, 7);
String blueStr = hex.substring(7);
rgb[0] = Integer.valueOf(alphaStr, 16);
rgb[1] = Integer.valueOf(redStr, 16);
rgb[2] = Integer.valueOf(greenStr, 16);
rgb[3] = Integer.valueOf(blueStr, 16);
return rgb;
}
/**
* 对传入颜色生成梯度透明的颜色集合
*
* @param startColor 开始颜色
* @param startColor 结束颜色
* @param step 步长
* @return 生成的梯度颜色集合
*/
public static List<Integer> gradientAlpha(String startColor, String endColor, int step) {
// 将HEX转为RGB
int[] sColor = hexToArgb(startColor);
int[] eColor = hexToArgb(endColor);
// 计算每一步的差值
int aStep = (eColor[0] - sColor[0]) / step;
int rStep = (eColor[1] - sColor[1]) / step;
int gStep = (eColor[2] - sColor[2]) / step;
int bStep = (eColor[3] - sColor[3]) / step;
// 生成渐变色
List<Integer> gradientColorArr = new ArrayList<>();
for (int i = 0; i < step; i++) {
gradientColorArr.add(
Color.argb(aStep * i + sColor[0],
rStep * i + sColor[1],
gStep * i + sColor[2],
bStep * i + sColor[3]));
}
return gradientColorArr;
}
/**
* 对传入颜色生成梯度透明的颜色集合
*
* @param startColor 开始颜色
* @param startColor 结束颜色
* @param step 步长
* @return 生成的梯度颜色集合
*/
public static List<Integer> gradientAlpha_(String startColor, String centerColor, String endColor, int step) {
// 生成渐变色
List<Integer> gradientColorArr = new ArrayList<>();
// 将HEX转为RGB
int[] sColor = hexToArgb(startColor);
int[] cColor = hexToArgb(centerColor);
int[] eColor = hexToArgb(endColor);
if (step >= 3) {
int colorStep = (int) Math.floor(step/2);
// 计算每一步的差值
float aStep = (cColor[0] - sColor[0]) / colorStep;
float rStep = (cColor[1] - sColor[1]) / colorStep;
float gStep = (cColor[2] - sColor[2]) / colorStep;
float bStep = (cColor[3] - sColor[3]) / colorStep;
for (int i = 0; i < colorStep; i++) {
gradientColorArr.add(
Color.argb((int)(aStep * i + sColor[0]),
(int)(rStep * i + sColor[1]),
(int)(gStep * i + sColor[2]),
(int)(bStep * i + sColor[3])));
}
float aStep_ = (eColor[0] - cColor[0]) / colorStep;
float rStep_ = (eColor[1] - cColor[1]) / colorStep;
float gStep_ = (eColor[2] - cColor[2]) / colorStep;
float bStep_ = (eColor[3] - cColor[3]) / colorStep;
for (int i = 0; i < colorStep; i++) {
gradientColorArr.add(
Color.argb((int)(aStep_ * i + cColor[0]),
(int)(rStep_ * i + cColor[1]),
(int)(gStep_ * i + cColor[2]),
(int)(bStep_ * i + cColor[3])));
}
} else {
gradientColorArr.add(Color.argb(cColor[0], cColor[1], cColor[2], cColor[3]));
}
return gradientColorArr;
}
/**
* 获取一组渐变色数组
*
* @param startColor 开始颜色
* @param endColor 结束颜色
* @param step 步长
* @return 生成的梯度颜色集合
*/
public static List<Integer> getGradientAlpha(String startColor, String centerColor, String endColor, int step) {
// 将HEX转为RGB
int[] sColor = hexToArgb(startColor);
int[] cColor = hexToArgb(centerColor);
int[] eColor = hexToArgb(endColor);
// 生成渐变色
List<Integer> gradientColorArr = new ArrayList<>();
if (step >= 3) {
// 开始颜色
gradientColorArr.add(Color.argb(sColor[0], sColor[1], sColor[2], sColor[3]));
// 中间颜色
for (int i = 0; i < (step - 2); i++) {
gradientColorArr.add(Color.argb(cColor[0], cColor[1], cColor[2], cColor[3]));
}
//结束颜色
gradientColorArr.add(Color.argb(eColor[0], eColor[1], eColor[2], eColor[3]));
} else {
gradientColorArr.add(Color.argb(cColor[0], cColor[1], cColor[2], cColor[3]));
}
return gradientColorArr;
}
}

View File

@@ -1,4 +1,4 @@
package com.mogo.utils;
package com.mogo.eagle.core.utilcode.util;
import android.Manifest;
import android.annotation.TargetApi;
@@ -8,8 +8,6 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiManager;
@@ -19,31 +17,27 @@ import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.text.DecimalFormat;
import java.util.Enumeration;
import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
public class CommonUtils {
private static String mMacSerial = null;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.mogo.utils;
package com.mogo.eagle.core.utilcode.util;
import android.os.Handler;
import android.os.Message;

View File

@@ -1,4 +1,4 @@
package com.mogo.utils;
package com.mogo.eagle.core.utilcode.util;
import android.text.TextUtils;

View File

@@ -1,4 +1,4 @@
package com.mogo.utils;
package com.mogo.eagle.core.utilcode.util;
import android.Manifest;
import android.content.Context;
@@ -8,11 +8,11 @@ import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import com.elegant.utils.storage.SharedPrefsMgr;
import androidx.core.content.ContextCompat;
import com.mogo.utils.storage.SharedPrefsMgr;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

View File

@@ -1,20 +1,28 @@
package com.mogo.eagle.core.utilcode.util;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.res.AssetFileDescriptor;
import android.net.Uri;
import android.os.Build;
import android.os.StatFs;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.security.DigestInputStream;
import java.security.MessageDigest;
@@ -26,6 +34,9 @@ import java.util.List;
import javax.net.ssl.HttpsURLConnection;
import androidx.annotation.IntRange;
import androidx.core.content.FileProvider;
/**
* <pre>
* author: Blankj
@@ -1446,6 +1457,389 @@ public final class FileUtils {
return blockSize * availableSize;
}
public static boolean createFileDir(String fileDir) {
if (TextUtils.isEmpty(fileDir)) {
return false;
}
try {
File dir = new File(fileDir);
if(!dir.exists()){
return dir.mkdirs();
}
return dir.exists();
} catch (Exception e) {
return false;
}
}
public static boolean createFileDir(File dir) {
if (dir == null) {
return false;
}
try {
return dir.exists() || dir.mkdir();
} catch (Exception e) {
return false;
}
}
public static void writeToFile(String fileDir, String fileName, String content) {
if (fileDir == null || fileName == null || content == null) {
return;
}
if (!createFileDir(fileDir)) {
return;
}
FileOutputStream fos = null;
OutputStreamWriter osw = null;
try {
fos = new FileOutputStream(fileDir + fileName, true);
osw = new OutputStreamWriter(fos);
osw.write(content);
osw.flush();
} catch (IOException e) {
e.printStackTrace();
} finally {
IOUtils.closeSilently(fos);
IOUtils.closeSilently(osw);
}
}
/**
* Read a text file into a String, optionally limiting the length.
*/
public static String readTextFile(File file) {
InputStream is = null;
BufferedInputStream bis = null;
ByteArrayOutputStream bos = null;
String text = null;
try {
is = new FileInputStream(file);
bis = new BufferedInputStream(is);
bos = new ByteArrayOutputStream();
int len;
byte[] data = new byte[1024];
do {
len = bis.read(data);
if (len > 0) bos.write(data, 0, len);
} while (len == data.length);
text = bos.toString();
} catch (Exception e) {
e.printStackTrace();
} finally {
IOUtils.closeSilently(is);
IOUtils.closeSilently(bis);
IOUtils.closeSilently(bos);
}
return text;
}
public static String fileToBase64(File file) {
String base64 = null;
InputStream in = null;
try {
in = new FileInputStream(file);
byte[] bytes = new byte[in.available()];
int length = in.read(bytes);
base64 = Base64.encodeToString(bytes, 0, length, Base64.DEFAULT);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
IOUtils.closeSilently(in);
}
return base64;
}
/**
* Writes string to file. Basically same as "echo -n $string > $filename"
*/
public static void stringToFile(String filename, String string) {
FileWriter out = null;
try {
out = new FileWriter(filename);
out.write(string);
} catch (Exception e) {
e.printStackTrace();
} finally {
IOUtils.closeSilently(out);
}
}
public static InputStream stringToStream(String content) {
InputStream inputStream = null;
try {
inputStream = new ByteArrayInputStream(content.getBytes());
} catch (Exception e) {
e.printStackTrace();
}
return inputStream;
}
public static String streamToString(InputStream is) throws IOException {
String content = null;
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
int i = -1;
while ((i = is.read()) != -1) {
bos.write(i);
}
content = bos.toString();
} catch (Exception e) {
e.printStackTrace();
}
return content;
}
public static String getStringFromFile(Context context, String fileName) {
FileInputStream fis = null;
ByteArrayOutputStream os = null;
String content = null;
try {
fis = context.openFileInput(fileName);
os = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int length = -1;
while ((length = fis.read(buffer)) != -1) {
os.write(buffer, 0, length);
}
content = os.toString();
} catch (Exception e) {
e.printStackTrace();
} finally {
IOUtils.closeSilently(fis);
IOUtils.closeSilently(os);
}
return content;
}
public static InputStream getStreamFromFile(Context context, String fileName) {
FileInputStream fis = null;
try {
fis = context.openFileInput(fileName);
} catch (Exception e) {
e.printStackTrace();
}
return fis;
}
public static void saveStringToFile(Context context, String content, String fileName) {
try {
FileOutputStream fos = context.openFileOutput(fileName, Context.MODE_PRIVATE);
fos.write(content.getBytes());
IOUtils.closeSilently(fos);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 将scheme为file的uri转成FileProvider 提供的content uri
*/
public static Uri convertFileUriToFileProviderUri(Context context, Uri uri) {
if (uri == null) return null;
if (ContentResolver.SCHEME_FILE.equals(uri.getScheme())) {
return getUriForFile(context, new File(uri.getPath()));
}
return uri;
}
/**
* 创建一个用于拍照图片输出路径的Uri (FileProvider)
*/
public static Uri getUriForFile(Context context, File file) {
return FileProvider.getUriForFile(context, getFileProviderName(context), file);
}
public static String getFileProviderName(Context context) {
return context.getPackageName() + ".fileprovider";
}
/**
* 把Uri 解析出文件绝对路径
*/
public static String parseOwnUri(Context context, Uri uri) {
if (uri == null) return null;
String path;
if (TextUtils.equals(uri.getAuthority(), getFileProviderName(context))) {
path = new File(uri.getPath()).getAbsolutePath();
} else {
path = uri.getPath();
}
return path;
}
public static String getFileStreamPath(Context context, String name) {
String absFileName = null;
try {
File file = context.getFileStreamPath(name);
if (file != null && file.exists()) {
absFileName = file.getAbsolutePath();
}
} catch (Exception e) {
e.printStackTrace();
}
return absFileName;
}
/**
* 拷贝文件数据到指定目录
*
* @param is
* @param to
* @param listener
*/
public static void copy(final InputStream is, final String to, final FileCopyListener listener) {
new Thread(new Runnable() {
@Override
public void run() {
Log.w("FileUtils", "======copy======");
if (listener != null) {
listener.onStart();
}
try {
long fileSize = is.available();
long process = 0;
byte[] buff = new byte[1024];
int rc = 0;
File toFile = new File(to);
if (!toFile.getParentFile().exists()) {
toFile.getParentFile().mkdirs();
}
FileOutputStream fos = new FileOutputStream(toFile);
while ((rc = is.read(buff, 0, 1024)) > 0) {
process += rc;
fos.write(buff, 0, rc);
if (listener != null) {
listener.onProcess(((int) (((float) process) * 100 / fileSize)));
}
}
fos.flush();
fos.close();
is.close();
} catch (Exception e) {
if (listener != null) {
listener.onFail(e);
return;
}
}
if (listener != null) {
listener.onFinish(to);
}
}
}).start();
}
/**
* 拷贝文件到制定目录
*
* @param from
* @param to
* @param listener
*/
public static void copy(final String from, final String to, final FileCopyListener listener) {
new Thread(new Runnable() {
@Override
public void run() {
File file = null;
try {
file = new File(from);
} catch (Exception e) {
if (listener != null) {
listener.onFail(e);
}
return;
}
if (!file.isFile()) {
if (listener != null) {
listener.onFail(new Exception(String.format("%s is not a file", from)));
return;
}
}
if (!file.exists()) {
if (listener != null) {
listener.onFail(new FileNotFoundException(String.format("%s is not exists.", from)));
return;
}
}
if (listener != null) {
listener.onStart();
}
long fileSize = file.length();
long process = 0;
try {
FileInputStream fis = new FileInputStream(file);
byte[] buff = new byte[1024];
int rc = 0;
File toFile = new File(to);
if (!toFile.getParentFile().exists()) {
toFile.getParentFile().mkdirs();
}
FileOutputStream fos = new FileOutputStream(toFile);
while ((rc = fis.read(buff, 0, 1024)) > 0) {
process += rc;
fos.write(buff, 0, rc);
if (listener != null) {
listener.onProcess(((int) (((float) process) * 100 / fileSize)));
}
}
fos.flush();
fos.close();
fis.close();
} catch (Exception e) {
if (listener != null) {
listener.onFail(e);
return;
}
}
if (listener != null) {
listener.onFinish(to);
}
}
}).start();
}
/**
* 文件拷贝监听
*/
public interface FileCopyListener {
// 开始
void onStart();
// 失败
void onFail(Exception e);
// 进度
void onProcess(@IntRange(from = 0, to = 100) int process);
// 结束成功
void onFinish(String toPath);
}
///////////////////////////////////////////////////////////////////////////
// interface
///////////////////////////////////////////////////////////////////////////

View File

@@ -1,12 +1,12 @@
package com.mogo.utils;
package com.mogo.eagle.core.utilcode.util;
import androidx.annotation.Nullable;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.InputStream;
import androidx.annotation.Nullable;
public class IOUtils {
public static byte[] inputToBytes( InputStream is) {

View File

@@ -1,4 +1,4 @@
package com.mogo.utils;
package com.mogo.eagle.core.utilcode.util;
import android.content.Context;
import android.content.Intent;

View File

@@ -1,7 +1,7 @@
/*
* 创建日期2012-10-9
*/
package com.mogo.utils;
package com.mogo.eagle.core.utilcode.util;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

View File

@@ -11,11 +11,14 @@ import android.net.wifi.ScanResult;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.telephony.PhoneStateListener;
import android.telephony.SignalStrength;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.text.format.Formatter;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresPermission;
import java.lang.reflect.Method;
@@ -34,6 +37,8 @@ import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static android.Manifest.permission.ACCESS_COARSE_LOCATION;
import static android.Manifest.permission.ACCESS_NETWORK_STATE;
@@ -89,6 +94,116 @@ public final class NetworkUtils {
return info != null && info.isConnected();
}
/**
* Returns true if device is connected to wifi or mobile network, false
* otherwise.
*
* @param context
* @return
*/
public static boolean isConnected( Context context ) {
if ( context == null ) {
return false;
}
ConnectivityManager conMan = (ConnectivityManager) context
.getSystemService( Context.CONNECTIVITY_SERVICE );
if ( conMan == null ) {
return false;
}
NetworkInfo infoWifi = conMan.getNetworkInfo( ConnectivityManager.TYPE_WIFI );
if ( infoWifi != null ) {
NetworkInfo.State wifi = infoWifi.getState();
if ( wifi == NetworkInfo.State.CONNECTED ) {
return true;
}
}
NetworkInfo infoMobile = conMan.getNetworkInfo( ConnectivityManager.TYPE_MOBILE );
if ( infoMobile != null ) {
NetworkInfo.State mobile = infoMobile.getState();
if ( mobile == NetworkInfo.State.CONNECTED ) {
return true;
}
}
return false;
}
/**
* Check if there is any connectivity to a Wifi network
*
* @param context
* @return
*/
public static boolean isConnectedWifi( Context context ) {
if ( context == null ) {
return false;
}
NetworkInfo info = getNetworkInfo( context );
return ( info != null && info.isConnected() && info.getType() == ConnectivityManager.TYPE_WIFI );
}
/**
* Check if there is any connectivity to a mobile network
*
* @param context
* @return
*/
public static boolean isConnectedMobile( Context context ) {
if ( context == null ) {
return false;
}
NetworkInfo info = getNetworkInfo( context );
return ( info != null && info.isConnected() && info.getType() == ConnectivityManager.TYPE_MOBILE );
}
/**
* Get the network info
*
* @param context
* @return
*/
@Nullable
public static NetworkInfo getNetworkInfo( Context context ) {
if ( context == null ) {
return null;
}
ConnectivityManager cm = (ConnectivityManager) context.getSystemService( Context.CONNECTIVITY_SERVICE );
if ( cm != null ) {
return cm.getActiveNetworkInfo();
}
return null;
}
/**
* URL
*
* @param url
* @return true false
*/
public static boolean isNetworkUrl( String url ) {
String regex = "^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]";
Pattern patt = Pattern.compile( regex );
Matcher matcher = patt.matcher( url );
return matcher.matches();
}
public static int netStrengthLevel = 0;
public static void listenNetStrength(Context context) {
TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
manager.listen(new PhoneStateListener() {
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
super.onSignalStrengthsChanged(signalStrength);
netStrengthLevel = signalStrength.getLevel();
}
}, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
}
/**
* Return whether network is available.
* <p>Must hold {@code <uses-permission android:name="android.permission.INTERNET" />}</p>

View File

@@ -6,6 +6,7 @@ import android.app.Application;
import android.app.usage.UsageStats;
import android.app.usage.UsageStatsManager;
import android.content.Context;
import android.os.Process;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
@@ -16,7 +17,10 @@ import android.util.Log;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Arrays;
@@ -220,7 +224,7 @@ public final class ProcessUtils {
private static String getCurrentProcessNameByFile() {
try {
File file = new File("/proc/" + android.os.Process.myPid() + "/" + "cmdline");
File file = new File("/proc/" + Process.myPid() + "/" + "cmdline");
BufferedReader mBufferedReader = new BufferedReader(new FileReader(file));
String processName = mBufferedReader.readLine().trim();
mBufferedReader.close();
@@ -237,7 +241,7 @@ public final class ProcessUtils {
if (am == null) return "";
List<ActivityManager.RunningAppProcessInfo> info = am.getRunningAppProcesses();
if (info == null || info.size() == 0) return "";
int pid = android.os.Process.myPid();
int pid = Process.myPid();
for (ActivityManager.RunningAppProcessInfo aInfo : info) {
if (aInfo.pid == pid) {
if (aInfo.processName != null) {
@@ -270,4 +274,74 @@ public final class ProcessUtils {
}
return processName;
}
public static boolean isMainProcess( Context context ) {
try {
ActivityManager activityManager = ( ( ActivityManager ) context.getSystemService( Context.ACTIVITY_SERVICE ) );
if ( activityManager == null ) {
return false;
}
List<ActivityManager.RunningAppProcessInfo> raps = activityManager.getRunningAppProcesses();
if ( raps == null || raps.size() <= 0 ) {
return false;
}
int pid = Process.myPid();
String packageName = context.getPackageName();
for ( ActivityManager.RunningAppProcessInfo info : raps ) {
if ( packageName.equals( info.processName ) ) {
return pid == info.pid;
}
}
return false;
} catch ( Exception e ) {
e.printStackTrace();
}
return false;
}
public static String getPackageName() {
String packageName = null;
BufferedReader reader = null;
try {
reader = new BufferedReader( new InputStreamReader( new FileInputStream( "/proc/" + Process.myPid() + "/cmdline" ) ) );
packageName = reader.readLine().trim();
} catch ( Exception e ) {
e.printStackTrace();
packageName = String.valueOf( Process.myPid() );
} finally {
if ( reader != null ) try {
reader.close();
} catch ( IOException e ) {
e.printStackTrace();
}
}
return packageName;
}
/**
* 获取进程号对应的进程名
*
* @param pid 进程号
* @return 进程名
*/
public static String getProcessName( int pid ) {
BufferedReader reader = null;
try {
reader = new BufferedReader( new FileReader( "/proc/" + pid + "/cmdline" ) );
String processName = reader.readLine();
if ( !TextUtils.isEmpty( processName ) ) {
processName = processName.trim();
}
return processName;
} catch ( Throwable t ) {
t.printStackTrace();
} finally {
IOUtils.closeSilently( reader );
}
return null;
}
}

View File

@@ -1,4 +1,4 @@
package com.mogo.utils;
package com.mogo.eagle.core.utilcode.util;
import android.app.Activity;
import android.content.Context;

View File

@@ -1,4 +1,4 @@
package com.mogo.utils;
package com.mogo.eagle.core.utilcode.util;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

View File

@@ -1,4 +1,4 @@
package com.mogo.utils;
package com.mogo.eagle.core.utilcode.util;
import android.os.Handler;
import android.os.Looper;

View File

@@ -1,15 +1,18 @@
package com.mogo.eagle.core.utilcode.util;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Build;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.Locale;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
/**
* <pre>
@@ -116,4 +119,30 @@ public class ViewUtils {
(LayoutInflater) Utils.getApp().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
return inflate.inflate(layoutId, null);
}
public static Bitmap fromView(View view) {
view.setDrawingCacheEnabled(true);
processChildView(view);
view.destroyDrawingCache();
view.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
// Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
// Canvas canvas = new Canvas( bitmap );
// view.draw( canvas );
// return bitmap;
Bitmap bitmap = null;
return (bitmap = view.getDrawingCache()) != null ? bitmap.copy(Bitmap.Config.ARGB_8888, false) : null;
}
public static void processChildView(View view) {
if (!(view instanceof ViewGroup)) {
if (view instanceof TextView) {
((TextView) view).setHorizontallyScrolling(false);
}
} else {
for (int var1 = 0; var1 < ((ViewGroup) view).getChildCount(); ++var1) {
processChildView(((ViewGroup) view).getChildAt(var1));
}
}
}
}

View File

@@ -1,4 +1,4 @@
package com.mogo.utils;
package com.mogo.eagle.core.utilcode.util;
import android.content.Context;

View File

@@ -41,13 +41,13 @@ dependencies {
implementation rootProject.ext.dependencies.mogoaicloudlocation
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
implementation rootProject.ext.dependencies.mogoutils
implementation rootProject.ext.dependencies.mogo_core_utils
implementation rootProject.ext.dependencies.mogoserviceapi
implementation rootProject.ext.dependencies.mogo_core_data
} else {
implementation project(":foudations:mogo-utils")
implementation project(':core:mogo-core-utils')
implementation project(":services:mogo-service-api")
implementation project(':core:mogo-core-data')

View File

@@ -7,7 +7,7 @@ import androidx.annotation.Keep;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.cloud.httpdns.MogoHttpDnsClient;
import com.mogo.cloud.httpdns.listener.OnAddressChangedListener;
import com.mogo.utils.logger.Logger;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
@Keep
@Route(path = HttpDnsConst.PATH)

View File

@@ -6,8 +6,8 @@ import androidx.annotation.Keep;
import com.mogo.cloud.location.LocationManager;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.service.cloud.location.IMogoLocationInfoService;
import com.mogo.utils.logger.Logger;
@Keep
public class MogoLocationInfoServices implements IMogoLocationInfoService {

View File

@@ -9,11 +9,11 @@ import com.mogo.cloud.socket.IMogoCloudSocketOnMessageListener;
import com.mogo.cloud.socket.SocketManager;
import com.mogo.cloud.socket.entity.MsgBody;
import com.mogo.cloud.socket.third.core.ConnectionLifecycleListener;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.service.cloud.socket.IMogoLifecycleListener;
import com.mogo.service.cloud.socket.IMogoMsgAckListener;
import com.mogo.service.cloud.socket.IMogoOnMessageListener;
import com.mogo.service.cloud.socket.IMogoSocketManager;
import com.mogo.utils.logger.Logger;
import com.zhidao.ptech.connsvr.commom.protocol.MogoCommon;
import java.util.ArrayList;

View File

@@ -32,11 +32,11 @@ dependencies {
implementation rootProject.ext.dependencies.mogowebsocket
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
implementation rootProject.ext.dependencies.mogoutils
implementation rootProject.ext.dependencies.mogo_core_utils
implementation rootProject.ext.dependencies.mogocommons
implementation rootProject.ext.dependencies.mogoserviceapi
} else {
implementation project(":foudations:mogo-utils")
implementation project(':core:mogo-core-utils')
implementation project(":foudations:mogo-commons")
implementation project(":services:mogo-service-api")
implementation project(':modules:mogo-module-common')

View File

@@ -6,7 +6,6 @@ import com.mogo.httpdns.IMogoHttpDns;
import com.mogo.httpdns.MogoHttpDnsHandler;
import com.mogo.module.common.constants.HostConst;
import com.mogo.utils.ThreadPoolService;
import com.mogo.utils.logger.Logger;
public class WebSocketDnsManager {

View File

@@ -4,7 +4,6 @@ import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import com.mogo.utils.logger.Logger;
import com.mogo.websocket.SocketClient;
public class WebSocketHandlerThread extends HandlerThread {

View File

@@ -13,7 +13,6 @@ import com.mogo.module.common.MogoApisHandler;
import com.mogo.service.connection.IMogoMsgAckListener;
import com.mogo.service.connection.IMogoOnWebSocketMessageListener;
import com.mogo.service.connection.IMogoWebSocketManager;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.utils.GsonUtil;
import com.mogo.websocket.ISocketMsgCallBack;
import com.mogo.websocket.ISocketMsgSetting;

View File

@@ -46,7 +46,7 @@ dependencies {
implementation rootProject.ext.dependencies.androidxlifecycleprocess
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
implementation rootProject.ext.dependencies.mogoutils
implementation rootProject.ext.dependencies.mogo_core_utils
api rootProject.ext.dependencies.mogoaicloudservicesdk
api rootProject.ext.dependencies.ttsbase
@@ -54,7 +54,7 @@ dependencies {
implementation rootProject.ext.dependencies.mogo_core_utils
api rootProject.ext.dependencies.mogo_core_network
} else {
implementation project(":foudations:mogo-utils")
implementation project(':core:mogo-core-utils')
api project(":foudations:mogo-aicloud-services-sdk")
api project(":tts:tts-base")

View File

@@ -20,13 +20,13 @@ import com.mogo.commons.crash.FinalizeCrashFixer;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.device.Devices;
import com.mogo.commons.network.NetConfigUtils;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.eagle.core.utilcode.mogo.toast.TipDrawable;
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
import com.mogo.eagle.core.utilcode.util.AppUtils;
import com.mogo.eagle.core.utilcode.util.CleanUtils;
import com.mogo.eagle.core.utilcode.util.ThreadPoolService;
import com.mogo.eagle.core.utilcode.util.Utils;
import com.mogo.utils.ThreadPoolService;
import com.mogo.utils.logger.Logger;
/**
* @author congtaowang

View File

@@ -1,9 +1,10 @@
package com.mogo.commons.crash;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleEventObserver;
import androidx.lifecycle.ProcessLifecycleOwner;
import com.mogo.utils.logger.Logger;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

View File

@@ -7,8 +7,8 @@ import android.database.Cursor;
import android.net.Uri;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.utils.ThreadPoolService;
import com.mogo.utils.logger.Logger;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.eagle.core.utilcode.util.ThreadPoolService;
public
/*

View File

@@ -16,8 +16,7 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.utils.SoftKeyBoardJobber;
import com.mogo.eagle.core.utilcode.util.SoftKeyBoardJobber;
/**
* @author congtaowang

View File

@@ -11,10 +11,10 @@ import com.mogo.eagle.core.network.Constants;
import com.mogo.eagle.core.network.LocationHelper;
import com.mogo.eagle.core.network.ServerParam;
import com.mogo.eagle.core.network.utils.GsonUtil;
import com.mogo.utils.CommonUtils;
import com.mogo.utils.DeviceIdUtils;
import com.mogo.utils.WindowUtils;
import com.mogo.utils.logger.Logger;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.eagle.core.utilcode.util.CommonUtils;
import com.mogo.eagle.core.utilcode.util.DeviceIdUtils;
import com.mogo.eagle.core.utilcode.util.WindowUtils;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

View File

@@ -11,7 +11,7 @@ import android.telephony.gsm.GsmCellLocation;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.utils.DeviceIdUtils;
import com.mogo.eagle.core.utilcode.util.DeviceIdUtils;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

View File

@@ -1,7 +1,7 @@
package com.mogo.commons.storage;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.utils.storage.SharedPrefsMgr;
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
/**
* @author congtaowang

View File

@@ -3,11 +3,11 @@ package com.mogo.commons.voice;
import android.content.Context;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.eagle.core.utilcode.util.ToastUtils;
import com.mogo.tts.base.IMogoTTS;
import com.mogo.tts.base.MogoTTSConstants;
import com.mogo.tts.base.PreemptType;
import com.mogo.utils.logger.Logger;
/**
* @author congtaowang

View File

@@ -1,84 +0,0 @@
package com.mogo.utils;
import android.app.Activity;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Iterator;
public class ActivityStack {
private static final Deque< Activity > ACTIVITY_STACK = new ArrayDeque<>();
public static synchronized void addActivity( Activity activity) {
if(activity != null){
ACTIVITY_STACK.offer(activity);
}
}
public static synchronized Activity currentActivity() {
return ACTIVITY_STACK.peekLast();
}
public static synchronized void finishCurrentActivity() {
Activity activity = ACTIVITY_STACK.pop();
if (!activity.isFinishing()) {
activity.finish();
}
}
public static synchronized void finishActivity( Activity activity) {
ACTIVITY_STACK.remove(activity);
if (!activity.isFinishing()) {
activity.finish();
}
}
public static synchronized void finishActivity( Class<? extends Activity > cls) {
Iterator< Activity > iterator = ACTIVITY_STACK.iterator();
while (iterator.hasNext()) {
Activity next = iterator.next();
if(next.getClass().equals(cls)){
iterator.remove();
if(!next.isFinishing()){
next.finish();
}
}
}
}
public static synchronized void finishActivityExcept( Class<?> cls) {
Iterator< Activity > iterator = ACTIVITY_STACK.iterator();
while (iterator.hasNext()) {
Activity next = iterator.next();
if (!next.getClass().equals(cls)) {
iterator.remove();
if(!next.isFinishing()){
next.finish();
}
}
}
}
public static synchronized void finishAllActivity() {
Iterator< Activity > iterator = ACTIVITY_STACK.iterator();
while (iterator.hasNext()) {
iterator.remove();
Activity next = iterator.next();
if(!next.isFinishing()){
next.finish();
}
}
}
public static synchronized boolean isActivityExist( Class<? extends Activity > cls){
Iterator< Activity > iterator = ACTIVITY_STACK.iterator();
while (iterator.hasNext()) {
Activity next = iterator.next();
if(next.getClass().equals(cls)){
return true;
}
}
return false;
}
}

View File

@@ -1,149 +0,0 @@
package com.mogo.utils;
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import java.util.List;
/**
* @author congtaowang
* @since 2020-04-09
* <p>
* 描述
*/
public class AppUtils {
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 ) {
PackageInfo packageInfo;
if ( TextUtils.isEmpty( pkg ) ) {
return false;
}
try {
packageInfo = context.getPackageManager().getPackageInfo( pkg, 0 );
} catch ( PackageManager.NameNotFoundException e ) {
packageInfo = null;
e.printStackTrace();
}
if ( packageInfo == null ) {
return false;
} else {
return true;
}
}
private static final String MOGO_MAP_SDK_VERSION = "MAP_SDK_VERSION";
public static String getCustomMapSDKVersion(Context context){
return getApplicationMetaValue(context,MOGO_MAP_SDK_VERSION);
}
private static String getApplicationMetaValue(Context context,String metaName){
try {
ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(),PackageManager.GET_META_DATA);
Bundle bundle = applicationInfo.metaData;
if (bundle != null){
return bundle.getString(metaName);
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return "";
}
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 ) {
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 ) {
return true;
}
}
}
}
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 ) {
return true;
}
}
}
}
return false;
}
//获取已安装应用的 uid-1 表示未安装此应用或程序异常
public static int getPackageUid( Context context, String packageName ) {
try {
ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo( packageName, 0 );
if ( applicationInfo != null ) {
return applicationInfo.uid;
}
} catch ( Exception e ) {
return -1;
}
return -1;
}
/**
* 判断某一 uid 的程序是否有正在运行的进程,即是否存活
* Created by cafeting on 2017/2/4.
*
* @param context 上下文
* @param uid 已安装应用的 uid
* @return true 表示正在运行false 表示没有运行
*/
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 ) {
return true;
}
}
}
return false;
}
}

View File

@@ -1,464 +0,0 @@
package com.mogo.utils;
import java.io.Serializable;
import java.lang.reflect.Array;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.RandomAccess;
@SuppressWarnings({ "unchecked" })
public class ArrayUtils {
/**
* 加强版的asList会检查传入是否为null以保证不会抛出异常 并且返回的arraylist改为{@link ArrayList}
*
* @param <T>
* @param array
* @return
*/
public static <T> ArrayList<T> asList( T... array) {
if (array == null) {
return new ArrayList<T>(0);
}
ArrayList<T> list = new ArrayList<T>( Arrays.asList(array));
return list;
}
public static <T> List<T> asReadOnlyList( T... array) {
return new ReadOnlyArrayList<T>(array);
}
public static boolean contains( Object[] array, Object value) {
if (array == null) {
return false;
}
for ( Object object : array) {
if (object == null) {
if (value == null) {
return true;
}
} else if (object.equals(value)) {
return true;
}
}
return false;
}
/**
* 在已排序数组中查询是否存在某值
*
* @param array
* @param value
* @return
*/
public static boolean contains(int[] array, int value) {
return Arrays.binarySearch(array, value) >= 0 ? true : false;
}
/**
* 从jdk1.6拷贝过来android中没有这些方法。<br />
* Copies the specified array, truncating or padding with <tt>false</tt> (if necessary) so the copy has the
* specified length. For all indices that are valid in both the original array and the copy, the two arrays will
* contain identical values. For any indices that are valid in the copy but not the original, the copy will contain
* <tt>false</tt>. Such indices will exist if and only if the specified length is greater than that of the original
* array.
*
* @param original the array to be copied
* @param newLength the length of the copy to be returned
* @return a copy of the original array, truncated or padded with false elements to obtain the specified length
* @throws NegativeArraySizeException if <tt>newLength</tt> is negative
* @throws NullPointerException if <tt>original</tt> is null
*/
public static boolean[] copyOf(boolean[] original, int newLength) {
boolean[] copy = new boolean[newLength];
System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
return copy;
}
/**
* 从jdk1.6拷贝过来android中没有这些方法。<br />
* Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.
* For all indices that are valid in both the original array and the copy, the two arrays will contain identical
* values. For any indices that are valid in the copy but not the original, the copy will contain <tt>(byte)0</tt>.
* Such indices will exist if and only if the specified length is greater than that of the original array.
*
* @param original the array to be copied
* @param newLength the length of the copy to be returned
* @return a copy of the original array, truncated or padded with zeros to obtain the specified length
* @throws NegativeArraySizeException if <tt>newLength</tt> is negative
* @throws NullPointerException if <tt>original</tt> is null
*/
public static byte[] copyOf(byte[] original, int newLength) {
byte[] copy = new byte[newLength];
System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
return copy;
}
/**
* 从jdk1.6拷贝过来android中没有这些方法。<br />
* Copies the specified array, truncating or padding with null characters (if necessary) so the copy has the
* specified length. For all indices that are valid in both the original array and the copy, the two arrays will
* contain identical values. For any indices that are valid in the copy but not the original, the copy will contain
* <tt>'\\u000'</tt>. Such indices will exist if and only if the specified length is greater than that of the
* original array.
*
* @param original the array to be copied
* @param newLength the length of the copy to be returned
* @return a copy of the original array, truncated or padded with null characters to obtain the specified length
* @throws NegativeArraySizeException if <tt>newLength</tt> is negative
* @throws NullPointerException if <tt>original</tt> is null
*/
public static char[] copyOf(char[] original, int newLength) {
char[] copy = new char[newLength];
System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
return copy;
}
/**
* 从jdk1.6拷贝过来android中没有这些方法。<br />
* Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.
* For all indices that are valid in both the original array and the copy, the two arrays will contain identical
* values. For any indices that are valid in the copy but not the original, the copy will contain <tt>0d</tt>. Such
* indices will exist if and only if the specified length is greater than that of the original array.
*
* @param original the array to be copied
* @param newLength the length of the copy to be returned
* @return a copy of the original array, truncated or padded with zeros to obtain the specified length
* @throws NegativeArraySizeException if <tt>newLength</tt> is negative
* @throws NullPointerException if <tt>original</tt> is null
*/
public static double[] copyOf(double[] original, int newLength) {
double[] copy = new double[newLength];
System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
return copy;
}
/**
* 从jdk1.6拷贝过来android中没有这些方法。<br />
* Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.
* For all indices that are valid in both the original array and the copy, the two arrays will contain identical
* values. For any indices that are valid in the copy but not the original, the copy will contain <tt>0f</tt>. Such
* indices will exist if and only if the specified length is greater than that of the original array.
*
* @param original the array to be copied
* @param newLength the length of the copy to be returned
* @return a copy of the original array, truncated or padded with zeros to obtain the specified length
* @throws NegativeArraySizeException if <tt>newLength</tt> is negative
* @throws NullPointerException if <tt>original</tt> is null
*/
public static float[] copyOf(float[] original, int newLength) {
float[] copy = new float[newLength];
System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
return copy;
}
/**
* 从jdk1.6拷贝过来android中没有这些方法。<br />
* Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.
* For all indices that are valid in both the original array and the copy, the two arrays will contain identical
* values. For any indices that are valid in the copy but not the original, the copy will contain <tt>0</tt>. Such
* indices will exist if and only if the specified length is greater than that of the original array.
*
* @param original the array to be copied
* @param newLength the length of the copy to be returned
* @return a copy of the original array, truncated or padded with zeros to obtain the specified length
* @throws NegativeArraySizeException if <tt>newLength</tt> is negative
* @throws NullPointerException if <tt>original</tt> is null
*/
public static int[] copyOf(int[] original, int newLength) {
int[] copy = new int[newLength];
System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
return copy;
}
/**
* 从jdk1.6拷贝过来android中没有这些方法。<br />
* Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.
* For all indices that are valid in both the original array and the copy, the two arrays will contain identical
* values. For any indices that are valid in the copy but not the original, the copy will contain <tt>0L</tt>. Such
* indices will exist if and only if the specified length is greater than that of the original array.
*
* @param original the array to be copied
* @param newLength the length of the copy to be returned
* @return a copy of the original array, truncated or padded with zeros to obtain the specified length
* @throws NegativeArraySizeException if <tt>newLength</tt> is negative
* @throws NullPointerException if <tt>original</tt> is null
*/
public static long[] copyOf(long[] original, int newLength) {
long[] copy = new long[newLength];
System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
return copy;
}
/**
* 从jdk1.6拷贝过来android中没有这些方法。<br />
* Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.
* For all indices that are valid in both the original array and the copy, the two arrays will contain identical
* values. For any indices that are valid in the copy but not the original, the copy will contain <tt>(short)0</tt>.
* Such indices will exist if and only if the specified length is greater than that of the original array.
*
* @param original the array to be copied
* @param newLength the length of the copy to be returned
* @return a copy of the original array, truncated or padded with zeros to obtain the specified length
* @throws NegativeArraySizeException if <tt>newLength</tt> is negative
* @throws NullPointerException if <tt>original</tt> is null
*/
public static short[] copyOf(short[] original, int newLength) {
short[] copy = new short[newLength];
System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
return copy;
}
/**
* 从jdk1.6拷贝过来android中没有这些方法。<br />
* Copies the specified array, truncating or padding with nulls (if necessary) so the copy has the specified length.
* For all indices that are valid in both the original array and the copy, the two arrays will contain identical
* values. For any indices that are valid in the copy but not the original, the copy will contain <tt>null</tt>.
* Such indices will exist if and only if the specified length is greater than that of the original array. The
* resulting array is of exactly the same class as the original array.
*
* @param original the array to be copied
* @param newLength the length of the copy to be returned
* @return a copy of the original array, truncated or padded with nulls to obtain the specified length
* @throws NegativeArraySizeException if <tt>newLength</tt> is negative
* @throws NullPointerException if <tt>original</tt> is null
*/
public static <T> T[] copyOf(T[] original, int newLength) {
return (T[]) copyOf(original, newLength, original.getClass());
}
/**
* 从jdk1.6拷贝过来android中没有这些方法。<br />
* Copies the specified array, truncating or padding with nulls (if necessary) so the copy has the specified length.
* For all indices that are valid in both the original array and the copy, the two arrays will contain identical
* values. For any indices that are valid in the copy but not the original, the copy will contain <tt>null</tt>.
* Such indices will exist if and only if the specified length is greater than that of the original array. The
* resulting array is of the class <tt>newType</tt>.
*
* @param original the array to be copied
* @param newLength the length of the copy to be returned
* @param newType the class of the copy to be returned
* @return a copy of the original array, truncated or padded with nulls to obtain the specified length
* @throws NegativeArraySizeException if <tt>newLength</tt> is negative
* @throws NullPointerException if <tt>original</tt> is null
* @throws ArrayStoreException if an element copied from <tt>original</tt> is not of a runtime type that can be
* stored in an array of class <tt>newType</tt>
*/
public static <T, U> T[] copyOf(U[] original, int newLength, Class<? extends T[]> newType) {
T[] copy = ( Object ) newType == ( Object ) Object[].class ? (T[]) new Object[newLength] : (T[]) Array.newInstance(
newType.getComponentType(), newLength);
System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
return copy;
}
/**
* 在数组中查询某值所在位置
*
* @param array
* @param value
* @return
*/
public static int indexOf(int[] array, int value) {
for (int i = 0; i < array.length; i++) {
if (array[i] == value) {
return i;
}
}
throw new ArrayIndexOutOfBoundsException(value + "is not in " + Arrays.toString(array));
}
/**
* 在数组中查询某值所在位置
*
* @param <T>
* @param array
* @param value
* @return
*/
public static <T> int indexOf(T[] array, T value) {
for (int i = 0; i < array.length; i++) {
if (array[i].equals(value)) {
return i;
}
}
throw new ArrayIndexOutOfBoundsException(value.toString() + "is not in " + Arrays.toString(array));
}
private static class ReadOnlyArrayList<E> extends AbstractList<E> implements List<E>, Serializable, RandomAccess {
private static final long serialVersionUID = 1L;
private final E[] a;
ReadOnlyArrayList(E[] storage) {
a = storage;
}
@Override
public boolean contains( Object object) {
if (a == null) {
return false;
}
if (object != null) {
for (E element : a) {
if (object.equals(element)) {
return true;
}
}
} else {
for (E element : a) {
if (element == null) {
return true;
}
}
}
return false;
}
@Override
public E get(int location) {
try {
return a[location];
} catch ( ArrayIndexOutOfBoundsException e) {
throw new IndexOutOfBoundsException();
} catch ( NullPointerException e) {
throw new IndexOutOfBoundsException();
}
}
@Override
public int indexOf( Object object) {
if (a == null) {
return -1;
}
if (object != null) {
for (int i = 0; i < a.length; i++) {
if (object.equals(a[i])) {
return i;
}
}
} else {
for (int i = 0; i < a.length; i++) {
if (a[i] == null) {
return i;
}
}
}
return -1;
}
@Override
public int lastIndexOf( Object object) {
if (a == null) {
return -1;
}
if (object != null) {
for (int i = a.length - 1; i >= 0; i--) {
if (object.equals(a[i])) {
return i;
}
}
} else {
for (int i = a.length - 1; i >= 0; i--) {
if (a[i] == null) {
return i;
}
}
}
return -1;
}
@Override
public E set(int location, E object) {
if (a == null) {
throw new IndexOutOfBoundsException();
}
try {
E result = a[location];
a[location] = object;
return result;
} catch ( ArrayIndexOutOfBoundsException e) {
throw new IndexOutOfBoundsException();
} catch ( ArrayStoreException e) {
throw new ClassCastException();
}
}
@Override
public int size() {
return a == null ? 0 : a.length;
}
@Override
public Object[] toArray() {
if (a == null) {
return new Object[0];
}
return a.clone();
}
@Override
public <T> T[] toArray(T[] contents) {
if (a == null) {
return contents;
}
int size = size();
if (size > contents.length) {
Class<?> ct = contents.getClass().getComponentType();
contents = (T[]) Array.newInstance(ct, size);
}
System.arraycopy(a, 0, contents, 0, size);
if (size < contents.length) {
contents[size] = null;
}
return contents;
}
}
/**
* @param array
* @return
*/
public static <T> boolean isEmpty( Collection<T> array) {
if (array == null || array.size() == 0) {
return true;
}
return false;
}
/**
* @param array
* @return
*/
public static <T> boolean isEmpty(T[] array) {
if (array == null || array.length == 0) {
return true;
}
return false;
}
/**
* 合并2个array
*
* @param head
* @param tail
* @return
*/
public static <T> T[] join(T[] head, T[] tail) {
if (head == null) {
return tail;
}
if (tail == null) {
return head;
}
Class<?> type = head.getClass().getComponentType();
T[] result = (T[]) Array.newInstance(type, head.length + tail.length);
System.arraycopy(head, 0, result, 0, head.length);
System.arraycopy(tail, 0, result, head.length, tail.length);
return result;
}
}

Some files were not shown because too many files have changed in this diff Show More