Commit fbff357dc0e4a257877e4ba6fc2154528c739384
1 parent
0a369345
1 修改日志输出
Showing
7 changed files
with
49 additions
and
39 deletions
app/strike/src/main/java/com/cnlive/strike/MainActivity.java
| @@ -28,7 +28,7 @@ public class MainActivity extends AppCompatActivity { | @@ -28,7 +28,7 @@ public class MainActivity extends AppCompatActivity { | ||
| 28 | findViewById(R.id.go_to).setOnClickListener(new View.OnClickListener() { | 28 | findViewById(R.id.go_to).setOnClickListener(new View.OnClickListener() { |
| 29 | @Override | 29 | @Override |
| 30 | public void onClick(View v) { | 30 | public void onClick(View v) { |
| 31 | - startActivity(new Intent(MainActivity.this, LoginActivity.class)); | 31 | + startActivity(new Intent(MainActivity.this, DemoActivity.class)); |
| 32 | // finish(); | 32 | // finish(); |
| 33 | } | 33 | } |
| 34 | }); | 34 | }); |
app/strike/src/main/java/com/cnlive/strike/MyFragment.java
| @@ -19,6 +19,7 @@ import com.cnlive.strike.network.bean.LetHimNoSeeBean; | @@ -19,6 +19,7 @@ import com.cnlive.strike.network.bean.LetHimNoSeeBean; | ||
| 19 | import com.cnlive.strike.network.bean.TestBean; | 19 | import com.cnlive.strike.network.bean.TestBean; |
| 20 | import com.me.yokeyword.fragmentation.anim.DefaultVerticalAnimator; | 20 | import com.me.yokeyword.fragmentation.anim.DefaultVerticalAnimator; |
| 21 | import com.me.yokeyword.fragmentation.anim.FragmentAnimator; | 21 | import com.me.yokeyword.fragmentation.anim.FragmentAnimator; |
| 22 | +import com.orhanobut.logger.Logger; | ||
| 22 | 23 | ||
| 23 | import java.util.HashMap; | 24 | import java.util.HashMap; |
| 24 | import java.util.Map; | 25 | import java.util.Map; |
| @@ -72,7 +73,7 @@ public class MyFragment extends BaseFragment<MyFragmentView, MyPresenter> { | @@ -72,7 +73,7 @@ public class MyFragment extends BaseFragment<MyFragmentView, MyPresenter> { | ||
| 72 | // Log.e(TAG, "onFail: "); | 73 | // Log.e(TAG, "onFail: "); |
| 73 | // } | 74 | // } |
| 74 | // }); | 75 | // }); |
| 75 | - startForResult(new MyFragment1(),1001); | 76 | + startForResult(new MyFragment1(), 1001); |
| 76 | } | 77 | } |
| 77 | }); | 78 | }); |
| 78 | baseView.findViewById(R.id.btn_test).setOnClickListener(new View.OnClickListener() { | 79 | baseView.findViewById(R.id.btn_test).setOnClickListener(new View.OnClickListener() { |
| @@ -149,8 +150,12 @@ public class MyFragment extends BaseFragment<MyFragmentView, MyPresenter> { | @@ -149,8 +150,12 @@ public class MyFragment extends BaseFragment<MyFragmentView, MyPresenter> { | ||
| 149 | @Override | 150 | @Override |
| 150 | public void onFragmentResult(int requestCode, int resultCode, Bundle data) { | 151 | public void onFragmentResult(int requestCode, int resultCode, Bundle data) { |
| 151 | super.onFragmentResult(requestCode, resultCode, data); | 152 | super.onFragmentResult(requestCode, resultCode, data); |
| 152 | - if (requestCode==1001){ | ||
| 153 | - setStatusBarColor(R.color.green,0); | 153 | + if (requestCode == 1001) { |
| 154 | + setStatusBarColor(R.color.green, 0); | ||
| 155 | + | ||
| 156 | + if (null != data) { | ||
| 157 | + logError(data.getString("test")); | ||
| 158 | + } | ||
| 154 | } | 159 | } |
| 155 | } | 160 | } |
| 156 | } | 161 | } |
app/strike/src/main/java/com/cnlive/strike/MyFragment1.java
| 1 | package com.cnlive.strike; | 1 | package com.cnlive.strike; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | +import android.os.Build; | ||
| 5 | +import android.os.Bundle; | ||
| 4 | import android.util.Log; | 6 | import android.util.Log; |
| 5 | import android.view.View; | 7 | import android.view.View; |
| 6 | 8 | ||
| @@ -24,6 +26,10 @@ public class MyFragment1 extends BaseFragment { | @@ -24,6 +26,10 @@ public class MyFragment1 extends BaseFragment { | ||
| 24 | @Override | 26 | @Override |
| 25 | protected void initView() { | 27 | protected void initView() { |
| 26 | super.initView(); | 28 | super.initView(); |
| 29 | + Bundle bundle = new Bundle(); | ||
| 30 | + bundle.putString("test", "你好"); | ||
| 31 | + setFragmentResult(1001, bundle); | ||
| 32 | + | ||
| 27 | setStatusBarColor(R.color.qmui_config_color_red, 0); | 33 | setStatusBarColor(R.color.qmui_config_color_red, 0); |
| 28 | setStatusBarTextColor(StatusBarConfig.BLACK); | 34 | setStatusBarTextColor(StatusBarConfig.BLACK); |
| 29 | baseView.findViewById(R.id.btn_test).setOnClickListener(new View.OnClickListener() { | 35 | baseView.findViewById(R.id.btn_test).setOnClickListener(new View.OnClickListener() { |
| @@ -54,5 +60,6 @@ public class MyFragment1 extends BaseFragment { | @@ -54,5 +60,6 @@ public class MyFragment1 extends BaseFragment { | ||
| 54 | }); | 60 | }); |
| 55 | } | 61 | } |
| 56 | }); | 62 | }); |
| 63 | + | ||
| 57 | } | 64 | } |
| 58 | } | 65 | } |
cloud/user/src/main/java/com/cnlive/strike/user/ui/activity/LoginActivity.java
| @@ -11,6 +11,7 @@ import androidx.fragment.app.FragmentManager; | @@ -11,6 +11,7 @@ import androidx.fragment.app.FragmentManager; | ||
| 11 | 11 | ||
| 12 | import com.alibaba.android.arouter.facade.annotation.Route; | 12 | import com.alibaba.android.arouter.facade.annotation.Route; |
| 13 | import com.cnlive.core.libs.base.frame.activity.BaseActivity; | 13 | import com.cnlive.core.libs.base.frame.activity.BaseActivity; |
| 14 | +import com.cnlive.core.libs.base.frame.fragment.BaseFragment; | ||
| 14 | import com.cnlive.core.libs.base.util.FragmentUtil; | 15 | import com.cnlive.core.libs.base.util.FragmentUtil; |
| 15 | import com.cnlive.strike.user.R; | 16 | import com.cnlive.strike.user.R; |
| 16 | import com.cnlive.strike.user.ui.fragment.QuickLoginFragment; | 17 | import com.cnlive.strike.user.ui.fragment.QuickLoginFragment; |
| @@ -28,7 +29,7 @@ public class LoginActivity extends BaseActivity { | @@ -28,7 +29,7 @@ public class LoginActivity extends BaseActivity { | ||
| 28 | public static String TAG_MSG = "tagMsg"; | 29 | public static String TAG_MSG = "tagMsg"; |
| 29 | public static String TAG_SHARE = "tagValue"; | 30 | public static String TAG_SHARE = "tagValue"; |
| 30 | public static String TAG_CLICK_AD = "clickAd"; | 31 | public static String TAG_CLICK_AD = "clickAd"; |
| 31 | - private Fragment quickLoginFragment; | 32 | + private BaseFragment quickLoginFragment; |
| 32 | private boolean fromTokenError; | 33 | private boolean fromTokenError; |
| 33 | private String tagMsg; | 34 | private String tagMsg; |
| 34 | private String shareType; | 35 | private String shareType; |
| @@ -72,11 +73,6 @@ public class LoginActivity extends BaseActivity { | @@ -72,11 +73,6 @@ public class LoginActivity extends BaseActivity { | ||
| 72 | 73 | ||
| 73 | 74 | ||
| 74 | @Override | 75 | @Override |
| 75 | - protected int getViewLayoutId() { | ||
| 76 | - return R.layout.activity_login; | ||
| 77 | - } | ||
| 78 | - | ||
| 79 | - @Override | ||
| 80 | protected void initView() { | 76 | protected void initView() { |
| 81 | fromTokenError = getIntent().getBooleanExtra(FROM_TOKEN_ERROR, false); | 77 | fromTokenError = getIntent().getBooleanExtra(FROM_TOKEN_ERROR, false); |
| 82 | tagMsg = getIntent().getStringExtra(TAG_MSG) == null ? "" : getIntent().getStringExtra(TAG_MSG); | 78 | tagMsg = getIntent().getStringExtra(TAG_MSG) == null ? "" : getIntent().getStringExtra(TAG_MSG); |
| @@ -85,10 +81,6 @@ public class LoginActivity extends BaseActivity { | @@ -85,10 +81,6 @@ public class LoginActivity extends BaseActivity { | ||
| 85 | addFragment(); | 81 | addFragment(); |
| 86 | } | 82 | } |
| 87 | 83 | ||
| 88 | - @Override | ||
| 89 | - protected void initData() { | ||
| 90 | - | ||
| 91 | - } | ||
| 92 | 84 | ||
| 93 | @Override | 85 | @Override |
| 94 | protected void onNewIntent(Intent intent) { | 86 | protected void onNewIntent(Intent intent) { |
| @@ -104,10 +96,7 @@ public class LoginActivity extends BaseActivity { | @@ -104,10 +96,7 @@ public class LoginActivity extends BaseActivity { | ||
| 104 | } else { | 96 | } else { |
| 105 | quickLoginFragment = QuickLoginFragment.newInstance(fromTokenError, tagMsg, clickAd); | 97 | quickLoginFragment = QuickLoginFragment.newInstance(fromTokenError, tagMsg, clickAd); |
| 106 | } | 98 | } |
| 107 | - | ||
| 108 | - FragmentManager fragmentManager = getSupportFragmentManager(); | ||
| 109 | - FragmentUtil fragmentUtil = new FragmentUtil(R.id.loginContent); | ||
| 110 | - fragmentUtil.changeFragment(quickLoginFragment, fragmentManager); | 99 | + loadRootFragment(quickLoginFragment); |
| 111 | } | 100 | } |
| 112 | 101 | ||
| 113 | @Override | 102 | @Override |
core/base/src/main/java/com/cnlive/core/libs/base/application/BaseApplication.java
| @@ -4,7 +4,9 @@ import android.app.Application; | @@ -4,7 +4,9 @@ import android.app.Application; | ||
| 4 | 4 | ||
| 5 | import com.cnlive.strike.base.BuildConfig; | 5 | import com.cnlive.strike.base.BuildConfig; |
| 6 | import com.orhanobut.logger.AndroidLogAdapter; | 6 | import com.orhanobut.logger.AndroidLogAdapter; |
| 7 | +import com.orhanobut.logger.FormatStrategy; | ||
| 7 | import com.orhanobut.logger.Logger; | 8 | import com.orhanobut.logger.Logger; |
| 9 | +import com.orhanobut.logger.PrettyFormatStrategy; | ||
| 8 | 10 | ||
| 9 | public class BaseApplication extends Application { | 11 | public class BaseApplication extends Application { |
| 10 | private static BaseApplication instance; | 12 | private static BaseApplication instance; |
| @@ -13,7 +15,14 @@ public class BaseApplication extends Application { | @@ -13,7 +15,14 @@ public class BaseApplication extends Application { | ||
| 13 | public void onCreate() { | 15 | public void onCreate() { |
| 14 | super.onCreate(); | 16 | super.onCreate(); |
| 15 | instance = this; | 17 | instance = this; |
| 16 | - Logger.addLogAdapter(new AndroidLogAdapter() { | 18 | + FormatStrategy formatStrategy = PrettyFormatStrategy.newBuilder() |
| 19 | +// .showThreadInfo(true) // (Optional) Whether to show thread info or not. Default true | ||
| 20 | +// .methodCount(5) // (Optional) How many method line to show. Default 2 | ||
| 21 | +// .methodOffset(0) // (Optional) Hides internal method calls up to offset. Default 5 | ||
| 22 | +// .logStrategy(customLog) // (Optional) Changes the log strategy to print out. Default LogCat | ||
| 23 | + .tag("TAG") // (Optional) Global tag for every log. Default PRETTY_LOGGER | ||
| 24 | + .build(); | ||
| 25 | + Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy) { | ||
| 17 | @Override | 26 | @Override |
| 18 | public boolean isLoggable(int priority, String tag) { | 27 | public boolean isLoggable(int priority, String tag) { |
| 19 | return AppConfig.isDebug(); | 28 | return AppConfig.isDebug(); |
core/base/src/main/java/com/cnlive/core/libs/base/frame/activity/BaseActivity.java
| @@ -705,24 +705,24 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -705,24 +705,24 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 705 | // } | 705 | // } |
| 706 | 706 | ||
| 707 | 707 | ||
| 708 | - public void logError(Object info) { | 708 | + public void logError(String info) { |
| 709 | Logger.e(TAG, info); | 709 | Logger.e(TAG, info); |
| 710 | } | 710 | } |
| 711 | 711 | ||
| 712 | - public void logDebug(Object info) { | ||
| 713 | - Logger.d(TAG, info); | 712 | + public void logDebug(String info) { |
| 713 | + Logger.d(info); | ||
| 714 | } | 714 | } |
| 715 | 715 | ||
| 716 | - public void logWarn(Object info) { | ||
| 717 | - Logger.w(TAG, info); | 716 | + public void logWarn(String info) { |
| 717 | + Logger.w(info); | ||
| 718 | } | 718 | } |
| 719 | 719 | ||
| 720 | - public void logInfo(Object info) { | ||
| 721 | - Logger.i(TAG, info); | 720 | + public void logInfo(String info) { |
| 721 | + Logger.i(info); | ||
| 722 | } | 722 | } |
| 723 | 723 | ||
| 724 | - public void logVerbose(Object info) { | ||
| 725 | - Logger.v(TAG, info); | 724 | + public void logVerbose(String info) { |
| 725 | + Logger.v(info); | ||
| 726 | } | 726 | } |
| 727 | 727 | ||
| 728 | public void logJson(String json) { | 728 | public void logJson(String json) { |
| @@ -1020,7 +1020,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -1020,7 +1020,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 1020 | @Override | 1020 | @Override |
| 1021 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 1021 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
| 1022 | super.onActivityResult(requestCode, resultCode, data); | 1022 | super.onActivityResult(requestCode, resultCode, data); |
| 1023 | - if (null!=getSupportFragmentManager()&&null != getSupportFragmentManager().getFragments()) { | 1023 | + if (null != getSupportFragmentManager() && null != getSupportFragmentManager().getFragments()) { |
| 1024 | for (Fragment fragment : getSupportFragmentManager().getFragments()) { | 1024 | for (Fragment fragment : getSupportFragmentManager().getFragments()) { |
| 1025 | if (null != fragment) { | 1025 | if (null != fragment) { |
| 1026 | fragment.onActivityResult(requestCode, resultCode, data); | 1026 | fragment.onActivityResult(requestCode, resultCode, data); |
core/base/src/main/java/com/cnlive/core/libs/base/frame/fragment/BaseFragment.java
| @@ -357,24 +357,24 @@ public abstract class BaseFragment<V extends BaseView, P extends BasePresenter<V | @@ -357,24 +357,24 @@ public abstract class BaseFragment<V extends BaseView, P extends BasePresenter<V | ||
| 357 | } | 357 | } |
| 358 | 358 | ||
| 359 | /*************************************log******************************************/ | 359 | /*************************************log******************************************/ |
| 360 | - public void logError(Object info) { | ||
| 361 | - Logger.e(TAG, info); | 360 | + public void logError(String info) { |
| 361 | + Logger.e(info); | ||
| 362 | } | 362 | } |
| 363 | 363 | ||
| 364 | - public void logDebug(Object info) { | ||
| 365 | - Logger.d(TAG, info); | 364 | + public void logDebug(String info) { |
| 365 | + Logger.d(info); | ||
| 366 | } | 366 | } |
| 367 | 367 | ||
| 368 | - public void logWarn(Object info) { | ||
| 369 | - Logger.w(TAG, info); | 368 | + public void logWarn(String info) { |
| 369 | + Logger.w(info); | ||
| 370 | } | 370 | } |
| 371 | 371 | ||
| 372 | - public void logInfo(Object info) { | ||
| 373 | - Logger.i(TAG, info); | 372 | + public void logInfo(String info) { |
| 373 | + Logger.i(info); | ||
| 374 | } | 374 | } |
| 375 | 375 | ||
| 376 | - public void logVerbose(Object info) { | ||
| 377 | - Logger.v(TAG, info); | 376 | + public void logVerbose(String info) { |
| 377 | + Logger.v( info); | ||
| 378 | } | 378 | } |
| 379 | 379 | ||
| 380 | public void logJson(String json) { | 380 | public void logJson(String json) { |