12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132 |
- //
- // WeiboViewControlle.m
- // wq
- //
- // Created by weqia on 13-8-28.
- // Copyright (c) 2013年 Weqia. All rights reserved.
- //
- #import "WeiboViewControlle.h"
- #import "WeiboCell.h"
- #import "ObjUrlData.h"
- #import "JSONKit.h"
- #import "LXActionSheet.h"
- #import "addMsgVC.h"
- #import "JXTextView.h"
- #import <MediaPlayer/MediaPlayer.h>
- #import "photosViewController.h"
- //#import "mvViewController.h"
- //#import "userInfoVC.h"
- #import "JXUserInfoVC.h"
- //#import "JXCell.h"
- #import "webpageVC.h"
- #import "JXBlogRemind.h"
- #import "JXTabMenuView.h"
- #import "JXBlogRemindVC.h"
- #import "JX_DownListView.h"
- #import "JXReportUserVC.h"
- #import "JXActionSheetVC.h"
- #import "JXMenuView.h"
- #import "ImageResize.h"
- #import "JXCameraVC.h"
- #import "HBHttpRequestCache.h"
- #define TopHeight 7
- #define CellHeight 45
- #define TopImageInset JX_SCREEN_WIDTH/5*1.8
- @interface WeiboViewControlle ()<UIAlertViewDelegate,JXActionSheetVCDelegate,JXSelectMenuViewDelegate,JXMenuViewDelegate,WeiboCellDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate,JXCameraVCDelegate>
- {
- BOOL _first;
- NSString * phoneNumber;
- UIWebView * webView;
-
- NSMutableArray * _images; //测试用
- NSMutableArray * _contents;
-
- UIImageView *_topBackImageView;
- }
- @property (nonatomic,copy)NSString *urlStr;
- @property (nonatomic, strong) JXMessageObject *remindMsg;
- @property (nonatomic, strong) NSMutableArray *remindArray;
- @property (nonatomic, strong) WeiboData *currentData;
- @property (nonatomic, strong) JXActionSheetVC *actionVC;
- @property (nonatomic, strong) WeiboCell *lastCell; // 用于点赞、评论控件, 记录上个cell
- //@property (nonatomic, strong) NSMutableArray *collectArray;
- @property (nonatomic, assign) BOOL isFirstGoin;
- @property (nonatomic, strong) NSString *topImageUrl;
- @property (nonatomic, assign) CGFloat lastOffsetY;
- @property (nonatomic, assign) CGFloat deltaY;
- @end
- @implementation WeiboViewControlle
- @synthesize replyDataTemp,selectWeiboData,deleteWeibo,refreshCount,refreshCellIndex,selectWeiboCell,user;
- - (id)init
- {
- self = [super init];
- if (self) {
- _pool = [[NSMutableArray alloc]init];
- refreshCellIndex = -1;
- //self.isGotoBack = NO;
- // self.title = Localized(@"WeiboViewControlle_MyFriend");
- self.title = Localized(@"JX_LifeCircle");
- self.heightFooter = 0;
- self.heightHeader = 0;
- if (self.isDetail) {
- self.heightHeader = JX_SCREEN_TOP;
- self.isGotoBack = YES;
- self.title = Localized(@"JX_Detail");
- }
-
- // _input.delegate = self;
- #ifdef IS_SHOW_MENU
- self.isGotoBack = YES;
-
- #endif
- //self.view.frame = CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT);
- [self createHeadAndFoot];
-
-
- if (!self.isDetail) {
- #ifdef IS_SHOW_MENU
- [self setupHeadView];
-
- #endif
- // [self buildAddMsg];
- }else {
- self.isShowFooterPull = NO;
- }
- [self buildInput];
- _first = YES;
- replyDataTemp = [[WeiboReplyData alloc]init];
- _datas=[[NSMutableArray alloc]init];
-
- [g_notify addObserver:self selector:@selector(doRefresh:) name:kUpdateUserNotifaction object:nil];
- [g_notify addObserver:self selector:@selector(urlTouch:) name:kCellTouchUrlNotifaction object:nil];
- [g_notify addObserver:self selector:@selector(phoneTouch:) name:kCellTouchPhoneNotifaction object:nil];
- [g_notify addObserver:self selector:@selector(remindNotif:) name:kXMPPMessageWeiboRemind object:nil];
- [g_notify addObserver:self selector:@selector(didEnterBackground:) name:kApplicationDidEnterBackground object:nil];
- _remindArray = [[JXBlogRemind sharedInstance] doFetchUnread];
- if (_remindArray.count > 0 && !self.isNotShowRemind) {
- [self createTableHeadShowRemind];
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- // [g_mainVC.tb setBadge:2 title:[NSString stringWithFormat:@"%ld",_remindArray.count]];
- int number = 0;
- if (g_App.linkArray.count == 0) {
- number = 2;
- }else if(g_App.linkArray.count == 1){
- number = 3;
- }else if(g_App.linkArray.count == 2){
- number = 100;
- }
- [g_mainVC.tb setBadge:number title:[NSString stringWithFormat:@"%ld",_remindArray.count]];
- });
-
- }else {
- [self createTableHeadShowRemind];
- }
- [self getWeiboBackImage];
- }
- return self;
- }
- - (void)setupHeadView {
- self.tableHeader = [[UIView alloc]initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_TOP)];
- self.tableHeader.backgroundColor = [UIColor whiteColor];
- [self.view addSubview:self.tableHeader];
-
- JXLabel* p = [[JXLabel alloc]initWithFrame:CGRectMake(40, JX_SCREEN_TOP - 32, self_width-40*2, 20)];
- p.backgroundColor = [UIColor clearColor];
- p.textAlignment = NSTextAlignmentCenter;
- p.textColor = [UIColor blackColor];
- p.text = self.title;
- p.font = [UIFont systemFontOfSize:18.0];
- p.userInteractionEnabled = YES;
- [self.tableHeader addSubview:p];
- if (self.isGotoBack) {
- self.gotoBackBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, JX_SCREEN_TOP - 46, 46, 46)];
- [self.gotoBackBtn setBackgroundImage:[UIImage imageNamed:@"title_back_black_big"] forState:UIControlStateNormal];
- [self.gotoBackBtn addTarget:self action:@selector(actionQuit) forControlEvents:UIControlEventTouchUpInside];
- [self.gotoBackBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- self.gotoBackBtn.titleLabel.font = [UIFont systemFontOfSize:15.0];
-
- [self.tableHeader addSubview:self.gotoBackBtn];
- }
- if (!self.isDetail && [self.user.userId isEqualToString:MY_USER_ID]) {
- UIButton* btn = [UIFactory createButtonWithImage:@"im_003_more_button_black"
- highlight:nil
- target:self
- selector:@selector(onAddMsg:)];
- btn.frame = CGRectMake(JX_SCREEN_WIDTH - 18-15*2, JX_SCREEN_TOP - 18-15*2, 18+15*2, 18+15*2);
- [self.tableHeader addSubview:btn];
- }
- }
- -(instancetype)initCollection{
- if (self = [super init]) {
- self.isCollection = YES;
- self.title = Localized(@"JX_MyCollection");
- self.isGotoBack = YES;
- self.heightHeader = JX_SCREEN_TOP;
- self.heightFooter = 0;
-
- self.datas = [NSMutableArray array];
- self.user = g_myself;
- [self createHeadAndFoot];
-
- [self createTableHeadShowRemind];
- self.footer.hidden = YES;
- [self getWeiboBackImage];
- }
- return self;
- }
- -(void)dealloc{
- [_pool removeAllObjects];
- [g_notify removeObserver:self name:kUpdateUserNotifaction object:nil];
- [g_notify removeObserver:self name:kCellTouchUrlNotifaction object:nil];
- [g_notify removeObserver:self name:kXMPPMessageWeiboRemind object:nil];
- [g_notify removeObserver:self name:kApplicationDidEnterBackground object:nil];
- // NSLog(@"WeiboViewControlle.dealloc");
- // [super dealloc];
- }
- - (void)getWeiboBackImage {
- [g_server getUser:user.userId toView:self];
- }
- - (void)viewDidAppear:(BOOL)animated
- {
- [super viewDidAppear:animated];
- [g_notify addObserver:self selector:@selector(changeKeyBoard:) name:UIKeyboardWillShowNotification object:nil];
- }
- - (void)viewDidDisappear:(BOOL)animated{
- [super viewDidDisappear:animated];
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
- [g_notify removeObserver:self name:UIKeyboardWillShowNotification object:nil];
- [[SDImageCache sharedImageCache] setValue:nil forKey:@"memCache"];
- [[HBHttpRequestCache shareCache] clearMemoryCache];
- }
- - (void)actionQuit {
- [self didEnterBackground:nil];
- [[SDImageCache sharedImageCache] setValue:nil forKey:@"memCache"];
- [super actionQuit];
- }
- - (void) remindNotif:(NSNotification *)notif {
- JXMessageObject *msg = notif.object;
- self.remindMsg = msg;
- _remindArray = [[JXBlogRemind sharedInstance] doFetchUnread];
- if (!self.isNotShowRemind) {
- [self createTableHeadShowRemind];
- }else {
- [self showTopImage];
- }
- [self getServerData];
- }
- // 进入后台
- - (void)didEnterBackground:(NSNotification *)notif {
- // 暂停语音播放
- for (NSInteger i = 0; i < _datas.count; i ++) {
- WeiboCell *cell = [_table cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];
- if (cell) {
- if (cell.audioPlayer != nil) {
- [cell.audioPlayer stop];
- }
- }
- }
- }
- -(void)getServerData{
- // [_wait start];
- if (self.isCollection) {
- [g_server userCollectionListWithType:0 pageIndex:0 toView:self];
- }else if (self.isDetail) {
- [g_server getMessage:self.detailMsgId toView:self];
- }else{
- [g_App.jxServer listMessage:0 messageId:[self getLastMessageId:_datas] toView:self];
- }
-
- }
- -(void)scrollToPageUp{
- // [self doHideKeyboard];
- [_wait start];
- [super scrollToPageUp];
- }
- #pragma mark ------------------数据成功返回----------------------
- -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
- [_wait stop];
- // [super stopLoading];
-
- if([aDownload.action isEqualToString:act_UploadFile]){
- JXUserObject *user = [[JXUserObject alloc] init];
- user.msgBackGroundUrl = [(NSDictionary *)[dict[@"images"] firstObject] objectForKey:@"oUrl"];
- [g_server updateUser:user toView:self];
- }
- if ([aDownload.action isEqualToString:act_UserUpdate]) {
- NSString *urlStr = [NSString stringWithFormat:@"%@",dict[@"msgBackGroundUrl"]];
- if (IsStringNull(urlStr)) {
- [g_server getHeadImageLarge:user.userId userName:user.userNickname imageView:_topBackImageView];
- }else {
- [g_server getImage:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] imageView:_topBackImageView];
- }
- }
- //添加新回复
- if([aDownload.action isEqualToString:act_CommentAdd]){
- [replyDataTemp setMatch];
-
- for (NSInteger i = 0; i < _datas.count; i ++) {
- WeiboData *data = _datas[i];
- if ([data.messageId isEqualToString:selectWeiboData.messageId]) {
- selectWeiboData = data;
- self.selectWeiboCell = [_table cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];
- break;
- }
- }
-
- if (selectWeiboData.replys.count >= 20) {
- selectWeiboData.replys = [NSMutableArray arrayWithArray:[selectWeiboData.replys subarrayWithRange:NSMakeRange(0, 19)]];
- }
- // 数据结构问题,需服务器改
- replyDataTemp.replyId = [dict objectForKey:@"resultObject"];
-
- [selectWeiboData.replys insertObject:replyDataTemp atIndex:0];
- selectWeiboData.page = 0;
- selectWeiboData.commentCount += 1;
- selectWeiboData.replyHeight=[selectWeiboData heightForReply];
-
- if ([selectWeiboData.replys count] != 0) {
- [self.selectWeiboCell refresh];
- }
-
- replyDataTemp = [[WeiboReplyData alloc]init];
- }
- if ([aDownload.action isEqualToString:act_CommentDel]){
- [replyDataTemp setMatch];
-
- [selectWeiboData.replys removeObjectAtIndex:self.deleteReply];
- selectWeiboData.page = 0;
- selectWeiboData.commentCount -= 1;
- selectWeiboData.replyHeight=[selectWeiboData heightForReply];
-
- [self.selectWeiboCell refresh];
-
- replyDataTemp = [[WeiboReplyData alloc]init];
- }
- if([aDownload.action isEqualToString:act_PraiseAdd]){
- [self doAddPraiseOK];
- }
- if([aDownload.action isEqualToString:act_PraiseDel]){
- [self doDelPraiseOK];
- }
- if([aDownload.action isEqualToString:act_GiftAdd]){
-
- }
- if([aDownload.action isEqualToString:act_userEmojiAdd]){
- WeiboData *data = _datas[self.lastCell.tag];
- data.isCollect = YES;
- [_datas replaceObjectAtIndex:self.lastCell.tag withObject:data];
- [_table reloadRow:(int)self.lastCell.tag section:0];
- [g_server showMsg:Localized(@"JX_CollectionSuccess") delay:1.3f];
- }
- if([aDownload.action isEqualToString:act_CommentList]){
- for(int i=0;i<[array1 count];i++){
- WeiboReplyData * reply=[[WeiboReplyData alloc]init];
- NSDictionary* dict = [array1 objectAtIndex:i];
- reply.type=1;
- reply.addHeight = 60;
- [reply getDataFromDict:dict];
- [reply setMatch];
- [self.selectWeiboData.replys addObject:reply];
- }
- [self.selectWeiboCell refresh];
- }
- if([aDownload.action isEqualToString:act_MsgDel]){
- [_datas removeObject:selectWeiboData];
- refreshCount++;
- [_table reloadData];
- }
- if([aDownload.action isEqualToString:act_MsgList] || [aDownload.action isEqualToString:act_MsgListUser] || [aDownload.action isEqualToString:act_MsgGet]){
- self.isShowFooterPull = [array1 count] >= jx_page_size;
- if(_page==0)
- [_datas removeAllObjects];
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- //数据莫名为空
- if(_datas != nil){
- NSMutableArray * tempData = [[NSMutableArray alloc] init];
- NSInteger displayNum = 12;
- if (array1.count > displayNum) {
- for (int i=0; i< displayNum; i++) {
- NSDictionary* row = [array1 objectAtIndex:i];
- WeiboData * weibo=[[WeiboData alloc]init];
- [weibo getDataFromDict:row];
- [tempData addObject:weibo];
- }
- if (tempData.count > 0){
- [_datas addObjectsFromArray:tempData];
- [self loadWeboData:_datas complete:nil formDb:NO];
- }else {
- if (dict) {
- WeiboData *data = [[WeiboData alloc] init];
- [data getDataFromDict:dict];
- [tempData addObject:data];
- [_datas addObjectsFromArray:tempData];
- [self loadWeboData:_datas complete:nil formDb:NO];
- }
- }
- [_table reloadData];
- [tempData removeAllObjects];
- dispatch_async(dispatch_get_global_queue(0, 0), ^{
- for (NSInteger i=displayNum; i<[array1 count]; i++) {
- NSDictionary* row = [array1 objectAtIndex:i];
- WeiboData * weibo=[[WeiboData alloc]init];
- [weibo getDataFromDict:row];
- [tempData addObject:weibo];
- }
- if (tempData.count > 0){
- [_datas addObjectsFromArray:tempData];
- [self loadWeboData:_datas complete:nil formDb:NO];
- }else {
- if (dict) {
- WeiboData *data = [[WeiboData alloc] init];
- [data getDataFromDict:dict];
- [tempData addObject:data];
- [_datas addObjectsFromArray:tempData];
- [self loadWeboData:_datas complete:nil formDb:NO];
- }
- }
- });
- }else{
- for (NSInteger i=0; i<[array1 count]; i++) {
- NSDictionary* row = [array1 objectAtIndex:i];
- WeiboData * weibo=[[WeiboData alloc]init];
- [weibo getDataFromDict:row];
- [tempData addObject:weibo];
- }
- if (tempData.count > 0){
- [_datas addObjectsFromArray:tempData];
- [self loadWeboData:_datas complete:nil formDb:NO];
- }else {
- if (dict) {
- WeiboData *data = [[WeiboData alloc] init];
- [data getDataFromDict:dict];
- [tempData addObject:data];
- [_datas addObjectsFromArray:tempData];
- [self loadWeboData:_datas complete:nil formDb:NO];
- }
- }
- [_table reloadData];
- }
- }
- // for (int i=0; i<[array1 count]; i++) {
- // NSDictionary* row = [array1 objectAtIndex:i];
- // WeiboData * weibo=[[WeiboData alloc]init];
- // [weibo getDataFromDict:row];
- // [tempData addObject:weibo];
- // }
- // if (tempData.count > 0){
- // [_datas addObjectsFromArray:tempData];
- // [self loadWeboData:_datas complete:nil formDb:NO];
- // }else {
- // if (dict) {
- // WeiboData *data = [[WeiboData alloc] init];
- // [data getDataFromDict:dict];
- // [tempData addObject:data];
- // [_datas addObjectsFromArray:tempData];
- // [self loadWeboData:_datas complete:nil formDb:NO];
- // }
- // }
- // }
- // [_table reloadData];
- }
- if ([aDownload.action isEqualToString:act_userCollectionList]) {
- if (_page ==0) {
- [_datas removeAllObjects];
- }
- NSMutableArray * tempData = [[NSMutableArray alloc] init];
- for (int i=0; i<[array1 count]; i++) {
- NSDictionary* row = [array1 objectAtIndex:i];
- NSString * msgStr = row[@"msg"];
- // NSDictionary * msgDict = [[[SBJsonParser alloc]init]objectWithString:msgStr];
- //
- // JXMessageObject *msg=[[JXMessageObject alloc] init];
- //// [msg fromDictionary:bodyDict];
- // [msg fromXmlDict:msgDict];
-
- int collectType = [row[@"type"] intValue];
- NSTimeInterval createTime = [row[@"createTime"] doubleValue];
- NSString * emojiId = row[@"emojiId"];
-
- NSString *url = row[@"url"];
- NSString *fileLength = row[@"fileLength"];
- NSString *fileName = row[@"fileName"];
- NSString *fileSize = row[@"fileSize"];
- NSString *collectContent = row[@"collectContent"];
- WeiboData * weibo=[[WeiboData alloc]init];
- weibo.createTime = createTime;
- weibo.objectId = emojiId;
- if (collectContent.length > 0) {
- weibo.content = collectContent;
- }
- // [weibo getDataFromDict:row];
- [self weiboData:weibo WithUrl:url msg:msgStr collectType:collectType fileLength:fileLength fileName:fileName fileSize:fileSize];
- [tempData addObject:weibo];
- }
- if (tempData.count > 0){
- [_datas addObjectsFromArray:tempData];
- [self loadWeboData:_datas complete:nil formDb:NO];
- }
- [_table reloadData];
-
- }
- if ([aDownload.action isEqualToString:act_WeiboDeleteCollect]) {
- [g_server showMsg:Localized(@"JX_weiboCancelCollect") delay:1.3f];
- WeiboData *data = _datas[self.lastCell.tag];
- data.isCollect = NO;
- [_datas replaceObjectAtIndex:self.lastCell.tag withObject:data];
- [_table reloadRow:(int)self.lastCell.tag section:0];
- }
- if ([aDownload.action isEqualToString:act_userEmojiDelete]) {
- [g_server showMsg:Localized(@"JXAlert_DeleteOK") delay:1.3f];
- NSIndexPath * indexPath = [_table indexPathForCell:selectWeiboCell];
- [_datas removeObject:selectWeiboData];
- // [_table deleteRow:(int)indexPath.row section:(int)indexPath.section];
- [_table reloadData];
- }
- if([aDownload.action isEqualToString:act_PhotoList]){
- if([array1 count]>0){
- [photosViewController showPhotos:array1];
- }else{
-
- }
- }
- if( [aDownload.action isEqualToString:act_UserGet] ){
- JXUserObject* p = [[JXUserObject alloc]init];
- [p getDataFromDict:dict];
- if (!self.isFirstGoin) {
- self.isFirstGoin = YES;
- _topImageUrl = p.msgBackGroundUrl;
- [self showTopImage];
- return;
- }
-
- JXUserInfoVC* vc = [JXUserInfoVC alloc];
- vc.user = p;
- vc.fromAddType = 6;
- vc = [vc init];
- // [g_window addSubview:vc.view];
- [g_navigation pushViewController:vc animated:YES];
- [_pool addObject:vc];
- // [p release];
- }
-
- if([aDownload.action isEqualToString:act_Report]){
- [_wait stop];
- [g_App showAlert:Localized(@"JXUserInfoVC_ReportSuccess")];
- }
- }
- -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
- [_wait hide];
- // [super stopLoading];
- return show_error;
- }
- -(int) didServerConnectError:(JXConnection*)aDownload error:(NSError *)error{//error为空时,代表超时
- [_wait hide];
- // [super stopLoading];
- return show_error;
- }
- -(void) didServerConnectStart:(JXConnection*)aDownload{
- // [_wait start];
- }
- -(void)weiboData:(WeiboData *)weiboData WithUrl:(NSString *)dataUrl msg:(NSString *)msg collectType:(int)collectType fileLength:(NSString *)fileLength fileName:(NSString *)fileName fileSize:(NSString *)fileSize{
- // weiboData.messageId = msg.messageId;
- weiboData.userId = MY_USER_ID;
- weiboData.userNickName = MY_USER_NAME;
-
- // weiboData.createTime = [[dict objectForKey:@"time"] longLongValue];
- // weiboData.deviceModel = [dict objectForKey:@"model"];
- // weiboData.location = [dict objectForKey:@"location"];
- // weiboData.flag = [[dict objectForKey:@"flag"] intValue];
- // weiboData.visible = [[dict objectForKey:@"visible"] intValue];
- // weiboData.isPraise = [[dict objectForKey:@"isPraise"] boolValue];
- // weiboData.isLoved = [[dict objectForKey:@"isLoved"] boolValue];
-
- // weiboData.loveCount = [[[dict objectForKey:@"count"] objectForKey:@"collect"] intValue];
- // weiboData.shareCount = [[[dict objectForKey:@"count"] objectForKey:@"share"] intValue];
- // weiboData.playCount = [[[dict objectForKey:@"count"] objectForKey:@"play"] intValue];
- // weiboData.forwardCount = [[[dict objectForKey:@"count"] objectForKey:@"forward"] intValue];
- // weiboData.praiseCount = [[[dict objectForKey:@"count"] objectForKey:@"praise"] intValue];
- // weiboData.commentCount = [[[dict objectForKey:@"count"] objectForKey:@"comment"] intValue];
- // weiboData.giftCount = [[[dict objectForKey:@"count"] objectForKey:@"money"] intValue];
- // weiboData.giftTotalPrice = [[[dict objectForKey:@"count"] objectForKey:@"total"] intValue];
-
- // weiboData.title = @"titletitle";
- // weiboData.type = [[[dict objectForKey:@"body"] objectForKey:@"type"] intValue];
-
- // self.audios = [[dict objectForKey:@"body"] objectForKey:@"audios"];
- // self.videos = [[dict objectForKey:@"body"] objectForKey:@"videos"];
- // weiboData.time = [[dict objectForKey:@"body"] objectForKey:@"time"];
- // weiboData.address = [[dict objectForKey:@"body"] objectForKey:@"address"];
- // weiboData.remark = [[dict objectForKey:@"body"] objectForKey:@"remark"];
-
- // NSDictionary* row = nil;
-
-
- // CollectTypeEmoji = 6,//表情
- // CollectTypeImage = 1,//图片
- // CollectTypeVideo = 2,//视频
- // CollectTypeFile = 3,//文件
- // CollectTypeVoice = 4,//语音
- // CollectTypeText = 5,//文本
-
-
- if (collectType == 1) {//图片
- weiboData.type = weibo_dataType_image;
- // weiboData.images = [NSMutableArray arrayWithObject:msg.content];
- NSArray *urlArr = [dataUrl componentsSeparatedByString:@","];
- for (int i = 0; i < urlArr.count; i++) {
- ObjUrlData * url=[[ObjUrlData alloc] init];
- url.url= urlArr[i];
- url.mime=@"image/pic";
- [weiboData.smalls addObject:url];
- [weiboData.larges addObject:url];
- [weiboData.images addObject:url];
- }
-
- }else if (collectType == 2) {//视频
- weiboData.type = weibo_dataType_video;
- ObjUrlData * url=[[ObjUrlData alloc] init];
- url.url= dataUrl;
- url.fileSize = fileSize;
- url.timeLen = @([fileLength intValue]);
- [weiboData.videos addObject:url];
- }else if (collectType == 3) {//文件
- weiboData.type = weibo_dataType_file;
- ObjUrlData * url=[[ObjUrlData alloc] init];
- url.url= msg;
- url.fileSize = fileSize;
- url.type = @"4";
- if (fileName.length > 0) {
- url.name = [fileName lastPathComponent];
- }else {
- url.name = [msg lastPathComponent];
- }
- [weiboData.files addObject:url];
- }else if (collectType == 4) {//语音
- weiboData.type = weibo_dataType_audio;
- ObjUrlData * url=[[ObjUrlData alloc] init];
- url.url= dataUrl;
- url.fileSize =fileSize;
- url.timeLen = @([fileLength intValue]);
- [weiboData.audios addObject:url];
- }else if (collectType == 5) {//文本
- weiboData.type = weibo_dataType_text;
- weiboData.content= msg;
- }else if (collectType == 6) {//表情
-
- }
- // NSArray* p = nil;
- // weiboData.images = [[dict objectForKey:@"body"] objectForKey:@"images"];
- //
- // for(int i=0;i<[p count];i++){
- // row = [p objectAtIndex:i];
- //
- // ObjUrlData * url=[[ObjUrlData alloc] init];
- // url.url= [row objectForKey:@"tUrl"];
- // url.mime=@"image/pic";
- // [smalls addObject:url];
- //
- // url =[[ObjUrlData alloc]init];
- // url.url= [row objectForKey:@"oUrl"];
- // url.mime=@"image/pic";
- // [larges addObject:url];
- // }
-
- // p = [[dict objectForKey:@"body"] objectForKey:@"audios"];
- // for(int i=0;i<[p count];i++){
- // row = [p objectAtIndex:i];
- //
- // ObjUrlData * url=[[ObjUrlData alloc] init];
- // url.url= [row objectForKey:@"oUrl"];
- // url.fileSize = [row objectForKey:@"size"];
- // url.timeLen = [row objectForKey:@"length"];
- // [audios addObject:url];
- // }
-
- // p = [[dict objectForKey:@"body"] objectForKey:@"videos"];
- // for(int i=0;i<[p count];i++){
- // row = [p objectAtIndex:i];
- //
- // ObjUrlData * url=[[ObjUrlData alloc] init];
- // url.url= [row objectForKey:@"oUrl"];
- // url.fileSize = [row objectForKey:@"size"];
- // url.timeLen = [row objectForKey:@"length"];
- // [videos addObject:url];
- // }
-
- if( ([weiboData.audios count]>0 || [weiboData.videos count]>0) && [weiboData.images count]<=0){//假如没图,则用头像代替
- ObjUrlData * url=[[ObjUrlData alloc]init];
- // url.url= @"http://www.feizl.com/upload2007/2013_02/130227014423722.jpg";
- url.url= [g_server getHeadImageOUrl:MY_USER_ID];
- url.mime=@"image/pic";
- [weiboData.smalls addObject:url];
- }
-
- // p = [dict objectForKey:@"praises"];
- // for(int i=0;i<[p count];i++){
- // WeiboReplyData * reply=[[WeiboReplyData alloc]init];
- // reply.type=reply_data_praise;
- // // reply.addHeight = self.minHeightForComment;
- // reply.messageId=self.messageId;
- // row = [p objectAtIndex:i];
- // [reply getDataFromDict:row];
- // [praises addObject:reply];
- // }
-
-
- // p = [dict objectForKey:@"gifts"];
- // for(int i=0;i<[p count];i++){
- // WeiboReplyData * reply=[[WeiboReplyData alloc]init];
- // reply.type=reply_data_gift;
- // // reply.addHeight = self.minHeightForComment;
- // reply.messageId=self.messageId;
- // row = [p objectAtIndex:i];
- // [reply getDataFromDict:row];
- // [gifts addObject:reply];
- // }
-
- // p = [dict objectForKey:@"comments"];
- // for(NSInteger i = p.count - 1; i >= 0; i--){
- // WeiboReplyData * reply=[[WeiboReplyData alloc]init];
- // reply.type=reply_data_comment;
- // reply.addHeight = self.minHeightForComment;
- // reply.messageId=self.messageId;
- // row = [p objectAtIndex:i];
- // [reply getDataFromDict:row];
- // [replys addObject:reply];
- // }
- }
- -(void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- if (!self.isDetail && !self.isCollection) {
- //使大头像显示不全,让下方不被tabbar遮挡
- _table.contentInset = UIEdgeInsetsMake(-TopImageInset + (THE_DEVICE_HAVE_HEAD ? -44 : -20), 0, 49, 0);
- }
- // _table.contentOffset = CGPointMake(0,JX_SCREEN_WIDTH/16.0*8.0);
- [UIApplication sharedApplication].statusBarHidden = NO;
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
- if (self.isCollection || self.isDetail) {
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
- }
- }
- - (void)viewDidLoad
- {
-
- [super viewDidLoad];
- [self scrollToPageUp];
- //监听键盘状态
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardWillHideNotification object:nil];
- }
- - (void)keyboardDidHide:(NSNotification *)notification
- {
- [self doHideKeyboard];
- }
- //- (void)textFieldDidEndEditing:(UITextField *)textField{
- // [self doHideKeyboard];
- //}
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- //#warning Potentially incomplete method implementation.
- // Return the number of sections.
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- //#warning Incomplete method implementation.
- // Return the number of rows in the section.
-
- return [_datas count];
- }
- #pragma mark - Table view --------代理-------- data source
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- // NSString *CellIdentifier = [NSString stringWithFormat:@"WeiboCell_%d_%ld",refreshCount,indexPath.row];
- NSString *CellIdentifier = nil;
- if (self.isCollection)
- CellIdentifier = [NSString stringWithFormat:@"collectionCell"];
- else
- CellIdentifier = [NSString stringWithFormat:@"WeiboCell"];
-
- WeiboCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if(cell==nil){
- cell = [WeiboCell alloc];
- cell = [cell initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
- }
- if (self.isSend) {
- cell.contentView.userInteractionEnabled = NO;
- }else {
- cell.contentView.userInteractionEnabled = YES;
- }
-
- WeiboData * weibo;
- if ([_datas count] > indexPath.row) {
- weibo=[_datas objectAtIndex:indexPath.row];
- }
- cell.delegate = self;
- cell.controller=self;
- cell.tableViewP = tableView;
- cell.tag = indexPath.row;
- cell.isPraise = weibo.isPraise;
- cell.isCollect = weibo.isCollect;
- cell.weibo = weibo;
- [cell setupData];
-
- float height=[self tableView:tableView heightForRowAtIndexPath:indexPath];
- UIView * view=[cell.contentView viewWithTag:1200];
- if(view==nil){
- UIView* line = [[UIView alloc]init];
- line.backgroundColor = THE_LINE_COLOR;
- line.frame=CGRectMake(0, height-LINE_WH, JX_SCREEN_WIDTH, LINE_WH);
- [cell.contentView addSubview:line];
- line.tag=1200;
- }else{
- view.frame=CGRectMake(0, height-LINE_WH, JX_SCREEN_WIDTH, LINE_WH);
- }
- if (self.isCollection) {
- cell.btnReply.hidden = YES;
- cell.btnLike.hidden = YES;
- cell.btnReport.hidden = YES;
- cell.btnCollection.hidden = YES;
- }
- if (self.isCollection || [weibo.userId isEqualToString:MY_USER_ID]) {
-
- cell.delBtn.hidden = NO;
- }else {
- cell.delBtn.hidden = YES;
- }
-
- if (self.isSend) {
- cell.delBtn.hidden = YES;
- }
-
- [self doAutoScroll:indexPath];
- return cell;
- }
- - (void)videoStartPlayer {
- [_videoPlayer switch];
- }
- - (void)weiboCell:(WeiboCell *)weiboCell clickVideoWithIndex:(NSInteger)index {
- self.videoIndex = index;
- _videoPlayer = [JXVideoPlayer alloc];
- _videoPlayer.videoFile = [[_datas objectAtIndex:index] getMediaURL];
- _videoPlayer.type = JXVideoTypeWeibo;
- _videoPlayer.didVideoPlayEnd = @selector(didVideoPlayEnd);
- _videoPlayer.isShowHide = YES;
- _videoPlayer.delegate = self;
- _videoPlayer = [_videoPlayer initWithParent:self.view];
- [self performSelector:@selector(videoStartPlayer) withObject:self afterDelay:0.2];
- }
- - (void)weiboCell:(WeiboCell *)weiboCell shareUrlActionWithUrl:(NSString *)url title:(NSString *)title {
- webpageVC *webVC = [webpageVC alloc];
- webVC.isGotoBack= YES;
- webVC.isSend = YES;
- webVC.title = title;
- webVC.url = url;
- webVC = [webVC init];
- [g_navigation.navigationView addSubview:webVC.view];
- // [g_navigation pushViewController:webVC animated:YES];
- }
- #pragma mark - Table view delegate
- -(void)doHideMenu{
- [self resignFirstResponder];
- UIMenuController *menuController = [UIMenuController sharedMenuController];
- [menuController setMenuVisible:NO];
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (self.menuView) {
- [self.menuView dismissBaseView];
- self.lastCell = nil;
- }
- [self doHideMenu];
- [self doHideKeyboard];
-
- if (self.isCollection) {
-
- if ([self.delegate respondsToSelector:@selector(weiboVC:didSelectWithData:)]) {
- WeiboData *data = _datas[indexPath.row];
- _currentData = data;
- [g_App showAlert:Localized(@"JXWantSendCollectionMessage") delegate:self tag:2457 onlyConfirm:NO];
- }
- }
-
- return;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
-
- //依据数据的多少修改cell的高度
- if ([_datas count] != 0 && [_datas count] > indexPath.row) {
- WeiboData * data=[_datas objectAtIndex:indexPath.row];
- // 评论点击打开更多时,replyHeight还是记录的之前的,这里更新下高度
- data.replyHeight = [data heightForReply];
- float n = [WeiboCell getHeightByContent:data];
-
- if (self.isCollection) {
- n -= 20;
- if (data.type == weibo_dataType_text) {
- n -= 10;
- }
- }
- return n+20;
- }
- return 0;
- }
- #pragma -mark 回调方法
- - (void)urlTouch:(NSNotification *)notification{
- self.actionVC = [[JXActionSheetVC alloc] initWithImages:@[] names:@[Localized(@"JXEmoji_OpenUrl")]];
- self.actionVC.delegate = self;
- self.actionVC.tag = 105;
- NSMutableString *str = notification.object;
- if ([str rangeOfString:@"http"].location == NSNotFound) {
- self.urlStr = [NSString stringWithFormat:@"http://%@",str];
- }else {
- self.urlStr = [str copy];
- }
- [g_App.window addSubview:self.actionVC.view];
- }
- - (void)phoneTouch:(NSNotification *)notification{
-
- self.actionVC = [[JXActionSheetVC alloc] initWithImages:@[] names:@[Localized(@"JXEmoji_CallPhone")]];
- self.actionVC.delegate = self;
- self.actionVC.tag = 102;
- phoneNumber=notification.object;
- [g_App.window addSubview:self.actionVC.view];
- }
- - (void)actionSheet:(JXActionSheetVC *)actionSheet didButtonWithIndex:(NSInteger)index {
- if (actionSheet.tag==105){
- if(0==index){
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-
- webpageVC *webVC = [webpageVC alloc];
- webVC.isGotoBack= YES;
- webVC.isSend = YES;
- webVC.title = Localized(@"JXEmoji_OpenUrl");
- webVC.url = self.urlStr;
- webVC = [webVC init];
- [g_navigation.navigationView addSubview:webVC.view];
- // [g_navigation pushViewController:webVC animated:YES];
- });
- }
- }else if (actionSheet.tag==102){
- if(0==index){
- NSString * string=[NSString stringWithFormat:@"tel:%@",phoneNumber];
- if(webView==nil)
- webView=[[UIWebView alloc]initWithFrame:self.view.bounds];
- [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:string]]];
- webView.hidden=YES;
- [self.view addSubview:webView];
- }
- }else if (actionSheet.tag == 111){
- if (index == 0) {
- UIImagePickerController *ipc = [[UIImagePickerController alloc] init];
- ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
- ipc.delegate = self;
- ipc.allowsEditing = YES;
- //选择图片模式
- ipc.modalPresentationStyle = UIModalPresentationCurrentContext;
- if (IS_PAD) {
- UIPopoverController *pop = [[UIPopoverController alloc] initWithContentViewController:ipc];
- [pop presentPopoverFromRect:CGRectMake((self.view.frame.size.width - 320) / 2, 0, 300, 300) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
- }else {
- [self presentViewController:ipc animated:YES completion:nil];
- }
-
- }else {
- JXCameraVC *vc = [JXCameraVC alloc];
- vc.cameraDelegate = self;
- vc.isPhoto = YES;
- vc = [vc init];
- [self presentViewController:vc animated:YES completion:nil];
- }
- }
- }
- -(void)coreLabel:(HBCoreLabel*)coreLabel linkClick:(NSString*)linkStr
- {
-
- }
- -(void)coreLabel:(HBCoreLabel *)coreLabel phoneClick:(NSString *)linkStr
- {
- self.actionVC = [[JXActionSheetVC alloc] initWithImages:@[] names:@[Localized(@"JXEmoji_CallPhone")]];
- self.actionVC.delegate = self;
- self.actionVC.tag = 102;
- phoneNumber=linkStr;
- [g_App.window addSubview:self.actionVC.view];
- }
- -(void)coreLabel:(HBCoreLabel *)coreLabel mobieClick:(NSString *)linkStr
- {
- self.actionVC = [[JXActionSheetVC alloc] initWithImages:@[] names:@[Localized(@"JXEmoji_CallPhone"),Localized(@"JX_SendMessage")]];
- self.actionVC.delegate = self;
- self.actionVC.tag = 103;
- phoneNumber=linkStr;
- [g_App.window addSubview:self.actionVC.view];
- }
- //-(void)footViewBeginLoad:(PageLoadFootView*)footView
- //{
- // // [self loadFromDb:NO];
- //}
- -(void)loadWeboData:(NSArray*)webos complete:(void(^)())complete formDb:(BOOL)fromDb
- {
- //用i循环遍历
- for(int i = 0 ; i < [webos count];i++){
- WeiboData * weibo = [webos objectAtIndex:i];
- weibo.match=nil;
- [weibo setMatch];
- weibo.uploadFailed=NO;
- weibo.linesLimit=YES;
- weibo.replyHeight=[weibo heightForReply];
- if (weibo.type == weibo_dataType_video) {
- ObjUrlData * obj =[weibo.smalls firstObject];
- UIImage *img = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:obj.url]]];
- if (img.size.height > img.size.width) {
- weibo.videoHeight = 200;
- }else {
- weibo.videoHeight = 150;
- }
- }else {
- weibo.imageHeight=[HBShowImageControl heightForFileStr:weibo.smalls];
- if (weibo.type == weibo_dataType_audio) {
- weibo.imageHeight = 30;
- }
- }
- if(weibo.type == weibo_dataType_file) weibo.fileHeight = 100;
- if (weibo.type == weibo_dataType_share) {
- weibo.shareHeight = 70;
- }
- }
- //需要在遍历时改变内容,所以弃用
- // for(WeiboData * weibo in webos){
- // weibo.match=nil;
- // [weibo setMatch];
- // weibo.uploadFailed=NO;
- // weibo.linesLimit=YES;
- // weibo.imageHeight=[HBShowImageControl heightForFileStr:weibo.smalls];
- // weibo.replyHeight=[weibo heightForReply];
- // }
- dispatch_async(dispatch_get_main_queue(), ^{
- refreshCount++;
- [self.tableView reloadData];
- if(complete){
- complete();
- }
- });
- }
- - (void)loadWeboData:(NSArray *) webos {
- [self loadWeboData:webos complete:nil formDb:NO];
- }
- #pragma mark ---------------发说说------------
- - (void)onAddMsg:(UIButton *)btn{
- if (self.menuView) {
- [self.menuView dismissBaseView];
- self.menuView = nil;
- }
- // //标题数组
- // NSMutableArray * titleArr = [[NSMutableArray alloc]initWithArray:@[Localized(@"JX_SendWord"),Localized(@"JX_SendImage"),Localized(@"JX_SendVoice"),Localized(@"JX_SendVideo"),Localized(@"JX_NewCommentAndPraise")]];
- JX_SelectMenuView *menuView = [[JX_SelectMenuView alloc] initWithTitle:@[
- // Localized(@"JX_SendWord"),
- Localized(@"JX_SendImage"),
- Localized(@"JX_SendVoice"),
- Localized(@"JX_SendVideo"),
- Localized(@"JX_SendFile"),
- Localized(@"JX_NewCommentAndPraise")]
- image:@[@"menu_add_msg",@"menu_add_voice",@"menu_add_video",@"menu_add_file",@"menu_add_reply"]
- cellHeight:45];
- menuView.delegate = self;
- [g_App.window addSubview:menuView];
-
- // UIWindow *window = [[UIApplication sharedApplication].delegate window];
- // CGRect moreFrame = [self.tableHeader convertRect:btn.frame toView:window];
- //
- // JX_DownListView * downListView = [[JX_DownListView alloc] initWithFrame:self.view.bounds];
- // downListView.listContents = titleArr;
- //
- // __weak typeof(self) weakSelf = self;
- // [downListView downlistPopOption:^(NSInteger index, NSString *content) {
- //
- // [weakSelf moreListActionWithIndex:index];
- //
- // } whichFrame:moreFrame animate:YES];
- // [downListView show];
- //
- //模糊背景
- // _bgBlackAlpha = [[UIView alloc]initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT)];
- // _bgBlackAlpha.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
- // [self.view addSubview:_bgBlackAlpha];
- //
- // //自定义View
- // _selectView = [JX_SelectMenuView creatViewWithCount:[titleArr count] title:titleArr point:CGPointMake(JX_SCREEN_WIDTH - JX_SCREEN_WIDTH/2 - 5, JX_SCREEN_TOP - 5) topHeight:TopHeight cellHeight:CellHeight];
- // _selectView.alpha = 0.0;
- // [_bgBlackAlpha addSubview:_selectView];
- // //动画
- // [UIView animateWithDuration:0.3 animations:^{
- // _selectView.alpha = 1;
- // }];
- }
- - (void)didMenuView:(JX_SelectMenuView *)MenuView WithIndex:(NSInteger)index {
- switch (index) {
- case 0:
- case 1:
- case 2:
- case 3:{
- addMsgVC* vc = [[addMsgVC alloc] init];
- //在发布信息后调用,并使其刷新
- vc.block = ^{
- [self scrollToPageUp];
- };
- vc.dataType = (int)index + 2;
- vc.delegate = self;
- vc.didSelect = @selector(hideKeyShowAlert);
- // [g_window addSubview:vc.view];
- [g_navigation pushViewController:vc animated:YES];
- vc.view.hidden = NO;
- }
- break;
- case 4:{
-
- JXBlogRemindVC *vc = [[JXBlogRemindVC alloc] init];
- vc.remindArray = self.remindArray;
- vc.isShowAll = YES;
- // [g_window addSubview:vc.view];
- [g_navigation pushViewController:vc animated:YES];
- }
- break;
- default:
- break;
- }
- }
- - (void) moreListActionWithIndex:(NSInteger)index {
-
- }
- - (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
- UITouch * touch = touches.anyObject;
- if (_selectView == nil) {
- return;
- }
- CGPoint location = [touch locationInView:_selectView];
- //不在选择范围内
- if (location.x < 0 || location.x > JX_SCREEN_WIDTH/2 || location.y < 7) {
- [self viewDisMissAction];
- return;
- }
- int num = (location.y - TopHeight)/CellHeight;
- if (num >= 0 && num < 4) {
- addMsgVC* vc = [[addMsgVC alloc] init];
- //在发布信息后调用,并使其刷新
- vc.block = ^{
- [self scrollToPageUp];
- };
- vc.dataType = num+1;
- vc.delegate = self;
- vc.didSelect = @selector(hideKeyShowAlert);
- // [g_window addSubview:vc.view];
- [g_navigation pushViewController:vc animated:YES];
- vc.view.hidden = NO;
- }
- if (num == 4) {
- JXBlogRemindVC *vc = [[JXBlogRemindVC alloc] init];
- vc.remindArray = self.remindArray;
- vc.isShowAll = YES;
- // [g_window addSubview:vc.view];
- [g_navigation pushViewController:vc animated:YES];
- }
-
- [self viewDisMissAction];
- }
- - (void)viewDisMissAction{
- [UIView animateWithDuration:0.4 animations:^{
- _bgBlackAlpha.alpha = 0.0;
- } completion:^(BOOL finished) {
- [_selectView removeFromSuperview];
- _selectView = nil;
- [_bgBlackAlpha removeFromSuperview];
- }];
- }
- //单独加在weiboview上,弃用
- - (void) hideKeyShowAlert
- {
- [self doHideKeyboard];
-
-
- }
- //- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
- //{
- // if (actionSheet.tag==102){
- // if(0==buttonIndex){
- // NSString * string=[NSString stringWithFormat:@"tel:%@",phoneNumber];
- // if(webView==nil)
- // webView=[[UIWebView alloc]initWithFrame:self.view.bounds];
- // [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:string]]];
- // webView.hidden=YES;
- // [self.view addSubview:webView];
- // }
- // }else if (actionSheet.tag==103){
- // if(0==buttonIndex){
- // NSString * string=[NSString stringWithFormat:@"tel:%@",phoneNumber];
- // if(webView==nil)
- // webView=[[UIWebView alloc]initWithFrame:self.view.bounds];
- // [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:string]]];
- // webView.hidden=YES;
- // [self.view addSubview:webView];
- // }else if(1==buttonIndex){
- //
- // }
- // }
- //}
- - (void)tableView:(UITableView *)tableView touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
- [self doHideMenu];
- [self doHideKeyboard];
- }
- - (void)tapHide:(UITapGestureRecognizer *)tap{
- [self doHideMenu];
- [self doHideKeyboard];
- }
- //创建回复keyBoard上的回复小黑条
- -(void)buildInput{
- self.clearBackGround = [[UIView alloc]initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT)];
-
- UITapGestureRecognizer * tapG = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapHide:)];
-
- [self.clearBackGround addGestureRecognizer:tapG];
-
- _inputParent = [[UIView alloc]initWithFrame:CGRectMake(0, 200, JX_SCREEN_WIDTH, 49)];
- _inputParent.backgroundColor = [UIColor whiteColor];
- [self.view addSubview:self.clearBackGround];
- [self.clearBackGround addSubview:_inputParent];
- // 配置自适应
- _inputParent.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin);
- self.clearBackGround.hidden = YES;
- _inputParent.opaque = YES;
- _inputParent.hidden = YES;
-
- _input=[[UITextView alloc]initWithFrame:CGRectMake(15, 8, JX_SCREEN_WIDTH -30 , 33)];
- // _input.target = self;
- _input.delegate = self;
- // _input.didTouch = @selector(onInputText:);
- _input.backgroundColor = [UIColor whiteColor];
- _input.layer.cornerRadius = 3.f;
- _input.layer.masksToBounds = YES;
- // _input.placeHolder = Localized(@"JXAlert_InputSomething");
-
-
- _input.autoresizingMask = UIViewAutoresizingFlexibleWidth;
- _input.scrollIndicatorInsets = UIEdgeInsetsMake(10.0f, 0.0f, 10.0f, 8.0f);
- _input.contentInset = UIEdgeInsetsZero;
- _input.scrollEnabled = YES;
- _input.scrollsToTop = NO;
- _input.userInteractionEnabled = YES;
- _input.font = [UIFont systemFontOfSize:16.0f];
- _input.textColor = [UIColor blackColor];
- _input.backgroundColor = [UIColor whiteColor];
- _input.keyboardAppearance = UIKeyboardAppearanceDefault;
- _input.keyboardType = UIKeyboardTypeDefault;
- _input.textAlignment = NSTextAlignmentLeft;
-
- //重要,扁平
- _input.backgroundColor = [UIColor clearColor];
- // self.layer.borderColor = [UIColor colorWithWhite:0.8f alpha:1.0f].CGColor;
- _input.layer.borderColor = [UIColor colorWithWhite:0.8f alpha:1.0f].CGColor;
- _input.layer.borderWidth = 0.65f;
- _input.layer.cornerRadius = 6.0f;
- _input.returnKeyType = UIReturnKeySend;
-
-
-
- [_inputParent addSubview:_input];
- }
- - (void)textViewDidChange:(UITextView *)textView {
-
- NSString* s = textView.text;
- unichar c = [s characterAtIndex:s.length-1];
- if (c == '\n'){
-
- s = [s substringToIndex:s.length-1];
- [self onInputText:s];
- // textView.hidden = YES;
- }
-
-
- static CGFloat maxHeight =66.0f;
- CGRect frame = textView.frame;
- CGSize constraintSize = CGSizeMake(frame.size.width, MAXFLOAT);
- CGSize size = [textView sizeThatFits:constraintSize];
-
- if (size.height >= maxHeight)
- {
- size.height = maxHeight;
- textView.scrollEnabled = YES; // 允许滚动
- }
- else
- {
- textView.scrollEnabled = NO; // 不允许滚动
- }
- if (textView.hidden) {
- size.height = 32 + 5.5;
- }
- textView.frame = CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, size.height);
- _inputParent.frame = CGRectMake(_inputParent.frame.origin.x, JX_SCREEN_HEIGHT + self.deltaY - (size.height + 16), _inputParent.frame.size.width, size.height + 16);
- }
- -(void)changeKeyBoard:(NSNotification *)aNotifacation
- {
- // return;
- //获取到键盘frame 变化之前的frame
- NSValue *keyboardBeginBounds=[[aNotifacation userInfo]objectForKey:UIKeyboardFrameBeginUserInfoKey];
- CGRect beginRect=[keyboardBeginBounds CGRectValue];
-
- //获取到键盘frame变化之后的frame
- NSValue *keyboardEndBounds=[[aNotifacation userInfo]objectForKey:UIKeyboardFrameEndUserInfoKey];
-
- CGRect endRect=[keyboardEndBounds CGRectValue];
-
- CGFloat deltaY=endRect.origin.y-beginRect.origin.y;
- //拿frame变化之后的origin.y-变化之前的origin.y,其差值(带正负号)就是我们self.view的y方向上的增量
- deltaY=-endRect.size.height;
- self.deltaY = deltaY;
- // NSLog(@"deltaY:%f",deltaY);
-
- [_table setFrame:CGRectMake(0, JX_SCREEN_HEIGHT+deltaY-_table.frame.size.height, _table.frame.size.width, _table.frame.size.height)];
- [_inputParent setFrame:CGRectMake(0, JX_SCREEN_HEIGHT+deltaY-_inputParent.frame.size.height, _inputParent.frame.size.width, _inputParent.frame.size.height)];
- }
- -(void)doHideKeyboard{
- [_input resignFirstResponder];
- _table.frame =CGRectMake(0,self.heightHeader,self_width,JX_SCREEN_HEIGHT-self.heightHeader-self.heightFooter);
- _inputParent.frame = CGRectMake(0,JX_SCREEN_HEIGHT-_inputParent.frame.size.height,_inputParent.frame.size.width,_inputParent.frame.size.height);
- _inputParent.hidden = YES;
- self.clearBackGround.hidden = YES;
- _input.frame = CGRectMake(_input.frame.origin.x, 8, _input.frame.size.width, _input.frame.size.height);
- }
- -(void)setupTableViewHeight:(CGFloat)height tag:(NSInteger)tag{
- _table.contentSize = CGSizeMake(_table.contentSize.width, _table.contentSize.height+height);
- [_table reloadRow:(int)tag section:0];
- }
- -(IBAction)deleteAction:(id)sender
- {
- UIAlertView * alert=[[UIAlertView alloc]initWithTitle:Localized(@"JX_DeleteShare")
- message:nil
- delegate:self
- cancelButtonTitle:Localized(@"JX_Cencal")
- otherButtonTitles:Localized(@"JX_Confirm"), nil];
- alert.tag=222;
- [alert show];
- }
- //发送回复
- -(void)onInputText:(NSString*)s{
- _input.text = nil;
- [self doHideKeyboard];
-
- replyDataTemp.messageId = selectWeiboData.messageId;
- replyDataTemp.body = s;
- replyDataTemp.userId = MY_USER_ID;
- replyDataTemp.userNickName = g_server.myself.userNickname;
-
- [g_App.jxServer addComment:replyDataTemp toView:self];
- }
- -(void)delBtnAction:(WeiboData *)cellData{
- selectWeiboData = cellData;
- NSUInteger index = [_datas indexOfObject:cellData];
- if (index != NSNotFound) {
- NSIndexPath * indexPath = [NSIndexPath indexPathForRow:index inSection:0];
- selectWeiboCell = [_table cellForRowAtIndexPath:indexPath];
- }
-
- // if (self.isCollection) {
- //
- // [g_server userEmojiDeleteWithId:selectWeiboData.objectId toView:self];
- // }else {
- [self deleteAction];
- // }
- }
- - (void)fileAction:(WeiboData *)cellData {
- ObjUrlData * obj= [cellData.files firstObject];
- webpageVC *webVC = [webpageVC alloc];
- webVC.isGotoBack= YES;
- webVC.isSend = YES;
- if (obj.name.length > 0) {
- webVC.titleString = obj.name;
- }else {
- webVC.titleString = [obj.url lastPathComponent];
- }
- webVC.url = obj.url;
- webVC = [webVC init];
- [g_navigation.navigationView addSubview:webVC.view];
- // [g_navigation pushViewController:webVC animated:YES];
- }
- //#pragma mark - 点赞、评论控件 delegate
- //- (void)didMenuView:(JXMenuView *)menuView WithButtonIndex:(NSInteger)index {
- // self.menuView = nil;
- // if (index == 0) {
- // if (!selectWeiboData.isPraise) {
- // [self praiseAddAction];
- // } else {
- // [self praiseDelAction];
- // }
- // }else if (index == 1) {
- // [self commentAction];
- // }else if (index == 2) {
- // if ([selectWeiboData.userId isEqualToString:MY_USER_ID]) {
- // [self deleteAction];
- // }else {
- // [self reportUserView];
- // }
- // }
- //}
- #pragma mark - 点赞、评论控件创建
- -(void)btnReplyAction:(UIButton *)sender WithCell:(WeiboCell *)cell {
- // if (self.menuView) {
- // [self.menuView dismissBaseView];
- // if (cell == _lastCell) {
- // self.lastCell = nil;
- // return;
- // }
- // }
- self.lastCell = cell;
- NSIndexPath * indexPath = [NSIndexPath indexPathForRow:cell.tag inSection:0];
- selectWeiboCell = [_table cellForRowAtIndexPath:indexPath];
- selectWeiboData = [_datas objectAtIndex:cell.tag];
-
- // BOOL isDelete = [selectWeiboData.userId isEqualToString:MY_USER_ID];
- // NSArray *strArr = @[selectWeiboData.isPraise ? Localized(@"JX_Cencal") : Localized(@"JX_Good"),Localized(@"JX_Comment"),isDelete ? Localized(@"JX_Delete") : Localized(@"JXUserInfoVC_Report")];
- // NSArray *imgArr = @[@"blog_giveLike",@"blog_comments",isDelete ? @"blog_delete" : @"blog_report"];
- //
- // CGPoint point = cell.replyContent.frame.origin;
- // CGFloat y = point.y-5;
- //
- //
- // self.menuView = [[JXMenuView alloc] initWithPoint:CGPointMake(0, y) Title:strArr Images:imgArr];
- // self.menuView.delegate = self;
- // [cell addSubview:self.menuView];
- NSInteger btnTag = sender.tag % 1000;
- if (btnTag == 1) { // 点赞
- if (!selectWeiboData.isPraise) {
- [self praiseAddAction];
- } else {
- [self praiseDelAction];
- }
- }else if(btnTag == 2) { // 评论
- if (cell.weibo.isAllowComment == 0) {
- [self commentAction];
- }else {
- [g_server showMsg:Localized(@"JX_NotComments") delay:.5];
- }
- }else if(btnTag == 3) { // 收藏
- [self collectionWeibo];
- }else{ // 举报
- [self reportUserView];
- }
-
-
- }
- - (void)collectionWeibo {
- NSMutableDictionary *dataDict = [[NSMutableDictionary alloc] init];
- WeiboData * weibo = [_datas objectAtIndex:self.lastCell.tag];
-
- if (weibo.isCollect) { // 如果已被收藏,则取消收藏
- [g_server userWeiboEmojiDeleteWithId:weibo.messageId toView:self];
- }else {
- ObjUrlData *data;
- NSString *msg;
- if (weibo.images.count > 0 || weibo.videos.count > 0) { // 图片或者视频都会进
- if (weibo.videos.count > 0) { // 如果是视频
- data = [weibo.videos firstObject];
- msg = data.url;
- weibo.type = 2;
- }else { // 只是图片
- NSMutableArray *imgArr = [NSMutableArray array];
- for (NSDictionary *dict in weibo.images) {
- NSString *imgUrl = [dict objectForKey:@"oUrl"];
- [imgArr addObject:imgUrl];
- }
- if (imgArr.count > 1) {
- msg = [imgArr componentsJoinedByString:@","];
- }else {
- msg = [imgArr firstObject];
- }
- weibo.type = 1;
- }
- }else if (weibo.audios.count > 0) {
- data = [weibo.audios firstObject];
- msg = data.url;
- weibo.type = 4;
- }else if (weibo.files.count > 0){
- data = [weibo.files firstObject];
- msg = data.url;
- weibo.type = 3;
- }else if (weibo.videos.count > 0){
- // 视频放在图片中做处理
- }else { // 纯文本
- weibo.type = 5;
- msg = weibo.content;
- }
- [dataDict setValue:msg forKey:@"msg"];
- [dataDict setValue:@(weibo.type) forKey:@"type"];
- [dataDict setValue:data.name forKey:@"fileName"];
- [dataDict setValue:data.fileSize forKey:@"fileSize"];
- [dataDict setValue:data.timeLen forKey:@"fileLength"];
- [dataDict setValue:weibo.content forKey:@"collectContent"];
- [dataDict setValue:weibo.messageId forKey:@"collectMsgId"];
- [dataDict setValue:@1 forKey:@"collectType"];
-
- NSMutableArray * emoji = [NSMutableArray array];
- [emoji addObject:dataDict];
- [g_server addFavoriteWithEmoji:emoji toView:self];
- }
- }
- -(void)reportUserView{
- JXReportUserVC * reportVC = [[JXReportUserVC alloc] init];
- reportVC.user = self.user;
- reportVC.delegate = self;
- [g_navigation pushViewController:reportVC animated:YES];
-
- }
- - (void)report:(JXUserObject *)reportUser reasonId:(NSNumber *)reasonId {
- [g_server reportUser:selectWeiboData.userId roomId:nil webUrl:nil reasonId:reasonId toView:self];
- }
- - (BOOL)canBecomeFirstResponder
- {
- return YES;
- }
- - (BOOL)canPerformAction:(SEL)action
- withSender:(id)sender
- {
- if (action == @selector(allCommentAction) ||
- action == @selector(commentAction) ||
- action == @selector(giftAction) ||
- action == @selector(forwardAction) ||
- action == @selector(deleteAction) ||
- (action == @selector(praiseAddAction) && !selectWeiboData.isPraise) ||
- (action == @selector(praiseDelAction) && selectWeiboData.isPraise) || action == @selector(reportUserView))
- return YES;
- else
- return NO;
- }
- -(void)delAndReplyAction
- {
-
- }
- -(void)allCommentAction{
-
- }
- -(void)doShowAddComment:(NSString*)s{
- // _input.placeHolder = s;
- self.clearBackGround.hidden = NO;
- _inputParent.hidden = NO;
- [_input becomeFirstResponder];
- }
- -(void)commentAction{
- replyDataTemp.toUserId = nil;
- replyDataTemp.toNickName = nil;
- [self doShowAddComment:nil];
- }
- -(void)praiseAddAction{
- if(!selectWeiboData.isPraise)
- [g_App.jxServer addPraise:selectWeiboData.messageId toView:self];
- }
- -(void)praiseDelAction{
- if(selectWeiboData.isPraise)
- [g_App.jxServer delPraise:selectWeiboData.messageId toView:self];
- }
- -(void)giftAction{
- return;
- // NSMutableArray* p = [[NSMutableArray alloc]init];
- // for(int i=0;i<2;i++){
- // NSMutableDictionary* dict = [[NSMutableDictionary alloc]init];
- // [dict setValue:[NSNumber numberWithInt:i+1] forKey:@"goodsId"];
- // [dict setValue:@"3" forKey:@"count"];
- // [p addObject:dict];
- // }
- // SBJsonWriter * OderJsonwriter = [SBJsonWriter new];
- // NSString * jsonString = [OderJsonwriter stringWithObject:p];
- // // [OderJsonwriter release];
- // // [p release];
- // [g_App.jxServer addGift:selectWeiboData.messageId gifts:jsonString toView:self];
- }
- -(void)forwardAction{
-
- }
- //删除说说
- -(void)deleteAction{
-
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:Localized(@"JX_IsDeletionConfirmed") message:nil delegate:self cancelButtonTitle:Localized(@"JX_Cencal") otherButtonTitles:Localized(@"JX_Confirm"), nil];
- [alert show];
- }
- - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
- if (buttonIndex == 1) {
-
- if (alertView.tag == 2457) {
- [self actionQuit];
- [UIView animateWithDuration:0.3 animations:^{
- [alertView dismissWithClickedButtonIndex:buttonIndex animated:NO];
- } completion:^(BOOL finished) {
- [self.delegate weiboVC:self didSelectWithData:_currentData];
- }];
- }else {
-
- NSInteger i = [_datas indexOfObject:selectWeiboData];
- WeiboCell *cell = [_table cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];
- if (cell.audioPlayer != nil) {
- [cell.audioPlayer stop];
- cell.audioPlayer = nil;
- }
-
- if (cell.videoPlayer != nil) {
- [cell.videoPlayer stop];
- cell.videoPlayer = nil;
- }
- if (self.isCollection) {
-
- [g_server userEmojiDeleteWithId:selectWeiboData.objectId toView:self];
- }else {
- [g_server delMessage:selectWeiboData.messageId toView:self];
- }
- }
-
- }
- }
- //顶部大头照
- -(void)createTableHeadShowRemind{
-
- if (self.isDetail || self.isCollection) {
- _table.tableHeaderView = nil;
- return;
- }
- // [g_mainVC.tb setBadge:2 title:[NSString stringWithFormat:@"%ld",_remindArray.count]];
- int number = 0;
- if (g_App.linkArray.count == 0) {
- number = 2;
- }else if(g_App.linkArray.count == 1){
- number = 3;
- }else if(g_App.linkArray.count == 2){
- number = 100;
- }
- [g_mainVC.tb setBadge:number title:[NSString stringWithFormat:@"%ld",_remindArray.count]];
-
- UIView* head = [[UIView alloc]initWithFrame:CGRectMake(0,0, JX_SCREEN_WIDTH,250+JX_SCREEN_TOP+TopImageInset + (THE_DEVICE_HAVE_HEAD ? 44 : 20))];
- head.backgroundColor = [UIColor whiteColor];
-
- //上方大头照
- JXImageView* iv = [[JXImageView alloc]initWithFrame:CGRectMake(0,0, JX_SCREEN_WIDTH,head.frame.size.height)];
- iv.delegate = self;
- iv.didTouch = @selector(actionPhotos);
- iv.changeAlpha = NO;
- iv.backgroundColor = [UIColor lightGrayColor];
- iv.clipsToBounds = YES;
- iv.contentMode = UIViewContentModeScaleAspectFill;
- _topBackImageView = iv;
- [self showTopImage];
- // [g_server getHeadImageLarge:user.userId imageView:iv];
- [head addSubview:iv];
-
- UIButton* backBtn = [UIFactory createButtonWithImage:@"blog_back"
- highlight:nil
- target:self
- selector:@selector(actionQuit)];
- backBtn.frame = CGRectMake(15, JX_SCREEN_TOP-7-30+TopImageInset, 30, 30);
- [head addSubview:backBtn];
-
- if (!self.isDetail && [self.user.userId isEqualToString:MY_USER_ID]) {
- UIButton* btn = [UIFactory createButtonWithImage:@"blog_add_msg"
- highlight:nil
- target:self
- selector:@selector(onAddMsg:)];
- btn.frame = CGRectMake(JX_SCREEN_WIDTH-15-30, JX_SCREEN_TOP-7-30+TopImageInset, 30, 30);
- [head addSubview:btn];
- }
-
- UIView *radianView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(head.frame)-47, JX_SCREEN_WIDTH, 47)];
- radianView.backgroundColor = [UIColor whiteColor];
- [head addSubview:radianView];
-
- [self setPartRoundWithView:radianView corners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadius:27];
-
- CGFloat btnWH = 38;
- // 语音
- CGFloat btnX = (JX_SCREEN_WIDTH-38*5)/6;
- CGFloat btnY = iv.frame.size.height-btnWH-15- radianView.frame.size.height;
-
- if (!self.isDetail && [self.user.userId isEqualToString:MY_USER_ID] && !self.isCollection) {
- UIButton *btn;
-
-
- btn = [[UIButton alloc] initWithFrame:CGRectMake(btnX, btnY, btnWH, btnWH)];
- [btn setTag:1];
- [btn setImage:[UIImage imageNamed:@"weibo_menu_btn_voice"] forState:UIControlStateNormal];
- [btn addTarget:self action:@selector(didMenuBtn:) forControlEvents:UIControlEventTouchUpInside];
- [head addSubview:btn];
-
- // 图文
- btn = [[UIButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(btn.frame)+btnX, btnY, btnWH, btnWH)];
- [btn setTag:0];
- [btn setImage:[UIImage imageNamed:@"weibo_menu_btn_image"] forState:UIControlStateNormal];
- [btn addTarget:self action:@selector(didMenuBtn:) forControlEvents:UIControlEventTouchUpInside];
- [head addSubview:btn];
- // 视频
- btn = [[UIButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(btn.frame)+btnX, btnY, btnWH, btnWH)];
- [btn setTag:2];
- [btn setImage:[UIImage imageNamed:@"weibo_menu_btn_video"] forState:UIControlStateNormal];
- [btn addTarget:self action:@selector(didMenuBtn:) forControlEvents:UIControlEventTouchUpInside];
- [head addSubview:btn];
- // 文件
- btn = [[UIButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(btn.frame)+btnX, btnY, btnWH, btnWH)];
- [btn setTag:3];
- [btn setImage:[UIImage imageNamed:@"weibo_menu_btn_file"] forState:UIControlStateNormal];
- [btn addTarget:self action:@selector(didMenuBtn:) forControlEvents:UIControlEventTouchUpInside];
- [head addSubview:btn];
- // 点赞/回复
- btn = [[UIButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(btn.frame)+btnX, btnY, btnWH, btnWH)];
- [btn setTag:4];
- [btn setImage:[UIImage imageNamed:@"weibo_menu_btn_like"] forState:UIControlStateNormal];
- [btn addTarget:self action:@selector(didMenuBtn:) forControlEvents:UIControlEventTouchUpInside];
- [head addSubview:btn];
- }
-
- UILabel *name = [[UILabel alloc] initWithFrame:CGRectMake(0, btnY-20-20, JX_SCREEN_WIDTH, 20)];
- name.textColor = [UIColor whiteColor];
- name.font = SYSFONT(20);
- name.text = self.user.userNickname;
- name.textAlignment = NSTextAlignmentCenter;
- [head addSubview:name];
-
- name.layer.shadowColor = [UIColor blackColor].CGColor;
- name.layer.shadowOpacity = 0.6;
- name.layer.shadowRadius = 1.0;
- name.clipsToBounds = NO;
-
-
- iv = [[JXImageView alloc]initWithFrame:CGRectMake((JX_SCREEN_WIDTH-79)/2,CGRectGetMinY(name.frame)-10-79, 79,79)];
- iv.layer.masksToBounds = YES;
- iv.layer.cornerRadius = iv.frame.size.width/2;
- iv.layer.borderWidth = 3.f;
- iv.layer.borderColor = [UIColor whiteColor].CGColor;
- iv.delegate = self;
- iv.didTouch = @selector(actionUser);
- [g_server getHeadImageSmall:user.userId userName:nil imageView:iv];
- [head addSubview:iv];
- if (self.remindArray.count) {
- head.frame = CGRectMake(head.frame.origin.x, head.frame.origin.y, head.frame.size.width, head.frame.size.height + 40-17+15);
- UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(radianView.frame)-17, 180, 40)];
- btn.backgroundColor = [UIColor colorWithWhite:.2 alpha:1];
- btn.center = CGPointMake(head.frame.size.width / 2, btn.center.y);
- btn.layer.cornerRadius = btn.frame.size.height/2;
- btn.layer.masksToBounds = YES;
- [btn addTarget:self action:@selector(remindBtnAction:) forControlEvents:UIControlEventTouchUpInside];
- [head addSubview:btn];
-
-
- UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 5, 30, 30)];
- JXBlogRemind *br = _remindArray.firstObject;
- [g_server getHeadImageLarge:br.fromUserId userName:br.fromUserName imageView:imageView];
- imageView.layer.cornerRadius = imageView.frame.size.height/2;
- imageView.layer.masksToBounds = YES;
- [btn addSubview:imageView];
-
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, btn.frame.size.width, btn.frame.size.height)];
- label.font = SYSFONT(14.0);
- label.backgroundColor = [UIColor clearColor];
- label.textColor = [UIColor whiteColor];
- label.textAlignment = NSTextAlignmentCenter;
- label.text = [NSString stringWithFormat:@"%ld%@",self.remindArray.count, Localized(@"JX_PieceNewMessage")];
- [btn addSubview:label];
-
-
- UIImageView *arrowImage = [[UIImageView alloc] initWithFrame:CGRectMake(btn.frame.size.width - 15-7, (40-13)/2, 7, 13)];
- arrowImage.image = [[UIImage imageNamed:@"new_icon_>"] imageWithTintColor:[UIColor blackColor]];
- [btn addSubview:arrowImage];
- }
-
- _table.tableHeaderView = head;
- }
- // 画圆角
- - (void)setPartRoundWithView:(UIView *)view corners:(UIRectCorner)corners cornerRadius:(float)cornerRadius {
- CAShapeLayer *shapeLayer = [CAShapeLayer layer];
- shapeLayer.path = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(cornerRadius, cornerRadius)].CGPath;
- view.layer.mask = shapeLayer;
- }
- - (void)didMenuBtn:(UIButton *)button {
- NSInteger index = button.tag;
- switch (index) {
- case 0:
- case 1:
- case 2:
- case 3:{
- addMsgVC* vc = [[addMsgVC alloc] init];
- //在发布信息后调用,并使其刷新
- vc.block = ^{
- [self scrollToPageUp];
- };
- vc.dataType = (int)index + 2;
- vc.delegate = self;
- vc.didSelect = @selector(hideKeyShowAlert);
- [g_navigation pushViewController:vc animated:YES];
- vc.view.hidden = NO;
- }
- break;
- case 4:{
-
- JXBlogRemindVC *vc = [[JXBlogRemindVC alloc] init];
- vc.remindArray = self.remindArray;
- vc.isShowAll = YES;
- [g_navigation pushViewController:vc animated:YES];
- }
- break;
- default:
- break;
- }
- }
- - (void)remindBtnAction:(UIButton *)btn {
- JXBlogRemindVC *vc = [[JXBlogRemindVC alloc] init];
- vc.remindArray = self.remindArray;
- // [g_window addSubview:vc.view];
- [g_navigation pushViewController:vc animated:YES];
-
- [[JXBlogRemind sharedInstance] updateUnread];
- _remindArray = [[JXBlogRemind sharedInstance] doFetchUnread];
- [self createTableHeadShowRemind];
- // [self showTopImage];
- }
- -(void)doRefresh:(NSNotification *)notifacation{
- [self createTableHeadShowRemind];
- [self getServerData];
- }
- -(void)actionUser{
- // _userVc = nil;
- // _userVc = [userInfoVC alloc];
- // _userVc.userId = self.user.userId;
- // [_userVc init];
- // [g_window addSubview:_userVc.view];
- // [g_server getUser:self.user.userId toView:self];
-
- JXUserInfoVC* vc = [JXUserInfoVC alloc];
- vc.userId = self.user.userId;
- vc.fromAddType = 6;
- vc = [vc init];
- [g_navigation pushViewController:vc animated:YES];
- [_pool addObject:vc];
- }
- -(NSString*)getLastMessageId:(NSArray*)objects{
- NSString* lastId = @"";
- if(_page > 0){
- NSInteger n = [objects count]-1;
- if(n>=0){
- WeiboData* p = [objects objectAtIndex:n];
- lastId = p.messageId;
- p = nil;
- }
- }
- return lastId;
- }
- -(void)doAddPraiseOK{
- BOOL b=YES;
- for(int i=0;i<[selectWeiboData.praises count];i++){
- WeiboReplyData* praise = [selectWeiboData.praises objectAtIndex:i];
- if([praise.userId intValue] == [g_server.myself.userId intValue]){
- b = NO;
- break;
- }
- }
-
- if(b){
- WeiboReplyData* praise = [[WeiboReplyData alloc]init];
- praise.userId = g_server.myself.userId;
- praise.userNickName = g_server.myself.userNickname;
- praise.type = reply_data_praise;
- [self.selectWeiboData.praises insertObject:praise atIndex:0];
- selectWeiboData.replyHeight=[selectWeiboData heightForReply];
- }
-
- selectWeiboData.praiseCount++;
- selectWeiboData.isPraise = YES;
- [self.selectWeiboCell refresh];
-
-
-
- // JXMessageObject *msg = [[JXMessageObject alloc] init];
- // msg.timeSend = [NSDate date];
- // msg.fromUserId = MY_USER_ID;
- // msg.fromUserName = g_server.myself.userNickname;
- // NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- // [dict setObject:selectWeiboData.messageId forKey:@"id"];
- // NSString *url;
- // int type;
- // if (selectWeiboData.images.count > 0) {
- // url = [selectWeiboData.images.firstObject objectForKey:@"oUrl"];
- // type = 1;
- // }
- // if (selectWeiboData.audios.count > 0) {
- // url = selectWeiboData.audios.firstObject;
- // type = 2;
- // }
- // if (selectWeiboData.videos.count > 0) {
- // url = selectWeiboData.videos.firstObject;
- // type = 3;
- // }
- //
- // [dict setObject:[NSNumber numberWithInt:type] forKey:@"type"];
- // if (url.length > 0) {
- //
- // [dict setObject:url forKey:@"url"];
- // }
- //
- // NSError *error;
- // NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict
- // options:NSJSONWritingPrettyPrinted // Pass 0 if you don't care about the readability of the generated string
- // error:&error];
- //
- // NSString *jsonString;
- // if (! jsonData)
- // {
- // NSLog(@"Got an error: %@", error);
- // }else
- // {
- // jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
- // }
- //
- // jsonString = [jsonString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; //去除掉首尾的空白字符和换行字符
- //
- // [jsonString stringByReplacingOccurrencesOfString:@"\n" withString:@""];
- //
- // msg.objectId = jsonString;
- // [g_xmpp sendMessage:msg roomName:nil];
-
- }
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
- if (self.isCollection || self.isDetail) {
- return;
- }
- CGFloat offsetY = scrollView.contentOffset.y;
- NSLog(@"------------------y = %f",offsetY);
- // if (y > 250+JX_SCREEN_TOP+TopImageInset + (THE_DEVICE_HAVE_HEAD ? 44 : 20)) {
- // [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
- // self.tableHeader.alpha = 1;
- // }else {
- // [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
- // self.tableHeader.alpha = 0;
- // }
-
- if (offsetY > 200) {
- // if (offsetY < _lastOffsetY) {
- [UIView animateWithDuration:.3f animations:^{
- self.tableHeader.transform = CGAffineTransformIdentity; //复位
- } completion:^(BOOL finished) {
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
- }];
- // }else {
- // [UIView animateWithDuration:.3f animations:^{
- // self.tableHeader.transform = CGAffineTransformMakeTranslation(0, -JX_SCREEN_TOP);
- // } completion:^(BOOL finished) {
- // [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
- // }];
- // }
- }else {
- [UIView animateWithDuration:.3f animations:^{
- self.tableHeader.transform = CGAffineTransformMakeTranslation(0, -JX_SCREEN_TOP);
- } completion:^(BOOL finished) {
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
- }];
- }
- _lastOffsetY = offsetY;
- }
- -(void)doDelPraiseOK{
- for(int i=0;i<[selectWeiboData.praises count];i++){
- WeiboReplyData* praise = [selectWeiboData.praises objectAtIndex:i];
- if([praise.userId intValue] == [g_server.myself.userId intValue]){
- [selectWeiboData.praises removeObjectAtIndex:i];
- break;
- }
- }
- selectWeiboData.praiseCount--;
- if(selectWeiboData.praiseCount<0)
- selectWeiboData.praiseCount=0;
- selectWeiboData.isPraise = NO;
- selectWeiboData.replyHeight=[selectWeiboData heightForReply];
- [self.selectWeiboCell refresh];
- }
- -(void)actionPhotos{
- if (![user.userId isEqualToString:MY_USER_ID]) {
- return;
- }
- JXActionSheetVC *actionVC = [[JXActionSheetVC alloc] initWithImages:@[] names:@[Localized(@"JX_ChoosePhoto"),Localized(@"JX_TakePhoto")]];
- actionVC.delegate = self;
- actionVC.tag = 111;
- [self presentViewController:actionVC animated:NO completion:nil];
- }
- -(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
- {
- [picker dismissViewControllerAnimated:YES completion:nil];
- }
- - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
- {
- UIImage *image = [ImageResize image:[info objectForKey:@"UIImagePickerControllerEditedImage"] fillSize:CGSizeMake(640, 640)];
-
- NSString* filePath = [FileInfo getUUIDFileName:@"jpg"];
- [g_server saveImageToFile:image file:filePath isOriginal:NO];
- [g_server uploadFile:filePath validTime:@"-1" messageId:nil toView:self];
- _topBackImageView.image = image;
- [picker dismissViewControllerAnimated:YES completion:nil];
- }
- - (void)cameraVC:(JXCameraVC *)vc didFinishWithImage:(UIImage *)image {
- UIImage *camImage = [ImageResize image:image fillSize:CGSizeMake(640, 640)];
-
- NSString* filePath = [FileInfo getUUIDFileName:@"jpg"];
- [g_server saveImageToFile:camImage file:filePath isOriginal:NO];
- [g_server uploadFile:filePath validTime:@"-1" messageId:nil toView:self];
-
- _topBackImageView.image = camImage;
- }
- // 滚动tableView 移除点赞、评论控件
- - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
- [self.menuView dismissBaseView];
- self.lastCell = nil;
- }
- - (void)showTopImage {
- if (IsStringNull(_topImageUrl)) {
- [g_server getHeadImageLarge:user.userId userName:user.userNickname imageView:_topBackImageView];
- }else {
- [g_server getImage:_topImageUrl imageView:_topBackImageView];
- }
- }
- @end
|