Commit 4ca8fcf1 by sikang

update script

parent 37b36a63
cd ../app/src/app/
git add .
echo -n "commit message: "
read message
git commit -m "${message}"
git push origin master
\ No newline at end of file
......@@ -22,5 +22,6 @@
"RepaymentFragment"
],
"root": "../../app/src/main",
"manifest": "../../app/src/main/AndroidManifest.xml"
"manifest": "../../app/src/main/AndroidManifest.xml",
"applibroot": "../../app/src/app"
}
......@@ -79,3 +79,43 @@ manifest_path = os.path.join(os.getcwd(), manifest)
process_file_content(manifest_path, "AndroidManifest.xml")
#update applib
# read configs
with open('obact_lib.json', "rt") as f:
json_root = json.load(f)
activities = json_root["activities"]
source_root = json_root["applibroot"]
manifest = json_root["appmanifest"]
print("activity mapping %s"%activity_mangle_setting)s
root_path = os.path.join(os.getcwd(), source_root)
# perform content replace for the files
print("processing file content...")
for root, dirs, files in os.walk(source_root):
directory = os.path.join(os.getcwd(), root)
for file in files:
if file.endswith(".java"):
# get the path of the java file
path = os.path.join(directory, file)
process_file_content(path, file)
print("processing file content done")
print("renaming files")
for root, dirs, files in os.walk(source_root):
directory = os.path.join(os.getcwd(), root)
for file in files:
if file.endswith(".java"):
name = os.path.splitext(file)[0]
if name in activity_mangle_setting:
# get the path of the java file
src = os.path.join(directory, file)
dst = os.path.join(directory, "%s.java"%activity_mangle_setting[name])
print("%s -> %s"%(src, dst))
os.rename(src, dst)
print("renaming files done")
......@@ -82,5 +82,6 @@
"root": "../../lib_base/src/main",
"manifest": "../../lib_base/src/main/AndroidManifest.xml",
"approot": "../../app/src/main",
"appmanifest": "../../app/src/main/AndroidManifest.xml"
"appmanifest": "../../app/src/main/AndroidManifest.xml",
"applibroot": "../../app/src/app"
}
......@@ -120,3 +120,42 @@ manifest_path = os.path.join(os.getcwd(), manifest)
process_file_content(manifest_path, "AndroidManifest.xml")
#update applib
# read configs
with open('obact_lib.json', "rt") as f:
json_root = json.load(f)
activities = json_root["activities"]
source_root = json_root["applibroot"]
manifest = json_root["appmanifest"]
print("activity mapping %s"%activity_mangle_setting)s
root_path = os.path.join(os.getcwd(), source_root)
# perform content replace for the files
print("processing file content...")
for root, dirs, files in os.walk(source_root):
directory = os.path.join(os.getcwd(), root)
for file in files:
if file.endswith(".java"):
# get the path of the java file
path = os.path.join(directory, file)
process_file_content(path, file)
print("processing file content done")
print("renaming files")
for root, dirs, files in os.walk(source_root):
directory = os.path.join(os.getcwd(), root)
for file in files:
if file.endswith(".java"):
name = os.path.splitext(file)[0]
if name in activity_mangle_setting:
# get the path of the java file
src = os.path.join(directory, file)
dst = os.path.join(directory, "%s.java"%activity_mangle_setting[name])
print("%s -> %s"%(src, dst))
os.rename(src, dst)
print("renaming files done")
......@@ -12,7 +12,6 @@ import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
......@@ -31,7 +30,6 @@ import tech.starwin.base.BasePresenter;
import tech.starwin.mvp.IView;
import tech.starwin.mvp.presenter.UserPresenter;
import tech.starwin.utils.PreferencesManager;
import tech.starwin.utils.context_utils.AppLanguageUtils;
import tech.starwin.utils.PresenterHoler;
import tech.starwin.utils.context_utils.FragmentLauncher;
......@@ -79,6 +77,11 @@ public abstract class BaseActivity extends AppCompatActivity implements IView {
private final BehaviorSubject<ActivityEvent> lifecycleSubject = BehaviorSubject.create();
/**
* 逻辑代码托管
*/
private BaseTrustee trustee;
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(AppLanguageUtils.attachBaseContext(newBase, LibConfig.LANGUAGE));
......@@ -100,7 +103,13 @@ public abstract class BaseActivity extends AppCompatActivity implements IView {
if ("HomeActivity".equals(TAG)) {
getPresenter(UserPresenter.class).getCustomerMsg("");
}
if(getTrustee()==null){
getTrustee().onCreate();
}
}
public ViewGroup getContentView() {
return rootLayout;
}
@Override
......@@ -115,16 +124,26 @@ public abstract class BaseActivity extends AppCompatActivity implements IView {
// MsgHandleService.handleMsg(this, new RemoteMessage(getIntent().getExtras()));
// }
lifecycleSubject.onNext(ActivityEvent.START);
if(getTrustee()==null){
getTrustee().onStart();
}
}
public ViewGroup getContentView() {
return rootLayout;
@Override
protected void onRestart() {
super.onRestart();
if(getTrustee()==null){
getTrustee().onRestart();
}
}
@Override
protected void onResume() {
super.onResume();
lifecycleSubject.onNext(ActivityEvent.RESUME);
if(getTrustee()==null){
getTrustee().onResume();
}
}
@Override
......@@ -132,6 +151,9 @@ public abstract class BaseActivity extends AppCompatActivity implements IView {
super.onPause();
lifecycleSubject.onNext(ActivityEvent.PAUSE);
progressDialog.dissmissLoading();
if(getTrustee()==null){
getTrustee().onPause();
}
}
@Override
......@@ -139,6 +161,9 @@ public abstract class BaseActivity extends AppCompatActivity implements IView {
super.onStop();
progressDialog.setEnable(false);
lifecycleSubject.onNext(ActivityEvent.STOP);
if(getTrustee()==null){
getTrustee().onStop();
}
}
@Override
......@@ -149,7 +174,11 @@ public abstract class BaseActivity extends AppCompatActivity implements IView {
}
lifecycleSubject.onNext(ActivityEvent.DESTROY);
presenterHelper.onDestory();
if(getTrustee()==null){
getTrustee().onDestroy();
}
}
@Override
@NonNull
......@@ -190,6 +219,9 @@ public abstract class BaseActivity extends AppCompatActivity implements IView {
}
}
@Override
public void onHttpSuccess(String action, Object result) {
}
@Override
public void onHttpFinish(String action) {
......@@ -234,6 +266,7 @@ public abstract class BaseActivity extends AppCompatActivity implements IView {
}
unBinder = LibConfig.bindView(this, rootLayout);
initView();
getFragmentLauncher();
}
/**
......@@ -300,6 +333,9 @@ public abstract class BaseActivity extends AppCompatActivity implements IView {
public FragmentLauncher getFragmentLauncher() {
if (bindFragmentLayout() != 0 && fragmentLauncher == null) {
fragmentLauncher = new FragmentLauncher(this, bindFragmentLayout());
if(getTrustee()==null){
getTrustee().setFragmentLauncher(fragmentLauncher);
}
}
return fragmentLauncher;
}
......@@ -360,4 +396,16 @@ public abstract class BaseActivity extends AppCompatActivity implements IView {
}
}, ms);
}
public BaseTrustee bindTrustee() {
return null;
}
public BaseTrustee getTrustee() {
if (trustee == null) {
trustee = bindTrustee();
}
return trustee;
}
}
package com.common.base;
import android.app.Activity;
import android.content.Context;
import android.support.annotation.CheckResult;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import android.view.View;
import android.view.ViewGroup;
import com.trello.rxlifecycle2.LifecycleTransformer;
import com.trello.rxlifecycle2.RxLifecycle;
import com.trello.rxlifecycle2.android.ActivityEvent;
import com.trello.rxlifecycle2.android.RxLifecycleAndroid;
import javax.annotation.Nonnull;
import io.reactivex.Observable;
import io.reactivex.subjects.BehaviorSubject;
import tech.starwin.LibConfig;
import tech.starwin.base.BasePresenter;
import tech.starwin.mvp.IView;
import tech.starwin.utils.PresenterHoler;
import tech.starwin.utils.context_utils.FragmentLauncher;
/**
* Created by SiKang on 2019/3/12.
*/
public abstract class BaseTrustee implements IView {
private ViewGroup trustorView;
private Activity trustorActivity;
private Object unBinder;
/**
* 创建和缓存Presenter实例
*/
private PresenterHoler presenterHelper;
private FragmentLauncher fragmentLauncher;
private final BehaviorSubject<ActivityEvent> lifecycleSubject = BehaviorSubject.create();
public BaseTrustee(Activity activity, ViewGroup view) {
this.trustorActivity = activity;
this.trustorView = view;
}
protected View findViewById(@IdRes int viewId) {
return trustorView.findViewById(viewId);
}
public abstract void initView();
public void setPresenterHelper(PresenterHoler presenterHelper) {
this.presenterHelper = presenterHelper;
}
/**
* 获取Presenter
*/
public <T extends BasePresenter> T getPresenter(Class<T> clz) {
if (presenterHelper == null) {
presenterHelper = new PresenterHoler(this);
}
return presenterHelper.getPresenter(clz);
}
/**
* 生命周期托管
*/
public void onCreate() {
lifecycleSubject.onNext(ActivityEvent.CREATE);
unBinder = LibConfig.bindView(this, trustorView);
initView();
}
protected void onStart() {
lifecycleSubject.onNext(ActivityEvent.START);
}
protected void onRestart() {
}
protected void onResume() {
lifecycleSubject.onNext(ActivityEvent.RESUME);
}
protected void onPause() {
lifecycleSubject.onNext(ActivityEvent.PAUSE);
}
protected void onStop() {
lifecycleSubject.onNext(ActivityEvent.STOP);
}
protected void onDestroy() {
lifecycleSubject.onNext(ActivityEvent.DESTROY);
if (unBinder != null) {
LibConfig.unBindView(unBinder);
}
if (presenterHelper != null) {
presenterHelper.onDestory();
}
}
public void onBackPressed(){}
@Override
public void onHttpStart(String action, boolean isShowLoading) {
}
@Override
public void onHttpSuccess(String action, Object result) {
}
@Override
public void onHttpError(String action, String msg) {
}
@Override
public void onHttpFinish(String action) {
}
@Override
@NonNull
@CheckResult
public final Observable<ActivityEvent> lifecycle() {
return lifecycleSubject.hide();
}
@Override
@NonNull
@CheckResult
public final <T> LifecycleTransformer<T> bindUntilEvent(@NonNull ActivityEvent event) {
return RxLifecycle.bindUntilEvent(lifecycleSubject, event);
}
@Override
@NonNull
@CheckResult
public final <T> LifecycleTransformer<T> bindToLifecycle() {
return RxLifecycleAndroid.bindActivity(lifecycleSubject);
}
public Activity getActivity() {
return trustorActivity;
}
public ViewGroup getTrustorView() {
return trustorView;
}
public String getString(@StringRes int id) {
return getActivity().getString(id);
}
public FragmentLauncher getFragmentLauncher() {
return fragmentLauncher;
}
public void setFragmentLauncher(FragmentLauncher fragmentLauncher) {
this.fragmentLauncher = fragmentLauncher;
}
}
......@@ -92,7 +92,7 @@ public abstract class HttpObserver<T> implements Observer<T> {
return true;
// case 403:
// // 短信发送失败
// onError(Error.SERVER_ERROR, LibConfig.getContext().getString(R.string.sms_code_error));
// onError(Error.SERVER_ERROR, LibConfig.getActivity().getString(R.string.sms_code_error));
// return true;
case 409:
if (exception.response().body() != null) {
......
package tech.starwin.impl;
import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import com.common.base.BaseTrustee;
/**
* Created by SiKang on 2019/3/12.
*/
public interface OnEntrustListener {
BaseTrustee onEntrust(Activity activity, ViewGroup view, Class clz);
}
......@@ -27,6 +27,6 @@ public class EventCenterAdapter extends BaseRecyclerAdapter<ActivityInfoBean> {
@Override
public void bindData(RecyclerViewHolder holder, int position, ActivityInfoBean item) {
Glide.with(getContext()).load(item.getUrl()).into(holder.getImageView(R.id.iv_image_activity_center));
// holder.getTextView(R.id.tv_content_activity_center).setText(getContext().getString(R.string.title_activity_center));
// holder.getTextView(R.id.tv_content_activity_center).setText(getActivity().getString(R.string.title_activity_center));
}
}
......@@ -65,8 +65,8 @@ public class LoginManager {
// if (!TextUtils.isEmpty(LibConfig.LOGIN_ACTIVITY_ACTION)) {
// //跳转登录界面
// if (isActionSupport(LibConfig.getContext(), LibConfig.LOGIN_ACTIVITY_ACTION)) {
// new ActivityJumper.Builder(LibConfig.getContext(), LibConfig.LOGIN_ACTIVITY_ACTION)
// if (isActionSupport(LibConfig.getActivity(), LibConfig.LOGIN_ACTIVITY_ACTION)) {
// new ActivityJumper.Builder(LibConfig.getActivity(), LibConfig.LOGIN_ACTIVITY_ACTION)
// .build().start();
// } else {
// LogUtils.e(TAG, "找不到LoginActivity,请在build.gradle中配置正确的 ‘LOGIN_ACTIVITY_ACTION’ ");
......
......@@ -64,7 +64,7 @@ public class TrackEventHelper {
public static void logEvent(String eventName) {
//TODO - FireBase配置
//FireBase 埋点
// FirebaseAnalytics.getInstance(LibConfig.getContext()).logEvent(eventName, null);
// FirebaseAnalytics.getInstance(LibConfig.getActivity()).logEvent(eventName, null);
if (onTrackEventListener != null) {
onTrackEventListener.onActionEvent(eventName);
}
......
......@@ -114,7 +114,7 @@ public class UploadManager {
// options.put(FMAgent.OPTION_DOMAIN,LibConfig.TD_TEST_SERVER );
// options.put(FMAgent.OPTION_BLACKBOX_MAXSIZE, 5 * 1024);
// options.put(FMAgent.OPTION_PARTNER_CODE, LibConfig.TONGDUN_DEVICE_PARENT_CODE);
// FMAgent.initWithCallback(LibConfig.getContext(), FMAgent.ENV_PRODUCTION, options, new FMCallback() {
// FMAgent.initWithCallback(LibConfig.getActivity(), FMAgent.ENV_PRODUCTION, options, new FMCallback() {
// @Override
// public void onEvent(String blackbox) {
// LogUtils.d(TAG, "callback_blackbox: " + blackbox);
......
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