Commit 92ef3449bb43de39e7065521b0627df57c220733
Merge branch 'master' of bj.gitlab.cnlive.com:cnlive-team/newModuleStrike
Showing
23 changed files
with
471 additions
and
129 deletions
app/strike/build.gradle
| @@ -39,6 +39,10 @@ android { | @@ -39,6 +39,10 @@ android { | ||
| 39 | dexOptions { | 39 | dexOptions { |
| 40 | javaMaxHeapSize '4g' | 40 | javaMaxHeapSize '4g' |
| 41 | } | 41 | } |
| 42 | + | ||
| 43 | + dataBinding { | ||
| 44 | + enabled true | ||
| 45 | + } | ||
| 42 | buildTypes { | 46 | buildTypes { |
| 43 | debug { | 47 | debug { |
| 44 | signingConfig signingConfigs.debugConfig | 48 | signingConfig signingConfigs.debugConfig |
| @@ -169,6 +173,7 @@ dependencies { | @@ -169,6 +173,7 @@ dependencies { | ||
| 169 | implementation project(path: ':core:network') | 173 | implementation project(path: ':core:network') |
| 170 | implementation project(path: ':core:base') | 174 | implementation project(path: ':core:base') |
| 171 | implementation project(path: ':cloud:user') | 175 | implementation project(path: ':cloud:user') |
| 176 | + implementation project(path: ':cloud:pay') | ||
| 172 | 177 | ||
| 173 | implementation project(path: ':core:imageload') | 178 | implementation project(path: ':core:imageload') |
| 174 | implementation project(path: ':module:xiaojiasoundbox') | 179 | implementation project(path: ':module:xiaojiasoundbox') |
app/strike/src/main/java/com/cnlive/strike/MainActivity.java
| @@ -34,6 +34,7 @@ public class MainActivity extends AppCompatActivity { | @@ -34,6 +34,7 @@ public class MainActivity extends AppCompatActivity { | ||
| 34 | public void onClick(View v) { | 34 | public void onClick(View v) { |
| 35 | if (TextUtils.isEmpty(UserService.getUid(MainActivity.this))) { | 35 | if (TextUtils.isEmpty(UserService.getUid(MainActivity.this))) { |
| 36 | startActivity(new Intent(MainActivity.this, LoginActivity.class)); | 36 | startActivity(new Intent(MainActivity.this, LoginActivity.class)); |
| 37 | +// finish(); | ||
| 37 | } else { | 38 | } else { |
| 38 | startActivity(new Intent(MainActivity.this, MyActivity.class)); | 39 | startActivity(new Intent(MainActivity.this, MyActivity.class)); |
| 39 | } | 40 | } |
app/strike/src/main/java/com/cnlive/strike/MyActivity.java
| @@ -3,29 +3,85 @@ package com.cnlive.strike; | @@ -3,29 +3,85 @@ package com.cnlive.strike; | ||
| 3 | 3 | ||
| 4 | import android.content.Intent; | 4 | import android.content.Intent; |
| 5 | import android.text.TextUtils; | 5 | import android.text.TextUtils; |
| 6 | +import android.view.View; | ||
| 6 | 7 | ||
| 7 | import com.alibaba.android.arouter.facade.annotation.Route; | 8 | import com.alibaba.android.arouter.facade.annotation.Route; |
| 8 | import com.cnlive.core.libs.base.frame.activity.BaseActivity; | 9 | import com.cnlive.core.libs.base.frame.activity.BaseActivity; |
| 10 | +import com.cnlive.core.network.HttpConn; | ||
| 11 | +import com.cnlive.core.network.NetCallBack; | ||
| 12 | +import com.cnlive.core.network.model.BaseResult; | ||
| 13 | +import com.cnlive.libs.wjjpay.model.GroupBalanceInfo; | ||
| 14 | +import com.cnlive.libs.wjjpay.pay.WjjPay; | ||
| 9 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; | 15 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 10 | import com.cnlive.moudle.pedometer.ui.activity.RunLineActivity; | 16 | import com.cnlive.moudle.pedometer.ui.activity.RunLineActivity; |
| 17 | +import com.cnlive.strike.databinding.ActivityMyBinding; | ||
| 11 | import com.cnlive.strike.user.auth.UserService; | 18 | import com.cnlive.strike.user.auth.UserService; |
| 12 | import com.cnlive.strike.xiaojiaspeaker.commonInfo.XiaoJIaCommInfo; | 19 | import com.cnlive.strike.xiaojiaspeaker.commonInfo.XiaoJIaCommInfo; |
| 13 | import com.cnlive.strike.xiaojiaspeaker.ui.activity.AllDeviceActivity; | 20 | import com.cnlive.strike.xiaojiaspeaker.ui.activity.AllDeviceActivity; |
| 21 | +import com.cnlive.strike.xiaojiaspeaker.util.QMUITipDialogUtil; | ||
| 14 | 22 | ||
| 15 | @Route(path = "/strick/MyActivity") | 23 | @Route(path = "/strick/MyActivity") |
| 16 | public class MyActivity extends BaseActivity { | 24 | public class MyActivity extends BaseActivity { |
| 25 | + public ActivityMyBinding binding; | ||
| 17 | 26 | ||
| 18 | @Override | 27 | @Override |
| 19 | - protected int getViewLayoutId() { | 28 | + protected int getBindLayoutId() { |
| 20 | return R.layout.activity_my; | 29 | return R.layout.activity_my; |
| 21 | } | 30 | } |
| 22 | 31 | ||
| 23 | @Override | 32 | @Override |
| 33 | + protected void initBindingData() { | ||
| 34 | + super.initBindingData(); | ||
| 35 | + binding = (ActivityMyBinding) baseBinding; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + @Override | ||
| 24 | protected void initView() { | 39 | protected void initView() { |
| 25 | // getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MyFragment()).commitAllowingStateLoss(); | 40 | // getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MyFragment()).commitAllowingStateLoss(); |
| 26 | initXiaoJiaSoundBoxData(); | 41 | initXiaoJiaSoundBoxData(); |
| 27 | - startActivity(new Intent(MyActivity.this, RunLineActivity.class)); | ||
| 28 | - finish(); | 42 | +// startActivity(new Intent(MyActivity.this, RunLineActivity.class)); |
| 43 | +// finish(); | ||
| 44 | + binding.btnChange.setOnClickListener(new View.OnClickListener() { | ||
| 45 | + @Override | ||
| 46 | + public void onClick(View v) { | ||
| 47 | + startActivity(new Intent(MyActivity.this, RunLineActivity.class)); | ||
| 48 | + | ||
| 49 | +// WjjPay.passwordIsExisting(UserService.getUid(me), new NetCallBack<BaseResult<GroupBalanceInfo>>() { | ||
| 50 | +// @Override | ||
| 51 | +// public void onRequestState(int state) { | ||
| 52 | +// | ||
| 53 | +// } | ||
| 54 | +// | ||
| 55 | +// @Override | ||
| 56 | +// public void onSuccess(BaseResult<GroupBalanceInfo> data) { | ||
| 57 | +// QMUITipDialogUtil.successDialog(me, data.getErrorCode() + "" + data.getData().getBalance(), 5); | ||
| 58 | +// } | ||
| 59 | +// | ||
| 60 | +// @Override | ||
| 61 | +// public void onFailure(String errCode, String errMsg) { | ||
| 62 | +// QMUITipDialogUtil.failedDialog(me, errMsg, 3); | ||
| 63 | +// } | ||
| 64 | +// }); | ||
| 65 | +// WjjPay.setPassword(UserService.getUid(me), "123456", new NetCallBack<BaseResult>() { | ||
| 66 | +// @Override | ||
| 67 | +// public void onRequestState(int state) { | ||
| 68 | +// if (state == HttpConn.ON_START) { | ||
| 69 | +// QMUITipDialogUtil.loadingDialog(me, "修改中", true); | ||
| 70 | +// } | ||
| 71 | +// } | ||
| 72 | +// | ||
| 73 | +// @Override | ||
| 74 | +// public void onSuccess(BaseResult data) { | ||
| 75 | +// QMUITipDialogUtil.successDialog(me, data.getMessage(), 5); | ||
| 76 | +// } | ||
| 77 | +// | ||
| 78 | +// @Override | ||
| 79 | +// public void onFailure(String errCode, String errMsg) { | ||
| 80 | +// QMUITipDialogUtil.failedDialog(me, errMsg, 3); | ||
| 81 | +// } | ||
| 82 | +// }); | ||
| 83 | + } | ||
| 84 | + }); | ||
| 29 | } | 85 | } |
| 30 | 86 | ||
| 31 | @Override | 87 | @Override |
app/strike/src/main/res/layout/activity_my.xml
| 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | - xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| 4 | - xmlns:tools="http://schemas.android.com/tools" | ||
| 5 | - android:layout_width="match_parent" | ||
| 6 | - android:layout_height="match_parent" | ||
| 7 | - tools:context="com.cnlive.strike.MyActivity"> | 2 | +<layout> |
| 8 | 3 | ||
| 9 | - <RelativeLayout | ||
| 10 | - android:id="@+id/fragment_container" | 4 | + <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| 5 | + xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| 6 | + xmlns:tools="http://schemas.android.com/tools" | ||
| 11 | android:layout_width="match_parent" | 7 | android:layout_width="match_parent" |
| 12 | - android:layout_height="match_parent"> | 8 | + android:layout_height="match_parent" |
| 9 | + tools:context="com.cnlive.strike.MyActivity"> | ||
| 13 | 10 | ||
| 14 | - <TextView | ||
| 15 | - android:layout_width="wrap_content" | ||
| 16 | - android:layout_height="wrap_content" | ||
| 17 | - android:text="sfwerfwef" /> | 11 | + <RelativeLayout |
| 12 | + android:id="@+id/fragment_container" | ||
| 13 | + android:layout_width="match_parent" | ||
| 14 | + android:layout_height="match_parent"> | ||
| 15 | + | ||
| 16 | + <TextView | ||
| 17 | + android:layout_width="wrap_content" | ||
| 18 | + android:layout_height="wrap_content" | ||
| 19 | + android:text="sfwerfwef" /> | ||
| 20 | + | ||
| 21 | + <Button | ||
| 22 | + android:id="@+id/btn_change" | ||
| 23 | + android:layout_width="wrap_content" | ||
| 24 | + android:layout_height="wrap_content" | ||
| 25 | + android:text="修改支付密码" /> | ||
| 26 | + </RelativeLayout> | ||
| 18 | </RelativeLayout> | 27 | </RelativeLayout> |
| 19 | -</RelativeLayout> | 28 | +</layout> |
| 20 | \ No newline at end of file | 29 | \ No newline at end of file |
cloud/user/src/main/AndroidManifest.xml
| @@ -39,7 +39,6 @@ | @@ -39,7 +39,6 @@ | ||
| 39 | android:name="WEIBO_CHANNEL" | 39 | android:name="WEIBO_CHANNEL" |
| 40 | android:value="weibo" /> | 40 | android:value="weibo" /> |
| 41 | 41 | ||
| 42 | - <activity android:name="com.cnlive.strike.moudle.user.ui.activity.MainTestActivity" /> | ||
| 43 | <activity | 42 | <activity |
| 44 | android:name=".ui.activity.LoginActivity" | 43 | android:name=".ui.activity.LoginActivity" |
| 45 | android:configChanges="keyboardHidden|screenSize|orientation|smallestScreenSize|screenLayout" | 44 | android:configChanges="keyboardHidden|screenSize|orientation|smallestScreenSize|screenLayout" |
| @@ -50,12 +49,6 @@ | @@ -50,12 +49,6 @@ | ||
| 50 | <action android:name="android.accounts.AccountAuthenticator" /> | 49 | <action android:name="android.accounts.AccountAuthenticator" /> |
| 51 | </intent-filter> | 50 | </intent-filter> |
| 52 | </activity> | 51 | </activity> |
| 53 | - | ||
| 54 | - <activity | ||
| 55 | - android:name="com.cnlive.strike.moudle.user.ui.activity.BindPhoneNumberActivity" | ||
| 56 | - android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation" | ||
| 57 | - android:launchMode="singleTop" | ||
| 58 | - android:screenOrientation="portrait" /> | ||
| 59 | <activity | 52 | <activity |
| 60 | android:name=".ui.activity.FirstLoginActivity" | 53 | android:name=".ui.activity.FirstLoginActivity" |
| 61 | android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation" | 54 | android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation" |
cloud/user/src/main/java/com/cnlive/strike/user/sms/SmsVerifyCatcher.java
| @@ -27,6 +27,9 @@ import androidx.core.app.ActivityCompat; | @@ -27,6 +27,9 @@ import androidx.core.app.ActivityCompat; | ||
| 27 | import androidx.core.content.ContextCompat; | 27 | import androidx.core.content.ContextCompat; |
| 28 | import androidx.fragment.app.Fragment; | 28 | import androidx.fragment.app.Fragment; |
| 29 | 29 | ||
| 30 | +import com.cnlive.core.libs.base.frame.fragment.BaseFragment; | ||
| 31 | +import com.cnlive.core.libs.base.interfaces.OnPermissionResponseListener; | ||
| 32 | + | ||
| 30 | /** | 33 | /** |
| 31 | * Created by Anton Bevza on 8/15/16. | 34 | * Created by Anton Bevza on 8/15/16. |
| 32 | */ | 35 | */ |
| @@ -35,7 +38,7 @@ public class SmsVerifyCatcher { | @@ -35,7 +38,7 @@ public class SmsVerifyCatcher { | ||
| 35 | public static int PERMISSION_REQUEST_CODE = 12; | 38 | public static int PERMISSION_REQUEST_CODE = 12; |
| 36 | 39 | ||
| 37 | private Activity activity; | 40 | private Activity activity; |
| 38 | - private Fragment fragment; | 41 | + private BaseFragment fragment; |
| 39 | private OnSmsCatchListener<String> onSmsCatchListener; | 42 | private OnSmsCatchListener<String> onSmsCatchListener; |
| 40 | private SmsReceiver smsReceiver; | 43 | private SmsReceiver smsReceiver; |
| 41 | private String phoneNumber; | 44 | private String phoneNumber; |
| @@ -49,13 +52,17 @@ public class SmsVerifyCatcher { | @@ -49,13 +52,17 @@ public class SmsVerifyCatcher { | ||
| 49 | smsReceiver.setCallback(this.onSmsCatchListener); | 52 | smsReceiver.setCallback(this.onSmsCatchListener); |
| 50 | } | 53 | } |
| 51 | 54 | ||
| 52 | - public SmsVerifyCatcher(Activity activity, Fragment fragment, OnSmsCatchListener<String> onSmsCatchListener) { | 55 | + public SmsVerifyCatcher(Activity activity, BaseFragment fragment, OnSmsCatchListener<String> onSmsCatchListener) { |
| 53 | this(activity, onSmsCatchListener); | 56 | this(activity, onSmsCatchListener); |
| 54 | this.fragment = fragment; | 57 | this.fragment = fragment; |
| 58 | + | ||
| 55 | } | 59 | } |
| 56 | 60 | ||
| 57 | //For fragments | 61 | //For fragments |
| 58 | - public static boolean isStoragePermissionGranted(Activity activity, Fragment fragment) { | 62 | + public static boolean isStoragePermissionGranted(Activity activity, BaseFragment fragment) { |
| 63 | + if (null==fragment){ | ||
| 64 | + return false; | ||
| 65 | + } | ||
| 59 | if (Build.VERSION.SDK_INT >= 23) { | 66 | if (Build.VERSION.SDK_INT >= 23) { |
| 60 | if (ContextCompat.checkSelfPermission(activity, Manifest.permission.RECEIVE_SMS) | 67 | if (ContextCompat.checkSelfPermission(activity, Manifest.permission.RECEIVE_SMS) |
| 61 | == PackageManager.PERMISSION_GRANTED && | 68 | == PackageManager.PERMISSION_GRANTED && |
cloud/user/src/main/java/com/cnlive/strike/user/ui/activity/LoginActivity.java
| @@ -15,6 +15,8 @@ import com.cnlive.core.libs.base.frame.fragment.BaseFragment; | @@ -15,6 +15,8 @@ import com.cnlive.core.libs.base.frame.fragment.BaseFragment; | ||
| 15 | import com.cnlive.core.libs.base.util.FragmentUtil; | 15 | import com.cnlive.core.libs.base.util.FragmentUtil; |
| 16 | import com.cnlive.strike.user.R; | 16 | import com.cnlive.strike.user.R; |
| 17 | import com.cnlive.strike.user.ui.fragment.QuickLoginFragment; | 17 | import com.cnlive.strike.user.ui.fragment.QuickLoginFragment; |
| 18 | +import com.me.yokeyword.fragmentation.anim.DefaultHorizontalAnimator; | ||
| 19 | +import com.me.yokeyword.fragmentation.anim.FragmentAnimator; | ||
| 18 | 20 | ||
| 19 | /** | 21 | /** |
| 20 | * @author Lynn | 22 | * @author Lynn |
| @@ -24,7 +26,6 @@ import com.cnlive.strike.user.ui.fragment.QuickLoginFragment; | @@ -24,7 +26,6 @@ import com.cnlive.strike.user.ui.fragment.QuickLoginFragment; | ||
| 24 | @Route(path = LoginActivity.PATH) | 26 | @Route(path = LoginActivity.PATH) |
| 25 | public class LoginActivity extends BaseActivity { | 27 | public class LoginActivity extends BaseActivity { |
| 26 | public static final String PATH = "/cloud/user/ui/activity/login"; | 28 | public static final String PATH = "/cloud/user/ui/activity/login"; |
| 27 | - | ||
| 28 | public static String FROM_TOKEN_ERROR = "from_token_error"; | 29 | public static String FROM_TOKEN_ERROR = "from_token_error"; |
| 29 | public static String TAG_MSG = "tagMsg"; | 30 | public static String TAG_MSG = "tagMsg"; |
| 30 | public static String TAG_SHARE = "tagValue"; | 31 | public static String TAG_SHARE = "tagValue"; |
| @@ -71,13 +72,17 @@ public class LoginActivity extends BaseActivity { | @@ -71,13 +72,17 @@ public class LoginActivity extends BaseActivity { | ||
| 71 | context.startActivity(intent); | 72 | context.startActivity(intent); |
| 72 | } | 73 | } |
| 73 | 74 | ||
| 74 | - | ||
| 75 | @Override | 75 | @Override |
| 76 | - protected void initView() { | 76 | + protected void initParam() { |
| 77 | + super.initParam(); | ||
| 77 | fromTokenError = getIntent().getBooleanExtra(FROM_TOKEN_ERROR, false); | 78 | fromTokenError = getIntent().getBooleanExtra(FROM_TOKEN_ERROR, false); |
| 78 | tagMsg = getIntent().getStringExtra(TAG_MSG) == null ? "" : getIntent().getStringExtra(TAG_MSG); | 79 | tagMsg = getIntent().getStringExtra(TAG_MSG) == null ? "" : getIntent().getStringExtra(TAG_MSG); |
| 79 | shareType = getIntent().getStringExtra(TAG_SHARE); | 80 | shareType = getIntent().getStringExtra(TAG_SHARE); |
| 80 | clickAd = getIntent().getBooleanExtra(TAG_CLICK_AD, false); | 81 | clickAd = getIntent().getBooleanExtra(TAG_CLICK_AD, false); |
| 82 | + } | ||
| 83 | + | ||
| 84 | + @Override | ||
| 85 | + protected void initView() { | ||
| 81 | addFragment(); | 86 | addFragment(); |
| 82 | } | 87 | } |
| 83 | 88 | ||
| @@ -105,4 +110,5 @@ public class LoginActivity extends BaseActivity { | @@ -105,4 +110,5 @@ public class LoginActivity extends BaseActivity { | ||
| 105 | if (quickLoginFragment != null) | 110 | if (quickLoginFragment != null) |
| 106 | quickLoginFragment.onRequestPermissionsResult(requestCode, permissions, grantResults); | 111 | quickLoginFragment.onRequestPermissionsResult(requestCode, permissions, grantResults); |
| 107 | } | 112 | } |
| 113 | + | ||
| 108 | } | 114 | } |
core/base/src/main/java/com/cnlive/core/libs/base/frame/activity/BaseActivity.java
| @@ -87,9 +87,9 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -87,9 +87,9 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 87 | public BaseActivity me;//本类 | 87 | public BaseActivity me;//本类 |
| 88 | private Bundle savedInstanceState; | 88 | private Bundle savedInstanceState; |
| 89 | private OnPermissionResponseListener onPermissionResponseListener; //权限申请回调 | 89 | private OnPermissionResponseListener onPermissionResponseListener; //权限申请回调 |
| 90 | - private int DEFAULT_REQUEST_CODE_PERMISSION = 0x00099;//默认权限请求码 | 90 | + private final int DEFAULT_REQUEST_CODE_PERMISSION = 0x00099;//默认权限请求码 |
| 91 | private int USER_SET_REQUEST_CODE_PERMISSION = -0x00099;//用户设置的权限请求码 | 91 | private int USER_SET_REQUEST_CODE_PERMISSION = -0x00099;//用户设置的权限请求码 |
| 92 | - private String defaultDefinePermissionTip = "需要必要的权限才可以正常使用该功能,您已拒绝获得该权限。\n如果需要重新授权,您可以点击“设置”按钮进入系统设置进行授权";//默认拒绝的权限提示语 | 92 | + private final String defaultDefinePermissionTip = "需要必要的权限才可以正常使用该功能,您已拒绝获得该权限。\n如果需要重新授权,您可以点击“设置”按钮进入系统设置进行授权";//默认拒绝的权限提示语 |
| 93 | private String userSetDefinePermissionTip = "";//用户设置的权限提示语 | 93 | private String userSetDefinePermissionTip = "";//用户设置的权限提示语 |
| 94 | // private SwipeBackActivityHelper mHelper;//侧滑返回 | 94 | // private SwipeBackActivityHelper mHelper;//侧滑返回 |
| 95 | private boolean isOpenSwipBack = false; | 95 | private boolean isOpenSwipBack = false; |
| @@ -99,6 +99,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -99,6 +99,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 99 | private final SwipeBackActivityDelegate mSwipeDelegate = new SwipeBackActivityDelegate(this); | 99 | private final SwipeBackActivityDelegate mSwipeDelegate = new SwipeBackActivityDelegate(this); |
| 100 | private boolean isDefinePermissionCloseActivity = false; | 100 | private boolean isDefinePermissionCloseActivity = false; |
| 101 | private boolean isUserClickAllowBtn = false;//用户是否点击允许按钮 | 101 | private boolean isUserClickAllowBtn = false;//用户是否点击允许按钮 |
| 102 | + private boolean isShowRefuseDialog = true;//是否显示拒绝提示框 | ||
| 102 | private String[] userSetPermission; | 103 | private String[] userSetPermission; |
| 103 | 104 | ||
| 104 | @Override | 105 | @Override |
| @@ -281,6 +282,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -281,6 +282,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 281 | isUserClickAllowBtn = false; | 282 | isUserClickAllowBtn = false; |
| 282 | int requestCode = DEFAULT_REQUEST_CODE_PERMISSION; | 283 | int requestCode = DEFAULT_REQUEST_CODE_PERMISSION; |
| 283 | String tip = defaultDefinePermissionTip; | 284 | String tip = defaultDefinePermissionTip; |
| 285 | + boolean isShowDialog = isShowRefuseDialog; | ||
| 284 | if (null != onPermissionResponseListener && null != userSetPermission) { | 286 | if (null != onPermissionResponseListener && null != userSetPermission) { |
| 285 | if (null != userSetDefinePermissionTip) { | 287 | if (null != userSetDefinePermissionTip) { |
| 286 | tip = userSetDefinePermissionTip; | 288 | tip = userSetDefinePermissionTip; |
| @@ -289,7 +291,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -289,7 +291,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 289 | requestCode = USER_SET_REQUEST_CODE_PERMISSION; | 291 | requestCode = USER_SET_REQUEST_CODE_PERMISSION; |
| 290 | } | 292 | } |
| 291 | //开始请求 | 293 | //开始请求 |
| 292 | - requestPermission(requestCode, tip, isDefinePermissionCloseActivity, userSetPermission, onPermissionResponseListener); | 294 | + requestPermission(requestCode, tip, isDefinePermissionCloseActivity, userSetPermission, isShowDialog, onPermissionResponseListener); |
| 293 | } | 295 | } |
| 294 | } | 296 | } |
| 295 | } | 297 | } |
| @@ -482,6 +484,20 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -482,6 +484,20 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 482 | } | 484 | } |
| 483 | } | 485 | } |
| 484 | 486 | ||
| 487 | + public void requestPermission(String[] permissions, boolean isShowRefuseDialog, OnPermissionResponseListener | ||
| 488 | + onPermissionResponseListener) { | ||
| 489 | + this.onPermissionResponseListener = onPermissionResponseListener; | ||
| 490 | + this.isShowRefuseDialog = isShowRefuseDialog; | ||
| 491 | + if (checkPermissions(permissions)) { | ||
| 492 | + if (onPermissionResponseListener != null) { | ||
| 493 | + onPermissionResponseListener.onSuccess(permissions); | ||
| 494 | + } | ||
| 495 | + } else { | ||
| 496 | + List<String> needPermissions = getDeniedPermissions(permissions); | ||
| 497 | + ActivityCompat.requestPermissions(this, needPermissions.toArray(new String[needPermissions.size()]), DEFAULT_REQUEST_CODE_PERMISSION); | ||
| 498 | + } | ||
| 499 | + } | ||
| 500 | + | ||
| 485 | /** | 501 | /** |
| 486 | * 请求权限 | 502 | * 请求权限 |
| 487 | * <p> | 503 | * <p> |
| @@ -491,6 +507,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -491,6 +507,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 491 | * @param permissions 请求的权限 | 507 | * @param permissions 请求的权限 |
| 492 | * @param onPermissionResponseListener 回调监听器 | 508 | * @param onPermissionResponseListener 回调监听器 |
| 493 | */ | 509 | */ |
| 510 | + | ||
| 494 | public void requestPermission(boolean isDefineActivity, String[] permissions, OnPermissionResponseListener | 511 | public void requestPermission(boolean isDefineActivity, String[] permissions, OnPermissionResponseListener |
| 495 | onPermissionResponseListener) { | 512 | onPermissionResponseListener) { |
| 496 | this.onPermissionResponseListener = onPermissionResponseListener; | 513 | this.onPermissionResponseListener = onPermissionResponseListener; |
| @@ -505,6 +522,21 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -505,6 +522,21 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 505 | } | 522 | } |
| 506 | } | 523 | } |
| 507 | 524 | ||
| 525 | + public void requestPermission(boolean isDefineActivity, String[] permissions, boolean isShowRefuseDialog, OnPermissionResponseListener | ||
| 526 | + onPermissionResponseListener) { | ||
| 527 | + this.onPermissionResponseListener = onPermissionResponseListener; | ||
| 528 | + this.isDefinePermissionCloseActivity = isDefineActivity; | ||
| 529 | + this.isShowRefuseDialog = isShowRefuseDialog; | ||
| 530 | + if (checkPermissions(permissions)) { | ||
| 531 | + if (onPermissionResponseListener != null) { | ||
| 532 | + onPermissionResponseListener.onSuccess(permissions); | ||
| 533 | + } | ||
| 534 | + } else { | ||
| 535 | + List<String> needPermissions = getDeniedPermissions(permissions); | ||
| 536 | + ActivityCompat.requestPermissions(this, needPermissions.toArray(new String[needPermissions.size()]), DEFAULT_REQUEST_CODE_PERMISSION); | ||
| 537 | + } | ||
| 538 | + } | ||
| 539 | + | ||
| 508 | /** | 540 | /** |
| 509 | * 请求权限 | 541 | * 请求权限 |
| 510 | * <p> | 542 | * <p> |
| @@ -514,6 +546,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -514,6 +546,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 514 | * @param permissions 请求的权限 | 546 | * @param permissions 请求的权限 |
| 515 | * @param onPermissionResponseListener 回调监听器 | 547 | * @param onPermissionResponseListener 回调监听器 |
| 516 | */ | 548 | */ |
| 549 | + | ||
| 517 | public void requestPermission(String defineTip, boolean isDefineActivity, String[] permissions, OnPermissionResponseListener | 550 | public void requestPermission(String defineTip, boolean isDefineActivity, String[] permissions, OnPermissionResponseListener |
| 518 | onPermissionResponseListener) { | 551 | onPermissionResponseListener) { |
| 519 | this.isDefinePermissionCloseActivity = isDefineActivity; | 552 | this.isDefinePermissionCloseActivity = isDefineActivity; |
| @@ -530,6 +563,23 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -530,6 +563,23 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 530 | } | 563 | } |
| 531 | } | 564 | } |
| 532 | 565 | ||
| 566 | + public void requestPermission(String defineTip, boolean isDefineActivity, String[] permissions, boolean isShowRefuseDialog, OnPermissionResponseListener | ||
| 567 | + onPermissionResponseListener) { | ||
| 568 | + this.isDefinePermissionCloseActivity = isDefineActivity; | ||
| 569 | + this.userSetDefinePermissionTip = defineTip; | ||
| 570 | + this.onPermissionResponseListener = onPermissionResponseListener; | ||
| 571 | + this.isShowRefuseDialog = isShowRefuseDialog; | ||
| 572 | + this.userSetPermission = permissions; | ||
| 573 | + if (checkPermissions(permissions)) { | ||
| 574 | + if (onPermissionResponseListener != null) { | ||
| 575 | + onPermissionResponseListener.onSuccess(permissions); | ||
| 576 | + } | ||
| 577 | + } else { | ||
| 578 | + List<String> needPermissions = getDeniedPermissions(permissions); | ||
| 579 | + ActivityCompat.requestPermissions(this, needPermissions.toArray(new String[needPermissions.size()]), DEFAULT_REQUEST_CODE_PERMISSION); | ||
| 580 | + } | ||
| 581 | + } | ||
| 582 | + | ||
| 533 | /** | 583 | /** |
| 534 | * 请求权限 | 584 | * 请求权限 |
| 535 | * <p> | 585 | * <p> |
| @@ -553,6 +603,21 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -553,6 +603,21 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 553 | } | 603 | } |
| 554 | } | 604 | } |
| 555 | 605 | ||
| 606 | + public void requestPermission(String defineTip, String[] permissions, boolean isShowRefuseDialog, OnPermissionResponseListener | ||
| 607 | + onPermissionResponseListener) { | ||
| 608 | + this.userSetDefinePermissionTip = defineTip; | ||
| 609 | + this.onPermissionResponseListener = onPermissionResponseListener; | ||
| 610 | + this.isShowRefuseDialog = isShowRefuseDialog; | ||
| 611 | + if (checkPermissions(permissions)) { | ||
| 612 | + if (onPermissionResponseListener != null) { | ||
| 613 | + onPermissionResponseListener.onSuccess(permissions); | ||
| 614 | + } | ||
| 615 | + } else { | ||
| 616 | + List<String> needPermissions = getDeniedPermissions(permissions); | ||
| 617 | + ActivityCompat.requestPermissions(this, needPermissions.toArray(new String[needPermissions.size()]), DEFAULT_REQUEST_CODE_PERMISSION); | ||
| 618 | + } | ||
| 619 | + } | ||
| 620 | + | ||
| 556 | /** | 621 | /** |
| 557 | * 自定义权限申请码 | 622 | * 自定义权限申请码 |
| 558 | * | 623 | * |
| @@ -575,6 +640,22 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -575,6 +640,22 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 575 | } | 640 | } |
| 576 | } | 641 | } |
| 577 | 642 | ||
| 643 | + public void requestPermission(int requestCode, boolean isDefineActivity, String[] | ||
| 644 | + permissions, boolean isShowRefuseDialog, OnPermissionResponseListener onPermissionResponseListener) { | ||
| 645 | + this.onPermissionResponseListener = onPermissionResponseListener; | ||
| 646 | + this.USER_SET_REQUEST_CODE_PERMISSION = requestCode; | ||
| 647 | + this.isDefinePermissionCloseActivity = isDefineActivity; | ||
| 648 | + this.isShowRefuseDialog = isShowRefuseDialog; | ||
| 649 | + if (checkPermissions(permissions)) { | ||
| 650 | + if (onPermissionResponseListener != null) { | ||
| 651 | + onPermissionResponseListener.onSuccess(permissions); | ||
| 652 | + } | ||
| 653 | + } else { | ||
| 654 | + List<String> needPermissions = getDeniedPermissions(permissions); | ||
| 655 | + ActivityCompat.requestPermissions(this, needPermissions.toArray(new String[needPermissions.size()]), USER_SET_REQUEST_CODE_PERMISSION); | ||
| 656 | + } | ||
| 657 | + } | ||
| 658 | + | ||
| 578 | /** | 659 | /** |
| 579 | * 自定义权限申请码 | 660 | * 自定义权限申请码 |
| 580 | * | 661 | * |
| @@ -596,6 +677,21 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -596,6 +677,21 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 596 | } | 677 | } |
| 597 | } | 678 | } |
| 598 | 679 | ||
| 680 | + public void requestPermission(int requestCode, String[] | ||
| 681 | + permissions, boolean isShowRefuseDialog, OnPermissionResponseListener onPermissionResponseListener) { | ||
| 682 | + this.onPermissionResponseListener = onPermissionResponseListener; | ||
| 683 | + this.USER_SET_REQUEST_CODE_PERMISSION = requestCode; | ||
| 684 | + this.isShowRefuseDialog = isShowRefuseDialog; | ||
| 685 | + if (checkPermissions(permissions)) { | ||
| 686 | + if (onPermissionResponseListener != null) { | ||
| 687 | + onPermissionResponseListener.onSuccess(permissions); | ||
| 688 | + } | ||
| 689 | + } else { | ||
| 690 | + List<String> needPermissions = getDeniedPermissions(permissions); | ||
| 691 | + ActivityCompat.requestPermissions(this, needPermissions.toArray(new String[needPermissions.size()]), USER_SET_REQUEST_CODE_PERMISSION); | ||
| 692 | + } | ||
| 693 | + } | ||
| 694 | + | ||
| 599 | /** | 695 | /** |
| 600 | * 自定义权限申请码和提示信息 | 696 | * 自定义权限申请码和提示信息 |
| 601 | * | 697 | * |
| @@ -619,6 +715,23 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -619,6 +715,23 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 619 | } | 715 | } |
| 620 | } | 716 | } |
| 621 | 717 | ||
| 718 | + public void requestPermission(int requestCode, String defineTip, boolean isDefineActivity, String[] | ||
| 719 | + permissions, boolean isShowRefuseDialog, OnPermissionResponseListener onPermissionResponseListener) { | ||
| 720 | + this.onPermissionResponseListener = onPermissionResponseListener; | ||
| 721 | + this.USER_SET_REQUEST_CODE_PERMISSION = requestCode; | ||
| 722 | + this.isDefinePermissionCloseActivity = isDefineActivity; | ||
| 723 | + this.userSetDefinePermissionTip = defineTip; | ||
| 724 | + this.isShowRefuseDialog = isShowRefuseDialog; | ||
| 725 | + if (checkPermissions(permissions)) { | ||
| 726 | + if (onPermissionResponseListener != null) { | ||
| 727 | + onPermissionResponseListener.onSuccess(permissions); | ||
| 728 | + } | ||
| 729 | + } else { | ||
| 730 | + List<String> needPermissions = getDeniedPermissions(permissions); | ||
| 731 | + ActivityCompat.requestPermissions(this, needPermissions.toArray(new String[needPermissions.size()]), USER_SET_REQUEST_CODE_PERMISSION); | ||
| 732 | + } | ||
| 733 | + } | ||
| 734 | + | ||
| 622 | /** | 735 | /** |
| 623 | * 自定义权限申请码和提示信息 | 736 | * 自定义权限申请码和提示信息 |
| 624 | * | 737 | * |
| @@ -641,6 +754,22 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -641,6 +754,22 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 641 | } | 754 | } |
| 642 | } | 755 | } |
| 643 | 756 | ||
| 757 | + public void requestPermission(int requestCode, String defineTip, String[] | ||
| 758 | + permissions, boolean isShowRefuseDialog, OnPermissionResponseListener onPermissionResponseListener) { | ||
| 759 | + this.onPermissionResponseListener = onPermissionResponseListener; | ||
| 760 | + this.USER_SET_REQUEST_CODE_PERMISSION = requestCode; | ||
| 761 | + this.userSetDefinePermissionTip = defineTip; | ||
| 762 | + this.isShowRefuseDialog = isShowRefuseDialog; | ||
| 763 | + if (checkPermissions(permissions)) { | ||
| 764 | + if (onPermissionResponseListener != null) { | ||
| 765 | + onPermissionResponseListener.onSuccess(permissions); | ||
| 766 | + } | ||
| 767 | + } else { | ||
| 768 | + List<String> needPermissions = getDeniedPermissions(permissions); | ||
| 769 | + ActivityCompat.requestPermissions(this, needPermissions.toArray(new String[needPermissions.size()]), USER_SET_REQUEST_CODE_PERMISSION); | ||
| 770 | + } | ||
| 771 | + } | ||
| 772 | + | ||
| 644 | /** | 773 | /** |
| 645 | * 自定义权限申请码和提示信息 | 774 | * 自定义权限申请码和提示信息 |
| 646 | * 可传入string字符串 | 775 | * 可传入string字符串 |
| @@ -665,6 +794,23 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -665,6 +794,23 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 665 | } | 794 | } |
| 666 | } | 795 | } |
| 667 | 796 | ||
| 797 | + public void requestPermission(int requestCode, @StringRes int defineTip, boolean isDefineActivity, String[] | ||
| 798 | + permissions, boolean isShowRefuseDialog, OnPermissionResponseListener onPermissionResponseListener) { | ||
| 799 | + this.onPermissionResponseListener = onPermissionResponseListener; | ||
| 800 | + this.USER_SET_REQUEST_CODE_PERMISSION = requestCode; | ||
| 801 | + this.userSetDefinePermissionTip = getResources().getString(defineTip); | ||
| 802 | + this.isDefinePermissionCloseActivity = isDefineActivity; | ||
| 803 | + this.isShowRefuseDialog = isShowRefuseDialog; | ||
| 804 | + if (checkPermissions(permissions)) { | ||
| 805 | + if (onPermissionResponseListener != null) { | ||
| 806 | + onPermissionResponseListener.onSuccess(permissions); | ||
| 807 | + } | ||
| 808 | + } else { | ||
| 809 | + List<String> needPermissions = getDeniedPermissions(permissions); | ||
| 810 | + ActivityCompat.requestPermissions(this, needPermissions.toArray(new String[needPermissions.size()]), USER_SET_REQUEST_CODE_PERMISSION); | ||
| 811 | + } | ||
| 812 | + } | ||
| 813 | + | ||
| 668 | /** | 814 | /** |
| 669 | * 自定义权限申请码和提示信息 | 815 | * 自定义权限申请码和提示信息 |
| 670 | * 可传入string字符串 | 816 | * 可传入string字符串 |
| @@ -688,6 +834,22 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -688,6 +834,22 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 688 | } | 834 | } |
| 689 | } | 835 | } |
| 690 | 836 | ||
| 837 | + public void requestPermission(int requestCode, @StringRes int defineTip, String[] | ||
| 838 | + permissions, boolean isShowRefuseDialog, OnPermissionResponseListener onPermissionResponseListener) { | ||
| 839 | + this.onPermissionResponseListener = onPermissionResponseListener; | ||
| 840 | + this.USER_SET_REQUEST_CODE_PERMISSION = requestCode; | ||
| 841 | + this.userSetDefinePermissionTip = getResources().getString(defineTip); | ||
| 842 | + this.isShowRefuseDialog = isShowRefuseDialog; | ||
| 843 | + if (checkPermissions(permissions)) { | ||
| 844 | + if (onPermissionResponseListener != null) { | ||
| 845 | + onPermissionResponseListener.onSuccess(permissions); | ||
| 846 | + } | ||
| 847 | + } else { | ||
| 848 | + List<String> needPermissions = getDeniedPermissions(permissions); | ||
| 849 | + ActivityCompat.requestPermissions(this, needPermissions.toArray(new String[needPermissions.size()]), USER_SET_REQUEST_CODE_PERMISSION); | ||
| 850 | + } | ||
| 851 | + } | ||
| 852 | + | ||
| 691 | /** | 853 | /** |
| 692 | * 获取权限集中需要申请权限的列表 | 854 | * 获取权限集中需要申请权限的列表 |
| 693 | * | 855 | * |
| @@ -717,17 +879,34 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -717,17 +879,34 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 717 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, | 879 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, |
| 718 | @NonNull int[] grantResults) { | 880 | @NonNull int[] grantResults) { |
| 719 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); | 881 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); |
| 882 | + if (null != getSupportFragmentManager() && null != getSupportFragmentManager().getFragments()) { | ||
| 883 | + for (Fragment fragment : getSupportFragmentManager().getFragments()) { | ||
| 884 | + if (null != fragment) { | ||
| 885 | + fragment.onRequestPermissionsResult(requestCode, permissions, grantResults); | ||
| 886 | + } | ||
| 887 | + } | ||
| 888 | + } | ||
| 720 | //默认权限申请码 | 889 | //默认权限申请码 |
| 721 | if (requestCode == DEFAULT_REQUEST_CODE_PERMISSION) { | 890 | if (requestCode == DEFAULT_REQUEST_CODE_PERMISSION) { |
| 722 | if (verifyPermissions(grantResults)) { | 891 | if (verifyPermissions(grantResults)) { |
| 723 | if (onPermissionResponseListener != null) { | 892 | if (onPermissionResponseListener != null) { |
| 724 | onPermissionResponseListener.onSuccess(permissions); | 893 | onPermissionResponseListener.onSuccess(permissions); |
| 725 | } | 894 | } |
| 895 | + //重置显示值 | ||
| 896 | + resetPermissionConfig(); | ||
| 726 | } else { | 897 | } else { |
| 727 | if (onPermissionResponseListener != null) { | 898 | if (onPermissionResponseListener != null) { |
| 728 | onPermissionResponseListener.onFail(); | 899 | onPermissionResponseListener.onFail(); |
| 729 | } | 900 | } |
| 730 | - showTipsDialog(); | 901 | + if (isShowRefuseDialog) { |
| 902 | + showTipsDialog(); | ||
| 903 | + } else { | ||
| 904 | + if (isDefinePermissionCloseActivity) { | ||
| 905 | + finish(); | ||
| 906 | + } | ||
| 907 | + //重置显示值 | ||
| 908 | + resetPermissionConfig(); | ||
| 909 | + } | ||
| 731 | } | 910 | } |
| 732 | } | 911 | } |
| 733 | //用户自定义权限申请码 | 912 | //用户自定义权限申请码 |
| @@ -736,17 +915,36 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -736,17 +915,36 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 736 | if (onPermissionResponseListener != null) { | 915 | if (onPermissionResponseListener != null) { |
| 737 | onPermissionResponseListener.onSuccess(permissions); | 916 | onPermissionResponseListener.onSuccess(permissions); |
| 738 | } | 917 | } |
| 918 | + //重置显示值 | ||
| 919 | + resetPermissionConfig(); | ||
| 739 | } else { | 920 | } else { |
| 740 | if (onPermissionResponseListener != null) { | 921 | if (onPermissionResponseListener != null) { |
| 741 | onPermissionResponseListener.onFail(); | 922 | onPermissionResponseListener.onFail(); |
| 742 | } | 923 | } |
| 743 | - showTipsDialog(); | 924 | + if (isShowRefuseDialog) { |
| 925 | + showTipsDialog(); | ||
| 926 | + } else { | ||
| 927 | + if (isDefinePermissionCloseActivity) { | ||
| 928 | + finish(); | ||
| 929 | + } | ||
| 930 | + //重置显示值 | ||
| 931 | + resetPermissionConfig(); | ||
| 932 | + } | ||
| 744 | } | 933 | } |
| 745 | - //重置用户提示语 | ||
| 746 | - userSetDefinePermissionTip = ""; | 934 | + |
| 747 | } | 935 | } |
| 748 | } | 936 | } |
| 749 | 937 | ||
| 938 | + private void resetPermissionConfig() { | ||
| 939 | + isShowRefuseDialog = true;//默认显示权限拒绝提示框 | ||
| 940 | + isUserClickAllowBtn = false;//默认用户没有点击允许按钮 | ||
| 941 | + USER_SET_REQUEST_CODE_PERMISSION = -0x00099;//默认用户没有自己设置权限请求码 | ||
| 942 | + userSetDefinePermissionTip = "";//默认没有设置提示语 | ||
| 943 | + isDefinePermissionCloseActivity = false;//默认不允许关闭当前窗口 | ||
| 944 | + userSetPermission = null;//重置用户设置权限 | ||
| 945 | + onPermissionResponseListener = null; | ||
| 946 | + } | ||
| 947 | + | ||
| 750 | /** | 948 | /** |
| 751 | * 检测所有的权限是否都已授权 | 949 | * 检测所有的权限是否都已授权 |
| 752 | * | 950 | * |
| @@ -813,17 +1011,9 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -813,17 +1011,9 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 813 | @Override | 1011 | @Override |
| 814 | public void onClick(DialogInterface dialog, int which) { | 1012 | public void onClick(DialogInterface dialog, int which) { |
| 815 | if (isDefinePermissionCloseActivity) { | 1013 | if (isDefinePermissionCloseActivity) { |
| 816 | - isDefinePermissionCloseActivity = false; | ||
| 817 | - //先判断当前是否是多个activity | ||
| 818 | -// if (null != getSupportFragmentManager().getFragments() && getSupportFragmentManager().getFragments().size() > 1) { | ||
| 819 | -// //移除最上层的 | ||
| 820 | -// pop(); | ||
| 821 | -// } else { | ||
| 822 | finish(); | 1014 | finish(); |
| 823 | -// } | ||
| 824 | - | ||
| 825 | } | 1015 | } |
| 826 | - | 1016 | + resetPermissionConfig(); |
| 827 | } | 1017 | } |
| 828 | }) | 1018 | }) |
| 829 | .setPositiveButton("去设置", new DialogInterface.OnClickListener() { | 1019 | .setPositiveButton("去设置", new DialogInterface.OnClickListener() { |
| @@ -997,6 +1187,10 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -997,6 +1187,10 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 997 | mDelegate.loadRootFragment(R.id.root_container, toFragment); | 1187 | mDelegate.loadRootFragment(R.id.root_container, toFragment); |
| 998 | } | 1188 | } |
| 999 | 1189 | ||
| 1190 | + public void loadRootFragment(@NonNull ISupportFragment toFragment, boolean allowAnimation) { | ||
| 1191 | + mDelegate.loadRootFragment(R.id.root_container, toFragment, allowAnimation); | ||
| 1192 | + } | ||
| 1193 | + | ||
| 1000 | /** | 1194 | /** |
| 1001 | * 加载根Fragment, 即Activity内的第一个Fragment 或 Fragment内的第一个子Fragment | 1195 | * 加载根Fragment, 即Activity内的第一个Fragment 或 Fragment内的第一个子Fragment |
| 1002 | * | 1196 | * |
| @@ -1007,6 +1201,16 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -1007,6 +1201,16 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 1007 | mDelegate.loadRootFragment(containerId, toFragment); | 1201 | mDelegate.loadRootFragment(containerId, toFragment); |
| 1008 | } | 1202 | } |
| 1009 | 1203 | ||
| 1204 | + /** | ||
| 1205 | + * 加载根Fragment, 即Activity内的第一个Fragment 或 Fragment内的第一个子Fragment | ||
| 1206 | + * | ||
| 1207 | + * @param containerId 容器id | ||
| 1208 | + * @param toFragment 目标Fragment | ||
| 1209 | + */ | ||
| 1210 | + public void loadRootFragment(int containerId, @NonNull ISupportFragment toFragment, boolean allowAnimation) { | ||
| 1211 | + mDelegate.loadRootFragment(containerId, toFragment, allowAnimation); | ||
| 1212 | + } | ||
| 1213 | + | ||
| 1010 | public void loadRootFragment(int containerId, ISupportFragment toFragment, boolean addToBackStack, boolean allowAnimation) { | 1214 | public void loadRootFragment(int containerId, ISupportFragment toFragment, boolean addToBackStack, boolean allowAnimation) { |
| 1011 | mDelegate.loadRootFragment(containerId, toFragment, addToBackStack, allowAnimation); | 1215 | mDelegate.loadRootFragment(containerId, toFragment, addToBackStack, allowAnimation); |
| 1012 | } | 1216 | } |
| @@ -1019,6 +1223,13 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -1019,6 +1223,13 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 1019 | } | 1223 | } |
| 1020 | 1224 | ||
| 1021 | /** | 1225 | /** |
| 1226 | + * 加载多个同级根Fragment,类似Wechat, QQ主页的场景 | ||
| 1227 | + */ | ||
| 1228 | + public void loadMultipleRootFragment(int showPosition, ISupportFragment... toFragments) { | ||
| 1229 | + mDelegate.loadMultipleRootFragment(R.id.root_container, showPosition, toFragments); | ||
| 1230 | + } | ||
| 1231 | + | ||
| 1232 | + /** | ||
| 1022 | * show一个Fragment,hide其他同栈所有Fragment | 1233 | * show一个Fragment,hide其他同栈所有Fragment |
| 1023 | * 使用该方法时,要确保同级栈内无多余的Fragment,(只有通过loadMultipleRootFragment()载入的Fragment) | 1234 | * 使用该方法时,要确保同级栈内无多余的Fragment,(只有通过loadMultipleRootFragment()载入的Fragment) |
| 1024 | * <p> | 1235 | * <p> |
core/base/src/main/java/com/cnlive/core/libs/base/frame/fragment/BaseFragment.java
| @@ -268,51 +268,95 @@ public abstract class BaseFragment<V extends BaseView, P extends BasePresenter<V | @@ -268,51 +268,95 @@ public abstract class BaseFragment<V extends BaseView, P extends BasePresenter<V | ||
| 268 | me.requestPermission(permissions, onPermissionResponseListener); | 268 | me.requestPermission(permissions, onPermissionResponseListener); |
| 269 | } | 269 | } |
| 270 | 270 | ||
| 271 | + public void requestPermission(String[] permissions, boolean isShowRefuseDialog, OnPermissionResponseListener onPermissionResponseListener) { | ||
| 272 | + me.requestPermission(permissions, isShowRefuseDialog, onPermissionResponseListener); | ||
| 273 | + } | ||
| 274 | + | ||
| 271 | //权限申请 | 275 | //权限申请 |
| 272 | public void requestPermission(boolean isDefineActivity, String[] permissions, OnPermissionResponseListener onPermissionResponseListener) { | 276 | public void requestPermission(boolean isDefineActivity, String[] permissions, OnPermissionResponseListener onPermissionResponseListener) { |
| 273 | me.requestPermission(isDefineActivity, permissions, onPermissionResponseListener); | 277 | me.requestPermission(isDefineActivity, permissions, onPermissionResponseListener); |
| 274 | } | 278 | } |
| 275 | 279 | ||
| 280 | + public void requestPermission(boolean isDefineActivity, String[] permissions, boolean isShowRefuseDialog, OnPermissionResponseListener onPermissionResponseListener) { | ||
| 281 | + me.requestPermission(isDefineActivity, permissions, isShowRefuseDialog, onPermissionResponseListener); | ||
| 282 | + } | ||
| 283 | + | ||
| 276 | //权限申请 | 284 | //权限申请 |
| 277 | public void requestPermission(int requestCode, String[] permissions, OnPermissionResponseListener onPermissionResponseListener) { | 285 | public void requestPermission(int requestCode, String[] permissions, OnPermissionResponseListener onPermissionResponseListener) { |
| 278 | me.requestPermission(requestCode, permissions, onPermissionResponseListener); | 286 | me.requestPermission(requestCode, permissions, onPermissionResponseListener); |
| 279 | } | 287 | } |
| 280 | 288 | ||
| 289 | + public void requestPermission(int requestCode, String[] permissions, boolean isShowRefuseDialog, OnPermissionResponseListener onPermissionResponseListener) { | ||
| 290 | + me.requestPermission(requestCode, permissions, isShowRefuseDialog, onPermissionResponseListener); | ||
| 291 | + } | ||
| 292 | + | ||
| 281 | //权限申请 | 293 | //权限申请 |
| 282 | public void requestPermission(int requestCode, boolean isDefineActivity, String[] permissions, OnPermissionResponseListener onPermissionResponseListener) { | 294 | public void requestPermission(int requestCode, boolean isDefineActivity, String[] permissions, OnPermissionResponseListener onPermissionResponseListener) { |
| 283 | me.requestPermission(requestCode, isDefineActivity, permissions, onPermissionResponseListener); | 295 | me.requestPermission(requestCode, isDefineActivity, permissions, onPermissionResponseListener); |
| 284 | } | 296 | } |
| 285 | 297 | ||
| 298 | + public void requestPermission(int requestCode, boolean isDefineActivity, String[] permissions, boolean isShowRefuseDialog, OnPermissionResponseListener onPermissionResponseListener) { | ||
| 299 | + me.requestPermission(requestCode, isDefineActivity, permissions, isShowRefuseDialog, onPermissionResponseListener); | ||
| 300 | + } | ||
| 301 | + | ||
| 286 | //权限申请 | 302 | //权限申请 |
| 287 | public void requestPermission(int requestCode, String defineTip, String[] permissions, OnPermissionResponseListener onPermissionResponseListener) { | 303 | public void requestPermission(int requestCode, String defineTip, String[] permissions, OnPermissionResponseListener onPermissionResponseListener) { |
| 288 | me.requestPermission(requestCode, defineTip, permissions, onPermissionResponseListener); | 304 | me.requestPermission(requestCode, defineTip, permissions, onPermissionResponseListener); |
| 289 | } | 305 | } |
| 290 | 306 | ||
| 307 | + public void requestPermission(int requestCode, String defineTip, String[] permissions, boolean isShowRefuseDialog, OnPermissionResponseListener onPermissionResponseListener) { | ||
| 308 | + me.requestPermission(requestCode, defineTip, permissions, isShowRefuseDialog, onPermissionResponseListener); | ||
| 309 | + } | ||
| 310 | + | ||
| 291 | //权限申请 | 311 | //权限申请 |
| 292 | public void requestPermission(int requestCode, String defineTip, boolean isDefineActivity, String[] permissions, OnPermissionResponseListener onPermissionResponseListener) { | 312 | public void requestPermission(int requestCode, String defineTip, boolean isDefineActivity, String[] permissions, OnPermissionResponseListener onPermissionResponseListener) { |
| 293 | me.requestPermission(requestCode, defineTip, isDefineActivity, permissions, onPermissionResponseListener); | 313 | me.requestPermission(requestCode, defineTip, isDefineActivity, permissions, onPermissionResponseListener); |
| 294 | } | 314 | } |
| 295 | 315 | ||
| 316 | + public void requestPermission(int requestCode, String defineTip, boolean isDefineActivity, String[] permissions, boolean isShowRefuseDialog, OnPermissionResponseListener onPermissionResponseListener) { | ||
| 317 | + me.requestPermission(requestCode, defineTip, isDefineActivity, permissions, isShowRefuseDialog, onPermissionResponseListener); | ||
| 318 | + } | ||
| 319 | + | ||
| 296 | public void requestPermission(String defineTip, String[] permissions, OnPermissionResponseListener | 320 | public void requestPermission(String defineTip, String[] permissions, OnPermissionResponseListener |
| 297 | onPermissionResponseListener) { | 321 | onPermissionResponseListener) { |
| 298 | me.requestPermission(defineTip, permissions, onPermissionResponseListener); | 322 | me.requestPermission(defineTip, permissions, onPermissionResponseListener); |
| 299 | } | 323 | } |
| 300 | 324 | ||
| 325 | + public void requestPermission(String defineTip, String[] permissions, boolean isShowRefuseDialog, OnPermissionResponseListener | ||
| 326 | + onPermissionResponseListener) { | ||
| 327 | + me.requestPermission(defineTip, permissions, isShowRefuseDialog, onPermissionResponseListener); | ||
| 328 | + } | ||
| 329 | + | ||
| 301 | public void requestPermission(String defineTip, boolean isDefineActivity, String[] permissions, OnPermissionResponseListener | 330 | public void requestPermission(String defineTip, boolean isDefineActivity, String[] permissions, OnPermissionResponseListener |
| 302 | onPermissionResponseListener) { | 331 | onPermissionResponseListener) { |
| 303 | me.requestPermission(defineTip, isDefineActivity, permissions, onPermissionResponseListener); | 332 | me.requestPermission(defineTip, isDefineActivity, permissions, onPermissionResponseListener); |
| 304 | } | 333 | } |
| 305 | 334 | ||
| 335 | + public void requestPermission(String defineTip, boolean isDefineActivity, String[] permissions, boolean isShowRefuseDialog, OnPermissionResponseListener | ||
| 336 | + onPermissionResponseListener) { | ||
| 337 | + me.requestPermission(defineTip, isDefineActivity, permissions, isShowRefuseDialog, onPermissionResponseListener); | ||
| 338 | + } | ||
| 339 | + | ||
| 306 | public void requestPermission(int requestCode, @StringRes int defineTip, String[] | 340 | public void requestPermission(int requestCode, @StringRes int defineTip, String[] |
| 307 | permissions, OnPermissionResponseListener onPermissionResponseListener) { | 341 | permissions, OnPermissionResponseListener onPermissionResponseListener) { |
| 308 | me.requestPermission(requestCode, defineTip, permissions, onPermissionResponseListener); | 342 | me.requestPermission(requestCode, defineTip, permissions, onPermissionResponseListener); |
| 309 | } | 343 | } |
| 310 | 344 | ||
| 345 | + public void requestPermission(int requestCode, @StringRes int defineTip, String[] | ||
| 346 | + permissions, boolean isShowRefuseDialog, OnPermissionResponseListener onPermissionResponseListener) { | ||
| 347 | + me.requestPermission(requestCode, defineTip, permissions, isShowRefuseDialog, onPermissionResponseListener); | ||
| 348 | + } | ||
| 349 | + | ||
| 311 | public void requestPermission(int requestCode, @StringRes int defineTip, boolean isDefineActivity, String[] | 350 | public void requestPermission(int requestCode, @StringRes int defineTip, boolean isDefineActivity, String[] |
| 312 | permissions, OnPermissionResponseListener onPermissionResponseListener) { | 351 | permissions, OnPermissionResponseListener onPermissionResponseListener) { |
| 313 | me.requestPermission(requestCode, defineTip, isDefineActivity, permissions, onPermissionResponseListener); | 352 | me.requestPermission(requestCode, defineTip, isDefineActivity, permissions, onPermissionResponseListener); |
| 314 | } | 353 | } |
| 315 | 354 | ||
| 355 | + public void requestPermission(int requestCode, @StringRes int defineTip, boolean isDefineActivity, String[] | ||
| 356 | + permissions, boolean isShowRefuseDialog, OnPermissionResponseListener onPermissionResponseListener) { | ||
| 357 | + me.requestPermission(requestCode, defineTip, isDefineActivity, permissions, isShowRefuseDialog, onPermissionResponseListener); | ||
| 358 | + } | ||
| 359 | + | ||
| 316 | //多权限检查 | 360 | //多权限检查 |
| 317 | public boolean checkPermissions(String[] permissions) { | 361 | public boolean checkPermissions(String[] permissions) { |
| 318 | return me.checkPermissions(permissions); | 362 | return me.checkPermissions(permissions); |
core/base/src/main/java/com/me/yokeyword/fragmentation/SupportActivityDelegate.java
| @@ -192,6 +192,10 @@ public class SupportActivityDelegate { | @@ -192,6 +192,10 @@ public class SupportActivityDelegate { | ||
| 192 | loadRootFragment(containerId, toFragment, true, false); | 192 | loadRootFragment(containerId, toFragment, true, false); |
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | + public void loadRootFragment(int containerId, ISupportFragment toFragment, boolean allowAnimation) { | ||
| 196 | + loadRootFragment(containerId, toFragment, true, allowAnimation); | ||
| 197 | + } | ||
| 198 | + | ||
| 195 | public void loadRootFragment(int containerId, ISupportFragment toFragment, boolean addToBackStack, boolean allowAnimation) { | 199 | public void loadRootFragment(int containerId, ISupportFragment toFragment, boolean addToBackStack, boolean allowAnimation) { |
| 196 | mTransactionDelegate.loadRootTransaction(getSupportFragmentManager(), containerId, toFragment, addToBackStack, allowAnimation); | 200 | mTransactionDelegate.loadRootTransaction(getSupportFragmentManager(), containerId, toFragment, addToBackStack, allowAnimation); |
| 197 | } | 201 | } |
core/network/build.gradle
| @@ -31,4 +31,6 @@ dependencies { | @@ -31,4 +31,6 @@ dependencies { | ||
| 31 | testImplementation 'junit:junit:4.12' | 31 | testImplementation 'junit:junit:4.12' |
| 32 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' | 32 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' |
| 33 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | 33 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' |
| 34 | + //七牛上传 | ||
| 35 | + implementation "com.qiniu:qiniu-android-sdk:$rootProject.qiniuAndroidSdk" | ||
| 34 | } | 36 | } |
core/network/src/main/java/com/cnlive/core/network/NetBuilder.java
| 1 | package com.cnlive.core.network; | 1 | package com.cnlive.core.network; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | +import com.cnlive.core.network.interceptor.NetPPEncryptInterceptor; | ||
| 5 | +import com.cnlive.core.network.interceptor.NetPPPayEncryptInterceptor; | ||
| 4 | import com.cnlive.core.network.interceptor.SignEncryptInterceptor; | 6 | import com.cnlive.core.network.interceptor.SignEncryptInterceptor; |
| 5 | import com.cnlive.core.network.request.HttpConfig; | 7 | import com.cnlive.core.network.request.HttpConfig; |
| 6 | 8 | ||
| @@ -65,6 +67,12 @@ public class NetBuilder<NetService> { | @@ -65,6 +67,12 @@ public class NetBuilder<NetService> { | ||
| 65 | if (interceptor instanceof SignEncryptInterceptor) { | 67 | if (interceptor instanceof SignEncryptInterceptor) { |
| 66 | isAdd = true; | 68 | isAdd = true; |
| 67 | break; | 69 | break; |
| 70 | + } else if (interceptor instanceof NetPPEncryptInterceptor) { | ||
| 71 | + isAdd = true; | ||
| 72 | + break; | ||
| 73 | + } else if (interceptor instanceof NetPPPayEncryptInterceptor) { | ||
| 74 | + isAdd = true; | ||
| 75 | + break; | ||
| 68 | } | 76 | } |
| 69 | } | 77 | } |
| 70 | if (!isAdd) { | 78 | if (!isAdd) { |
core/network/src/main/java/com/cnlive/core/network/interceptor/DESEncryptInterceptor.java
| 1 | package com.cnlive.core.network.interceptor; | 1 | package com.cnlive.core.network.interceptor; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | -import com.cnlive.core.network.util.SignUtil; | ||
| 5 | import com.cnlive.core.libs.base.application.AppConfig; | 4 | import com.cnlive.core.libs.base.application.AppConfig; |
| 5 | +import com.cnlive.core.network.util.SignUtil; | ||
| 6 | import com.cnlive.libs.encipher.CNLiveEncipher; | 6 | import com.cnlive.libs.encipher.CNLiveEncipher; |
| 7 | 7 | ||
| 8 | import java.io.IOException; | 8 | import java.io.IOException; |
core/network/src/main/java/com/cnlive/core/network/interceptor/NetPPPayEncryptInterceptor.java
| @@ -6,99 +6,97 @@ import com.cnlive.core.network.util.SignUtil; | @@ -6,99 +6,97 @@ import com.cnlive.core.network.util.SignUtil; | ||
| 6 | 6 | ||
| 7 | import java.io.IOException; | 7 | import java.io.IOException; |
| 8 | import java.util.HashMap; | 8 | import java.util.HashMap; |
| 9 | +import java.util.Iterator; | ||
| 9 | import java.util.Map; | 10 | import java.util.Map; |
| 10 | 11 | ||
| 11 | import okhttp3.FormBody; | 12 | import okhttp3.FormBody; |
| 12 | -import okhttp3.HttpUrl; | ||
| 13 | import okhttp3.Interceptor; | 13 | import okhttp3.Interceptor; |
| 14 | import okhttp3.MultipartBody; | 14 | import okhttp3.MultipartBody; |
| 15 | import okhttp3.Request; | 15 | import okhttp3.Request; |
| 16 | -import okhttp3.RequestBody; | ||
| 17 | import okhttp3.Response; | 16 | import okhttp3.Response; |
| 18 | 17 | ||
| 19 | public class NetPPPayEncryptInterceptor implements Interceptor { | 18 | public class NetPPPayEncryptInterceptor implements Interceptor { |
| 20 | - @Override | ||
| 21 | - public Response intercept(Chain chain) throws IOException { | ||
| 22 | - Request request = chain.request(); | ||
| 23 | - | ||
| 24 | - if (request.body() instanceof FormBody) { | ||
| 25 | - //处理方式 1 | ||
| 26 | - Map<String, String> parameter = new HashMap<>(); | ||
| 27 | - | ||
| 28 | - FormBody body = ((FormBody) request.body()); | ||
| 29 | - FormBody.Builder builder = new FormBody.Builder(); | 19 | + public NetPPPayEncryptInterceptor() { |
| 20 | + } | ||
| 30 | 21 | ||
| 31 | - for (int i = 0; i < body.size(); i++) { | ||
| 32 | - parameter.put(body.name(i), body.value(i)); | 22 | + public Response intercept(Chain var1) throws IOException { |
| 23 | + Request var2 = var1.request(); | ||
| 24 | + Map.Entry var7; | ||
| 25 | + FormBody.Builder var11; | ||
| 26 | + Iterator var13; | ||
| 27 | + FormBody var14; | ||
| 28 | + Request var15; | ||
| 29 | + if (var2.body() instanceof FormBody) { | ||
| 30 | + HashMap var8 = new HashMap(); | ||
| 31 | + FormBody var9 = (FormBody)var2.body(); | ||
| 32 | + var11 = new FormBody.Builder(); | ||
| 33 | + | ||
| 34 | + for(int var16 = 0; var16 < var9.size(); ++var16) { | ||
| 35 | + var8.put(var9.name(var16), var9.value(var16)); | ||
| 33 | } | 36 | } |
| 34 | 37 | ||
| 35 | - for (Map.Entry<String, String> entity : SignUtil.getNetPPPaySignString(parameter).entrySet()) { | ||
| 36 | - builder.addEncoded(entity.getKey(), entity.getValue()); | ||
| 37 | - } | 38 | + var13 = SignUtil.getNetPPPaySignString(var8).entrySet().iterator(); |
| 38 | 39 | ||
| 39 | - RequestBody newBody = builder.build(); | 40 | + while(var13.hasNext()) { |
| 41 | + var7 = (Map.Entry)var13.next(); | ||
| 42 | + var11.addEncoded((String)var7.getKey(), (String)var7.getValue()); | ||
| 43 | + } | ||
| 40 | 44 | ||
| 41 | - Request newRequest = request.newBuilder() | ||
| 42 | - .method(request.method(), newBody) | ||
| 43 | - .url(request.url()) | ||
| 44 | - .build(); | ||
| 45 | - return chain.proceed(newRequest); | ||
| 46 | - } else if (request.body() instanceof MultipartBody) { | ||
| 47 | - //处理方式 2 (暂时不签名) | 45 | + var14 = var11.build(); |
| 46 | + var15 = var2.newBuilder().method(var2.method(), var14).url(var2.url()).build(); | ||
| 47 | + return var1.proceed(var15); | ||
| 48 | + } else if (var2.body() instanceof MultipartBody) { | ||
| 49 | + return var1.proceed(var2); | ||
| 48 | } else { | 50 | } else { |
| 49 | - if ("POST".equals(request.method())) { | ||
| 50 | - //处理方式 3 | ||
| 51 | - HttpUrl.Builder authorizedUrlBuilder = request.url().newBuilder(); | ||
| 52 | - | ||
| 53 | - Map<String, String> parameter = new HashMap<>(); | ||
| 54 | - | ||
| 55 | - for (String key : request.url().queryParameterNames()) { | ||
| 56 | - parameter.put(key, request.url().queryParameter(key)); | ||
| 57 | - authorizedUrlBuilder.removeAllQueryParameters(key); | 51 | + okhttp3.HttpUrl.Builder var3; |
| 52 | + HashMap var4; | ||
| 53 | + Iterator var5; | ||
| 54 | + String var6; | ||
| 55 | + if ("POST".equals(var2.method())) { | ||
| 56 | + var3 = var2.url().newBuilder(); | ||
| 57 | + var4 = new HashMap(); | ||
| 58 | + var5 = var2.url().queryParameterNames().iterator(); | ||
| 59 | + | ||
| 60 | + while(var5.hasNext()) { | ||
| 61 | + var6 = (String)var5.next(); | ||
| 62 | + var4.put(var6, var2.url().queryParameter(var6)); | ||
| 63 | + var3.removeAllQueryParameters(var6); | ||
| 58 | } | 64 | } |
| 59 | 65 | ||
| 60 | - FormBody.Builder builder = new FormBody.Builder(); | 66 | + var11 = new FormBody.Builder(); |
| 67 | + var13 = SignUtil.getNetPPPaySignString(var4).entrySet().iterator(); | ||
| 61 | 68 | ||
| 62 | - for (Map.Entry<String, String> entity : SignUtil.getNetPPPaySignString(parameter).entrySet()) { | ||
| 63 | - builder.add(entity.getKey(), entity.getValue()); | 69 | + while(var13.hasNext()) { |
| 70 | + var7 = (Map.Entry)var13.next(); | ||
| 71 | + var11.add((String)var7.getKey(), (String)var7.getValue()); | ||
| 64 | } | 72 | } |
| 65 | 73 | ||
| 66 | - RequestBody newBody = builder.build(); | ||
| 67 | - | ||
| 68 | - Request newRequest = request.newBuilder() | ||
| 69 | - .method(request.method(), newBody) | ||
| 70 | - .url(authorizedUrlBuilder.build()) | ||
| 71 | - .build(); | ||
| 72 | - return chain.proceed(newRequest); | ||
| 73 | - }else{ | ||
| 74 | - //处理方式 3 | ||
| 75 | - HttpUrl.Builder authorizedUrlBuilder = request.url().newBuilder(); | ||
| 76 | - | ||
| 77 | - Map<String, String> parameter = new HashMap<>(); | ||
| 78 | - | ||
| 79 | - for (String key : request.url().queryParameterNames()) { | ||
| 80 | - parameter.put(key, request.url().queryParameter(key)); | ||
| 81 | - authorizedUrlBuilder.removeAllQueryParameters(key); | 74 | + var14 = var11.build(); |
| 75 | + var15 = var2.newBuilder().method(var2.method(), var14).url(var3.build()).build(); | ||
| 76 | + return var1.proceed(var15); | ||
| 77 | + } else { | ||
| 78 | + var3 = var2.url().newBuilder(); | ||
| 79 | + var4 = new HashMap(); | ||
| 80 | + var5 = var2.url().queryParameterNames().iterator(); | ||
| 81 | + | ||
| 82 | + while(var5.hasNext()) { | ||
| 83 | + var6 = (String)var5.next(); | ||
| 84 | + var4.put(var6, var2.url().queryParameter(var6)); | ||
| 85 | + var3.removeAllQueryParameters(var6); | ||
| 82 | } | 86 | } |
| 83 | 87 | ||
| 84 | - for (Map.Entry<String, String> entity : SignUtil.getNetPPPaySignString(parameter).entrySet()) { | ||
| 85 | - authorizedUrlBuilder.addQueryParameter(entity.getKey(), entity.getValue()); | ||
| 86 | - } | 88 | + var5 = SignUtil.getNetPPPaySignString(var4).entrySet().iterator(); |
| 87 | 89 | ||
| 88 | - authorizedUrlBuilder.scheme(request.url().scheme()); | ||
| 89 | - authorizedUrlBuilder.host(request.url().host()); | 90 | + while(var5.hasNext()) { |
| 91 | + Map.Entry var12 = (Map.Entry)var5.next(); | ||
| 92 | + var3.addQueryParameter((String)var12.getKey(), (String)var12.getValue()); | ||
| 93 | + } | ||
| 90 | 94 | ||
| 91 | - Request newRequest = request.newBuilder() | ||
| 92 | - .method(request.method(), request.body()) | ||
| 93 | - .url(authorizedUrlBuilder.build()) | ||
| 94 | - .build(); | ||
| 95 | - return chain.proceed(newRequest); | 95 | + var3.scheme(var2.url().scheme()); |
| 96 | + var3.host(var2.url().host()); | ||
| 97 | + Request var10 = var2.newBuilder().method(var2.method(), var2.body()).url(var3.build()).build(); | ||
| 98 | + return var1.proceed(var10); | ||
| 96 | } | 99 | } |
| 97 | } | 100 | } |
| 98 | - | ||
| 99 | - | ||
| 100 | - return chain.proceed(request); | ||
| 101 | } | 101 | } |
| 102 | - | ||
| 103 | - | ||
| 104 | } | 102 | } |
| 105 | \ No newline at end of file | 103 | \ No newline at end of file |
module/pedometer/src/main/java/com/cnlive/moudle/pedometer/upload/UploadLogic.java renamed to core/network/src/main/java/com/cnlive/core/network/upload/UploadLogic.java
module/pedometer/src/main/java/com/cnlive/moudle/pedometer/upload/UploadProvider.java renamed to core/network/src/main/java/com/cnlive/core/network/upload/UploadProvider.java
| 1 | -package com.cnlive.moudle.pedometer.upload; | 1 | +package com.cnlive.core.network.upload; |
| 2 | 2 | ||
| 3 | import android.app.Activity; | 3 | import android.app.Activity; |
| 4 | import android.content.Context; | 4 | import android.content.Context; |
| @@ -8,17 +8,17 @@ import android.text.TextUtils; | @@ -8,17 +8,17 @@ import android.text.TextUtils; | ||
| 8 | 8 | ||
| 9 | import com.cnlive.core.libs.base.application.AppConfig; | 9 | import com.cnlive.core.libs.base.application.AppConfig; |
| 10 | import com.cnlive.core.libs.base.util.AlertUtil; | 10 | import com.cnlive.core.libs.base.util.AlertUtil; |
| 11 | +import com.cnlive.core.libs.base.util.FileTypeUtil; | ||
| 11 | import com.cnlive.core.libs.base.util.StringUtils; | 12 | import com.cnlive.core.libs.base.util.StringUtils; |
| 12 | import com.cnlive.core.network.model.BaseResult; | 13 | import com.cnlive.core.network.model.BaseResult; |
| 13 | import com.cnlive.core.network.HttpConn; | 14 | import com.cnlive.core.network.HttpConn; |
| 14 | import com.cnlive.core.network.NetCallBack; | 15 | import com.cnlive.core.network.NetCallBack; |
| 15 | import com.cnlive.core.network.api.ApiBaseServiceOpen; | 16 | import com.cnlive.core.network.api.ApiBaseServiceOpen; |
| 16 | import com.cnlive.core.network.request.BaseRequest; | 17 | import com.cnlive.core.network.request.BaseRequest; |
| 17 | -import com.cnlive.media.picker.utils.FileTypeUtil; | ||
| 18 | import com.cnlive.core.network.model.UploadAuthData; | 18 | import com.cnlive.core.network.model.UploadAuthData; |
| 19 | -import com.cnlive.moudle.pedometer.upload.interfaces.ProgressCallback; | ||
| 20 | -import com.cnlive.moudle.pedometer.utils.FileUtil; | ||
| 21 | -import com.cnlive.moudle.pedometer.utils.IDUtils; | 19 | +import com.cnlive.core.network.upload.interfaces.ProgressCallback; |
| 20 | +import com.cnlive.core.network.upload.utils.FileUtil; | ||
| 21 | +import com.cnlive.core.network.upload.utils.IDUtils; | ||
| 22 | import com.qiniu.android.http.ResponseInfo; | 22 | import com.qiniu.android.http.ResponseInfo; |
| 23 | import com.qiniu.android.storage.UpCompletionHandler; | 23 | import com.qiniu.android.storage.UpCompletionHandler; |
| 24 | import com.qiniu.android.storage.UpProgressHandler; | 24 | import com.qiniu.android.storage.UpProgressHandler; |
module/pedometer/src/main/java/com/cnlive/moudle/pedometer/upload/interfaces/ProgressCallback.java renamed to core/network/src/main/java/com/cnlive/core/network/upload/interfaces/ProgressCallback.java
module/pedometer/src/main/java/com/cnlive/moudle/pedometer/upload/utils/FileUtil.java renamed to core/network/src/main/java/com/cnlive/core/network/upload/utils/FileUtil.java
module/pedometer/src/main/java/com/cnlive/moudle/pedometer/upload/utils/IDUtils.java renamed to core/network/src/main/java/com/cnlive/core/network/upload/utils/IDUtils.java
module/pedometer/src/main/java/com/cnlive/moudle/pedometer/upload/utils/MD5.java renamed to core/network/src/main/java/com/cnlive/core/network/upload/utils/MD5.java
module/pedometer/src/main/java/com/cnlive/moudle/pedometer/upload/utils/MD5Utils.java renamed to core/network/src/main/java/com/cnlive/core/network/upload/utils/MD5Utils.java
module/pedometer/build.gradle
| @@ -81,8 +81,6 @@ dependencies { | @@ -81,8 +81,6 @@ dependencies { | ||
| 81 | //加载动画 | 81 | //加载动画 |
| 82 | implementation "com.wang.avi:library:$rootProject.avi" | 82 | implementation "com.wang.avi:library:$rootProject.avi" |
| 83 | // implementation "com.cnlive.libs:video_qiniu:$rootProject.libVideoQiniu" | 83 | // implementation "com.cnlive.libs:video_qiniu:$rootProject.libVideoQiniu" |
| 84 | - //七牛上传 | ||
| 85 | - implementation "com.qiniu:qiniu-android-sdk:$rootProject.qiniuAndroidSdk" | ||
| 86 | implementation("com.cnlive:lib_upload:$rootProject.libUpload") { | 84 | implementation("com.cnlive:lib_upload:$rootProject.libUpload") { |
| 87 | exclude group: 'com.android.support' | 85 | exclude group: 'com.android.support' |
| 88 | exclude group: 'com.cnlive' | 86 | exclude group: 'com.cnlive' |
module/pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunningFinishFragmentView.java
| @@ -41,7 +41,7 @@ import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunningFinishFragment; | @@ -41,7 +41,7 @@ import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunningFinishFragment; | ||
| 41 | import com.cnlive.moudle.collectionTrace.utils.CollStepUtil; | 41 | import com.cnlive.moudle.collectionTrace.utils.CollStepUtil; |
| 42 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; | 42 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 43 | import com.cnlive.moudle.pedometer.sql.entity.CollUserStepEntity; | 43 | import com.cnlive.moudle.pedometer.sql.entity.CollUserStepEntity; |
| 44 | -import com.cnlive.moudle.pedometer.upload.UploadLogic; | 44 | +import com.cnlive.core.network.upload.UploadLogic; |
| 45 | import com.cnlive.moudle.pedometer.utils.MyMapUtil; | 45 | import com.cnlive.moudle.pedometer.utils.MyMapUtil; |
| 46 | import com.cnlive.moudle.pedometer.utils.ScreenUtil; | 46 | import com.cnlive.moudle.pedometer.utils.ScreenUtil; |
| 47 | import com.cnlive.moudle.pedometer.utils.TimeUtil; | 47 | import com.cnlive.moudle.pedometer.utils.TimeUtil; |