From 4c1abca185a5727da6fb314a0cb4cd44bfe1b3bf Mon Sep 17 00:00:00 2001
From: Davin <591807572@qq.com>
Date: 星期五, 07 六月 2024 17:48:47 +0800
Subject: [PATCH] feature appkey修改
---
EZSDK/EZSDK/EZ/TempPassword/Controllers/HDLEZDeviceMsgListViewController.m | 103 ++++++++++++++++++++++++++++++++++++---------------
1 files changed, 72 insertions(+), 31 deletions(-)
diff --git a/EZSDK/EZSDK/EZ/TempPassword/Controllers/HDLEZDeviceMsgListViewController.m b/EZSDK/EZSDK/EZ/TempPassword/Controllers/HDLEZDeviceMsgListViewController.m
index baac279..b4eb890 100644
--- a/EZSDK/EZSDK/EZ/TempPassword/Controllers/HDLEZDeviceMsgListViewController.m
+++ b/EZSDK/EZSDK/EZ/TempPassword/Controllers/HDLEZDeviceMsgListViewController.m
@@ -110,39 +110,16 @@
weakSelf.msgListModel=[HDLEZDevMsgListModel yy_modelWithDictionary:responseData.data];
if (responseData.success) {
weakSelf.msgListModel=[HDLEZDevMsgListModel yy_modelWithDictionary:responseData.data];
- if (weakSelf.msgListModel.list.count!=0) {
- [weakSelf.msgList addObjectsFromArray:weakSelf.msgListModel.list];
- weakSelf.msgListV.msgList=weakSelf.msgList;
- weakSelf.currentPageNo+=1;
- }else{
-#warning mock
- if (weakSelf.msgList.count == 0) {
- HDLEZDeviceMsgInfoModel *model = [[HDLEZDeviceMsgInfoModel alloc] init];
- model.title = @"mock title 浣犲ソ浣犲ソ鎴戞槸瓒呴暱鐨勬祴璇曟爣棰橈紝浣犳潵鐪嬩笅鏄惁瓒呭嚭闀垮害锛屼綘濂戒綘濂芥垜鏄秴闀跨殑娴嬭瘯鏍囬锛屼綘鏉ョ湅涓嬫槸鍚﹁秴鍑洪暱搴�";
- model.createTime = @"2023.06.15";
- model.content = @"mock content";
- model.imageUrl = @"https://upload-images.jianshu.io/upload_images/5809200-a99419bb94924e6d.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240";
- [weakSelf.msgList addObject:model];
-
- HDLEZDeviceMsgInfoModel *model1 = [[HDLEZDeviceMsgInfoModel alloc] init];
- model1.title = @"mock title1锛屼綘濂戒綘濂�";
- model1.createTime = @"2023.06.15";
- model1.content = @"mock content1";
- model1.imageUrl = @"http://b.hiphotos.baidu.com/image/pic/item/e824b899a9014c08878b2c4c0e7b02087af4f4a3.jpg";
- [weakSelf.msgList addObject:model1];
-
- HDLEZDeviceMsgInfoModel *model2 = [[HDLEZDeviceMsgInfoModel alloc] init];
- model2.title = @"mock title2";
- model2.createTime = @"2023.06.15";
- model2.content = @"mock content2";
- model2.imageUrl = @"https://fastly.picsum.photos/id/452/1000/3000.jpg?hmac=g6GQYs1wmiPeoKOdwI3ot1y4MInIj_dnPk_jCYbVYfk";
- [weakSelf.msgList addObject:model2];
-
+ if (weakSelf.currentPageNo == 1) {
+ [weakSelf.msgList removeAllObjects];
}
- weakSelf.msgListV.msgList=weakSelf.msgList;
+ [weakSelf.msgList addObjectsFromArray:weakSelf.msgListModel.list];
+ weakSelf.msgListV.msgList=weakSelf.msgList;
+ if (weakSelf.msgListModel.list.count == weakSelf.pageSize) {
+ weakSelf.currentPageNo+=1;
+ } else {
[weakSelf.footer endRefreshingWithNoMoreData];
}
-
}else{
[weakSelf.view makeToast:responseData.message
duration:1.5
@@ -168,6 +145,18 @@
}
- (void)didClickDownLoad:(MWPhotoBrowser *)photoBrowser {
+
+ __weak __typeof(self)weakSelf = self;
+ [self authPhotoLibraries:^(BOOL isAblity) {
+ if (isAblity) {
+ [weakSelf downloadTheImage];
+ } else {
+ [weakSelf guideUserOpenAuth];
+ }
+ }];
+}
+
+- (void)downloadTheImage {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
if (!self.currentPreviewPhoto || self.currentPreviewPhoto.length == 0) {
[UIView dd_showMessage:NSLocalizedString(@"device_save_gallery_failure", @"涓嬭浇澶辫触")];
@@ -201,9 +190,59 @@
}
else
{
- message = [error description];
+ message = NSLocalizedString(@"device_save_gallery_failure", @"涓嬭浇澶辫触");
+ NSLog(@"#######鍥剧墖淇濆瓨澶辫触锛�%@", [error description]);
}
[UIView dd_showMessage:message];
+}
+
+/*璁块棶鐩稿唽鏉冮檺
+ */
+-(void)authPhotoLibraries:(void(^)(BOOL isAblity))result {
+ PHAuthorizationStatus author =[PHPhotoLibrary authorizationStatus];
+ if (author == PHAuthorizationStatusRestricted || author ==PHAuthorizationStatusDenied){
+ if (result) {
+ result(NO);
+ }
+ } else if (author == PHAuthorizationStatusNotDetermined) { // 棣栨鎺堟潈
+ dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
+ dispatch_async(queue, ^{
+ [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
+ if (status != PHAuthorizationStatusAuthorized) {
+ if (result) {
+ result(NO);
+ }
+ } else {
+ if (result) {
+ result(YES);
+ }
+ }
+ }];
+ });
+ } else {
+ if (result) {
+ result(YES);
+ }
+ }
+}
+
+/*寮曞鐢ㄦ埛鎺堟潈鑾峰彇鍥剧墖
+ */
+- (void)guideUserOpenAuth{
+ UIAlertController *alertC = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"hdl_ez_download_tip", @"娓╅Θ鎻愮ず") message:NSLocalizedString(@"hdl_ez_download_auth", @"璇锋墦寮�璁块棶鏉冮檺") preferredStyle:(UIAlertControllerStyleAlert)];
+ UIAlertAction *alertA = [UIAlertAction actionWithTitle:NSLocalizedString(@"hdl_ez_download_cancle", @"鍙栨秷") style:(UIAlertActionStyleDefault) handler:nil];
+ UIAlertAction *act = [UIAlertAction actionWithTitle:NSLocalizedString(@"hdl_ez_download_toSet", @"鍘昏缃�") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+ // 寮曞鐢ㄦ埛璁剧疆
+ NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
+
+ if ([[UIApplication sharedApplication] canOpenURL:url]) {
+
+ [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
+ }
+ }];
+ [alertC addAction:alertA];
+ [alertC addAction:act];
+ [self presentViewController:alertC animated:YES completion:nil];
}
#pragma mark PrivateMethod
@@ -212,6 +251,8 @@
self.photos = [NSMutableArray array];
[self.photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:picUrl]]];
MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
+ browser.displayActionButton = NO;
+ browser.zoomPhotosToFill = NO;
[browser showDownloadBtn];
[self.navigationController pushViewController:browser animated:NO];
--
Gitblit v1.8.0