addMsgVC.m 71 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888
  1. //
  2. // addMsgVC.m
  3. // sjvodios
  4. //
  5. // Created by on 12-5-23.
  6. // Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
  7. //
  8. #import <AVFoundation/AVFoundation.h>
  9. #import "addMsgVC.h"
  10. #import "AppDelegate.h"
  11. #import "JXImageView.h"
  12. #import "JXServer.h"
  13. #import "JXConnection.h"
  14. #import "ImageResize.h"
  15. #import "UIFactory.h"
  16. #import "JXTableView.h"
  17. #import "QBImagePickerController.h"
  18. #import "SBJsonWriter.h"
  19. #import "recordVideoViewController.h"
  20. #import "JXTextView.h"
  21. #import "JXMediaObject.h"
  22. #import "LXActionSheet.h"
  23. #import "myMediaVC.h"
  24. #import "JXLocationVC.h"
  25. #import "JXMapData.h"
  26. #import "WhoCanSeeViewController.h"
  27. #import "JXSelFriendVC.h"
  28. #import "JXSelectFriendsVC.h"
  29. #import "RITLPhotosViewController.h"
  30. #import "RITLPhotosDataManager.h"
  31. #import "JXMyFile.h"
  32. #import "UIImageView+FileType.h"
  33. #import "JXFileDetailViewController.h"
  34. #import "JXShareFileObject.h"
  35. #import "webpageVC.h"
  36. #import "JXSelectorVC.h"
  37. #ifdef Meeting_Version
  38. #ifdef Live_Version
  39. #import "JXSmallVideoViewController.h"
  40. #endif
  41. #endif
  42. #import "JXActionSheetVC.h"
  43. #import "JXCameraVC.h"
  44. #import "QCheckBox.h"
  45. #import "JXSelectCoverVC.h"
  46. #define insert_photo_tag -100000
  47. typedef enum {
  48. MsgVisible_public = 1,
  49. MsgVisible_private,
  50. MsgVisible_see,
  51. MsgVisible_nonSee,
  52. // MsgVisible_remind,
  53. }MsgVisible;
  54. @interface addMsgVC()<VisibelDelegate,RITLPhotosViewControllerDelegate,JXSelectorVCDelegate, JXActionSheetVCDelegate, JXCameraVCDelegate,JXSelectCoverVCDelegate,JXImageViewPanDelegate,JXActionSheetVCDelegate>
  55. @property (nonatomic) UIButton * lableBtn;
  56. @property (nonatomic) UIButton * locBtn;
  57. @property (nonatomic) UIButton * canSeeBtn;
  58. @property (nonatomic) UIButton * remindWhoBtn;
  59. @property (nonatomic) UIButton * replybanBtn;
  60. @property (nonatomic, strong) QCheckBox *checkbox;
  61. @property (nonatomic) UIButton * notReplyBtn;
  62. @property (nonatomic) UILabel * lableLabel;
  63. @property (nonatomic) UILabel * visibleLabel;
  64. @property (nonatomic) UILabel * remindLabel;
  65. @property (nonatomic) MsgVisible visible;
  66. @property (nonatomic) NSArray * userArray;
  67. @property (nonatomic) NSArray * userIdArray;
  68. @property (nonatomic) NSMutableArray * selLabelsArray;
  69. @property (nonatomic) NSMutableArray * mailListUserArray;
  70. @property (nonatomic) CLLocationCoordinate2D coor;
  71. @property (nonatomic) NSString * locStr;
  72. @property (nonatomic) NSArray * remindArray;
  73. @property (nonatomic) NSArray * remindNameArray;
  74. @property (nonatomic) NSArray * visibelArray;
  75. @property (nonatomic, assign) int timeLen;
  76. @property (nonatomic, assign) NSInteger currentLableIndex;
  77. @property (nonatomic, strong) JXLocationVC *locationVC;
  78. @property (nonatomic, strong) JXImageView* iv;
  79. @property (nonatomic, assign) CGPoint startPoint;
  80. @property (nonatomic, assign) CGPoint oraginPoint;
  81. @property (nonatomic, assign) CGPoint newPoint;
  82. @property (nonatomic, assign) CGPoint lastPoint;
  83. @property (nonatomic, strong) NSMutableArray* imageViewArray;
  84. @property (nonatomic, assign) NSTimeInterval intoBorderTime;
  85. @property (nonatomic, assign) NSTimeInterval stayBorderTime;
  86. @property (nonatomic, assign) BOOL inBorder;
  87. @property (nonatomic, assign) BOOL isUpdateImage;
  88. @property (nonatomic, strong) NSMutableArray *videoImageUlrArr; // 视频封面url
  89. @property (nonatomic, assign) BOOL isVideoFirstUpload; // 上传封面
  90. @property (nonatomic, strong) NSMutableDictionary *gifDataDic;
  91. @end
  92. @implementation addMsgVC
  93. @synthesize isChanged;
  94. @synthesize audioFile;
  95. @synthesize videoFile;
  96. @synthesize fileFile;
  97. @synthesize dataType;
  98. #define video_tag -100
  99. #define audio_tag -200
  100. #define pause_tag -300
  101. #define file_tag -400
  102. - (addMsgVC *) init
  103. {
  104. self = [super init];
  105. self.heightHeader = JX_SCREEN_TOP;
  106. self.heightFooter = 0;
  107. self.maxImageCount = 9;
  108. self.isGotoBack = YES;
  109. self.isFreeOnClose = YES;
  110. self.title = Localized(@"addMsgVC_SendFriend");
  111. //self.view.frame = g_window.bounds;
  112. [self createHeadAndFoot];
  113. self.tableBody.backgroundColor = [UIColor whiteColor];
  114. _images = [[NSMutableArray alloc]init];
  115. _videoImageUlrArr = [[NSMutableArray alloc]init];
  116. _visible = MsgVisible_public;
  117. _remindArray = [NSArray array];
  118. _visibelArray = [NSArray arrayWithObjects:Localized(@"JXBlogVisibel_public"), Localized(@"JXBlogVisibel_private"), Localized(@"JXBlogVisibel_see"), Localized(@"JXBlogVisibel_nonSee"), nil];
  119. #ifdef Meeting_Version
  120. #ifdef Live_Version
  121. _currentLableIndex = JXSmallVideoTypeOther - 1;
  122. #endif
  123. #endif
  124. return self;
  125. }
  126. -(void)dealloc{
  127. // NSLog(@"addMsgVC.dealloc");
  128. [_images removeAllObjects];
  129. // [_images release];
  130. // [super dealloc];
  131. }
  132. -(void)setDataType:(int)value{
  133. dataType = value;
  134. [g_factory removeAllChild:self.tableBody];
  135. _buildHeight=0;
  136. if(dataType >= weibo_dataType_text){
  137. [self buildTextView];
  138. self.title = Localized(@"JX_SendWord");
  139. //在发布信息后调用,并使其刷新
  140. }
  141. if(dataType == weibo_dataType_image){
  142. [self buildImageViews];
  143. self.title = Localized(@"JX_SendImage");
  144. }
  145. if(dataType == weibo_dataType_audio){
  146. [self buildAudios];
  147. [self showAudios];
  148. self.title = Localized(@"JX_SendVoice");
  149. }
  150. if(dataType == weibo_dataType_video){
  151. [self buildVideos];
  152. if (videoFile.length > 0) {
  153. UIImage *image = [FileInfo getFirstImageFromVideo:videoFile];
  154. if (image) {
  155. [_images addObject:image];
  156. }
  157. }
  158. [self showVideos];
  159. self.title = Localized(@"JX_SendVideo");
  160. }
  161. if (dataType == weibo_dataType_file) {
  162. [self buildFiles];
  163. [self showFiles];
  164. self.title = Localized(@"JX_SendFile");
  165. }
  166. if (dataType == weibo_dataType_share) {
  167. [self buildShare];
  168. self.title = Localized(@"JX_ShareLifeCircle");
  169. }
  170. int h1 = 38,h=0,w=JX_SCREEN_WIDTH-9*2;
  171. CGFloat maxY = 0;
  172. UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, h+_buildHeight+10, JX_SCREEN_WIDTH, 8)];
  173. line.backgroundColor = HEXCOLOR(0xF2F2F2);
  174. [self.tableBody addSubview:line];
  175. //可见
  176. [self.tableBody addSubview:self.canSeeBtn];
  177. self.canSeeBtn.frame = CGRectMake(0, CGRectGetMaxY(line.frame), JX_SCREEN_WIDTH, 56);
  178. maxY = CGRectGetMaxY(self.canSeeBtn.frame);
  179. //提醒
  180. [self.tableBody addSubview:self.remindWhoBtn];
  181. self.remindWhoBtn.frame = CGRectMake(0, h+CGRectGetMaxY(self.canSeeBtn.frame), JX_SCREEN_WIDTH, 56);
  182. maxY = CGRectGetMaxY(self.remindWhoBtn.frame);
  183. if (self.isShortVideo) {
  184. //标签
  185. [self.tableBody addSubview:self.lableBtn];
  186. self.lableBtn.frame = CGRectMake(0, h+CGRectGetMaxY(self.remindWhoBtn.frame), JX_SCREEN_WIDTH, 56);
  187. maxY = CGRectGetMaxY(self.lableBtn.frame);
  188. }
  189. if ([g_config.isOpenPositionService intValue] == 0) {
  190. //位置
  191. [self.tableBody addSubview:self.locBtn];
  192. if (self.isShortVideo) {
  193. self.locBtn.frame = CGRectMake(0, h+CGRectGetMaxY(self.lableBtn.frame), JX_SCREEN_WIDTH, 56);
  194. }else {
  195. self.locBtn.frame = CGRectMake(0, h+CGRectGetMaxY(self.remindWhoBtn.frame), JX_SCREEN_WIDTH, 56);
  196. }
  197. maxY = CGRectGetMaxY(self.locBtn.frame);
  198. }
  199. //禁止他人评论
  200. [self.tableBody addSubview:self.replybanBtn];
  201. self.replybanBtn.frame = CGRectMake(0, maxY, JX_SCREEN_WIDTH, 56);
  202. maxY = CGRectGetMaxY(self.replybanBtn.frame);
  203. UIButton* btn;
  204. btn = [UIFactory createButtonWithTitle:Localized(@"JX_Send")
  205. titleFont:g_factory.font15
  206. titleColor:[UIColor whiteColor]
  207. normal:nil
  208. highlight:nil];
  209. // [btn setBackgroundImage:[g_theme themeTintImage:@"feaBtn_backImg_sel"] forState:UIControlStateNormal];
  210. // [btn setBackgroundImage:[g_theme themeTintImage:@"feaBtn_backImg_sel"] forState:UIControlStateDisabled];
  211. [btn setBackgroundImage:[UIImage createImageWithColor:THEMECOLOR] forState:UIControlStateNormal];
  212. [btn setBackgroundImage:[UIImage createImageWithColor:[THEMECOLOR colorWithAlphaComponent:0.5]] forState:UIControlStateDisabled];
  213. btn.frame = CGRectMake(JX_SCREEN_WIDTH-15-51, JX_SCREEN_TOP-9-29, 51, 29);
  214. btn.custom_acceptEventInterval = .25f;
  215. btn.layer.cornerRadius = 3.f;
  216. btn.layer.masksToBounds = YES;
  217. btn.enabled = NO;
  218. [btn addTarget:self action:@selector(actionSave) forControlEvents:UIControlEventTouchUpInside];
  219. [self.tableHeader addSubview:btn];
  220. _sendBtn = btn;
  221. [self showImages];
  222. }
  223. - (UIButton *)lableBtn {
  224. if (!_lableBtn) {
  225. _lableBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  226. [_lableBtn setBackgroundColor:[UIColor whiteColor]];
  227. [_lableBtn setTitle:Localized(@"JX_SelectionLabel") forState:UIControlStateNormal];
  228. [_lableBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  229. [_lableBtn setTitleColor:HEXCOLOR(0x576b95) forState:UIControlStateSelected];
  230. _lableBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  231. [_lableBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 50, 0, 0)];
  232. _lableBtn.titleLabel.font = g_factory.font16;
  233. _lableBtn.custom_acceptEventInterval = 1.0f;
  234. [_lableBtn addTarget:self action:@selector(lableBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  235. UIView * line = [[UIView alloc] init];
  236. line.frame = CGRectMake(15, 55.5, JX_SCREEN_WIDTH-15*2, LINE_WH);
  237. line.backgroundColor = THE_LINE_COLOR;
  238. [_lableBtn addSubview:line];
  239. UIImageView * locImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tap"]];
  240. locImg.frame = CGRectMake(15, 17, 22, 22);
  241. [_lableBtn addSubview:locImg];
  242. // _locLabel = [UIFactory createLabelWith:CGRectZero text:@"所在位置" font:g_factory.font15 textColor:[UIColor blackColor] backgroundColor:[UIColor clearColor]];
  243. // _locLabel.frame = CGRectMake(CGRectGetMaxX(locImg.frame)+10, 8, JX_SCREEN_WIDTH-CGRectGetMaxX(locImg.frame)-10-50, 30);
  244. // [_locBtn addSubview:_locLabel];
  245. UIImageView * arrowView = [[UIImageView alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-15-7, 21.5, 7, 13)];
  246. arrowView.image = [UIImage imageNamed:@"new_icon_>"];
  247. [_lableBtn addSubview:arrowView];
  248. _lableLabel = [UIFactory createLabelWith:CGRectZero text:Localized(@"OTHER") font:g_factory.font16 textColor:[UIColor blackColor] backgroundColor:[UIColor clearColor]];
  249. _lableLabel.frame = CGRectMake(arrowView.frame.origin.x - 200 - 10, 17, 200, 22);
  250. _lableLabel.textAlignment = NSTextAlignmentRight;
  251. [_lableBtn addSubview:_lableLabel];
  252. }
  253. return _lableBtn;
  254. }
  255. -(UIButton *)locBtn{
  256. if (!_locBtn) {
  257. _locBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  258. [_locBtn setBackgroundColor:[UIColor whiteColor]];
  259. [_locBtn setTitle:Localized(@"JXUserInfoVC_Loation") forState:UIControlStateNormal];
  260. [_locBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  261. [_locBtn setTitleColor:HEXCOLOR(0x576b95) forState:UIControlStateSelected];
  262. _locBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  263. [_locBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 50, 0, 0)];
  264. _locBtn.titleLabel.font = g_factory.font16;
  265. _locBtn.custom_acceptEventInterval = 1.0f;
  266. [_locBtn addTarget:self action:@selector(locBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  267. UIView * line = [[UIView alloc] init];
  268. line.frame = CGRectMake(50, 55.5, JX_SCREEN_WIDTH-15*2, LINE_WH);
  269. line.backgroundColor = THE_LINE_COLOR;
  270. [_locBtn addSubview:line];
  271. UIImageView * locImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"currentLocation_gray"]];
  272. locImg.frame = CGRectMake(15, 17, 22, 22);
  273. [_locBtn addSubview:locImg];
  274. // _locLabel = [UIFactory createLabelWith:CGRectZero text:@"所在位置" font:g_factory.font15 textColor:[UIColor blackColor] backgroundColor:[UIColor clearColor]];
  275. // _locLabel.frame = CGRectMake(CGRectGetMaxX(locImg.frame)+10, 8, JX_SCREEN_WIDTH-CGRectGetMaxX(locImg.frame)-10-50, 30);
  276. // [_locBtn addSubview:_locLabel];
  277. UIImageView * arrowView = [[UIImageView alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-15-7, 21.5, 7, 13)];
  278. arrowView.image = [UIImage imageNamed:@"new_icon_>"];
  279. [_locBtn addSubview:arrowView];
  280. }
  281. return _locBtn;
  282. }
  283. -(UIButton *)canSeeBtn{
  284. if (!_canSeeBtn) {
  285. _canSeeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  286. [_canSeeBtn setBackgroundColor:[UIColor whiteColor]];
  287. [_canSeeBtn setTitle:Localized(@"JXBlog_whocansee") forState:UIControlStateNormal];
  288. // [_canSeeBtn setTitle:Localized(@"JXBlog_whocansee") forState:UIControlStateSelected];
  289. [_canSeeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  290. [_canSeeBtn setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
  291. _canSeeBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  292. [_canSeeBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 50, 0, 0)];
  293. _canSeeBtn.titleLabel.font = g_factory.font16;
  294. _canSeeBtn.custom_acceptEventInterval = 1.0f;
  295. [_canSeeBtn addTarget:self action:@selector(whoCanSeeBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  296. UIView * line = [[UIView alloc] init];
  297. line.frame = CGRectMake(50, 55.5, JX_SCREEN_WIDTH-15*2, LINE_WH);
  298. line.backgroundColor = THE_LINE_COLOR;
  299. [_canSeeBtn addSubview:line];
  300. UIImageView * locImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"seeVisibel_gray"]];
  301. locImg.frame = CGRectMake(15, 17, 22, 22);
  302. [_canSeeBtn addSubview:locImg];
  303. UIImageView * arrowView = [[UIImageView alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-15-7, 21.5, 7, 13)];
  304. arrowView.image = [UIImage imageNamed:@"new_icon_>"];
  305. [_canSeeBtn addSubview:arrowView];
  306. _visibleLabel = [UIFactory createLabelWith:CGRectZero text:_visibelArray[_visible-1] font:g_factory.font16 textColor:[UIColor blackColor] backgroundColor:[UIColor clearColor]];
  307. _visibleLabel.frame = CGRectMake(CGRectGetMaxX(_canSeeBtn.titleLabel.frame)+_canSeeBtn.titleEdgeInsets.left+10, 17, CGRectGetMinX(arrowView.frame)-CGRectGetMaxX(_canSeeBtn.titleLabel.frame)-_canSeeBtn.titleEdgeInsets.left-10-10, 22);
  308. _visibleLabel.textAlignment = NSTextAlignmentRight;
  309. _visibleLabel.textColor = HEXCOLOR(0x999999);
  310. [_canSeeBtn addSubview:_visibleLabel];
  311. }
  312. return _canSeeBtn;
  313. }
  314. -(UIButton *)remindWhoBtn{
  315. if (!_remindWhoBtn) {
  316. _remindWhoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  317. [_remindWhoBtn setBackgroundColor:[UIColor whiteColor]];
  318. [_remindWhoBtn setTitle:Localized(@"JXBlog_remindWho") forState:UIControlStateNormal];
  319. [_remindWhoBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  320. [_remindWhoBtn setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
  321. [_remindWhoBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateDisabled];
  322. _remindWhoBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  323. [_remindWhoBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 50, 0, 0)];
  324. _remindWhoBtn.titleLabel.font = g_factory.font16;
  325. _remindWhoBtn.custom_acceptEventInterval = 1.0f;
  326. [_remindWhoBtn addTarget:self action:@selector(remindWhoBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  327. UIView * line = [[UIView alloc] init];
  328. line.frame = CGRectMake(50, 55.5, JX_SCREEN_WIDTH-15*2, LINE_WH);
  329. line.backgroundColor = THE_LINE_COLOR;
  330. [_remindWhoBtn addSubview:line];
  331. UIImageView * locImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"blogRemind_gray"]];
  332. locImg.frame = CGRectMake(15, 17, 22, 22);
  333. [_remindWhoBtn addSubview:locImg];
  334. UIImageView * arrowView = [[UIImageView alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-15-7, 21.5, 7, 13)];
  335. arrowView.image = [UIImage imageNamed:@"new_icon_>"];
  336. [_remindWhoBtn addSubview:arrowView];
  337. _remindLabel = [UIFactory createLabelWith:CGRectZero text:@"" font:g_factory.font16 textColor:[UIColor blackColor] backgroundColor:[UIColor clearColor]];
  338. _remindLabel.frame = CGRectMake(CGRectGetMaxX(_remindWhoBtn.titleLabel.frame)+_remindWhoBtn.titleEdgeInsets.left+30, 17, CGRectGetMinX(arrowView.frame)-CGRectGetMaxX(_remindWhoBtn.titleLabel.frame)-_remindWhoBtn.titleEdgeInsets.left-10-30, 22);
  339. _remindLabel.textAlignment = NSTextAlignmentRight;
  340. _remindLabel.textColor = HEXCOLOR(0x999999);
  341. [_remindWhoBtn addSubview:_remindLabel];
  342. }
  343. return _remindWhoBtn;
  344. }
  345. - (UIButton *)replybanBtn {
  346. if (!_replybanBtn) {
  347. _replybanBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  348. // _checkbox = [[QCheckBox alloc] initWithDelegate:self];
  349. // _checkbox.frame = CGRectMake(15, 15, 20, 20);
  350. // [_replybanBtn addSubview:_checkbox];
  351. _notReplyBtn = [[UIButton alloc] initWithFrame:CGRectMake(15, 17, 22, 22)];
  352. [_notReplyBtn setBackgroundImage:[UIImage imageNamed:@"weibo_not_reply"] forState:UIControlStateNormal];
  353. [_notReplyBtn setBackgroundImage:[UIImage imageNamed:@"sel_check_wx2"] forState:UIControlStateSelected];
  354. [_notReplyBtn addTarget:self action:@selector(clickReplyBanBtn) forControlEvents:UIControlEventTouchUpInside];
  355. [_replybanBtn addSubview:_notReplyBtn];
  356. UILabel *tint = [[UILabel alloc] initWithFrame:CGRectMake(50, 18, 100, 20)];
  357. tint.text = Localized(@"JX_DoNotCommentOnThem");
  358. tint.font = SYSFONT(16);
  359. [_replybanBtn addSubview:tint];
  360. UILabel *tintGray = [[UILabel alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-15-160, 18, 160, 20)];
  361. tintGray.text = Localized(@"JX_ EveryoneCanNotComment");
  362. tintGray.textColor = HEXCOLOR(0x999999);
  363. tintGray.font = SYSFONT(12);
  364. [_replybanBtn addSubview:tintGray];
  365. [_replybanBtn addTarget:self action:@selector(clickReplyBanBtn) forControlEvents:UIControlEventTouchUpInside];
  366. }
  367. return _replybanBtn;
  368. }
  369. - (void)didReceiveMemoryWarning
  370. {
  371. // Releases the view if it doesn't have a superview.
  372. [super didReceiveMemoryWarning];
  373. }
  374. -(void)doRefresh{
  375. _refreshCount++;
  376. }
  377. - (void)viewWillAppear:(BOOL)animated
  378. {
  379. [super viewWillAppear:animated];
  380. }
  381. - (void)viewDidAppear:(BOOL)animated
  382. {
  383. [super viewDidAppear:animated];
  384. if (self.urlShare.length > 0) {
  385. _remark.text = self.urlShare;
  386. }
  387. }
  388. -(void)buildTextView{
  389. _buildHeight = 0;
  390. _remark = [[UITextView alloc] initWithFrame:CGRectMake(15, 1, JX_SCREEN_WIDTH -30,78)];
  391. // _remark.target = self;
  392. // _remark.didTouch = @selector(actionSave);
  393. //_remark.placeHolder = @"这一刻的想法..";
  394. _remark.backgroundColor = [UIColor clearColor];
  395. // _remark.layer.borderColor = [UIColor colorWithWhite:0.8f alpha:1.0f].CGColor;
  396. // _remark.layer.borderWidth = 0.65f;
  397. // _remark.layer.cornerRadius = 6.0f;
  398. _remark.returnKeyType = UIReturnKeyDone;
  399. _remark.font = g_factory.font16;
  400. _remark.text = Localized(@"addMsgVC_Mind");
  401. _remark.textColor = [UIColor grayColor];
  402. _remark.delegate = self;
  403. [self.tableBody addSubview:_remark];
  404. _buildHeight += 80;
  405. }
  406. - (void)textViewDidChange:(UITextView *)textView {
  407. _sendBtn.enabled = fileFile.length > 0 || _images.count > 0 || videoFile.length > 0 || audioFile.length > 0 || textView.text.length > 0;
  408. }
  409. -(void)buildImageViews{
  410. // UILabel* lb = [[UILabel alloc]initWithFrame:CGRectMake(0, _buildHeight, JX_SCREEN_WIDTH, 25)];
  411. // lb.text = Localized(@"addMsgVC_AddPhoto");
  412. // lb.font = g_UIFactory.font16;
  413. // lb.backgroundColor = [UIColor clearColor];
  414. // [self.tableBody addSubview:lb];
  415. svImages = [[UIScrollView alloc] initWithFrame:CGRectMake(0, _buildHeight+25, JX_SCREEN_WIDTH,80)];
  416. svImages.pagingEnabled = YES;
  417. svImages.delegate = self;
  418. svImages.showsVerticalScrollIndicator = NO;
  419. svImages.showsHorizontalScrollIndicator = NO;
  420. svImages.backgroundColor = [UIColor clearColor];
  421. svImages.userInteractionEnabled = YES;
  422. [self.tableBody addSubview:svImages];
  423. _buildHeight += 105;
  424. }
  425. -(void)buildAudios{
  426. // UILabel* lb = [[UILabel alloc]initWithFrame:CGRectMake(0, _buildHeight, JX_SCREEN_WIDTH, 25)];
  427. // lb.text = Localized(@"addMsgVC_AddVoice");
  428. // lb.font = g_UIFactory.font14;
  429. // lb.backgroundColor = [UIColor clearColor];
  430. // [self.tableBody addSubview:lb];
  431. svAudios = [[UIScrollView alloc] initWithFrame:CGRectMake(0, _buildHeight+25, JX_SCREEN_WIDTH,80)];
  432. svAudios.pagingEnabled = YES;
  433. svAudios.delegate = self;
  434. svAudios.showsVerticalScrollIndicator = NO;
  435. svAudios.showsHorizontalScrollIndicator = NO;
  436. svAudios.backgroundColor = [UIColor clearColor];
  437. svAudios.userInteractionEnabled = YES;
  438. [self.tableBody addSubview:svAudios];
  439. _buildHeight += 105;
  440. }
  441. -(void)buildVideos{
  442. // UILabel* lb = [[UILabel alloc]initWithFrame:CGRectMake(0, _buildHeight, JX_SCREEN_WIDTH, 25)];
  443. // lb.text = Localized(@"addMsgVC_AddVideo");
  444. // lb.font = g_UIFactory.font14;
  445. // lb.backgroundColor = [UIColor clearColor];
  446. // [self.tableBody addSubview:lb];
  447. svVideos = [[UIScrollView alloc] initWithFrame:CGRectMake(0, _buildHeight+25, JX_SCREEN_WIDTH ,80)];
  448. svVideos.pagingEnabled = YES;
  449. svVideos.delegate = self;
  450. svVideos.showsVerticalScrollIndicator = NO;
  451. svVideos.showsHorizontalScrollIndicator = NO;
  452. svVideos.backgroundColor = [UIColor clearColor];
  453. svVideos.userInteractionEnabled = YES;
  454. [self.tableBody addSubview:svVideos];
  455. _buildHeight += 105;
  456. }
  457. -(void)buildFiles{
  458. // UILabel* lb = [[UILabel alloc]initWithFrame:CGRectMake(0, _buildHeight, JX_SCREEN_WIDTH, 25)];
  459. // lb.text = Localized(@"JX_AddMsgVC_AddFile");
  460. // lb.font = g_UIFactory.font14;
  461. // lb.backgroundColor = [UIColor clearColor];
  462. // [self.tableBody addSubview:lb];
  463. svFiles = [[UIScrollView alloc] initWithFrame:CGRectMake(0, _buildHeight+25, JX_SCREEN_WIDTH ,80)];
  464. svFiles.pagingEnabled = YES;
  465. svFiles.delegate = self;
  466. svFiles.showsVerticalScrollIndicator = NO;
  467. svFiles.showsHorizontalScrollIndicator = NO;
  468. svFiles.backgroundColor = [UIColor clearColor];
  469. svFiles.userInteractionEnabled = YES;
  470. [self.tableBody addSubview:svFiles];
  471. _buildHeight += 105;
  472. }
  473. - (void)buildShare{
  474. UIButton *view = [[UIButton alloc] initWithFrame:CGRectMake(10, _buildHeight + 25, JX_SCREEN_WIDTH - 20, 70)];
  475. view.backgroundColor = HEXCOLOR(0xf0f0f0);
  476. [view addTarget:self action:@selector(shareAction:) forControlEvents:UIControlEventTouchUpInside];
  477. [self.tableBody addSubview:view];
  478. JXImageView *imageView = [[JXImageView alloc] initWithFrame:CGRectMake(10, 10, 50, 50)];
  479. // imageView.image = [UIImage imageNamed:@"ALOGO_1200"];
  480. [imageView sd_setImageWithURL:[NSURL URLWithString:self.shareIcon] placeholderImage:[UIImage imageNamed:@"ALOGO_1200"]];
  481. [view addSubview:imageView];
  482. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(imageView.frame) + 5, imageView.frame.origin.y, view.frame.size.width - CGRectGetMaxX(imageView.frame) - 15, imageView.frame.size.height)];
  483. label.numberOfLines = 0;
  484. // label.text = @"哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈";
  485. label.text = self.shareTitle;
  486. label.font = [UIFont systemFontOfSize:14.0];
  487. [view addSubview:label];
  488. _buildHeight += 105;
  489. }
  490. - (void)shareAction:(UIButton *)btn {
  491. webpageVC *webVC = [webpageVC alloc];
  492. webVC.isGotoBack= YES;
  493. webVC.isSend = YES;
  494. webVC.title = self.shareTitle;
  495. webVC.url = self.shareUr;
  496. webVC = [webVC init];
  497. [g_navigation.navigationView addSubview:webVC.view];
  498. // [g_navigation pushViewController:webVC animated:YES];
  499. }
  500. -(void)showImages{
  501. int i;
  502. [g_factory removeAllChild:svImages];
  503. NSInteger n = [_images count];
  504. _sendBtn.enabled = n > 1 || _remark.text.length > 0;
  505. svImages.contentSize = CGSizeMake((n+1) * 80, svImages.frame.size.height);
  506. for(i=0;i<n&&i<9;i++){
  507. JXImageView* iv = [[JXImageView alloc]initWithFrame:CGRectMake(i*78+15, 10, 63,63)];
  508. iv.delegate = self;
  509. iv.panDelegate = self;
  510. iv.userInteractionEnabled = YES;
  511. iv.layer.cornerRadius = 6;
  512. iv.layer.masksToBounds = YES;
  513. iv.animationType = JXImageView_Animation_Line;
  514. iv.tag = i;
  515. [iv addLongPressGesture];
  516. [iv addTapGesture];
  517. iv.image = [_images objectAtIndex:i];
  518. [svImages addSubview:iv];
  519. // [iv release];
  520. }
  521. _imageViewArray = [NSMutableArray arrayWithArray:svImages.subviews];
  522. UIButton* btn = [self createButton:nil icon:@"add_picture" action:@selector(actionImage:) parent:svImages];
  523. btn.frame = CGRectMake(i*78+15, 10, 63, 63);
  524. btn.tag = insert_photo_tag;
  525. }
  526. - (void)tapImageView:(JXImageView *)imageView{
  527. [self actionImage:imageView];
  528. }
  529. - (void)getTouchWhenMove:(JXImageView *)imageView withTouch:(NSSet *)touch withEvent:(UIEvent *)event withLongPressGes:(UILongPressGestureRecognizer *)lpGes{
  530. UITouch *mytouch = touch.allObjects.lastObject;
  531. CGPoint inWindow = [mytouch locationInView:nil];
  532. if ((inWindow.x > JX_SCREEN_WIDTH - 30 && inWindow.x < JX_SCREEN_WIDTH && svImages.contentOffset.x == 0) || (inWindow.x < 30 && svImages.contentOffset.x > 0)) {
  533. if (_inBorder) {
  534. _stayBorderTime = mytouch.timestamp - _intoBorderTime;
  535. if (_stayBorderTime > 0.3) {
  536. [self changeWhenPan:imageView gesture:lpGes];
  537. }
  538. }else{
  539. _inBorder = YES;
  540. _intoBorderTime = mytouch.timestamp;
  541. }
  542. }else{
  543. _inBorder = NO;
  544. _intoBorderTime = 0;
  545. }
  546. }
  547. - (void)changeWhenPan:(JXImageView *)sender gesture:(UILongPressGestureRecognizer *)sender2{
  548. BOOL isBorderStart = NO;
  549. if (sender2.state == UIGestureRecognizerStateBegan) {
  550. [svImages setScrollEnabled:NO];
  551. sender.alpha = 0.5;
  552. self.startPoint = [sender2 locationInView:svImages];
  553. CGPoint inWindow = [sender2 locationInView:nil];
  554. if ((inWindow.x > JX_SCREEN_WIDTH - 30 && inWindow.x < JX_SCREEN_WIDTH && svImages.contentOffset.x == 0) || (inWindow.x < 30 && svImages.contentOffset.x > 0)) {
  555. isBorderStart = YES;
  556. }else{
  557. isBorderStart = NO;
  558. }
  559. self.oraginPoint = sender.center;
  560. _lastPoint = _oraginPoint;
  561. [self.view bringSubviewToFront:svImages];
  562. [svImages bringSubviewToFront:sender];
  563. }else if (sender2.state == UIGestureRecognizerStateChanged) {
  564. self.newPoint = [sender2 locationInView:svImages];
  565. CGFloat xChange = _newPoint.x - _startPoint.x;
  566. CGFloat yChange = _newPoint.y - _startPoint.y;
  567. sender.center = CGPointMake(_oraginPoint.x + xChange, _oraginPoint.y + yChange);
  568. CGPoint inWindow = [sender2 locationInView:nil];
  569. if (isBorderStart) {
  570. if ((inWindow.x < JX_SCREEN_WIDTH - 30 && svImages.contentOffset.x == 0) && (inWindow.x > 30 && svImages.contentOffset.x > 0)){
  571. isBorderStart = NO;
  572. }
  573. }
  574. if (inWindow.x < 30 && svImages.contentOffset.x > 0 && !isBorderStart && _stayBorderTime > 0.3) {
  575. for (int num = 0; num <_imageViewArray.count; num++) {
  576. JXImageView *imgView = _imageViewArray[num];
  577. if (imgView.tag != num) {
  578. [_imageViewArray exchangeObjectAtIndex:num withObjectAtIndex:imgView.tag];
  579. }
  580. }
  581. [UIView animateWithDuration:0.3 animations:^{
  582. [svImages setContentOffset:CGPointMake(0, 0)];
  583. }];
  584. _stayBorderTime = 0;
  585. _inBorder = NO;
  586. NSInteger index = sender.tag;
  587. for (NSInteger i = index - 1; i > -1; i--) {
  588. JXImageView *imgView = _imageViewArray[i];
  589. [_images exchangeObjectAtIndex:imgView.tag withObjectAtIndex:imgView.tag + 1];
  590. [UIView animateWithDuration:0.5 animations:^{
  591. imgView.tag = imgView.tag + 1;
  592. CGPoint center = imgView.center;
  593. imgView.center = _lastPoint;
  594. _lastPoint = center;
  595. }];
  596. }
  597. sender.tag = 0;
  598. }else if (inWindow.x > g_window.frame.size.width - 30 && _newPoint.x < svImages.contentSize.width && !isBorderStart && _stayBorderTime > 0.3) {
  599. for (int num = 0; num <_imageViewArray.count; num++) {
  600. JXImageView *imgView = _imageViewArray[num];
  601. if (imgView.tag != num) {
  602. [_imageViewArray exchangeObjectAtIndex:num withObjectAtIndex:imgView.tag];
  603. }
  604. }
  605. [UIView animateWithDuration:0.3 animations:^{
  606. [svImages setContentOffset:CGPointMake(svImages.contentSize.width - JX_SCREEN_WIDTH, 0)];
  607. }];
  608. _stayBorderTime = 0;
  609. _inBorder = NO;
  610. NSInteger index = sender.tag;
  611. for (NSInteger i = index + 1; i < _imageViewArray.count; i++) {
  612. JXImageView *imgView = _imageViewArray[i];
  613. [_images exchangeObjectAtIndex:imgView.tag withObjectAtIndex:imgView.tag - 1];
  614. [UIView animateWithDuration:0.5 animations:^{
  615. imgView.tag = imgView.tag - 1;
  616. CGPoint center = imgView.center;
  617. imgView.center = _lastPoint;
  618. _lastPoint = center;
  619. }];
  620. }
  621. sender.tag = _imageViewArray.count - 1;
  622. }else{
  623. for (int num = 0; num <_imageViewArray.count; num++) {
  624. JXImageView *imgView = _imageViewArray[num];
  625. if (imgView.tag != num) {
  626. [_imageViewArray exchangeObjectAtIndex:num withObjectAtIndex:imgView.tag];
  627. }
  628. }
  629. for (NSInteger i = 0;i < _imageViewArray.count; i++) {
  630. JXImageView * imgView = _imageViewArray[i];
  631. if (CGRectContainsPoint(imgView.frame, _newPoint)) {
  632. if (imgView == sender) {
  633. continue;
  634. }
  635. [UIView animateWithDuration:0.3 animations:^{
  636. CGPoint point = imgView.center;
  637. imgView.center = _lastPoint;
  638. _lastPoint = point;
  639. }];
  640. [_images exchangeObjectAtIndex:imgView.tag withObjectAtIndex:sender.tag];
  641. NSInteger l = imgView.tag;
  642. imgView.tag = sender.tag;
  643. sender.tag = l;
  644. }
  645. }
  646. if (!CGRectContainsPoint(svImages.bounds, _newPoint)) {
  647. [sender2 setState:UIGestureRecognizerStateEnded];
  648. }
  649. }
  650. }else if(sender2.state == UIGestureRecognizerStateEnded) {
  651. sender.alpha = 1;
  652. [UIView animateWithDuration:0.3 animations:^{
  653. sender.center = _lastPoint;
  654. }];
  655. [svImages setScrollEnabled:YES];
  656. }
  657. }
  658. -(void)showAudios{
  659. // int i;
  660. [g_factory removeAllChild:svAudios];
  661. if(audioFile){
  662. _sendBtn.enabled = YES;
  663. JXImageView* iv = [[JXImageView alloc]initWithFrame:CGRectMake(10, 10, 60, 60)];
  664. iv.userInteractionEnabled = YES;
  665. iv.layer.cornerRadius = 6;
  666. iv.layer.masksToBounds = YES;
  667. iv.delegate = self;
  668. // iv.didTouch = @selector(onDelAudio);
  669. iv.didTouch = @selector(donone);
  670. iv.animationType = JXImageView_Animation_Line;
  671. iv.tag = audio_tag;
  672. [svAudios addSubview:iv];
  673. // [iv release];
  674. if([_images count]>0)
  675. iv.image = [_images objectAtIndex:0];
  676. else
  677. [g_server getHeadImageSmall:g_server.myself.userId userName:g_server.myself.userNickname imageView:iv];
  678. audioPlayer = [[JXAudioPlayer alloc] initWithParent:iv];
  679. audioPlayer.isOpenProximityMonitoring = NO;
  680. audioPlayer.pauseBtn.userInteractionEnabled = NO;
  681. audioPlayer.audioFile = audioFile;
  682. }else{
  683. _sendBtn.enabled = _remark.text.length > 0;
  684. UIButton* btn = [self createButton:nil icon:@"add_voice" action:@selector(onAddAudio) parent:svAudios];
  685. btn.frame = CGRectMake(15, 10, 63, 63);
  686. }
  687. }
  688. -(void)showVideos{
  689. // int i;
  690. [g_factory removeAllChild:svVideos];
  691. if(videoFile){
  692. _sendBtn.enabled = YES;
  693. _iv = [[JXImageView alloc] initWithFrame:CGRectMake(15, 10, 60, 60)];
  694. _iv.userInteractionEnabled = YES;
  695. _iv.layer.cornerRadius = 6;
  696. _iv.layer.masksToBounds = YES;
  697. _iv.delegate = self;
  698. // iv.didTouch = @selector(onDelVideo);
  699. _iv.didTouch = @selector(donone);
  700. _iv.animationType = JXImageView_Animation_Line;
  701. _iv.tag = video_tag;
  702. if([_images count]>0)
  703. _iv.image = [_images objectAtIndex:0];
  704. else
  705. [g_server getHeadImageSmall:g_server.myself.userId userName:g_server.myself.userNickname imageView:_iv];
  706. [svVideos addSubview:_iv];
  707. // [iv release];
  708. UIButton *pauseBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
  709. pauseBtn.center = CGPointMake(_iv.frame.size.width/2,_iv.frame.size.height/2);
  710. [pauseBtn setBackgroundImage:[UIImage imageNamed:@"playvideo"] forState:UIControlStateNormal];
  711. [pauseBtn addTarget:self action:@selector(showTheVideo) forControlEvents:UIControlEventTouchUpInside];
  712. [_iv addSubview:pauseBtn];
  713. pauseBtn.userInteractionEnabled = NO;
  714. // videoPlayer = [[JXVideoPlayer alloc] initWithParent:iv];
  715. // videoPlayer.videoFile = videoFile;
  716. }else{
  717. _sendBtn.enabled = _remark.text.length > 0;
  718. UIButton* btn = [self createButton:nil icon:@"add_video" action:@selector(onAddVideo) parent:svVideos];
  719. btn.frame = CGRectMake(15, 10, 63, 63);
  720. }
  721. }
  722. - (void)donone {
  723. if (audioFile) {
  724. JXActionSheetVC *vc = [[JXActionSheetVC alloc] initWithImages:nil names:@[@"重新录制",@"播放"]];
  725. vc.delegate = self;
  726. vc.tag = 10021;
  727. [self presentViewController:vc animated:YES completion:nil];
  728. }
  729. else if (videoFile) {
  730. JXActionSheetVC *vc = [[JXActionSheetVC alloc] initWithImages:nil names:@[@"重新选择",@"重新录制",@"播放"]];
  731. vc.delegate = self;
  732. vc.tag = 10022;
  733. [self presentViewController:vc animated:YES completion:nil];
  734. }
  735. }
  736. - (void)selectImageView:(id)imgView index:(NSInteger)tag{
  737. NSLog(@"我的tag = %ld",(long)tag);
  738. _iv.image = _images[tag];
  739. [self saveImgCover:_images[tag]];
  740. }
  741. // 保存封面图
  742. - (void)saveImgCover:(UIImage *)img{
  743. NSString *filePath = [NSString stringWithFormat:@"%@%@.jpg",myTempFilePath,[[videoFile lastPathComponent] stringByDeletingPathExtension]];
  744. NSFileManager *manager = [NSFileManager defaultManager];
  745. BOOL isExist = [manager fileExistsAtPath:filePath];
  746. NSError *error;
  747. if (isExist) {
  748. [manager removeItemAtPath:filePath error:&error];
  749. }
  750. NSData * imageData = UIImageJPEGRepresentation(img, 1);
  751. BOOL isSave = [imageData writeToFile:filePath atomically:YES];
  752. if (!isSave) {
  753. NSLog(@"保存封面图失败");
  754. return;
  755. }
  756. [self.videoImageUlrArr removeAllObjects];
  757. self.isVideoFirstUpload = YES;
  758. [g_server uploadFile:filePath validTime:nil messageId:nil toView:self];
  759. }
  760. - (void)showTheVideo {
  761. // UIView *playerView = [[UIView alloc] initWithFrame:self.view.bounds];
  762. // [self.view addSubview:playerView];
  763. videoPlayer= [JXVideoPlayer alloc];
  764. videoPlayer.videoFile = videoFile;
  765. videoPlayer.didVideoPlayEnd = @selector(didVideoPlayEnd);
  766. videoPlayer.isStartFullScreenPlay = YES; //全屏播放
  767. videoPlayer.delegate = self;
  768. videoPlayer = [videoPlayer initWithParent:self.view];
  769. [videoPlayer switch];
  770. }
  771. -(void)showFiles{
  772. // int i;
  773. [g_factory removeAllChild:svFiles];
  774. if(fileFile){
  775. _sendBtn.enabled = YES;
  776. JXImageView* iv = [[JXImageView alloc] initWithFrame:CGRectMake(15, 10, 60, 60)];
  777. iv.userInteractionEnabled = YES;
  778. iv.layer.cornerRadius = 6;
  779. iv.layer.masksToBounds = YES;
  780. iv.delegate = self;
  781. iv.didTouch = @selector(actionFile:);
  782. iv.animationType = JXImageView_Animation_Line;
  783. iv.tag = file_tag;
  784. NSString * fileExt = [fileFile pathExtension];
  785. NSInteger fileType = [self fileTypeWithExt:fileExt];
  786. [iv setFileType:fileType];
  787. // if([_images count]>0)
  788. // iv.image = [_images objectAtIndex:0];
  789. // else
  790. // [g_server getHeadImageSmall:g_server.myself.userId imageView:iv];
  791. [svFiles addSubview:iv];
  792. }else{
  793. _sendBtn.enabled = _remark.text.length > 0;
  794. UIButton* btn = [self createButton:nil icon:@"add_file" action:@selector(onAddFile) parent:svFiles];
  795. btn.frame = CGRectMake(15, 10, 63, 63);
  796. }
  797. }
  798. - (void)actionFile:(JXImageView *)imageView {
  799. JXActionSheetVC *vc = [[JXActionSheetVC alloc] initWithImages:nil names:@[@"重新选择",@"打开"]];
  800. vc.delegate = self;
  801. vc.tag = 10001;
  802. [self presentViewController:vc animated:YES completion:nil];
  803. // JXFileDetailViewController * detailVC = [[JXFileDetailViewController alloc] init];
  804. // NSDictionary *dict = @{
  805. // @"url":fileFile,
  806. // @"name":[fileFile pathExtension]
  807. // };
  808. // JXShareFileObject *fileObj = [JXShareFileObject shareFileWithDict:dict];
  809. // detailVC.shareFile = fileObj;
  810. // [g_navigation pushViewController:detailVC animated:YES];
  811. // [g_navigation pushViewController:webVC animated:YES];
  812. }
  813. -(int)fileTypeWithExt:(NSString *)fileExt{
  814. int fileType = 0;
  815. if ([fileExt isEqualToString:@"jpg"] || [fileExt isEqualToString:@"jpeg"] || [fileExt isEqualToString:@"png"] || [fileExt isEqualToString:@"gif"] || [fileExt isEqualToString:@"bmp"])
  816. fileType = 1;
  817. else if ([fileExt isEqualToString:@"amr"] || [fileExt isEqualToString:@"mp3"] || [fileExt isEqualToString:@"wav"])
  818. fileType = 2;
  819. else if ([fileExt isEqualToString:@"mp4"] || [fileExt isEqualToString:@"mov"])
  820. fileType = 3;
  821. else if ([fileExt isEqualToString:@"ppt"] || [fileExt isEqualToString:@"pptx"])
  822. fileType = 4;
  823. else if ([fileExt isEqualToString:@"xls"] || [fileExt isEqualToString:@"xlsx"])
  824. fileType = 5;
  825. else if ([fileExt isEqualToString:@"doc"] || [fileExt isEqualToString:@"docx"])
  826. fileType = 6;
  827. else if ([fileExt isEqualToString:@"zip"] || [fileExt isEqualToString:@"rar"])
  828. fileType = 7;
  829. else if ([fileExt isEqualToString:@"txt"])
  830. fileType = 8;
  831. else if ([fileExt isEqualToString:@"pdf"])
  832. fileType = 10;
  833. else
  834. fileType = 9;
  835. return fileType;
  836. }
  837. - (void)viewDidload{
  838. [super viewDidLoad];
  839. }
  840. - (void)viewDidUnload
  841. {
  842. [super viewDidUnload];
  843. }
  844. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  845. {
  846. // Return YES for supported orientations
  847. return (interfaceOrientation == UIInterfaceOrientationPortrait);
  848. }
  849. - (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
  850. if ([textView.text isEqualToString:Localized(@"addMsgVC_Mind")]) {
  851. textView.text = @"";
  852. textView.textColor = [UIColor blackColor];
  853. }
  854. return YES;
  855. }
  856. - (void)textViewDidEndEditing:(UITextView *)textView{
  857. // [textView resignFirstResponder];
  858. return;
  859. }
  860. - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
  861. if ([text isEqualToString:@"\n"] ) {
  862. [self.view endEditing:YES];
  863. }
  864. if(textView.text.length > 10000 && ![text isEqualToString:@""]){
  865. [JXMyTools showTipView:Localized(@"JX_InputLimit")];
  866. return NO;
  867. }
  868. return YES;
  869. }
  870. -(void)actionImage:(JXImageView*)sender{
  871. _photoIndex = sender.tag;
  872. if(_photoIndex==insert_photo_tag&&[_images count]>8){
  873. [g_App showAlert:Localized(@"addMsgVC_SelNinePhoto")];
  874. return;
  875. }else if(_photoIndex==insert_photo_tag){
  876. JXActionSheetVC *actionVC = [[JXActionSheetVC alloc] initWithImages:@[] names:@[Localized(@"JX_ChoosePhoto"),Localized(@"JX_TakePhoto")]];
  877. actionVC.delegate = self;
  878. actionVC.tag = 111;
  879. [self presentViewController:actionVC animated:NO completion:nil];
  880. return;
  881. }
  882. LXActionSheet* _menu = [[LXActionSheet alloc]
  883. initWithTitle:nil
  884. delegate:self
  885. cancelButtonTitle:Localized(@"JX_Cencal")
  886. destructiveButtonTitle:Localized(@"JX_Update")
  887. otherButtonTitles:@[Localized(@"JX_Delete")]];
  888. [g_window addSubview:_menu];
  889. // [_menu release];
  890. }
  891. - (void)actionSheet:(JXActionSheetVC *)actionSheet didButtonWithIndex:(NSInteger)index {
  892. if (actionSheet.tag == 2457) {
  893. if (index == 0) {
  894. RITLPhotosViewController *photoController = RITLPhotosViewController.photosViewController;
  895. photoController.configuration.maxCount = 1;//最大的选择数目
  896. photoController.configuration.containVideo = YES;//选择类型,目前只选择图片不选择视频
  897. photoController.configuration.containImage = NO;//选择类型,目前只选择视频不选择图片
  898. photoController.photo_delegate = self;
  899. // photoController.thumbnailSize = CGSizeMake(220, 220);//缩略图的尺寸
  900. // photoController.defaultIdentifers = self.saveAssetIds;//记录已经选择过的资源
  901. [self presentViewController:photoController animated:true completion:^{}];
  902. }else {
  903. JXCameraVC *vc = [JXCameraVC alloc];
  904. vc.cameraDelegate = self;
  905. vc.isVideo = YES;
  906. vc = [vc init];
  907. [self presentViewController:vc animated:YES completion:nil];
  908. }
  909. }
  910. else if (actionSheet.tag == 10001) {
  911. if (index == 0) {
  912. [self onAddFile];
  913. }
  914. else if (index == 1) {
  915. webpageVC *webVC = [webpageVC alloc];
  916. webVC.isGotoBack= YES;
  917. webVC.isSend = YES;
  918. webVC.title = [fileFile pathExtension];
  919. webVC.url = fileFile;
  920. webVC = [webVC init];
  921. [g_navigation.navigationView addSubview:webVC.view];
  922. }
  923. }
  924. else if (actionSheet.tag == 10021) {
  925. if (index == 0) {
  926. [self onAddAudio];
  927. }
  928. else if (index == 1) {
  929. [audioPlayer switch];
  930. }
  931. }
  932. else if (actionSheet.tag == 10022) {
  933. if (index == 0) {
  934. RITLPhotosViewController *photoController = RITLPhotosViewController.photosViewController;
  935. photoController.configuration.maxCount = 1;//最大的选择数目
  936. photoController.configuration.containVideo = YES;//选择类型,目前只选择图片不选择视频
  937. photoController.configuration.containImage = NO;//选择类型,目前只选择视频不选择图片
  938. photoController.photo_delegate = self;
  939. // photoController.thumbnailSize = CGSizeMake(220, 220);//缩略图的尺寸
  940. // photoController.defaultIdentifers = self.saveAssetIds;//记录已经选择过的资源
  941. [self presentViewController:photoController animated:true completion:^{}];
  942. }
  943. else if (index == 1) {
  944. JXCameraVC *vc = [JXCameraVC alloc];
  945. vc.cameraDelegate = self;
  946. vc.isVideo = YES;
  947. vc = [vc init];
  948. [self presentViewController:vc animated:YES completion:nil];
  949. }
  950. else {
  951. [self showTheVideo];
  952. }
  953. }
  954. else{
  955. if (index == 0) {
  956. self.maxImageCount = self.maxImageCount - (int)[_images count];
  957. self.isUpdateImage = NO;
  958. [self pickImages:YES];
  959. }else {
  960. JXCameraVC *vc = [JXCameraVC alloc];
  961. vc.cameraDelegate = self;
  962. vc.isPhoto = YES;
  963. vc = [vc init];
  964. [self presentViewController:vc animated:YES completion:nil];
  965. }
  966. }
  967. }
  968. - (void)cameraVC:(JXCameraVC *)vc didFinishWithImage:(UIImage *)image {
  969. [_images addObject:image];
  970. [self showImages];
  971. }
  972. - (void)cameraVC:(JXCameraVC *)vc didFinishWithVideoPath:(NSString *)filePath timeLen:(NSInteger)timeLen {
  973. [_images removeAllObjects];
  974. JXMediaObject* media = [[JXMediaObject alloc] init];
  975. media.userId = MY_USER_ID;
  976. media.fileName = filePath;
  977. media.isVideo = [NSNumber numberWithBool:YES];
  978. media.timeLen = [NSNumber numberWithInteger:timeLen];
  979. media.createTime = [NSDate date];
  980. // media.photoPath = filePath.absoluteString;
  981. [media insert];
  982. NSString* file = media.fileName;
  983. UIImage *image = [FileInfo getFirstImageFromVideo:file];
  984. videoFile = [file copy];
  985. // file = [NSString stringWithFormat:@"%@.jpg",[file stringByDeletingPathExtension]];
  986. // [_images addObject:[UIImage imageWithContentsOfFile:file]];
  987. [_images addObject:image];
  988. JXSelectCoverVC *Vc = [[JXSelectCoverVC alloc] initWithVideo:videoFile];
  989. Vc.delegate = self;
  990. [g_navigation pushViewController:Vc animated:YES];
  991. [self showVideos];
  992. }
  993. - (void)didClickOnButtonIndex:(LXActionSheet*)sender buttonIndex:(int)buttonIndex{
  994. if(buttonIndex<0)
  995. return;
  996. _nSelMenu = buttonIndex;
  997. [self doOutputMenu];
  998. }
  999. -(void)doOutputMenu{
  1000. if(_nSelMenu==0){
  1001. if(_photoIndex == audio_tag){
  1002. [self onAddAudio];
  1003. return;
  1004. }
  1005. if(_photoIndex == video_tag){
  1006. [self onAddVideo];
  1007. return;
  1008. }
  1009. self.isUpdateImage = YES;
  1010. [self pickImages:NO];
  1011. }
  1012. if(_nSelMenu==1){
  1013. if(_photoIndex == audio_tag){
  1014. [self onDelAudio];
  1015. return;
  1016. }
  1017. if(_photoIndex == video_tag){
  1018. [self onDelVideo];
  1019. return;
  1020. }
  1021. [_images removeObjectAtIndex:_photoIndex];
  1022. [self showImages];
  1023. }
  1024. }
  1025. -(void)pickImages:(BOOL)Multi{
  1026. RITLPhotosViewController *photoController = RITLPhotosViewController.photosViewController;
  1027. if (!self.isUpdateImage) {
  1028. photoController.configuration.maxCount = 9 - _images.count;//最大的选择数目
  1029. }else {
  1030. photoController.configuration.maxCount = 1;//最大的选择数目
  1031. }
  1032. photoController.configuration.containVideo = NO;//选择类型,目前只选择图片不选择视频
  1033. photoController.photo_delegate = self;
  1034. photoController.thumbnailSize = CGSizeMake(320, 320);//缩略图的尺寸
  1035. // photoController.defaultIdentifers = self.saveAssetIds;//记录已经选择过的资源
  1036. [self presentViewController:photoController animated:true completion:^{}];
  1037. // QBImagePickerController *imagePickerController = [[QBImagePickerController alloc] init];
  1038. // __weak id weakSelf = self;
  1039. // imagePickerController.delegate = weakSelf;
  1040. // imagePickerController.allowsMultipleSelection = YES;
  1041. // imagePickerController.limitsMaximumNumberOfSelection = YES;
  1042. //// imagePickerController.limitsMinimumNumberOfSelection = YES;
  1043. // imagePickerController.maximumNumberOfSelection = self.maxImageCount;
  1044. //// imagePickerController.minimumNumberOfSelection = 1;
  1045. //
  1046. // UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:imagePickerController];
  1047. // [self presentViewController:navigationController animated:YES completion:NULL];
  1048. // [imagePickerController release];
  1049. // [navigationController release];
  1050. }
  1051. #pragma mark - 发送原图
  1052. - (void)photosViewController:(UIViewController *)viewController images:(NSArray<UIImage *> *)images infos:(NSArray<NSDictionary *> *)infos {
  1053. if (self.isUpdateImage) {
  1054. _images[_photoIndex] = images.firstObject;
  1055. }else {
  1056. [_images addObjectsFromArray:images.mutableCopy];
  1057. }
  1058. self.gifDataDic = nil;
  1059. self.gifDataDic = [NSMutableDictionary dictionary];
  1060. for (int i = 0; i < images.count; i++) {
  1061. UIImage *image = images[i];
  1062. if (image.images.count > 0) {
  1063. NSDictionary *dic = [infos objectAtIndex:i];
  1064. NSData *data = [dic objectForKey:@"gifData"];
  1065. [self.gifDataDic setValue:data forKey:[NSString stringWithFormat:@"%d",i]];
  1066. }
  1067. }
  1068. [self showImages];
  1069. }
  1070. #pragma mark - 发送缩略图
  1071. - (void)photosViewController:(UIViewController *)viewController thumbnailImages:(NSArray *)thumbnailImages infos:(NSArray<NSDictionary *> *)infos {
  1072. if (self.isUpdateImage) {
  1073. _images[_photoIndex] = thumbnailImages.firstObject;
  1074. }else {
  1075. [_images addObjectsFromArray:thumbnailImages.mutableCopy];
  1076. }
  1077. self.gifDataDic = nil;
  1078. self.gifDataDic = [NSMutableDictionary dictionary];
  1079. for (int i = 0; i < thumbnailImages.count; i++) {
  1080. UIImage *image = thumbnailImages[i];
  1081. if (image.images.count > 0) {
  1082. NSDictionary *dic = [infos objectAtIndex:i];
  1083. NSData *data = [dic objectForKey:@"gifData"];
  1084. [self.gifDataDic setValue:data forKey:[NSString stringWithFormat:@"%d",i]];
  1085. }
  1086. }
  1087. [self showImages];
  1088. }
  1089. - (void)imagePickerController:(QBImagePickerController *)imagePickerController didFinishPickingMediaWithInfo:(id)info
  1090. {
  1091. if(imagePickerController.allowsMultipleSelection) {
  1092. NSArray *mediaInfoArray = (NSArray *)info;
  1093. // NSLog(@"Selected %d photos", mediaInfoArray.count);
  1094. for(int i=0;i<[mediaInfoArray count];i++){
  1095. NSDictionary *selected = (NSDictionary *)[mediaInfoArray objectAtIndex:i];
  1096. [_images addObject:[selected objectForKey:@"UIImagePickerControllerOriginalImage"]];
  1097. }
  1098. } else {
  1099. NSDictionary *selected = (NSDictionary *)info;
  1100. [_images replaceObjectAtIndex:_photoIndex withObject:[selected objectForKey:@"UIImagePickerControllerOriginalImage"]];
  1101. // NSLog(@"Selected: %@", selected);
  1102. }
  1103. [self dismissViewControllerAnimated:YES completion:NULL];
  1104. [self showImages];
  1105. }
  1106. -(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
  1107. {
  1108. [self dismissViewControllerAnimated:NO completion:^{
  1109. }];
  1110. }
  1111. - (NSString *)imagePickerController:(QBImagePickerController *)imagePickerController descriptionForNumberOfPhotos:(NSUInteger)numberOfPhotos{
  1112. return [NSString stringWithFormat:@"%ld photos",numberOfPhotos];
  1113. }
  1114. //- (NSString *)descriptionForSelectingAllAssets:(QBImagePickerController *)imagePickerController
  1115. //{
  1116. // return @"全部选择";
  1117. //}
  1118. //
  1119. //- (NSString *)descriptionForDeselectingAllAssets:(QBImagePickerController *)imagePickerController
  1120. //{
  1121. // return @"取消全部";
  1122. //}
  1123. - (NSString *)getNumberFromStr:(NSString *)str
  1124. {
  1125. NSCharacterSet *nonDigitCharacterSet = [[NSCharacterSet decimalDigitCharacterSet] invertedSet];
  1126. return[[str componentsSeparatedByCharactersInSet:nonDigitCharacterSet] componentsJoinedByString:@""];
  1127. }
  1128. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  1129. // [g_App hideMessage:g_App.lastMsgView];
  1130. [_wait stop];
  1131. if([aDownload.action isEqualToString:act_UploadFile]){
  1132. if (self.isVideoFirstUpload) {
  1133. self.isVideoFirstUpload = NO;
  1134. // [self.videoImageUlrArr removeAllObjects];
  1135. self.videoImageUlrArr = [dict objectForKey:@"images"];
  1136. // [g_server uploadFile:_images audio:audioFile video:videoFile file:fileFile type:self.dataType+1 validTime:@"-1" timeLen:_timeLen toView:self];
  1137. return;
  1138. }
  1139. NSDictionary *dataD;
  1140. if (_timeLen > 0) { // 和安卓统一,所以自己传length,暂时只有语音处理
  1141. NSMutableDictionary *dataDict = [NSMutableDictionary dictionary];
  1142. [dataDict setObject:@(_timeLen) forKey:@"length"];
  1143. [dataDict setObject:[(NSDictionary *)[[dict objectForKey:@"audios"] firstObject] objectForKey:@"oFileName"] forKey:@"oFileName"];
  1144. [dataDict setObject:[(NSDictionary *)[[dict objectForKey:@"audios"] firstObject] objectForKey:@"status"] forKey:@"status"];
  1145. [dataDict setObject:[(NSDictionary *)[[dict objectForKey:@"audios"] firstObject] objectForKey:@"oUrl"] forKey:@"oUrl"];
  1146. NSMutableDictionary *mutDict = [NSMutableDictionary dictionaryWithDictionary:dict];
  1147. NSMutableArray *mutArr = [NSMutableArray arrayWithObjects:dataDict, nil];
  1148. [mutDict setObject:mutArr forKey:@"audios"];
  1149. dataD = mutDict;
  1150. }else {
  1151. NSMutableArray *array = [NSMutableArray arrayWithArray:[dict objectForKey:@"images"]];
  1152. if (array.count > 0) {
  1153. for (NSInteger i = 0; i < array.count -1; i++) {
  1154. for (NSInteger j = 0; j < array.count - 1; j++) {
  1155. NSString *str1 = [(NSDictionary *)array[j] objectForKey:@"oFileName"];
  1156. NSString *str2 = [(NSDictionary *)array[j+1] objectForKey:@"oFileName"];
  1157. NSInteger num1 = [[self getNumberFromStr:str1] integerValue];
  1158. NSInteger num2 = [[self getNumberFromStr:str2] integerValue];
  1159. if (num1 > num2) {
  1160. [array exchangeObjectAtIndex:j withObjectAtIndex:j+1];
  1161. }
  1162. }
  1163. }
  1164. [dict setValue:array forKey:@"images"];
  1165. }
  1166. if (self.videoImageUlrArr.count > 0) {
  1167. [dict setValue:self.videoImageUlrArr forKey:@"images"];
  1168. }
  1169. dataD = dict;
  1170. }
  1171. NSString *label = nil;
  1172. if (self.isShortVideo) {
  1173. label = [NSString stringWithFormat:@"%ld",self.currentLableIndex + 1];
  1174. }
  1175. [g_server addMessage:_remark.text type:dataType data:dataD flag:3 visible:_visible lookArray:_userIdArray coor:_coor location:_locStr remindArray:_remindArray lable:label isAllowComment:self.notReplyBtn.selected toView:self];
  1176. }
  1177. if([aDownload.action isEqualToString:act_MsgAdd]){
  1178. if (self.block) {
  1179. self.block();
  1180. }
  1181. [g_App showAlert:Localized(@"JXAlert_SendOK")];
  1182. [self hideKeyboard];
  1183. if (self.urlShare.length > 0) {
  1184. [self.view removeFromSuperview];
  1185. }else {
  1186. [self actionQuit];
  1187. }
  1188. }
  1189. [self dismissViewControllerAnimated:YES completion:NULL];
  1190. }
  1191. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  1192. [_wait stop];
  1193. if([aDownload.action isEqualToString:act_UploadFile]){
  1194. if (self.isVideoFirstUpload) {
  1195. self.isVideoFirstUpload = NO;
  1196. }
  1197. }
  1198. return show_error;
  1199. }
  1200. -(int) didServerConnectError:(JXConnection*)aDownload error:(NSError *)error{//error为空时,代表超时
  1201. [_wait stop];
  1202. if([aDownload.action isEqualToString:act_UploadFile]){
  1203. if (self.isVideoFirstUpload) {
  1204. self.isVideoFirstUpload = NO;
  1205. }
  1206. }
  1207. return show_error;
  1208. }
  1209. -(void) didServerConnectStart:(JXConnection*)aDownload{
  1210. [_wait start:Localized(@"JX_SendNow")];
  1211. }
  1212. - (void)lableBtnAction:(UIButton *)button {
  1213. JXSelectorVC *vc = [[JXSelectorVC alloc] init];
  1214. vc.title = Localized(@"JX_SelectionLabel");
  1215. vc.array = @[Localized(@"JX_Food"),Localized(@"JX_Attractions"),Localized(@"JX_Culture"),Localized(@"JX_HaveFun"),Localized(@"JX_Hotel"),Localized(@"JX_Shopping"),Localized(@"JX_Movement"),Localized(@"OTHER"),];
  1216. // vc.array = @[@"简体中文", @"繁體中文(香港)", @"English",@"Bahasa Melayu",@"ภาษาไทย"];
  1217. vc.selectIndex = _currentLableIndex;
  1218. vc.selectorDelegate = self;
  1219. // [g_window addSubview:vc.view];
  1220. [g_navigation pushViewController:vc animated:YES];
  1221. }
  1222. - (void)selector:(JXSelectorVC *)selector selectorAction:(NSInteger)selectIndex {
  1223. self.currentLableIndex = selectIndex;
  1224. self.lableLabel.text = selector.array[selectIndex];
  1225. }
  1226. -(void)locBtnAction:(UIButton *)button{
  1227. _locationVC = [JXLocationVC alloc];
  1228. _locationVC.isSend = YES;
  1229. _locationVC.locationType = JXLocationTypeCurrentLocation;
  1230. _locationVC.delegate = self;
  1231. _locationVC.didSelect = @selector(onSelLocation:);
  1232. _locationVC.isCircleCome = YES;
  1233. _locationVC = [_locationVC init];
  1234. // [g_window addSubview:_locationVC.view];
  1235. [g_navigation pushViewController:_locationVC animated:YES];
  1236. }
  1237. -(void)whoCanSeeBtnAction:(UIButton *)button{
  1238. WhoCanSeeViewController * whoVC = [[WhoCanSeeViewController alloc] init];
  1239. whoVC.visibelDelegate = self;
  1240. whoVC.type = _visible;
  1241. whoVC.selLabelsArray = self.selLabelsArray.count > 0 ? self.selLabelsArray : [NSMutableArray array];
  1242. whoVC.mailListUserArray = self.mailListUserArray.count > 0 ? self.mailListUserArray : [NSMutableArray array];
  1243. // [g_window addSubview:whoVC.view];
  1244. [g_navigation pushViewController:whoVC animated:YES];
  1245. }
  1246. -(void)remindWhoBtnAction:(UIButton *)button{
  1247. JXSelectFriendsVC * selVC = [[JXSelectFriendsVC alloc] init];
  1248. selVC.delegate = self;
  1249. selVC.didSelect = @selector(selRemindDelegate:);
  1250. if (_visible == MsgVisible_see) {
  1251. selVC.type = JXSelUserTypeCustomArray;
  1252. selVC.array = [_userArray mutableCopy];
  1253. }else if (_visible == MsgVisible_nonSee) {
  1254. selVC.type = JXSelUserTypeDisAble;
  1255. NSMutableSet * set = [NSMutableSet set];
  1256. [set addObjectsFromArray:_userIdArray];
  1257. selVC.disableSet = set;
  1258. }else {
  1259. selVC.type = JXSelUserTypeSelFriends;
  1260. NSMutableSet * set = [NSMutableSet set];
  1261. [set addObjectsFromArray:_remindArray];
  1262. selVC.existSet = set;
  1263. }
  1264. // [g_window addSubview:selVC.view];
  1265. [g_navigation pushViewController:selVC animated:YES];
  1266. }
  1267. - (void)clickReplyBanBtn {
  1268. // _checkbox.checked = !_checkbox.checked;
  1269. _notReplyBtn.selected = !_notReplyBtn.selected;
  1270. }
  1271. -(void)selRemindDelegate:(JXSelectFriendsVC*)vc{
  1272. NSArray * indexArr = [vc.set allObjects];
  1273. NSMutableArray * adduserArr = [NSMutableArray array];
  1274. NSMutableArray * userNameArr = [NSMutableArray array];
  1275. for (NSNumber * index in indexArr) {
  1276. JXUserObject * selUser;
  1277. if (vc.seekTextField.text.length > 0) {
  1278. selUser = vc.searchArray[[index intValue] % 100000-1];
  1279. }else{
  1280. selUser = [[vc.letterResultArr objectAtIndex:[index intValue] / 100000-1] objectAtIndex:[index intValue] % 100000-1];
  1281. }
  1282. [adduserArr addObject:selUser.userId];
  1283. [userNameArr addObject:selUser.userNickname];
  1284. }
  1285. _remindArray = [NSArray arrayWithArray:adduserArr];
  1286. _remindNameArray = [NSArray arrayWithArray:userNameArr];
  1287. if (_remindNameArray.count > 0) {
  1288. _remindLabel.text = [_remindNameArray componentsJoinedByString:@","];
  1289. }
  1290. }
  1291. -(void)seeVisibel:(int)visibel userArray:(NSArray *)userArray selLabelsArray:(NSMutableArray *)selLabelsArray mailListArray:(NSMutableArray *)mailListArray{
  1292. _visible = visibel+1;
  1293. _selLabelsArray = selLabelsArray;
  1294. _mailListUserArray = mailListArray;
  1295. _visibleLabel.text = _visibelArray[visibel];
  1296. if (_visible == 3 || _visible == 4) {
  1297. NSMutableArray * uArray = [NSMutableArray array];
  1298. NSMutableArray * userIdArray = [NSMutableArray array];
  1299. for (JXUserObject * selUser in userArray) {
  1300. JXUserObject *user = [[JXUserObject sharedInstance] getUserById:selUser.userId];
  1301. [uArray addObject:user];
  1302. [userIdArray addObject:selUser.userId];
  1303. }
  1304. _userIdArray = userIdArray;
  1305. _userArray = uArray;
  1306. }
  1307. switch (_visible) {
  1308. case 1:
  1309. case 3:
  1310. case 4:
  1311. _remindWhoBtn.enabled = YES;
  1312. _remindArray = [NSArray array];
  1313. _remindLabel.text = @"";
  1314. break;
  1315. case 2:
  1316. _remindWhoBtn.enabled = NO;
  1317. _remindArray = nil;
  1318. _remindLabel.text = @"";
  1319. break;
  1320. default:
  1321. break;
  1322. }
  1323. // if (visibel == 3 || visibel ==4) {
  1324. // NSMutableArray * nameArray = [NSMutableArray array];
  1325. // for (JXUserObject * selUser in userArray) {
  1326. // [nameArray addObject:selUser.userNickname];
  1327. // }
  1328. // if (nameArray.count > 0) {
  1329. // NSString * nameStr = [nameArray componentsJoinedByString:@","];
  1330. // _visibleLabel.text = nameStr;
  1331. // }
  1332. // }
  1333. // NSMutableArray * nameArray = [NSMutableArray array];
  1334. // for (JXUserObject * selUser in userArray) {
  1335. // [nameArray addObject:selUser.userNickname];
  1336. // }
  1337. }
  1338. #pragma mark - 点击发布调用的方法
  1339. -(void)actionSave{
  1340. [audioPlayer stop];
  1341. audioPlayer = nil;
  1342. [videoPlayer stop];
  1343. videoPlayer = nil;
  1344. [self hideKeyboard];
  1345. /**
  1346. 取消单独文字发送
  1347. */
  1348. // if(self.dataType == weibo_dataType_text){
  1349. // if ([_remark.text isEqualToString:Localized(@"addMsgVC_Mind")]||[_remark.text isEqual:@""]) {
  1350. // [g_App showAlert:Localized(@"JXAlert_InputSomething")];
  1351. // return;
  1352. // }
  1353. // [g_server addMessage:_remark.text type:dataType data:nil flag:3 visible:_visible lookArray:_userIdArray coor:_coor location:_locStr remindArray:_remindArray toView:self];
  1354. // }
  1355. // else
  1356. if(self.dataType == weibo_dataType_image) {
  1357. if (_images.count <=0 && _remark.text.length <= 0) {
  1358. [g_App showAlert:Localized(@"JXAlert_InputSomething")];
  1359. return;
  1360. }
  1361. else if(_images.count <= 0 && _remark.text.length > 0) {
  1362. if ([_remark.text isEqualToString:Localized(@"addMsgVC_Mind")]) {
  1363. [g_App showAlert:Localized(@"JXAlert_InputSomething")];
  1364. return;
  1365. }
  1366. NSString *str = [_remark.text stringByReplacingOccurrencesOfString:@" " withString:@""];
  1367. if (str.length <= 0) {
  1368. [g_App showAlert:@"请输入有效内容"];
  1369. return;
  1370. }
  1371. [g_server addMessage:_remark.text type:1 data:nil flag:3 visible:_visible lookArray:_userIdArray coor:_coor location:_locStr remindArray:_remindArray lable:nil isAllowComment:self.notReplyBtn.selected toView:self];
  1372. }else if(_images.count > 0){
  1373. if ([_remark.text isEqualToString:Localized(@"addMsgVC_Mind")]){
  1374. _remark.text = @"";
  1375. }
  1376. [g_server uploadFile:_images audio:audioFile video:videoFile file:fileFile type:self.dataType+1 validTime:@"-1" timeLen:_timeLen toView:self gifDic:self.gifDataDic];
  1377. }
  1378. }
  1379. else if (self.dataType == weibo_dataType_share) {
  1380. NSDictionary *dict = @{
  1381. @"sdkUrl" : self.shareUr,
  1382. @"sdkIcon" : self.shareIcon,
  1383. @"sdkTitle": self.shareTitle
  1384. };
  1385. [g_server addMessage:_remark.text type:dataType data:dict flag:3 visible:_visible lookArray:_userIdArray coor:_coor location:_locStr remindArray:_remindArray lable:nil isAllowComment:self.notReplyBtn.selected toView:self];
  1386. }
  1387. else{
  1388. if (_images.count <= 0 && audioFile.length <= 0 && videoFile.length <= 0 && fileFile.length <= 0) {
  1389. [g_App showAlert:Localized(@"JX_AddFile")];
  1390. return;
  1391. }
  1392. if ([_remark.text isEqualToString:Localized(@"addMsgVC_Mind")]){
  1393. _remark.text = @"";
  1394. }
  1395. [g_server uploadFile:_images audio:audioFile video:videoFile file:fileFile type:self.dataType+1 validTime:@"-1" timeLen:_timeLen toView:self gifDic:self.gifDataDic];
  1396. }
  1397. }
  1398. - (BOOL) hideKeyboard {
  1399. [_remark resignFirstResponder];
  1400. [self.view endEditing:YES];
  1401. return YES;
  1402. }
  1403. -(void)onAddVideo{
  1404. [self hideKeyboard];
  1405. JXActionSheetVC *actionVC = [[JXActionSheetVC alloc] initWithImages:@[] names:@[Localized(@"JXMyMediaVC_LoationMedia"),Localized(@"JX_RecordVideo")]];
  1406. actionVC.delegate = self;
  1407. actionVC.tag = 2457;
  1408. [self presentViewController:actionVC animated:NO completion:nil];
  1409. // AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
  1410. // if (authStatus == AVAuthorizationStatusRestricted || authStatus ==AVAuthorizationStatusDenied)
  1411. // {
  1412. // [g_server showMsg:Localized(@"JX_CanNotopenCenmar")];
  1413. // return;
  1414. // }
  1415. // if ([[JXMediaObject sharedInstance] fetch].count <= 0) {
  1416. //
  1417. // myMediaVC* vc = [[myMediaVC alloc]init];
  1418. // vc.delegate = self;
  1419. // vc.didSelect = @selector(onSelMedia:);
  1420. //// [g_window addSubview:vc.view];
  1421. // [g_navigation pushViewController:vc animated:YES];
  1422. // [vc onAddVideo];
  1423. // }else {
  1424. // myMediaVC* vc = [[myMediaVC alloc]init];
  1425. // vc.delegate = self;
  1426. // vc.didSelect = @selector(onSelMedia:);
  1427. //// [g_window addSubview:vc.view];
  1428. // [g_navigation pushViewController:vc animated:YES];
  1429. // }
  1430. // recordVideoViewController * videoRecordVC = [recordVideoViewController alloc];
  1431. // videoRecordVC.maxTime = 30;
  1432. // videoRecordVC.isReciprocal = NO;
  1433. // videoRecordVC.delegate = self;
  1434. // videoRecordVC.didRecord = @selector(newVideo:);
  1435. // [videoRecordVC init];
  1436. // [g_window addSubview:videoRecordVC.view];
  1437. }
  1438. #pragma mark - 发送视频
  1439. - (void)photosViewController:(UIViewController *)viewController media:(JXMediaObject *)media {
  1440. [_images removeAllObjects];
  1441. media.userId = g_server.myself.userId;
  1442. media.isVideo = [NSNumber numberWithBool:YES];
  1443. [media insert];
  1444. NSString* file = media.fileName;
  1445. UIImage *image = [FileInfo getFirstImageFromVideo:file];
  1446. videoFile = [file copy];
  1447. // file = [NSString stringWithFormat:@"%@.jpg",[file stringByDeletingPathExtension]];
  1448. // [_images addObject:[UIImage imageWithContentsOfFile:file]];
  1449. [_images addObject:image];
  1450. // double integer = [FileInfo getVideoTimeFromVideo:videoFile];
  1451. // NSInteger num = 0;
  1452. // double interval;
  1453. // if (integer < 16) {
  1454. // interval = integer/16;
  1455. // num = 15;
  1456. // }else if (integer >= 16 && integer <= 32){
  1457. // interval = 1;
  1458. // num = ceil(integer) - 1;
  1459. // }else{
  1460. // interval = integer/32;
  1461. // num = 31;
  1462. // }
  1463. //
  1464. // for (int i = 0; i< num; i++) {
  1465. // UIImage *image = [FileInfo getImagesFromVideo:videoFile withTimeInterval:interval*(i+1)];
  1466. // if (image) {
  1467. // [_images addObject:image];
  1468. // }
  1469. // }
  1470. JXSelectCoverVC *vc = [[JXSelectCoverVC alloc] initWithVideo:videoFile];
  1471. vc.delegate = self;
  1472. [g_navigation pushViewController:vc animated:YES];
  1473. [self showVideos];
  1474. }
  1475. - (void)touchAtlasButtonReturnCover:(UIImage *)img{
  1476. _iv.image = img;
  1477. [self saveImgCover:img];
  1478. }
  1479. - (void)selectImage:(UIImage *)img toView:(JXSelectCoverVC *)view{
  1480. _iv.image = img;
  1481. [self saveImgCover:img];
  1482. }
  1483. -(void)onSelMedia:(JXMediaObject*)p{
  1484. //
  1485. // p.userId = g_server.myself.userId;
  1486. // p.isVideo = [NSNumber numberWithBool:YES];
  1487. //// [p insert];
  1488. //
  1489. // NSString* file = p.fileName;
  1490. // videoFile = [file copy];
  1491. // file = [NSString stringWithFormat:@"%@.jpg",[file stringByDeletingPathExtension]];
  1492. // [_images addObject:[UIImage imageWithContentsOfFile:file]];
  1493. // [self showVideos];
  1494. //
  1495. }
  1496. -(void)onAddFile{
  1497. [self hideKeyboard];
  1498. JXMyFile* vc = [[JXMyFile alloc]init];
  1499. vc.delegate = self;
  1500. vc.didSelect = @selector(onSelFile:);
  1501. [g_navigation pushViewController:vc animated:YES];
  1502. }
  1503. -(void)onSelFile:(NSString*)file{
  1504. //发送文件,file仅仅包含文件在本地的地址
  1505. fileFile = [file copy];
  1506. // file = [NSString stringWithFormat:@"%@.jpg",[file stringByDeletingPathExtension]];
  1507. // [_images addObject:[UIImage imageWithContentsOfFile:file]];
  1508. [self showFiles];
  1509. }
  1510. -(void)onAddAudio{
  1511. [self hideKeyboard];
  1512. // recordAudioVC* vc = [[recordAudioVC alloc]init];
  1513. // vc.delegate = self;
  1514. // vc.didRecord = @selector(newAudio:);
  1515. // [g_window addSubview:vc.view];
  1516. // [self stopAllPlayer];
  1517. //跳转音频录制界面
  1518. JXAudioRecorderViewController * audioRecordVC = [[JXAudioRecorderViewController alloc] init];
  1519. audioRecordVC.delegate = self;
  1520. audioRecordVC.maxTime = 60;
  1521. // [g_window addSubview:audioRecordVC.view];
  1522. [g_navigation pushViewController:audioRecordVC animated:YES];
  1523. }
  1524. //音频录制返回
  1525. #pragma mark JXaudioRecorder delegate
  1526. -(void)JXaudioRecorderDidFinish:(NSString *)filePath TimeLen:(int)timenlen{
  1527. // _editingType = @"audio";
  1528. // _voiceTimeLen = timenlen;
  1529. //上传
  1530. // [_wait start:@"正在上传音频"];
  1531. // [g_server uploadFile:filePath toView:self];
  1532. // NSString* file = sender.outputFileName;
  1533. JXMediaObject* p = [[JXMediaObject alloc]init];
  1534. p.userId = g_server.myself.userId;
  1535. p.fileName = filePath;
  1536. p.isVideo = [NSNumber numberWithBool:NO];
  1537. p.timeLen = [NSNumber numberWithInt:timenlen];
  1538. // [p insert];
  1539. // [p release];
  1540. self.timeLen = timenlen;
  1541. audioFile = [filePath copy];
  1542. [self showAudios];
  1543. filePath = nil;
  1544. }
  1545. -(void)newVideo:(recordVideoViewController *)sender;
  1546. {
  1547. if( ![[NSFileManager defaultManager] fileExistsAtPath:sender.outputFileName] )
  1548. return;
  1549. NSString* file = sender.outputFileName;
  1550. JXMediaObject* p = [[JXMediaObject alloc]init];
  1551. p.userId = g_server.myself.userId;
  1552. p.fileName = file;
  1553. p.isVideo = [NSNumber numberWithBool:YES];
  1554. p.timeLen = [NSNumber numberWithInt:sender.timeLen];
  1555. // [p insert];
  1556. // [p release];
  1557. videoFile = [file copy];
  1558. file = [NSString stringWithFormat:@"%@.jpg",[file stringByDeletingPathExtension]];
  1559. [_images addObject:[UIImage imageWithContentsOfFile:file]];
  1560. [self showVideos];
  1561. file = nil;
  1562. }
  1563. -(void)onSelLocation:(JXMapData*)location{
  1564. _coor = (CLLocationCoordinate2D){[location.latitude doubleValue],[location.longitude doubleValue]};
  1565. if (location.title.length > 0) {
  1566. _locStr = [NSString stringWithFormat:@"%@ %@",location.title,location.subtitle];
  1567. }else{
  1568. _locStr = location.subtitle;
  1569. }
  1570. // _locLabel.text = _locStr;
  1571. [self.locBtn setTitle:_locStr forState:UIControlStateSelected];
  1572. self.locBtn.selected = YES;
  1573. }
  1574. //-(void)newAudio:(recordAudioVC *)sender
  1575. //{
  1576. // if( ![[NSFileManager defaultManager] fileExistsAtPath:sender.outputFileName] )
  1577. // return;
  1578. // NSString* file = sender.outputFileName;
  1579. //
  1580. // JXMediaObject* p = [[JXMediaObject alloc]init];
  1581. // p.userId = g_server.myself.userId;
  1582. // p.fileName = file;
  1583. // p.isVideo = [NSNumber numberWithBool:NO];
  1584. // p.timeLen = [NSNumber numberWithInt:sender.timeLen];
  1585. // [p insert];
  1586. //// [p release];
  1587. //
  1588. // audioFile = [file copy];
  1589. // [self showAudios];
  1590. // file = nil;
  1591. //}
  1592. -(UIButton*)createButton:(NSString*)title icon:(NSString*)icon action:(SEL)action parent:(UIView*)parent{
  1593. UIButton* btn = [UIFactory createButtonWithImage:icon
  1594. highlight:nil
  1595. target:self
  1596. selector:action];
  1597. btn.titleEdgeInsets = UIEdgeInsetsMake(45, -60, 0, 0);
  1598. [btn setTitle:title forState:UIControlStateNormal];
  1599. [btn setTitleColor:HEXCOLOR(0x999999) forState:UIControlStateNormal];
  1600. btn.titleLabel.font = g_factory.font10;
  1601. [parent addSubview:btn];
  1602. return btn;
  1603. }
  1604. -(void)onDelVideo{
  1605. videoFile = nil;
  1606. [self showVideos];
  1607. }
  1608. -(void)onDelAudio{
  1609. audioFile = nil;
  1610. [self showAudios];
  1611. }
  1612. -(void)actionQuit{
  1613. [super actionQuit];
  1614. if(self.delegate != nil && [self.delegate respondsToSelector:self.didSelect])
  1615. [self.delegate performSelectorOnMainThread:self.didSelect withObject:self waitUntilDone:NO];
  1616. }
  1617. @end