Commit bc7a10171a79afca08b8740b78a4ce316cf0c67f
1 parent
4f62092f
图片工具代码更新
Showing
6 changed files
with
27 additions
and
123 deletions
app/strike/src/main/java/com/cnlive/strike/imgutil/ImgActivity.java
| @@ -21,8 +21,6 @@ import com.cnlive.core.imageload.callback.ImageDownLoadCallBack; | @@ -21,8 +21,6 @@ import com.cnlive.core.imageload.callback.ImageDownLoadCallBack; | ||
| 21 | import com.cnlive.core.imageload.config.PriorityMode; | 21 | import com.cnlive.core.imageload.config.PriorityMode; |
| 22 | import com.cnlive.core.imageload.config.ScaleMode; | 22 | import com.cnlive.core.imageload.config.ScaleMode; |
| 23 | import com.cnlive.core.imageload.loader.ImageLoader; | 23 | import com.cnlive.core.imageload.loader.ImageLoader; |
| 24 | -import com.cnlive.core.imageload.preview.model.ImagePreviewShowInfo; | ||
| 25 | -import com.cnlive.core.imageload.preview.model.PreviewData; | ||
| 26 | import com.cnlive.core.imageload.util.DownLoadImageService; | 24 | import com.cnlive.core.imageload.util.DownLoadImageService; |
| 27 | import com.cnlive.cloud.R; | 25 | import com.cnlive.cloud.R; |
| 28 | import com.cnlive.cloud.user.auth.UserService; | 26 | import com.cnlive.cloud.user.auth.UserService; |
| @@ -143,22 +141,19 @@ public class ImgActivity extends AppCompatActivity { | @@ -143,22 +141,19 @@ public class ImgActivity extends AppCompatActivity { | ||
| 143 | .scale(ScaleMode.CENTER_CROP) | 141 | .scale(ScaleMode.CENTER_CROP) |
| 144 | .into(iv_test1); | 142 | .into(iv_test1); |
| 145 | 143 | ||
| 146 | - PreviewData data = new PreviewData(); | ||
| 147 | - data.setCollection(true); | ||
| 148 | - data.setSid(UserService.getUid(this)); | ||
| 149 | - data.setType("1"); | ||
| 150 | - data.setUserId(UserService.getUid(this)); | ||
| 151 | - data.setSave(true); | ||
| 152 | - | ||
| 153 | - ArrayList<ImagePreviewShowInfo> list = new ArrayList<>(); | ||
| 154 | - ImagePreviewShowInfo info = new ImagePreviewShowInfo(); | ||
| 155 | - info.setImgPath(URL1); | ||
| 156 | - info.setPreviewPath(URL1); | ||
| 157 | - list.add(info); | ||
| 158 | - data.setPicList(list); | ||
| 159 | - | ||
| 160 | - | ||
| 161 | - data.setShowImg(URL1); | 144 | +// PreViewImgData data = new PreViewImgData(); |
| 145 | +// data.setCollection(true); | ||
| 146 | +// data.setType("1"); | ||
| 147 | +// data.setUserId(UserService.getUid(this)); | ||
| 148 | +// data.setSave(true); | ||
| 149 | +// ArrayList<PreViewImgInfo> list = new ArrayList<>(); | ||
| 150 | +// PreViewImgInfo info = new PreViewImgInfo(); | ||
| 151 | +// info.setImgUrl(URL1); | ||
| 152 | +// info.setPreviewImgUrl(URL1); | ||
| 153 | +// list.add(info); | ||
| 154 | +// data.setPicInfoList(list); | ||
| 155 | +// | ||
| 156 | +// data.setShowImg(URL1); | ||
| 162 | // iv_test1.setOnClickListener(view -> PreviewImageViewActivity.startPreviewPictrue(this, view, data)); | 157 | // iv_test1.setOnClickListener(view -> PreviewImageViewActivity.startPreviewPictrue(this, view, data)); |
| 163 | 158 | ||
| 164 | // LoadImage.with(this) | 159 | // LoadImage.with(this) |
core/imageload/src/main/java/com/cnlive/core/imagepreview/uti/DownloadUtil.java
| 1 | package com.cnlive.core.imagepreview.uti; | 1 | package com.cnlive.core.imagepreview.uti; |
| 2 | 2 | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | +import android.os.Build; | ||
| 4 | import android.os.Environment; | 5 | import android.os.Environment; |
| 5 | import android.os.Handler; | 6 | import android.os.Handler; |
| 6 | import android.os.Message; | 7 | import android.os.Message; |
| 7 | 8 | ||
| 8 | 9 | ||
| 10 | +import com.cnlive.core.libs.base.util.FileUtils; | ||
| 11 | + | ||
| 9 | import java.io.File; | 12 | import java.io.File; |
| 10 | import java.io.FileOutputStream; | 13 | import java.io.FileOutputStream; |
| 11 | import java.io.IOException; | 14 | import java.io.IOException; |
| @@ -63,7 +66,7 @@ public class DownloadUtil { | @@ -63,7 +66,7 @@ public class DownloadUtil { | ||
| 63 | FileOutputStream fos = null; | 66 | FileOutputStream fos = null; |
| 64 | //储存下载文件的目录 | 67 | //储存下载文件的目录 |
| 65 | 68 | ||
| 66 | - String filePath = (AndroidQUtil.isAndroidQ()? context.getExternalFilesDir("") : Environment.getExternalStorageDirectory()) + File.separator + saveDir; | 69 | + String filePath = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q? context.getExternalFilesDir("") : Environment.getExternalStorageDirectory()) + File.separator + saveDir; |
| 67 | String savePath = isExistDir(filePath); | 70 | String savePath = isExistDir(filePath); |
| 68 | try { | 71 | try { |
| 69 | is = response.body().byteStream(); | 72 | is = response.body().byteStream(); |
core/imageload/src/main/java/com/cnlive/core/ui/presenter/PreViewImagePresenter.java
| @@ -4,6 +4,7 @@ import android.app.Activity; | @@ -4,6 +4,7 @@ import android.app.Activity; | ||
| 4 | import android.content.Context; | 4 | import android.content.Context; |
| 5 | import android.content.Intent; | 5 | import android.content.Intent; |
| 6 | import android.net.Uri; | 6 | import android.net.Uri; |
| 7 | +import android.os.Build; | ||
| 7 | import android.os.Environment; | 8 | import android.os.Environment; |
| 8 | import android.text.TextUtils; | 9 | import android.text.TextUtils; |
| 9 | import android.util.Log; | 10 | import android.util.Log; |
| @@ -12,6 +13,7 @@ import com.bumptech.glide.Glide; | @@ -12,6 +13,7 @@ import com.bumptech.glide.Glide; | ||
| 12 | import com.bumptech.glide.request.FutureTarget; | 13 | import com.bumptech.glide.request.FutureTarget; |
| 13 | import com.bumptech.glide.request.target.Target; | 14 | import com.bumptech.glide.request.target.Target; |
| 14 | import com.cnlive.core.imageload.api.ApiServiceStock; | 15 | import com.cnlive.core.imageload.api.ApiServiceStock; |
| 16 | +import com.cnlive.core.libs.base.application.AppConfig; | ||
| 15 | import com.cnlive.core.libs.base.frame.presenter.BasePresenter; | 17 | import com.cnlive.core.libs.base.frame.presenter.BasePresenter; |
| 16 | import com.cnlive.core.libs.base.util.FileTypeUtil; | 18 | import com.cnlive.core.libs.base.util.FileTypeUtil; |
| 17 | import com.cnlive.core.libs.base.util.FileUtils; | 19 | import com.cnlive.core.libs.base.util.FileUtils; |
| @@ -128,14 +130,14 @@ public class PreViewImagePresenter extends BasePresenter<PreViewImageView> { | @@ -128,14 +130,14 @@ public class PreViewImagePresenter extends BasePresenter<PreViewImageView> { | ||
| 128 | if (FileUtils.isFileExists(imagePath)) { | 130 | if (FileUtils.isFileExists(imagePath)) { |
| 129 | List<String> list = new ArrayList(); | 131 | List<String> list = new ArrayList(); |
| 130 | list.add(imagePath); | 132 | list.add(imagePath); |
| 131 | - UploadLogic.uploadonePic(FLAG,context, true, list, new NetCallBack<List<FeedBackInfo>>() { | 133 | + UploadLogic.uploadonePic(context, true, list, new NetCallBack<List<FeedBackInfo>>() { |
| 132 | @Override | 134 | @Override |
| 133 | public void onRequestState(int state) { | 135 | public void onRequestState(int state) { |
| 134 | 136 | ||
| 135 | } | 137 | } |
| 136 | 138 | ||
| 137 | @Override | 139 | @Override |
| 138 | - public void onSuccess(List<FeedBackInfo> data) { | 140 | + public void onSuccess(List<com.cnlive.core.network.upload.model.FeedBackInfo> data) { |
| 139 | if (data.size() > 0) { | 141 | if (data.size() > 0) { |
| 140 | if (data.get(0).getImageUrl().contains("http")) { | 142 | if (data.get(0).getImageUrl().contains("http")) { |
| 141 | collection(context, data.get(0).getImageUrl(), context.data); | 143 | collection(context, data.get(0).getImageUrl(), context.data); |
| @@ -159,7 +161,7 @@ public class PreViewImagePresenter extends BasePresenter<PreViewImageView> { | @@ -159,7 +161,7 @@ public class PreViewImagePresenter extends BasePresenter<PreViewImageView> { | ||
| 159 | private void collection(PreViewImageActivity context, String imagePath, PreViewImgData previewData) { | 161 | private void collection(PreViewImageActivity context, String imagePath, PreViewImgData previewData) { |
| 160 | if (previewData == null) return; | 162 | if (previewData == null) return; |
| 161 | Map<String, String> requestMap = new HashMap<>(); | 163 | Map<String, String> requestMap = new HashMap<>(); |
| 162 | - requestMap.put("appId", BuildConfig.APP_ID); | 164 | + requestMap.put("appId", AppConfig.getAppId()); |
| 163 | requestMap.put("sid", previewData.getUserId()); | 165 | requestMap.put("sid", previewData.getUserId()); |
| 164 | requestMap.put("type", previewData.getType()); | 166 | requestMap.put("type", previewData.getType()); |
| 165 | requestMap.put("img", imagePath); | 167 | requestMap.put("img", imagePath); |
| @@ -190,7 +192,7 @@ public class PreViewImagePresenter extends BasePresenter<PreViewImageView> { | @@ -190,7 +192,7 @@ public class PreViewImagePresenter extends BasePresenter<PreViewImageView> { | ||
| 190 | requestMap.put("collectionType", previewData.getCollectionType()); | 192 | requestMap.put("collectionType", previewData.getCollectionType()); |
| 191 | } | 193 | } |
| 192 | 194 | ||
| 193 | - HttpConn.action(FLAG, BaseRequest.init() | 195 | + HttpConn.action(BaseRequest.init() |
| 194 | .service(ApiServiceStock.class) | 196 | .service(ApiServiceStock.class) |
| 195 | .collection(requestMap), new NetCallBack<BaseResult>() { | 197 | .collection(requestMap), new NetCallBack<BaseResult>() { |
| 196 | @Override | 198 | @Override |
| @@ -200,12 +202,12 @@ public class PreViewImagePresenter extends BasePresenter<PreViewImageView> { | @@ -200,12 +202,12 @@ public class PreViewImagePresenter extends BasePresenter<PreViewImageView> { | ||
| 200 | 202 | ||
| 201 | @Override | 203 | @Override |
| 202 | public void onSuccess(BaseResult data) { | 204 | public void onSuccess(BaseResult data) { |
| 203 | - if(getView() != null) getView().showSucessfulMessage("收藏成功"); | 205 | + ifViewAttached(view -> view.showSucessfulMessage("收藏成功")); |
| 204 | } | 206 | } |
| 205 | 207 | ||
| 206 | @Override | 208 | @Override |
| 207 | public void onFailure(String errCode, String errMsg, Exception e) { | 209 | public void onFailure(String errCode, String errMsg, Exception e) { |
| 208 | - if(getView() != null) getView().showMessage(errMsg); | 210 | + ifViewAttached(view -> view.showMessage(errMsg)); |
| 209 | } | 211 | } |
| 210 | }); | 212 | }); |
| 211 | } | 213 | } |
| @@ -229,7 +231,7 @@ public class PreViewImagePresenter extends BasePresenter<PreViewImageView> { | @@ -229,7 +231,7 @@ public class PreViewImagePresenter extends BasePresenter<PreViewImageView> { | ||
| 229 | String filePath = "Strike" + File.separator + "video"; | 231 | String filePath = "Strike" + File.separator + "video"; |
| 230 | String md5 = MD5Util.getMD5(file); | 232 | String md5 = MD5Util.getMD5(file); |
| 231 | InputStream inStream = new FileInputStream(file); //读入原文件 | 233 | InputStream inStream = new FileInputStream(file); //读入原文件 |
| 232 | - File appDir = new File((AndroidQUtil.isAndroidQ()? activity.getExternalFilesDir("") : Environment.getExternalStorageDirectory()), filePath); | 234 | + File appDir = new File((Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q? activity.getExternalFilesDir("") : Environment.getExternalStorageDirectory()), filePath); |
| 233 | if (!appDir.exists()) appDir.mkdir(); | 235 | if (!appDir.exists()) appDir.mkdir(); |
| 234 | 236 | ||
| 235 | String type = FileTypeUtil.getFileType(file.getAbsolutePath()); | 237 | String type = FileTypeUtil.getFileType(file.getAbsolutePath()); |
core/imageload/src/main/java/com/cnlive/core/ui/view/PreViewImageView.java
| @@ -230,7 +230,7 @@ public class PreViewImageView extends BaseView { | @@ -230,7 +230,7 @@ public class PreViewImageView extends BaseView { | ||
| 230 | File file = new File(content); //pic 1 video 3 | 230 | File file = new File(content); //pic 1 video 3 |
| 231 | if (!FileUtils.isFileExists(content)) return; | 231 | if (!FileUtils.isFileExists(content)) return; |
| 232 | ArrayList<Media> medialist = new ArrayList<>(); | 232 | ArrayList<Media> medialist = new ArrayList<>(); |
| 233 | - Media media = new Media(file.getPath(), file.getName(), 1, 1, file.length(), 0, "",Uri.fromFile(file).toString()); | 233 | + Media media = new Media(file.getPath(), file.getName(), 1, 1, file.length(), 0, ""); |
| 234 | medialist.add(media); | 234 | medialist.add(media); |
| 235 | PreviewRouters.startReleaseManagementAcityity(activity, file.getPath(), file.getName(), 1, 1, file.length(), 0, ""); | 235 | PreviewRouters.startReleaseManagementAcityity(activity, file.getPath(), file.getName(), 1, 1, file.length(), 0, ""); |
| 236 | if (activity == null) activity.finish(); | 236 | if (activity == null) activity.finish(); |
core/imageload/src/main/res/layout/activity_preview_image_view.xml deleted
100644 → 0
| 1 | -<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | - | ||
| 3 | -<layout> | ||
| 4 | - <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 5 | - xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| 6 | - xmlns:tools="http://schemas.android.com/tools" | ||
| 7 | - android:layout_width="match_parent" | ||
| 8 | - android:layout_height="match_parent" | ||
| 9 | - android:background="@color/black" | ||
| 10 | - tools:context=".preview.PreviewImageViewActivity"> | ||
| 11 | - | ||
| 12 | - <ImageView | ||
| 13 | - android:id="@+id/iv_error" | ||
| 14 | - android:layout_width="wrap_content" | ||
| 15 | - android:layout_height="wrap_content" | ||
| 16 | - android:layout_centerInParent="true" | ||
| 17 | - android:scaleType="fitCenter" | ||
| 18 | - android:background="@drawable/preview_zwtp" | ||
| 19 | - android:visibility="gone"/> | ||
| 20 | - | ||
| 21 | - <com.cnlive.core.imageload.preview.widget.MutipleTouchViewPager | ||
| 22 | - android:id="@+id/vp_photos" | ||
| 23 | - android:layout_width="match_parent" | ||
| 24 | - android:layout_height="wrap_content" | ||
| 25 | - android:background="@color/black" | ||
| 26 | - android:layout_centerInParent="true" | ||
| 27 | - /> | ||
| 28 | - | ||
| 29 | - <LinearLayout | ||
| 30 | - android:id="@+id/rl_indicator" | ||
| 31 | - android:layout_width="wrap_content" | ||
| 32 | - android:layout_height="wrap_content" | ||
| 33 | - android:layout_alignParentBottom="true" | ||
| 34 | - android:layout_centerHorizontal="true" | ||
| 35 | - android:layout_marginBottom="40dp" | ||
| 36 | - android:orientation="horizontal" | ||
| 37 | - android:visibility="gone"> | ||
| 38 | - <TextView | ||
| 39 | - android:id="@+id/tv_current" | ||
| 40 | - android:layout_width="wrap_content" | ||
| 41 | - android:layout_height="wrap_content" | ||
| 42 | - android:textColor="@color/white" | ||
| 43 | - android:textSize="18sp" /> | ||
| 44 | - | ||
| 45 | - <TextView | ||
| 46 | - android:id="@+id/tv" | ||
| 47 | - android:layout_width="wrap_content" | ||
| 48 | - android:layout_height="wrap_content" | ||
| 49 | - android:layout_marginLeft="3dp" | ||
| 50 | - android:textColor="@color/white" | ||
| 51 | - android:text="/" | ||
| 52 | - android:textSize="18sp" /> | ||
| 53 | - | ||
| 54 | - <TextView | ||
| 55 | - android:id="@+id/tv_All" | ||
| 56 | - android:layout_width="wrap_content" | ||
| 57 | - android:layout_height="wrap_content" | ||
| 58 | - android:layout_marginLeft="3dp" | ||
| 59 | - android:textSize="18sp" | ||
| 60 | - android:textColor="@color/white"/> | ||
| 61 | - </LinearLayout> | ||
| 62 | - </RelativeLayout> | ||
| 63 | -</layout> |
core/imageload/src/main/res/layout/item_process_html.xml deleted
100644 → 0
| 1 | -<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | -<layout> | ||
| 3 | - | ||
| 4 | - <data> | ||
| 5 | - | ||
| 6 | - <variable | ||
| 7 | - name="data" | ||
| 8 | - type="com.cnlive.core.imageload.preview.model.ProcessImageInfo" /> | ||
| 9 | - </data> | ||
| 10 | - | ||
| 11 | - <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 12 | - android:id="@+id/root" | ||
| 13 | - android:layout_width="match_parent" | ||
| 14 | - android:layout_height="wrap_content" | ||
| 15 | - android:background="@color/white"> | ||
| 16 | - | ||
| 17 | - <TextView | ||
| 18 | - android:id="@+id/tv_item" | ||
| 19 | - android:layout_width="wrap_content" | ||
| 20 | - android:layout_height="wrap_content" | ||
| 21 | - android:layout_centerInParent="true" | ||
| 22 | - android:layout_centerVertical="true" | ||
| 23 | - android:gravity="center" | ||
| 24 | - android:padding="15dp" | ||
| 25 | - android:textColor="@color/color_333" /> | ||
| 26 | - | ||
| 27 | - <View | ||
| 28 | - android:layout_width="match_parent" | ||
| 29 | - android:layout_height="1dp" | ||
| 30 | - android:layout_below="@+id/tv_item" | ||
| 31 | - android:background="#f2f3f4" /> | ||
| 32 | - </RelativeLayout> | ||
| 33 | -</layout> |