Commit 94f84f261391de9b837fd25f62c2a259ce247350

Authored by 韩亚云
1 parent e47f8554

二维码相关代码迁移

Showing 49 changed files with 4693 additions and 27 deletions

Too many changes to show.

To preserve performance only 49 of 161 files are displayed.

app/strike/src/main/java/com/cnlive/strike/MainActivity.java
@@ -11,7 +11,6 @@ import android.view.View; @@ -11,7 +11,6 @@ import android.view.View;
11 11
12 import com.cnlive.strike.demo.activity.DemoActivity; 12 import com.cnlive.strike.demo.activity.DemoActivity;
13 import com.cnlive.strike.imgutil.ImgActivity; 13 import com.cnlive.strike.imgutil.ImgActivity;
14 -import com.cnlive.strike.user.ui.activity.LoginActivity;  
15 14
16 import androidx.annotation.NonNull; 15 import androidx.annotation.NonNull;
17 import androidx.annotation.Nullable; 16 import androidx.annotation.Nullable;
app/strike/src/main/java/com/cnlive/strike/imgutil/ImgActivity.java
@@ -19,6 +19,8 @@ import com.cnlive.core.imageload.callback.ImageDownLoadCallBack; @@ -19,6 +19,8 @@ import com.cnlive.core.imageload.callback.ImageDownLoadCallBack;
19 import com.cnlive.core.imageload.config.PriorityMode; 19 import com.cnlive.core.imageload.config.PriorityMode;
20 import com.cnlive.core.imageload.config.ScaleMode; 20 import com.cnlive.core.imageload.config.ScaleMode;
21 import com.cnlive.core.imageload.loader.ImageLoader; 21 import com.cnlive.core.imageload.loader.ImageLoader;
  22 +import com.cnlive.core.imageload.preview.PreviewImageViewActivity;
  23 +import com.cnlive.core.imageload.preview.model.PreviewData;
22 import com.cnlive.core.imageload.util.DownLoadImageService; 24 import com.cnlive.core.imageload.util.DownLoadImageService;
23 import com.cnlive.strike.R; 25 import com.cnlive.strike.R;
24 26
@@ -97,37 +99,20 @@ public class ImgActivity extends AppCompatActivity { @@ -97,37 +99,20 @@ public class ImgActivity extends AppCompatActivity {
97 } 99 }
98 }; 100 };
99 101
100 -  
101 -// //组织数据  
102 -// ArrayList<ThumbViewInfo> mThumbViewInfoList = new ArrayList<>(); // 这个最好定义成成员变量  
103 -// ThumbViewInfo item;  
104 -// mThumbViewInfoList.clear();  
105 -// for (int i = 0;i < resultList.size(); i++) {  
106 -// Rect bounds = new Rect();  
107 -// //new ThumbViewInfo(图片地址);  
108 -// item=new ThumbViewInfo(resultList.get(i).getOriginUrl());  
109 -// item.setBounds(bounds);  
110 -// mThumbViewInfoList.add(item);  
111 -// }  
112 -//  
113 -////打开预览界面  
114 -// GPreviewBuilder.from(Context context)  
115 -// //是否使用自定义预览界面,当然8.0之后因为配置问题,必须要使用  
116 -// .to(ImageLookActivity.class)  
117 -// .setData(mThumbViewInfoList)  
118 -// .setCurrentIndex(position)  
119 -// .setSingleFling(true)  
120 -// .setType(GPreviewBuilder.IndicatorType.Number)  
121 -// // 小圆点  
122 -//// .setType(GPreviewBuilder.IndicatorType.Dot)  
123 -// .start();//启动  
124 -  
125 ImageLoader.with(this) 102 ImageLoader.with(this)
126 .url(URL1) 103 .url(URL1)
127 .animate(animation) 104 .animate(animation)
128 .scale(ScaleMode.CENTER_CROP) 105 .scale(ScaleMode.CENTER_CROP)
129 .into(iv_test1); 106 .into(iv_test1);
130 107
  108 + PreviewData data = new PreviewData();
  109 + data.setLife(false);
  110 + data.setFriend(false);
  111 + data.setScan(false);
  112 + data.setCollection(false);
  113 + data.setShowImg(URL1);
  114 + iv_test1.setOnClickListener(view -> PreviewImageViewActivity.startPreviewPictrue(this, view, data));
  115 +
131 ImageLoader.with(this) 116 ImageLoader.with(this)
132 .url(URL1) 117 .url(URL1)
133 .scale(ScaleMode.FIT_CENTER) 118 .scale(ScaleMode.FIT_CENTER)
build.gradle
@@ -143,7 +143,7 @@ task clean(type: Delete) { @@ -143,7 +143,7 @@ task clean(type: Delete) {
143 //配置全局变量 143 //配置全局变量
144 ext { 144 ext {
145 libEmoj = '2.0.9' 145 libEmoj = '2.0.9'
146 - libMediaPicker = '1.5.8' 146 + libMediaPicker = '1.6.0'
147 // loading动画 147 // loading动画
148 avi = "2.1.3" 148 avi = "2.1.3"
149 //蓝牙 149 //蓝牙
@@ -151,4 +151,5 @@ ext { @@ -151,4 +151,5 @@ ext {
151 //动画大全 151 //动画大全
152 viewAnimationsEasing='2.0@aar' 152 viewAnimationsEasing='2.0@aar'
153 viewAnimationsAndroid='2.3@aar' 153 viewAnimationsAndroid='2.3@aar'
  154 + libEmoj = '2.1.0'
154 } 155 }
core/app_qr/.gitignore 0 → 100644
  1 +/build
core/app_qr/build.gradle 0 → 100644
  1 +apply plugin: 'com.android.library'
  2 +
  3 +android {
  4 +// compileSdkVersion 29
  5 +// buildToolsVersion "29.0.2"
  6 +//
  7 +//
  8 +// defaultConfig {
  9 +// minSdkVersion 16
  10 +// targetSdkVersion 29
  11 +// versionCode 1
  12 +// versionName "1.0"
  13 +// testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  14 +// consumerProguardFiles 'consumer-rules.pro'
  15 +// }
  16 +
  17 + buildTypes {
  18 + release {
  19 + minifyEnabled false
  20 + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  21 + }
  22 + }
  23 +}
  24 +
  25 +dependencies {
  26 + implementation fileTree(dir: 'libs', include: ['*.jar'])
  27 + implementation 'cn.bertsir.zbarLibary:zbarlibary:1.3.3'
  28 + implementation "com.cnlive.libs:mediapicker:$rootProject.libMediaPicker"
  29 + implementation "com.cnlive.libs:emoj:$rootProject.libEmoj"
  30 + implementation project(path: ':cloud:user')
  31 + implementation project(path: ':core:network')
  32 +}
core/app_qr/proguard-rules.pro 0 → 100644
  1 +# Add project specific ProGuard rules here.
  2 +# You can control the set of applied configuration files using the
  3 +# proguardFiles setting in build.gradle.
  4 +#
  5 +# For more details, see
  6 +# http://developer.android.com/guide/developing/tools/proguard.html
  7 +
  8 +# If your project uses WebView with JS, uncomment the following
  9 +# and specify the fully qualified class name to the JavaScript interface
  10 +# class:
  11 +#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
  12 +# public *;
  13 +#}
  14 +
  15 +# Uncomment this to preserve the line number information for
  16 +# debugging stack traces.
  17 +#-keepattributes SourceFile,LineNumberTable
  18 +
  19 +# If you keep the line number information, uncomment this to
  20 +# hide the original source file name.
  21 +#-renamesourcefileattribute SourceFile
core/app_qr/src/main/AndroidManifest.xml 0 → 100644
  1 +<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  2 + package="com.cnlive.strike.moudle.qr" >
  3 +
  4 + <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
  5 + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  6 + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
  7 + <uses-permission android:name="android.permission.INTERNET" />
  8 + <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
  9 + <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
  10 + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  11 + <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
  12 + <uses-permission android:name="android.permission.CAMERA" />
  13 + <uses-permission android:name="android.permission.VIBRATE" />
  14 +
  15 +
  16 + <application >
  17 + <activity
  18 + android:name=".ui.activity.QrSignInActivity"
  19 + android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation"
  20 + android:launchMode="singleTop"
  21 + android:screenOrientation="portrait" />
  22 + <activity
  23 + android:name=".ui.activity.QrPayActivity"
  24 + android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation"
  25 + android:launchMode="singleTop"
  26 + android:screenOrientation="portrait" />
  27 + <activity
  28 + android:name=".ui.activity.OtherQrActivity"
  29 + android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation"
  30 + android:launchMode="singleTop"
  31 + android:screenOrientation="portrait" />
  32 + <activity
  33 + android:name=".ui.activity.SpeakerBindStateActivity"
  34 + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
  35 + android:launchMode="singleTask"
  36 + android:screenOrientation="portrait" />
  37 + <activity
  38 + android:name=".ui.activity.ScanZarBarActivity"
  39 + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
  40 + android:launchMode="singleTask"
  41 + android:screenOrientation="portrait" />
  42 + <activity
  43 + android:name=".ui.activity.GenerateQRActivity"
  44 + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
  45 + android:launchMode="singleTask"
  46 + android:screenOrientation="portrait" />
  47 + </application>
  48 +
  49 +
  50 +</manifest>
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/api/ApiServiceQrcode.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.api;
  2 +
  3 +import com.cnlive.core.network.BaseResult;
  4 +import com.cnlive.strike.moudle.qr.model.CheckQrUrlInfo;
  5 +import com.cnlive.strike.moudle.qr.model.CottonCandyInfo;
  6 +import com.cnlive.strike.moudle.qr.model.CreateQrInfo;
  7 +import com.cnlive.strike.moudle.qr.model.DarenInfoModel;
  8 +import com.cnlive.strike.moudle.qr.model.QrActivityInfo;
  9 +import com.cnlive.strike.moudle.qr.model.QrOrderInfo;
  10 +import com.cnlive.strike.moudle.qr.model.QrSignInfo;
  11 +
  12 +import java.util.Map;
  13 +
  14 +import io.reactivex.Observable;
  15 +import retrofit2.adapter.rxjava2.Result;
  16 +import retrofit2.http.FieldMap;
  17 +import retrofit2.http.FormUrlEncoded;
  18 +import retrofit2.http.POST;
  19 +import retrofit2.http.QueryMap;
  20 +
  21 +/**
  22 + * created by hanyayun
  23 + * on 2019/11/27
  24 + */
  25 +public interface ApiServiceQrcode {
  26 + /**
  27 + * 获取生成二维码的数据
  28 + * @param map
  29 + * @return
  30 + * appId
  31 + * sid
  32 + * type 生成或充值二维码 生成:gen 重置:reset
  33 + */
  34 + @POST("Daren/qrcode/genOrResetQrCode.action")
  35 + Observable<BaseResult<CreateQrInfo>> getQrContent(@QueryMap() Map<String, String> map);
  36 +
  37 +
  38 + @POST("Daren/qrcode/checkQrCode.action")
  39 + Observable<BaseResult<CreateQrInfo>> checkQr(@QueryMap() Map<String, String> map);
  40 +
  41 + /**
  42 + * 获取达人信息
  43 + *
  44 + * @param param
  45 + * @return
  46 + */
  47 + @POST("Daren/member/getDarenById.action")
  48 + Observable<BaseResult<DarenInfoModel>> getDarenBySid(@QueryMap Map<String, String> param);
  49 +
  50 + /**
  51 + * 获取达人信息
  52 + *
  53 + * @param param
  54 + * @return
  55 + */
  56 + @FormUrlEncoded
  57 + @POST("Daren/order/addOrder.action")
  58 + Observable<BaseResult<QrOrderInfo>> getQrOrder(@FieldMap Map<String, String> param);
  59 + /**
  60 + * 扫码签到(临时)
  61 + *
  62 + * @param param
  63 + * @return
  64 + */
  65 + @POST("Daren/sign/checkSignInfo.action")
  66 + Observable<BaseResult<QrSignInfo>> checkSignInfo(@QueryMap Map<String, String> param);
  67 +
  68 + /**
  69 + * 扫码活动(临时)
  70 + * @param param
  71 + * @return
  72 + */
  73 + @POST("Daren/sign/checkQrActivity.action")
  74 + Observable<BaseResult<QrActivityInfo>> checkQrActivity(@QueryMap Map<String, String> param);
  75 +
  76 + /**
  77 + * 校验二维码数据
  78 + * @param param
  79 + * @return
  80 + */
  81 + @POST("Daren/qrcode/checkQrCodeUrl.action")
  82 + Observable<BaseResult<CheckQrUrlInfo>> checkQrUrl(@QueryMap Map<String, String> param);
  83 +
  84 +
  85 + /**
  86 + * 生成棉花糖订单信息
  87 + * @param param
  88 + * @return
  89 + */
  90 +
  91 + @POST("Daren/order/addOrderMHT.action")
  92 + Observable<BaseResult<CottonCandyInfo>> getCottonCandy(@QueryMap Map<String, String> param);
  93 +
  94 +
  95 + /**
  96 + * 音箱家庭邀请成员
  97 + *
  98 + * @return
  99 + */
  100 + @POST("Daren/sound/familyGroupInviteYD.action")
  101 + Observable<BaseResult> familyGroupInviteYD(@QueryMap() Map<String, String> map);
  102 +
  103 +
  104 + /**
  105 + * 生成棉花糖订单信息
  106 + * @param param
  107 + * @return
  108 + */
  109 +
  110 + @POST("Daren/group/userAddGroup.action")
  111 + Observable<BaseResult> userAddGroup(@QueryMap Map<String, String> param);
  112 +
  113 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/frame/presenter/GenerateQRPresenter.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.frame.presenter;
  2 +
  3 +import com.cnlive.core.libs.base.application.AppConfig;
  4 +import com.cnlive.core.libs.base.frame.presenter.BasePresenter;
  5 +import com.cnlive.core.network.BaseResult;
  6 +import com.cnlive.core.network.HttpConn;
  7 +import com.cnlive.core.network.NetCallBack;
  8 +import com.cnlive.core.network.request.BaseRequest;
  9 +import com.cnlive.strike.moudle.qr.api.ApiServiceQrcode;
  10 +import com.cnlive.strike.moudle.qr.frame.view.GenerateQRView;
  11 +import com.cnlive.strike.moudle.qr.model.CreateQrInfo;
  12 +import com.cnlive.strike.moudle.qr.ui.activity.GenerateQRActivity;
  13 +import com.cnlive.strike.user.auth.UserService;
  14 +
  15 +import java.util.HashMap;
  16 +import java.util.Map;
  17 +
  18 +/**
  19 + * 创建:wukuiqing
  20 + * <p>
  21 + * 时间:2018/4/25
  22 + * <p>
  23 + * 描述:
  24 + */
  25 +
  26 +public class GenerateQRPresenter extends BasePresenter<GenerateQRView> {
  27 + /**
  28 + * 生成二维码
  29 + *
  30 + * @param generateQRActivity
  31 + */
  32 + public void createQr(GenerateQRActivity generateQRActivity, String type) {
  33 + ifViewAttached(view -> view.showLoading());
  34 + Map<String, String> requestData = new HashMap<>();
  35 + String userId = UserService.getUid(generateQRActivity);
  36 + requestData.put("appId", AppConfig.getAppId());
  37 + requestData.put("sid", userId);
  38 + requestData.put("type", type);
  39 + HttpConn.action(BaseRequest
  40 + .init()
  41 + .service(ApiServiceQrcode.class)
  42 + .getQrContent(requestData), new NetCallBack<BaseResult<CreateQrInfo>>() {
  43 + @Override
  44 + public void onRequestState(int state) {
  45 +
  46 + }
  47 +
  48 + @Override
  49 + public void onSuccess(BaseResult<CreateQrInfo> data) {
  50 + String content = data.getData().getQrcode();
  51 + if(content.length() > 0)ifViewAttached(view -> view.creataQr(content));
  52 + }
  53 +
  54 + @Override
  55 + public void onFailure(String errCode, String errMsg) {
  56 + ifViewAttached(view -> view.showCreateErr(errMsg));
  57 + }
  58 + }
  59 + );
  60 + }
  61 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/frame/presenter/QrPayPresenter.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.frame.presenter;
  2 +
  3 +
  4 +import android.content.Context;
  5 +
  6 +import com.cnlive.core.libs.base.application.AppConfig;
  7 +import com.cnlive.core.libs.base.frame.presenter.BasePresenter;
  8 +import com.cnlive.core.network.BaseResult;
  9 +import com.cnlive.core.network.HttpConn;
  10 +import com.cnlive.core.network.NetCallBack;
  11 +import com.cnlive.core.network.request.BaseRequest;
  12 +import com.cnlive.strike.moudle.qr.api.ApiServiceQrcode;
  13 +import com.cnlive.strike.moudle.qr.frame.view.QrPayView;
  14 +import com.cnlive.strike.moudle.qr.model.DarenInfoModel;
  15 +import com.cnlive.strike.moudle.qr.model.QrOrderInfo;
  16 +import com.cnlive.strike.user.auth.UserService;
  17 +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog;
  18 +
  19 +import java.util.HashMap;
  20 +import java.util.Map;
  21 +
  22 +
  23 +
  24 +/**
  25 + * 作者: 吴奎庆
  26 + * <p>
  27 + * 时间: 2018/7/11
  28 + * <p>
  29 + * 简介:
  30 + */
  31 +
  32 +public class QrPayPresenter extends BasePresenter<QrPayView> {
  33 +
  34 + private QMUITipDialog loadingDiaog;
  35 +
  36 + /**
  37 + * 获取达人信息(被支付着的信息)
  38 + *
  39 + * @param activity
  40 + * @param dareId
  41 + */
  42 + public void getDarenInfo(Context activity, String dareId) {
  43 + Map<String, String> requestMap = new HashMap<>();
  44 + requestMap.put("sid", "");
  45 + requestMap.put("darenId", dareId);
  46 + HttpConn.action(
  47 + BaseRequest
  48 + .init()
  49 + .service(ApiServiceQrcode.class)
  50 + .getDarenBySid(requestMap), new NetCallBack<BaseResult<DarenInfoModel>>() {
  51 + @Override
  52 + public void onRequestState(int state) {
  53 + if (state == HttpConn.ON_START) {
  54 + ifViewAttached(view -> view.showLoadingView());
  55 + } else if (state == HttpConn.ON_END) {
  56 + ifViewAttached(view -> view.hideLoadingView());
  57 + }
  58 + }
  59 +
  60 + @Override
  61 + public void onSuccess(BaseResult<DarenInfoModel> data) {
  62 + ifViewAttached(view -> view.setData(data));
  63 + }
  64 +
  65 + @Override
  66 + public void onFailure(String errCode, String errMsg) {
  67 + ifViewAttached(view -> view.showRetryView(Integer.parseInt(errCode)));
  68 + }
  69 + }
  70 +
  71 + );
  72 + }
  73 +
  74 + public void getQrOrder(Context activity, String dareId, String money, String remarkContent) {
  75 + loadingDiaog = new QMUITipDialog.Builder(activity)
  76 + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING)
  77 + .setTipWord("请稍后")
  78 + .create();
  79 + Map<String, String> requestMap = new HashMap<>();
  80 + requestMap.put("sid", UserService.getUid(activity));
  81 + requestMap.put("darenId", dareId);
  82 + requestMap.put("appId", AppConfig.getAppId());
  83 + requestMap.put("price", money);
  84 + requestMap.put("remark", remarkContent);
  85 +
  86 + HttpConn.action(
  87 + BaseRequest.init()
  88 + .service(ApiServiceQrcode.class)
  89 + .getQrOrder(requestMap), new NetCallBack<BaseResult<QrOrderInfo>>() {
  90 + @Override
  91 + public void onRequestState(int state) {
  92 +
  93 + }
  94 +
  95 + @Override
  96 + public void onSuccess(BaseResult<QrOrderInfo> data) {
  97 + loadingDiaog.dismiss();
  98 + ifViewAttached(view -> view.getQrOrder(data));
  99 + }
  100 +
  101 + @Override
  102 + public void onFailure(String errCode, String errMsg) {
  103 + loadingDiaog.dismiss();
  104 + ifViewAttached(view -> view.showMessage(errMsg));
  105 + }
  106 + }
  107 +
  108 + );
  109 + }
  110 +
  111 + public void cancel() {
  112 + if (loadingDiaog != null) loadingDiaog.dismiss();
  113 + }
  114 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/frame/presenter/QrSignInPresenter.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.frame.presenter;
  2 +
  3 +import com.cnlive.core.libs.base.frame.presenter.BasePresenter;
  4 +import com.cnlive.strike.moudle.qr.frame.view.QrSignInView;
  5 +
  6 +/**
  7 + * 作者: 吴奎庆
  8 + * <p>
  9 + * 时间: 2018/8/28
  10 + * <p>
  11 + * 简介:
  12 + */
  13 +
  14 +public class QrSignInPresenter extends BasePresenter<QrSignInView> {
  15 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/frame/presenter/ScanNewPresenter.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.frame.presenter;
  2 +
  3 +import android.os.Environment;
  4 +import android.text.TextUtils;
  5 +
  6 +import com.cnlive.core.libs.base.frame.presenter.BasePresenter;
  7 +import com.cnlive.strike.moudle.qr.frame.view.ScanNewView;
  8 +import com.cnlive.strike.moudle.qr.ui.activity.ScanZarBarActivity;
  9 +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter;
  10 +
  11 +import java.io.File;
  12 +
  13 +import cn.bertsir.zbar.utils.QRUtils;
  14 +import io.reactivex.Observable;
  15 +import io.reactivex.ObservableOnSubscribe;
  16 +import io.reactivex.Observer;
  17 +import io.reactivex.android.schedulers.AndroidSchedulers;
  18 +import io.reactivex.disposables.Disposable;
  19 +import io.reactivex.schedulers.Schedulers;
  20 +import top.zibin.luban.Luban;
  21 +import top.zibin.luban.OnCompressListener;
  22 +
  23 +/**
  24 + * 创建:wukuiqing
  25 + * <p>
  26 + * 时间:2018/4/25
  27 + * <p>
  28 + * 描述:
  29 + */
  30 +
  31 +public class ScanNewPresenter extends BasePresenter<ScanNewView> {
  32 +
  33 + /**
  34 + * 校验扫描出来的瞬狙
  35 + *
  36 + * @param result
  37 + */
  38 + public void checkQr(String result) {
  39 + if (!TextUtils.isEmpty(result)) {
  40 + ifViewAttached(view -> {
  41 + view.stopScan();
  42 + view.processQrContent(result);
  43 + });
  44 + } else {
  45 + ifViewAttached(view -> view.showMessage("未识别二维码"));
  46 + }
  47 +
  48 + }
  49 +
  50 + /**
  51 + * 识别二位码的信息
  52 + *
  53 + * @param ScanZarBarActivity
  54 + * @param file
  55 + */
  56 + public void getQrMessage(ScanZarBarActivity ScanZarBarActivity, File file) {
  57 + Observable.create((ObservableOnSubscribe<String>) emitter -> {
  58 + //优先使用zbar识别一次二维码
  59 + String content = QRUtils.getInstance().decodeQRcode(file.getAbsolutePath());
  60 + if (content != null && content.length() > 0) {
  61 + emitter.onNext(content);
  62 + } else {
  63 + emitter.onNext("");
  64 + }
  65 + }).subscribeOn(Schedulers.io())
  66 + .observeOn(AndroidSchedulers.mainThread())
  67 + .subscribe(new Observer<String>() {
  68 + @Override
  69 + public void onSubscribe(Disposable d) {
  70 + }
  71 +
  72 + @Override
  73 + public void onNext(String s) {
  74 + checkQr( s);
  75 + }
  76 +
  77 + @Override
  78 + public void onError(Throwable e) {
  79 + }
  80 +
  81 + @Override
  82 + public void onComplete() {
  83 + }
  84 + });
  85 + }
  86 +
  87 + /**
  88 + * 图片压缩
  89 + *
  90 + * @param ScanZarBarActivity
  91 + * @param path
  92 + */
  93 + public void luBanFile(ScanZarBarActivity ScanZarBarActivity, String path) {
  94 + Luban.with(ScanZarBarActivity)
  95 + .load(path)
  96 + .ignoreBy(400)
  97 + .setTargetDir(getPath())
  98 + .filter(path1 -> !(TextUtils.isEmpty(path1) || path1.toLowerCase().endsWith(".gif")))
  99 + .setCompressListener(new OnCompressListener() {
  100 + @Override
  101 + public void onStart() {
  102 + }
  103 +
  104 + @Override
  105 + public void onSuccess(File file) {
  106 +
  107 + if (!file.getAbsolutePath().equals(path))
  108 + ifViewAttached(view -> view.lubanSuccessed(file));
  109 + getQrMessage(ScanZarBarActivity, file);
  110 + }
  111 +
  112 + @Override
  113 + public void onError(Throwable e) {
  114 + ifViewAttached(view -> view.showMessage("二维码压缩失败"));
  115 + }
  116 + }).launch();
  117 + }
  118 +
  119 + /**
  120 + * 鲁班压缩后图片的存储位置
  121 + *
  122 + * @return
  123 + */
  124 + private String getPath() {
  125 + String path = Environment.getExternalStorageDirectory() + "/strike/current/";
  126 + File file = new File(path);
  127 + if (file.mkdirs()) {
  128 + return path;
  129 + }
  130 + return path;
  131 + }
  132 +
  133 + public void IdentifyQRCode(ScanZarBarActivity context, String path) {
  134 + Observable.create((ObservableOnSubscribe<String>) emitter -> {
  135 + //优先使用zbar识别一次二维码
  136 + String content=null;
  137 + content = QRUtils.getInstance().decodeQRcode(path);
  138 + if (TextUtils.isEmpty(path)){
  139 + content = QRUtils.getInstance().decodeQRcodeByZxing(path);
  140 + }
  141 + if (content != null && content.length() > 0) {
  142 + emitter.onNext(content);
  143 + } else {
  144 + emitter.onNext("");
  145 + }
  146 + }).subscribeOn(Schedulers.io())
  147 + .observeOn(AndroidSchedulers.mainThread())
  148 + .subscribe(new Observer<String>() {
  149 + @Override
  150 + public void onSubscribe(Disposable d) {
  151 + }
  152 +
  153 + @Override
  154 + public void onNext(String s) {
  155 + checkQr(s);
  156 + }
  157 +
  158 + @Override
  159 + public void onError(Throwable e) {
  160 + }
  161 +
  162 + @Override
  163 + public void onComplete() {
  164 + }
  165 + });
  166 + }
  167 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/frame/presenter/ScanPresenter.java 0 → 100644
  1 +//package com.cnlive.strike.moudle.qr.frame.presenter;
  2 +//
  3 +//import android.os.Environment;
  4 +//import android.text.TextUtils;
  5 +//
  6 +//import com.cnlive.strike.moudle.qr.frame.view.ScanView;
  7 +//import com.cnlive.strike.moudle.qr.ui.activity.ScanActivity;
  8 +//import com.cnlive.strike.moudle.qr.uitl.QrUtils;
  9 +//import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter;
  10 +//
  11 +//import java.io.File;
  12 +//
  13 +//import io.reactivex.Observable;
  14 +//import io.reactivex.ObservableOnSubscribe;
  15 +//import io.reactivex.Observer;
  16 +//import io.reactivex.android.schedulers.AndroidSchedulers;
  17 +//import io.reactivex.disposables.Disposable;
  18 +//import io.reactivex.schedulers.Schedulers;
  19 +//import top.zibin.luban.Luban;
  20 +//import top.zibin.luban.OnCompressListener;
  21 +//
  22 +///**
  23 +// * 创建:wukuiqing
  24 +// * <p>
  25 +// * 时间:2018/4/25
  26 +// * <p>
  27 +// * 描述:
  28 +// */
  29 +//
  30 +//public class ScanPresenter extends MvpBasePresenter<ScanView> {
  31 +//
  32 +// /**
  33 +// * 校验扫描出来的瞬狙
  34 +// *
  35 +// * @param scanActivity
  36 +// * @param result
  37 +// */
  38 +// public void checkQr(ScanActivity scanActivity, String result) {
  39 +// if (getView() == null) return;
  40 +// if (!TextUtils.isEmpty(result)) {
  41 +// if (getView() != null) getView().processQrContent(result);
  42 +// } else {
  43 +// getView().showMessage("未识别二维码");
  44 +// }
  45 +//
  46 +// }
  47 +//
  48 +// /**
  49 +// * 识别二位码的信息
  50 +// *
  51 +// * @param scanActivity
  52 +// * @param file
  53 +// */
  54 +// public void getQrMessage(ScanActivity scanActivity, File file) {
  55 +// Observable.create((ObservableOnSubscribe<String>) emitter -> {
  56 +// String content = QrUtils.identifyQr(scanActivity, file);
  57 +// if (content != null && content.length() > 0) {
  58 +// emitter.onNext(content);
  59 +// } else {
  60 +// emitter.onNext("");
  61 +// }
  62 +// }).subscribeOn(Schedulers.io())
  63 +// .observeOn(AndroidSchedulers.mainThread())
  64 +// .subscribe(new Observer<String>() {
  65 +// @Override
  66 +// public void onSubscribe(Disposable d) {
  67 +// }
  68 +//
  69 +// @Override
  70 +// public void onNext(String s) {
  71 +// checkQr(scanActivity, s);
  72 +// }
  73 +//
  74 +// @Override
  75 +// public void onError(Throwable e) {
  76 +// }
  77 +//
  78 +// @Override
  79 +// public void onComplete() {
  80 +// }
  81 +// });
  82 +// }
  83 +//
  84 +// /**
  85 +// * 图片压缩
  86 +// *
  87 +// * @param scanActivity
  88 +// * @param path
  89 +// */
  90 +// public void luBanFile(ScanActivity scanActivity, String path) {
  91 +// Luban.with(scanActivity)
  92 +// .load(path)
  93 +// .ignoreBy(400)
  94 +// .setTargetDir(getPath())
  95 +// .filter(path1 -> !(TextUtils.isEmpty(path1) || path1.toLowerCase().endsWith(".gif")))
  96 +// .setCompressListener(new OnCompressListener() {
  97 +// @Override
  98 +// public void onStart() {
  99 +// }
  100 +//
  101 +// @Override
  102 +// public void onSuccess(File file) {
  103 +//
  104 +// if (getView() != null && !file.getAbsolutePath().equals(path))
  105 +// getView().lubanSuccessed(file);
  106 +// getQrMessage(scanActivity, file);
  107 +// }
  108 +//
  109 +// @Override
  110 +// public void onError(Throwable e) {
  111 +// getView().showMessage("二维码压缩失败");
  112 +// }
  113 +// }).launch();
  114 +// }
  115 +//
  116 +// /**
  117 +// * 鲁班压缩后图片的存储位置
  118 +// *
  119 +// * @return
  120 +// */
  121 +// private String getPath() {
  122 +// String path = Environment.getExternalStorageDirectory() + "/strike/current/";
  123 +// File file = new File(path);
  124 +// if (file.mkdirs()) {
  125 +// return path;
  126 +// }
  127 +// return path;
  128 +// }
  129 +//}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/frame/presenter/SpeakerBindStatePresenter.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.frame.presenter;
  2 +
  3 +
  4 +import com.cnlive.core.libs.base.frame.presenter.BasePresenter;
  5 +import com.cnlive.core.libs.base.util.SimpleDES;
  6 +import com.cnlive.core.network.BaseResult;
  7 +import com.cnlive.core.network.HttpConn;
  8 +import com.cnlive.core.network.NetCallBack;
  9 +import com.cnlive.core.network.request.BaseRequest;
  10 +import com.cnlive.strike.moudle.qr.api.ApiServiceQrcode;
  11 +import com.cnlive.strike.moudle.qr.frame.view.SpeakerBindStateView;
  12 +import com.cnlive.strike.moudle.qr.ui.activity.SpeakerBindStateActivity;
  13 +
  14 +import java.util.HashMap;
  15 +
  16 +import okhttp3.MediaType;
  17 +import okhttp3.RequestBody;
  18 +
  19 +/**
  20 + * 作者: 吴奎庆
  21 + * <p>
  22 + * 时间: 2019/10/11
  23 + * <p>
  24 + * 简介:
  25 + */
  26 +public class SpeakerBindStatePresenter extends BasePresenter<SpeakerBindStateView> {
  27 + public void initData(SpeakerBindStateActivity speakerBindStateActivity, String content) {
  28 +
  29 + String encryptionContent = SimpleDES.ebotongEncrypto(content, "homeAudio");
  30 + HashMap<String, String> requestMap = new HashMap<>();
  31 + requestMap.put("type", "1");
  32 + requestMap.put("contactsInvite", encryptionContent);
  33 +
  34 + HttpConn.action(
  35 + BaseRequest.init()
  36 + .service(ApiServiceQrcode.class)
  37 + .familyGroupInviteYD(requestMap),
  38 + new NetCallBack<BaseResult>() {
  39 + @Override
  40 + public void onRequestState(int state) {
  41 +
  42 + }
  43 +
  44 + @Override
  45 + public void onSuccess(BaseResult data) {
  46 + ifViewAttached(view -> view.showSucesss(data.getErrorCode(),data.getMessage()));
  47 + }
  48 +
  49 + @Override
  50 + public void onFailure(String errCode, String errMsg) {
  51 + ifViewAttached(view -> view.processFailData(Integer.parseInt(errCode),errMsg));
  52 + }
  53 + }
  54 + );
  55 + }
  56 +
  57 + private static RequestBody getRequestString(String value) {
  58 + RequestBody requestString = RequestBody.create(MediaType.parse("text/plain"), value);
  59 + return requestString;
  60 + }
  61 +
  62 + private static RequestBody getRequestString2(String value) {
  63 + RequestBody requestString = RequestBody.create(MediaType.parse("application/json"), value);
  64 + return requestString;
  65 + }
  66 +
  67 +
  68 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/frame/view/GenerateQRView.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.frame.view;
  2 +
  3 +import android.Manifest;
  4 +import android.content.ContentValues;
  5 +import android.content.Context;
  6 +import android.content.Intent;
  7 +import android.graphics.Bitmap;
  8 +import android.graphics.BitmapFactory;
  9 +import android.net.Uri;
  10 +import android.os.Environment;
  11 +import android.provider.MediaStore;
  12 +import android.view.View;
  13 +
  14 +import com.bumptech.glide.request.RequestOptions;
  15 +import com.cnlive.core.libs.base.frame.view.BaseView;
  16 +import com.cnlive.core.libs.base.interfaces.OnPermissionResponseListener;
  17 +import com.cnlive.core.libs.base.util.AlertUtil;
  18 +import com.cnlive.core.libs.base.util.GlideRoundedCornersTransform;
  19 +import com.cnlive.core.libs.base.util.GlideUtil;
  20 +import com.cnlive.core.libs.base.util.ImagePickerComUtils;
  21 +import com.cnlive.core.libs.base.util.SimpleDES;
  22 +import com.cnlive.media.picker.utils.ScreenUtils;
  23 +import com.cnlive.strike.moudle.qr.R;
  24 +import com.cnlive.strike.moudle.qr.ui.activity.GenerateQRActivity;
  25 +import com.cnlive.strike.moudle.qr.ui.activity.ScanZarBarActivity;
  26 +import com.cnlive.strike.moudle.qr.uitl.QRCodeUtil;
  27 +import com.cnlive.strike.user.auth.UserService;
  28 +import com.cnlive.strike.user.model.CNLiveUserInfo;
  29 +import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
  30 +import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
  31 +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog;
  32 +
  33 +import org.json.JSONException;
  34 +import org.json.JSONObject;
  35 +
  36 +import java.io.File;
  37 +import java.io.FileNotFoundException;
  38 +import java.io.FileOutputStream;
  39 +import java.io.IOException;
  40 +import java.util.ArrayList;
  41 +
  42 +
  43 +import static com.bumptech.glide.request.RequestOptions.bitmapTransform;
  44 +
  45 +/**
  46 + * 创建:wukuiqing
  47 + * <p>
  48 + * 时间:2018/4/25
  49 + * <p>
  50 + * 描述:
  51 + */
  52 +
  53 +public class GenerateQRView extends BaseView {
  54 + GenerateQRActivity mContext;
  55 + private final CNLiveUserInfo userInfo;
  56 + public Bitmap qrBitmap;
  57 + public QMUITipDialog tipDialog;
  58 + public QMUIDialog resetDialog;
  59 +
  60 + public GenerateQRView(GenerateQRActivity mContext) {
  61 + this.mContext = mContext;
  62 + userInfo = UserService.getInstance(mContext).getAppAccount();
  63 + tipDialog = new QMUITipDialog.Builder(mContext)
  64 + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING)
  65 + .setTipWord("生成中")
  66 + .create();
  67 + }
  68 +
  69 + public void setUserData(ArrayList userUrl, String userName, String address, String bomHint) {
  70 + mContext.binding.tvUserName.setText(userName);
  71 + mContext.binding.tvWhere.setText(address);
  72 + RequestOptions options = bitmapTransform(new GlideRoundedCornersTransform(10f, GlideRoundedCornersTransform.CornerType.ALL))
  73 + .placeholder(R.drawable.bg_image_loading);
  74 + //TODO 目前只支持单人头像展示
  75 + if (userUrl != null && userUrl.size() == 1) {
  76 + mContext.binding.ivUserOneIcon.setVisibility(View.VISIBLE);
  77 + GlideUtil.into(mContext.binding.ivUserOneIcon, userUrl.get(0), options);
  78 + }
  79 + mContext.binding.tvBom.setText(bomHint);
  80 +
  81 + }
  82 +
  83 + public void showQr(Bitmap bitmap) {
  84 + if (qrBitmap != null) qrBitmap.recycle();
  85 + qrBitmap = bitmap;
  86 + if (bitmap != null) {
  87 + GlideUtil.into(mContext.binding.ivQr, qrBitmap);
  88 + } else {
  89 + showMessage("二维码生成失败");
  90 + }
  91 + }
  92 +
  93 + public void showMessage(String content) {
  94 + if (mContext == null) return;
  95 + hideLoading();
  96 + AlertUtil.showDeftToast(mContext, content);
  97 + }
  98 +
  99 + public void saveQr() {
  100 + if (mContext == null) return;
  101 + if (!ImagePickerComUtils.isSdExist()) {
  102 + showMessage("SD卡不存在");
  103 + return;
  104 + }
  105 + mContext.requestPermission(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, String.valueOf(R.string.dialog_imagepicker_permission_sdcard_message),new OnPermissionResponseListener() {
  106 +
  107 + @Override
  108 + public void onSuccess(String[] permissions) {
  109 + if (qrBitmap == null) {
  110 + showMessage("二维码生成失败");
  111 + } else {
  112 + saveImageToGallery(mContext, qrBitmap);
  113 + }
  114 + }
  115 +
  116 + @Override
  117 + public void onFail() {
  118 + showMessage("您还没有存储权限请去设置");
  119 + }
  120 + });
  121 + }
  122 +
  123 + public void creataQr(String content) {
  124 + if (mContext == null) return;
  125 + mContext.isCreateQr = true;
  126 + mContext.binding.ivRef.setVisibility(View.GONE);
  127 + hideLoading();
  128 + JSONObject jsonObject = new JSONObject();
  129 + String encryptionContent = SimpleDES.ebotongEncrypto(content, "cnliveIm");
  130 + try {
  131 + jsonObject.put("content", encryptionContent);
  132 + jsonObject.put("time", System.currentTimeMillis());
  133 + jsonObject.put("type", mContext.qrType);
  134 + } catch (JSONException e) {
  135 + e.printStackTrace();
  136 + }
  137 + String qrContent = jsonObject.toString();
  138 + if (qrContent != null && encryptionContent != null && mContext.qrType != null && qrContent.length() > 0) {
  139 + mContext.runOnUiThread(new Runnable() {
  140 + @Override
  141 + public void run() {
  142 + Bitmap logoBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.ewm_qr_lcon);
  143 + Bitmap bitmap = QRCodeUtil.createQRCodeBitmap(qrContent, ScreenUtils.dp2px(mContext, 150), logoBitmap, 0.2f);
  144 + showQr(bitmap);
  145 + }
  146 + });
  147 + } else {
  148 + AlertUtil.showDeftToast(mContext, "数据异常");
  149 + }
  150 +
  151 +
  152 + }
  153 +
  154 + public void showLoading() {
  155 + tipDialog.show();
  156 + }
  157 +
  158 + public void hideLoading() {
  159 + if (tipDialog != null && tipDialog.isShowing())
  160 + tipDialog.dismiss();
  161 + }
  162 +
  163 +
  164 + public void saveImageToGallery(Context context, Bitmap bmp) {
  165 + // 首先保存图片
  166 + String fileName = System.currentTimeMillis() + ".jpg";
  167 + File file = new File(getPath(), fileName);
  168 + try {
  169 + FileOutputStream fos = new FileOutputStream(file);
  170 + bmp.compress(Bitmap.CompressFormat.JPEG, 100, fos);
  171 + fos.flush();
  172 + fos.close();
  173 + } catch (FileNotFoundException e) {
  174 + e.printStackTrace();
  175 + } catch (IOException e) {
  176 + e.printStackTrace();
  177 + }
  178 +
  179 + ContentValues values = new ContentValues();
  180 + values.put(MediaStore.Images.Media.DATA, file.getAbsolutePath());
  181 + values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
  182 + context.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
  183 +
  184 + // 其次把文件插入到系统图库
  185 +// try {
  186 +// MediaStore.Images.Media.insertImage(context.getContentResolver(),
  187 +// file.getAbsolutePath(), fileName, null);
  188 +// } catch (FileNotFoundException e) {
  189 +// e.printStackTrace();
  190 +// }
  191 + // 最后通知图库更新
  192 + context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + file.getAbsolutePath())));
  193 +
  194 + AlertUtil.showSuccessToast(mContext, "保存成功");
  195 +
  196 + }
  197 +
  198 + public void resetQr() {
  199 +
  200 + resetDialog = new QMUIDialog.MessageDialogBuilder(mContext)
  201 + .setTitle("是否重置二维码")
  202 + .setMessage("重置后你将会获得新的二维码,而此前" +
  203 + "的二维码均将失效。")
  204 + .addAction("取消", new QMUIDialogAction.ActionListener() {
  205 + @Override
  206 + public void onClick(QMUIDialog dialog, int index) {
  207 + dialog.dismiss();
  208 + }
  209 + })
  210 + .addAction("确定", new QMUIDialogAction.ActionListener() {
  211 + @Override
  212 + public void onClick(QMUIDialog dialog, int index) {
  213 +
  214 + mContext.getPresenter().createQr(mContext, "reset");
  215 + dialog.dismiss();
  216 +
  217 + }
  218 + })
  219 + .show();
  220 +
  221 +
  222 + }
  223 +
  224 + public void scanQr() {
  225 + if (mContext == null) return;
  226 + if (!ImagePickerComUtils.isSdExist()) {
  227 + showMessage("SD卡不存在");
  228 + return;
  229 + }
  230 + mContext.requestPermission(new String[]{Manifest.permission.CAMERA}, String.valueOf(R.string.dialog_imagepicker_permission_camera_nerver_ask_message),new OnPermissionResponseListener() {
  231 +
  232 + @Override
  233 + public void onSuccess(String[] permissions) {
  234 + ScanZarBarActivity.startActivity(mContext, "");
  235 + }
  236 +
  237 + @Override
  238 + public void onFail() {
  239 + showMessage("您还没有相机权限,请去设置");
  240 + }
  241 + });
  242 + }
  243 +
  244 + /**
  245 + * 鲁班压缩后图片的存储位置
  246 + *
  247 + * @return
  248 + */
  249 + private String getPath() {
  250 + String path = Environment.getExternalStorageDirectory() + "/strike/current/";
  251 + File file = new File(path);
  252 + if (file.mkdirs()) {
  253 + return path;
  254 + }
  255 + return path;
  256 + }
  257 +
  258 + public void showCreateErr(String message) {
  259 + showMessage(message);
  260 + if (mContext == null) return;
  261 + mContext.isCreateQr = false;
  262 + mContext.binding.ivRef.setVisibility(View.VISIBLE);
  263 + }
  264 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/frame/view/QrPayView.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.frame.view;
  2 +
  3 +import android.text.TextUtils;
  4 +import android.view.MotionEvent;
  5 +import android.view.View;
  6 +
  7 +import com.cnlive.core.libs.base.frame.view.BaseView;
  8 +import com.cnlive.core.libs.base.util.AlertUtil;
  9 +import com.cnlive.core.libs.base.util.GlideUtil;
  10 +import com.cnlive.core.network.BaseResult;
  11 +import com.cnlive.strike.moudle.qr.R;
  12 +import com.cnlive.strike.moudle.qr.model.DarenInfoModel;
  13 +import com.cnlive.strike.moudle.qr.model.QrOrderInfo;
  14 +import com.cnlive.strike.moudle.qr.routers.QrRouters;
  15 +import com.cnlive.strike.moudle.qr.ui.fragment.QrPayFragment;
  16 +import com.cnlive.strike.moudle.qr.uitl.StringReplaceUtil;
  17 +import com.cnlive.strike.user.auth.UserService;
  18 +
  19 +/**
  20 + * 作者: 吴奎庆
  21 + * <p>
  22 + * 时间: 2018/7/11
  23 + * <p>
  24 + * 简介:
  25 + */
  26 +
  27 +public class QrPayView extends BaseView {
  28 + QrPayFragment fragment;
  29 + private String darenName;
  30 + private String darenFace;
  31 + private String qr_pay_realname;
  32 + private String shopName;
  33 +
  34 + public QrPayView(QrPayFragment fragment) {
  35 + this.fragment = fragment;
  36 + }
  37 +
  38 + public void showEmptyView() {
  39 + if (fragment.binding.emptyView != null) {
  40 + fragment.binding.emptyView.show(fragment.getString(R.string.msg_empty_page), "", R.drawable.zhuangtai_kong);
  41 + fragment.binding.emptyView.setVisibility(View.VISIBLE);
  42 + fragment.binding.llContent.setVisibility(View.GONE);
  43 + fragment.binding.emptyView.setOnTouchListener(new View.OnTouchListener() {
  44 + @Override
  45 + public boolean onTouch(View v, MotionEvent event) {
  46 + return true;
  47 + }
  48 + });
  49 + }
  50 +
  51 + }
  52 +
  53 +
  54 + public void showRetryView(int state) {
  55 + String titleText = "";
  56 + String detailText = "";
  57 + if (state == -3) {
  58 + titleText = fragment.getString(R.string.msg_failed_network_title);
  59 + detailText = fragment.getString(R.string.msg_failed_network_detail);
  60 + } else {
  61 + titleText = fragment.getString(R.string.msg_failed_other_title);
  62 + detailText = fragment.getString(R.string.msg_failed_other_detail);
  63 + }
  64 + if (fragment.binding.emptyView != null)
  65 + fragment.binding.emptyView.show(titleText, detailText, R.drawable.wufalianjie);
  66 + fragment.binding.emptyView.setVisibility(View.VISIBLE);
  67 + fragment.binding.llContent.setVisibility(View.GONE);
  68 + }
  69 +
  70 + public void showLoadingView() {
  71 + fragment.binding.emptyView.show(true);
  72 + }
  73 +
  74 + public void hideLoadingView() {
  75 + fragment.binding.emptyView.hide();
  76 + }
  77 +
  78 + public void setData(BaseResult<DarenInfoModel> data) {
  79 + if (fragment.getActivity() == null) return;
  80 + fragment.binding.emptyView.setVisibility(View.GONE);
  81 + fragment.binding.llContent.setVisibility(View.VISIBLE);
  82 + darenName = data.getData().getNickName();
  83 + String paytodaren = fragment.getActivity().getResources().getString(R.string.qr_pay_to_daren);
  84 + shopName = data.getData().getShopName();
  85 + if (TextUtils.isEmpty(shopName)) {
  86 + String stringResult = String.format(paytodaren, "未知");
  87 + fragment.binding.tvDarenDarenname.setText(stringResult);
  88 + } else {
  89 + String stringResult = String.format(paytodaren, shopName);
  90 + fragment.binding.tvDarenDarenname.setText(stringResult);
  91 + }
  92 +
  93 +
  94 + qr_pay_realname = fragment.getActivity().getResources().getString(R.string.qr_pay_realname);
  95 + String darenRealName = data.getData().getRealName();
  96 + if (TextUtils.isEmpty(darenRealName)) {
  97 + darenRealName = "未知";
  98 + } else {
  99 + darenRealName = StringReplaceUtil.userNameReplaceWithStar(darenRealName);
  100 + }
  101 + String realNameResult = String.format(qr_pay_realname, data.getData().getNickName(), darenRealName);
  102 + fragment.binding.tvDarenNickname.setText(realNameResult);
  103 + darenFace = data.getData().getFace();
  104 + GlideUtil.into(fragment.binding.ivDarenIcon, darenFace);
  105 + }
  106 +
  107 + public void showMessage(String message) {
  108 + if (fragment == null) return;
  109 + AlertUtil.showDeftToast(fragment.getActivity(), message);
  110 + }
  111 +
  112 +
  113 + public void getQrOrder(BaseResult<QrOrderInfo> data) {
  114 + String toName;
  115 + if (TextUtils.isEmpty(shopName)) {
  116 + toName = "未知";
  117 + } else {
  118 + toName = shopName;
  119 + }
  120 + String remarkText = fragment.binding.tvRemarks.getText().toString();
  121 + QrRouters.startOrderQrPay(fragment.getActivity(),UserService.getUid(fragment.getActivity()), data.getData().getOrderId(), data.getData().getPrice(), fragment.dareId, true, toName, false, "1", "3", "order", "扫码支付", darenFace, !TextUtils.isEmpty(remarkText) && remarkText.trim().length() > 0 && !"添加备注".equals(remarkText) ? remarkText.trim() : "");
  122 + }
  123 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/frame/view/QrSignInView.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.frame.view;
  2 +
  3 +import com.cnlive.core.libs.base.frame.view.BaseView;
  4 +import com.cnlive.strike.moudle.qr.ui.fragment.QrSignInFragment;
  5 +
  6 +/**
  7 + * 作者: 吴奎庆
  8 + * <p>
  9 + * 时间: 2018/8/28
  10 + * <p>
  11 + * 简介:
  12 + */
  13 +
  14 +public class QrSignInView extends BaseView {
  15 + QrSignInFragment fragment;
  16 + public QrSignInView(QrSignInFragment fragment) {
  17 + this.fragment=fragment;
  18 + }
  19 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/frame/view/ScanNewView.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.frame.view;
  2 +
  3 +import android.Manifest;
  4 +import android.app.Activity;
  5 +import android.content.Context;
  6 +import android.content.Intent;
  7 +import android.graphics.Color;
  8 +import android.graphics.PorterDuff;
  9 +import android.media.AudioManager;
  10 +import android.media.SoundPool;
  11 +import android.net.Uri;
  12 +import android.os.Build;
  13 +import android.os.Environment;
  14 +import android.text.TextUtils;
  15 +import android.view.View;
  16 +import android.widget.Button;
  17 +import android.widget.SeekBar;
  18 +
  19 +import com.cnlive.core.libs.base.frame.view.BaseView;
  20 +import com.cnlive.core.libs.base.interfaces.OnPermissionResponseListener;
  21 +import com.cnlive.core.libs.base.util.AlertUtil;
  22 +import com.cnlive.core.libs.base.util.FileUtils;
  23 +import com.cnlive.core.libs.base.util.ImagePickerComUtils;
  24 +import com.cnlive.core.libs.base.util.StatusBarUtil;
  25 +import com.cnlive.media.picker.ImagePicker;
  26 +import com.cnlive.media.picker.PickerConfig;
  27 +import com.cnlive.strike.moudle.qr.R;
  28 +import com.cnlive.strike.moudle.qr.ui.activity.GenerateQRActivity;
  29 +import com.cnlive.strike.moudle.qr.ui.activity.ScanZarBarActivity;
  30 +import com.cnlive.strike.moudle.qr.uitl.IdentifyTheQRCodeCallback;
  31 +import com.cnlive.strike.moudle.qr.uitl.QrContentUtil;
  32 +import com.cnlive.strike.user.auth.UserService;
  33 +import com.qmuiteam.qmui.widget.QMUITopBar;
  34 +
  35 +import java.io.File;
  36 +import java.util.ArrayList;
  37 +import java.util.concurrent.TimeUnit;
  38 +
  39 +import cn.bertsir.zbar.QrConfig;
  40 +import io.reactivex.Observable;
  41 +import io.reactivex.android.schedulers.AndroidSchedulers;
  42 +import io.reactivex.disposables.Disposable;
  43 +
  44 +
  45 +/**
  46 + * 创建:wukuiqing
  47 + * <p>
  48 + * 时间:2018/4/25
  49 + * <p>
  50 + * 描述:
  51 + */
  52 +
  53 +public class ScanNewView extends BaseView {
  54 + ScanZarBarActivity mContext;
  55 + private static final int image_item_max_size = 20 * 1024 * 1024;
  56 + int CORNER_COLOR = Color.parseColor("#1AAD19");
  57 + int LINE_FAST = 1500;
  58 + private Disposable disposable;
  59 +
  60 + public ScanNewView(ScanZarBarActivity mContext) {
  61 + this.mContext = mContext;
  62 + }
  63 +
  64 + public void initView() {
  65 + if (mContext == null) return;
  66 + StatusBarUtil.setStatusBarWrite(mContext);
  67 + StatusBarUtil.setColor(mContext, mContext.getResources().getColor(R.color.color_fff), 0);
  68 + QMUITopBar toolbar = mContext.binding.titleBar.topbar;
  69 + toolbar.setTitle("二维码扫描");
  70 + toolbar.setBackgroundColor(mContext.getResources().getColor(R.color.white));
  71 + toolbar.addLeftImageButton(R.drawable.drd_fanhui, R.id.qmui_topbar_item_left_back)
  72 + .setOnClickListener(v -> mContext.onBackPressed());
  73 + if (mContext.type != null && mContext.type.equals("qr")) {
  74 + Button xc = toolbar.addRightTextButton("相册", R.id.topbar_right_clean_button);
  75 + xc.setTextColor(mContext.getResources().getColor(R.color.blacktext));
  76 + xc.setOnClickListener(v -> {
  77 + showAum(false);
  78 + });
  79 + }
  80 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
  81 + setSeekBarColor(mContext.binding.vsbZoom, CORNER_COLOR);
  82 + }
  83 +// mContext.binding.vsbZoom.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
  84 +// @Override
  85 +// public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
  86 +// mContext.binding.cp.setZoom((progress / 100f));
  87 +// }
  88 +//
  89 +// @Override
  90 +// public void onStartTrackingTouch(SeekBar seekBar) {
  91 +//
  92 +// }
  93 +//
  94 +// @Override
  95 +// public void onStopTrackingTouch(SeekBar seekBar) {
  96 +//
  97 +// }
  98 +// });
  99 + mContext.binding.setOnClickListener(v -> onClick(v.getId()));
  100 + mContext.binding.cp.setFlash(false);
  101 + mContext.binding.sv.setType(QrConfig.TYPE_QRCODE);
  102 +
  103 + mContext.binding.sv.setCornerColor(CORNER_COLOR);
  104 + mContext.binding.sv.setLineSpeed(LINE_FAST);
  105 + mContext.binding.sv.setLineColor(CORNER_COLOR);
  106 +
  107 + mContext.soundPool = new SoundPool(10, AudioManager.STREAM_SYSTEM, 5);
  108 + mContext.soundPool.load(mContext, cn.bertsir.zbar.R.raw.qrcode, 1);
  109 + }
  110 +
  111 + public void setSeekBarColor(SeekBar seekBar, int color) {
  112 + seekBar.getThumb().setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
  113 + seekBar.getProgressDrawable().setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
  114 + }
  115 +
  116 + private void onClick(int id) {
  117 + if (R.id.rl_flashalight == id) {
  118 + if (!mContext.isFlight) {
  119 + mContext.binding.cp.setFlash(true);
  120 + mContext.binding.ivFlashlightKg.setBackgroundResource(R.drawable.gz_shoudian_hover);
  121 + mContext.binding.tvFlashlightArlt.setText("轻触关闭");
  122 + mContext.binding.tvFlashlightArlt.setTextColor(mContext.getResources().getColor(R.color.color_1aad19));
  123 + mContext.isFlight = true;
  124 + } else {
  125 + mContext.binding.cp.setFlash(false);
  126 + mContext.binding.ivFlashlightKg.setBackgroundResource(R.drawable.gz_shoudian);
  127 + mContext.binding.tvFlashlightArlt.setText("轻触点亮");
  128 + mContext.binding.tvFlashlightArlt.setTextColor(mContext.getResources().getColor(R.color.white));
  129 + mContext.isFlight = false;
  130 + }
  131 + } else if (R.id.rl_my_qr == id) {
  132 + ArrayList urls = new ArrayList();
  133 + UserService userService = UserService.getInstance(mContext);
  134 + urls.add(userService.getAppAccount().getFaceUrl());
  135 + GenerateQRActivity.startActivity(mContext, urls, userService.getAppAccount().getNickName(), userService.getAppAccount().getLocation(), "扫描二维码,加我好友", "user", "....");
  136 + }
  137 + }
  138 +
  139 + //开始的生命周期
  140 + public void onStart() {
  141 + if (mContext == null) return;
  142 + try {
  143 + } catch (Exception e) {
  144 + showMessage("扫描异常");
  145 + }
  146 + }
  147 +
  148 + //页面停止
  149 + public void stopScan() {
  150 + if (mContext == null) return;
  151 + if (mContext == null) return;
  152 + if (mContext.binding.cp != null) {
  153 + mContext.binding.cp.stop();
  154 + }
  155 + if (mContext.binding.cp != null) {
  156 + mContext.binding.sv.stop();
  157 + }
  158 + mContext.binding.rlLoading.setVisibility(View.VISIBLE);
  159 + }
  160 +
  161 + public void onPause() {
  162 + if (mContext == null) return;
  163 + if (mContext.binding.cp != null) {
  164 + mContext.binding.cp.stop();
  165 + }
  166 + if (mContext.binding.cp != null) {
  167 + mContext.binding.sv.stop();
  168 + }
  169 +
  170 + mContext.binding.sv.onPause();
  171 + mContext.binding.cp.setFlash(false);
  172 + mContext.binding.ivFlashlightKg.setBackgroundResource(R.drawable.gz_shoudian);
  173 + mContext.binding.tvFlashlightArlt.setText("轻触点亮");
  174 + mContext.binding.tvFlashlightArlt.setTextColor(mContext.getResources().getColor(R.color.white));
  175 + mContext.isFlight = false;
  176 + }
  177 +
  178 + /**
  179 + * 展示错误信息
  180 + *
  181 + * @param content
  182 + */
  183 + public void showMessage(String content) {
  184 + if (mContext == null) return;
  185 + AlertUtil.showDeftToast(mContext, content);
  186 + }
  187 +
  188 +
  189 + private String[] showAumPermission = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE};
  190 +
  191 + /**
  192 + * 打开相册
  193 + */
  194 + public void showAum(boolean checkOnly) {
  195 + if (mContext == null) return;
  196 + if (!ImagePickerComUtils.isSdExist()) {
  197 + showMessage("SD卡不存在");
  198 + return;
  199 + }
  200 +
  201 + if(checkOnly){
  202 + mContext.requestPermission(showAumPermission, String.valueOf(R.string.dialog_imagepicker_permission_sdcard_message), new OnPermissionResponseListener() {
  203 + @Override
  204 + public void onSuccess(String[] permissions) {
  205 + new ImagePicker.Builder()
  206 + .maxNum(1)
  207 + .maxImageSize(image_item_max_size)
  208 + .setSelectGif(false)
  209 + .selectMode(PickerConfig.PICKER_IMAGE)
  210 + .cachePath(Environment.getExternalStorageDirectory() + "/strike/file/")
  211 + .isFriendCircle(true)
  212 + .builder()
  213 + .start((Activity) mContext, 200, PickerConfig.DEFAULT_RESULT_CODE);
  214 + }
  215 +
  216 + @Override
  217 + public void onFail() {
  218 +
  219 + }
  220 + });
  221 + }else {
  222 +
  223 + }
  224 + }
  225 +
  226 +
  227 + /**
  228 + * 开始扫描
  229 + */
  230 + public void startScan() {
  231 + if (mContext == null) return;
  232 + if (mContext.binding.cp != null) {
  233 + mContext.binding.cp.start();
  234 + }
  235 + if (mContext.binding.cp != null) {
  236 + mContext.binding.sv.startScan();
  237 + }
  238 +
  239 + }
  240 +
  241 +
  242 + /**
  243 + * 清除鲁班压缩后的文件
  244 + *
  245 + * @param luBanFile
  246 + */
  247 + public void clearLuBan(File luBanFile) {
  248 + if (luBanFile != null && luBanFile.getAbsolutePath().contains("current")) {
  249 + FileUtils.deleteFile(luBanFile);
  250 + Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
  251 + Uri uri = Uri.fromFile(luBanFile);
  252 + intent.setData(uri);
  253 + mContext.sendBroadcast(intent);
  254 + }
  255 + }
  256 +
  257 + /**
  258 + * 鲁班压缩完成
  259 + *
  260 + * @param file
  261 + */
  262 + public void lubanSuccessed(File file) {
  263 + if (file != null && file.exists()) mContext.luBanFile = file;
  264 + }
  265 +
  266 + public void processQrContent(String qrContent) {
  267 + if (mContext == null) return;
  268 + QrContentUtil.getInstance().getQrContent(mContext, qrContent, new IdentifyTheQRCodeCallback() {
  269 +
  270 + @Override
  271 + public void qRCodeCallback(boolean isIdentify, String message) {
  272 + mContext.binding.rlLoading.setVisibility(View.GONE);
  273 + if (!isIdentify) {
  274 + showMessage(message);
  275 + disposable = Observable.timer(2, TimeUnit.SECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(aLong -> {
  276 + startScan();
  277 + });
  278 + } else {
  279 + mContext.finish();
  280 + }
  281 + }
  282 + });
  283 + }
  284 +
  285 + public void onDestory() {
  286 + if (disposable != null) disposable.dispose();
  287 + }
  288 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/frame/view/SpeakerBindStateView.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.frame.view;
  2 +
  3 +import android.text.TextUtils;
  4 +import android.view.View;
  5 +
  6 +import com.cnlive.core.libs.base.frame.view.BaseView;
  7 +import com.cnlive.core.libs.base.util.StatusBarUtil;
  8 +import com.cnlive.strike.moudle.qr.R;
  9 +import com.cnlive.strike.moudle.qr.ui.activity.SpeakerBindStateActivity;
  10 +import com.qmuiteam.qmui.widget.QMUITopBar;
  11 +
  12 +/**
  13 + * 作者: 吴奎庆
  14 + * <p>
  15 + * 时间: 2019/10/11
  16 + * <p>
  17 + * 简介:
  18 + */
  19 +public class SpeakerBindStateView extends BaseView {
  20 + SpeakerBindStateActivity mActivity;
  21 + private QMUITopBar toolbar;
  22 +
  23 + public SpeakerBindStateView(SpeakerBindStateActivity mActivity) {
  24 + this.mActivity = mActivity;
  25 + }
  26 +
  27 + public void initView(String content) {
  28 +
  29 + StatusBarUtil.setStatusBarWrite(mActivity);
  30 + StatusBarUtil.setColor(mActivity, mActivity.getResources().getColor(R.color.color_fff), 0);
  31 + toolbar = (QMUITopBar) mActivity.binding.includeToolbar.topbar;
  32 +// toolbar.setTitle("扫描结果");
  33 + toolbar.setBackgroundColor(mActivity.getResources().getColor(R.color.white));
  34 + toolbar.addLeftImageButton(R.drawable.xzq_fh, R.id.qmui_topbar_item_left_back).setOnClickListener(new View.OnClickListener() {
  35 + @Override
  36 + public void onClick(View v) {
  37 + mActivity.finish();
  38 + }
  39 + });
  40 + mActivity.binding.tvSuccess.setOnClickListener(v -> {
  41 + mActivity.finish();
  42 + });
  43 + }
  44 +
  45 + public void processFailData(int code, String message) {
  46 + mActivity.binding.ivIcon.setBackgroundResource(R.drawable.iv_speaker_fail);
  47 + mActivity.binding.tvState.setTextColor(mActivity.getResources().getColor(R.color.color_f10));
  48 + mActivity.binding.tvState.setText("绑定失败");
  49 + mActivity.binding.tvMessage.setText(message);
  50 + mActivity.binding.tvSuccess.setVisibility(View.GONE);
  51 + toolbar.setTitle("绑定失败");
  52 + }
  53 +
  54 + public void showSucesss(String code, String message) {
  55 +
  56 + if (!TextUtils.isEmpty(code)) {
  57 + if (code.equals("0")) {
  58 + mActivity.binding.ivIcon.setBackgroundResource(R.drawable.iv_speaker_success);
  59 + mActivity.binding.tvState.setTextColor(mActivity.getResources().getColor(R.color.color_23d31e));
  60 + mActivity.binding.tvState.setText("绑定成功");
  61 + mActivity.binding.tvMessage.setText(message);
  62 + toolbar.setTitle("绑定成功");
  63 + mActivity.binding.tvSuccess.setVisibility(View.VISIBLE);
  64 + }
  65 + }
  66 +
  67 + }
  68 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/model/CheckQrUrlInfo.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.model;
  2 +
  3 +/**
  4 + * 作者: 吴奎庆
  5 + * <p>
  6 + * 时间: 2018/9/30
  7 + * <p>
  8 + * 简介: 校验二维码是否合法
  9 + */
  10 +
  11 +public class CheckQrUrlInfo {
  12 +
  13 + /**
  14 + * checkDetail : 扫描二维码内容合法
  15 + * code : 0
  16 + */
  17 +
  18 + private String checkDetail;
  19 + private int code;
  20 +
  21 + public String getCheckDetail() {
  22 + return checkDetail;
  23 + }
  24 +
  25 + public void setCheckDetail(String checkDetail) {
  26 + this.checkDetail = checkDetail;
  27 + }
  28 +
  29 + public int getCode() {
  30 + return code;
  31 + }
  32 +
  33 + public void setCode(int code) {
  34 + this.code = code;
  35 + }
  36 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/model/CottonCandyInfo.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.model;
  2 +
  3 +/**
  4 + * 作者: 吴奎庆
  5 + * <p>
  6 + * 时间: 2018/12/6
  7 + * <p>
  8 + * 简介:
  9 + */
  10 +public class CottonCandyInfo {
  11 +
  12 + /**
  13 + * darenId : daren_378258
  14 + * face : http://wjj.ys1.cnliveimg.com/769/img/2018/0416/head_b.png
  15 + * price : 0.01
  16 + * shopName : 粉熊朵朵
  17 + * orderId : e4f3da07b8804aab9be59e559faa5a33
  18 + * paymentType : {"wechat":true,"ali":true,"wjj":true,"union":true}
  19 + */
  20 +
  21 + private String darenId;
  22 + private String face;
  23 + private double price;
  24 + private String shopName;
  25 + private String orderId;
  26 + private PaymentTypeBean paymentType;
  27 +
  28 + public String getDarenId() {
  29 + return darenId;
  30 + }
  31 +
  32 + public void setDarenId(String darenId) {
  33 + this.darenId = darenId;
  34 + }
  35 +
  36 + public String getFace() {
  37 + return face;
  38 + }
  39 +
  40 + public void setFace(String face) {
  41 + this.face = face;
  42 + }
  43 +
  44 + public double getPrice() {
  45 + return price;
  46 + }
  47 +
  48 + public void setPrice(double price) {
  49 + this.price = price;
  50 + }
  51 +
  52 + public String getShopName() {
  53 + return shopName;
  54 + }
  55 +
  56 + public void setShopName(String shopName) {
  57 + this.shopName = shopName;
  58 + }
  59 +
  60 + public String getOrderId() {
  61 + return orderId;
  62 + }
  63 +
  64 + public void setOrderId(String orderId) {
  65 + this.orderId = orderId;
  66 + }
  67 +
  68 + public PaymentTypeBean getPaymentType() {
  69 + return paymentType;
  70 + }
  71 +
  72 + public void setPaymentType(PaymentTypeBean paymentType) {
  73 + this.paymentType = paymentType;
  74 + }
  75 +
  76 + public static class PaymentTypeBean {
  77 + /**
  78 + * wechat : true
  79 + * ali : true
  80 + * wjj : true
  81 + * union : true
  82 + */
  83 +
  84 + private boolean wechat;
  85 + private boolean ali;
  86 + private boolean wjj;
  87 + private boolean union;
  88 +
  89 + public boolean isWechat() {
  90 + return wechat;
  91 + }
  92 +
  93 + public void setWechat(boolean wechat) {
  94 + this.wechat = wechat;
  95 + }
  96 +
  97 + public boolean isAli() {
  98 + return ali;
  99 + }
  100 +
  101 + public void setAli(boolean ali) {
  102 + this.ali = ali;
  103 + }
  104 +
  105 + public boolean isWjj() {
  106 + return wjj;
  107 + }
  108 +
  109 + public void setWjj(boolean wjj) {
  110 + this.wjj = wjj;
  111 + }
  112 +
  113 + public boolean isUnion() {
  114 + return union;
  115 + }
  116 +
  117 + public void setUnion(boolean union) {
  118 + this.union = union;
  119 + }
  120 + }
  121 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/model/CreateQrInfo.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.model;
  2 +
  3 +public class CreateQrInfo {
  4 +
  5 +
  6 + public String getQrcode() {
  7 + return qrcode;
  8 + }
  9 +
  10 + public void setQrcode(String qrcode) {
  11 + this.qrcode = qrcode;
  12 + }
  13 +
  14 + private String qrcode;
  15 +}
0 \ No newline at end of file 16 \ No newline at end of file
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/model/DarenInfoModel.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.model;
  2 +
  3 +import java.util.List;
  4 +
  5 +/**
  6 + * 获取达人信息
  7 + *
  8 + * @author Lynn
  9 + * @date 2018/2/6
  10 + */
  11 +
  12 +public class DarenInfoModel {
  13 + private String darenId;
  14 + private int sid;
  15 + private String face;
  16 + private String nickName;
  17 + private List<CategoryModel> category;
  18 + private String wxOpenId;
  19 + private int status;
  20 + private String address;
  21 + private String shopName;
  22 + private String realName;
  23 + private String custSign;
  24 + private String type;
  25 + private int followNum;
  26 + private int fansNum;
  27 +
  28 + public String getDarenId() {
  29 + return darenId;
  30 + }
  31 +
  32 + public void setDarenId(String darenId) {
  33 + this.darenId = darenId;
  34 + }
  35 +
  36 + public int getSid() {
  37 + return sid;
  38 + }
  39 +
  40 + public void setSid(int sid) {
  41 + this.sid = sid;
  42 + }
  43 +
  44 + public String getFace() {
  45 + return face;
  46 + }
  47 +
  48 + public void setFace(String face) {
  49 + this.face = face;
  50 + }
  51 +
  52 + public String getNickName() {
  53 + return nickName;
  54 + }
  55 +
  56 + public void setNickName(String nickName) {
  57 + this.nickName = nickName;
  58 + }
  59 +
  60 + public List<CategoryModel> getCategoryList() {
  61 + return category;
  62 + }
  63 +
  64 + public void setCategoryList(List<CategoryModel> categoryList) {
  65 + this.category = categoryList;
  66 + }
  67 +
  68 + public String getWxOpenId() {
  69 + return wxOpenId;
  70 + }
  71 +
  72 + public void setWxOpenId(String wxOpenId) {
  73 + this.wxOpenId = wxOpenId;
  74 + }
  75 +
  76 + public int getStatus() {
  77 + return status;
  78 + }
  79 +
  80 + public void setStatus(int status) {
  81 + this.status = status;
  82 + }
  83 +
  84 + public String getAddress() {
  85 + return address;
  86 + }
  87 +
  88 + public void setAddress(String address) {
  89 + this.address = address;
  90 + }
  91 +
  92 + public String getShopName() {
  93 + return shopName;
  94 + }
  95 +
  96 + public void setShopName(String shopName) {
  97 + this.shopName = shopName;
  98 + }
  99 +
  100 + public String getRealName() {
  101 + return realName;
  102 + }
  103 +
  104 + public void setRealName(String realName) {
  105 + this.realName = realName;
  106 + }
  107 +
  108 + public String getCustSign() {
  109 + return custSign;
  110 + }
  111 +
  112 + public void setCustSign(String custSign) {
  113 + this.custSign = custSign;
  114 + }
  115 +
  116 + public String getType() {
  117 + return type;
  118 + }
  119 +
  120 + public void setType(String type) {
  121 + this.type = type;
  122 + }
  123 +
  124 + public int getFollowNum() {
  125 + return followNum;
  126 + }
  127 +
  128 + public void setFollowNum(int followNum) {
  129 + this.followNum = followNum;
  130 + }
  131 +
  132 + public int getFansNum() {
  133 + return fansNum;
  134 + }
  135 +
  136 + public void setFansNum(int fansNum) {
  137 + this.fansNum = fansNum;
  138 + }
  139 +
  140 + public static class CategoryModel {
  141 + private List<TypeModel> categoryItems;
  142 + private CategoryIcon categoryIcon;
  143 +
  144 + public List<TypeModel> getCategoryItems() {
  145 + return categoryItems;
  146 + }
  147 +
  148 + public void setCategoryItems(List<TypeModel> categoryItems) {
  149 + this.categoryItems = categoryItems;
  150 + }
  151 +
  152 + public CategoryIcon getCategoryIcon() {
  153 + return categoryIcon;
  154 + }
  155 +
  156 + public void setCategoryIcon(CategoryIcon categoryIcon) {
  157 + this.categoryIcon = categoryIcon;
  158 + }
  159 +
  160 + public static class TypeModel {
  161 + private String typeName;
  162 + private String color;
  163 + private String typeId;
  164 +
  165 + public String getTypeName() {
  166 + return typeName;
  167 + }
  168 +
  169 + public void setTypeName(String typeName) {
  170 + this.typeName = typeName;
  171 + }
  172 +
  173 + public String getColor() {
  174 + return color;
  175 + }
  176 +
  177 + public void setColor(String color) {
  178 + this.color = color;
  179 + }
  180 +
  181 + public String getTypeId() {
  182 + return typeId;
  183 + }
  184 +
  185 + public void setTypeId(String typeId) {
  186 + this.typeId = typeId;
  187 + }
  188 +
  189 + }
  190 +
  191 + public static class CategoryIcon {
  192 + private String categoryName;
  193 + private String categoryId;
  194 + private String categoryImage;
  195 +
  196 + public String getCategoryName() {
  197 + return categoryName;
  198 + }
  199 +
  200 + public void setCategoryName(String categoryName) {
  201 + this.categoryName = categoryName;
  202 + }
  203 +
  204 + public String getCategoryId() {
  205 + return categoryId;
  206 + }
  207 +
  208 + public void setCategoryId(String categoryId) {
  209 + this.categoryId = categoryId;
  210 + }
  211 +
  212 + public String getCategoryImage() {
  213 + return categoryImage;
  214 + }
  215 +
  216 + public void setCategoryImage(String categoryImage) {
  217 + this.categoryImage = categoryImage;
  218 + }
  219 + }
  220 + }
  221 +
  222 + @Override
  223 + public String toString() {
  224 + return "DarenInfoModel{" +
  225 + "darenId='" + darenId + '\'' +
  226 + ", sid=" + sid +
  227 + ", face='" + face + '\'' +
  228 + ", category=" + category +
  229 + ", wxOpenId='" + wxOpenId + '\'' +
  230 + ", status=" + status +
  231 + ", address='" + address + '\'' +
  232 + ", shopName='" + shopName + '\'' +
  233 + ", realName='" + realName + '\'' +
  234 + ", custSign='" + custSign + '\'' +
  235 + ", type=" + type +
  236 + '}';
  237 + }
  238 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/model/QRCodeReceiptData.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.model;
  2 +
  3 +
  4 +import androidx.databinding.BaseObservable;
  5 +
  6 +/**
  7 + * 二維碼收款數據
  8 + */
  9 +public class QRCodeReceiptData extends BaseObservable {
  10 +
  11 + private String userAvatar;
  12 + private String userName;
  13 + private double paymentAmount;
  14 + private String payTime;
  15 +
  16 + public String getUserAvatar() {
  17 + return userAvatar;
  18 + }
  19 +
  20 + public void setUserAvatar(String userAvatar) {
  21 + this.userAvatar = userAvatar;
  22 + }
  23 +
  24 + public String getUserName() {
  25 + return userName;
  26 + }
  27 +
  28 + public void setUserName(String userName) {
  29 + this.userName = userName;
  30 + }
  31 +
  32 + public double getPaymentAmount() {
  33 + return paymentAmount;
  34 + }
  35 +
  36 + public void setPaymentAmount(double paymentAmount) {
  37 + this.paymentAmount = paymentAmount;
  38 + }
  39 +
  40 + public String getPayTime() {
  41 + return payTime;
  42 + }
  43 +
  44 + public void setPayTime(String payTime) {
  45 + this.payTime = payTime;
  46 + }
  47 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/model/QrActivityInfo.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.model;
  2 +
  3 +/**
  4 + * 作者: 吴奎庆
  5 + * <p>
  6 + * 时间: 2018/8/29
  7 + * <p>
  8 + * 简介:
  9 + */
  10 +
  11 +public class QrActivityInfo {
  12 + String qrActivityUrl;
  13 +
  14 + public String getQrActivityUrl() {
  15 + return qrActivityUrl;
  16 + }
  17 +
  18 + public void setQrActivityUrl(String qrActivityUrl) {
  19 + this.qrActivityUrl = qrActivityUrl;
  20 + }
  21 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/model/QrContentBean.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.model;
  2 +
  3 +/**
  4 + * 作者: 吴奎庆
  5 + * <p>
  6 + * 时间: 2018/9/17
  7 + * <p>
  8 + * 简介: 二维码识别的内容
  9 + */
  10 +
  11 +public class QrContentBean {
  12 + String type;
  13 + String content;
  14 + Long time;
  15 +
  16 + public Long getTime() {
  17 + return time;
  18 + }
  19 +
  20 + public void setTime(Long time) {
  21 + this.time = time;
  22 + }
  23 +
  24 + public String getType() {
  25 + return type;
  26 + }
  27 +
  28 + public void setType(String type) {
  29 + this.type = type;
  30 + }
  31 +
  32 + public String getContent() {
  33 + return content;
  34 + }
  35 +
  36 + public void setContent(String content) {
  37 + this.content = content;
  38 + }
  39 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/model/QrInfo.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.model;
  2 +
  3 +/**
  4 + * 创建:wukuiqing
  5 + * <p>
  6 + * 时间:2018/4/25
  7 + * <p>
  8 + * 描述: 二维码生成的数据结构
  9 + */
  10 +
  11 +public class QrInfo {
  12 +
  13 + public String getSid() {
  14 + return sid;
  15 + }
  16 +
  17 + public void setSid(String sid) {
  18 + this.sid = sid;
  19 + }
  20 +
  21 + public String getToken() {
  22 + return token;
  23 + }
  24 +
  25 + public void setToken(String token) {
  26 + this.token = token;
  27 + }
  28 +
  29 + public String getType() {
  30 + return type;
  31 + }
  32 +
  33 + public void setType(String type) {
  34 + this.type = type;
  35 + }
  36 +
  37 + private String sid;
  38 + private String token;
  39 + //二维码的类型 type user 表示 个人名片
  40 + private String type;
  41 +
  42 + public String getNick() {
  43 + return nick;
  44 + }
  45 +
  46 + public void setNick(String nick) {
  47 + this.nick = nick;
  48 + }
  49 +
  50 + private String nick;
  51 +
  52 + public String getFace() {
  53 + return face;
  54 + }
  55 +
  56 + public void setFace(String face) {
  57 + this.face = face;
  58 + }
  59 +
  60 + private String face;
  61 +
  62 +
  63 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/model/QrOrderInfo.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.model;
  2 +
  3 +/**
  4 + * 作者: 吴奎庆
  5 + * <p>
  6 + * 时间: 2018/7/11
  7 + * <p>
  8 + * 简介:
  9 + */
  10 +
  11 +public class QrOrderInfo {
  12 +
  13 +
  14 + private String orderId;
  15 + private String remark;
  16 +
  17 + public String getOrderId() {
  18 + return orderId;
  19 + }
  20 +
  21 + public void setOrderId(String orderId) {
  22 + this.orderId = orderId;
  23 + }
  24 +
  25 + public String getRemark() {
  26 + return remark;
  27 + }
  28 +
  29 + public void setRemark(String remark) {
  30 + this.remark = remark;
  31 + }
  32 +
  33 + public double getPrice() {
  34 + return price;
  35 + }
  36 +
  37 + public void setPrice(double price) {
  38 + this.price = price;
  39 + }
  40 +
  41 + private double price;
  42 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/model/QrPayBean.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.model;
  2 +
  3 +/**
  4 + * 作者: 吴奎庆
  5 + * <p>
  6 + * 时间: 2018/7/10
  7 + * <p>
  8 + * 简介: 生成二维码封装的content数据
  9 + */
  10 +
  11 +public class QrPayBean {
  12 + String darenId;
  13 + String payMoney;
  14 +
  15 + public String getDarenId() {
  16 + return darenId;
  17 + }
  18 +
  19 + public void setDarenId(String darenId) {
  20 + this.darenId = darenId;
  21 + }
  22 +
  23 + public String getPayMoney() {
  24 + return payMoney;
  25 + }
  26 +
  27 + public void setPayMoney(String payMoney) {
  28 + this.payMoney = payMoney;
  29 + }
  30 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/model/QrSignInfo.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.model;
  2 +
  3 +/**
  4 + * 作者: 吴奎庆
  5 + * <p>
  6 + * 时间: 2018/8/28
  7 + * <p>
  8 + * 简介:
  9 + */
  10 +
  11 +public class QrSignInfo {
  12 + String msg;
  13 +
  14 + public String getType() {
  15 + return type;
  16 + }
  17 +
  18 + public void setType(String type) {
  19 + this.type = type;
  20 + }
  21 +
  22 + String type;
  23 +
  24 + public String getMsg() {
  25 + return msg;
  26 + }
  27 +
  28 + public void setMsg(String msg) {
  29 + this.msg = msg;
  30 + }
  31 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/observable/QRCodeReceiptObservable.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.observable;
  2 +
  3 +import com.cnlive.strike.moudle.qr.model.QRCodeReceiptData;
  4 +
  5 +import java.util.Observable;
  6 +
  7 +/**
  8 + * Created by gujun on 2018/7/12.
  9 + * 二維碼收款的狀態的監聽
  10 + */
  11 +
  12 +public class QRCodeReceiptObservable extends Observable {
  13 +
  14 + private static QRCodeReceiptObservable instance = new QRCodeReceiptObservable();
  15 +
  16 + public static QRCodeReceiptObservable getInstance() {
  17 + return instance;
  18 + }
  19 +
  20 + public void updatePayStatus(QRCodeReceiptData data) {
  21 + setChanged();
  22 + notifyObservers(data);
  23 + }
  24 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/routers/QrRouters.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.routers;
  2 +
  3 +import android.content.Context;
  4 +import android.text.TextUtils;
  5 +
  6 +import com.alibaba.android.arouter.launcher.ARouter;
  7 +import com.cnlive.strike.moudle.qr.model.CottonCandyInfo;
  8 +import com.cnlive.strike.moudle.qr.model.QrInfo;
  9 +import com.cnlive.strike.user.auth.UserService;
  10 +
  11 +/**
  12 + * 作者: 吴奎庆
  13 + * <p>
  14 + * 时间: 2018/12/11
  15 + * <p>
  16 + * 简介:
  17 + */
  18 +public class QrRouters {
  19 + /**
  20 + * 棉花糖支付的逻辑
  21 + *
  22 + * @param fromId
  23 + * @param orderId
  24 + * @param price
  25 + * @param toId
  26 + * @param qrPay
  27 + * @param toName
  28 + * @param isGroup
  29 + * @param fromType
  30 + * @param toType
  31 + * @param sourceType
  32 + * @param title
  33 + * @param toFace
  34 + * @param remark
  35 + * @param paymentType
  36 + */
  37 + public static void startRouterCottonCandyPay(Context context, String fromId, String orderId, double price, String toId, boolean qrPay, String toName, boolean isGroup, String fromType, String toType, String sourceType, String title, String toFace, String remark, CottonCandyInfo.PaymentTypeBean paymentType) {
  38 +
  39 + if (paymentType == null) {
  40 + ARouter.getInstance().build("/cnuser/PayActivity")
  41 + .withString("fromId", fromId)
  42 + .withString("orderId", orderId)
  43 + .withDouble("price", price)
  44 + .withString("toId", toId)
  45 + .withString("toName", toName)
  46 + .withBoolean("qrPay", qrPay)
  47 + .withBoolean("isGroup", isGroup)
  48 +
  49 + .withBoolean("wechat", true)
  50 + .withBoolean("ali", true)
  51 + .withBoolean("wjj", true)
  52 + .withBoolean("union", true)
  53 +
  54 + .withString("fromType", fromType)
  55 + .withString("toType", toType)
  56 + .withString("sourceType", sourceType)
  57 + .withString("title", title)
  58 + .withString("toFace", toFace)
  59 + .withString("remark", remark)
  60 + .withString("jumpType", "cottonCandyType")
  61 + .navigation(context);
  62 + } else {
  63 + ARouter.getInstance().build("/cnuser/PayActivity")
  64 + .withString("fromId", fromId)
  65 + .withString("orderId", orderId)
  66 + .withDouble("price", price)
  67 + .withString("toId", toId)
  68 + .withString("toName", toName)
  69 + .withBoolean("qrPay", qrPay)
  70 + .withBoolean("isGroup", isGroup)
  71 +
  72 + .withBoolean("wechat", paymentType.isWechat())
  73 + .withBoolean("ali", paymentType.isAli())
  74 + .withBoolean("wjj", paymentType.isWjj())
  75 + .withBoolean("union", paymentType.isUnion())
  76 +
  77 + .withString("fromType", fromType)
  78 + .withString("toType", toType)
  79 + .withString("sourceType", sourceType)
  80 + .withString("title", title)
  81 + .withString("toFace", toFace)
  82 + .withString("remark", remark)
  83 + .withString("jumpType", "cottonCandyType")
  84 + .navigation(context);
  85 + }
  86 +
  87 + }
  88 +
  89 + /**
  90 + * 棉花糖支付的逻辑
  91 + *
  92 + * @param fromId
  93 + * @param orderId
  94 + * @param price
  95 + * @param toId
  96 + * @param qrPay
  97 + * @param toName
  98 + * @param isGroup
  99 + * @param fromType
  100 + * @param toType
  101 + * @param sourceType
  102 + * @param title
  103 + * @param toFace
  104 + * @param remark
  105 + */
  106 + public static void startOrderQrPay(Context context, String fromId, String orderId, double price, String toId, boolean qrPay, String toName, boolean isGroup, String fromType, String toType, String sourceType, String title, String toFace, String remark) {
  107 + ARouter.getInstance().build("/cnuser/PayActivity")
  108 + .withString("fromId", fromId)
  109 + .withString("orderId", orderId)
  110 + .withDouble("price", price)
  111 + .withString("toId", toId)
  112 + .withString("toName", toName)
  113 + .withBoolean("qrPay", qrPay)
  114 + .withBoolean("isGroup", isGroup)
  115 + .withString("fromType", fromType)
  116 + .withString("toType", toType)
  117 + .withString("sourceType", sourceType)
  118 + .withString("title", title)
  119 + .withString("toFace", toFace)
  120 + .withString("remark", remark)
  121 + .withString("jumpType", "qrType")
  122 + .navigation(context);
  123 + }
  124 +
  125 + /**
  126 + * 跳转到其他页面
  127 + *
  128 + * @param url
  129 + * @param uid
  130 + */
  131 + public static void startOther(Context context, String url, String uid) {
  132 + ARouter.getInstance().build("/web/WebViewActivity")
  133 + .withString("rSid", uid == null ? "" : uid)
  134 + .withString("rUrl", url == null ? "" : url)
  135 + .withBoolean("rEnableTitle", false)
  136 + .withBoolean("enableMore", true)
  137 + .withBoolean("rEnableJump", false)
  138 + .withBoolean("rNeedSign", true)
  139 + .withBoolean("rIsOther", false)
  140 + .withBoolean("rEnableRefresh", true)
  141 + .navigation(context);
  142 + }
  143 +
  144 + /**
  145 + * tiao转到订单详情
  146 + *
  147 + * @param orderId
  148 + * @param inType
  149 + * @param inStatus
  150 + */
  151 + public static void startOrderDetail(Context context, String orderId, int inType, String inStatus) {
  152 +
  153 + ARouter.getInstance().build("/cnuser/OrderDetailActivity")
  154 + .withString("orderId", orderId == null ? "" : orderId)
  155 + .withInt("inType", inType)
  156 + .withString("inStatus", inStatus == null ? "-1" : inStatus)
  157 + .navigation(context);
  158 + }
  159 +
  160 + /**
  161 + * 跳转到用户页面
  162 + *
  163 + * @param qrInfo
  164 + */
  165 + public static void startUserDetail(Context context, QrInfo qrInfo) {
  166 + ARouter.getInstance().build("/chat/UserInfoActivity")
  167 + .withString("rNickName", qrInfo.getNick())
  168 + .withString("rImage", qrInfo.getFace())
  169 + .withString("rUserId", qrInfo.getSid())
  170 + .navigation(context);
  171 + }
  172 +
  173 + /**
  174 + * 扫码支付
  175 + *
  176 + * @param action
  177 + * @param darenId
  178 + */
  179 + public static void startQrPay(Context context, int action, String darenId) {
  180 + ARouter.getInstance().build("/qr/QrPayActivity")
  181 + .withInt("action", action)
  182 + .withString("darenId", darenId == null ? "" : darenId)
  183 + .navigation(context);
  184 + }
  185 +
  186 + /**
  187 + * 跳转到明星圈子
  188 + *
  189 + * @param context
  190 + * @param homepageId
  191 + */
  192 + public static void startStarDetail(Context context, String homepageId, boolean isStarPage) {
  193 + String userId = UserService.getUid(context);
  194 + if (TextUtils.isEmpty(homepageId) || TextUtils.isEmpty(userId)) return;
  195 + ARouter.getInstance().build("/cnsubscription/SubscriptionDetailActivity")
  196 + .withString("spId", homepageId)
  197 + .withString("userId", userId)
  198 + .withBoolean("isStarPage", isStarPage)
  199 + .navigation(context);
  200 + }
  201 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/routers/service/QrServiceImpl.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.routers.service;
  2 +
  3 +import android.content.Context;
  4 +import android.graphics.Bitmap;
  5 +
  6 +import com.alibaba.android.arouter.facade.annotation.Route;
  7 +import com.cnlive.core.libs.base.arouter.QrService;
  8 +import com.cnlive.strike.moudle.qr.uitl.QRCodeUtil;
  9 +import androidx.annotation.Nullable;
  10 +
  11 +/**
  12 + * 作者: 吴奎庆
  13 + * <p>
  14 + * 时间: 2019/6/18
  15 + * <p>
  16 + * 简介:
  17 + */
  18 +@Route(path = QrService.PATH, name = QrService.NAME, group = QrService.GROUP)
  19 +public class QrServiceImpl implements QrService {
  20 +
  21 + @Override
  22 + public Bitmap createQrIconBitMap(String s, int i, @Nullable Bitmap bitmap, float v) {
  23 + return QRCodeUtil.createQRCodeBitmap(s, i, bitmap, v);
  24 + }
  25 +
  26 + @Override
  27 + public Bitmap createQRNoIconBitmap(@Nullable String s, int i) {
  28 + return QRCodeUtil.createQRCodeBitmap(s, i);
  29 + }
  30 +
  31 + @Override
  32 + public void init(Context context) {
  33 + }
  34 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/ui/activity/GenerateQRActivity.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.ui.activity;
  2 +
  3 +import android.app.Dialog;
  4 +import android.content.Context;
  5 +import android.content.Intent;
  6 +import android.view.View;
  7 +
  8 +import com.alibaba.android.arouter.facade.annotation.Route;
  9 +import com.cnlive.core.libs.base.frame.activity.BaseActivity;
  10 +import com.cnlive.core.libs.base.ui.widget.BottomSheet;
  11 +import com.cnlive.core.libs.base.util.DoublePressed;
  12 +import com.cnlive.core.libs.base.util.StatusBarUtil;
  13 +import com.cnlive.strike.moudle.qr.R;
  14 +import com.cnlive.strike.moudle.qr.databinding.ActivityGenerateQrBinding;
  15 +import com.cnlive.strike.moudle.qr.frame.presenter.GenerateQRPresenter;
  16 +import com.cnlive.strike.moudle.qr.frame.view.GenerateQRView;
  17 +import com.qmuiteam.qmui.widget.QMUITopBar;
  18 +
  19 +import java.util.ArrayList;
  20 +
  21 +
  22 +/**
  23 + * 创建:wukuiqing
  24 + * <p>
  25 + * 时间:2018/4/25
  26 + * <p>
  27 + * 描述: 二维码名片
  28 + */
  29 +@Route(path = "/qr/GenerateQRActivity")
  30 +public class GenerateQRActivity extends BaseActivity<GenerateQRView, GenerateQRPresenter> {
  31 +
  32 + private Dialog bottomDialog;
  33 + //头像
  34 + private ArrayList userUrl;
  35 + //名字
  36 + private String userName;
  37 + //位置
  38 + private String address;
  39 + //底部提醒文字
  40 + private String bomHint;
  41 + //二维码的类型 orderCode 订单二维码类型 user 用户的个人的二维码
  42 + public String qrType;
  43 + // 封装进二维码的数据
  44 + private String content;
  45 +
  46 + //是否生成了二维码
  47 + public boolean isCreateQr;
  48 + public ActivityGenerateQrBinding binding;
  49 +
  50 + //TODO 目前此页面不支持群头像展示逻辑,如果后期添加的话把groupId传参
  51 + public static void startActivity(Context context, ArrayList userUrl, String userName, String address, String bomHint, String qrType, String content) {
  52 + Intent intent = new Intent(context, GenerateQRActivity.class);
  53 + intent.putStringArrayListExtra("userUrl", userUrl);
  54 + intent.putExtra("userName", userName);
  55 + intent.putExtra("address", address);
  56 + intent.putExtra("bomHint", bomHint);
  57 + intent.putExtra("content", content);
  58 + intent.putExtra("qrType", qrType);
  59 + context.startActivity(intent);
  60 + }
  61 +
  62 +
  63 + @Override
  64 + protected int getBindLayoutId() {
  65 + return R.layout.activity_generate_qr;
  66 + }
  67 +
  68 +
  69 + @Override
  70 + protected void initBindingData() {
  71 + binding = (ActivityGenerateQrBinding) baseBinding;
  72 + }
  73 +
  74 +
  75 + @Override
  76 + protected void initView() {
  77 + initViews();
  78 + }
  79 +
  80 + @Override
  81 + protected void onResume() {
  82 + super.onResume();
  83 + if (bottomDialog != null && bottomDialog.isShowing()) bottomDialog.cancel();
  84 + }
  85 +
  86 +
  87 + @Override
  88 + protected void onDestroy() {
  89 + super.onDestroy();
  90 + if (bottomDialog != null) bottomDialog.dismiss();
  91 + if (getMvpView().resetDialog != null) getMvpView().resetDialog.dismiss();
  92 + }
  93 +
  94 + private void initViews() {
  95 + StatusBarUtil.setStatusBarWrite(this);
  96 + StatusBarUtil.setColor(this, getResources().getColor(R.color.color_fff), 0);
  97 + QMUITopBar toolbar = (QMUITopBar) binding.titleBar.topbar;
  98 + toolbar.setTitle("二维码名片");
  99 + toolbar.setBackgroundColor(getResources().getColor(R.color.white));
  100 + toolbar.addLeftImageButton(R.drawable.drd_fanhui, R.id.qmui_topbar_item_left_back).setOnClickListener(new View.OnClickListener() {
  101 + @Override
  102 + public void onClick(View v) {
  103 + onBackPressed();
  104 + }
  105 + });
  106 +
  107 + bottomDialog = new BottomSheet.BottomListSheetBuilder(this)
  108 + .addItem("保存图片")
  109 + .addItem("扫描二维码")
  110 + .addItem("重置二维码", "", true)
  111 + .addItem("取消")
  112 + .setOnSheetItemClickListener((dialog, itemView, position, tag) -> {
  113 + switch (position) {
  114 + case 0:
  115 + //保存图片
  116 + if (DoublePressed.onDoublePressed()) return;
  117 + dialog.dismiss();
  118 + getMvpView().saveQr();
  119 +
  120 + break;
  121 + case 1:
  122 + //扫描二维码
  123 + dialog.dismiss();
  124 + getMvpView().scanQr();
  125 + break;
  126 + case 2:
  127 + //重置二维码
  128 +// getPresenter().createQr(this);
  129 + dialog.dismiss();
  130 + getMvpView().resetQr();
  131 +
  132 + break;
  133 + case 3:
  134 + dialog.dismiss();
  135 + break;
  136 + }
  137 + }).build();
  138 +
  139 +
  140 + qrType = getIntent().getStringExtra("qrType");
  141 + userUrl = getIntent().getStringArrayListExtra("userUrl");
  142 + userName = getIntent().getStringExtra("userName");
  143 + address = getIntent().getStringExtra("address");
  144 + bomHint = getIntent().getStringExtra("bomHint");
  145 + qrType = getIntent().getStringExtra("qrType");
  146 + content = getIntent().getStringExtra("content");
  147 +
  148 + if (qrType != null && qrType.equals("user")) {
  149 + toolbar.addRightImageButton(R.drawable.pyq_xiangxizilao_shezhi, R.id.fragment_more)
  150 + .setOnClickListener(v -> {
  151 + if (!bottomDialog.isShowing()) bottomDialog.show();
  152 + });
  153 +
  154 + getPresenter().createQr(this, "gen");
  155 + } else if (qrType != null && qrType.equals("orderCode")) {
  156 + if (content != null && !content.equals(""))
  157 + getMvpView().creataQr(content);
  158 + }
  159 +
  160 + getMvpView().setUserData(userUrl, userName, address, bomHint);
  161 +
  162 + binding.ivRef.setOnClickListener(view -> {
  163 + getPresenter().createQr(this, "gen");
  164 + });
  165 +
  166 + }
  167 +
  168 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/ui/activity/OtherQrActivity.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.ui.activity;
  2 +
  3 +import android.content.Context;
  4 +import android.content.Intent;
  5 +import android.os.Bundle;
  6 +import androidx.annotation.Nullable;
  7 +import androidx.appcompat.app.AppCompatActivity;
  8 +import androidx.databinding.DataBindingUtil;
  9 +
  10 +import android.text.TextUtils;
  11 +import android.view.View;
  12 +
  13 +import com.cnlive.core.libs.base.frame.activity.BaseActivity;
  14 +import com.cnlive.core.libs.base.util.StatusBarUtil;
  15 +import com.cnlive.strike.moudle.qr.R;
  16 +import com.cnlive.strike.moudle.qr.databinding.ActivityOtherQrBinding;
  17 +import com.qmuiteam.qmui.widget.QMUITopBar;
  18 +
  19 +/**
  20 + * 作者: 吴奎庆
  21 + * <p>
  22 + * 时间: 2018/7/13
  23 + * <p>
  24 + * 简介:
  25 + */
  26 +
  27 +public class OtherQrActivity extends BaseActivity {
  28 + public static final String KEY_CONTENT = "content";
  29 + private String content;
  30 + private ActivityOtherQrBinding binding;
  31 +
  32 + public static void startActivity(Context context, String content) {
  33 + Intent intent = new Intent(context, OtherQrActivity.class);
  34 + intent.putExtra(KEY_CONTENT, content);
  35 + context.startActivity(intent);
  36 + }
  37 +
  38 + @Override
  39 + protected int getBindLayoutId() {
  40 + return R.layout.activity_other_qr;
  41 + }
  42 +
  43 + @Override
  44 + protected void initBindingData() {
  45 + binding = (ActivityOtherQrBinding) baseBinding;
  46 + }
  47 +
  48 + @Override
  49 + protected void initView() {
  50 + initViews();
  51 + }
  52 +
  53 + private void initViews() {
  54 + StatusBarUtil.setStatusBarWrite(this);
  55 + StatusBarUtil.setColor(this, getResources().getColor(R.color.color_fff), 0);
  56 + QMUITopBar toolbar = (QMUITopBar) binding.includeToolbar.topbar;
  57 + toolbar.setTitle("扫描结果");
  58 + toolbar.setBackgroundColor(getResources().getColor(R.color.white));
  59 + toolbar.addLeftImageButton(R.drawable.drd_fanhui, R.id.qmui_topbar_item_left_back).setOnClickListener(new View.OnClickListener() {
  60 + @Override
  61 + public void onClick(View v) {
  62 + finish();
  63 + }
  64 + });
  65 + content = getIntent().getStringExtra(KEY_CONTENT);
  66 + if (TextUtils.isEmpty(content)){
  67 + content="您扫描的内容为空";
  68 + }
  69 + binding.tvContent.setText(content);
  70 + }
  71 +
  72 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/ui/activity/QrPayActivity.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.ui.activity;
  2 +
  3 +import android.content.Context;
  4 +import android.content.Intent;
  5 +import android.os.Bundle;
  6 +
  7 +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.fragment.BaseFragment;
  10 +import com.cnlive.core.libs.base.util.AlertUtil;
  11 +import com.cnlive.core.libs.base.util.StatusBarUtil;
  12 +import com.cnlive.strike.moudle.qr.R;
  13 +import com.cnlive.strike.moudle.qr.ui.fragment.QrPayFragment;
  14 +import com.qmuiteam.qmui.arch.QMUIFragment;
  15 +
  16 +/**
  17 + * 作者: 吴奎庆
  18 + * <p>
  19 + * 时间: 2018/7/11
  20 + * <p>
  21 + * 简介:
  22 + */
  23 +@Route(path = "/qr/QrPayActivity")
  24 +public class QrPayActivity extends BaseActivity {
  25 +
  26 + private static final String tag_action = "action";
  27 + private static final String tag_darenId = "darenId";
  28 + // qrpay
  29 + private static final int QRPAY = 1001;
  30 + //二维码生成
  31 + private static final int QRGENERATE = 1002;
  32 +
  33 +
  34 + public static void start(Context context, int action, String darenId) {
  35 + Intent intent = new Intent(context, QrPayActivity.class);
  36 + intent.putExtra(tag_action, action);
  37 + intent.putExtra(tag_darenId, darenId);
  38 + context.startActivity(intent);
  39 + }
  40 +
  41 + private BaseFragment fragment;
  42 +
  43 + @Override
  44 + protected void initView() {
  45 + StatusBarUtil.setStatusBarWrite(this);
  46 + int action = getIntent().getIntExtra(tag_action, -1);
  47 + String darenId= getIntent().getStringExtra(tag_darenId);
  48 + if (action == QRPAY) {
  49 + fragment = QrPayFragment.newInstance(darenId);
  50 + } else {
  51 + finish();
  52 + AlertUtil.showDeftToast(this, "不支持的内容类型.");
  53 + return;
  54 + }
  55 +
  56 + loadRootFragment(fragment);
  57 + }
  58 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/ui/activity/QrSignInActivity.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.ui.activity;
  2 +
  3 +import android.content.Context;
  4 +import android.content.Intent;
  5 +import android.os.Bundle;
  6 +
  7 +import com.cnlive.core.libs.base.frame.activity.BaseActivity;
  8 +import com.cnlive.core.libs.base.frame.fragment.BaseFragment;
  9 +import com.cnlive.core.libs.base.util.StatusBarUtil;
  10 +import com.cnlive.strike.moudle.qr.R;
  11 +import com.cnlive.strike.moudle.qr.ui.fragment.QrSignInFragment;
  12 +
  13 +/**
  14 + * 作者: 吴奎庆
  15 + * <p>
  16 + * 时间: 2018/8/28
  17 + * <p>
  18 + * 简介:
  19 + */
  20 +
  21 +public class QrSignInActivity extends BaseActivity {
  22 +
  23 + public static void start(Context context, String msg, String type) {
  24 + Intent intent = new Intent(context, QrSignInActivity.class);
  25 + intent.putExtra("msg", msg);
  26 + intent.putExtra("type", type);
  27 + context.startActivity(intent);
  28 + }
  29 +
  30 + BaseFragment fragment;
  31 +
  32 + @Override
  33 + protected void initView() {
  34 + StatusBarUtil.setStatusBarWrite(this);
  35 + StatusBarUtil.setColor(this, getResources().getColor(R.color.color_fff), 0);
  36 + String msg = getIntent().getStringExtra("msg");
  37 + String type = getIntent().getStringExtra("type");
  38 + if (fragment == null) {
  39 + fragment = QrSignInFragment.newNetPayFragment(msg, type);
  40 + }
  41 + loadRootFragment(fragment);
  42 + }
  43 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/ui/activity/ScanActivity.java 0 → 100644
  1 +//package com.cnlive.strike.moudle.qr.ui.activity;
  2 +//
  3 +//import android.Manifest;
  4 +//import android.content.Context;
  5 +//import android.content.Intent;
  6 +//import android.databinding.BaseObservable;
  7 +//import android.os.Bundle;
  8 +//import android.os.Vibrator;
  9 +//import android.support.annotation.NonNull;
  10 +//import android.support.annotation.Nullable;
  11 +//
  12 +//import com.alibaba.android.arouter.facade.annotation.Route;
  13 +//import com.cnlive.libs.base.frame.activity.MvpBindingActivity;
  14 +//import com.cnlive.media.picker.PickerConfig;
  15 +//import com.cnlive.media.picker.entity.Media;
  16 +//import com.cnlive.media.picker.utils.PermissionChecker;
  17 +//import com.cnlive.strike.moudle.baseim.model.QRCodeReceiptData;
  18 +//import com.cnlive.strike.moudle.baseim.util.observable.QRCodeReceiptObservable;
  19 +//import com.cnlive.strike.moudle.qr.R;
  20 +//import com.cnlive.strike.moudle.qr.databinding.ActivityScanBinding;
  21 +//import com.cnlive.strike.moudle.qr.frame.presenter.ScanPresenter;
  22 +//import com.cnlive.strike.moudle.qr.frame.view.ScanView;
  23 +//import com.cnlive.strike.moudle.qr.uitl.QrContentUtil;
  24 +//
  25 +//import java.io.File;
  26 +//import java.util.ArrayList;
  27 +//import java.util.Observable;
  28 +//import java.util.Observer;
  29 +//
  30 +//import cn.bingoogolapple.qrcode.core.QRCodeView;
  31 +//
  32 +//
  33 +///**
  34 +// * 创建:wukuiqing
  35 +// * <p>
  36 +// * 时间:2018/4/25
  37 +// * <p>
  38 +// * 描述:
  39 +// */
  40 +////@Route(path = "/qr/ScanActivity")
  41 +//public class ScanActivity extends MvpBindingActivity<ScanView, ScanPresenter, BaseObservable, ActivityScanBinding> implements QRCodeView.Delegate, Observer {
  42 +//
  43 +// //闪光灯是否开启
  44 +// public boolean isFlight;
  45 +// //type
  46 +// public String type;
  47 +// //七牛压缩的文件
  48 +// public File luBanFile;
  49 +// //用户页面的返回码
  50 +// public int userResult = 10010;
  51 +// //
  52 +// public static int REQUEST_CODE_START_MOMENT_READ_WRITE_CAMERA = 10015;
  53 +// public static int REQUEST_CODE_PERMISSION_CAMERA = 10013;
  54 +//
  55 +// public static void startActivity(Context context, String type) {
  56 +// Intent intent = new Intent(context, ScanActivity.class);
  57 +// intent.putExtra("where", type);
  58 +// context.startActivity(intent);
  59 +// }
  60 +//
  61 +// @Override
  62 +// protected int getLayoutId() {
  63 +// return R.layout.activity_scan;
  64 +// }
  65 +//
  66 +// @Override
  67 +// protected void onCreate(@Nullable Bundle savedInstanceState) {
  68 +// super.onCreate(savedInstanceState);
  69 +// type = getIntent().getStringExtra("where");
  70 +// QRCodeReceiptObservable.getInstance().addObserver(this);
  71 +// getMvpView().initView();
  72 +// boolean hasPermission = PermissionChecker.checkPermissions(this
  73 +// , new String[]{Manifest.permission.CAMERA}
  74 +// , REQUEST_CODE_START_MOMENT_READ_WRITE_CAMERA, R.string.CAMERA);
  75 +// if (hasPermission)getMvpView().startScan();
  76 +// }
  77 +//
  78 +// private void vibrate() {
  79 +// Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
  80 +// vibrator.vibrate(200);
  81 +// }
  82 +//
  83 +// @Override
  84 +// public void onScanQRCodeSuccess(String result) {
  85 +// vibrate();
  86 +// getPresenter().checkQr(ScanActivity.this, result);
  87 +// }
  88 +//
  89 +// @Override
  90 +// public void onCameraAmbientBrightnessChanged(boolean isDark) {
  91 +//
  92 +// }
  93 +//
  94 +// @Override
  95 +// public void onScanQRCodeOpenCameraError() {
  96 +// if (getMvpView() != null) getMvpView().showMessage("相机异常");
  97 +// }
  98 +//
  99 +// @Override
  100 +// protected void onStart() {
  101 +// super.onStart();
  102 +// if (getMvpView() != null) getMvpView().onStart();
  103 +// }
  104 +//
  105 +// @Override
  106 +// protected void onStop() {
  107 +// if (getMvpView() != null) getMvpView().onStop();
  108 +// super.onStop();
  109 +// }
  110 +//
  111 +// @Override
  112 +// protected void onPause() {
  113 +// super.onPause();
  114 +// if (getMvpView() != null) getMvpView().onPause();
  115 +// }
  116 +//
  117 +// @Override
  118 +// protected void onResume() {
  119 +// super.onResume();
  120 +//
  121 +// }
  122 +//
  123 +// @Override
  124 +// protected void onDestroy() {
  125 +// if (binding != null && binding.zxingview != null) binding.zxingview.onDestroy();
  126 +// QRCodeReceiptObservable.getInstance().deleteObserver(this);
  127 +// QrContentUtil.getInstance().cancel();
  128 +// if (luBanFile != null && luBanFile.exists()) getMvpView().clearLuBan(luBanFile);
  129 +// super.onDestroy();
  130 +// if (getMvpView() != null && getMvpView().tipDialog != null)
  131 +// getMvpView().tipDialog.dismiss();
  132 +//
  133 +// QrContentUtil.getInstance().cancel();
  134 +// }
  135 +//
  136 +//
  137 +// @Override
  138 +// protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  139 +// super.onActivityResult(requestCode, resultCode, data);
  140 +// if (requestCode == 200 && resultCode == PickerConfig.DEFAULT_RESULT_CODE) {
  141 +// ArrayList<Media> select = data.getParcelableArrayListExtra(PickerConfig.EXTRA_RESULT);
  142 +// if (select != null && select.size() > 0) {
  143 +// String path = select.get(0).path;
  144 +// if (getPresenter() != null) getPresenter().luBanFile(this, path);
  145 +// } else getMvpView().showMessage("请选择图片");
  146 +// } else if (requestCode == userResult) {
  147 +// finish();
  148 +// }
  149 +// }
  150 +//
  151 +// @Override
  152 +// public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
  153 +// super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  154 +// if (requestCode == REQUEST_CODE_PERMISSION_CAMERA) {
  155 +// boolean hasPermission = PermissionChecker.onRequestPermissionsResult(this, requestCode, permissions, grantResults,
  156 +// false, com.cnlive.media.picker.R.string.dialog_imagepicker_permission_sdcard_nerver_ask_message)[0];
  157 +// if (hasPermission) {
  158 +// if (getMvpView() != null) getMvpView().showAum();
  159 +// }
  160 +// }else if (requestCode==REQUEST_CODE_START_MOMENT_READ_WRITE_CAMERA){
  161 +// boolean hasPermission = PermissionChecker.onRequestPermissionsResult(this
  162 +// , requestCode, permissions, grantResults,
  163 +// false,R.string.request_camera)[0];
  164 +// if (hasPermission)getMvpView().startScan();
  165 +// }
  166 +// }
  167 +//
  168 +// @Override
  169 +// public void update(Observable o, Object arg) {
  170 +// if (o instanceof QRCodeReceiptObservable && arg instanceof QRCodeReceiptData) {
  171 +// finish();
  172 +// }
  173 +// }
  174 +//
  175 +// @Override
  176 +// protected void onSaveInstanceState(Bundle outState) {
  177 +// super.onSaveInstanceState(outState);
  178 +// outState.putString("where", type);
  179 +// }
  180 +//}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/ui/activity/ScanZarBarActivity.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.ui.activity;
  2 +
  3 +import android.Manifest;
  4 +import android.content.Context;
  5 +import android.content.Intent;
  6 +import android.media.SoundPool;
  7 +import android.os.Bundle;
  8 +import android.os.Vibrator;
  9 +import androidx.annotation.NonNull;
  10 +import androidx.annotation.Nullable;
  11 +import android.text.TextUtils;
  12 +import android.view.MotionEvent;
  13 +
  14 +import com.alibaba.android.arouter.facade.annotation.Route;
  15 +import com.cnlive.core.libs.base.frame.activity.BaseActivity;
  16 +import com.cnlive.core.libs.base.interfaces.OnPermissionResponseListener;
  17 +import com.cnlive.media.picker.PickerConfig;
  18 +import com.cnlive.media.picker.entity.Media;
  19 +import com.cnlive.strike.moudle.qr.R;
  20 +import com.cnlive.strike.moudle.qr.databinding.ActivityScaZbarBinding;
  21 +import com.cnlive.strike.moudle.qr.frame.presenter.ScanNewPresenter;
  22 +import com.cnlive.strike.moudle.qr.frame.view.ScanNewView;
  23 +import com.cnlive.strike.moudle.qr.model.QRCodeReceiptData;
  24 +import com.cnlive.strike.moudle.qr.observable.QRCodeReceiptObservable;
  25 +import com.cnlive.strike.moudle.qr.uitl.QrContentUtil;
  26 +
  27 +import java.io.File;
  28 +import java.util.ArrayList;
  29 +import java.util.Observable;
  30 +import java.util.Observer;
  31 +
  32 +import cn.bertsir.zbar.Qr.Symbol;
  33 +import cn.bertsir.zbar.QrConfig;
  34 +import cn.bertsir.zbar.ScanCallback;
  35 +import cn.bertsir.zbar.utils.QRUtils;
  36 +
  37 +
  38 +/**
  39 + * 创建:wukuiqing
  40 + * <p>
  41 + * 时间:2018/4/25
  42 + * <p>
  43 + * 描述:
  44 + */
  45 +@Route(path = "/qr/ScanActivity")
  46 +public class ScanZarBarActivity extends BaseActivity<ScanNewView, ScanNewPresenter> implements Observer {
  47 +
  48 + //闪光灯是否开启
  49 + public boolean isFlight;
  50 + //type
  51 + public String type;
  52 + //七牛压缩的文件
  53 + public File luBanFile;
  54 + //用户页面的返回码
  55 + public int userResult = 10010;
  56 + //是否支持双指放大
  57 + boolean isFinger_zoom=true;
  58 + public SoundPool soundPool;
  59 +
  60 + private float oldDist = 5f;
  61 + public ActivityScaZbarBinding binding;
  62 +
  63 +
  64 + public static void startActivity(Context context, String type) {
  65 + Intent intent = new Intent(context, ScanZarBarActivity.class);
  66 + intent.putExtra("where", type);
  67 + context.startActivity(intent);
  68 + }
  69 +
  70 + @Override
  71 + protected int getBindLayoutId() {
  72 + Symbol.scanType = QrConfig.TYPE_QRCODE;
  73 + Symbol.scanFormat = QrConfig.BARCODE_EAN13;
  74 + Symbol.is_only_scan_center = true;
  75 + return R.layout.activity_sca_zbar;
  76 + }
  77 +
  78 + @Override
  79 + protected void initBindingData() {
  80 + binding = (ActivityScaZbarBinding) baseBinding;
  81 + }
  82 +
  83 + @Override
  84 + public boolean onTouchEvent(MotionEvent event) {
  85 + if(isFinger_zoom){
  86 + switch (event.getAction() & MotionEvent.ACTION_MASK) {
  87 + case MotionEvent.ACTION_POINTER_DOWN:
  88 + oldDist = QRUtils.getInstance().getFingerSpacing(event);
  89 +
  90 + break;
  91 + case MotionEvent.ACTION_MOVE:
  92 + if (event.getPointerCount() == 2) {
  93 + float newDist = QRUtils.getInstance().getFingerSpacing(event);
  94 + if (newDist > oldDist) {
  95 + binding.cp.handleZoom(true);
  96 + } else if (newDist < oldDist) {
  97 + binding.cp.handleZoom(false);
  98 + }
  99 + oldDist = newDist;
  100 + }
  101 + break;
  102 + }
  103 + }
  104 + return super.onTouchEvent(event);
  105 +
  106 + }
  107 +
  108 + @Override
  109 + protected void onCreate(@Nullable Bundle savedInstanceState) {
  110 + super.onCreate(savedInstanceState);
  111 + type = getIntent().getStringExtra("where");
  112 + QRCodeReceiptObservable.getInstance().addObserver(this);
  113 + getMvpView().initView();
  114 +
  115 + requestPermission(new String[]{Manifest.permission.CAMERA}, String.valueOf(R.string.CAMERA), new OnPermissionResponseListener() {
  116 + @Override
  117 + public void onSuccess(String[] permissions) {
  118 + getMvpView().startScan();
  119 + }
  120 +
  121 + @Override
  122 + public void onFail() {
  123 +
  124 + }
  125 + });
  126 + }
  127 +
  128 + private void vibrate() {
  129 + Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
  130 + vibrator.vibrate(200);
  131 + if (soundPool != null)
  132 + soundPool.play(1, 1, 1, 0, 0, 1);
  133 + }
  134 +
  135 +
  136 + @Override
  137 + protected void onStart() {
  138 + super.onStart();
  139 + if (getMvpView() != null) getMvpView().onStart();
  140 + }
  141 +
  142 + @Override
  143 + protected void onStop() {
  144 + super.onStop();
  145 + }
  146 +
  147 + @Override
  148 + protected void onPause() {
  149 + super.onPause();
  150 + if (getMvpView() != null) getMvpView().onPause();
  151 + }
  152 +
  153 + @Override
  154 + protected void onResume() {
  155 + super.onResume();
  156 + if (binding.cp != null) {
  157 + binding.cp.setScanCallback(resultCallback);
  158 + binding.cp.start();
  159 + }
  160 + binding.sv.onResume();
  161 +
  162 + }
  163 +
  164 + private ScanCallback resultCallback = new ScanCallback() {
  165 + @Override
  166 + public void onScanResult(String result) {
  167 +
  168 + if (binding.cp != null) {
  169 + binding.cp.setFlash(false);
  170 + }
  171 + getPresenter().checkQr(result);
  172 + vibrate();
  173 + }
  174 + };
  175 +
  176 + @Override
  177 + protected void onDestroy() {
  178 + QRCodeReceiptObservable.getInstance().deleteObserver(this);
  179 + if (luBanFile != null && luBanFile.exists()) getMvpView().clearLuBan(luBanFile);
  180 + super.onDestroy();
  181 + if (binding.cp != null) {
  182 + binding.cp.setFlash(false);
  183 + binding.cp.stop();
  184 + }
  185 + if (getMvpView() != null) getMvpView().onDestory();
  186 +
  187 + }
  188 +
  189 +
  190 + @Override
  191 + protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  192 + super.onActivityResult(requestCode, resultCode, data);
  193 + if (requestCode == 200 && resultCode == PickerConfig.DEFAULT_RESULT_CODE) {
  194 + ArrayList<Media> select = data.getParcelableArrayListExtra(PickerConfig.EXTRA_RESULT);
  195 + if (select != null && select.size() > 0) {
  196 + String path = select.get(0).path;
  197 + if (!TextUtils.isEmpty(path)&&getPresenter() != null)getPresenter().IdentifyQRCode(this,path);
  198 +
  199 +// if (getPresenter() != null) getPresenter().luBanFile(this, path);
  200 +
  201 + } else getMvpView().showMessage("请选择图片");
  202 + } else if (requestCode == userResult) {
  203 + finish();
  204 + }
  205 + }
  206 +
  207 + @Override
  208 + public void update(Observable o, Object arg) {
  209 + if (o instanceof QRCodeReceiptObservable && arg instanceof QRCodeReceiptData) {
  210 + finish();
  211 + }
  212 + }
  213 +
  214 + @Override
  215 + protected void onSaveInstanceState(Bundle outState) {
  216 + super.onSaveInstanceState(outState);
  217 + outState.putString("where", type);
  218 + }
  219 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/ui/activity/SpeakerBindStateActivity.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.ui.activity;
  2 +
  3 +import android.content.Context;
  4 +import android.content.Intent;
  5 +
  6 +import com.cnlive.core.libs.base.frame.activity.BaseActivity;
  7 +import com.cnlive.strike.moudle.qr.R;
  8 +import com.cnlive.strike.moudle.qr.databinding.ActivitySpeakerBindStateBinding;
  9 +import com.cnlive.strike.moudle.qr.frame.presenter.SpeakerBindStatePresenter;
  10 +import com.cnlive.strike.moudle.qr.frame.view.SpeakerBindStateView;
  11 +
  12 +
  13 +/**
  14 + * 作者: 吴奎庆
  15 + * <p>
  16 + * 时间: 2019/10/11
  17 + * <p>
  18 + * 简介: 音响绑定状态
  19 + */
  20 +public class SpeakerBindStateActivity extends BaseActivity<SpeakerBindStateView, SpeakerBindStatePresenter> {
  21 +
  22 + public ActivitySpeakerBindStateBinding binding;
  23 +
  24 + public static void startActivity(Context context, String content) {
  25 + Intent intent = new Intent(context, SpeakerBindStateActivity.class);
  26 + intent.putExtra("content", content);
  27 + context.startActivity(intent);
  28 + }
  29 +
  30 + @Override
  31 + protected int getBindLayoutId() {
  32 + return R.layout.activity_speaker_bind_state;
  33 + }
  34 +
  35 + @Override
  36 + protected void initBindingData() {
  37 + binding = (ActivitySpeakerBindStateBinding) baseBinding;
  38 + }
  39 +
  40 + @Override
  41 + protected void initView() {
  42 + String content = getIntent().getStringExtra("content");
  43 + if (getPresenter()!=null)getPresenter().initData(this,content);
  44 + if (getMvpView() != null) getMvpView().initView(content);
  45 + }
  46 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/ui/fragment/QrPayFragment.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.ui.fragment;
  2 +
  3 +import android.app.Dialog;
  4 +import android.os.Bundle;
  5 +import androidx.annotation.Nullable;
  6 +import android.text.InputFilter;
  7 +import android.text.TextUtils;
  8 +import android.view.View;
  9 +
  10 +import com.cnlive.core.libs.base.frame.fragment.BaseFragment;
  11 +import com.cnlive.strike.moudle.qr.R;
  12 +import com.cnlive.strike.moudle.qr.databinding.FragmentQrPayBinding;
  13 +import com.cnlive.strike.moudle.qr.frame.presenter.QrPayPresenter;
  14 +import com.cnlive.strike.moudle.qr.frame.view.QrPayView;
  15 +import com.cnlive.strike.moudle.qr.model.QRCodeReceiptData;
  16 +import com.cnlive.strike.moudle.qr.observable.QRCodeReceiptObservable;
  17 +import com.cnlive.strike.moudle.qr.uitl.AlertDialogUtils;
  18 +import com.cnlive.strike.moudle.qr.uitl.NumRangeInputFilter;
  19 +
  20 +import java.util.Observable;
  21 +import java.util.Observer;
  22 +
  23 +/**
  24 + * 作者: 吴奎庆
  25 + * <p>
  26 + * 时间: 2018/7/11
  27 + * <p>
  28 + * 简介: 扫码支付的页面
  29 + */
  30 +
  31 +public class QrPayFragment extends BaseFragment<QrPayView, QrPayPresenter> implements Observer {
  32 + private static final String tag_darenId = "darenId";
  33 + public String dareId;
  34 + private String remarkContent = "";
  35 + private Dialog remarkDialog;
  36 + public FragmentQrPayBinding binding;
  37 +
  38 +
  39 + public static QrPayFragment newInstance(String darenId) {
  40 + Bundle args = new Bundle();
  41 + QrPayFragment fragment = new QrPayFragment();
  42 + args.putString(tag_darenId, darenId);
  43 + fragment.setArguments(args);
  44 + return fragment;
  45 + }
  46 +
  47 + @Override
  48 + protected int getBindLayoutId() {
  49 + return R.layout.fragment_qr_pay;
  50 + }
  51 +
  52 + @Override
  53 + protected void initBindingData() {
  54 + binding = (FragmentQrPayBinding) baseBinding;
  55 + }
  56 +
  57 + @Override
  58 + protected void initParams() {
  59 + dareId = getArguments().getString(tag_darenId);
  60 + }
  61 +
  62 + @Override
  63 + protected void initView() {
  64 + QRCodeReceiptObservable.getInstance().addObserver(this);
  65 + binding.includeToolbar.topbar.setTitle("付款");
  66 + }
  67 +
  68 +
  69 + @Override
  70 + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  71 + super.onViewCreated(view, savedInstanceState);
  72 + binding.setOnClick(v -> onClick(v.getId()));
  73 +
  74 + getPresenter().getDarenInfo(getActivity(), dareId);
  75 + binding.tvMoney.setFilters(new InputFilter[]{new NumRangeInputFilter()});
  76 +
  77 + remarkDialog = AlertDialogUtils.showRemarksDialog(getActivity(), "取消", "确定", getString(R.string.remark_dialog_title), R.color.color_remark_dialog_ok, R.color.color_remark_dialog_ok, new AlertDialogUtils.RightListener() {
  78 + @Override
  79 + public void onClickRight(Dialog dialog, String content) {
  80 + if (TextUtils.isEmpty(content)) {
  81 + binding.tvRemarks.setText("添加备注");
  82 + binding.tvRemarks.setTextColor(getActivity().getResources().getColor(R.color.color_remark));
  83 + binding.tvChange.setVisibility(View.GONE);
  84 + } else {
  85 + remarkContent = content;
  86 + binding.tvRemarks.setText(content);
  87 + binding.tvRemarks.setTextColor(getActivity().getResources().getColor(R.color.text_gray));
  88 + binding.tvChange.setVisibility(View.VISIBLE);
  89 + binding.tvChange.setText("修改");
  90 + binding.tvChange.setTextColor(getActivity().getResources().getColor(R.color.color_remark));
  91 + }
  92 +
  93 + }
  94 + });
  95 + }
  96 +
  97 + private void onClick(int id) {
  98 +
  99 + if (R.id.bt_pay==id){
  100 + String money = binding.tvMoney.getText().toString();
  101 +
  102 + if (!TextUtils.isEmpty(money)) {
  103 + double xx = Double.valueOf(money);
  104 + if (xx > 0){
  105 + getPresenter().getQrOrder(getActivity(), dareId, money, remarkContent);
  106 + }else {
  107 + getMvpView().showMessage("请输入正确的金额");
  108 + }
  109 +
  110 + } else {
  111 + getMvpView().showMessage("请输入正确的金额");
  112 + }
  113 + }else if (R.id.tv_remarks==id){
  114 + remarkDialog.show();
  115 + }else if (R.id.tv_change==id){
  116 + remarkDialog.show();
  117 + }
  118 + }
  119 +
  120 + @Override
  121 + public void onDestroy() {
  122 + if (remarkDialog != null) remarkDialog.dismiss();
  123 + if (getPresenter() != null) getPresenter().cancel();
  124 + QRCodeReceiptObservable.getInstance().deleteObserver(this);
  125 + super.onDestroy();
  126 + }
  127 +
  128 + @Override
  129 + public void update(Observable o, Object arg) {
  130 + if (o instanceof QRCodeReceiptObservable && arg instanceof QRCodeReceiptData) {
  131 + getActivity().finish();
  132 + }
  133 + }
  134 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/ui/fragment/QrSignInFragment.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.ui.fragment;
  2 +
  3 +import android.os.Bundle;
  4 +import androidx.annotation.Nullable;
  5 +import androidx.fragment.app.Fragment;
  6 +
  7 +import android.text.TextUtils;
  8 +import android.view.View;
  9 +
  10 +import com.cnlive.core.libs.base.frame.fragment.BaseFragment;
  11 +import com.cnlive.core.libs.base.util.AlertUtil;
  12 +import com.cnlive.strike.moudle.qr.R;
  13 +import com.cnlive.strike.moudle.qr.databinding.FragmentQrPayBinding;
  14 +import com.cnlive.strike.moudle.qr.databinding.FragmentQrSigninBinding;
  15 +import com.cnlive.strike.moudle.qr.frame.presenter.QrSignInPresenter;
  16 +import com.cnlive.strike.moudle.qr.frame.view.QrSignInView;
  17 +
  18 +/**
  19 + * 作者: 吴奎庆
  20 + * <p>
  21 + * 时间: 2018/8/28
  22 + * <p>
  23 + * 简介:
  24 + */
  25 +
  26 +public class QrSignInFragment extends BaseFragment<QrSignInView, QrSignInPresenter> {
  27 + private String message;
  28 + private String type;
  29 + private FragmentQrSigninBinding binding;
  30 + public static QrSignInFragment newNetPayFragment(String msg, String type) {
  31 + QrSignInFragment fragment = new QrSignInFragment();
  32 + Bundle args = new Bundle();
  33 + args.putString("msg", msg);
  34 + args.putString("type", type);
  35 + fragment.setArguments(args);
  36 + return fragment;
  37 + }
  38 +
  39 + @Override
  40 + protected int getBindLayoutId() {
  41 + return R.layout.fragment_qr_signin;
  42 + }
  43 +
  44 + @Override
  45 + protected void initBindingData() {
  46 + binding = (FragmentQrSigninBinding) baseBinding;
  47 + }
  48 +
  49 + @Override
  50 + protected void initParams() {
  51 + message = getArguments() == null ? null : (String) getArguments().getString("msg");
  52 + type = getArguments() == null ? null : (String) getArguments().getString("type");
  53 + if (TextUtils.isEmpty(message) || TextUtils.isEmpty(type)) {
  54 + AlertUtil.showDeftToast(getActivity(), "加载信息有误.");
  55 + getActivity().finish();
  56 + return;
  57 + }
  58 + }
  59 +
  60 +
  61 + @Override
  62 + protected void initView() {
  63 + binding.tvMessage.setText(message);
  64 + binding.includeToolbar.topbar.setTitle("签到");
  65 + switch (type) {
  66 + case "1001":
  67 + binding.ivIcon.setBackgroundResource(R.drawable.ye_cfqd);
  68 + break;
  69 + case "1002":
  70 + binding.ivIcon.setBackgroundResource(R.drawable.ye_cfqd);
  71 + break;
  72 + default:
  73 + binding.ivIcon.setBackgroundResource(R.drawable.ye_cfqd);
  74 + break;
  75 + }
  76 + binding.btFinish.setOnClickListener(v -> getActivity().finish());
  77 + }
  78 +
  79 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/ui/widget/CustomCameraPreview.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.ui.widget;
  2 +
  3 +import android.content.Context;
  4 +import android.hardware.Camera;
  5 +import android.os.Handler;
  6 +import android.util.AttributeSet;
  7 +import android.view.SurfaceHolder;
  8 +import android.view.SurfaceView;
  9 +import android.view.ViewGroup;
  10 +import android.widget.FrameLayout;
  11 +import android.widget.Toast;
  12 +
  13 +import cn.bertsir.zbar.CameraManager;
  14 +import cn.bertsir.zbar.ScanCallback;
  15 +
  16 +/**
  17 + * 作者: 吴奎庆
  18 + * <p>
  19 + * 时间: 2019/6/1
  20 + * <p>
  21 + * 简介:
  22 + */
  23 +public class CustomCameraPreview extends FrameLayout implements SurfaceHolder.Callback {
  24 +
  25 + private CameraManager mCameraManager;
  26 + private CustomCameraScanAnalysis mPreviewCallback;
  27 + private SurfaceView mSurfaceView;
  28 +
  29 + public CustomCameraPreview(Context context) {
  30 + this(context, null);
  31 + }
  32 +
  33 + public CustomCameraPreview(Context context, AttributeSet attrs) {
  34 + this(context, attrs, 0);
  35 + }
  36 +
  37 + public CustomCameraPreview(Context context, AttributeSet attrs, int defStyleAttr) {
  38 + super(context, attrs, defStyleAttr);
  39 +
  40 + mCameraManager = new CameraManager(context);
  41 + mPreviewCallback = new CustomCameraScanAnalysis(context);
  42 + }
  43 +
  44 + /**
  45 + * Set Scan results callback.
  46 + *
  47 + * @param callback {@link ScanCallback}.
  48 + */
  49 + public void setScanCallback(ScanCallback callback) {
  50 + mPreviewCallback.setScanCallback(callback);
  51 + }
  52 +
  53 + /**
  54 + * Camera start preview.
  55 + */
  56 + public boolean start() {
  57 + try {
  58 + mCameraManager.openDriver();
  59 + } catch (Exception e) {
  60 + Toast.makeText(getContext(), "摄像头权限被拒绝!", Toast.LENGTH_SHORT).show();
  61 + return false;
  62 + }
  63 + mPreviewCallback.onStart();
  64 +
  65 + if (mSurfaceView == null) {
  66 + mSurfaceView = new SurfaceView(getContext());
  67 + addView(mSurfaceView, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
  68 +
  69 + SurfaceHolder holder = mSurfaceView.getHolder();
  70 + holder.addCallback(this);
  71 + holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
  72 + }
  73 + startCameraPreview(mSurfaceView.getHolder());
  74 + return true;
  75 + }
  76 +
  77 + /**
  78 + * Camera stop preview.
  79 + */
  80 + public void stop() {
  81 + removeCallbacks(mAutoFocusTask);
  82 + mPreviewCallback.onStop();
  83 +
  84 + mCameraManager.stopPreview();
  85 + mCameraManager.closeDriver();
  86 + }
  87 +
  88 + private void startCameraPreview(SurfaceHolder holder) {
  89 + try {
  90 + mCameraManager.startPreview(holder, mPreviewCallback);
  91 + mCameraManager.autoFocus(mFocusCallback);
  92 + } catch (Exception e) {
  93 + e.printStackTrace();
  94 + //如果异常延迟200ms再试
  95 + new Handler().postDelayed(new Runnable() {
  96 + @Override
  97 + public void run() {
  98 + mCameraManager.autoFocus(mFocusCallback);
  99 + }
  100 + }, 200);
  101 + }
  102 + }
  103 +
  104 + @Override
  105 + public void surfaceCreated(SurfaceHolder holder) {
  106 + }
  107 +
  108 + @Override
  109 + public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
  110 + if (holder.getSurface() == null) {
  111 + return;
  112 + }
  113 + mCameraManager.stopPreview();
  114 + startCameraPreview(holder);
  115 + }
  116 +
  117 + @Override
  118 + public void surfaceDestroyed(SurfaceHolder holder) {
  119 + }
  120 +
  121 + private Camera.AutoFocusCallback mFocusCallback = new Camera.AutoFocusCallback() {
  122 + public void onAutoFocus(boolean success, Camera camera) {
  123 + postDelayed(mAutoFocusTask, 1000);
  124 + }
  125 + };
  126 +
  127 + private Runnable mAutoFocusTask = new Runnable() {
  128 + public void run() {
  129 + mCameraManager.autoFocus(mFocusCallback);
  130 + }
  131 + };
  132 +
  133 + @Override
  134 + protected void onDetachedFromWindow() {
  135 + stop();
  136 + super.onDetachedFromWindow();
  137 + }
  138 +
  139 + public void setFlash() {
  140 + mCameraManager.setFlash();
  141 + }
  142 +
  143 + public void setFlash(boolean open) {
  144 + mCameraManager.setFlash(open);
  145 + }
  146 +
  147 + public void setZoom(float zoom){
  148 + mCameraManager.setCameraZoom(zoom);
  149 + }
  150 +
  151 + public void handleZoom(boolean isZoomIn){
  152 + mCameraManager.handleZoom(isZoomIn);
  153 + }
  154 +}
0 \ No newline at end of file 155 \ No newline at end of file
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/ui/widget/CustomCameraScanAnalysis.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.ui.widget;
  2 +
  3 +import android.content.Context;
  4 +import android.hardware.Camera;
  5 +import android.os.Handler;
  6 +import android.os.Looper;
  7 +import android.os.Message;
  8 +import android.text.TextUtils;
  9 +
  10 +import com.google.zxing.BinaryBitmap;
  11 +import com.google.zxing.LuminanceSource;
  12 +import com.google.zxing.NotFoundException;
  13 +import com.google.zxing.PlanarYUVLuminanceSource;
  14 +import com.google.zxing.ResultPoint;
  15 +import com.google.zxing.common.DetectorResult;
  16 +import com.google.zxing.common.HybridBinarizer;
  17 +import com.google.zxing.datamatrix.detector.Detector;
  18 +
  19 +import java.util.concurrent.ExecutorService;
  20 +import java.util.concurrent.Executors;
  21 +
  22 +import cn.bertsir.zbar.Qr.Config;
  23 +import cn.bertsir.zbar.Qr.Image;
  24 +import cn.bertsir.zbar.Qr.ImageScanner;
  25 +import cn.bertsir.zbar.Qr.Symbol;
  26 +import cn.bertsir.zbar.Qr.SymbolSet;
  27 +import cn.bertsir.zbar.QrConfig;
  28 +import cn.bertsir.zbar.ScanCallback;
  29 +import cn.bertsir.zbar.utils.QRUtils;
  30 +
  31 +/**
  32 + * 作者: 吴奎庆
  33 + * <p>
  34 + * 时间: 2019/6/1
  35 + * <p>
  36 + * 简介:
  37 + */
  38 +public class CustomCameraScanAnalysis implements Camera.PreviewCallback{
  39 +
  40 +private ExecutorService executorService=Executors.newSingleThreadExecutor();
  41 +
  42 +private ImageScanner mImageScanner;
  43 +private Handler mHandler;
  44 +private ScanCallback mCallback;
  45 +private static final String TAG="CameraScanAnalysis";
  46 +
  47 +private boolean allowAnalysis=true;
  48 +private Image barcode;
  49 +private int cropWidth;
  50 +private int cropHeight;
  51 +private Camera.Size size;
  52 +private byte[]data;
  53 +private Camera camera;
  54 +private Context context;
  55 +
  56 +
  57 + CustomCameraScanAnalysis(Context context){
  58 + this.context=context;
  59 + mImageScanner=new ImageScanner();
  60 + if(Symbol.scanType== QrConfig.TYPE_QRCODE){
  61 + mImageScanner.setConfig(Symbol.NONE,Config.ENABLE,0);
  62 + mImageScanner.setConfig(Symbol.QRCODE,Config.ENABLE,1);
  63 + }else if(Symbol.scanType==QrConfig.TYPE_BARCODE){
  64 + mImageScanner.setConfig(Symbol.NONE,Config.ENABLE,0);
  65 + mImageScanner.setConfig(Symbol.CODE128,Config.ENABLE,1);
  66 + mImageScanner.setConfig(Symbol.CODE39,Config.ENABLE,1);
  67 + mImageScanner.setConfig(Symbol.EAN13,Config.ENABLE,1);
  68 + mImageScanner.setConfig(Symbol.EAN8,Config.ENABLE,1);
  69 + mImageScanner.setConfig(Symbol.UPCA,Config.ENABLE,1);
  70 + mImageScanner.setConfig(Symbol.UPCE,Config.ENABLE,1);
  71 + mImageScanner.setConfig(Symbol.UPCE,Config.ENABLE,1);
  72 + }else if(Symbol.scanType==QrConfig.TYPE_ALL){
  73 + mImageScanner.setConfig(Symbol.NONE,Config.X_DENSITY,3);
  74 + mImageScanner.setConfig(Symbol.NONE,Config.Y_DENSITY,3);
  75 + }else if(Symbol.scanType==QrConfig.TYPE_CUSTOM){
  76 + mImageScanner.setConfig(Symbol.NONE,Config.ENABLE,0);
  77 + mImageScanner.setConfig(Symbol.scanFormat,Config.ENABLE,1);
  78 + }else{
  79 + mImageScanner.setConfig(Symbol.NONE,Config.X_DENSITY,3);
  80 + mImageScanner.setConfig(Symbol.NONE,Config.Y_DENSITY,3);
  81 + }
  82 +
  83 + mHandler=new Handler(Looper.getMainLooper()){
  84 +@Override
  85 +public void handleMessage(Message msg){
  86 + if(mCallback!=null)mCallback.onScanResult((String)msg.obj);
  87 + }
  88 + };
  89 + }
  90 +
  91 + void setScanCallback(ScanCallback callback){
  92 + this.mCallback=callback;
  93 + }
  94 +
  95 + void onStop(){
  96 + this.allowAnalysis=false;
  97 + }
  98 +
  99 + void onStart(){
  100 + this.allowAnalysis=true;
  101 + }
  102 +
  103 +@Override
  104 +public void onPreviewFrame(byte[]data,Camera camera){
  105 + if(allowAnalysis){
  106 + allowAnalysis=false;
  107 + this.data=data;
  108 + this.camera=camera;
  109 +
  110 + size=camera.getParameters().getPreviewSize();
  111 + barcode=new Image(size.width,size.height,"Y800");
  112 + barcode.setData(data);
  113 +
  114 + if(Symbol.is_only_scan_center){
  115 + cropWidth=(int)(Symbol.cropWidth*(size.height/(float)Symbol.screenWidth));
  116 + cropHeight=(int)(Symbol.cropHeight*(size.width/(float)Symbol.screenHeight));
  117 +
  118 + Symbol.cropX=size.width/2-cropHeight/2;
  119 + Symbol.cropY=size.height/2-cropWidth/2;
  120 +
  121 + barcode.setCrop(Symbol.cropX,Symbol.cropY,cropHeight,cropWidth);
  122 +
  123 + }
  124 +
  125 + executorService.execute(mAnalysisTask);
  126 +
  127 + }
  128 + }
  129 +
  130 +/**
  131 + * 相机设置焦距
  132 + */
  133 +public void cameraZoom(Camera mCamera){
  134 + if(mCamera!=null){
  135 + Camera.Parameters parameters=mCamera.getParameters();
  136 + if(!parameters.isZoomSupported()){
  137 + return;
  138 + }
  139 + int maxZoom=parameters.getMaxZoom();
  140 + if(maxZoom==0){
  141 + return;
  142 + }
  143 + if(parameters.getZoom()+10>parameters.getMaxZoom()){
  144 + return;
  145 + }
  146 + parameters.setZoom(parameters.getZoom()+10);
  147 + mCamera.setParameters(parameters);
  148 + }
  149 + }
  150 +
  151 +private Runnable mAnalysisTask=new Runnable(){
  152 +@Override
  153 +public void run(){
  154 +
  155 + if(Symbol.is_auto_zoom&&Symbol.scanType==QrConfig.TYPE_QRCODE
  156 + &&QRUtils.getInstance().isScreenOriatationPortrait(context)){
  157 + LuminanceSource source=new PlanarYUVLuminanceSource(data,size.width,
  158 + size.height,Symbol.cropX,Symbol.cropY,cropWidth,cropHeight,true);
  159 + if(source!=null){
  160 + BinaryBitmap bitmap=new BinaryBitmap(new HybridBinarizer(source));
  161 + DetectorResult detectorResult=null;
  162 + try{
  163 + detectorResult=new Detector(bitmap.getBlackMatrix()).detect();
  164 + ResultPoint[]p=detectorResult.getPoints();
  165 + //计算扫描框中的二维码的宽度,两点间距离公式
  166 + float point1X=p[0].getX();
  167 + float point1Y=p[0].getY();
  168 + float point2X=p[1].getX();
  169 + float point2Y=p[1].getY();
  170 + int len=(int)Math.sqrt(Math.abs(point1X-point2X)*Math.abs(point1X-point2X)+Math.abs(point1Y-point2Y)*Math.abs(point1Y-point2Y));
  171 + if(len<cropWidth/4&&len>10){
  172 + cameraZoom(camera);
  173 + }
  174 + }catch(NotFoundException e){
  175 + e.printStackTrace();
  176 + }
  177 + }
  178 + }
  179 +
  180 +
  181 + int result=mImageScanner.scanImage(barcode);
  182 +
  183 + String resultStr=null;
  184 + if(result!=0){
  185 + SymbolSet symSet=mImageScanner.getResults();
  186 + for(Symbol sym:symSet)
  187 + resultStr=sym.getData();
  188 + }
  189 +
  190 + if(!TextUtils.isEmpty(resultStr)){
  191 + Message message=mHandler.obtainMessage();
  192 + message.obj=resultStr;
  193 + message.sendToTarget();
  194 + }else allowAnalysis=true;
  195 + }
  196 + };
  197 + }
0 \ No newline at end of file 198 \ No newline at end of file
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/ui/widget/CustomScanView.java 0 → 100644
  1 +package com.cnlive.strike.moudle.qr.ui.widget;
  2 +
  3 +import android.content.Context;
  4 +import android.util.AttributeSet;
  5 +import android.view.View;
  6 +import android.view.WindowManager;
  7 +import android.view.animation.Animation;
  8 +import android.view.animation.TranslateAnimation;
  9 +import android.widget.FrameLayout;
  10 +import android.widget.LinearLayout;
  11 +
  12 +import com.cnlive.strike.moudle.qr.R;
  13 +
  14 +import java.util.ArrayList;
  15 +
  16 +import cn.bertsir.zbar.Qr.Symbol;
  17 +import cn.bertsir.zbar.QrConfig;
  18 +import cn.bertsir.zbar.view.CornerView;
  19 +import cn.bertsir.zbar.view.LineView;
  20 +
  21 +/**
  22 + * 作者: 吴奎庆
  23 + * <p>
  24 + * 时间: 2019/6/1
  25 + * <p>
  26 + * 简介:
  27 + */
  28 +public class CustomScanView extends FrameLayout {
  29 +
  30 + private LineView iv_scan_line;
  31 + private TranslateAnimation animation;
  32 + private FrameLayout fl_scan;
  33 + private int CURRENT_TYEP = 1;
  34 + private CornerView cnv_left_top;
  35 + private CornerView cnv_left_bottom;
  36 + private CornerView cnv_right_top;
  37 + private CornerView cnv_right_bottom;
  38 + private ArrayList<CornerView> cornerViews;
  39 + private int line_speed = 3000;
  40 +
  41 + public CustomScanView(Context context) {
  42 + super(context);
  43 + initView(context);
  44 + }
  45 +
  46 + public CustomScanView(Context context, AttributeSet attrs) {
  47 + super(context, attrs);
  48 + initView(context);
  49 + }
  50 +
  51 + public CustomScanView(Context context,AttributeSet attrs,int defStyleAttr) {
  52 + super(context, attrs, defStyleAttr);
  53 + initView(context);
  54 + }
  55 +
  56 + private void initView(Context mContext){
  57 + View scan_view = View.inflate(mContext, R.layout.layout_view_scan, this);
  58 +
  59 + cnv_left_top = (CornerView) scan_view.findViewById(R.id.cnv_left_top);
  60 + cnv_left_bottom = (CornerView) scan_view.findViewById(R.id.cnv_left_bottom);
  61 + cnv_right_top = (CornerView) scan_view.findViewById(R.id.cnv_right_top);
  62 + cnv_right_bottom = (CornerView) scan_view.findViewById(R.id.cnv_right_bottom);
  63 +
  64 + cornerViews = new ArrayList<>();
  65 + cornerViews.add(cnv_left_top);
  66 + cornerViews.add(cnv_left_bottom);
  67 + cornerViews.add(cnv_right_top);
  68 + cornerViews.add(cnv_right_bottom);
  69 +
  70 + iv_scan_line = (LineView) scan_view.findViewById(R.id.iv_scan_line);
  71 +
  72 + fl_scan = (FrameLayout) scan_view.findViewById(R.id.fl_scan);
  73 +
  74 + animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation
  75 + .RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
  76 + 0.9f);
  77 + animation.setDuration(line_speed);
  78 + animation.setRepeatCount(-1);
  79 + animation.setRepeatMode(Animation.RESTART);
  80 + }
  81 +
  82 + public void setLineSpeed(int speed){
  83 + animation.setDuration(speed);
  84 + }
  85 +
  86 + public void startScan(){
  87 + iv_scan_line.startAnimation(animation);
  88 + getViewWidthHeight();
  89 + }
  90 +
  91 + public void stop(){
  92 + iv_scan_line.setVisibility(View.GONE);
  93 + iv_scan_line.clearAnimation();
  94 + getViewWidthHeight();
  95 + }
  96 +
  97 + public void onPause(){
  98 + if (iv_scan_line != null) {
  99 + iv_scan_line.clearAnimation();
  100 + iv_scan_line.setVisibility(View.GONE);
  101 + }
  102 + }
  103 +
  104 + public void onResume(){
  105 + if (iv_scan_line != null) {
  106 + iv_scan_line.startAnimation(animation);
  107 + }
  108 + }
  109 +
  110 + public void setType(int type){
  111 + CURRENT_TYEP = type;
  112 + LinearLayout.LayoutParams fl_params = (LinearLayout.LayoutParams) fl_scan.getLayoutParams();
  113 + if(CURRENT_TYEP == QrConfig.SCANVIEW_TYPE_QRCODE){
  114 + fl_params.width = dip2px(250);
  115 + fl_params.height = dip2px(250);
  116 + }else if(CURRENT_TYEP == QrConfig.SCANVIEW_TYPE_BARCODE){
  117 + fl_params.width = dip2px(300);
  118 + fl_params.height = dip2px(100);
  119 + }
  120 + fl_scan.setLayoutParams(fl_params);
  121 + }
  122 +
  123 + public void setCornerColor(int color){
  124 + for (int i = 0; i < cornerViews.size(); i++) {
  125 + cornerViews.get(i).setColor(color);
  126 + }
  127 + }
  128 +
  129 + public void setCornerWidth(int dp){
  130 + for (int i = 0; i < cornerViews.size(); i++) {
  131 + cornerViews.get(i).setLineWidth(dp);
  132 + }
  133 + }
  134 +
  135 + public void setLineColor(int color){
  136 + iv_scan_line.setLinecolor(color);
  137 + }
  138 +
  139 + public int dip2px(int dp) {
  140 + float density = getContext().getResources().getDisplayMetrics().density;
  141 + return (int) (dp * density + 0.5);
  142 + }
  143 +
  144 + public void getViewWidthHeight(){
  145 + fl_scan.post(new Runnable() {
  146 + @Override
  147 + public void run() {
  148 + Symbol.cropWidth = fl_scan.getWidth();
  149 + Symbol.cropHeight = fl_scan.getHeight();
  150 + Symbol.screenWidth = getScreenWidth();
  151 + Symbol.screenHeight = getScreenHeight();
  152 +
  153 + }
  154 + });
  155 + }
  156 +
  157 + public int getScreenWidth() {
  158 + WindowManager wm = (WindowManager) getContext()
  159 + .getSystemService(Context.WINDOW_SERVICE);
  160 +
  161 + int width = wm.getDefaultDisplay().getWidth();
  162 + return width;
  163 + }
  164 +
  165 + public int getScreenHeight() {
  166 + WindowManager wm = (WindowManager) getContext()
  167 + .getSystemService(Context.WINDOW_SERVICE);
  168 + int height = wm.getDefaultDisplay().getHeight();
  169 + return height;
  170 + }
  171 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/ui/widget/zxing/BarcodeFormat.java 0 → 100644
  1 +/*
  2 + * Copyright 2007 ZXing authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +
  17 +package com.cnlive.strike.moudle.qr.ui.widget.zxing;
  18 +
  19 +/**
  20 + * Enumerates barcode formats known to this package. Please keep alphabetized.
  21 + *
  22 + * @author Sean Owen
  23 + */
  24 +public enum BarcodeFormat {
  25 +
  26 + /** Aztec 2D barcode format. */
  27 + AZTEC,
  28 +
  29 + /** CODABAR 1D format. */
  30 + CODABAR,
  31 +
  32 + /** Code 39 1D format. */
  33 + CODE_39,
  34 +
  35 + /** Code 93 1D format. */
  36 + CODE_93,
  37 +
  38 + /** Code 128 1D format. */
  39 + CODE_128,
  40 +
  41 + /** Data Matrix 2D barcode format. */
  42 + DATA_MATRIX,
  43 +
  44 + /** EAN-8 1D format. */
  45 + EAN_8,
  46 +
  47 + /** EAN-13 1D format. */
  48 + EAN_13,
  49 +
  50 + /** ITF (Interleaved Two of Five) 1D format. */
  51 + ITF,
  52 +
  53 + /** MaxiCode 2D barcode format. */
  54 + MAXICODE,
  55 +
  56 + /** PDF417 format. */
  57 + PDF_417,
  58 +
  59 + /** QR Code 2D barcode format. */
  60 + QR_CODE,
  61 +
  62 + /** RSS 14 */
  63 + RSS_14,
  64 +
  65 + /** RSS EXPANDED */
  66 + RSS_EXPANDED,
  67 +
  68 + /** UPC-A 1D format. */
  69 + UPC_A,
  70 +
  71 + /** UPC-E 1D format. */
  72 + UPC_E,
  73 +
  74 + /** UPC/EAN extension format. Not a stand-alone format. */
  75 + UPC_EAN_EXTENSION
  76 +
  77 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/ui/widget/zxing/BitArray.java 0 → 100644
  1 +/*
  2 + * Copyright 2007 ZXing authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +
  17 +package com.cnlive.strike.moudle.qr.ui.widget.zxing;
  18 +
  19 +import java.util.Arrays;
  20 +
  21 +/**
  22 + * <p>A simple, fast array of bits, represented compactly by an array of ints internally.</p>
  23 + *
  24 + * @author Sean Owen
  25 + */
  26 +public final class BitArray implements Cloneable {
  27 +
  28 + private int[] bits;
  29 + private int size;
  30 +
  31 + public BitArray() {
  32 + this.size = 0;
  33 + this.bits = new int[1];
  34 + }
  35 +
  36 + public BitArray(int size) {
  37 + this.size = size;
  38 + this.bits = makeArray(size);
  39 + }
  40 +
  41 + // For testing only
  42 + BitArray(int[] bits, int size) {
  43 + this.bits = bits;
  44 + this.size = size;
  45 + }
  46 +
  47 + public int getSize() {
  48 + return size;
  49 + }
  50 +
  51 + public int getSizeInBytes() {
  52 + return (size + 7) / 8;
  53 + }
  54 +
  55 + private void ensureCapacity(int size) {
  56 + if (size > bits.length * 32) {
  57 + int[] newBits = makeArray(size);
  58 + System.arraycopy(bits, 0, newBits, 0, bits.length);
  59 + this.bits = newBits;
  60 + }
  61 + }
  62 +
  63 + /**
  64 + * @param i bit to get
  65 + * @return true iff bit i is set
  66 + */
  67 + public boolean get(int i) {
  68 + return (bits[i / 32] & (1 << (i & 0x1F))) != 0;
  69 + }
  70 +
  71 + /**
  72 + * Sets bit i.
  73 + *
  74 + * @param i bit to set
  75 + */
  76 + public void set(int i) {
  77 + bits[i / 32] |= 1 << (i & 0x1F);
  78 + }
  79 +
  80 + /**
  81 + * Flips bit i.
  82 + *
  83 + * @param i bit to set
  84 + */
  85 + public void flip(int i) {
  86 + bits[i / 32] ^= 1 << (i & 0x1F);
  87 + }
  88 +
  89 + /**
  90 + * @param from first bit to check
  91 + * @return index of first bit that is set, starting from the given index, or size if none are set
  92 + * at or beyond this given index
  93 + * @see #getNextUnset(int)
  94 + */
  95 + public int getNextSet(int from) {
  96 + if (from >= size) {
  97 + return size;
  98 + }
  99 + int bitsOffset = from / 32;
  100 + int currentBits = bits[bitsOffset];
  101 + // mask off lesser bits first
  102 + currentBits &= ~((1 << (from & 0x1F)) - 1);
  103 + while (currentBits == 0) {
  104 + if (++bitsOffset == bits.length) {
  105 + return size;
  106 + }
  107 + currentBits = bits[bitsOffset];
  108 + }
  109 + int result = (bitsOffset * 32) + Integer.numberOfTrailingZeros(currentBits);
  110 + return result > size ? size : result;
  111 + }
  112 +
  113 + /**
  114 + * @param from index to start looking for unset bit
  115 + * @return index of next unset bit, or {@code size} if none are unset until the end
  116 + * @see #getNextSet(int)
  117 + */
  118 + public int getNextUnset(int from) {
  119 + if (from >= size) {
  120 + return size;
  121 + }
  122 + int bitsOffset = from / 32;
  123 + int currentBits = ~bits[bitsOffset];
  124 + // mask off lesser bits first
  125 + currentBits &= ~((1 << (from & 0x1F)) - 1);
  126 + while (currentBits == 0) {
  127 + if (++bitsOffset == bits.length) {
  128 + return size;
  129 + }
  130 + currentBits = ~bits[bitsOffset];
  131 + }
  132 + int result = (bitsOffset * 32) + Integer.numberOfTrailingZeros(currentBits);
  133 + return result > size ? size : result;
  134 + }
  135 +
  136 + /**
  137 + * Sets a block of 32 bits, starting at bit i.
  138 + *
  139 + * @param i first bit to set
  140 + * @param newBits the new value of the next 32 bits. Note again that the least-significant bit
  141 + * corresponds to bit i, the next-least-significant to i+1, and so on.
  142 + */
  143 + public void setBulk(int i, int newBits) {
  144 + bits[i / 32] = newBits;
  145 + }
  146 +
  147 + /**
  148 + * Clears all bits (sets to false).
  149 + */
  150 + public void clear() {
  151 + int max = bits.length;
  152 + for (int i = 0; i < max; i++) {
  153 + bits[i] = 0;
  154 + }
  155 + }
  156 +
  157 + public void appendBit(boolean bit) {
  158 + ensureCapacity(size + 1);
  159 + if (bit) {
  160 + bits[size / 32] |= 1 << (size & 0x1F);
  161 + }
  162 + size++;
  163 + }
  164 +
  165 + /**
  166 + * Appends the least-significant bits, from value, in order from most-significant to
  167 + * least-significant. For example, appending 6 bits from 0x000001E will append the bits
  168 + * 0, 1, 1, 1, 1, 0 in that order.
  169 + *
  170 + * @param value {@code int} containing bits to append
  171 + * @param numBits bits from value to append
  172 + */
  173 + public void appendBits(int value, int numBits) {
  174 + if (numBits < 0 || numBits > 32) {
  175 + throw new IllegalArgumentException("Num bits must be between 0 and 32");
  176 + }
  177 + ensureCapacity(size + numBits);
  178 + for (int numBitsLeft = numBits; numBitsLeft > 0; numBitsLeft--) {
  179 + appendBit(((value >> (numBitsLeft - 1)) & 0x01) == 1);
  180 + }
  181 + }
  182 +
  183 + public void appendBitArray(BitArray other) {
  184 + int otherSize = other.size;
  185 + ensureCapacity(size + otherSize);
  186 + for (int i = 0; i < otherSize; i++) {
  187 + appendBit(other.get(i));
  188 + }
  189 + }
  190 +
  191 + public void xor(BitArray other) {
  192 + if (size != other.size) {
  193 + throw new IllegalArgumentException("Sizes don't match");
  194 + }
  195 + for (int i = 0; i < bits.length; i++) {
  196 + // The last int could be incomplete (i.e. not have 32 bits in
  197 + // it) but there is no problem since 0 XOR 0 == 0.
  198 + bits[i] ^= other.bits[i];
  199 + }
  200 + }
  201 +
  202 + /**
  203 + *
  204 + * @param bitOffset first bit to start writing
  205 + * @param array array to write into. Bytes are written most-significant byte first. This is the opposite
  206 + * of the internal representation, which is exposed by {@link #getBitArray()}
  207 + * @param offset position in array to start writing
  208 + * @param numBytes how many bytes to write
  209 + */
  210 + public void toBytes(int bitOffset, byte[] array, int offset, int numBytes) {
  211 + for (int i = 0; i < numBytes; i++) {
  212 + int theByte = 0;
  213 + for (int j = 0; j < 8; j++) {
  214 + if (get(bitOffset)) {
  215 + theByte |= 1 << (7 - j);
  216 + }
  217 + bitOffset++;
  218 + }
  219 + array[offset + i] = (byte) theByte;
  220 + }
  221 + }
  222 +
  223 + /**
  224 + * @return underlying array of ints. The first element holds the first 32 bits, and the least
  225 + * significant bit is bit 0.
  226 + */
  227 + public int[] getBitArray() {
  228 + return bits;
  229 + }
  230 +
  231 + /**
  232 + * Reverses all bits in the array.
  233 + */
  234 + public void reverse() {
  235 + int[] newBits = new int[bits.length];
  236 + // reverse all int's first
  237 + int len = (size - 1) / 32;
  238 + int oldBitsLen = len + 1;
  239 + for (int i = 0; i < oldBitsLen; i++) {
  240 + long x = bits[i];
  241 + x = ((x >> 1) & 0x55555555L) | ((x & 0x55555555L) << 1);
  242 + x = ((x >> 2) & 0x33333333L) | ((x & 0x33333333L) << 2);
  243 + x = ((x >> 4) & 0x0f0f0f0fL) | ((x & 0x0f0f0f0fL) << 4);
  244 + x = ((x >> 8) & 0x00ff00ffL) | ((x & 0x00ff00ffL) << 8);
  245 + x = ((x >> 16) & 0x0000ffffL) | ((x & 0x0000ffffL) << 16);
  246 + newBits[len - i] = (int) x;
  247 + }
  248 + // now correct the int's if the bit size isn't a multiple of 32
  249 + if (size != oldBitsLen * 32) {
  250 + int leftOffset = oldBitsLen * 32 - size;
  251 + int currentInt = newBits[0] >>> leftOffset;
  252 + for (int i = 1; i < oldBitsLen; i++) {
  253 + int nextInt = newBits[i];
  254 + currentInt |= nextInt << (32 - leftOffset);
  255 + newBits[i - 1] = currentInt;
  256 + currentInt = nextInt >>> leftOffset;
  257 + }
  258 + newBits[oldBitsLen - 1] = currentInt;
  259 + }
  260 + bits = newBits;
  261 + }
  262 +
  263 + private static int[] makeArray(int size) {
  264 + return new int[(size + 31) / 32];
  265 + }
  266 +
  267 + @Override
  268 + public boolean equals(Object o) {
  269 + if (!(o instanceof BitArray)) {
  270 + return false;
  271 + }
  272 + BitArray other = (BitArray) o;
  273 + return size == other.size && Arrays.equals(bits, other.bits);
  274 + }
  275 +
  276 + @Override
  277 + public int hashCode() {
  278 + return 31 * size + Arrays.hashCode(bits);
  279 + }
  280 +
  281 + @Override
  282 + public String toString() {
  283 + StringBuilder result = new StringBuilder(size);
  284 + for (int i = 0; i < size; i++) {
  285 + if ((i & 0x07) == 0) {
  286 + result.append(' ');
  287 + }
  288 + result.append(get(i) ? 'X' : '.');
  289 + }
  290 + return result.toString();
  291 + }
  292 +
  293 + @Override
  294 + public BitArray clone() {
  295 + return new BitArray(bits.clone(), size);
  296 + }
  297 +
  298 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/ui/widget/zxing/BitMatrix.java 0 → 100644
  1 +/*
  2 + * Copyright 2007 ZXing authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +
  17 +package com.cnlive.strike.moudle.qr.ui.widget.zxing;
  18 +
  19 +import java.util.Arrays;
  20 +
  21 +/**
  22 + * <p>Represents a 2D matrix of bits. In function arguments below, and throughout the common
  23 + * module, x is the column position, and y is the row position. The ordering is always x, y.
  24 + * The origin is at the top-left.</p>
  25 + *
  26 + * <p>Internally the bits are represented in a 1-D array of 32-bit ints. However, each row begins
  27 + * with a new int. This is done intentionally so that we can copy out a row into a BitArray very
  28 + * efficiently.</p>
  29 + *
  30 + * <p>The ordering of bits is row-major. Within each int, the least significant bits are used first,
  31 + * meaning they represent lower x values. This is compatible with BitArray's implementation.</p>
  32 + *
  33 + * @author Sean Owen
  34 + * @author dswitkin@google.com (Daniel Switkin)
  35 + */
  36 +public final class BitMatrix implements Cloneable {
  37 +
  38 + private final int width;
  39 + private final int height;
  40 + private final int rowSize;
  41 + private final int[] bits;
  42 +
  43 + // A helper to construct a square matrix.
  44 + public BitMatrix(int dimension) {
  45 + this(dimension, dimension);
  46 + }
  47 +
  48 + public BitMatrix(int width, int height) {
  49 + if (width < 1 || height < 1) {
  50 + throw new IllegalArgumentException("Both dimensions must be greater than 0");
  51 + }
  52 + this.width = width;
  53 + this.height = height;
  54 + this.rowSize = (width + 31) / 32;
  55 + bits = new int[rowSize * height];
  56 + }
  57 +
  58 + private BitMatrix(int width, int height, int rowSize, int[] bits) {
  59 + this.width = width;
  60 + this.height = height;
  61 + this.rowSize = rowSize;
  62 + this.bits = bits;
  63 + }
  64 +
  65 + public static BitMatrix parse(String stringRepresentation, String setString, String unsetString) {
  66 + if (stringRepresentation == null) {
  67 + throw new IllegalArgumentException();
  68 + }
  69 +
  70 + boolean[] bits = new boolean[stringRepresentation.length()];
  71 + int bitsPos = 0;
  72 + int rowStartPos = 0;
  73 + int rowLength = -1;
  74 + int nRows = 0;
  75 + int pos = 0;
  76 + while (pos < stringRepresentation.length()) {
  77 + if (stringRepresentation.charAt(pos) == '\n' ||
  78 + stringRepresentation.charAt(pos) == '\r') {
  79 + if (bitsPos > rowStartPos) {
  80 + if (rowLength == -1) {
  81 + rowLength = bitsPos - rowStartPos;
  82 + } else if (bitsPos - rowStartPos != rowLength) {
  83 + throw new IllegalArgumentException("row lengths do not match");
  84 + }
  85 + rowStartPos = bitsPos;
  86 + nRows++;
  87 + }
  88 + pos++;
  89 + } else if (stringRepresentation.substring(pos, pos + setString.length()).equals(setString)) {
  90 + pos += setString.length();
  91 + bits[bitsPos] = true;
  92 + bitsPos++;
  93 + } else if (stringRepresentation.substring(pos, pos + unsetString.length()).equals(unsetString)) {
  94 + pos += unsetString.length();
  95 + bits[bitsPos] = false;
  96 + bitsPos++;
  97 + } else {
  98 + throw new IllegalArgumentException(
  99 + "illegal character encountered: " + stringRepresentation.substring(pos));
  100 + }
  101 + }
  102 +
  103 + // no EOL at end?
  104 + if (bitsPos > rowStartPos) {
  105 + if (rowLength == -1) {
  106 + rowLength = bitsPos - rowStartPos;
  107 + } else if (bitsPos - rowStartPos != rowLength) {
  108 + throw new IllegalArgumentException("row lengths do not match");
  109 + }
  110 + nRows++;
  111 + }
  112 +
  113 + BitMatrix matrix = new BitMatrix(rowLength, nRows);
  114 + for (int i = 0; i < bitsPos; i++) {
  115 + if (bits[i]) {
  116 + matrix.set(i % rowLength, i / rowLength);
  117 + }
  118 + }
  119 + return matrix;
  120 + }
  121 +
  122 + /**
  123 + * <p>Gets the requested bit, where true means black.</p>
  124 + *
  125 + * @param x The horizontal component (i.e. which column)
  126 + * @param y The vertical component (i.e. which row)
  127 + * @return value of given bit in matrix
  128 + */
  129 + public boolean get(int x, int y) {
  130 + int offset = y * rowSize + (x / 32);
  131 + return ((bits[offset] >>> (x & 0x1f)) & 1) != 0;
  132 + }
  133 +
  134 + /**
  135 + * <p>Sets the given bit to true.</p>
  136 + *
  137 + * @param x The horizontal component (i.e. which column)
  138 + * @param y The vertical component (i.e. which row)
  139 + */
  140 + public void set(int x, int y) {
  141 + int offset = y * rowSize + (x / 32);
  142 + bits[offset] |= 1 << (x & 0x1f);
  143 + }
  144 +
  145 + /**
  146 + * <p>Flips the given bit.</p>
  147 + *
  148 + * @param x The horizontal component (i.e. which column)
  149 + * @param y The vertical component (i.e. which row)
  150 + */
  151 + public void flip(int x, int y) {
  152 + int offset = y * rowSize + (x / 32);
  153 + bits[offset] ^= 1 << (x & 0x1f);
  154 + }
  155 +
  156 + /**
  157 + * Clears all bits (sets to false).
  158 + */
  159 + public void clear() {
  160 + int max = bits.length;
  161 + for (int i = 0; i < max; i++) {
  162 + bits[i] = 0;
  163 + }
  164 + }
  165 +
  166 + /**
  167 + * <p>Sets a square region of the bit matrix to true.</p>
  168 + *
  169 + * @param left The horizontal position to begin at (inclusive)
  170 + * @param top The vertical position to begin at (inclusive)
  171 + * @param width The width of the region
  172 + * @param height The height of the region
  173 + */
  174 + public void setRegion(int left, int top, int width, int height) {
  175 + if (top < 0 || left < 0) {
  176 + throw new IllegalArgumentException("Left and top must be nonnegative");
  177 + }
  178 + if (height < 1 || width < 1) {
  179 + throw new IllegalArgumentException("Height and width must be at least 1");
  180 + }
  181 + int right = left + width;
  182 + int bottom = top + height;
  183 + if (bottom > this.height || right > this.width) {
  184 + throw new IllegalArgumentException("The region must fit inside the matrix");
  185 + }
  186 + for (int y = top; y < bottom; y++) {
  187 + int offset = y * rowSize;
  188 + for (int x = left; x < right; x++) {
  189 + bits[offset + (x / 32)] |= 1 << (x & 0x1f);
  190 + }
  191 + }
  192 + }
  193 +
  194 + /**
  195 + * @return The width of the matrix
  196 + */
  197 + public int getWidth() {
  198 + return width;
  199 + }
  200 +
  201 + /**
  202 + * @return The height of the matrix
  203 + */
  204 + public int getHeight() {
  205 + return height;
  206 + }
  207 +
  208 + @Override
  209 + public boolean equals(Object o) {
  210 + if (!(o instanceof BitMatrix)) {
  211 + return false;
  212 + }
  213 + BitMatrix other = (BitMatrix) o;
  214 + return width == other.width && height == other.height && rowSize == other.rowSize &&
  215 + Arrays.equals(bits, other.bits);
  216 + }
  217 +
  218 + @Override
  219 + public int hashCode() {
  220 + int hash = width;
  221 + hash = 31 * hash + width;
  222 + hash = 31 * hash + height;
  223 + hash = 31 * hash + rowSize;
  224 + hash = 31 * hash + Arrays.hashCode(bits);
  225 + return hash;
  226 + }
  227 +
  228 + /**
  229 + * @return string representation using "X" for set and " " for unset bits
  230 + */
  231 + @Override
  232 + public String toString() {
  233 + return toString("X ", " ");
  234 + }
  235 +
  236 + /**
  237 + * @param setString representation of a set bit
  238 + * @param unsetString representation of an unset bit
  239 + * @return string representation of entire matrix utilizing given strings
  240 + */
  241 + public String toString(String setString, String unsetString) {
  242 + return buildToString(setString, unsetString, "\n");
  243 + }
  244 +
  245 + /**
  246 + * @param setString representation of a set bit
  247 + * @param unsetString representation of an unset bit
  248 + * @param lineSeparator newline character in string representation
  249 + * @return string representation of entire matrix utilizing given strings and line separator
  250 + * @deprecated call {@link #toString(String, String)} only, which uses \n line separator always
  251 + */
  252 + @Deprecated
  253 + public String toString(String setString, String unsetString, String lineSeparator) {
  254 + return buildToString(setString, unsetString, lineSeparator);
  255 + }
  256 +
  257 + private String buildToString(String setString, String unsetString, String lineSeparator) {
  258 + StringBuilder result = new StringBuilder(height * (width + 1));
  259 + for (int y = 0; y < height; y++) {
  260 + for (int x = 0; x < width; x++) {
  261 + result.append(get(x, y) ? setString : unsetString);
  262 + }
  263 + result.append(lineSeparator);
  264 + }
  265 + return result.toString();
  266 + }
  267 +
  268 + @Override
  269 + public BitMatrix clone() {
  270 + return new BitMatrix(width, height, rowSize, bits.clone());
  271 + }
  272 +
  273 +}
core/app_qr/src/main/java/com/cnlive/strike/moudle/qr/ui/widget/zxing/BlockPair.java 0 → 100644
  1 +/*
  2 + * Copyright 2008 ZXing authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +
  17 +package com.cnlive.strike.moudle.qr.ui.widget.zxing;
  18 +
  19 +final class BlockPair {
  20 +
  21 + private final byte[] dataBytes;
  22 + private final byte[] errorCorrectionBytes;
  23 +
  24 + BlockPair(byte[] data, byte[] errorCorrection) {
  25 + dataBytes = data;
  26 + errorCorrectionBytes = errorCorrection;
  27 + }
  28 +
  29 + public byte[] getDataBytes() {
  30 + return dataBytes;
  31 + }
  32 +
  33 + public byte[] getErrorCorrectionBytes() {
  34 + return errorCorrectionBytes;
  35 + }
  36 +
  37 +}