Commit e733e5a0 by 王涛55

格式化代码

parent b35592d0
if (build_module == build_module_app) {
apply plugin: 'com.android.application'
} else {
......@@ -59,8 +58,8 @@ android {
renderscriptDebuggable false
signingConfig signingConfigs.sign
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField("boolean","SHOW_LOG","false")
buildConfigField("boolean","SERVER_ADDRESS_ENABLE","false")
buildConfigField("boolean", "SHOW_LOG", "false")
buildConfigField("boolean", "SERVER_ADDRESS_ENABLE", "false")
}
debug {
minifyEnabled false
......@@ -72,8 +71,8 @@ android {
renderscriptDebuggable true
signingConfig signingConfigs.sign
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField("boolean","SHOW_LOG","true")
buildConfigField("boolean","SERVER_ADDRESS_ENABLE","true")
buildConfigField("boolean", "SHOW_LOG", "true")
buildConfigField("boolean", "SERVER_ADDRESS_ENABLE", "true")
}
}
......
......@@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.module.hikcreate">
<application
android:roundIcon="@mipmap/ic_launcher"
android:allowBackup="false"
......
......@@ -3,10 +3,10 @@ package com.hikcreate.app;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;
import com.hikcreate.base.BaseActivityLifeLogic;
/**
*
* @author wangtao55
* @date 2019/9/23
* @mail wangtao55@hikcreate.com
......@@ -14,7 +14,7 @@ import com.hikcreate.base.BaseActivityLifeLogic;
public class AppActivityLifeCycle extends BaseActivityLifeLogic {
@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
Toast.makeText(activity,"AppActivityLifeCycle",Toast.LENGTH_LONG).show();
Toast.makeText(activity, "AppActivityLifeCycle", Toast.LENGTH_LONG).show();
}
@Override
......
......@@ -7,7 +7,6 @@ import android.util.Log;
import com.hikcreate.base.BaseAppLogic;
/**
*
* @author wangtao55
* @date 2019/9/23
* @mail wangtao55@hikcreate.com
......@@ -15,21 +14,21 @@ import com.hikcreate.base.BaseAppLogic;
public class AppAppLogic extends BaseAppLogic {
@Override
public void onCreate(Context context) {
Log.v("AppAppLogic","onCreate--------------------->");
Log.v("AppAppLogic", "onCreate--------------------->");
}
@Override
public void onTerminate(Context context) {
Log.v("AppAppLogic","onTerminate--------------------->");
Log.v("AppAppLogic", "onTerminate--------------------->");
}
@Override
public void onLowMemory(Context context) {
Log.v("AppAppLogic","onLowMemory--------------------->");
Log.v("AppAppLogic", "onLowMemory--------------------->");
}
@Override
public void onConfigurationChanged(Context context,Configuration newConfig) {
Log.v("AppAppLogic","onConfigurationChanged--------------------->");
public void onConfigurationChanged(Context context, Configuration newConfig) {
Log.v("AppAppLogic", "onConfigurationChanged--------------------->");
}
}
......@@ -7,7 +7,6 @@ import com.hikcreate.data.config.ActivityLifeCycleInitConfig;
import com.hikcreate.data.config.AppInitConfig;
/**
*
* @author wangtao55
* @date 2019/9/23
* @mail wangtao55@hikcreate.com
......@@ -22,14 +21,14 @@ public class CommonApplication extends Application {
AppContext.getInstance().logicOnCreate(this);
}
private void registerAppInit(){
private void registerAppInit() {
//登录组件
AppContext.getInstance().registerAppLogic(AppInitConfig.LOGIN_CONFIG);
//app壳组件
AppContext.getInstance().registerAppLogic(AppInitConfig.APP_CONFIG);
}
private void registerActivityLife(){
private void registerActivityLife() {
//登录组件的acitivity生命周期监控
AppContext.getInstance().registerActivityLifeLogic(ActivityLifeCycleInitConfig.LOGIN_CONFIG);
//app壳组件的acitivity生命周期监控
......
......@@ -8,6 +8,7 @@ import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;
import com.hikcreate.data.config.AppProvider;
import com.hikcreate.library.util.LogCat;
import com.hikcreate.module_router.router.RouterResponse;
import com.hikcreate.module_router.tools.ModuleRouterUtil;
import com.message.bean.GeneralMessageBean;
......@@ -36,44 +37,34 @@ public class testActivity extends AppCompatActivity {
setContentView(R.layout.app_test);
findViewById(R.id.mBtnLogin).setOnClickListener(v -> {
RouterResponse response = ModuleRouterUtil.getRouterResponse(getApplicationContext(),
AppProvider.LOGIN_PROVIDER,AppProvider.GET_USER_INFO_ACTION);
if(response != null){
if(response.getObject() != null){
AppProvider.LOGIN_PROVIDER, AppProvider.GET_USER_INFO_ACTION);
if (response != null) {
if (response.getObject() != null) {
HashMap value = (HashMap) response.getObject();
Toast.makeText(getApplicationContext(), (String) value.get("mobile"),Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(),(String)value.get("name"),Toast.LENGTH_LONG).show();
LogCat.d("userInfo", (String) value.get("mobile"));
LogCat.d("userInfo", (String) value.get("name"));
}
Toast.makeText(getApplicationContext(),response.getData(),Toast.LENGTH_LONG).show();
LogCat.d("userInfo", response.getData());
}
});
findViewById(R.id.mBtnPassport).setOnClickListener(v -> {
findViewById(R.id.mBtnLoginSync).setOnClickListener(v -> {
new Thread(() -> {
try {
HashMap<String,String> value = new HashMap<>();
value.put("name","wangtao");
value.put("mobile","150000000000");
RouterResponse response = ModuleRouterUtil.getRouterResponse(getApplicationContext(),
AppProvider.LOGIN_PROVIDER,AppProvider.GET_USER_INFO_ACTION);
AppProvider.USER_INFO_CHANGE_PROVIDER, AppProvider.USER_INFO_CHANGE_ACTION,value);
final String result = response.get();
new Handler().post(() -> {
try {
Toast.makeText(testActivity.this, result, Toast.LENGTH_SHORT).show();
} catch (Exception e) {
e.printStackTrace();
}
});
} catch (Exception e) {
e.printStackTrace();
}
runOnUiThread(() -> Toast.makeText(testActivity.this, result, Toast.LENGTH_SHORT).show());
}).start();
});
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.add(R.id.test_passport,new TestFragment());
transaction.add(R.id.test_passport, new TestFragment());
transaction.commit();
}
}
......@@ -7,28 +7,29 @@
android:layout_height="match_parent">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="获取用户信息"
android:id="@+id/mBtnLogin"
/>
android:id="@+id/mBtnLogin" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="获取用户信息-异步"
android:id="@+id/mBtnLoginSync" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="发送Message信息"
android:layout_marginTop="10dp"
android:id="@+id/mBtnPassport"
/>
android:id="@+id/mBtnPassport" />
<FrameLayout
android:layout_width="match_parent"
android:id="@+id/test_passport"
android:layout_height="600dp"/>
android:layout_height="600dp" />
</LinearLayout>
......@@ -5,7 +5,6 @@ import android.content.res.Configuration;
import android.util.Log;
/**
*
* @author wangtao55
* @date 2019/9/23
* @mail wangtao55@hikcreate.com
......@@ -13,21 +12,21 @@ import android.util.Log;
public class AppAppLogic extends BaseAppLogic {
@Override
public void onCreate(Context context) {
Log.v("AppAppLogic","onCreate--------------------->");
Log.v("AppAppLogic", "onCreate--------------------->");
}
@Override
public void onTerminate(Context context) {
Log.v("AppAppLogic","onTerminate--------------------->");
Log.v("AppAppLogic", "onTerminate--------------------->");
}
@Override
public void onLowMemory(Context context) {
Log.v("AppAppLogic","onLowMemory--------------------->");
Log.v("AppAppLogic", "onLowMemory--------------------->");
}
@Override
public void onConfigurationChanged(Context context,Configuration newConfig) {
Log.v("AppAppLogic","onConfigurationChanged--------------------->");
public void onConfigurationChanged(Context context, Configuration newConfig) {
Log.v("AppAppLogic", "onConfigurationChanged--------------------->");
}
}
......@@ -28,6 +28,7 @@ public class AppContext {
private List<BaseActivityLifeLogic> logicActivityLifeClassList = new ArrayList<>();
private static AppContext mAppContext;
private AppContext() {
}
......@@ -38,63 +39,63 @@ public class AppContext {
return mAppContext;
}
public void registerAppLogic(String logicClass){
public void registerAppLogic(String logicClass) {
logicList.add(logicClass);
}
public void registerActivityLifeLogic(String logicClass){
public void registerActivityLifeLogic(String logicClass) {
logicActivityLifeList.add(logicClass);
}
public void logicOnCreate(Application application){
public void logicOnCreate(Application application) {
for(String logicClass : logicList){
for (String logicClass : logicList) {
try {
Class appClass = Class.forName(logicClass);
BaseAppLogic appLogic = (BaseAppLogic) appClass.newInstance();
logicClassList.add(appLogic);
appLogic.onCreate(application);
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
}
for(String logicActivityClass : logicActivityLifeList){
for (String logicActivityClass : logicActivityLifeList) {
try {
Class appClass = Class.forName(logicActivityClass);
BaseActivityLifeLogic appLogic = (BaseActivityLifeLogic) appClass.newInstance();
logicActivityLifeClassList.add(appLogic);
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
}
init(application);
}
public void logicOnTerminate(Application application){
for(BaseAppLogic logicClass : logicClassList){
public void logicOnTerminate(Application application) {
for (BaseAppLogic logicClass : logicClassList) {
try {
logicClass.onTerminate(application);
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
}
}
public void logicOnLowMemory(Application application){
for(BaseAppLogic logicClass : logicClassList){
public void logicOnLowMemory(Application application) {
for (BaseAppLogic logicClass : logicClassList) {
try {
logicClass.onLowMemory(application);
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
}
}
public void logicOnConfigurationChanged(Application application,Configuration newConfig){
for(BaseAppLogic logicClass : logicClassList){
public void logicOnConfigurationChanged(Application application, Configuration newConfig) {
for (BaseAppLogic logicClass : logicClassList) {
try {
logicClass.onConfigurationChanged(application,newConfig);
}catch (Exception e){
logicClass.onConfigurationChanged(application, newConfig);
} catch (Exception e) {
e.printStackTrace();
}
}
......@@ -106,14 +107,14 @@ public class AppContext {
MultiDex.install(application);
}
public void initActivityLifeCycle(Application application){
public void initActivityLifeCycle(Application application) {
application.registerActivityLifecycleCallbacks(new Application.ActivityLifecycleCallbacks() {
@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
for(BaseActivityLifeLogic logicClass : logicActivityLifeClassList){
for (BaseActivityLifeLogic logicClass : logicActivityLifeClassList) {
try {
logicClass.onActivityCreated(activity,savedInstanceState);
}catch (Exception e){
logicClass.onActivityCreated(activity, savedInstanceState);
} catch (Exception e) {
e.printStackTrace();
}
}
......@@ -121,10 +122,10 @@ public class AppContext {
@Override
public void onActivityStarted(Activity activity) {
for(BaseActivityLifeLogic logicClass : logicActivityLifeClassList){
for (BaseActivityLifeLogic logicClass : logicActivityLifeClassList) {
try {
logicClass.onActivityStarted(activity);
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
}
......@@ -132,10 +133,10 @@ public class AppContext {
@Override
public void onActivityResumed(Activity activity) {
for(BaseActivityLifeLogic logicClass : logicActivityLifeClassList){
for (BaseActivityLifeLogic logicClass : logicActivityLifeClassList) {
try {
logicClass.onActivityResumed(activity);
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
}
......@@ -143,10 +144,10 @@ public class AppContext {
@Override
public void onActivityPaused(Activity activity) {
for(BaseActivityLifeLogic logicClass : logicActivityLifeClassList){
for (BaseActivityLifeLogic logicClass : logicActivityLifeClassList) {
try {
logicClass.onActivityPaused(activity);
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
}
......@@ -154,10 +155,10 @@ public class AppContext {
@Override
public void onActivityStopped(Activity activity) {
for(BaseActivityLifeLogic logicClass : logicActivityLifeClassList){
for (BaseActivityLifeLogic logicClass : logicActivityLifeClassList) {
try {
logicClass.onActivityStopped(activity);
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
}
......@@ -165,10 +166,10 @@ public class AppContext {
@Override
public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
for(BaseActivityLifeLogic logicClass : logicActivityLifeClassList){
for (BaseActivityLifeLogic logicClass : logicActivityLifeClassList) {
try {
logicClass.onActivitySaveInstanceState(activity,outState);
}catch (Exception e){
logicClass.onActivitySaveInstanceState(activity, outState);
} catch (Exception e) {
e.printStackTrace();
}
}
......@@ -176,10 +177,10 @@ public class AppContext {
@Override
public void onActivityDestroyed(Activity activity) {
for(BaseActivityLifeLogic logicClass : logicActivityLifeClassList){
for (BaseActivityLifeLogic logicClass : logicActivityLifeClassList) {
try {
logicClass.onActivityDestroyed(activity);
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
}
......
......@@ -11,10 +11,10 @@ public class AppProvider {
//登录模块 Provider
public static final String LOGIN_PROVIDER = "login_provider";
public static final String PWD_PROVIDER = "pwd_provider";
public static final String USER_INFO_CHANGE_PROVIDER = "change_user_info_provider";
//登录模块Aciton
public static final String GET_USER_INFO_ACTION = "user_action";
public static final String PWD_ACTION = "pwd_action";
public static final String USER_INFO_CHANGE_ACTION = "change_user_info_action";
}
......@@ -6,7 +6,7 @@ if (build_module == build_module_login) {
android {
defaultConfig {
if (build_module == build_module_login) {
applicationId build_modele_app_id +"."+ project.getName()
applicationId build_modele_app_id + "." + project.getName()
}
minSdkVersion build_config.min_sdk
targetSdkVersion build_config.target_sdk
......
......@@ -2,6 +2,7 @@ package com.hikcreate.login.moduel.router.action.change;
import android.content.Context;
import com.hikcreate.library.util.LogCat;
import com.hikcreate.module_router.ModuleAction;
import com.hikcreate.module_router.ModuleActionResult;
......@@ -14,14 +15,26 @@ import java.util.HashMap;
* @date 2019/9/24
* @mail wangtao55@hikcreate.com
*/
public class ChangePwd extends ModuleAction {
public class ChangeUserInfo extends ModuleAction {
@Override
public boolean isAsync(HashMap<String, String> requestData) {
return false;
return true;
}
@Override
public ModuleActionResult invoke(Context context, HashMap<String, String> requestData) {
return null;
LogCat.d("userInfo", "new-->" + requestData.get("name"));
LogCat.d("userInfo", "new-->" + requestData.get("mobile"));
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("name", "newTest");
hashMap.put("mobile", "18888888888");
return new ModuleActionResult.Builder()
.code(ModuleActionResult.CODE_SUCCESS)
.msg("修改密码成功")
.data("18888888888-newTest")
.object(hashMap)
.build();
}
}
......@@ -23,9 +23,9 @@ public class GetUserInfoAction extends ModuleAction {
@Override
public ModuleActionResult invoke(Context context, HashMap<String, String> requestData) {
HashMap<String,String> hashMap = new HashMap<>();
hashMap.put("name","test");
hashMap.put("mobile","15828028350");
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("name", "test");
hashMap.put("mobile", "15828028350");
return new ModuleActionResult.Builder()
.code(ModuleActionResult.CODE_SUCCESS)
.msg("登录成功")
......
package com.hikcreate.login.moduel.router.provider;
import com.hikcreate.login.moduel.router.action.change.ChangePwd;
import com.hikcreate.login.moduel.router.action.change.ChangeUserInfo;
import com.hikcreate.module_router.ModuleProvider;
import static com.hikcreate.data.config.AppProvider.PWD_ACTION;
import static com.hikcreate.data.config.AppProvider.USER_INFO_CHANGE_ACTION;
/**
* 登录Provider
......@@ -15,6 +14,6 @@ import static com.hikcreate.data.config.AppProvider.PWD_ACTION;
public class ChangePwdProvider extends ModuleProvider {
@Override
protected void registerActions() {
registerAction(PWD_ACTION,new ChangePwd());
registerAction(USER_INFO_CHANGE_ACTION, new ChangeUserInfo());
}
}
......@@ -2,6 +2,7 @@ package com.hikcreate.login.moduel.router.provider;
import com.hikcreate.login.moduel.router.action.login.GetUserInfoAction;
import com.hikcreate.module_router.ModuleProvider;
import static com.hikcreate.data.config.AppProvider.GET_USER_INFO_ACTION;
......@@ -15,7 +16,7 @@ import static com.hikcreate.data.config.AppProvider.GET_USER_INFO_ACTION;
public class LoginProvider extends ModuleProvider {
@Override
protected void registerActions() {
registerAction(GET_USER_INFO_ACTION,new GetUserInfoAction());
registerAction(GET_USER_INFO_ACTION, new GetUserInfoAction());
}
}
......@@ -30,7 +30,6 @@ public class testLoginActivity extends AppCompatActivity {
public void onClick(View v) {
}
});
}
......
......@@ -7,7 +7,6 @@ import com.hikcreate.data.config.ActivityLifeCycleInitConfig;
import com.hikcreate.data.config.AppInitConfig;
/**
*
* @author wangtao55
* @date 2019/9/23
* @mail wangtao55@hikcreate.com
......
......@@ -7,7 +7,6 @@ import android.widget.Toast;
import com.hikcreate.base.BaseActivityLifeLogic;
/**
*
* @author wangtao55
* @date 2019/9/23
* @mail wangtao55@hikcreate.com
......@@ -15,7 +14,7 @@ import com.hikcreate.base.BaseActivityLifeLogic;
public class LoginActivityLifeCycle extends BaseActivityLifeLogic {
@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
Toast.makeText(activity,"我来到了登录页面",Toast.LENGTH_LONG).show();
Toast.makeText(activity, "我来到了登录页面", Toast.LENGTH_LONG).show();
}
@Override
......
......@@ -22,30 +22,33 @@ import com.hikcreate.module_router.LocalRouter;
public class LoginAppLogic extends BaseAppLogic {
@Override
public void onCreate(Context application) {
Log.v("LoginAppLogic","onCreate--------------------->");
Log.v("LoginAppLogic", "onCreate--------------------->");
initProviderCreate();
}
@Override
public void onTerminate(Context applicatio) {
Log.v("LoginAppLogic","onTerminate--------------------->");
Log.v("LoginAppLogic", "onTerminate--------------------->");
}
@Override
public void onLowMemory(Context applicatio) {
Log.v("LoginAppLogic","onLowMemory--------------------->");
Log.v("LoginAppLogic", "onLowMemory--------------------->");
}
@Override
public void onConfigurationChanged(Context applicatio,Configuration newConfig) {
Log.v("LoginAppLogic","onConfigurationChanged--------------------->");
public void onConfigurationChanged(Context applicatio, Configuration newConfig) {
Log.v("LoginAppLogic", "onConfigurationChanged--------------------->");
}
private void initProviderCreate(){
private void initProviderCreate() {
LocalRouter.getInstance(AppContext.
getInstance().getApplication()).
registerProvider(AppProvider.LOGIN_PROVIDER,
new LoginProvider());
LocalRouter.getInstance(AppContext.
getInstance().getApplication()).
registerProvider(AppProvider.USER_INFO_CHANGE_PROVIDER,
new ChangePwdProvider());
}
}
......@@ -10,7 +10,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="我是登录"
android:id="@+id/mBtnLogin"
/>
android:id="@+id/mBtnLogin" />
</LinearLayout>
......@@ -7,7 +7,7 @@ if (build_module == build_module_passport) {
android {
defaultConfig {
if (build_module == build_module_passport) {
applicationId build_modele_app_id +"."+ project.getName()
applicationId build_modele_app_id + "." + project.getName()
}
minSdkVersion build_config.min_sdk
targetSdkVersion build_config.target_sdk
......
......@@ -7,7 +7,6 @@ import android.widget.Toast;
import com.hikcreate.base.BaseActivityLifeLogic;
/**
*
* @author wangtao55
* @date 2019/9/23
* @mail wangtao55@hikcreate.com
......@@ -15,7 +14,7 @@ import com.hikcreate.base.BaseActivityLifeLogic;
public class PassPortActivityLifeCycle extends BaseActivityLifeLogic {
@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
Toast.makeText(activity,"我来到了登录页面",Toast.LENGTH_LONG).show();
Toast.makeText(activity, "我来到了登录页面", Toast.LENGTH_LONG).show();
}
@Override
......
......@@ -16,21 +16,21 @@ import com.hikcreate.base.BaseAppLogic;
public class PassPortAppLogic extends BaseAppLogic {
@Override
public void onCreate(Context context) {
Log.v("LoginAppLogic","onCreate--------------------->");
Log.v("LoginAppLogic", "onCreate--------------------->");
}
@Override
public void onTerminate(Context context) {
Log.v("LoginAppLogic","onTerminate--------------------->");
Log.v("LoginAppLogic", "onTerminate--------------------->");
}
@Override
public void onLowMemory(Context context) {
Log.v("LoginAppLogic","onLowMemory--------------------->");
Log.v("LoginAppLogic", "onLowMemory--------------------->");
}
@Override
public void onConfigurationChanged(Context context,Configuration newConfig) {
Log.v("LoginAppLogic","onConfigurationChanged--------------------->");
public void onConfigurationChanged(Context context, Configuration newConfig) {
Log.v("LoginAppLogic", "onConfigurationChanged--------------------->");
}
}
......@@ -29,16 +29,17 @@ public class TestFragment extends Fragment {
super.onCreate(savedInstanceState);
MessageWrap.getMessageWrapDefault().register(this);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//通过参数中的布局填充获取对应布局
return inflater.inflate(R.layout.passport_test_fragment,container,false);
return inflater.inflate(R.layout.passport_test_fragment, container, false);
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void test(GeneralMessageBean bean){
Toast.makeText(getActivity(),MessageWrap.getMessageWrapDefault().
getMessageInfo(bean,"tempValue"),Toast.LENGTH_LONG).show();
public void test(GeneralMessageBean bean) {
Toast.makeText(getActivity(), MessageWrap.getMessageWrapDefault().
getMessageInfo(bean, "tempValue"), Toast.LENGTH_LONG).show();
}
@Override
......
......@@ -5,7 +5,6 @@ import android.app.Application;
import com.hikcreate.base.AppContext;
/**
*
* @author wangtao55
* @date 2019/9/23
* @mail wangtao55@hikcreate.com
......
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.app.login">
<application
android:roundIcon="@mipmap/ic_launcher"
android:allowBackup="false"
......@@ -12,6 +13,5 @@
tools:replace="android:icon,android:roundIcon,android:theme,android:label,android:allowBackup">
</application>
</manifest>
\ No newline at end of file
......@@ -7,13 +7,11 @@
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="我来自于哪里:"
android:id="@+id/tv_from"
/>
android:id="@+id/tv_from" />
<TextView
......@@ -21,16 +19,14 @@
android:layout_height="wrap_content"
android:text="消息内容为"
android:layout_marginTop="10dp"
android:id="@+id/tv_message_info"
/>
android:id="@+id/tv_message_info" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="name:"
android:layout_marginTop="10dp"
android:id="@+id/tv_value"
/>
android:id="@+id/tv_value" />
</LinearLayout>
......@@ -30,7 +30,6 @@ android {
}
dexOptions {
preDexLibraries = false
}
......@@ -43,7 +42,7 @@ dependencies {
api fileTree(dir: 'libs', include: ['*.jar'])
// App's support dependencies
api ([
api([
deps.appcompat,
deps.multidex,
deps.cardview,
......@@ -53,7 +52,7 @@ dependencies {
deps.guava
])
// rx dependencies
api ([
api([
deps.retrofit2,
deps.retrofit2_converter_gson,
deps.retrofit2_converter_scalars,
......@@ -71,6 +70,6 @@ dependencies {
api deps.otto
api deps.gson
api deps.eventbus
api deps.aRouterApi,{ exclude group: 'com.android.support:appcompat-v7:25.2.0' }
api deps.aRouterApi, { exclude group: 'com.android.support:appcompat-v7:25.2.0' }
annotationProcessor deps.aRouterCompiler
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hikcreate.library">
<application
android:allowBackup="false">
</application>
<application android:allowBackup="false"></application>
</manifest>
......@@ -10,6 +10,4 @@ package com.hikcreate.library.app;
public class AppContext {
}
......@@ -3,8 +3,8 @@ package com.hikcreate.library.app;
import android.app.Application;
/**
*
* app初始化基础类
*
* @author wangtao
* @date 2019/07/04
* @mail wangtao55@hikcreate.com
......
......@@ -3,6 +3,7 @@ package com.hikcreate.library.app.config;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import com.hikcreate.library.app.HikApplicationCreate;
/**
......
......@@ -8,6 +8,7 @@ package com.hikcreate.library.app.ui.view.databindadapter;
public interface IRefreshViewModel {
// 用于在ViewModel刷新数据
void refresh();
// 用于在ViewModel加载更多数据
void loadMore();
}
......@@ -163,7 +163,7 @@ public class PatternLockView extends View {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if(msg.what == RESET){
if (msg.what == RESET) {
resetPattern();
}
}
......@@ -1042,9 +1042,11 @@ public class PatternLockView extends View {
public void onStarted() {
handler.removeMessages(RESET);
}
@Override
public void onProgress(List<Dot> progressPattern) {
}
@Override
public void onComplete(List<Dot> progressPattern) {
if (progressPattern.size() <= 0) {
......@@ -1063,7 +1065,7 @@ public class PatternLockView extends View {
mPatternViewMode = PatternViewMode.CORRECT;
} else {
mPatternViewMode = PatternViewMode.WRONG;
handler.sendEmptyMessageDelayed(RESET,2000);
handler.sendEmptyMessageDelayed(RESET, 2000);
}
......
......@@ -2,6 +2,7 @@ package com.hikcreate.library.app.ui.view.recycleview;
import android.content.Context;
import android.databinding.ViewDataBinding;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......
......@@ -64,9 +64,7 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*
* @param bitmap
*
* @return
*/
public static RoundedDrawable fromBitmap(Bitmap bitmap) {
......@@ -80,9 +78,7 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*
* @param drawable
*
* @return
*/
public static Drawable fromDrawable(Drawable drawable) {
......@@ -121,9 +117,7 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*
* @param drawable
*
* @return
*/
public static Bitmap drawableToBitmap(Drawable drawable) {
......@@ -153,7 +147,6 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*
* @return
*/
@Override
......@@ -176,7 +169,6 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*/
private void updateShaderMatrix() {
float scale;
......@@ -284,7 +276,6 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*
* @param canvas
*/
@Override
......@@ -310,7 +301,6 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*
* @return
*/
@Override
......@@ -321,7 +311,6 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*
* @param alpha
*/
@Override
......@@ -333,7 +322,6 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*
* @param cf
*/
@Override
......@@ -345,7 +333,6 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*
* @param dither
*/
@Override
......@@ -357,7 +344,6 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*
* @param filter
*/
@Override
......@@ -369,7 +355,6 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*
* @return
*/
@Override
......@@ -380,7 +365,6 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*
* @return
*/
@Override
......@@ -391,7 +375,6 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*
* @return
*/
public float getCornerRadius() {
......@@ -401,9 +384,7 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*
* @param radius
*
* @return
*/
public RoundedDrawable setCornerRadius(float radius) {
......@@ -415,7 +396,6 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*
* @return
*/
public float getBorderWidth() {
......@@ -425,9 +405,7 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*
* @param width
*
* @return
*/
public RoundedDrawable setBorderWidth(float width) {
......@@ -440,7 +418,6 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*
* @return
*/
public int getBorderColor() {
......@@ -450,9 +427,7 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*
* @param color
*
* @return
*/
public RoundedDrawable setBorderColor(int color) {
......@@ -462,7 +437,6 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*
* @return
*/
public ColorStateList getBorderColors() {
......@@ -472,9 +446,7 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*
* @param colors
*
* @return
*/
public RoundedDrawable setBorderColor(ColorStateList colors) {
......@@ -487,7 +459,6 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*
* @return
*/
public boolean isOval() {
......@@ -497,9 +468,7 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*
* @param oval
*
* @return
*/
public RoundedDrawable setOval(boolean oval) {
......@@ -511,7 +480,6 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*
* @return
*/
public ScaleType getScaleType() {
......@@ -521,9 +489,7 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*
* @param scaleType
*
* @return
*/
public RoundedDrawable setScaleType(ScaleType scaleType) {
......@@ -542,7 +508,6 @@ public class RoundedDrawable extends Drawable {
/**
* Method description
*
*
* @return
*/
public Bitmap toBitmap() {
......
......@@ -6,6 +6,8 @@ package com.hikcreate.library.app.ui.view.scroll.detectedscroll;
*/
public interface DetectedViewCallBack {
void onScrollFadeIn(int top);
void onScrollFadeOut(int top);
void fadeIn50Percent(boolean fadeIn50Percent);
}
......@@ -12,11 +12,11 @@ import com.hikcreate.library.plugin.netbase.exception.ApiException;
public class RequestObserverCallbackAdapter<T> extends RequestObserverCallback<T> {
public RequestObserverCallbackAdapter(){
public RequestObserverCallbackAdapter() {
super();
}
public RequestObserverCallbackAdapter(int tag){
public RequestObserverCallbackAdapter(int tag) {
super(tag);
}
......
......@@ -7,7 +7,7 @@ package com.hikcreate.library.plugin.netbase.entity;
* @data 2019/3/11
* @email leiyongsheng@hikcreate.com
*/
public class ListContentResultWithExtra<T,D> extends ListContentResult<T> {
public class ListContentResultWithExtra<T, D> extends ListContentResult<T> {
private D extra;
public D getExtra() {
......@@ -21,7 +21,7 @@ public class ListContentResultWithExtra<T,D> extends ListContentResult<T> {
@Override
public String toString() {
return "ListContentResultWithExtra{" +
"data="+super.toString()+
"data=" + super.toString() +
"extra=" + extra +
'}';
}
......
......@@ -41,11 +41,11 @@ public class LiveDataCallAdapter<R> implements CallAdapter<R, Object> {
protected void onActive() {
super.onActive();
if (started.compareAndSet(false, true)) {
LogCat.d("hik_SS","live data enqueue ----");
LogCat.d("hik_SS", "live data enqueue ----");
call.enqueue(new Callback<R>() {
@Override
public void onResponse(Call<R> call, Response<R> response) {
LogCat.d("hik_SS","live data enqueue response ----");
LogCat.d("hik_SS", "live data enqueue response ----");
postValue(response.body());
}
......
......@@ -2,6 +2,7 @@ package com.hikcreate.library.plugin.otto;
/**
* 事件通知基类
*
* @author 2015/9/23.
*/
public abstract class Event {
......
......@@ -18,8 +18,7 @@ public class BigDecimalUtils {
* 格式化精度
*
* @param v
* @param point
* 小数位数
* @param point 小数位数
* @return double
*/
public static Double format(double v, int point) {
......@@ -28,7 +27,6 @@ public class BigDecimalUtils {
}
/**
*
* @param v
* @param point
* @return
......@@ -57,6 +55,7 @@ public class BigDecimalUtils {
/**
* 带小数的显示小数。不带小数的显示整数
*
* @param d
* @return
*/
......
......@@ -21,8 +21,8 @@ public class ClassTypeEntity {
this.classType = classType;
}
public void addClassTyep(Type type){
if(classType == null){
public void addClassTyep(Type type) {
if (classType == null) {
classType = new ArrayList<>();
}
classType.add(type);
......
......@@ -26,13 +26,14 @@ public class DESUtil {
private static final String CHAR_SET = "UTF-8";
static{
static {
System.loadLibrary("getkey-lib");
}
/**
* 获取so动态库中的KEY
*
* @param context
* @return
*/
......
......@@ -35,8 +35,7 @@ public class DecimalDigitsInputFilter implements InputFilter {
if (dotPos >= 0) {
// protects against many dots
if (source.equals(".") || source.equals(","))
{
if (source.equals(".") || source.equals(",")) {
return "";
}
// if the text is entered before the dot
......
......@@ -12,6 +12,7 @@ import java.util.List;
public class GenericsUtils {
private static final String TAG = "GenericsUtils";
/**
* 通过反射,获得定义Class时声明的父类的范型参数的类型.
* 如public BookManager extends GenricManager<Book>
......
......@@ -64,7 +64,8 @@ public class IDCardValidateUtil {
/**
* 检查身份证号码正确性
*/
@Deprecated //Del by Gv. 2019.9.11. 因为夏令时误差,会导致checkBirthday()在校验生日时异常返回false,废弃此方法。如:1988-04-10,1989-04-16,1990-04-15,1991-04-14
@Deprecated
//Del by Gv. 2019.9.11. 因为夏令时误差,会导致checkBirthday()在校验生日时异常返回false,废弃此方法。如:1988-04-10,1989-04-16,1990-04-15,1991-04-14
public static boolean isCardNo(String card) {
if (TextUtils.isEmpty(card)) return false;
card = card.replace("x", "X");
......
......@@ -17,7 +17,7 @@ public class SVGUtils {
public static void tintSVGDrawable(SVGImageItem item) {
if (item != null && item.isLegal()) {
//利用ContextCompat工具类获取drawable图片资源
Drawable drawable = ContextCompat.getDrawable(item.mImageView.getContext(),item.getImgResId());
Drawable drawable = ContextCompat.getDrawable(item.mImageView.getContext(), item.getImgResId());
//简单的使用tint改变drawable颜色
Drawable wrap = DrawableCompat.wrap(drawable).mutate();
DrawableCompat.setTint(wrap, ContextCompat.getColor(item.mImageView.getContext(), item.getColorId()));
......
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
android:layout_height="match_parent">
<com.hikcreate.library.app.ui.view.patternlock.PatternLockView
......@@ -27,8 +25,7 @@
app:correctLineStateColor="#00ffffff"
app:wrongLineStateColor="#00ffffff"
app:wrongDotStateColor="#E95E52"
app:wrongDotStrokeStateColor="#E95E52"
/>
app:wrongDotStrokeStateColor="#E95E52" />
<TextView
......@@ -42,7 +39,7 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/pattern_lock_view_tip"
tools:text="请绘制您的手势密码"
android:id="@+id/pattern_lock_state_tv_view"/>
android:id="@+id/pattern_lock_state_tv_view" />
<com.hikcreate.library.app.ui.view.patternlock.PatternLockView
......@@ -52,8 +49,7 @@
app:layout_constraintRight_toRightOf="parent"
android:layout_marginTop="66dp"
android:layout_width="300dp"
android:layout_height="300dp"
/>
android:layout_height="300dp" />
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"/><path d="M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24">
<path
d="M0 0h24v24H0z"
fill="none" />
<path d="M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z" />
</svg>
\ No newline at end of file
......@@ -12,30 +12,30 @@
<declare-styleable name="PatternLockView">
<!--点行 列数量-->
<attr name="dotCount" format="integer"/>
<attr name="dotCount" format="integer" />
<!--点默认大小-->
<attr name="dotNormalSize" format="dimension"/>
<attr name="dotNormalSize" format="dimension" />
<!--点被选中时大小-->
<attr name="dotSelectedSize" format="dimension"/>
<attr name="dotSelectedSize" format="dimension" />
<!--连接线的宽度-->
<attr name="pathWidth" format="dimension"/>
<attr name="pathWidth" format="dimension" />
<!--点默认颜色-->
<attr name="normalDotStateColor" format="color"/>
<attr name="selectStateColor" format="color"/>
<attr name="normalDotStateColor" format="color" />
<attr name="selectStateColor" format="color" />
<!--正确点的颜色-->
<attr name="correctDotStateColor" format="color"/>
<attr name="correctDotStateColor" format="color" />
<!--正确点外环的颜色-->
<attr name="correctDotStrokeStateColor" format="color"/>
<attr name="correctDotStrokeStateColor" format="color" />
<!--正确线的颜色-->
<attr name="correctLineStateColor" format="color"/>
<attr name="correctLineStateColor" format="color" />
<!--错误线的颜色-->
<attr name="wrongLineStateColor" format="color"/>
<attr name="wrongLineStateColor" format="color" />
<!--错误点颜色-->
<attr name="wrongDotStateColor" format="color"/>
<attr name="wrongDotStateColor" format="color" />
<!--错误点外环颜色-->
<attr name="wrongDotStrokeStateColor" format="color"/>
<attr name="wrongDotStrokeStateColor" format="color" />
<!--点动画执行时间-->
<attr name="dotAnimationDuration" format="integer"/>
<attr name="checkMode" format="boolean"/>
<attr name="dotAnimationDuration" format="integer" />
<attr name="checkMode" format="boolean" />
</declare-styleable>
</resources>
\ No newline at end of file
......@@ -13,6 +13,7 @@ public class GeneralMessageBean {
private String dataClassName;//用于通过反射获取类的字符串
private String messageJsonData;//message的json数据
private String extraJsonData;//额外的消息的json数据
public String getDataAction() {
return dataAction;
}
......
package com.message.driver;
import android.util.Log;
import com.message.bean.GeneralMessageBean;
import com.message.util.ObjectUtil;
import org.greenrobot.eventbus.EventBus;
import info.hook.com.lib_data_drive.BuildConfig;
/**
......
......@@ -29,7 +29,7 @@ public class ObjectUtil {
return messageBeanObject;
}
private static Object invokeMethod(Object object,String methodName){
private static Object invokeMethod(Object object, String methodName) {
try {
Method method = object.getClass().getMethod(methodName);
return method.invoke(object);
......@@ -39,8 +39,8 @@ public class ObjectUtil {
return null;
}
private static Object getInfoByMethod(String className, String dataContent,String methodName){
return invokeMethod(getObjectBean(className,dataContent),methodName);
private static Object getInfoByMethod(String className, String dataContent, String methodName) {
return invokeMethod(getObjectBean(className, dataContent), methodName);
}
......@@ -55,41 +55,42 @@ public class ObjectUtil {
return null;
}
public static <T> T createInstance(Class<T> checkType,String className){
public static <T> T createInstance(Class<T> checkType, String className) {
try {
Class<T> clz = (Class<T>)Class.forName(className);
Class<T> clz = (Class<T>) Class.forName(className);
Object obj = clz.newInstance();
if (!checkType.isInstance(obj)) {
throw new Exception("类型不匹配");
}
return (T)obj;
return (T) obj;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static void readAttributeValue(Object obj){
String nameValues ="";
public static void readAttributeValue(Object obj) {
String nameValues = "";
Class cls = obj.getClass();
Field[] fields = cls.getDeclaredFields();
for (int i=0;i<fields.length;i++){
for (int i = 0; i < fields.length; i++) {
try {
Field field = fields[i];
field.setAccessible(true);
Object value = field.get(obj);
nameValues += field.getName()+":"+value+",";
nameValues += field.getName() + ":" + value + ",";
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
int lastIndex = nameValues.lastIndexOf(",");
String result= nameValues.substring(0,lastIndex);
String result = nameValues.substring(0, lastIndex);
System.out.println(result);
}
public static String readAttributeValueByName(Object obj,String name){
public static String readAttributeValueByName(Object obj, String name) {
Class cls = obj.getClass();
Field[] fields = cls.getDeclaredFields();
for (Field field : fields) {
......@@ -105,9 +106,9 @@ public class ObjectUtil {
return null;
}
public static String readAttributeValueByMethod(GeneralMessageBean mGeneralMessageBean, String name){
Object message = getObjectBean(mGeneralMessageBean.getDataClassName(),mGeneralMessageBean.getMessageJsonData());
return (String) invokeMethod(message,name);
public static String readAttributeValueByMethod(GeneralMessageBean mGeneralMessageBean, String name) {
Object message = getObjectBean(mGeneralMessageBean.getDataClassName(), mGeneralMessageBean.getMessageJsonData());
return (String) invokeMethod(message, name);
}
public static String readAttributeValueByName(GeneralMessageBean mGeneralMessageBean, String name) {
......
......@@ -15,11 +15,17 @@ import android.os.Bundle;
public abstract class BaseActivityLifeLogic {
abstract public void onActivityCreated(Activity activity, Bundle savedInstanceState);
abstract public void onActivityStarted(Activity activity);
abstract public void onActivityResumed(Activity activity);
abstract public void onActivityPaused(Activity activity);
abstract public void onActivityStopped(Activity activity);
abstract public void onActivityDestroyed(Activity activity);
abstract public void onActivitySaveInstanceState(Activity activity, Bundle savedInstanceState);
......
......@@ -14,10 +14,14 @@ import android.content.res.Configuration;
public abstract class BaseAppLogic {
private Application mApplication;
abstract public void onCreate(Context context);
abstract public void onTerminate(Context context);
abstract public void onLowMemory(Context context);
abstract public void onConfigurationChanged(Context context,Configuration newConfig);
abstract public void onConfigurationChanged(Context context, Configuration newConfig);
}
......@@ -14,20 +14,21 @@ public class ErrorAction extends ModuleAction {
private int mCode;
private String mMessage;
private boolean mAsync;
public ErrorAction() {
mCode = ModuleActionResult.CODE_ERROR;
mMessage = DEFAULT_MESSAGE;
mAsync = false;
}
public ErrorAction(boolean isAsync,int code, String message) {
public ErrorAction(boolean isAsync, int code, String message) {
this.mCode = code;
this.mMessage = message;
this.mAsync = isAsync;
}
@Override
public boolean isAsync( HashMap<String, String> requestData) {
public boolean isAsync(HashMap<String, String> requestData) {
return mAsync;
}
......
......@@ -3,10 +3,12 @@ package com.hikcreate.module_router;
import android.content.Context;
import android.support.annotation.NonNull;
import com.hikcreate.module_router.router.RouterRequest;
import com.hikcreate.module_router.router.RouterResponse;
import com.hikcreate.module_router.tools.Logger;
import com.hikcreate.module_router.tools.ProcessUtil;
import java.util.HashMap;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
......@@ -61,7 +63,7 @@ public class LocalRouter {
}
}
public RouterResponse route(@NonNull RouterRequest routerRequest){
public RouterResponse route(@NonNull RouterRequest routerRequest) {
Logger.d(TAG, "Process:" + mProcessName + "\nLocal route start: " + System.currentTimeMillis());
RouterResponse routerResponse = new RouterResponse();
......@@ -134,7 +136,7 @@ public class LocalRouter {
: mAction.invoke(mContext, mRequestData, mObject);
mResponse.mObject = result.getObject();
return result.toString();
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
......
......@@ -5,19 +5,21 @@ import android.content.Context;
import java.util.HashMap;
/**
*
* @author wangtao55
* @date 2019/9/19
* @mail wangtao55@hikcreate.com
*/
public abstract class ModuleAction {
public abstract boolean isAsync(HashMap<String,String> requestData);
public abstract ModuleActionResult invoke(Context context, HashMap<String,String> requestData);
public boolean isAsync(HashMap<String,String> requestData,Object object){
public abstract boolean isAsync(HashMap<String, String> requestData);
public abstract ModuleActionResult invoke(Context context, HashMap<String, String> requestData);
public boolean isAsync(HashMap<String, String> requestData, Object object) {
return false;
}
public ModuleActionResult invoke(Context context, HashMap<String,String> requestData, Object object){
public ModuleActionResult invoke(Context context, HashMap<String, String> requestData, Object object) {
return new ModuleActionResult.Builder().code(ModuleActionResult.CODE_NOT_IMPLEMENT).
msg("This method has not yet been implemented.").build();
}
......
......@@ -7,7 +7,6 @@ import org.json.JSONObject;
import java.util.HashMap;
/**
*
* @author wangtao55
* @date 2019/9/19
* @mail wangtao55@hikcreate.com
......@@ -35,7 +34,6 @@ public class ModuleActionResult {
this.msg = builder.mMsg;
this.data = builder.mData;
this.object = builder.mObject;
}
public Object getObject() {
......@@ -72,12 +70,14 @@ public class ModuleActionResult {
private String mMsg;
private Object mObject;
private String mData;
public Builder() {
mCode = CODE_ERROR;
mMsg = "";
mObject = null;
mData = null;
}
public Builder resultString(String resultString) {
try {
JSONObject jsonObject = new JSONObject(resultString);
......
......@@ -3,7 +3,6 @@ package com.hikcreate.module_router;
import java.util.HashMap;
/**
*
* @author wangtao55
* @date 2019/9/19
* @mail wangtao55@hikcreate.com
......@@ -11,19 +10,21 @@ import java.util.HashMap;
public abstract class ModuleProvider {
private boolean mValid = true;
private HashMap<String, ModuleAction> mActions;
public ModuleProvider(){
public ModuleProvider() {
mActions = new HashMap<>();
registerActions();
}
protected void registerAction(String actionName, ModuleAction action){
mActions.put(actionName,action);
protected void registerAction(String actionName, ModuleAction action) {
mActions.put(actionName, action);
}
public ModuleAction findAction(String actionName){
public ModuleAction findAction(String actionName) {
return mActions.get(actionName);
}
public boolean isValid(){
public boolean isValid() {
return mValid;
}
......
......@@ -8,6 +8,7 @@ import com.hikcreate.module_router.tools.ProcessUtil;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.HashMap;
......@@ -17,7 +18,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
/**
*
* @author wangtao55
* @date 2019/9/19
* @mail wangtao55@hikcreate.com
......@@ -220,8 +220,8 @@ public class RouterRequest {
return this;
}
public RouterRequest data(HashMap<String,String> value) {
if(value == null){
public RouterRequest data(HashMap<String, String> value) {
if (value == null) {
return this;
}
for (Map.Entry<String, String> entry : value.entrySet()) {
......@@ -230,7 +230,6 @@ public class RouterRequest {
return this;
}
public RouterRequest data(String key, String data) {
this.data.put(key, data);
return this;
......
......@@ -8,7 +8,6 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
/**
*
* @author wangtao55
* @date 2019/9/19
* @mail wangtao55@hikcreate.com
......@@ -25,12 +24,10 @@ public class RouterResponse {
private static final int TIME_OUT = 30 * 1000;
private long mTimeOut;
private boolean mHasGet = false;
int mCode = -1;
String mMessage = "";
String mData;
HashMap<String,String> keyValues;
private int mCode = -1;
private String mMessage = "";
private String mData;
HashMap<String, String> keyValues;
public RouterResponse() {
this(TIME_OUT);
......@@ -47,22 +44,21 @@ public class RouterResponse {
return mIsAsync;
}
public String get(){
try{
public String get() {
try {
if (mIsAsync) {
mResultString = mAsyncResponse.get(mTimeOut, TimeUnit.MILLISECONDS);
parseResult();
}else{
} else {
parseResult();
}
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
return mResultString;
}
private void parseResult(){
private void parseResult() {
if (!mHasGet) {
try {
JSONObject jsonObject = new JSONObject(mResultString);
......@@ -76,14 +72,14 @@ public class RouterResponse {
}
}
public int getCode(){
public int getCode() {
if (!mHasGet) {
get();
}
return mCode;
}
public String getMessage(){
public String getMessage() {
if (!mHasGet) {
get();
}
......@@ -97,13 +93,10 @@ public class RouterResponse {
return mData;
}
public Object getObject(){
public Object getObject() {
if (!mHasGet) {
get();
}
return mObject;
}
}
......@@ -3,7 +3,6 @@ package com.hikcreate.module_router.tools;
import android.util.Log;
/**
*
* @author wangtao55
* @date 2019/9/19
* @mail wangtao55@hikcreate.com
......@@ -14,10 +13,8 @@ public class Logger {
public final static int INFO = 3;
public final static int DEBUG = 4;
public final static int VERBOSE = 5;
public static int LOG_LEVEL = ERROR;
public static void e(String tag, String msg) {
if (LOG_LEVEL >= ERROR)
Log.e(tag, msg);
......
......@@ -15,18 +15,13 @@ import java.util.HashMap;
**/
public class ModuleRouterUtil {
public static RouterResponse getRouterResponse(Context context,String provider,String action){
public static RouterResponse getRouterResponse(Context context, String provider, String action) {
return LocalRouter.getInstance(context).route(RouterRequest.obtain(context).provider(provider).action(action));
}
public static RouterResponse getRouterResponse(Context context, String provider, String action,
HashMap<String,String> value){
HashMap<String, String> value) {
return LocalRouter.getInstance(context).route(RouterRequest.obtain(context).provider(provider).data(value).action(action));
}
public static RouterResponse startRouter(Context context,RouterRequest request){
return LocalRouter.getInstance(context).route(request);
}
}
......@@ -10,7 +10,6 @@ import java.io.FileReader;
import java.util.List;
/**
*
* @author wangtao55
* @date 2019/9/19
* @mail wangtao55@hikcreate.com
......@@ -44,7 +43,7 @@ public class ProcessUtil {
public static String getProcessName(Context context, int pid) {
String processName = getProcessName(pid);
if(UNKNOWN_PROCESS_NAME.equals(processName)){
if (UNKNOWN_PROCESS_NAME.equals(processName)) {
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningAppProcessInfo> runningApps = am.getRunningAppProcesses();
if (runningApps == null) {
......@@ -55,7 +54,7 @@ public class ProcessUtil {
return procInfo.processName;
}
}
}else{
} else {
return processName;
}
return UNKNOWN_PROCESS_NAME;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment