new Thread用RxJava或者线程池代替

This commit is contained in:
kehaoyuan
2017-05-22 09:07:18 +08:00
parent 9369218821
commit 8643a12744
33 changed files with 231 additions and 216 deletions

View File

@ -28,14 +28,14 @@ import rx.schedulers.Schedulers;
* Created by khy on 2016/12/1.
*/
public class QRCodeUtils {
public static void setQRCode(final Context context, final String newsId, final ImageView mShareQrCodeDv) {
public static void setQRCode(final Context context, final String qrBody, final ImageView mShareQrCodeDv) {
Observable
.create(new Observable.OnSubscribe<String>() {
@Override
public void call(Subscriber<? super String> subscriber) {
String filePath = context.getExternalCacheDir().getPath() + "/ShareImg/ShareQRCode.jpg";
boolean success = QRCodeUtils.createQRImage("http://www.ghzhushou.com/article/" + newsId + ".html?source=appshare200"
, 200, 200, filePath, context);
boolean success = QRCodeUtils.createQRImage(qrBody, 200, 200, filePath, context);
if (success) {
subscriber.onNext(filePath);
}
@ -62,7 +62,7 @@ public class QRCodeUtils {
* @param filePath 用于存储二维码图片的文件路径
* @return 生成二维码及保存文件是否成功
*/
public static boolean createQRImage(String content, int widthPix, int heightPix, String filePath, Context context) {
private static boolean createQRImage(String content, int widthPix, int heightPix, String filePath, Context context) {
try {
if (content == null || "".equals(content)) {
return false;