Commit fe7a7dbe by 宁斌

配置調整 登錄、註冊組件可單獨運行

parent bb8e3cd0
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gingersoft.cloud.gsa"> package="com.gingersoft.gsa.cloud">
<application <application
android:allowBackup="true" android:allowBackup="true"
......
package com.gingersoft.cloud.gsa.main; package com.gingersoft.gsa.cloud.main;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
...@@ -7,7 +7,7 @@ import android.view.Gravity; ...@@ -7,7 +7,7 @@ import android.view.Gravity;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import com.gingersoft.cloud.gsa.R; import com.gingersoft.gsa.cloud.R;
/** /**
* @author billy.qi * @author billy.qi
......
package com.gingersoft.cloud.gsa.main; package com.gingersoft.gsa.cloud.main;
import android.app.Application; import android.app.Application;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
// 完成组件、拦截器及跨进程json解释器等CC库自身需要的自动注册功能 // 完成组件、拦截器及跨进程json解释器等CC库自身需要的自动注册功能
// 支持新增自定义的其它自动注册功能,参考AutoRegister,用法参考cc-settings-demo.gradle // 支持新增自定义的其它自动注册功能,参考AutoRegister,用法参考cc-settings-demo.gradle
project.apply plugin: 'cc-register' project.apply plugin: 'cc-register'
project.dependencies.add('api', "com.billy.android:cc:2.1.5") //用最新版 project.dependencies.add('api', "com.billy.android:cc:2.1.6") //用最新版
//此文件是作为组件化配置的公共gradle脚本文件,在每个组件中都apply此文件,下载到工程根目录后,可以在下方添加一些自己工程中通用的配置 //此文件是作为组件化配置的公共gradle脚本文件,在每个组件中都apply此文件,下载到工程根目录后,可以在下方添加一些自己工程中通用的配置
// 可参考cc-settings-demo.gradle // 可参考cc-settings-demo.gradle
...@@ -32,3 +32,6 @@ project.dependencies.add('api', "com.billy.android:cc:2.1.5") //用最新版 ...@@ -32,3 +32,6 @@ project.dependencies.add('api', "com.billy.android:cc:2.1.5") //用最新版
// , 'codeInsertToMethodName' : 'initProcessors' // , 'codeInsertToMethodName' : 'initProcessors'
// , 'registerMethodName' : 'add' // , 'registerMethodName' : 'add'
//]) //])
//开启app内部多进程组件调用
ccregister.multiProcessEnabled = true
\ No newline at end of file
apply plugin: 'com.android.library' ext.alwaysLib = true //虽然apply了cc-settings-2.gradle,但一直作为library编译,否则别的组件依赖此module时会报错
apply from: rootProject.file("cc-settings.gradle")
android { android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"] compileSdkVersion rootProject.ext.android["compileSdkVersion"]
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gsa.cloud.order.detail"> package="com.gingersoft.gsa.cloud.order.detail">
<application> <application>
......
package com.gsa.cloud.order.detail; package com.gingersoft.gsa.cloud.order.detail;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gsa.cloud.order.list"> package="com.gingersoft.gsa.cloud.order.list">
</manifest> </manifest>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gsa.cloud.database"> package="com.gingersoft.gsa.cloud.database">
</manifest> </manifest>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gsa.cloud.network"> package="com.gingersoft.gsa.cloud.network">
</manifest> </manifest>
\ No newline at end of file
...@@ -3,7 +3,6 @@ include ':app', ...@@ -3,7 +3,6 @@ include ':app',
':cc-register', ':cc', ':cc-register', ':cc',
':android_internal', ':android_internal',
':public2:component-database', ':public2:component-database',
':public2:component-network',
':order:component-order-list', ':order:component-order-list',
':order:component-order-detail', ':order:component-order-detail',
':user:component-login', ':user:component-login',
......
...@@ -13,13 +13,13 @@ android { ...@@ -13,13 +13,13 @@ android {
minSdkVersion rootProject.ext.android["minSdkVersion"] minSdkVersion rootProject.ext.android["minSdkVersion"]
targetSdkVersion rootProject.ext.android["targetSdkVersion"] targetSdkVersion rootProject.ext.android["targetSdkVersion"]
if (project.ext.runAsApp) { if (project.ext.runAsApp) {
applicationId 'com.gingersoft.cloud.gsa.user.login' applicationId 'com.gingersoft.gsa.cloud.user.login'
} }
versionCode rootProject.ext.android["versionCode"] versionCode rootProject.ext.android["versionCode"]
versionName rootProject.ext.android["versionName"] versionName rootProject.ext.android["versionName"]
} }
resourcePrefix "gsa_user_login" resourcePrefix "user_login"
buildTypes { buildTypes {
...@@ -38,4 +38,5 @@ android { ...@@ -38,4 +38,5 @@ android {
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':mvp:arms') implementation project(':mvp:arms')
} }
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gsa.cloud.login"> package="com.gingersoft.gsa.cloud.user.login">
<application>
<activity android:name=".LoginActivity">
</activity>
</application>
</manifest> </manifest>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gingersoft.gsa.cloud.user.login">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/user_login_AppTheme">
<activity android:name="com.gingersoft.gsa.cloud.user.login.LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
\ No newline at end of file
package debug;
import android.app.Application;
import com.billy.cc.core.component.CC;
/**
* @author billy.qi
* @since 17/11/20 20:02
*/
public class MyApp extends Application {
@Override
public void onCreate() {
super.onCreate();
CC.enableVerboseLog(true);
CC.enableDebug(true);
CC.enableRemoteCC(true);
}
}
<resources>
<string name="demo_a_app_name">Demo_A</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="user_login_colorPrimary">#3F51B5</color>
<color name="user_login_colorPrimaryDark">#303F9F</color>
<color name="user_login_colorAccent">#FF4081</color>
</resources>
<resources>
<string name="user_login_app_name">Demo_A</string>
</resources>
<resources>
<!-- Base application theme. -->
<style name="user_login_AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/user_login_colorPrimary</item>
<item name="colorPrimaryDark">@color/user_login_colorPrimaryDark</item>
<item name="colorAccent">@color/user_login_colorAccent</item>
</style>
</resources>
package com.gsa.cloud.user.login; package com.gingersoft.gsa.cloud.user.login;
import com.billy.cc.core.component.CC; import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCResult; import com.billy.cc.core.component.CCResult;
...@@ -71,8 +71,8 @@ public class ComponentLogin implements IComponent { ...@@ -71,8 +71,8 @@ public class ComponentLogin implements IComponent {
} }
private void openActivity(CC cc) { private void openActivity(CC cc) {
// CCUtil.navigateTo(cc, ActivityA.class); CCUtil.navigateTo(cc, LoginActivity.class);
// CC.sendCCResult(cc.getCallId(), CCResult.success()); CC.sendCCResult(cc.getCallId(), CCResult.success());
} }
} }
package com.gsa.cloud.user.login; package com.gingersoft.gsa.cloud.user.login;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
...@@ -6,22 +6,23 @@ import android.support.v7.app.AppCompatActivity; ...@@ -6,22 +6,23 @@ import android.support.v7.app.AppCompatActivity;
import android.view.Gravity; import android.view.Gravity;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import com.gsa.cloud.login.R; import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCResult;
public class LoginActivity extends AppCompatActivity { public class LoginActivity extends AppCompatActivity {
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login); setContentView(R.layout.user_login_activity);
TextView textView = new TextView(this); TextView textView = new TextView(this);
textView.setGravity(Gravity.CENTER); textView.setGravity(Gravity.CENTER);
textView.setText("ActivityA\nClick to finish this activity"); textView.setText("this is login activity");
setContentView(textView); setContentView(textView);
textView.setOnClickListener(new View.OnClickListener() { textView.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
finish();
} }
}); });
} }
......
<resources> <resources>
<string name="app_name">component-order-list</string> <string name="user_login_name">component-user-login</string>
</resources> </resources>
...@@ -13,13 +13,13 @@ android { ...@@ -13,13 +13,13 @@ android {
minSdkVersion rootProject.ext.android["minSdkVersion"] minSdkVersion rootProject.ext.android["minSdkVersion"]
targetSdkVersion rootProject.ext.android["targetSdkVersion"] targetSdkVersion rootProject.ext.android["targetSdkVersion"]
if (project.ext.runAsApp) { if (project.ext.runAsApp) {
applicationId 'com.gingersoft.cloud.gsa.user.register' applicationId 'com.gingersoft.gsa.cloud.user.register'
} }
versionCode rootProject.ext.android["versionCode"] versionCode rootProject.ext.android["versionCode"]
versionName rootProject.ext.android["versionName"] versionName rootProject.ext.android["versionName"]
} }
resourcePrefix "gsa_user_register" resourcePrefix "user_register"
buildTypes { buildTypes {
...@@ -37,5 +37,5 @@ android { ...@@ -37,5 +37,5 @@ android {
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':mvp:arms')
} }
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gsa.cloud.register"> package="com.gingersoft.gsa.cloud.user.register">
<application>
<activity android:name=".RegisterActivity">
</activity>
</application>
</manifest> </manifest>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gingersoft.gsa.cloud.user.register">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/user_register_AppTheme">
<activity android:name=".RegisterActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
\ No newline at end of file
package debug;
import android.app.Application;
import com.billy.cc.core.component.CC;
/**
* @author billy.qi
* @since 17/11/20 20:02
*/
public class MyApp extends Application {
@Override
public void onCreate() {
super.onCreate();
CC.enableVerboseLog(true);
CC.enableDebug(true);
CC.enableRemoteCC(true);
}
}
<resources>
<string name="demo_a_app_name">Demo_A</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="user_register_colorPrimary">#3F51B5</color>
<color name="user_register_colorPrimaryDark">#303F9F</color>
<color name="user_register_colorAccent">#FF4081</color>
</resources>
<resources>
<string name="user_register_app_name">Demo_A</string>
</resources>
<resources>
<!-- Base application theme. -->
<style name="user_register_AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/user_register_colorPrimary</item>
<item name="colorPrimaryDark">@color/user_register_colorPrimaryDark</item>
<item name="colorAccent">@color/user_register_colorAccent</item>
</style>
</resources>
package com.gingersoft.gsa.cloud.user.register;
import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCResult;
import com.billy.cc.core.component.CCUtil;
import com.billy.cc.core.component.IComponent;
public class ComponentRegister implements IComponent {
@Override
public String getName() {
//组件的名称,调用此组件的方式:
// CC.obtainBuilder("ComponentA")...build().callAsync()
return "Component.Register";
}
/**
* 组件被调用时的入口
* 要确保每个逻辑分支都会调用到CC.sendCCResult,
* 包括try-catch,if-else,switch-case-default,startActivity
* @param cc 组件调用对象,可从此对象中获取相关信息
* @return true:将异步调用CC.sendCCResult(...),用于异步实现相关功能,例如:文件加载、网络请求等
* false:会同步调用CC.sendCCResult(...),即在onCall方法return之前调用,否则将被视为不合法的实现
*/
@Override
public boolean onCall(CC cc) {
String actionName = cc.getActionName();
switch (actionName) {
case "showRegisterActivity":
openActivity(cc);
break;
case "getLifecycleFragment":
//demo for provide fragment object to other component
getLifecycleFragment(cc);
break;
case "lifecycleFragment.addText":
lifecycleFragmentDoubleText(cc);
break;
case "getInfo":
getInfo(cc);
break;
default:
//这个逻辑分支上没有调用CC.sendCCResult(...),是一种错误的示例
//并且方法的返回值为false,代表不会异步调用CC.sendCCResult(...)
//在LocalCCInterceptor中将会返回错误码为-10的CCResult
break;
}
return false;
}
private void lifecycleFragmentDoubleText(CC cc) {
// LifecycleFragment lifecycleFragment = cc.getParamItem("fragment");
// if (lifecycleFragment != null) {
// String text = cc.getParamItem("text", "");
// lifecycleFragment.addText(text);
// CC.sendCCResult(cc.getCallId(), CCResult.success());
// } else {
// CC.sendCCResult(cc.getCallId(), CCResult.error("no fragment params"));
// }
}
private void getLifecycleFragment(CC cc) {
// CC.sendCCResult(cc.getCallId(), CCResult.successWithNoKey(new LifecycleFragment()));
}
private void getInfo(CC cc) {
String userName = "billy";
CC.sendCCResult(cc.getCallId(), CCResult.success("userName", userName));
}
private void openActivity(CC cc) {
CCUtil.navigateTo(cc, RegisterActivity.class);
CC.sendCCResult(cc.getCallId(), CCResult.success());
}
}
package com.gingersoft.gsa.cloud.user.register;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;
import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCResult;
public class RegisterActivity extends AppCompatActivity {
private static final String COMPONENT_NAME_A = "COMPONENT_NAME_A";
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.user_register_activity);
TextView textView = new TextView(this);
textView.setGravity(Gravity.CENTER);
textView.setText("this is register activity");
setContentView(textView);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// CC cc = CC.obtainBuilder(COMPONENT_NAME_A)
// .setActionName("getInfo")
// .build();
// CCResult result = cc.call();
}
});
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
<resources> <resources>
<string name="app_name">component-order-list</string> <string name="user_register_name">component-user-register</string>
</resources> </resources>
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