Advertisement
Guest User

Untitled

a guest
Sep 24th, 2015
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 151.43 KB | None | 0 0
  1. //
  2. // MainPageViewController.m
  3. // ijoomer
  4. //
  5. // Created by Tailored Solutions on 16/03/12.
  6. // Copyright 2013 Tailored Solutions. All rights reserved.
  7. //
  8.  
  9. #import "MainPageViewController.h"
  10. #import "LoginViewController.h"
  11. #import "RegisterViewController3_0.h"
  12. #import "UserDetailViewController.h"
  13. #import "Privacy.h"
  14. #import "ApplicationData.h"
  15. #import "User.h"
  16. #import "WriteMessageViewController.h"
  17. #import "FindFirstResponder.h"
  18. #import "FriendsViewController.h"
  19. #import "NotificationViewController.h"
  20. #import "Tab.h"
  21. #import "Jomsocial.h"
  22. #import "GroupDetailViewController.h"
  23. #import "JoomlaRegistration.h"
  24. #import "Core_joomer.h"
  25. #import "JomEventDetailViewController.h"
  26. #import "GlobalObjects.h"
  27. #import "Wall.h"
  28. #import "WallCell.h"
  29. #import "Video.h"
  30. #import "Image.h"
  31. #import "CommentViewController.h"
  32. #import "AlbumsViewController.h"
  33. #import "VideoViewController.h"
  34. #import "iJoomerAppDelegate.h"
  35. #import "MessageViewController.h"
  36. #import "PhotoDetailViewController.h"
  37. #import "VideoCommentViewController.h"
  38. #import "GPSLocationListner.h"
  39. #import "JomEditEventViewController.h"
  40. #import <AVFoundation/AVFoundation.h>
  41. #import <MediaPlayer/MediaPlayer.h>
  42. #import "GroupDetailViewController3_0.h"
  43. #import "JomEventDetailViewController3_0.h"
  44. #import "MoreUserSettings.h"
  45. #import <QuartzCore/QuartzCore.h>
  46.  
  47. static NSString *kCellIdentifier = @"WallCell";
  48.  
  49. @interface MainPageViewController()
  50. /*
  51. #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
  52. -(void)layoutForCurrentOrientation:(BOOL)animated;
  53. -(void)createADBannerView;
  54. #endif
  55. */
  56. @end
  57.  
  58. @implementation MainPageViewController
  59.  
  60. @synthesize userDetail;
  61. @synthesize imageDownloadsInProgress;
  62. @synthesize name;
  63. //@synthesize statusMsg;
  64. @synthesize profileCount;
  65. @synthesize userImg;
  66. @synthesize isMainUserProfileView;
  67. @synthesize spinner;
  68. @synthesize commentRecord;
  69. @synthesize btnsend;
  70. @synthesize btnPlay,btnReport,lblSecond;
  71. @synthesize txtStatus;
  72. @synthesize btnwtsonurmind;
  73.  
  74. //for photo caption
  75. @synthesize btnPhotocaption;
  76. @synthesize txtPhotoCaption;
  77. @synthesize btnPhotocaptionSend;
  78.  
  79.  
  80. #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
  81. @synthesize contentView, banner;
  82. @synthesize bannerIsVisible;
  83. #endif
  84.  
  85. #pragma mark -
  86. #pragma mark viewDidLoad & viewWillAppear
  87.  
  88. - (id)init {
  89. self = [super init];
  90. if(self) {
  91. self.tabBarItem.image = [UIImage imageNamed:@"profile.png"];
  92. }
  93. return self;
  94. }
  95.  
  96. - (void)viewDidLoad {
  97.  
  98. [super viewDidLoad];
  99. [btnUserFriends setTitle:NSLocalizedString(@"Friends_title",@"") forState:UIControlStateNormal];
  100. [btnUserPhotos setTitle:NSLocalizedString(@"Photo_title",@"") forState:UIControlStateNormal];
  101. [btnUserVideos setTitle:NSLocalizedString(@"video_title",@"") forState:UIControlStateNormal];
  102. [btnUserAbout setTitle:NSLocalizedString(@"button_aboutmeb",@"") forState:UIControlStateNormal];
  103. lblAbout.text = NSLocalizedString(@"about_title",@"");
  104. lblMap.text = NSLocalizedString(@"button_map",@"");
  105. lblRecentTitle.text = NSLocalizedString(@"ractivity_title",@"");
  106. [btnWritePost setTitle:NSLocalizedString(@"writepost_title",@"") forState:UIControlStateNormal];
  107. [btnPhotos setTitle:NSLocalizedString(@"Photo_title",@"") forState:UIControlStateNormal];
  108. [btnVideos setTitle:NSLocalizedString(@"video_title",@"") forState:UIControlStateNormal];
  109. [btnEvents setTitle:NSLocalizedString(@"Event_title" ,@"")forState:UIControlStateNormal];
  110. [btnPhotocaptionSend setTitle:NSLocalizedString(@"button_send",@"") forState:UIControlStateNormal];
  111. [btnMessage setTitle:NSLocalizedString(@"Message",@"") forState:UIControlStateNormal];
  112. [btnfriend setTitle:NSLocalizedString(@"addFriend",@"") forState:UIControlStateNormal];
  113. [btnsend setTitle:NSLocalizedString(@"button_send",@"") forState:UIControlStateNormal];
  114. [btnPhotocaptionSend setTitle:NSLocalizedString(@"button_send",@"") forState:UIControlStateNormal];
  115. [btnWritePost setTitle:NSLocalizedString(@"button_writepostm",@"") forState:UIControlStateNormal];
  116. [btnmessage setTitle:NSLocalizedString(@"button_profmess",@"") forState:UIControlStateNormal];
  117. lblRecentTitle.text = NSLocalizedString(@"button_RecentActivities",@"");
  118. lblAbout.text = NSLocalizedString(@"button_aboutmeb",@"");
  119. lblMap.hidden = YES;
  120. btnMap.hidden = YES;
  121. btnUnlikeStupid.hidden = YES;
  122. btnDislike.hidden = YES;
  123. lblDislikeCount.hidden = YES;
  124. btnUnlike.hidden = YES;
  125. btnLikePr.hidden = YES;
  126.  
  127.  
  128.  
  129. voiceoverView.frame = CGRectMake(voiceoverView.frame.origin.x, voiceoverView.frame.origin.y + 50, voiceoverView.frame.size.width, voiceoverView.frame.size.height);
  130.  
  131. newWall = [[Wall alloc]init];
  132. [[NSNotificationCenter defaultCenter] addObserver:self
  133. selector:@selector(movieFinished:)
  134. name:MPMoviePlayerPlaybackDidFinishNotification
  135. object:mp];
  136.  
  137. multipleDownloadRecord = [[NSMutableDictionary alloc] init];
  138. pageNo = 1;
  139. self->pullTable = tableView;
  140. [self addPullToRefreshHeader];
  141. tableView.tableHeaderView = headerView;
  142. cellOwner = [[TableCellOwner alloc]init];
  143. notifView.hidden = YES;
  144. permissionValue = 0;
  145. permissions = [[NSArray arrayWithObjects:NSLocalizedString(@"Public_title",@""),NSLocalizedString(@"sitemember_title",@""),NSLocalizedString(@"friends_title",@""),NSLocalizedString(@"onlyme_title",@""), nil] retain];
  146. scrollMenu.delegate = self;
  147. scrollMenu.hidden = YES;
  148. scrollMenu.contentSize = CGSizeMake(384, 78);
  149. NSDate *date = [[NSDate alloc]init];
  150. NSDateFormatter *format = [[NSDateFormatter alloc] init];
  151. [format setDateFormat:@"a"];
  152. NSString *str = [format stringFromDate:date];
  153. btnCancel = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"button_cancel", @"") style:UIBarButtonItemStylePlain target:self action:@selector(cancelButtonPressed:)];
  154. btnDone = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"button_done", @"") style:UIBarButtonItemStyleDone target:self action:@selector(doneButtonPressed:)];
  155.  
  156. // btnLogout = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"button_logout", @"") style:UIBarButtonItemStylePlain target:self action:@selector(logoutButtonPressed:)];
  157. //lblRecentTitle.textColor = [ApplicationData sharedInstance].textcolor;
  158. btnEdit.hidden = YES;
  159. //[btnEdit setBackgroundColor: palletePurple];
  160. [btnEdit setTitle:NSLocalizedString(@"button_edit", @"") forState:UIControlStateNormal];
  161. btnEdit.layer.cornerRadius = 3;
  162. if(!userDetail || ([ApplicationData sharedInstance].isLoggedIn && !userDetail.isFriend && userDetail.userId == 0))
  163. {
  164. btnEdit.hidden = NO;
  165. self.navigationItem.leftBarButtonItem = nil;
  166.  
  167. isMainUserProfileView = YES;
  168. if ([[ApplicationData sharedInstance].tabList count] > 0 && USE_SERVER_TABS)
  169. {
  170. dataForTable = [ApplicationData sharedInstance].profilemenuList;
  171. }
  172. else
  173. {
  174. NSDictionary *plistDict = [[NSDictionary alloc] initWithContentsOfFile:[[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"Data.plist"]];
  175. dataForTable = [plistDict objectForKey:@"profilemenu"];
  176. cellImageNames = [ApplicationData sharedInstance].profileMenuImages;
  177. }
  178. } else
  179. {
  180. [self performSelectorOnMainThread:@selector(profileRequest) withObject:nil waitUntilDone:YES];
  181.  
  182.  
  183. if ([[ApplicationData sharedInstance].tabList count] > 0 && USE_SERVER_TABS)
  184. {
  185. dataForTable = [ApplicationData sharedInstance].friendmenuList;
  186. }
  187. else
  188. {
  189. NSDictionary *plistDict = [[NSDictionary alloc] initWithContentsOfFile:[[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"Data.plist"]];
  190. dataForTable = [plistDict objectForKey:@"friendmenu"];
  191. cellImageNames = [ApplicationData sharedInstance].friendMenuImages;
  192. }
  193. }
  194.  
  195. [lbl_profileCount setText:NSLocalizedString(@"lblProfileCount", @"")];
  196. [changeImg setTitle:NSLocalizedString(@"button_edit", @"") forState:UIControlStateNormal];
  197.  
  198. self.imageDownloadsInProgress = [NSMutableDictionary dictionary];
  199.  
  200. backImg.image = [UIImage imageNamed:[ApplicationData sharedInstance].bgImage];
  201.  
  202. tableView.backgroundColor = [UIColor clearColor];
  203. name.delegate = self;
  204.  
  205. UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"button_back",@"") style:UIBarButtonItemStyleBordered target:nil action:nil];
  206. self.navigationItem.backBarButtonItem = backButton;
  207. [backButton release];
  208.  
  209. myWebview.hidden = YES;
  210. myWebview.delegate = self;
  211. }
  212.  
  213.  
  214. - (void)viewWillAppear:(BOOL)animated {
  215. isViewWillDisAapear = NO;
  216. [super viewWillAppear:animated];
  217. name.userInteractionEnabled = NO;
  218. self.title = @"";
  219. iJoomerAppDelegate *appdelegate = (iJoomerAppDelegate *) [[UIApplication sharedApplication] delegate];
  220. appdelegate.viewTop.hidden = NO;
  221. appdelegate.TabView.hidden = YES;
  222. //tablist
  223. //##########################################################################################################
  224. NSMutableArray *arr = [[NSMutableArray alloc] init];
  225. arr = [appdelegate fetchTabList:@"JomProfile"];
  226. if ([arr count] == 0 || [[ApplicationData sharedInstance].tabList count] == 0) {
  227. isTabbarHidden = YES;
  228. }
  229. else {
  230. isTabbarHidden = NO;
  231. }
  232. arr = [appdelegate fetchsidemenuList:@"JomProfile"];
  233. appdelegate.viewTop.hidden = NO;
  234. appdelegate.SelfViewcontroller = self;
  235. [appdelegate TabReset];
  236.  
  237. ///////////////////////////////////Voiceover Start//////////////////////
  238.  
  239. Voiceover.MainPageController = self;
  240. [Voiceover intialize];
  241.  
  242. VoiceoverPhotoCaption.MainPageController = self;
  243. [VoiceoverPhotoCaption intialize];
  244.  
  245. if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
  246. CGSize result = [[UIScreen mainScreen] bounds].size;
  247. if(result.height == 480) {
  248. if (isTabbarHidden == YES) {
  249. tableView.frame = CGRectMake(0, 0, 320, 415 -30);
  250.  
  251. }
  252. else {
  253. tableView.frame = CGRectMake(0, 0, 320, 365 -30);
  254.  
  255. }
  256. }
  257.  
  258. else if(result.height == 568) {
  259. if (isTabbarHidden == YES) {
  260. tableView.frame = CGRectMake(0, 0, 320, 500 -30);
  261.  
  262. }
  263. else {
  264. tableView.frame = CGRectMake(0, 0, 320, 455 -30);
  265.  
  266. } // iPhone 5
  267. }
  268. }
  269. [btnwtsonurmind setTitle:NSLocalizedString(@"Whats_on_Mind", @"") forState:UIControlStateNormal];
  270. ///////////////////////////////////Voiceover End//////////////////////
  271. [spinner startAnimating];
  272. // if(userDetail) {
  273. // name.text = @"";
  274. // userImg.image = [UIImage imageNamed:@""];
  275. //
  276. // }
  277.  
  278. permissionValue = 0;
  279. [btnPermission setBackgroundImage:[UIImage imageNamed:[ApplicationData sharedInstance].selButton] forState:UIControlStateNormal];
  280. [btnPermission setTitle:[NSString stringWithFormat:@" %@",[permissions objectAtIndex:0]] forState:UIControlStateNormal];
  281.  
  282. //for photo caption
  283. if (photoSelectIndex == 888) {
  284. imgPhotoPrev.hidden = NO;
  285. VoiceoverPhotoCaption.btnSpeakAndHold.hidden = YES;
  286. VoiceoverPhotoCaption.imgRecord.hidden = YES;
  287. imgPhotoBackPrev.hidden = NO;
  288. VoiceoverPhotoCaption.hidden = NO;
  289. Voiceover.hidden = YES;
  290.  
  291. }else if (photoSelectIndex == 999){
  292. imgPhotoPrev.hidden = YES;
  293. imgPhotoBackPrev.hidden = YES;
  294.  
  295. VoiceoverPhotoCaption.hidden = NO;
  296. Voiceover.hidden = YES;
  297. }else{
  298. imgPhotoPrev.hidden = YES;
  299. imgPhotoBackPrev.hidden = YES;
  300. VoiceoverPhotoCaption.hidden = NO;
  301. Voiceover.hidden = YES;
  302. }
  303.  
  304. [btnPhotocaption setTitle:NSLocalizedString(@"photo_caption", @"") forState:UIControlStateNormal];
  305.  
  306.  
  307.  
  308. #pragma mark
  309. #pragma mark Case for Showing and not showing CoverPhoto, Event, Photo and Video
  310. /* "extentionconfig":{"jomsocial":{"createEvent":0,"createGroup":0,"isVideoUpload":0,"videoUploadSize":1024,"isPhotoUpload":0,"PhotoUploadSize":1024,"isEnableTerms":1,"termsObject":"{\"extName\":\"jomsocial\",\"extView\":\"user\",\"extTask\":\"getTermsNCondition\"}","isEnableVoice":1}} */
  311.  
  312. // BOOL isPhotoUpload = [[[[ApplicationData sharedInstance].dictextentionconfig objectForKey:@"jomsocial"] objectForKey:@"isPhotoUpload"]boolValue];
  313. // if (isPhotoUpload) {
  314. // btncoverphoto.hidden = NO;
  315. // btnPhotos.hidden = NO;
  316. //
  317. // btnPhotos.frame = CGRectMake(78, 8, 40, 20);
  318. // btnVideos.frame = CGRectMake(122, 8, 42, 20);
  319. // btnEvents.frame = CGRectMake(169, 8, 42, 20);
  320. // }else {
  321. // btncoverphoto.hidden = YES;
  322. // btnPhotos.hidden = YES;
  323. // btnVideos.frame = CGRectMake(78, 8, 40, 20);
  324. // }
  325. //
  326. // BOOL createEvent = [[[[ApplicationData sharedInstance].dictextentionconfig objectForKey:@"jomsocial"] objectForKey:@"createEvent"]boolValue];
  327. // if (createEvent) {
  328. // btnEvents.hidden = NO;
  329. // btnPhotos.frame = CGRectMake(78, 8, 40, 20);
  330. // btnVideos.frame = CGRectMake(122, 8, 42, 20);
  331. // btnEvents.frame = CGRectMake(169, 8, 42, 20);
  332. // }else {
  333. // btnEvents.hidden = YES;
  334. // btnVideos.frame = CGRectMake(78, 8, 40, 20);
  335. // }
  336.  
  337. [self themechange];
  338. }
  339.  
  340. -(void)PhotoCaption{
  341. [spinner stopAnimating];
  342. [self showAlert:NSLocalizedString(@"Done_title",@"") Content:NSLocalizedString(@"photo_uploaded", @"")];
  343. }
  344.  
  345. - (IBAction)whatstonurmindButtonPressed{
  346. btnwtsonurmind.hidden = YES;
  347. [txtStatus becomeFirstResponder];
  348. CGPoint tableViewCenter = [tableView contentOffset];
  349. tableViewCenter.y += tableView.frame.size.height/2;
  350. [tableView setContentOffset:CGPointMake(0,tableViewCenter.y) animated:YES];}
  351.  
  352. -(void)viewDidAppear:(BOOL)animated {
  353. [super viewDidAppear:animated];
  354.  
  355. if ([ApplicationData sharedInstance].flag_cov_photochanged == 1) {
  356.  
  357. [ApplicationData sharedInstance].flag_cov_photochanged = 0;
  358.  
  359. imgvw_cover.image = [ApplicationData sharedInstance].userDetail.coverImg;
  360.  
  361.  
  362. }
  363.  
  364. if(isMainUserProfileView)
  365. {
  366. userDetail = [ApplicationData sharedInstance].userDetail;
  367. }
  368.  
  369. if(![ApplicationData sharedInstance].isLoggedIn)
  370. {
  371. LoginViewController *controller = [[LoginViewController alloc] init];
  372. int k = [controller LogincheckDict];
  373. if (k == 1) {
  374.  
  375. [controller LoginDone];
  376. [self viewDidAppear:NO];
  377. }
  378. else if (k==2)
  379. {
  380. [controller FBLoginDone];
  381. [self viewDidAppear:NO];
  382. }
  383. else
  384. {
  385. [self presentModalViewController:controller animated:YES];
  386. }
  387. [controller release];
  388. }
  389. else
  390. {
  391.  
  392.  
  393. if (userDetail.userId == 0)
  394. {
  395. btnfriend.hidden = YES;
  396. btncoverphoto.hidden = NO;
  397. //btnmessage.frame = CGRectMake(26, 263, 268, 30);
  398. //[btnmessage setBackgroundImage:[UIImage imageNamed:@"Lea_mesaage_box.png"] forState:UIControlStateNormal];
  399. }
  400. else
  401. {
  402.  
  403. btncoverphoto.hidden = YES;
  404. //[btnmessage setBackgroundImage:[UIImage imageNamed:@"Lea_friend_btn.png"] forState:UIControlStateNormal];
  405. if (!userDetail.isFriend) {
  406. btnfriend.hidden = NO;
  407. [btnfriend setTitle:NSLocalizedString(@"addFriend", @"") forState:UIControlStateNormal];
  408. [btnfriend removeTarget:self action:@selector(removeFriendButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  409. [btnfriend addTarget:self action:@selector(addFriendButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  410. //btnmessage.frame = CGRectMake(169, 263, 118, 30);
  411. //btnfriend.frame = CGRectMake(34, 263, 118, 30);
  412. }else {
  413. btnfriend.hidden = NO;
  414. [btnfriend setTitle:NSLocalizedString(@"already_friend", @"") forState:UIControlStateNormal];
  415. [btnfriend removeTarget:self action:@selector(addFriendButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  416. [btnfriend addTarget:self action:@selector(removeFriendButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  417. //btnmessage.frame = CGRectMake(169, 263, 118, 30);
  418. //btnfriend.frame = CGRectMake(34, 263, 118, 30);
  419. }
  420. }
  421.  
  422. if(userDetail) {
  423. timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(setUserData) userInfo:nil repeats:NO];
  424. }
  425. else {
  426.  
  427. if(![ApplicationData sharedInstance].userDetailCached){
  428. [ApplicationData sharedInstance].userDetailCached = YES;
  429. timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(setUserData) userInfo:nil repeats:NO];
  430. }
  431. else if(btnEdit.hidden == NO)
  432. {
  433. //statusMsg.text = [userDetail status];
  434. CGSize stringsize1 = [[userDetail status] sizeWithFont:[statusMsg font]];
  435.  
  436. if (stringsize1.width > 285)
  437. {
  438. //statusMsg.frame = CGRectMake(statusMsg.frame.origin.x, statusMsg.frame.origin.y, (stringsize1.width + 10.0), statusMsg.frame.size.height);
  439. //[scrstatusMsg setContentSize:(CGSizeMake((stringsize1.width + 15), 20))];
  440. }
  441.  
  442. lblvideoMsg.text = [userDetail.profile_video objectForKey:@"title"];
  443. stringsize1 = [[userDetail.profile_video objectForKey:@"title"] sizeWithFont:[lblvideoMsg font]];
  444.  
  445. if (stringsize1.width > 255)
  446. {
  447. lblvideoMsg.frame = CGRectMake(lblvideoMsg.frame.origin.x, lblvideoMsg.frame.origin.y, (stringsize1.width + 10.0), lblvideoMsg.frame.size.height);
  448. [scrvideoMsg setContentSize:(CGSizeMake((stringsize1.width + 15), 20))];
  449. }
  450.  
  451.  
  452. name.text = [userDetail userName];
  453.  
  454.  
  455. }
  456. if(![ApplicationData sharedInstance].userDetail.avatarImg ) {
  457. [self performSelectorOnMainThread:@selector(sendImageRequest) withObject:nil waitUntilDone:NO];
  458. }
  459. else {
  460. [userImg setImage:[userDetail avatarImg]];
  461. }
  462. }
  463. }
  464. iJoomerAppDelegate *appdelegate = (iJoomerAppDelegate *) [[UIApplication sharedApplication] delegate];
  465. [appdelegate fetchsidemenuList:@"JomProfile"];
  466. cellImageNames = [ApplicationData sharedInstance].profileMenuImages;
  467. [super viewDidAppear:YES];
  468. scrollMenu.contentSize = CGSizeMake(384, 78);
  469.  
  470.  
  471. if ([userDetail.status rangeOfString:@"{voice}"].location != NSNotFound) {
  472. Voiceview.hidden = NO;
  473. scrstatusMsg.hidden = YES;
  474.  
  475. NSString *strTitle = userDetail.status;
  476. strTitle = [strTitle stringByReplacingOccurrencesOfString: @"{voice}" withString:@""];
  477. strTitle = [strTitle stringByReplacingOccurrencesOfString: @"{/voice}" withString:@""];
  478. NSArray *arr = [strTitle componentsSeparatedByString:@"&"];
  479. userDetail.playVoice = [arr objectAtIndex:0];
  480. lblSecond.text = [NSString stringWithFormat:@"%@ s",[arr objectAtIndex:1]];
  481.  
  482.  
  483.  
  484. } else {
  485.  
  486.  
  487. Voiceview.hidden = YES;
  488. scrstatusMsg.hidden = NO;
  489. }
  490.  
  491.  
  492. }
  493.  
  494. #pragma mark -
  495. #pragma mark themeChange
  496.  
  497. -(void) themechange{
  498.  
  499. [btnWritePost setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  500. [btnWritePost setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
  501. [btnPhotos setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  502. [btnPhotos setTitleColor:[UIColor blackColor] forState:UIControlStateSelected];
  503. [btnVideos setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  504. [btnVideos setTitleColor:[UIColor blackColor] forState:UIControlStateSelected];
  505. [btnEvents setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  506. [btnEvents setTitleColor:[UIColor blackColor] forState:UIControlStateSelected];
  507.  
  508. if (photoSelectIndex == 888) {
  509. [btnWritePost setBackgroundColor:[UIColor clearColor]];
  510. [btnPhotos setBackgroundColor: palleteBlue];
  511. }
  512. else{
  513. [btnPhotos setBackgroundColor:[UIColor clearColor]];
  514. [btnVideos setBackgroundColor:[UIColor clearColor]];
  515. [btnEvents setBackgroundColor:[UIColor clearColor]];
  516. }
  517.  
  518.  
  519. // statusMsg.textColor=[UIColor blackColor];
  520. if (name.enabled == TRUE)
  521. {
  522. //name.textColor =[UIColor blackColor];
  523. }
  524. else
  525. {
  526. //name.textColor = [ApplicationData sharedInstance].textcolor;
  527. }
  528. lblDislikeCount.textColor = [ApplicationData sharedInstance].textcolor;
  529. tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  530. tableView.separatorColor = [UIColor clearColor];
  531. txtComment.textColor = [ApplicationData sharedInstance].textcolor;
  532. profileCount.textColor=[ApplicationData sharedInstance].textcolor;
  533. [btnPermission setTitleColor:[ApplicationData sharedInstance].textcolor forState:UIControlStateNormal];
  534. lbl_profileCount.textColor = [ApplicationData sharedInstance].textcolor;
  535. //name.font =[ApplicationData sharedInstance].header9;
  536. //statusMsg.font=[ApplicationData sharedInstance].header4;
  537. profileCount.font=[ApplicationData sharedInstance].header9;
  538. lbl_profileCount.font = [ApplicationData sharedInstance].header9;
  539. backImg.image = [UIImage imageNamed:[ApplicationData sharedInstance].bgImage];
  540. spinner.layer.cornerRadius = 8;
  541. spinner.layer.masksToBounds = YES;
  542. //[spinner setBackgroundColor:[ApplicationData sharedInstance].textcolor];
  543.  
  544. txtStatus.layer.cornerRadius = 4;
  545. txtStatus.layer.masksToBounds = YES;
  546. btnsend.layer.cornerRadius = 8;
  547. btnsend.layer.masksToBounds = YES;
  548. //layer for Send Button
  549. CALayer *imgLayerSend = [btnsend layer];
  550. [btnsend setBackgroundColor: palletePurple];
  551. [imgLayerSend setMasksToBounds:YES];
  552. [imgLayerSend setCornerRadius:3.0];
  553. [imgLayerSend setBorderWidth:0.0];
  554. [imgLayerSend setBorderColor:[[UIColor clearColor] CGColor]];
  555.  
  556. //lblViews.textColor = [ApplicationData sharedInstance].textcolorhead;
  557. //lblAbout.textColor = [ApplicationData sharedInstance].textcolorhead;
  558. //lblFriends.textColor = [ApplicationData sharedInstance].textcolorhead;
  559. lblMap.textColor = [ApplicationData sharedInstance].textcolorhead;
  560. //lblPhotos.textColor = [ApplicationData sharedInstance].textcolorhead;
  561. //lblVideos.textColor = [ApplicationData sharedInstance].textcolorhead;
  562. //lblRecentTitle.textColor = [ApplicationData sharedInstance].textcolor;
  563.  
  564. //[btnfriend setTitleColor:[ApplicationData sharedInstance].textcolorWhite forState:UIControlStateNormal];
  565. //[btnmessage setTitleColor:[ApplicationData sharedInstance].textcolorWhite forState:UIControlStateNormal];
  566. //[btnsend setTitleColor:[ApplicationData sharedInstance].textcolorWhite forState:UIControlStateNormal];
  567. // [Voiceover setBackgroundColor:[ApplicationData sharedInstance].VoiceViewcolor];
  568.  
  569. //for photo caption
  570. txtPhotoCaption.layer.cornerRadius = 4;
  571. txtPhotoCaption.layer.masksToBounds = YES;
  572. CALayer *imgLayerphotocaptionSend = [btnsend layer];
  573. [btnPhotocaptionSend setBackgroundColor:palletePurple];
  574. [imgLayerphotocaptionSend setMasksToBounds:YES];
  575. [imgLayerphotocaptionSend setCornerRadius:3.0];
  576. [imgLayerphotocaptionSend setBorderWidth:0.0];
  577. [imgLayerphotocaptionSend setBorderColor:[[UIColor clearColor] CGColor]];
  578. btnPhotocaptionSend.layer.cornerRadius = 8;
  579. btnPhotocaptionSend.layer.masksToBounds = YES;
  580. //[VoiceoverPhotoCaption setBackgroundColor:[ApplicationData sharedInstance].VoiceViewcolor];
  581. [tableView reloadData];
  582.  
  583. }
  584.  
  585. #pragma mark -
  586. #pragma mark textField
  587.  
  588. - (BOOL)textFieldShouldReturn: (UITextField *)textField {
  589. [textField resignFirstResponder];
  590. return YES;
  591. }
  592.  
  593. - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView {
  594. if (txtStatus.text.length == 0)
  595. {
  596. btnwtsonurmind.hidden = NO;
  597.  
  598. }else{
  599. btnwtsonurmind.hidden = YES;
  600.  
  601. }
  602. }// called on finger up as we are moving
  603.  
  604. - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
  605.  
  606. }// called when scroll view grinds to a halt
  607.  
  608.  
  609. - (void)textViewDidBeginEditing:(UITextView *)textView {
  610.  
  611. // CGPoint tableViewCenter = [tableView contentOffset];
  612. // tableViewCenter.y += tableView.frame.size.height/2;
  613. // [tableView setContentOffset:CGPointMake(0,tableViewCenter.y) animated:YES];
  614. if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
  615. CGSize result = [[UIScreen mainScreen] bounds].size;
  616. if(result.height == 480) {
  617. [tableView setContentOffset:CGPointMake(0,260) animated:YES];
  618. } else if(result.height == 568) {
  619. [tableView setContentOffset:CGPointMake(0,170) animated:YES];
  620.  
  621. }
  622. }
  623.  
  624. }
  625.  
  626. - (void)cancelPressed {
  627. if (txtComment.text.length > 0) {
  628. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"button_cancel",@"") message:NSLocalizedString(@"sure_cancel", @"") delegate:self cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"lblNo", @"No"), NSLocalizedString(@"lblYes", @"Yes"), nil];
  629. alert.tag = 2;
  630. [alert show];
  631. [alert release];
  632.  
  633. } else {
  634.  
  635. [[self.view findFirstResponder] resignFirstResponder];
  636. txtComment.backgroundColor =[UIColor whiteColor];
  637. txtComment.frame = CGRectMake(10.0, 250.0, 300.0, 45.0);
  638. if (userDetail.userId == 0)
  639. {
  640. btnEdit.hidden = NO;
  641. self.navigationItem.leftBarButtonItem = nil;
  642. }
  643. else
  644. {
  645. if (userDetail.isFriend)
  646. {
  647. self.navigationItem.rightBarButtonItem = nil;
  648. btnEdit.hidden = YES;
  649. }
  650. else
  651. {
  652. btnEdit.hidden = NO;
  653. }
  654. }
  655. txtComment.hidden = YES;
  656. }
  657.  
  658. }
  659.  
  660. - (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex {
  661. if ((buttonIndex == 1) && (alertView.tag == 2)) {
  662. [[self.view findFirstResponder] resignFirstResponder];
  663. txtComment.backgroundColor =[UIColor whiteColor];
  664. txtComment.frame = CGRectMake(10.0, 250.0, 300.0, 45.0);
  665. txtComment.hidden = YES;
  666. txtComment.text = @"";
  667. // [txtStatus setHidden:YES];
  668. [txtComment resignFirstResponder];
  669. // self.navigationItem.leftBarButtonItem = nil;
  670. if (userDetail.userId == 0) {
  671. btnEdit.hidden = NO;
  672. self.navigationItem.leftBarButtonItem = nil;
  673. }else {
  674. if (userDetail.isFriend) {
  675. self.navigationItem.rightBarButtonItem = nil;
  676. btnEdit.hidden = YES;
  677. }else {
  678. btnEdit.hidden = NO;
  679. }
  680. }
  681.  
  682. }
  683.  
  684. if ((buttonIndex == 1) && (alertView.tag == 3)) {
  685. Wall *record = [tempArray objectAtIndex:deleteIndex];
  686. NSMutableDictionary *postVariables = [[NSMutableDictionary alloc] init];
  687.  
  688. [postVariables setObject:[NSString stringWithFormat:@"%d",record.wallId] forKey:@"uniqueID"];
  689. [postVariables setObject:[NSString stringWithFormat:@"%d",0] forKey:@"comment"];
  690.  
  691. NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"wall" ExtTask:@"remove" TaskdataDictionary:postVariables Imagedata:nil];
  692.  
  693. currentRequestType = jDeleteWallQuery;
  694. [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
  695. // userDetail = [[GlobalObjects Wall:dict] retain];
  696. // DLog(@"count:%d",[userDetail.groupList count]);
  697. if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
  698. [self requestCompleted];
  699. }else {
  700. self.view.userInteractionEnabled = YES;
  701. }
  702.  
  703. }
  704.  
  705. if ((buttonIndex == 1) && (alertView.tag == 8)) {
  706. [spinner startAnimating];
  707. [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(removeFriend) userInfo:nil repeats:NO];
  708. }
  709.  
  710. if ((buttonIndex == 0) && (alertView.tag == 1)){
  711. [[self.view findFirstResponder] resignFirstResponder];
  712. [self addNew];
  713. }
  714. else if(buttonIndex == 1 && (alertView.tag == 1)){
  715. [[self.view findFirstResponder] resignFirstResponder];
  716. }
  717. }
  718.  
  719. -(void)removeFriend {
  720. NSMutableDictionary *postVariables = [[NSMutableDictionary alloc] init];
  721.  
  722. [postVariables setObject:[NSString stringWithFormat:@"%d",userDetail.userId] forKey:@"memberID"];
  723.  
  724. NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"friend" ExtTask:@"removeFriend" TaskdataDictionary:postVariables Imagedata:nil];
  725. currentRequestType =
  726. [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
  727. if ([ApplicationData sharedInstance].errorCode == 200) {
  728. [spinner startAnimating];
  729. [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(profileRequest) userInfo:nil repeats:NO];
  730. }
  731. }
  732.  
  733. -(void)update{
  734. [spinner stopAnimating];
  735. [self showAlert:NSLocalizedString(@"Done_title",@"") Content:NSLocalizedString(@"update_success", @"")];
  736. }
  737.  
  738. - (void)doneButtonPressed {
  739.  
  740. [[self.view findFirstResponder] resignFirstResponder];
  741. txtStatus.backgroundColor =[UIColor whiteColor];
  742. // txtStatus.frame = CGRectMake(10.0, 250.0, 300.0, 45.0);
  743. if (userDetail.userId == 0) {
  744. btnEdit.hidden = NO;
  745. self.navigationItem.leftBarButtonItem = nil;
  746. }else {
  747. if (userDetail.isFriend) {
  748. self.navigationItem.rightBarButtonItem = nil;
  749. btnEdit.hidden = YES;
  750. }else {
  751. btnEdit.hidden = NO;
  752. }
  753. }
  754. }
  755. - (IBAction)dismissActionSheet:(id)sender
  756. {
  757. [alertController dismissViewControllerAnimated:NO completion:nil];
  758.  
  759. }
  760. - (IBAction)DoneActionSheet:(id)sender
  761. {
  762. [alertController dismissViewControllerAnimated:NO completion:nil];
  763. [btnPermission setTitle:[permissions objectAtIndex:rowIndex] forState:UIControlStateNormal];
  764. if ([btnPermission.titleLabel.text isEqualToString:NSLocalizedString(@"Public_title",@"")]) {
  765. permissionValue = 0;
  766. }else if ([btnPermission.titleLabel.text isEqualToString:NSLocalizedString(@"sitemember_title",@"")]) {
  767. permissionValue = 20;
  768. }else if ([btnPermission.titleLabel.text isEqualToString:NSLocalizedString(@"friends_title",@"")]) {
  769. permissionValue = 30;
  770. }else if ([btnPermission.titleLabel.text isEqualToString:NSLocalizedString(@"onlyme_title",@"")]) {
  771. permissionValue = 40;
  772. }
  773.  
  774. }
  775. - (IBAction)PermissionButtonPressed:(id)sender {
  776.  
  777. if ([[[UIDevice currentDevice]systemVersion]floatValue] >= 8.0) {
  778.  
  779. alertController = [UIAlertController alertControllerWithTitle:@" \n\n\n\n\n\n\n\n\n\n\n"
  780. message:@""
  781. preferredStyle:UIAlertControllerStyleActionSheet];
  782.  
  783. UIPickerView *selectionPicker1=[[UIPickerView alloc]init];
  784. selectionPicker1 = [[UIPickerView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 120.0)];
  785. selectionPicker1.showsSelectionIndicator = YES;
  786. selectionPicker1.dataSource = self;
  787. selectionPicker1.delegate = self;
  788.  
  789. [alertController.view addSubview:selectionPicker1];
  790.  
  791. UISegmentedControl *closePicker = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:NSLocalizedString(@"button_Cancel",@"Cancel")]];
  792. closePicker.momentary = YES;
  793. closePicker.frame = CGRectMake(5, 175.0f, 140, 30.0f);
  794. closePicker.segmentedControlStyle = UISegmentedControlStyleBar;
  795. closePicker.tintColor = [UIColor blackColor];
  796. [closePicker addTarget:self action:@selector(dismissActionSheet:) forControlEvents:UIControlEventValueChanged];
  797. [alertController.view addSubview:closePicker];
  798.  
  799. UISegmentedControl *donePicker = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:NSLocalizedString(@"button_done", @"Done")]];
  800. donePicker.momentary = YES;
  801. donePicker.frame = CGRectMake(160, 175.0f, 140, 30.0f);
  802. donePicker.segmentedControlStyle = UISegmentedControlStyleBar;
  803. donePicker.tintColor = [UIColor blackColor];
  804. [donePicker addTarget:self action:@selector(DoneActionSheet:) forControlEvents:UIControlEventValueChanged];
  805. [alertController.view addSubview:donePicker];
  806. [self presentViewController:alertController animated:YES completion:nil];
  807.  
  808. }
  809. else
  810. {
  811. UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"\n\n\n\n\n\n\n\n\n\n\n"
  812. delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil
  813. otherButtonTitles:NSLocalizedString(@"Done_title",@""),NSLocalizedString(@"button_cancel",@""),nil];
  814. actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
  815.  
  816. actionSheet.tag = 4;
  817.  
  818. UIPickerView *selectionPicker = [[UIPickerView alloc] initWithFrame:CGRectZero];
  819. selectionPicker.delegate = self;
  820. selectionPicker.dataSource = self;
  821. selectionPicker.showsSelectionIndicator = YES;
  822.  
  823.  
  824. actionSheet.alpha = 1.0;
  825.  
  826. // add this picker to our view controller, initially hidden
  827. [actionSheet insertSubview:selectionPicker atIndex:0];
  828.  
  829. actionSheet.destructiveButtonIndex =1; // make the second button red (destructive)
  830. [actionSheet showInView:self.view];// showInView:self.view]; // show from our tabbar view (pops up in the middle of the tabbar)
  831. [actionSheet release];
  832. }
  833. }
  834.  
  835. -(IBAction)ShareButtonPressed:(id)sender
  836. {
  837. sendertag = 0;
  838.  
  839. if (txtStatus.text.length == 0)
  840. {
  841. [self showAlert:NSLocalizedString(@"no_text",@"") Content:NSLocalizedString(@"Please_enter_text", @"")];
  842. return;
  843. }
  844.  
  845. if (userDetail.userId == 0)
  846. {
  847. NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
  848. [postVariables setObject:txtStatus.text forKey:@"message"];
  849. [postVariables setObject:[NSString stringWithFormat:@"%d",permissionValue] forKey:@"privacy"];
  850. [postVariables setObject:[NSString stringWithFormat:@"%d",0] forKey:@"comment"];
  851.  
  852. NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"wall" ExtTask:@"add" TaskdataDictionary:postVariables Imagedata:nil];
  853.  
  854. newWall = [GlobalObjects Share:dict];
  855. [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
  856. currentRequestType = jStatusQuery;
  857. if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
  858. [self requestCompleted];
  859. }else {
  860. self.view.userInteractionEnabled = YES;
  861. }
  862.  
  863. }
  864. else
  865. {
  866. NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
  867. [postVariables setObject:txtStatus.text forKey:@"message"];
  868. [postVariables setObject:[NSString stringWithFormat:@"%d",userDetail.userId] forKey:@"uniqueID"];
  869. [postVariables setObject:[NSString stringWithFormat:@"%d",permissionValue] forKey:@"privacy"];
  870. [postVariables setObject:[NSString stringWithFormat:@"%d",0] forKey:@"comment"];
  871. // [postVariables setObject:[NSString stringWithFormat:@"%d",permissionValue] forKey:@"permissions"];
  872.  
  873. NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"wall" ExtTask:@"add" TaskdataDictionary:postVariables Imagedata:nil];
  874.  
  875. [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
  876. currentRequestType = jShareQuery;
  877. if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
  878. [self requestCompleted];
  879. }else {
  880. self.view.userInteractionEnabled = YES;
  881. }
  882. }
  883. [txtStatus resignFirstResponder];
  884. }
  885.  
  886. - (IBAction) movieFinished: (id) sender {
  887. [mp stop];
  888. }
  889.  
  890. //For Playing
  891. - (IBAction)PlayButtonPressed:(id)sender {
  892. // Make sure the audio is at the start of the stream.
  893. if(![sender isSelected]) {
  894.  
  895. // Wall *record = [[ApplicationData sharedInstance].updatesList objectAtIndex:[sender tag]];
  896. // wallRecord = record;
  897. NSString *strTitle = userDetail.status;
  898. // strTitle = [strTitle stringByReplacingOccurrencesOfString: @"{voice}" withString:@""];
  899. // strTitle = [strTitle stringByReplacingOccurrencesOfString: @"{/voice}" withString:@""];
  900. strTitle = [self stringBetweenString:@"{voice}" andString:@"{/voice}"];
  901. NSArray *arr = [strTitle componentsSeparatedByString:@"&"];
  902. userDetail.playVoice = [arr objectAtIndex:0];
  903. [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
  904. [[AVAudioSession sharedInstance] setActive: YES error: nil];
  905. NSURL *url;
  906. url = [NSURL URLWithString:userDetail.playVoice];
  907. DLog(@"url : %@",url);
  908. mp = [[MPMoviePlayerController alloc] initWithContentURL:url];
  909. [mp prepareToPlay];
  910. [mp play];
  911. DLog(@"Play...");
  912. }else{
  913. [mp stop];
  914. DLog(@"Stop...");
  915.  
  916. }
  917. [sender setSelected:![sender isSelected]];
  918.  
  919.  
  920. }
  921. -(NSString*)stringBetweenString:(NSString*)start andString:(NSString*)end {
  922. NSRange startRange = [userDetail.status rangeOfString:start];
  923. if (startRange.location != NSNotFound) {
  924. NSRange targetRange;
  925. targetRange.location = startRange.location + startRange.length;
  926. targetRange.length = [userDetail.status length] - targetRange.location;
  927. NSRange endRange = [userDetail.status rangeOfString:end options:0 range:targetRange];
  928. if (endRange.location != NSNotFound) {
  929. targetRange.length = endRange.location - targetRange.location;
  930. DLog(@"title : %@",userDetail.status);
  931. return [userDetail.status substringWithRange:targetRange];
  932. }
  933. }
  934. return nil;
  935. }
  936.  
  937.  
  938.  
  939. - (IBAction)PlayContentButtonPressed:(id)sender {
  940. // Make sure the audio is at the start of the stream.
  941. if(![sender isSelected]) {
  942. tempArray = userDetail.wallList;
  943.  
  944. Wall *record = [tempArray objectAtIndex:[sender tag]];
  945. wallRecord = record;
  946. NSString *strTitle = record.content;
  947. // strTitle = [strTitle stringByReplacingOccurrencesOfString: @"{voice}" withString:@""];
  948. // strTitle = [strTitle stringByReplacingOccurrencesOfString: @"{/voice}" withString:@""];
  949. strTitle = [self stringBetweenStringContent:@"{voice}" andString:@"{/voice}"];
  950. NSArray *arr = [strTitle componentsSeparatedByString:@"&"];
  951. record.playVoiceContent = [arr objectAtIndex:0];
  952. [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
  953. [[AVAudioSession sharedInstance] setActive: YES error: nil];
  954. NSURL *url;
  955. url = [NSURL URLWithString:record.playVoiceContent];
  956. DLog(@"url : %@",url);
  957. mp = [[MPMoviePlayerController alloc] initWithContentURL:url];
  958. [mp prepareToPlay];
  959. [mp play];
  960. DLog(@"Play1...");
  961. }else{
  962. [mp stop];
  963. DLog(@"Stop1...");
  964. ;}
  965. [sender setSelected:![sender isSelected]];
  966.  
  967.  
  968. }
  969. -(NSString*)stringBetweenStringContent:(NSString*)start andString:(NSString*)end1 {
  970. NSRange startRange = [wallRecord.content rangeOfString:start];
  971. if (startRange.location != NSNotFound) {
  972. NSRange targetRange;
  973. targetRange.location = startRange.location + startRange.length;
  974. targetRange.length = [wallRecord.content length] - targetRange.location;
  975. NSRange endRange = [wallRecord.content rangeOfString:end1 options:0 range:targetRange];
  976. if (endRange.location != NSNotFound) {
  977. targetRange.length = endRange.location - targetRange.location;
  978. DLog(@"title : %@",wallRecord.content);
  979. return [wallRecord.content substringWithRange:targetRange];
  980. }
  981. }
  982. return nil;
  983. }
  984.  
  985.  
  986. - (IBAction)PlayTitleButtonPressed:(id)sender {
  987. // Make sure the audio is at the start of the stream.
  988. if(![sender isSelected]) {
  989. tempArray = userDetail.wallList;
  990.  
  991. Wall *record = [tempArray objectAtIndex:[sender tag]];
  992. wallRecord = record;
  993. NSString *strTitle = record.title;
  994. // strTitle = [strTitle stringByReplacingOccurrencesOfString: @"{voice}" withString:@""];
  995. // strTitle = [strTitle stringByReplacingOccurrencesOfString: @"{/voice}" withString:@""];
  996. strTitle = [self stringBetweenStringTitle:@"{voice}" andString:@"{/voice}"];
  997. NSArray *arr = [strTitle componentsSeparatedByString:@"&"];
  998. record.playVoice = [arr objectAtIndex:0];
  999. [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
  1000. [[AVAudioSession sharedInstance] setActive: YES error: nil];
  1001. NSURL *url;
  1002. url = [NSURL URLWithString:record.playVoice];
  1003. DLog(@"url : %@",url);
  1004. mp = [[MPMoviePlayerController alloc] initWithContentURL:url];
  1005. [mp prepareToPlay];
  1006. [mp play];
  1007. DLog(@"Play...");
  1008.  
  1009. }else{
  1010. [mp stop];
  1011. DLog(@"Stop...");
  1012. }
  1013. [sender setSelected:![sender isSelected]];
  1014.  
  1015.  
  1016. }
  1017. -(NSString*)stringBetweenStringTitle:(NSString*)start andString:(NSString*)end {
  1018. NSRange startRange = [wallRecord.title rangeOfString:start];
  1019. if (startRange.location != NSNotFound) {
  1020. NSRange targetRange;
  1021. targetRange.location = startRange.location + startRange.length;
  1022. targetRange.length = [wallRecord.title length] - targetRange.location;
  1023. NSRange endRange = [wallRecord.title rangeOfString:end options:0 range:targetRange];
  1024. if (endRange.location != NSNotFound) {
  1025. targetRange.length = endRange.location - targetRange.location;
  1026. DLog(@"title : %@",wallRecord.title);
  1027. return [wallRecord.title substringWithRange:targetRange];
  1028. }
  1029. }
  1030. return nil;
  1031. }
  1032. -(IBAction)voiceSendButtonPressed:(id)sender {
  1033. if (userDetail.userId == 0)
  1034. {
  1035. sendertag = -888;
  1036. [Voiceover HoldAndSpeakButtonPressed:nil];
  1037. if ([[ApplicationData sharedInstance].VoiceCurrentTime isEqualToString:@"00:00"]) {
  1038. [spinner stopAnimating];
  1039. DLog(@"return update...");
  1040. return;
  1041. }
  1042.  
  1043. NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
  1044. [postVariables setObject:txtStatus.text forKey:@"message"];
  1045. [postVariables setObject:[NSString stringWithFormat:@"%d",permissionValue] forKey:@"privacy"];
  1046. [postVariables setObject:[NSString stringWithFormat:@"%d",0] forKey:@"comment"];
  1047. NSDictionary *dict = [Jomsocial JomsocialCommonDictfunctionVoice:@"wall" ExtTask:@"add" TaskdataDictionary:postVariables Voicedata:[ApplicationData sharedInstance].Voicedata voicename:@"voice"];
  1048. newWall = [GlobalObjects Share:dict];
  1049. [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
  1050. currentRequestType = jStatusQuery;
  1051. if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
  1052. [self requestCompleted];
  1053. }else {
  1054. self.view.userInteractionEnabled = YES;
  1055. }
  1056. }
  1057. else
  1058. {
  1059. [Voiceover HoldAndSpeakButtonPressed:nil];
  1060. if ([[ApplicationData sharedInstance].VoiceCurrentTime isEqualToString:@"00:00"]) {
  1061. [spinner stopAnimating];
  1062. DLog(@"return update...");
  1063. return;
  1064. }
  1065.  
  1066. NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
  1067. [postVariables setObject:txtStatus.text forKey:@"message"];
  1068. [postVariables setObject:[NSString stringWithFormat:@"%d",userDetail.userId] forKey:@"uniqueID"];
  1069. [postVariables setObject:[NSString stringWithFormat:@"%d",permissionValue] forKey:@"privacy"];
  1070. [postVariables setObject:[NSString stringWithFormat:@"%d",0] forKey:@"comment"];
  1071. // [postVariables setObject:[NSString stringWithFormat:@"%d",permissionValue] forKey:@"permissions"];
  1072. NSDictionary *dict = [Jomsocial JomsocialCommonDictfunctionVoice:@"wall" ExtTask:@"add" TaskdataDictionary:postVariables Voicedata:[ApplicationData sharedInstance].Voicedata voicename:@"voice"];
  1073. [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
  1074. currentRequestType = jShareQuery;
  1075. if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
  1076. [self requestCompleted];
  1077. }else {
  1078. self.view.userInteractionEnabled = YES;
  1079. }
  1080. }
  1081.  
  1082.  
  1083. }
  1084.  
  1085. -(IBAction)VoiceButtonPressed:(id)sender{
  1086. // self.view.userInteractionEnabled = NO;
  1087. [spinner startAnimating];
  1088. Voiceover.SpeakerView.hidden = YES;
  1089. [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(voiceSendButtonPressed:) userInfo:nil repeats:NO];
  1090. }
  1091.  
  1092. -(IBAction)voicePhotoCaptionSendButtonPressed:(id)sender {
  1093. [ApplicationData sharedInstance].VoicePhotocaption = 199;
  1094. [Voiceover HoldAndSpeakButtonPressed:nil];
  1095. if ([[ApplicationData sharedInstance].VoiceCurrentTime isEqualToString:@"00:00"]) {
  1096. [spinner stopAnimating];
  1097. DLog(@"return update...");
  1098. return;
  1099. }
  1100.  
  1101. NSData *imgData = UIImagePNGRepresentation(userImage); //UIImageJPEGRepresentation(userImage, 1.0);
  1102.  
  1103. NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
  1104. [postVariables setObject:@"0" forKey:@"isDefault"];
  1105. [postVariables setObject:txtPhotoCaption.text forKey:@"caption"];
  1106. [postVariables setObject:@"true" forKey:@"profile"];
  1107.  
  1108.  
  1109.  
  1110. NSDictionary *dict1=[Jomsocial JomsocialCommonDictfunctionVoice:@"media" ExtTask:@"uploadphoto" TaskdataDictionary:postVariables Imagedata:imgData Voicedata:[ApplicationData sharedInstance].Voicedata voicename:@"voice"];
  1111.  
  1112.  
  1113.  
  1114.  
  1115. [ApplicationData sharedInstance].errorCode = [[dict1 objectForKey:TAG_CODE] intValue];
  1116. currentRequestType = jGeneralQuery;
  1117. if([ErrorHandler hasError:self errorCode:[[dict1 objectForKey:TAG_CODE] intValue] errorMessage:[dict1 objectForKey:TAG_ERROR_MESSAGE]]){
  1118. [self requestCompleted];
  1119. }else {
  1120. self.view.userInteractionEnabled = YES;
  1121. }
  1122.  
  1123.  
  1124. }
  1125.  
  1126.  
  1127. -(IBAction)VoicePhotoCaptionButtonPressed:(id)sender{
  1128. // self.view.userInteractionEnabled = NO;
  1129. [spinner startAnimating];
  1130. VoiceoverPhotoCaption.SpeakerView.hidden = YES;
  1131. [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(voicePhotoCaptionSendButtonPressed:) userInfo:nil repeats:NO];
  1132. }
  1133.  
  1134. -(IBAction)WritePostPressed:(id)sender {
  1135. photoSelectIndex = 999;
  1136. [ApplicationData sharedInstance].VoicePhotocaption = 199;
  1137. Voiceover.hidden = NO;
  1138. VoiceoverPhotoCaption.hidden = YES;
  1139. imgPhotoPrev.hidden = YES;
  1140. imgPhotoBackPrev.hidden = YES;
  1141. [btnWritePost setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
  1142. [btnWritePost setBackgroundColor: palleteBlue];
  1143. [btnPhotos setBackgroundColor:[UIColor clearColor]];
  1144.  
  1145. }
  1146.  
  1147. -(IBAction)PhotosPressed:(id)sender {
  1148.  
  1149. if (txtPhotoCaption.text.length >0) {
  1150. btnPhotocaption.hidden = YES;
  1151. }else{
  1152. btnPhotocaption.hidden = NO;
  1153.  
  1154. }
  1155. [ApplicationData sharedInstance].VoicePhotocaption = 9999;;
  1156. isProfilePic = NO;
  1157. imgPhotoPrev.hidden = YES;
  1158. imgPhotoBackPrev.hidden = YES;
  1159. [btnWritePost setBackgroundColor:[UIColor clearColor]];
  1160. Voiceover.hidden = YES;
  1161. VoiceoverPhotoCaption.hidden = NO;
  1162. [self openPhotoGallery:nil];
  1163. [btnPhotos setBackgroundColor: palleteBlue ];
  1164. [btnPhotocaption setTitle:NSLocalizedString(@"photo_caption", @"") forState:UIControlStateNormal];
  1165. }
  1166.  
  1167. -(IBAction)VideosPressed:(id)sender {
  1168. [ApplicationData sharedInstance].VoicePhotocaption = 199;
  1169. [btnVideos setBackgroundColor: palleteBlue];
  1170. photoSelectIndex = 999;
  1171. VideoViewController *controller = [[VideoViewController alloc]init];
  1172. controller.isWall = YES;
  1173. controller.userDetail = userDetail;
  1174. [self.navigationController pushViewController:controller animated:YES];
  1175. [controller release];
  1176.  
  1177. }
  1178.  
  1179. -(IBAction)EventsPressed:(id)sender {
  1180. [btnEvents setBackgroundColor: palleteBlue];
  1181. photoSelectIndex = 999;
  1182. [ApplicationData sharedInstance].VoicePhotocaption = 199;
  1183. JomEditEventViewController *controller = [[JomEditEventViewController alloc] init];
  1184. [[self navigationController] pushViewController:controller animated:YES];
  1185. [controller release];
  1186.  
  1187. }
  1188.  
  1189. - (IBAction)openPhotoGallery:(id) sender {
  1190. // if ([sender isEqual:changeImg]) {
  1191. // isProfilePic = YES;
  1192. // }
  1193. UIActionSheet *actionSheet;
  1194. if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == YES) {
  1195. actionSheet = [[UIActionSheet alloc]
  1196. initWithTitle:NSLocalizedString(@"addPic",@"")
  1197. delegate:self
  1198. cancelButtonTitle:nil
  1199. destructiveButtonTitle:NSLocalizedString(@"button_cancel",@"")
  1200. otherButtonTitles:NSLocalizedString(@"gallery",@""),NSLocalizedString(@"cam",@""),nil];
  1201. } else {
  1202. actionSheet = [[UIActionSheet alloc]
  1203. initWithTitle:NSLocalizedString(@"addPic",@"")
  1204. delegate:self
  1205. cancelButtonTitle:nil
  1206. destructiveButtonTitle:NSLocalizedString(@"button_cancel",@"")
  1207. otherButtonTitles:NSLocalizedString(@"gallery",@""),nil];
  1208. }
  1209. actionSheet.tag = 888;
  1210.  
  1211. actionSheet.alpha = 1.0;
  1212. [actionSheet showInView:self.view]; //showInView:self.view]; // show from our tabbar view (pops up in the middle of the tabbar)
  1213. [actionSheet release];
  1214.  
  1215. }
  1216.  
  1217. //////////////////////////////////////////////////////////////////////////////////////////////////////
  1218. /////////////////////////////////// PickerView Delegate //////////////////////////////////////////////
  1219. //////////////////////////////////////////////////////////////////////////////////////////////////////
  1220.  
  1221. - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView {
  1222. return 1;
  1223. }
  1224.  
  1225. - (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
  1226. return [permissions count];
  1227. }
  1228.  
  1229. - (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
  1230. return [permissions objectAtIndex:row];
  1231.  
  1232.  
  1233. }
  1234.  
  1235. - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {
  1236. return 240;
  1237. }
  1238.  
  1239. - (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
  1240. rowIndex = row;
  1241. [permissions objectAtIndex:row];
  1242. // [btnPermission setTitle:[permissions objectAtIndex:row] forState:UIControlStateNormal];
  1243. [btnPermission setTitle:[NSString stringWithFormat:@" %@",[permissions objectAtIndex:row]] forState:UIControlStateNormal];
  1244. }
  1245.  
  1246.  
  1247. #pragma mark -
  1248. #pragma mark fetchData & requestCompleted
  1249.  
  1250. - (BOOL)Userdata_update
  1251. {
  1252. NSMutableDictionary *postVariables = [[NSMutableDictionary alloc] init];
  1253. [postVariables setObject:[NSString stringWithFormat:@"%d",userDetail.userId] forKey:@"userID"];
  1254.  
  1255. NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"user" ExtTask:@"profile" TaskdataDictionary:postVariables Imagedata:nil];
  1256.  
  1257. [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
  1258. if ([[dict objectForKey:TAG_CODE] intValue] == 200)
  1259. {
  1260. User *userObj = [GlobalObjects ProfileDetail:dict];
  1261.  
  1262. [ApplicationData sharedInstance].loggedUser = userObj.userId;
  1263. [ApplicationData sharedInstance].userDetail.userId = userObj.userId;
  1264. [ApplicationData sharedInstance].sessionId = userObj.sessionid;
  1265. [ApplicationData sharedInstance].userDetail.userName = userObj.userName;
  1266. [ApplicationData sharedInstance].userDetail.userEmail = userObj.userEmail;
  1267. [ApplicationData sharedInstance].userDetail.code = userObj.code;
  1268. [ApplicationData sharedInstance].errorCode = userObj.code;
  1269. [ApplicationData sharedInstance].userDetail.avatarURL = userObj.avatarURL;
  1270. [ApplicationData sharedInstance].userDetail.status = userObj.status;
  1271. [ApplicationData sharedInstance].userDetail.viewCount = userObj.viewCount;
  1272. [ApplicationData sharedInstance].userDetail.Liked = userObj.Liked;
  1273. [ApplicationData sharedInstance].userDetail.Disliked = userObj.Disliked;
  1274. [ApplicationData sharedInstance].userDetail.Likes = userObj.Likes;
  1275. [ApplicationData sharedInstance].userDetail.Dislikes = userObj.Dislikes;
  1276. [ApplicationData sharedInstance].userDetail.coverpicURL = userObj.coverpicURL;
  1277. [ApplicationData sharedInstance].userDetail.profile_video = userObj.profile_video;
  1278. return YES;
  1279. }
  1280. else
  1281. {
  1282. return NO;
  1283. }
  1284. currentRequestType = jProfileQuery;
  1285. if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
  1286. [self requestCompleted];
  1287. }else {
  1288. self.view.userInteractionEnabled = YES;
  1289. }
  1290. }
  1291.  
  1292. -(void)profileRequest
  1293. {
  1294. NSMutableDictionary *postVariables = [[NSMutableDictionary alloc] init];
  1295. [postVariables setObject:[NSString stringWithFormat:@"%d",userDetail.userId] forKey:@"userID"];
  1296. NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"user" ExtTask:@"profile" TaskdataDictionary:postVariables Imagedata:nil];
  1297. [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
  1298. User *userObj = [GlobalObjects ProfileDetail:dict];
  1299. userDetail.userName = userObj.userName;
  1300. userDetail.code = userObj.code;
  1301. [ApplicationData sharedInstance].errorCode = userObj.code;
  1302. userDetail.avatarURL = userObj.avatarURL;
  1303. userDetail.status = userObj.status;
  1304. userDetail.email = userObj.userEmail;
  1305. userDetail.coverpicURL = userObj.coverpicURL;
  1306. userDetail.viewCount = userObj.viewCount;
  1307. userDetail.Liked = userObj.Liked;
  1308. userDetail.Disliked = userObj.Disliked;
  1309. userDetail.Likes = userObj.Likes;
  1310. userDetail.Dislikes = userObj.Dislikes;
  1311. userDetail.isFriend = userObj.isFriend;
  1312. userDetail.pending = userObj.pending;
  1313. userDetail.viewCount = userObj.viewCount;
  1314. userDetail.TotalPhotos = userObj.TotalPhotos;
  1315. userDetail.totalAlbum = userObj.totalAlbum;
  1316. userDetail.TotalFriends = userObj.TotalFriends;
  1317. // userDetail.profile_video = [userObj.profile_video objectForKey:@"url"];
  1318. userDetail.profile_video = [dict valueForKey:@"profile_video"];
  1319.  
  1320.  
  1321.  
  1322. DLog(@"name:%@",userDetail.userName);
  1323. currentRequestType = jProfileQuery;
  1324. if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
  1325. [self requestCompleted];
  1326. }else {
  1327. self.view.userInteractionEnabled = YES;
  1328. }
  1329. }
  1330.  
  1331. -(void)fetchWall {
  1332. [spinner startAnimating];
  1333. [self performSelector:@selector(fetchwallWithSpinner) withObject:nil afterDelay:1];
  1334. }
  1335.  
  1336. -(void)fetchwallWithSpinner{
  1337.  
  1338.  
  1339. DLog(@"lat:%f long:%f",userDetail.latitude,userDetail.longitude);
  1340. NSMutableDictionary *postVariables = [[NSMutableDictionary alloc] init];
  1341. if (userDetail.userId != 0)
  1342. {
  1343. [postVariables setObject:[NSString stringWithFormat:@"%d",userDetail.userId] forKey:@"userID"];
  1344. }
  1345. [postVariables setObject:@"wall" forKey:@"type"];
  1346. [postVariables setObject:[NSString stringWithFormat:@"%d",pageNo] forKey:@"pageNO"];
  1347.  
  1348. NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"wall" ExtTask:@"wall" TaskdataDictionary:postVariables Imagedata:nil];
  1349.  
  1350. currentRequestType = jWallListQuery;
  1351. [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
  1352. tempArray = [GlobalObjects Wall:dict];
  1353.  
  1354. [ApplicationData sharedInstance].totalWall = [[dict objectForKey:@"total"] intValue];
  1355. if ([userDetail.wallList count] == 0) {
  1356. userDetail.wallList = tempArray;
  1357.  
  1358. }else {
  1359. for (int i = 0 ; i < [tempArray count]; i++) {
  1360. Wall *wallObj = [tempArray objectAtIndex:i];
  1361. [userDetail.wallList addObject:wallObj];
  1362. [wallObj release];
  1363. }
  1364.  
  1365. }
  1366. userDetail.wallList = tempArray;
  1367. tempArray = userDetail.wallList;
  1368.  
  1369. if ([ApplicationData sharedInstance].errorCode != 204) {
  1370. if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:@""]){
  1371. [self requestCompleted];
  1372. }else {
  1373. self.view.userInteractionEnabled = YES;
  1374. }
  1375. }else {
  1376. [ApplicationData sharedInstance].totalWall = 0;
  1377. [spinner stopAnimating];
  1378. self.view.userInteractionEnabled = YES;
  1379. }
  1380.  
  1381. }
  1382.  
  1383. -(void)jBadRequest{
  1384. [self showAlert:NSLocalizedString(@"alert_error",@"Error title") Content:NSLocalizedString(@"Wrong Data.", @"")];
  1385. }
  1386.  
  1387. -(void)jErroronServer{
  1388. [self showAlert:NSLocalizedString(@"alert_error",@"Error title") Content:NSLocalizedString(@"Server Error.", @"")];
  1389. }
  1390.  
  1391. -(void)jErrorMessage{
  1392. [self showAlert:NSLocalizedString(@"alert_error",@"Error title") Content:@"No Such Request Found."];
  1393. }
  1394. -(void)jNoContent{
  1395. [self showAlert:NSLocalizedString(@"Message",@"Error title") Content:NSLocalizedString(@"No Content Found.", @"")];
  1396. }
  1397.  
  1398. -(void)jUnsupportedFile {
  1399. [self showAlert:NSLocalizedString(@"alert_error",@"Error title") Content:NSLocalizedString(@"Unsupported File Type.", @"")];
  1400. }
  1401.  
  1402. -(void)jInvalidData {
  1403. [self showAlert:NSLocalizedString(@"alert_error",@"Error title") Content:NSLocalizedString(@"Upload Limit Exceeded.", @"")];
  1404. }
  1405.  
  1406. -(void)jUserNameError {
  1407. [self showAlert:NSLocalizedString(@"Message",@"Error title") Content:NSLocalizedString(@"Username Already Exists.", @"")];
  1408. }
  1409.  
  1410. -(void)jEmailError {
  1411. [self showAlert:NSLocalizedString(@"Message",@"Error title") Content:NSLocalizedString(@"Email Already Exists.", @"")];
  1412. }
  1413.  
  1414. -(void)jFBOption {
  1415. [self showAlert:NSLocalizedString(@"Message",@"Error title") Content:NSLocalizedString(@"Facebook User Not Found.", @"")];
  1416. }
  1417.  
  1418. -(void)jReportedContent {
  1419. [self showAlert:NSLocalizedString(@"Message",@"Error title") Content:NSLocalizedString(@"Permission Denied.", @"")];
  1420. }
  1421.  
  1422. -(void)JPermissionError {
  1423. [self showAlert:NSLocalizedString(@"Message",@"Error title") Content:NSLocalizedString(@"Restricted Access.", @"")];
  1424. }
  1425.  
  1426. -(void)jDuplicateData {
  1427. [self showAlert:NSLocalizedString(@"Message",@"Error title") Content:NSLocalizedString(@"Request already exists.", @"")];
  1428. }
  1429.  
  1430. -(void)jWaitingForPermission {
  1431. [self showAlert:NSLocalizedString(@"Message",@"Error title") Content:NSLocalizedString(@"Awaiting approval.", @"")];
  1432. }
  1433.  
  1434. - (void)requestCompleted {
  1435.  
  1436. [spinner stopAnimating];
  1437. [self stopLoading];
  1438. self.view.userInteractionEnabled = YES;
  1439. if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
  1440. CGSize result = [[UIScreen mainScreen] bounds].size;
  1441. if(result.height == 480) {
  1442. if (isTabbarHidden == YES) {
  1443. tableView.frame = CGRectMake(0, 0, 320, 415 -30);
  1444.  
  1445. }
  1446. else {
  1447. tableView.frame = CGRectMake(0, 0, 320, 365 -30);
  1448.  
  1449. }
  1450. }
  1451.  
  1452. else if(result.height == 568) {
  1453. if (isTabbarHidden == YES) {
  1454. tableView.frame = CGRectMake(0, 0, 320, 500 -30);
  1455.  
  1456.  
  1457. }
  1458. else {
  1459. tableView.frame = CGRectMake(0, 0, 320, 455 -30);
  1460.  
  1461. } // iPhone 5
  1462. }
  1463. }
  1464.  
  1465. if([imageDownloadsInProgress count] == 0)
  1466. {
  1467.  
  1468. }
  1469. [tabBarLayerView removeFromSuperview];
  1470.  
  1471. // switch ([ApplicationData sharedInstance].errorCode)
  1472. // {
  1473. // case jBadRequest:
  1474. // [self performSelectorOnMainThread:@selector(jBadRequest) withObject:nil waitUntilDone:NO];
  1475. // break;
  1476. //
  1477. // case jLoginRequired:
  1478. // [[ApplicationData sharedInstance] logout:self];
  1479. // [self performSelectorOnMainThread:@selector(openLoginView) withObject:nil waitUntilDone:YES];
  1480. // break;
  1481. //
  1482. // case jErroronServer:
  1483. // [self performSelectorOnMainThread:@selector(jErrorMessage) withObject:nil waitUntilDone:NO];
  1484. // break;
  1485. //
  1486. // case jNoContent:
  1487. // [self performSelectorOnMainThread:@selector(jNoContent) withObject:nil waitUntilDone:NO];
  1488. // break;
  1489. //
  1490. // case jErrorMessage:
  1491. // [self performSelectorOnMainThread:@selector(jErrorMessage) withObject:nil waitUntilDone:NO];
  1492. // break;
  1493. //
  1494. // case jUnsupportedFile:
  1495. // [self performSelectorOnMainThread:@selector(jUnsupportedFile) withObject:nil waitUntilDone:NO];
  1496. // break;
  1497. //
  1498. // case jInvalidData:
  1499. // [self performSelectorOnMainThread:@selector(jInvalidData) withObject:nil waitUntilDone:NO];
  1500. // break;
  1501. //
  1502. // case jUserNameError:
  1503. // [self performSelectorOnMainThread:@selector(jUserNameError) withObject:nil waitUntilDone:NO];
  1504. // break;
  1505. //
  1506. // case jEmailError:
  1507. // [self performSelectorOnMainThread:@selector(jEmailError) withObject:nil waitUntilDone:NO];
  1508. // break;
  1509. //
  1510. // case jFBOption:
  1511. // [self performSelectorOnMainThread:@selector(jFBOption) withObject:nil waitUntilDone:NO];
  1512. // break;
  1513. //
  1514. // case jSessionExpire:
  1515. // DLog(@"Session Expired Logging in Again");
  1516. // [[ApplicationData sharedInstance] LoginCheck:self];
  1517. // break;
  1518. //
  1519. // case jReportedContent:
  1520. // [self performSelectorOnMainThread:@selector(jReportedContent) withObject:nil waitUntilDone:NO];
  1521. // break;
  1522. //
  1523. // case JPermissionError:
  1524. // [self performSelectorOnMainThread:@selector(JPermissionError) withObject:nil waitUntilDone:NO];
  1525. // break;
  1526. //
  1527. // case jDuplicateData:
  1528. // [self performSelectorOnMainThread:@selector(jDuplicateData) withObject:nil waitUntilDone:NO];
  1529. // break;
  1530. //
  1531. // case jWaitingForPermission:
  1532. // [self performSelectorOnMainThread:@selector(jWaitingForPermission) withObject:nil waitUntilDone:NO];
  1533. // break;
  1534. // case jSuccess:
  1535. switch (currentRequestType)
  1536. {
  1537. case jShareQuery:
  1538. txtStatus.text = @"";
  1539. btnwtsonurmind.hidden = NO;
  1540. if (![spinner isAnimating]) {
  1541. [spinner startAnimating];
  1542. }
  1543. timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(fetchWall) userInfo:nil repeats:NO];
  1544. break;
  1545. case jDeleteWallQuery:
  1546. [ApplicationData sharedInstance].totalWall --;
  1547.  
  1548. [tempArray removeObjectAtIndex:deleteIndex];
  1549. [tableView reloadData];
  1550. break;
  1551. case jProfileQuery:
  1552. btnfriend.hidden = NO;
  1553. if(!userDetail.isFriend)
  1554. {
  1555.  
  1556. self.navigationItem.rightBarButtonItem = btnEdit1;
  1557. }
  1558. timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(setUserData) userInfo:nil repeats:NO];
  1559.  
  1560. break;
  1561. case jWallListQuery:
  1562. if ([userDetail.wallList count] > 0) {
  1563. [tableView reloadData];
  1564. [self loadImagesForUsers];
  1565. }
  1566.  
  1567. if (sendertag == -888) {
  1568. [self profileRequest];
  1569. }
  1570. if ([userDetail.status rangeOfString:@"{voice}"].location != NSNotFound) {
  1571. //lblContent.text = @"Play";
  1572. // DLog(@"statusvoice : %@",userDetail.status);
  1573. Voiceview.hidden = NO;
  1574. scrstatusMsg.hidden = YES;
  1575.  
  1576. NSString *strTitle = userDetail.status;
  1577. strTitle = [strTitle stringByReplacingOccurrencesOfString: @"{voice}" withString:@""];
  1578. strTitle = [strTitle stringByReplacingOccurrencesOfString: @"{/voice}" withString:@""];
  1579. NSArray *arr = [strTitle componentsSeparatedByString:@"&"];
  1580. userDetail.playVoice = [arr objectAtIndex:0];
  1581. lblSecond.text = [NSString stringWithFormat:@"%@ s",[arr objectAtIndex:1]];
  1582.  
  1583.  
  1584. } else {
  1585.  
  1586.  
  1587. Voiceview.hidden = YES;
  1588. scrstatusMsg.hidden = NO;
  1589. }
  1590.  
  1591.  
  1592. break;
  1593. case jGeneralQuery:
  1594. progressBar.hidden = YES;
  1595. if(userImage && isProfilePic) {
  1596. userImg.image = userImage;
  1597. [ApplicationData sharedInstance].userDetail.avatarImg = userImg.image;
  1598. userDetail.avatarImg = userImage;
  1599. btnEdit.hidden = NO;
  1600. [btnEdit setTitle:NSLocalizedString(@"button_edit", @"") forState:UIControlStateNormal];
  1601. [btnEdit removeTarget:self action:@selector(doneButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  1602. [btnEdit addTarget:self action:@selector(editButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  1603. self.navigationItem.leftBarButtonItem = nil;
  1604. tableView.userInteractionEnabled = YES;
  1605. userImg.alpha = 1.0;
  1606. [self performSelectorOnMainThread:@selector(update) withObject:nil waitUntilDone:YES];
  1607. userImage = nil;
  1608. }
  1609. else if (photoSelectIndex == 888) {
  1610. imgPhotoPrev.hidden = YES;
  1611. imgPhotoBackPrev.hidden = YES;
  1612. VoiceoverPhotoCaption.hidden = YES;
  1613. Voiceover.hidden = NO;
  1614. txtPhotoCaption.text = @"";
  1615. imgPhotoBackPrev.hidden = YES;
  1616. imgPhotoPrev.hidden = YES;
  1617. [btnPhotocaption setTitle:NSLocalizedString(@"photo_caption", @"") forState:UIControlStateNormal];
  1618. [self performSelectorOnMainThread:@selector(PhotoCaption) withObject:nil waitUntilDone:YES];
  1619. }
  1620.  
  1621. else{
  1622.  
  1623. btnEdit.hidden = NO;
  1624. [btnEdit setTitle:NSLocalizedString(@"button_edit", @"") forState:UIControlStateNormal];
  1625. [btnEdit removeTarget:self action:@selector(doneButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  1626. [btnEdit addTarget:self action:@selector(editButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  1627. self.navigationItem.leftBarButtonItem = nil;
  1628. tableView.userInteractionEnabled = YES;
  1629. [self performSelectorOnMainThread:@selector(update) withObject:nil waitUntilDone:YES];
  1630. }
  1631.  
  1632. // [spinner stopAnimating];
  1633. break;
  1634. case jStatusQuery:
  1635. btnwtsonurmind.hidden = NO;
  1636.  
  1637. userDetail.status = txtStatus.text;
  1638. statusMsg.text = [userDetail status];
  1639. CGSize stringsize1 = [[userDetail status] sizeWithFont:[statusMsg font]];
  1640.  
  1641.  
  1642. if (stringsize1.width > 285)
  1643. {
  1644. //statusMsg.frame = CGRectMake(statusMsg.frame.origin.x, statusMsg.frame.origin.y, (stringsize1.width + 10.0), statusMsg.frame.size.height);
  1645. // [scrstatusMsg setContentSize:(CGSizeMake((stringsize1.width + 15), 20))];
  1646. }
  1647. if ([userDetail.status rangeOfString:@"{voice}"].location != NSNotFound) {
  1648. Voiceview.hidden = NO;
  1649. scrstatusMsg.hidden = YES;
  1650.  
  1651. NSString *strTitle = userDetail.status;
  1652. strTitle = [strTitle stringByReplacingOccurrencesOfString: @"{voice}" withString:@""];
  1653. strTitle = [strTitle stringByReplacingOccurrencesOfString: @"{/voice}" withString:@""];
  1654. NSArray *arr = [strTitle componentsSeparatedByString:@"&"];
  1655. userDetail.playVoice = [arr objectAtIndex:0];
  1656. lblSecond.text = [NSString stringWithFormat:@"%@ s",[arr objectAtIndex:1]];
  1657.  
  1658.  
  1659. } else {
  1660.  
  1661.  
  1662. Voiceview.hidden = YES;
  1663. scrstatusMsg.hidden = NO;
  1664. }
  1665.  
  1666. lblvideoMsg.text = [userDetail.profile_video objectForKey:@"title"];
  1667. stringsize1 = [[userDetail.profile_video objectForKey:@"title"] sizeWithFont:[lblvideoMsg font]];
  1668.  
  1669. if (stringsize1.width > 255)
  1670. {
  1671. lblvideoMsg.frame = CGRectMake(lblvideoMsg.frame.origin.x, lblvideoMsg.frame.origin.y, (stringsize1.width + 10.0), lblvideoMsg.frame.size.height);
  1672. [scrvideoMsg setContentSize:(CGSizeMake((stringsize1.width + 15), 20))];
  1673. }
  1674.  
  1675. txtStatus.text = @"";
  1676. // [self performSelectorOnMainThread:@selector(fetchWall) withObject:nil waitUntilDone:YES];
  1677. if (![spinner isAnimating]) {
  1678. [spinner startAnimating];
  1679. }
  1680.  
  1681. timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(fetchWall) userInfo:nil repeats:NO];
  1682. // [tempArray insertObject:newWall atIndex:0];
  1683. // [tableView reloadData];
  1684. // [tempArray add]
  1685. break;
  1686. case jAddFriendQuery:
  1687. [self performSelectorOnMainThread:@selector(addfriend) withObject:nil waitUntilDone:YES];
  1688. userDetail.pending = YES;
  1689. break;
  1690.  
  1691. case jAddCountQuery:
  1692. userDetail.isCounted = YES;
  1693. userDetail.viewCount +=1;
  1694. profileCount.text = [NSString stringWithFormat:@"%d", [userDetail viewCount]];
  1695. break;
  1696.  
  1697. case jLogoutQuery:
  1698. [self.tabBarController.tabBar setHidden:NO];
  1699. [self showAlert:NSLocalizedString(@"logged_out",@"") Content:NSLocalizedString(@"logout_msg", @"")];
  1700. userImg.image = [UIImage imageNamed:@"the face.png"];
  1701. [[ApplicationData sharedInstance] logout:self];
  1702. name.text = @"";
  1703. statusMsg.text = @"";
  1704. profileCount.text = @"";
  1705. [self performSelectorOnMainThread:@selector(openLoginView) withObject:nil waitUntilDone:YES];
  1706. break;
  1707. case jNotificationQuery:
  1708. if([ApplicationData sharedInstance].loggedUser != 0) {
  1709. for(UINavigationController *viewController in self.tabBarController.viewControllers) {
  1710. if([viewController isKindOfClass:[UINavigationController class]] && [[[viewController viewControllers] objectAtIndex:0] isKindOfClass:[NotificationViewController class]]) {
  1711. viewController.tabBarItem.badgeValue = nil;
  1712. [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
  1713. if(([[ApplicationData sharedInstance].notificationList count] > 0)
  1714. || ([[ApplicationData sharedInstance].unreadMsgList count] > 0 ))
  1715. {
  1716. int badgeValue = [[ApplicationData sharedInstance].notificationList count]+[[ApplicationData sharedInstance].unreadMsgList count];
  1717. [viewController.tabBarItem setBadgeValue:[[NSString alloc] initWithFormat:@"%d", badgeValue]];
  1718. [[UIApplication sharedApplication] setApplicationIconBadgeNumber:badgeValue];
  1719. }
  1720. break;
  1721. }
  1722. }
  1723. }
  1724. break;
  1725. case jLikeQuery:
  1726. userDetail.Liked = YES;
  1727. if(!userDetail.isFriend && userDetail.userId == 0) {
  1728. [ApplicationData sharedInstance].userDetail.Liked = YES;
  1729. }
  1730. [btnLike setImage:[UIImage imageNamed:@"unlike_hover_icon.png"] forState:UIControlStateNormal];
  1731. [btnDislike setImage:[UIImage imageNamed:@"unlike_hover_icon.png"] forState:UIControlStateNormal];
  1732. [self performSelectorOnMainThread:@selector(profileRequest) withObject:nil waitUntilDone:YES];
  1733.  
  1734. break;
  1735. case jUnlikeQuery:
  1736. userDetail.Liked = NO;
  1737. if(!userDetail.isFriend && userDetail.userId == 0) {
  1738. [ApplicationData sharedInstance].userDetail.Liked = NO;
  1739. }
  1740. [btnLike setImage:[UIImage imageNamed:@"like_hover_icon.png"] forState:UIControlStateNormal];
  1741. [btnDislike setImage:[UIImage imageNamed:@"unlike_hover_icon.png"] forState:UIControlStateNormal];
  1742. [self performSelectorOnMainThread:@selector(profileRequest) withObject:nil waitUntilDone:YES];
  1743. break;
  1744. case jDislikeQuery:
  1745. userDetail.Disliked = YES;
  1746. if(!userDetail.isFriend && userDetail.userId == 0) {
  1747. [ApplicationData sharedInstance].userDetail.Disliked = YES;
  1748. }
  1749. [btnLike setImage:[UIImage imageNamed:@"like_hover_icon.png"] forState:UIControlStateNormal];
  1750. [btnDislike setImage:[UIImage imageNamed:@"like_hover_icon.png"] forState:UIControlStateNormal];
  1751. [self performSelectorOnMainThread:@selector(profileRequest) withObject:nil waitUntilDone:YES];
  1752. break;
  1753. case jlikeUnlikeQuery:
  1754. wallRecord.liked = !wallRecord.liked;
  1755. if (wallRecord.liked) {
  1756. wallRecord.likes++;
  1757. }
  1758. else {
  1759. wallRecord.likes--;
  1760. }
  1761. [tableView reloadData];
  1762. default:
  1763. break;
  1764. }
  1765. // break;
  1766. //
  1767. // default:
  1768. // break;
  1769. // }
  1770. tableView.userInteractionEnabled = YES;
  1771. self.navigationItem.rightBarButtonItem.enabled = YES;
  1772. self.navigationItem.leftBarButtonItem.enabled = YES;
  1773. }
  1774.  
  1775. -(void)addfriend{
  1776. [self showAlert:NSLocalizedString(@"Success",@"") Content:NSLocalizedString(@"approval_msg", @"")];
  1777. }
  1778.  
  1779. - (void)openLoginView {
  1780.  
  1781. LoginViewController *controller = [[LoginViewController alloc] init];
  1782. userDetail = nil;
  1783. userDetail.avatarImg = nil;
  1784. [ApplicationData sharedInstance].userDetail.avatarImg = nil;
  1785. int k = [controller LogincheckDict];
  1786. if (k == 1) {
  1787.  
  1788. [controller LoginDone];
  1789. [self viewWillAppear:NO];
  1790. }
  1791. else if (k==2)
  1792. {
  1793. [controller FBLoginDone];
  1794. [self viewWillAppear:NO];
  1795. }
  1796. else
  1797. {
  1798. [self presentModalViewController:controller animated:YES];
  1799. }
  1800. [controller release];
  1801. }
  1802.  
  1803. #pragma mark --
  1804. #pragma mark add Functions
  1805.  
  1806. - (void)addNew{
  1807.  
  1808. if(![spinner isAnimating])
  1809. {
  1810.  
  1811. [spinner startAnimating];
  1812.  
  1813. NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
  1814. [postVariables setObject:[NSString stringWithFormat:@"%d",userDetail.userId] forKey:@"memberID"];
  1815. [postVariables setObject:[NSString stringWithFormat:@"%@",msg.text] forKey:@"message"];
  1816.  
  1817. NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"friend" ExtTask:@"addFriend" TaskdataDictionary:postVariables Imagedata:nil];
  1818.  
  1819. [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
  1820. currentRequestType = jAddFriendQuery;
  1821. if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
  1822. [self requestCompleted];
  1823.  
  1824. }else {
  1825. self.view.userInteractionEnabled = YES;
  1826. }
  1827.  
  1828.  
  1829. }
  1830. }
  1831.  
  1832. #pragma mark --
  1833. #pragma mark alert
  1834.  
  1835.  
  1836.  
  1837. - (void)showAlert:(NSString *)title Content:(NSString *)bodyText {
  1838. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:bodyText
  1839. delegate:self cancelButtonTitle:NSLocalizedString(@"alert_cancel_btn_title",@"") otherButtonTitles: nil];
  1840. [alert setContentMode:UIViewContentModeScaleAspectFit];
  1841. [alert show];
  1842. [alert release];
  1843. }
  1844.  
  1845.  
  1846. - (void)setUserData {
  1847. DLog(@"friends:%d pics:%d album:%d",userDetail.TotalFriends,userDetail.TotalPhotos,userDetail.totalAlbum);
  1848. lblFriends.text = [NSString stringWithFormat:@"%d",userDetail.TotalFriends];
  1849. lblViews.text = [NSString stringWithFormat:@"%@ %d",NSLocalizedString(@"Views_title",@"") ,userDetail.viewCount];
  1850. lblPhotos.text = [NSString stringWithFormat:@"%d",userDetail.TotalPhotos];
  1851. lblVideos.text = [NSString stringWithFormat:@"%d",userDetail.totalAlbum];
  1852. if([userDetail avatarImg] && !isImageUpdated) {
  1853. userImg.image = [userDetail avatarImg];
  1854. }
  1855. else
  1856. {
  1857. if (!isImageUpdated) {
  1858. [self performSelectorOnMainThread:@selector(sendImageRequest) withObject:nil waitUntilDone:YES];
  1859. }
  1860.  
  1861. }
  1862. if(!userDetail.isFriend && userDetail.userId == 0)
  1863. {
  1864. DLog(@"like:%d Dislike:%d",userDetail.Liked,userDetail.Disliked);
  1865. userDetail = [ApplicationData sharedInstance].userDetail;
  1866. }
  1867. DLog(@"likes:%d",userDetail.Likes);
  1868. DLog(@"Dislikes:%d",userDetail.Dislikes);
  1869. if (userDetail.userId != 0) {
  1870. btnPhotos.hidden = YES;
  1871. btnVideos.hidden = YES;
  1872. btnEvents.hidden = YES;
  1873. }else {
  1874. btnPhotos.hidden = NO;
  1875. btnVideos.hidden = NO;
  1876. btnEvents.hidden = YES;
  1877. }
  1878. if([ApplicationData sharedInstance].frndCount != 0)
  1879. {
  1880. [btnFriendCount setTitle:[NSString stringWithFormat:@"%d",[ApplicationData sharedInstance].frndCount] forState:UIControlStateNormal];
  1881. }
  1882. else
  1883. {
  1884. btnFriendCount.hidden = YES;
  1885. }
  1886.  
  1887. if([ApplicationData sharedInstance].msgCount != 0)
  1888. {
  1889. [btnMsgCount setTitle:[NSString stringWithFormat:@"%d",[ApplicationData sharedInstance].msgCount] forState:UIControlStateNormal];
  1890. }
  1891. else
  1892. {
  1893. btnMsgCount.hidden = YES;
  1894. }
  1895.  
  1896. if([ApplicationData sharedInstance].groupCount != 0)
  1897. {
  1898. [btnGroupCount setTitle:[NSString stringWithFormat:@"%d",[ApplicationData sharedInstance].groupCount] forState:UIControlStateNormal];
  1899.  
  1900. }
  1901. else
  1902. {
  1903. btnGroupCount.hidden = YES;
  1904. }
  1905.  
  1906. if (userDetail.Dislikes == 0)
  1907. {
  1908. //lblDislikeCount.hidden = YES;
  1909. lblDislikeCount.text = [NSString stringWithFormat:@"%d",userDetail.Dislikes];
  1910. }
  1911. else
  1912. {
  1913.  
  1914. if (userDetail.Dislikes == 1)
  1915. {
  1916. //lblDislikeCount.text = [NSString stringWithFormat:@"%d Dislike",userDetail.Dislikes];
  1917. lblDislikeCount.text = [NSString stringWithFormat:@"%d",userDetail.Dislikes];
  1918. }
  1919. else
  1920. {
  1921. //lblDislikeCount.text = [NSString stringWithFormat:@"%d Dislikes",userDetail.Dislikes];
  1922. lblDislikeCount.text = [NSString stringWithFormat:@"%d",userDetail.Dislikes];
  1923. }
  1924. lblDislikeCount.hidden = YES;
  1925. }
  1926.  
  1927.  
  1928. lblLikeCount.text = [NSString stringWithFormat:@"%d",userDetail.Likes];
  1929.  
  1930. if (!userDetail.isLikeAllowed) {
  1931. btnLike.hidden = YES;
  1932. btnDislike.hidden = YES;
  1933. }else {
  1934. btnLike.hidden = NO;
  1935. btnDislike.hidden = NO;
  1936. }
  1937.  
  1938. if (userDetail.Liked) {
  1939. [btnLike setImage: [UIImage imageNamed:@"unlike_hover_icon.png"] forState:UIControlStateNormal];
  1940. }else {
  1941. [btnLike setImage:[UIImage imageNamed:@"like_hover_icon.png"] forState:UIControlStateNormal];
  1942.  
  1943. }
  1944.  
  1945. if (userDetail.Disliked)
  1946. {
  1947. [btnDislike setImage:[UIImage imageNamed:@"like_hover_icon.png"] forState:UIControlStateNormal];
  1948. }
  1949. else
  1950. {
  1951. [btnDislike setImage:[UIImage imageNamed:@"unlike_hover_icon.png"] forState:UIControlStateNormal];
  1952. }
  1953. if (!isImageUpdated) {
  1954.  
  1955. name.text = [userDetail userName];
  1956.  
  1957.  
  1958. }
  1959. if([statusMsg.text length] == 0 || !self.editing)
  1960. {
  1961.  
  1962. if ([ApplicationData sharedInstance].isprofile_video) {
  1963. [self performSelectorOnMainThread:@selector(profileRequest) withObject:nil waitUntilDone:YES];
  1964. }
  1965. [ApplicationData sharedInstance].isprofile_video = NO;
  1966. statusMsg.text = [userDetail status];
  1967. CGSize stringsize1 = [[userDetail status] sizeWithFont:[statusMsg font]];
  1968.  
  1969.  
  1970. lblvideoMsg.text = [userDetail.profile_video objectForKey:@"title"];
  1971. stringsize1 = [[userDetail.profile_video objectForKey:@"title"] sizeWithFont:[lblvideoMsg font]];
  1972.  
  1973. if (stringsize1.width > 255)
  1974. {
  1975. lblvideoMsg.frame = CGRectMake(lblvideoMsg.frame.origin.x, lblvideoMsg.frame.origin.y, (stringsize1.width + 10.0), lblvideoMsg.frame.size.height);
  1976. [scrvideoMsg setContentSize:(CGSizeMake((stringsize1.width + 15), 20))];
  1977. }
  1978. }
  1979.  
  1980. if (userDetail.coverImg) {
  1981. imgvw_cover.image = userDetail.coverImg;
  1982. }
  1983. else {
  1984. userDetail.coverImg = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[userDetail coverpicURL]]]];
  1985. imgvw_cover.image = userDetail.coverImg;
  1986. }
  1987.  
  1988. if ([ApplicationData sharedInstance].isReload) {
  1989. [ApplicationData sharedInstance].isReload = NO;
  1990. [self performSelectorOnMainThread:@selector(sendImageRequest) withObject:nil waitUntilDone:NO];
  1991. }
  1992. profileCount.text = [NSString stringWithFormat:@"%d", [userDetail viewCount]];
  1993. if([ApplicationData sharedInstance].isLoggedIn && userDetail.isFriend) {
  1994. self.navigationItem.rightBarButtonItem = nil;
  1995. btnEdit.hidden = YES;
  1996. }
  1997. if (userDetail.userId == 0)
  1998. {
  1999. btnfriend.hidden = YES;
  2000. btnEdit.hidden = NO;
  2001. btncoverphoto.hidden = NO;
  2002. //btnmessage.frame = CGRectMake(26, 263, 268, 30);
  2003. //[btnmessage setBackgroundImage:[UIImage imageNamed:@"Lea_mesaage_box.png"] forState:UIControlStateNormal];
  2004. }
  2005. else
  2006. {
  2007. btncoverphoto.hidden = YES;
  2008. //[btnmessage setBackgroundImage:[UIImage imageNamed:@"Lea_friend_btn.png"] forState:UIControlStateNormal];
  2009. if (!userDetail.isFriend) {
  2010. btnfriend.hidden = NO;
  2011. [btnfriend setTitle:NSLocalizedString(@"addFriend", @"") forState:UIControlStateNormal];
  2012. [btnfriend removeTarget:self action:@selector(removeFriendButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  2013. [btnfriend addTarget:self action:@selector(addFriendButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  2014. //btnmessage.frame = CGRectMake(169, 263, 118, 30);
  2015. //btnfriend.frame = CGRectMake(34, 263, 118, 30);
  2016. }else {
  2017. btnfriend.hidden = NO;
  2018. [btnfriend setTitle:NSLocalizedString(@"already_friend", @"") forState:UIControlStateNormal];
  2019. [btnfriend removeTarget:self action:@selector(addFriendButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  2020. [btnfriend addTarget:self action:@selector(removeFriendButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  2021. //btnmessage.frame = CGRectMake(169, 263, 118, 30);
  2022. //btnfriend.frame = CGRectMake(34, 263, 118, 30);
  2023. }
  2024. }
  2025. if ([userDetail.wallList count] > 0) {
  2026. tempArray = userDetail.wallList;
  2027. [tableView reloadData];
  2028. [self loadImagesForUsers];
  2029. [spinner stopAnimating];
  2030. } else {
  2031. if (![spinner isAnimating]) {
  2032. [spinner startAnimating];
  2033. }
  2034. [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(fetchWall) userInfo:nil repeats:NO];
  2035. }
  2036. if (lblvideoMsg.text.length == 0) {
  2037. imgVideo.hidden = YES;
  2038. scrvideoMsg.hidden = YES;
  2039. }else {
  2040. imgVideo.hidden = NO;
  2041. scrvideoMsg.hidden = NO;
  2042. }
  2043. }
  2044.  
  2045. - (void)embedYouTube:(NSString *)urlString frame:(CGRect)frame {
  2046.  
  2047. NSString *embedHTML;
  2048.  
  2049. NSString *html;
  2050.  
  2051. if ([[[UIDevice currentDevice]systemVersion]floatValue] >= 5.0) {
  2052.  
  2053. embedHTML = @"\
  2054. <html><head>\
  2055. <style type=\"text/css\">\
  2056. body {\
  2057. background-color: transparent;\
  2058. color: white;\
  2059. }\
  2060. </style>\
  2061. </head><body style=\"margin:0\">\
  2062. <iframe title=\"YouTube Video\" class=\"youtube-player\" type=\"text/html\"\
  2063. width=\"%0.0f\" height=\"%0.0f\" src=\"%@\"\
  2064. frameborder=\"0\" allowFullScreen ></iframe>";
  2065. NSArray *selectedOptions = [urlString componentsSeparatedByString:@"v="];
  2066.  
  2067.  
  2068. if ([selectedOptions count] != 1) {
  2069. urlString = [NSString stringWithFormat:@"http://www.youtube.com/embed/%@",[[selectedOptions objectAtIndex:1] substringToIndex:11]];
  2070. }
  2071.  
  2072. if ([selectedOptions count]== 1) {
  2073. selectedOptions = [urlString componentsSeparatedByString:@".be/"];
  2074. urlString = [NSString stringWithFormat:@"http://www.youtube.com/embed/%@",[[selectedOptions objectAtIndex:1] substringToIndex:11]];
  2075. }
  2076. NSString *myString = @"?showinfo=0";
  2077. urlString = [urlString stringByAppendingString:myString];
  2078.  
  2079. html = [NSString stringWithFormat: embedHTML, frame.size.width,frame.size.height, urlString];
  2080.  
  2081. // [youtubeThumbnail loadHTMLString:html baseURL:nil];
  2082. [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlString]]];
  2083.  
  2084. }else{
  2085. embedHTML = @"\
  2086. <html><head>\
  2087. <style type=\"text/css\">\
  2088. body {\
  2089. background-color: transparent;\
  2090. color: white;\
  2091. }\
  2092. </style>\
  2093. </head><body style=\"margin:0\">\
  2094. <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
  2095. width=\"%0.0f\" height=\"%0.0f\"></embed>\
  2096. </body></html>";
  2097. html = [NSString stringWithFormat:embedHTML, urlString, frame.size.width, frame.size.height];
  2098. [webView loadHTMLString:html baseURL:nil];
  2099. }
  2100. }
  2101.  
  2102.  
  2103. #pragma mark --
  2104. #pragma mark image upload & downloader
  2105. - (IBAction) LikePressed:(id)sender
  2106. {
  2107. [spinner stopAnimating];
  2108. if (userDetail.Liked)
  2109. {
  2110. [spinner startAnimating];
  2111. [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(UnLike) userInfo:nil repeats:NO];
  2112. }
  2113. else
  2114. {
  2115. [spinner startAnimating];
  2116. [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(Like) userInfo:nil repeats:NO];
  2117. }
  2118. }
  2119.  
  2120. - (IBAction)DislikePressed:(id)sender
  2121. {
  2122. [spinner stopAnimating];
  2123. if (userDetail.Disliked)
  2124. {
  2125. [spinner startAnimating];
  2126. [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(UnLike) userInfo:nil repeats:NO];
  2127. }
  2128. else
  2129. {
  2130. [spinner startAnimating];
  2131. [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(DisLike) userInfo:nil repeats:NO];
  2132. }
  2133. }
  2134.  
  2135. -(void)Like {
  2136. NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
  2137. [postVariables setObject:[NSString stringWithFormat:@"%d",userDetail.userId] forKey:@"userID"];
  2138.  
  2139. NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"user" ExtTask:@"like" TaskdataDictionary:postVariables Imagedata:nil];
  2140.  
  2141. [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
  2142. currentRequestType = jLikeQuery;
  2143. if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
  2144. [self requestCompleted];
  2145. }else {
  2146. self.view.userInteractionEnabled = YES;
  2147. }
  2148. }
  2149.  
  2150. -(void)UnLike {
  2151. NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
  2152. [postVariables setObject:[NSString stringWithFormat:@"%d",userDetail.userId] forKey:@"userID"];
  2153.  
  2154. NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"user" ExtTask:@"unlike" TaskdataDictionary:postVariables Imagedata:nil];
  2155. [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
  2156. currentRequestType = jUnlikeQuery;
  2157. if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
  2158. [self requestCompleted];
  2159. }else {
  2160. self.view.userInteractionEnabled = YES;
  2161. }
  2162. }
  2163.  
  2164. -(void)DisLike {
  2165. NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
  2166. [postVariables setObject:[NSString stringWithFormat:@"%d",userDetail.userId] forKey:@"userID"];
  2167. NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"user" ExtTask:@"dislike" TaskdataDictionary:postVariables Imagedata:nil];
  2168. [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
  2169. currentRequestType = jDislikeQuery;
  2170. if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
  2171. [self requestCompleted];
  2172. }else {
  2173. self.view.userInteractionEnabled = YES;
  2174. }
  2175. }
  2176.  
  2177.  
  2178. - (void)sendImageRequest {
  2179.  
  2180. IconDownloader *iconDownloader = [imageDownloadsInProgress objectForKey:[userDetail avatarURL]];
  2181. DLog(@"Download Avatar Image : %@", [userDetail avatarURL]);
  2182. if (iconDownloader == nil)
  2183. {
  2184.  
  2185. [spinner startAnimating];
  2186.  
  2187. iconDownloader = [[IconDownloader alloc] init];
  2188. iconDownloader.appRecord = userDetail;
  2189. iconDownloader.delegate = self;
  2190. iconDownloader.imageKey = [userDetail avatarURL];
  2191. [imageDownloadsInProgress setObject:iconDownloader forKey:[userDetail avatarURL]];
  2192. [iconDownloader startDownload];
  2193. [iconDownloader release];
  2194. }
  2195. }
  2196.  
  2197. - (void)sendImageUploadRequest:(UIImage *)uploadImg {
  2198. if (![spinner isAnimating]) {
  2199. [spinner startAnimating];
  2200. }
  2201.  
  2202. if(uploadImg) {
  2203. NSData *imgData = UIImageJPEGRepresentation(uploadImg, 1.0);
  2204.  
  2205. NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
  2206. [postVariables setObject:name.text forKey:@"name"];
  2207. NSString *jsonString = [Jomsocial CreateDictionary_joomsocial:@"user" ExtTask:@"updateProfile" TaskdataDictionary:postVariables Imagedata:imgData];
  2208. NSDictionary *dict = [JoomlaRegistration JoomSocialDictionary:jsonString Imagedata:imgData];
  2209. [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
  2210. currentRequestType = jGeneralQuery;
  2211.  
  2212. if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
  2213. [self requestCompleted];
  2214. }else {
  2215. self.view.userInteractionEnabled = YES;
  2216. }
  2217.  
  2218.  
  2219. } else if (![statusMsg.text isEqualToString:userDetail.status] || ![name.text isEqualToString:userDetail.userName]) {
  2220. NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
  2221. [postVariables setObject:name.text forKey:@"name"];
  2222.  
  2223. NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"user" ExtTask:@"updateProfile" TaskdataDictionary:postVariables Imagedata:nil];
  2224.  
  2225. [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
  2226. currentRequestType = jGeneralQuery;
  2227. if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
  2228. [self requestCompleted];
  2229. }else {
  2230. self.view.userInteractionEnabled = YES;
  2231. }
  2232.  
  2233. } else {
  2234. [self cancelButtonPressed:nil];
  2235. return;
  2236. }
  2237. }
  2238.  
  2239. #pragma mark -
  2240. #pragma mark editing
  2241.  
  2242. - (void)setEditing:(BOOL)editing animated:(BOOL)animated{
  2243. if(![spinner isAnimating]) {
  2244. if (editing)
  2245. {
  2246. self.navigationItem.leftBarButtonItem.title = NSLocalizedString(@"button_cancel",@"");
  2247. update=TRUE;
  2248.  
  2249. changeImg.hidden = FALSE;
  2250. userImage = nil;
  2251. }
  2252. else
  2253. {
  2254. if([name.text isEqualToString:@""]){
  2255. [self showAlert:NSLocalizedString(@"invalid",@"") Content:NSLocalizedString(@"invalid_msg",@"")];
  2256. [spinner stopAnimating];
  2257. name.text = userDetail.userName;
  2258.  
  2259. }
  2260. else if(!quit) {
  2261. self.navigationItem.leftBarButtonItem.enabled = FALSE;
  2262. tableView.userInteractionEnabled = FALSE;
  2263. self.navigationItem.rightBarButtonItem.enabled = FALSE;
  2264. [self sendImageUploadRequest:userImage];
  2265. }
  2266. self.navigationItem.leftBarButtonItem.title = NSLocalizedString(@"button_logout",@"");
  2267. update = FALSE;
  2268. changeImg.hidden = TRUE;
  2269. // [statusMsg setBorderStyle:UITextBorderStyleNone];
  2270. quit= FALSE;
  2271. //statusMsg.textColor = [ApplicationData sharedInstance].textcolor;
  2272. }
  2273.  
  2274. [super setEditing:editing animated:animated];
  2275. }
  2276. }
  2277.  
  2278. #pragma mark -
  2279. #pragma mark UIButton Events
  2280.  
  2281. - (IBAction)openGallery:(id) sender {
  2282. if ([sender isEqual:changeImg]) {
  2283. isProfilePic = YES;
  2284. }else {
  2285. isProfilePic = NO;
  2286. }
  2287. UIActionSheet *actionSheet;
  2288. if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == YES) {
  2289. actionSheet = [[UIActionSheet alloc]
  2290. initWithTitle:NSLocalizedString(@"addPic",@"")
  2291. delegate:self
  2292. cancelButtonTitle:nil
  2293. destructiveButtonTitle:NSLocalizedString(@"button_cancel",@"")
  2294. otherButtonTitles:NSLocalizedString(@"gallery",@""),NSLocalizedString(@"cam",@""),nil];
  2295. } else {
  2296. actionSheet = [[UIActionSheet alloc]
  2297. initWithTitle:NSLocalizedString(@"addPic",@"")
  2298. delegate:self
  2299. cancelButtonTitle:nil
  2300. destructiveButtonTitle:NSLocalizedString(@"button_cancel",@"")
  2301. otherButtonTitles:NSLocalizedString(@"gallery",@""),nil];
  2302. }
  2303. actionSheet.tag = 1;
  2304.  
  2305. actionSheet.alpha = 1.0;
  2306. [actionSheet showInView:self.view]; //showInView:self.view]; // show from our tabbar view (pops up in the middle of the tabbar)
  2307. [actionSheet release];
  2308.  
  2309. }
  2310.  
  2311. - (IBAction)editButtonPressed:(id)sender {
  2312. /*if(![spinner isAnimating]) {
  2313. [btnEdit setTitle:NSLocalizedString(@"button_done", @"") forState:UIControlStateNormal];
  2314. [btnEdit removeTarget:self action:@selector(editButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  2315. [btnEdit addTarget:self action:@selector(doneButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  2316. self.navigationItem.leftBarButtonItem = btnCancel;
  2317. name.backgroundColor = [UIColor whiteColor];
  2318. name.enabled = TRUE;
  2319. name.userInteractionEnabled = YES;
  2320. name.placeholder = NSLocalizedString(@"status_msg", @"Status Message");
  2321. [name setBorderStyle:UITextBorderStyleRoundedRect];
  2322. name.textColor=[ApplicationData sharedInstance].inputtxtColor;
  2323. changeImg.hidden = FALSE;
  2324. userImage = nil;
  2325. } */
  2326.  
  2327. MoreUserSettingsController *controller = [[MoreUserSettingsController alloc] init];
  2328. controller.userDetail = userDetail;
  2329. [[self navigationController] pushViewController:controller animated:YES];
  2330. }
  2331.  
  2332. - (IBAction)doneButtonPressed:(id)sender {
  2333. if(![spinner isAnimating]) {
  2334. [spinner startAnimating];
  2335. if([name.text isEqualToString:@""]){
  2336. [self showAlert:NSLocalizedString(@"invalid",@"") Content:NSLocalizedString(@"invalid_msg",@"")];
  2337. [spinner stopAnimating];
  2338.  
  2339. name.text = userDetail.userName;
  2340.  
  2341. } else {
  2342. name.userInteractionEnabled = NO;
  2343. [[name findFirstResponder]resignFirstResponder];
  2344. timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(profileUpdate) userInfo:nil repeats:NO];
  2345.  
  2346. }
  2347. changeImg.hidden = TRUE;
  2348. statusMsg.backgroundColor = [UIColor clearColor];
  2349. //statusMsg.textColor = [ApplicationData sharedInstance].textcolor;
  2350. [name setBorderStyle:UITextBorderStyleNone];
  2351. name.backgroundColor = [UIColor clearColor];
  2352. //name.textColor = [ApplicationData sharedInstance].textcolor;
  2353. }
  2354. }
  2355.  
  2356. - (void) profileUpdate {
  2357. [self sendImageUploadRequest:userImage];
  2358. }
  2359.  
  2360. - (IBAction)FriendsButtonPressed:(id)sender {
  2361. FriendsViewController *controller = [[FriendsViewController alloc]init];
  2362. controller.userDetail = userDetail;
  2363. [ApplicationData sharedInstance].totalFriends = 0;
  2364. [self.navigationController pushViewController:controller animated:YES];
  2365. [controller release];
  2366. }
  2367.  
  2368. - (IBAction)MessageButtonPressed:(id)sender {
  2369. if (userDetail.userId == 0) {
  2370. MessageViewController *controller = [[MessageViewController alloc]init];
  2371. [self.navigationController pushViewController:controller animated:YES];
  2372. [controller release];
  2373. }else {
  2374. WriteMessageViewController *controller = [[WriteMessageViewController alloc]init];
  2375. controller.userID = userDetail.userId;
  2376. controller.recipient = userDetail.userName;
  2377. [ApplicationData sharedInstance].recipient = userDetail.userName;
  2378. [ApplicationData sharedInstance].selectedFriend = [NSString stringWithFormat:@"%d",userDetail.userId];
  2379. controller.frndName = userDetail.userName;
  2380. controller.select = FALSE;
  2381. [self.navigationController pushViewController:controller animated:YES];
  2382. [controller release];
  2383. }
  2384. }
  2385.  
  2386. - (IBAction)PhotosButtonPressed:(id)sender
  2387. {
  2388. [ApplicationData sharedInstance].flag_cov_photo = 0;
  2389. AlbumsViewController *controller = [[AlbumsViewController alloc]init];
  2390. controller.userObj = userDetail;
  2391. [self.navigationController pushViewController:controller animated:YES];
  2392. [controller release];
  2393. }
  2394.  
  2395. - (IBAction)CoverPhotosButtonPressed:(id)sender
  2396. {
  2397. [ApplicationData sharedInstance].flag_cov_photo = 1;
  2398. [ApplicationData sharedInstance].cover_photo_TYPE=1;
  2399. AlbumsViewController *controller = [[AlbumsViewController alloc]init];
  2400. controller.userObj = userDetail;
  2401. [self.navigationController pushViewController:controller animated:YES];
  2402. [controller release];
  2403. }
  2404.  
  2405. -(IBAction)VideosButtonPressed:(id)sender {
  2406. VideoViewController *controller = [[VideoViewController alloc]init];
  2407. controller.userDetail = userDetail;
  2408. [self.navigationController pushViewController:controller animated:YES];
  2409. [controller release];
  2410. }
  2411.  
  2412. - (IBAction)UserDetailButtonPressed:(id)sender {
  2413. UserDetailViewController *controller = [[UserDetailViewController alloc]init];
  2414. controller.userDetail = self.userDetail;
  2415. [self.navigationController pushViewController:controller animated:YES];
  2416. [controller release];
  2417. }
  2418.  
  2419. - (IBAction)NotifPressed:(id)sender
  2420. {
  2421. notifView.hidden = !notifView.hidden;
  2422. if ([sender isEqual:btnFrndReq])
  2423. {
  2424.  
  2425. if (notifController.isMsg || notifController.isGroup)
  2426. {
  2427. notifController.isMsg = NO;
  2428. notifController.isGroup = NO;
  2429. notifController.isFriend = YES;
  2430. notifView.hidden = NO;
  2431. [notifController.tableView reloadData];
  2432. }
  2433. else if(notifController.isFriend)
  2434. {
  2435. notifController.isFriend = NO;
  2436. notifView.hidden = YES;
  2437. }
  2438. else
  2439. {
  2440. notifController.isFriend = YES;
  2441. notifView.hidden = NO;
  2442.  
  2443. [notifController.tableView reloadData];
  2444. }
  2445. }
  2446. else if ([sender isEqual:btnMessage])
  2447. {
  2448. if (notifController.isFriend || notifController.isGroup)
  2449. {
  2450. notifController.isFriend = NO;
  2451. notifController.isGroup = NO;
  2452. notifController.isMsg = YES;
  2453. notifView.hidden = NO;
  2454. [notifController.tableView reloadData];
  2455. }
  2456. else if(notifController.isMsg)
  2457. {
  2458. notifController.isMsg = NO;
  2459. notifView.hidden = YES;
  2460. }
  2461. else
  2462. {
  2463. notifController.isMsg = YES;
  2464. notifView.hidden = NO;
  2465. [notifController.tableView reloadData];
  2466. }
  2467. }
  2468. else if ([sender isEqual:btnGroup])
  2469. {
  2470. if (notifController.isFriend || notifController.isMsg)
  2471. {
  2472. notifController.isFriend = NO;
  2473. notifController.isMsg = NO;
  2474. notifController.isGroup = YES;
  2475. notifView.hidden = NO;
  2476. [notifController.tableView reloadData];
  2477. }
  2478. else if(notifController.isGroup)
  2479. {
  2480. notifController.isGroup = NO;
  2481. notifView.hidden = YES;
  2482. }
  2483. else
  2484. {
  2485. notifController.isGroup = YES;
  2486. notifView.hidden = NO;
  2487. [notifController.tableView reloadData];
  2488. }
  2489. }
  2490. }
  2491.  
  2492. - (IBAction)cancelButtonPressed:(id)sender {
  2493. iJoomerAppDelegate *appdelegate = (iJoomerAppDelegate *) [[UIApplication sharedApplication] delegate];
  2494. appdelegate.viewTop.hidden = NO;
  2495. appdelegate.TabView.hidden = YES;
  2496. self.navigationItem.rightBarButtonItem = nil;
  2497. self.navigationItem.hidesBackButton = NO;
  2498. webView.hidden = YES;
  2499. if([spinner isAnimating]) {
  2500. if(currentRequestType == jGeneralQuery) {
  2501. [imageUploader cancelUpload];
  2502. imageUploader = nil;
  2503. }
  2504.  
  2505. progressBar.hidden = YES;
  2506. [spinner stopAnimating];
  2507.  
  2508. userImg.alpha = 1.0;
  2509. userImage = nil;
  2510.  
  2511. }
  2512. [btnEdit setTitle:NSLocalizedString(@"button_edit", @"") forState:UIControlStateNormal];
  2513. [btnEdit removeTarget:self action:@selector(doneButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  2514. [btnEdit addTarget:self action:@selector(editButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  2515. self.navigationItem.leftBarButtonItem = nil;
  2516. btnEdit.hidden = NO;
  2517. statusMsg.backgroundColor = [UIColor clearColor];
  2518. //statusMsg.textColor = [UIColor blackColor];//[ApplicationData sharedInstance].textcolor;
  2519. [statusMsg setText:userDetail.status];
  2520. name.backgroundColor = [UIColor clearColor];
  2521. name.enabled = NO;
  2522. [name setBorderStyle:UITextBorderStyleNone];
  2523. //name.textColor = [ApplicationData sharedInstance].textcolor;
  2524. [name setText:userDetail.userName];
  2525. changeImg.hidden = YES;
  2526. if (userDetail.avatarImg) {
  2527. userImg.image = userDetail.avatarImg;
  2528. } else {
  2529. userImg.image = [UIImage imageNamed:@"the face.png"];
  2530. }
  2531.  
  2532. }
  2533.  
  2534. - (IBAction)addFriendButtonPressed:(id)sender {
  2535. if(![spinner isAnimating]) {
  2536. if(!userDetail.pending) {
  2537. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Message", @"") message:@"\n" delegate:self cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"button_add", @""), NSLocalizedString(@"button_cancel", @""),nil];
  2538. msg = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
  2539. [msg setBorderStyle:UITextBorderStyleRoundedRect];
  2540. [msg setPlaceholder:NSLocalizedString(@"addfriend_msg", @"")];
  2541. msg.delegate = self;
  2542. alert.tag = 1;
  2543. alert.alertViewStyle = UIAlertViewStylePlainTextInput;
  2544. [alert textFieldAtIndex:0];
  2545. //[alert setTransform:CGAffineTransformMakeTranslation(0.0, 110.0)];
  2546. [msg becomeFirstResponder];
  2547. [alert show];
  2548. [alert release];
  2549. }
  2550. else {
  2551. [self showAlert:NSLocalizedString(@"Pending",@"") Content:NSLocalizedString(@"waiting", @"waiting msg")];
  2552. }
  2553. }
  2554. }
  2555.  
  2556. - (IBAction)removeFriendButtonPressed:(id)sender {
  2557. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"r_u_sure",@"") message:NSLocalizedString(@"sure_remove",@"") delegate:self cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"lblNo", @"No"), NSLocalizedString(@"lblYes", @"Yes"), nil];
  2558. alert.tag = 8;
  2559. [alert show];
  2560. [alert release];
  2561. }
  2562. //for photo caption
  2563.  
  2564. - (IBAction)PhotocaptionButtonPressed{
  2565. [ApplicationData sharedInstance].VoicePhotocaption = 9999;
  2566. btnPhotocaption.hidden = YES;
  2567. [txtPhotoCaption becomeFirstResponder];
  2568. CGPoint tableViewCenter = [tableView contentOffset];
  2569. tableViewCenter.y += tableView.frame.size.height/2;
  2570. [tableView setContentOffset:CGPointMake(0,tableViewCenter.y) animated:YES];
  2571. }
  2572.  
  2573. - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
  2574.  
  2575. if (actionSheet.tag == 1) {
  2576. photoSelectIndex = 999;
  2577. if (buttonIndex == 0){
  2578.  
  2579. }
  2580. else if (buttonIndex == 1){
  2581. [self openGallery];
  2582.  
  2583. }
  2584. else if (buttonIndex == 2){
  2585. [self openCamera];
  2586. }
  2587. }else if (actionSheet.tag == 888) {
  2588.  
  2589. photoSelectIndex = 888;
  2590.  
  2591. if (buttonIndex == 0){
  2592.  
  2593. }
  2594. else if (buttonIndex == 1){
  2595. [self openGallery];
  2596.  
  2597. }
  2598. else if (buttonIndex == 2){
  2599. [self openCamera];
  2600. }
  2601. }
  2602.  
  2603. else if (actionSheet.tag == 2) {
  2604. if (buttonIndex == 0)
  2605. {
  2606. [self logoutProcess];
  2607. }
  2608. else if(buttonIndex == 1){
  2609. }
  2610. }else if(actionSheet.tag == 4 && buttonIndex == 0) {
  2611. [btnPermission setTitle:[permissions objectAtIndex:rowIndex] forState:UIControlStateNormal];
  2612. if ([btnPermission.titleLabel.text isEqualToString:NSLocalizedString(@"Public_title",@"")]) {
  2613. permissionValue = 0;
  2614. }else if ([btnPermission.titleLabel.text isEqualToString:NSLocalizedString(@"sitemember_title",@"")]) {
  2615. permissionValue = 20;
  2616. }else if ([btnPermission.titleLabel.text isEqualToString:NSLocalizedString(@"friends_title",@"")]) {
  2617. permissionValue = 30;
  2618. }else if ([btnPermission.titleLabel.text isEqualToString:NSLocalizedString(@"onlyme_title",@"")]) {
  2619. permissionValue = 40;
  2620. }
  2621. }
  2622. }
  2623.  
  2624. - (void)openCamera {
  2625.  
  2626. iJoomerAppDelegate *appdelegate = (iJoomerAppDelegate *) [[UIApplication sharedApplication] delegate];
  2627. appdelegate.viewTop.hidden = YES;
  2628. appdelegate.TabView.hidden = YES;
  2629. UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
  2630. imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
  2631. imagePicker.delegate = self;
  2632. imagePicker.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
  2633. [self presentModalViewController:imagePicker animated:YES];
  2634. [imagePicker release];
  2635. }
  2636.  
  2637. - (void)openGallery{
  2638. iJoomerAppDelegate *appdelegate = (iJoomerAppDelegate *) [[UIApplication sharedApplication] delegate];
  2639. appdelegate.viewTop.hidden = YES;
  2640. appdelegate.TabView.hidden = YES;
  2641. appdelegate.BtnSideMenu.hidden = YES;
  2642. UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
  2643. imagePicker.delegate = self;
  2644. imagePicker.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
  2645. [self presentModalViewController:imagePicker animated:YES];
  2646. [imagePicker release];
  2647. }
  2648.  
  2649. - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
  2650. iJoomerAppDelegate *appdelegate = (iJoomerAppDelegate *) [[UIApplication sharedApplication] delegate];
  2651. appdelegate.viewTop.hidden = NO;
  2652. appdelegate.TabView.hidden = YES;
  2653. UIImage *selectedImage = [info objectForKey:UIImagePickerControllerOriginalImage];
  2654. CGSize size = selectedImage.size;
  2655. CGFloat ratio = 0;
  2656. if((selectedImage.size.height > 480) || (selectedImage.size.width > 320)){
  2657. if (size.width > size.height) {
  2658. ratio = 320.0 / size.width;
  2659. }
  2660. else {
  2661. ratio = 480.0 / size.height;
  2662. }
  2663. CGRect rect = CGRectMake(0.0, 0.0, ratio * size.width, ratio * size.height);
  2664.  
  2665. UIGraphicsBeginImageContext(rect.size);
  2666. [selectedImage drawInRect:rect];
  2667. selectedImage = UIGraphicsGetImageFromCurrentImageContext();
  2668. }
  2669. userImage = [selectedImage retain];
  2670. PhotoPrevImage = [selectedImage retain];
  2671. imgPhotoPrev.image = selectedImage;
  2672.  
  2673. if (isProfilePic) {
  2674. [userImg setImage:selectedImage];
  2675. userImg.image = selectedImage;
  2676. isImageUpdated = YES;
  2677.  
  2678. }else {
  2679. [spinner startAnimating];
  2680. [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(photoUpload) userInfo:nil repeats:NO];
  2681. }
  2682. [self dismissModalViewControllerAnimated:YES];
  2683. }
  2684.  
  2685. - (IBAction)PhotocaptionSendButtonPressed{
  2686. [spinner startAnimating];
  2687. [txtPhotoCaption resignFirstResponder];
  2688. [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(photoUpload) userInfo:nil repeats:NO];
  2689. }
  2690. -(void)photoUpload {
  2691.  
  2692. if (txtPhotoCaption.text.length == 0) {
  2693. [self showAlert:NSLocalizedString(@"no_text",@"") Content:NSLocalizedString(@"photo_caption", @"")];
  2694. return;
  2695. }
  2696.  
  2697. NSData *imgData = UIImageJPEGRepresentation(userImage, 1.0);
  2698. NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
  2699. [postVariables setObject:@"0" forKey:@"isDefault"];
  2700. [postVariables setObject:txtPhotoCaption.text forKey:@"caption"];
  2701. [postVariables setObject:@"true" forKey:@"profile"];
  2702. NSString *jsonString = [Jomsocial CreateDictionary_joomsocial:@"media" ExtTask:@"uploadphoto" TaskdataDictionary:postVariables Imagedata:imgData];
  2703. NSDictionary *dict = [JoomlaRegistration JoomSocialDictionary:jsonString Imagedata:imgData];
  2704. [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
  2705. currentRequestType = jGeneralQuery;
  2706. if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
  2707. [self requestCompleted];
  2708. }else {
  2709. self.view.userInteractionEnabled = YES;
  2710. }
  2711. }
  2712. #pragma mark -
  2713. #pragma mark Table Functions
  2714.  
  2715. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView1 {
  2716. return 1;
  2717. }
  2718.  
  2719. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  2720.  
  2721.  
  2722. if(indexPath.row < [tempArray count])
  2723. {
  2724. Wall *record = [tempArray objectAtIndex:indexPath.row];
  2725. if([record.type isEqual:@""]){
  2726. return 130;
  2727. }else{
  2728. if([record.type isEqual:@"cover.upload"] || [record.type isEqual:@"profile.avatar.upload"] || [record.type isEqual:@"videos.linking"] || [record.type isEqual:@"videos"] || [record.type isEqual:@"events.avatar.upload"] ||[record.type isEqual:@"groups.avatar.upload"]){
  2729. return 260;
  2730. }else if([record.type isEqual:@"photos"]){
  2731. return 280;
  2732. }else{
  2733. return 130;
  2734. }
  2735.  
  2736. }
  2737.  
  2738. }else
  2739. {
  2740. return 44;
  2741. }
  2742.  
  2743.  
  2744.  
  2745.  
  2746.  
  2747. }
  2748.  
  2749. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  2750.  
  2751. DLog(@"count:%d",[tempArray count]);
  2752.  
  2753. int rows = [tempArray count];
  2754. if ([ApplicationData sharedInstance].totalWall > [tempArray count] ) {
  2755. rows = [tempArray count] + 1;
  2756. }
  2757. return rows;
  2758. return [tempArray count];
  2759.  
  2760.  
  2761. }
  2762.  
  2763. - (UITableViewCell *)tableView:(UITableView *)tableViewController cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  2764.  
  2765. if(indexPath.row < [tempArray count]) {
  2766. WallCell *cell;
  2767.  
  2768. // = (WallCell *)[tableView dequeueReusableCellWithIdentifier:kCellIdentifier];
  2769. wallRecord = [tempArray objectAtIndex:indexPath.row];
  2770. // if (cell == nil)
  2771. // {
  2772. // will check for the Wallcell customtableview
  2773. [cellOwner loadMyNibFile:kCellIdentifier];
  2774. cell = (WallCell *)cellOwner.cell;
  2775. [cell.btnCommentLike addTarget:self action:@selector(commentLikeButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  2776. [cell.btnComment addTarget:self action:@selector(commentButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  2777. [cell.btnLike addTarget:self action:@selector(likeButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  2778. [cell.btnUser addTarget:self action:@selector(userButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  2779. [cell.thumbnail addTarget:self action:@selector(videoButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  2780. [cell.btnUsersname addTarget:self action:@selector(userButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  2781. [cell.btnFrndName addTarget:self action:@selector(FriendNameButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  2782. [cell.btnDelete addTarget:self action:@selector(deleteWall:) forControlEvents:UIControlEventTouchUpInside];
  2783. [cell.btnPlay addTarget:self action:@selector(PlayTitleButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  2784. [cell.btnPlayContent addTarget:self action:@selector(PlayContentButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  2785. [cell.btnGoToQuestion addTarget:self action:@selector(simanswers:) forControlEvents:UIControlEventTouchUpInside];
  2786. cell.parentView = self;
  2787. // }
  2788. [self loadImagesForRows];
  2789.  
  2790. if (!wallRecord.isLikeAllowed && !wallRecord.isCommentAllowed) {
  2791. cell.backImg.frame = cell.frame;
  2792. }
  2793.  
  2794. if (!wallRecord.videoIcon && wallRecord.videoThumbUrl.length > 0)
  2795. {
  2796. [self performSelectorOnMainThread:@selector(startIconDownload3:) withObject:wallRecord waitUntilDone:NO];
  2797. }
  2798.  
  2799. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  2800.  
  2801. cell.btnUsername.hidden = YES;
  2802. cell.wallRecord = wallRecord;
  2803. if([cell.wallRecord.type isEqual:@"event"] || [cell.wallRecord.type isEqual:@"group"] ){
  2804. cell.btnUsername.hidden = NO;
  2805. }
  2806.  
  2807.  
  2808. if([cell.wallRecord.type isEqual:@"event"]){
  2809. [cell.btnUsername addTarget:self action:@selector(EventButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  2810. }else if ([cell.wallRecord.type isEqual:@"group"]){
  2811. [cell.btnUsername addTarget:self action:@selector(GroupButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  2812. }
  2813.  
  2814. cell.btnGoToQuestion.tag = (NSInteger)indexPath.row;
  2815. cell.btnCommentLike.tag = (NSInteger)indexPath.row;
  2816. cell.btnComment.tag = (NSInteger)indexPath.row;
  2817. cell.btnLike.tag = (NSInteger)indexPath.row;
  2818. cell.btnUser.tag = (NSInteger)indexPath.row;
  2819. cell.btnUsername.tag = (NSInteger)indexPath.row;
  2820. cell.btnFrndName.tag = (NSInteger)indexPath.row;
  2821. cell.btnDelete.tag = (NSInteger)indexPath.row;
  2822. cell.btnPlay.tag = (NSInteger)indexPath.row;
  2823. cell.btnPlayContent.tag = (NSInteger)indexPath.row;
  2824. cell.thumbnail.tag = (NSInteger)indexPath.row;
  2825. [cell reloadCell];
  2826. return cell;
  2827. }
  2828. else {
  2829.  
  2830. static NSString *CellIdentifier = @"Cell";
  2831. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  2832. cell.backgroundColor = [ApplicationData sharedInstance].tintColor;
  2833. if (cell == nil) {
  2834. cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil]autorelease];
  2835. //cell.backgroundColor = [ApplicationData sharedInstance].themeColor;
  2836. cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:15];
  2837. cell.textLabel.textColor = [ApplicationData sharedInstance].textcolor;
  2838. }
  2839. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  2840. cell.textLabel.text = NSLocalizedString(@"moreresult_title", @"Get more results...");
  2841.  
  2842. return cell;
  2843. }
  2844. }
  2845.  
  2846. - (void)tableView:(UITableView *)tableViewController didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  2847.  
  2848. if (![spinner isAnimating])
  2849. {
  2850. if(indexPath.row < [tempArray count]) {
  2851. Wall *record = [tempArray objectAtIndex:indexPath.row];
  2852. if ([record.type isEqualToString:@"event"])
  2853. {
  2854. if([[ApplicationData sharedInstance].joomsocialVersion rangeOfString:@"3.0"].length!=0){
  2855. JomEventDetailViewController3_0 *controller = [[JomEventDetailViewController3_0 alloc] init];
  2856. controller.selectedEvent = record.eventDetail;
  2857. controller.title = record.eventDetail.title;
  2858. [ApplicationData sharedInstance].isEditMode = NO;
  2859. [self.navigationController pushViewController:controller animated:YES];
  2860. [controller release];
  2861. }else{
  2862. JomEventDetailViewController *controller = [[JomEventDetailViewController alloc] init];
  2863. controller.selectedEvent = record.eventDetail;
  2864. controller.title = record.eventDetail.title;
  2865. [ApplicationData sharedInstance].isEditMode = NO;
  2866. [self.navigationController pushViewController:controller animated:YES];
  2867. [controller release];
  2868. }
  2869. }
  2870. else if ([record.type isEqualToString:@"group"]) {
  2871. if([[ApplicationData sharedInstance].joomsocialVersion rangeOfString:@"3.0"].length!=0){
  2872. GroupDetailViewController3_0 *controller = [[GroupDetailViewController3_0 alloc] initWithNibName:@"GroupDetailViewController3_0" bundle:nil];
  2873. controller.groupRecords= record.groupDetail;
  2874. controller.groupRecords.Id = record.groupDetail.Id;
  2875. [self.navigationController pushViewController:controller animated:YES];
  2876. [controller release];
  2877. }else {
  2878. GroupDetailViewController *controller = [[GroupDetailViewController alloc] initWithNibName:@"GroupDetailViewController" bundle:nil];
  2879. controller.groupRecords= record.groupDetail;
  2880. controller.groupRecords.Id = record.groupDetail.Id;
  2881. [self.navigationController pushViewController:controller animated:YES];
  2882. [controller release];
  2883. }
  2884. }
  2885. } else {
  2886. if (![spinner isAnimating]) {
  2887. [spinner startAnimating];
  2888. }
  2889. ++pageNo;
  2890. timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(fetchWall) userInfo:nil repeats:NO];
  2891. }
  2892. }
  2893.  
  2894.  
  2895.  
  2896. [tableViewController deselectRowAtIndexPath:indexPath animated:YES];
  2897. }
  2898.  
  2899.  
  2900.  
  2901. - (void)loadImagesForUsers {
  2902. NSMutableArray *temp;
  2903. temp = tempArray;
  2904. for (Wall *appRecord in temp) {
  2905. if (!appRecord.thumbImg) // avoid the app icon download if the app already has an icon
  2906. {
  2907. if([appRecord.thumbURL length] > 0 ) {
  2908. [self performSelectorOnMainThread:@selector(startIconDownload2:) withObject:appRecord waitUntilDone:NO];
  2909. }
  2910. }
  2911. }
  2912. }
  2913.  
  2914. - (void)loadImagesForRows {
  2915. for (Photo *appRecord in wallRecord.imageList) {
  2916. if (!appRecord.thumbImg) // avoid the app icon download if the app already has an icon
  2917. {
  2918. if([appRecord.thumbURL length] > 0 ) {
  2919. [self performSelectorOnMainThread:@selector(startIconDownload:) withObject:appRecord waitUntilDone:NO];
  2920. }
  2921. }
  2922. }
  2923. }
  2924.  
  2925. #pragma mark -
  2926. #pragma mark selectPhoto
  2927.  
  2928. - (void)selectPhoto:(id)sender Record:(Wall *)record {
  2929.  
  2930. UIImage *img1 = [sender imageForState:UIControlStateNormal];
  2931.  
  2932. MyCategory *album = [[MyCategory alloc] init];
  2933. album.photos = record.imageList;
  2934. PhotoDetailViewController *controller = [[PhotoDetailViewController alloc] initWithNibName:@"PhotoDetailView" bundle:nil];
  2935. controller.image = img1;
  2936. controller.albumObj = album;
  2937. controller.indexPathRow = -[sender tag] - 1;
  2938. controller.title = record.title;
  2939. // controller.albumOwner = record.userdetail;
  2940.  
  2941. [self.navigationController pushViewController:controller animated:YES];
  2942. [controller release];
  2943.  
  2944. }
  2945.  
  2946. - (void)selectVideo:(id)sender Record:(Video *)record {
  2947. VideoCommentViewController *controller = [[VideoCommentViewController alloc] init];
  2948. controller.videoObj = wallRecord.videoObj;
  2949. [self.navigationController pushViewController:controller animated:YES];
  2950. [controller release];
  2951.  
  2952. }
  2953.  
  2954.  
  2955. - (void)startIconDownload2:(Wall *)appRecord {
  2956. IconDownloader *iconDownloader = [imageDownloadsInProgress objectForKey:appRecord.thumbURL];
  2957. if (iconDownloader == nil && [appRecord.thumbURL length] > 0) {
  2958. if (![spinner isAnimating]) {
  2959. [spinner startAnimating];
  2960. }
  2961.  
  2962. iconDownloader = [[IconDownloader alloc] init];
  2963. iconDownloader.appRecord = appRecord;
  2964. iconDownloader.delegate = self;
  2965. iconDownloader.imageKey = appRecord.thumbURL;
  2966. [imageDownloadsInProgress setObject:iconDownloader forKey:appRecord.thumbURL];
  2967. [iconDownloader startDownload];
  2968. [iconDownloader release];
  2969. [multipleDownloadRecord setObject:[[NSMutableArray alloc] initWithObjects:appRecord, nil] forKey:appRecord.thumbURL];
  2970. } else {
  2971. NSMutableArray *downloadingRecords = [multipleDownloadRecord objectForKey:appRecord.thumbURL];
  2972. [downloadingRecords addObject:appRecord];
  2973. }
  2974. }
  2975.  
  2976. - (void)startIconDownload3:(Wall *)appRecord {
  2977. IconDownloader *iconDownloader = [imageDownloadsInProgress objectForKey:appRecord.videoThumbUrl];
  2978. if (iconDownloader == nil && [appRecord.videoThumbUrl length] > 0) {
  2979. [spinner startAnimating];
  2980. iconDownloader = [[IconDownloader alloc] init];
  2981. iconDownloader.appRecord = appRecord;
  2982. iconDownloader.delegate = self;
  2983. iconDownloader.imageKey = appRecord.videoThumbUrl;
  2984. [imageDownloadsInProgress setObject:iconDownloader forKey:appRecord.videoThumbUrl];
  2985. [iconDownloader startDownload];
  2986. [iconDownloader release];
  2987. }
  2988. }
  2989.  
  2990. #pragma mark -
  2991. #pragma mark ButtonPressed
  2992. -(IBAction)deleteWall:(id)sender {
  2993. deleteIndex = [sender tag];
  2994. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"r_u_sure",@"") message:NSLocalizedString(@"sure_delete",@"") delegate:self cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"lblNo", @"No"), NSLocalizedString(@"lblYes", @"Yes"), nil];
  2995. alert.tag = 3;
  2996. [alert show];
  2997. [alert release];
  2998. }
  2999.  
  3000. -(IBAction)EventButtonPressed:(id)sender{
  3001.  
  3002. Wall *record = [tempArray objectAtIndex:[sender tag]];
  3003. JomEventDetailViewController3_0 *controller = [[JomEventDetailViewController3_0 alloc] init];
  3004. controller.selectedEvent = record.eventDetail;
  3005. controller.title = record.eventDetail.title;
  3006. [ApplicationData sharedInstance].isEditMode = NO;
  3007. [self.navigationController pushViewController:controller animated:YES];
  3008. [controller release];
  3009.  
  3010. [spinner startAnimating];
  3011. [spinner release];
  3012.  
  3013.  
  3014. }
  3015.  
  3016. -(IBAction)GroupButtonPressed:(id)sender{
  3017.  
  3018. //Wall *record = [[ApplicationData sharedInstance].updatesList objectAtIndex:[sender tag]];
  3019. Wall *record = [tempArray objectAtIndex:[sender tag]];
  3020. GroupDetailViewController3_0 *controller = [[GroupDetailViewController3_0 alloc] initWithNibName:@"GroupDetailViewController3_0"bundle:nil];
  3021. controller.groupRecords= record.groupDetail;
  3022. controller.groupRecords.Id = record.groupDetail.Id;
  3023. [self.navigationController pushViewController:controller animated:YES];
  3024. [controller release];
  3025.  
  3026. [spinner startAnimating];
  3027. [spinner release];
  3028.  
  3029. }
  3030.  
  3031. - (IBAction)userButtonPressed:(id)sender {
  3032.  
  3033. Wall *record = [tempArray objectAtIndex:[sender tag]];
  3034. MainPageViewController *controller = [[MainPageViewController alloc] init];
  3035. controller.userDetail = record.userdetail;
  3036. [self.navigationController pushViewController:controller animated:YES];
  3037. [controller release];
  3038.  
  3039. // [self.splitViewController viewWillDisappear:YES];
  3040. // [[self.appDelegate.splitViewController.viewControllers objectAtIndex:0]popViewControllerAnimated:YES];
  3041. // [[self.appDelegate.splitViewController.viewControllers objectAtIndex:1]popViewControllerAnimated:YES];
  3042. // UIViewController &lt;UISplitViewControllerDelegate&gt;*viewController=[[self.appDelegate.splitViewController.viewControllers objectAtIndex:1] visibleViewController];
  3043. // self.splitViewController.delegate=viewController;
  3044. // [self.splitViewController viewWillAppear:YES];
  3045.  
  3046.  
  3047.  
  3048. }
  3049.  
  3050. - (IBAction)FriendNameButtonPressed:(id)sender {
  3051.  
  3052. Wall *record = [tempArray objectAtIndex:[sender tag]];
  3053. MainPageViewController *controller = [[MainPageViewController alloc] init];
  3054. controller.userDetail = record.tempUser;
  3055. [self.navigationController pushViewController:controller animated:YES];
  3056. [controller release];
  3057.  
  3058. }
  3059.  
  3060. - (IBAction)videoButtonPressed:(id)sender {
  3061. iJoomerAppDelegate *appdelegate = (iJoomerAppDelegate *) [[UIApplication sharedApplication] delegate];
  3062. appdelegate.viewTop.hidden = YES;
  3063. appdelegate.TabView.hidden = YES;
  3064. Video *videoObj = [tempArray objectAtIndex:[sender tag]];
  3065. NSURL *URL = [NSURL URLWithString:videoObj.videoURL];
  3066. [self presentMoviePlayerViewControllerAnimated:moviePlayer];
  3067. if(URL)
  3068. {
  3069. Class mplayerControllerClass = NSClassFromString(@"MPMoviePlayerViewController");
  3070. if(mplayerControllerClass != nil) {
  3071. #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 30200
  3072. moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:URL];
  3073. moviePlayer.wantsFullScreenLayout = YES;
  3074. //[self->moviePlayer shouldAutorotateToInterfaceOrientation:YES];
  3075. // Movie playback is asynchronous, so this method returns immediately.
  3076. if(moviePlayer)
  3077. {
  3078. [self presentMoviePlayerViewControllerAnimated:moviePlayer];
  3079. }
  3080. #else
  3081. // moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:URL];
  3082. // moviePlayer.scalingMode = MPMovieScalingModeFill;
  3083. // moviePlayer.controlStyle = MPMovieControlStyleDefault;
  3084. // moviePlayer.shouldAutoplay = YES;
  3085. // [self.view addSubview:moviePlayer.view];
  3086.  
  3087. movieplayer = [[[CustomMoviePlayerViewController alloc] initWithContentURL:URL] autorelease];
  3088.  
  3089. [self presentModalViewController:movieplayer animated:YES];
  3090. // Prep and play the movie
  3091. [movieplayer readyPlayer];
  3092.  
  3093. // if(moviePlayer)
  3094. // {
  3095. // [self.moviePlayer play];
  3096. // }
  3097.  
  3098. #endif
  3099. }
  3100. }
  3101. }
  3102.  
  3103. -(IBAction)ProfileVideoButtonPressed:(id)sender {
  3104. self.navigationItem.hidesBackButton = YES;
  3105. [self embedYouTube:[userDetail.profile_video objectForKey:@"url"] frame:CGRectZero];
  3106. webView.hidden = NO;
  3107. iJoomerAppDelegate *appdelegate = (iJoomerAppDelegate *) [[UIApplication sharedApplication] delegate];
  3108. appdelegate.viewTop.hidden = YES;
  3109. appdelegate.TabView.hidden = YES;
  3110. self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Close",@"Cancel") style:UIBarButtonItemStylePlain target:self action:@selector(cancelButtonPressed:)] autorelease];
  3111. }
  3112.  
  3113. - (IBAction)commentLikeButtonPressed:(id)sender {
  3114.  
  3115. CommentViewController *controller = [[CommentViewController alloc] init];
  3116. controller.selectedWall = [tempArray objectAtIndex:[sender tag]];
  3117. controller.userDetail = self.userDetail;
  3118. [self.navigationController pushViewController:controller animated:YES];
  3119. [controller release];
  3120. }
  3121.  
  3122. - (IBAction)commentButtonPressed:(id)sender {
  3123. CommentViewController *controller = [[CommentViewController alloc] init];
  3124. controller.selectedWall = [tempArray objectAtIndex:[sender tag]];
  3125. controller.userDetail = self.userDetail;
  3126. // controller.event = self.event;
  3127. [self.navigationController pushViewController:controller animated:YES];
  3128. [controller release];
  3129. }
  3130.  
  3131. - (IBAction)likeButtonPressed:(id)sender {
  3132.  
  3133. if (![spinner isAnimating]) {
  3134. tableView.userInteractionEnabled = FALSE;
  3135. wallRecord = [tempArray objectAtIndex:[sender tag]];
  3136. if ([[sender titleLabel].text isEqualToString:NSLocalizedString(@"unlike_btn", @"")]) {
  3137. NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
  3138. if ([wallRecord.liketype isEqualToString:@"videos"]) {
  3139. [postVariables setObject:[NSString stringWithFormat:@"%d",wallRecord.videoObj.videoID] forKey:@"wallID"];
  3140. }else {
  3141. [postVariables setObject:[NSString stringWithFormat:@"%d",wallRecord.wallId] forKey:@"wallID"];
  3142. }
  3143. [postVariables setObject:wallRecord.liketype forKey:@"type"];
  3144. // [postVariables setObject:[NSString stringWithFormat:@"%d",permissionValue] forKey:@"permissions"];
  3145.  
  3146. NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"wall" ExtTask:@"unlike" TaskdataDictionary:postVariables Imagedata:nil];
  3147.  
  3148. [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
  3149. currentRequestType = jlikeUnlikeQuery;
  3150. if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
  3151. [self requestCompleted];
  3152. }else {
  3153. [spinner stopAnimating];
  3154. [self stopLoading];
  3155. self.view.userInteractionEnabled = YES;
  3156. }
  3157. }
  3158. else
  3159. {
  3160. NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
  3161. if ([wallRecord.liketype isEqualToString:@"videos"]) {
  3162. [postVariables setObject:[NSString stringWithFormat:@"%d",wallRecord.videoObj.videoID] forKey:@"wallID"];
  3163. }else {
  3164. [postVariables setObject:[NSString stringWithFormat:@"%d",wallRecord.wallId] forKey:@"wallID"];
  3165. }
  3166. [postVariables setObject:wallRecord.liketype forKey:@"type"];
  3167. // [postVariables setObject:[NSString stringWithFormat:@"%d",permissionValue] forKey:@"permissions"];
  3168.  
  3169. NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"wall" ExtTask:@"like" TaskdataDictionary:postVariables Imagedata:nil];
  3170.  
  3171. [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
  3172. currentRequestType = jlikeUnlikeQuery;
  3173. if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
  3174. [self requestCompleted];
  3175. }else {
  3176. [spinner stopAnimating];
  3177. [self stopLoading];
  3178. self.view.userInteractionEnabled = YES;
  3179. }
  3180. }
  3181.  
  3182. }
  3183. }
  3184.  
  3185. - (void)postButtonPressed {
  3186. if (![spinner isAnimating]) {
  3187. if (txtComment.text.length == 0) {
  3188. [self showAlert:NSLocalizedString(@"no_text",@"") Content:NSLocalizedString(@"Please_enter_text", @"")];
  3189. return;
  3190. }
  3191. NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
  3192. [postVariables setObject:txtComment.text forKey:@"message"];
  3193. [postVariables setObject:[NSString stringWithFormat:@"%d",wallRecord.wallId] forKey:@"uniqueID"];
  3194. [postVariables setObject:[NSString stringWithFormat:@"%d",1] forKey:@"comment"];
  3195. [postVariables setObject:@"0" forKey:@"privacy"];
  3196. // [postVariables setObject:[NSString stringWithFormat:@"%d",permissionValue] forKey:@"permissions"];
  3197.  
  3198. NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"wall" ExtTask:@"add" TaskdataDictionary:postVariables Imagedata:nil];
  3199.  
  3200. [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
  3201. currentRequestType = jShareQuery;
  3202. if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
  3203. [self requestCompleted];
  3204. }else {
  3205. self.view.userInteractionEnabled = YES;
  3206. }
  3207. [txtComment resignFirstResponder];
  3208. [txtComment setHidden:YES];
  3209. }
  3210. txtComment.hidden = YES;
  3211. }
  3212.  
  3213. #pragma mark -
  3214. #pragma mark user defined functions
  3215.  
  3216. - (void)logoutProcess{
  3217. tableView.userInteractionEnabled = NO;
  3218. self.navigationItem.rightBarButtonItem.enabled = FALSE;
  3219.  
  3220. if(!tabBarLayerView) {
  3221. CGRect frame = CGRectMake(0,0,420,49);
  3222. tabBarLayerView = [[UIImageView alloc] initWithFrame:frame];
  3223. [[self.tabBarController tabBar] addSubview:tabBarLayerView];
  3224. // [self.tabBarController tabBar].userInteractionEnabled = NO;
  3225. [tabBarLayerView setUserInteractionEnabled:YES];
  3226. }
  3227. if (![spinner isAnimating])
  3228. {
  3229. [spinner startAnimating];
  3230. }
  3231.  
  3232.  
  3233. NSDictionary *dict = [JoomlaRegistration CreateDictionary:@"logout" TaskdataDictionary:nil Imagedata:nil];
  3234. //[ijoomer_lib Logout:[ApplicationData sharedInstance].loggedUser static_URL:sever_static_URL];
  3235.  
  3236. NSNumber *num = [dict objectForKey:@"code"];
  3237. int code = [num intValue];
  3238. [ApplicationData sharedInstance].errorCode = code;
  3239. currentRequestType = jLogoutQuery;
  3240. if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
  3241. [self requestCompleted];
  3242. }else {
  3243. self.view.userInteractionEnabled = YES;
  3244. }
  3245.  
  3246. }
  3247.  
  3248. #pragma mark -
  3249. #pragma mark default functions
  3250.  
  3251. - (void)didReceiveMemoryWarning {
  3252. }
  3253.  
  3254. - (void)viewDidUnload{
  3255. [btnLikePr release];
  3256. btnLikePr = nil;
  3257. [btnLike release];
  3258. btnLike = nil;
  3259. [btnUnlike release];
  3260. btnUnlike = nil;
  3261. [btnUnlikeStupid release];
  3262. btnUnlikeStupid = nil;
  3263. [btnMap release];
  3264. btnMap = nil;
  3265. [NSObject cancelPreviousPerformRequestsWithTarget:self];
  3266.  
  3267. #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
  3268. self.contentView = nil;
  3269. banner.delegate = nil;
  3270. self.banner = nil;
  3271. #endif
  3272. }
  3273.  
  3274. - (void)dealloc
  3275. {
  3276. [btnHoldnSpeak release];
  3277. [btnTextFromVoice release];
  3278. [btnUserAbout release];
  3279. [btnUserVideos release];
  3280. [btnUserPhotos release];
  3281. [btnUserFriends release];
  3282. [voiceoverView release];
  3283. [myWebview release];
  3284. [btnLikePr release];
  3285. [btnLike release];
  3286. [btnUnlike release];
  3287. [btnUnlikeStupid release];
  3288. [btnMap release];
  3289. [NSObject cancelPreviousPerformRequestsWithTarget:self];
  3290.  
  3291. #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
  3292. [contentView release]; contentView = nil;
  3293. banner.delegate = nil;
  3294. [banner release]; banner = nil;
  3295. #endif
  3296. [imageDownloadsInProgress release];
  3297. [imageUploader release];
  3298. //[dataForTable release];
  3299. //[tableView release];
  3300. [name release];
  3301. //[statusMsg release];
  3302. [userImg release];
  3303. if (false) {
  3304. [super dealloc];
  3305. }
  3306. }
  3307.  
  3308. - (void)viewWillDisappear:(BOOL)animated {
  3309. isImageUpdated = NO;
  3310.  
  3311. iJoomerAppDelegate *appdelegate = (iJoomerAppDelegate *) [[UIApplication sharedApplication] delegate];
  3312. appdelegate.viewTop.hidden = YES;
  3313. appdelegate.TabView.hidden = YES;
  3314. [NSObject cancelPreviousPerformRequestsWithTarget:self];
  3315. isViewWillDisAapear = YES;
  3316. if([spinner isAnimating]) {
  3317. RequestResponseManager *requestManager = [RequestResponseManager sharedInstance];
  3318. [requestManager cancleRequest];
  3319. [requestManager removeRequestProperty:self ExtraInfo:nil];
  3320. }
  3321. if([imageDownloadsInProgress count] > 0) {
  3322. IconDownloader *downloader;
  3323. for(downloader in [imageDownloadsInProgress objectEnumerator]) {
  3324. [downloader cancelDownload];
  3325. }
  3326. [imageDownloadsInProgress removeAllObjects];
  3327. }
  3328. if(imageUploader) {
  3329. self.navigationItem.rightBarButtonItem.enabled = TRUE;
  3330. self.navigationItem.leftBarButtonItem.enabled = TRUE;
  3331. tableView.userInteractionEnabled = YES;
  3332. if(userDetail.avatarImg) {
  3333. userImg.image = userDetail.avatarImg;
  3334. }
  3335. [imageUploader cancelUpload];
  3336. }
  3337. [spinner stopAnimating];
  3338. [self.tabBarController hidesBottomBarWhenPushed];
  3339. progressBar.hidden = TRUE;
  3340. userImg.alpha = 1;
  3341. }
  3342.  
  3343. - (void)startIconDownload:(Photo *)appRecord {
  3344. if(isViewWillDisAapear){return;};
  3345. IconDownloader *iconDownloader = [imageDownloadsInProgress objectForKey:appRecord.thumbURL];
  3346. if (iconDownloader == nil && [appRecord.thumbURL length] > 0)
  3347. {
  3348. //DLog(@"Start Image Downloading : %@ Total Progress : %d", appRecord.imgURL, [imageDownloadsInProgress count]);
  3349. [spinner startAnimating];
  3350. iconDownloader = [[IconDownloader alloc] init];
  3351. iconDownloader.appRecord = appRecord;
  3352. iconDownloader.delegate = self;
  3353. iconDownloader.imageKey = appRecord.thumbURL;
  3354. [imageDownloadsInProgress setObject:iconDownloader forKey:appRecord.thumbURL];
  3355. [iconDownloader startDownload];
  3356. [iconDownloader release];
  3357. [multipleDownloadRecord setObject:[[[NSMutableArray alloc] initWithObjects:appRecord, nil] autorelease] forKey:appRecord.thumbURL];
  3358. } else {
  3359. NSMutableArray *downloadingRecords = [multipleDownloadRecord objectForKey:appRecord.thumbURL];
  3360. [downloadingRecords addObject:appRecord];
  3361. }
  3362. }
  3363.  
  3364.  
  3365.  
  3366. //////////////////////////////////////////////////////////////////////////////////////////////////////////////
  3367. ////////////////////////////////////// IconDownloaderDelegate ////////////////////////////////////////////////
  3368. //////////////////////////////////////////////////////////////////////////////////////////////////////////////
  3369.  
  3370. - (void)appImageDidLoad:(NSObject *)imageKey
  3371. {
  3372. [imageDownloadsInProgress removeObjectForKey:imageKey];
  3373. if([imageDownloadsInProgress count] == 0)
  3374. {
  3375. [spinner stopAnimating];
  3376. [tableView reloadData];
  3377. if ([userDetail avatarImg])
  3378. {
  3379. DLog(@"image set");
  3380. [userImg setImage:[userDetail avatarImg]];
  3381. //[userImg setBackgroundColor:[UIColor clearColor]];
  3382. }
  3383. }
  3384. // for same url of multiple records
  3385. NSMutableArray *downloadingRecords = [multipleDownloadRecord objectForKey:imageKey];
  3386. if([downloadingRecords count] > 1) {
  3387. if([[downloadingRecords objectAtIndex:0] isKindOfClass:[Wall class]])
  3388. {
  3389. Wall *record = [downloadingRecords objectAtIndex:0];
  3390. for(id<IconRecord> otherRecord in downloadingRecords)
  3391. {
  3392. [otherRecord setImage:record.thumbImg ImageKey:imageKey];
  3393. }
  3394. }
  3395. else if([[downloadingRecords objectAtIndex:0] isKindOfClass:[Image class]])
  3396. {
  3397. Image *record = [downloadingRecords objectAtIndex:0];
  3398. for(id<IconRecord> otherRecord in downloadingRecords)
  3399. {
  3400. [otherRecord setImage:record.imgSource ImageKey:imageKey];
  3401. }
  3402. }
  3403. }
  3404. [downloadingRecords removeAllObjects];
  3405. [multipleDownloadRecord removeObjectForKey:imageKey];
  3406.  
  3407. if([imageDownloadsInProgress count] == 0) {
  3408. [spinner stopAnimating];
  3409. [tableView reloadData];
  3410. }
  3411. }
  3412.  
  3413. /////////////////////////////////////////////////////////////////////////////////////////////
  3414. /////////////////////////////////// Friends Map /////////////////////////////////////////////
  3415. /////////////////////////////////////////////////////////////////////////////////////////////
  3416.  
  3417. - (IBAction)mapButtonPressed:(id)sender {
  3418. UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"button_back",@"") style:UIBarButtonItemStylePlain target:self action:@selector(backButtonPressed:)];
  3419. self.navigationItem.rightBarButtonItem = button;
  3420. self.navigationItem.hidesBackButton = YES;
  3421. [button release];
  3422. [self.view addSubview:mapView];
  3423. tableView.hidden = YES;
  3424. mapView.hidden = NO;
  3425. [self showFriendsOnMap];
  3426. }
  3427.  
  3428. - (IBAction)backButtonPressed:(id)sender {
  3429. self.navigationItem.hidesBackButton = NO;
  3430. self.navigationItem.rightBarButtonItem = nil;
  3431. tableView.hidden = NO;
  3432. mapView.hidden = YES;
  3433. }
  3434.  
  3435. - (void)showFriendsOnMap {
  3436.  
  3437. if (!localmapView) {
  3438. if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
  3439. {
  3440. CGSize result = [[UIScreen mainScreen] bounds].size;
  3441. if(result.height == 480)
  3442. {
  3443. localmapView = [[MKMapView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 367.0)];
  3444. }
  3445. if(result.height == 568)
  3446. {
  3447. localmapView = [[MKMapView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 455.0)];
  3448. }
  3449. }
  3450. [mapView addSubview:localmapView];
  3451. }
  3452. else
  3453. {
  3454. NSArray *annotationArray = [localmapView annotations];
  3455. for(int i=[annotationArray count]-1; i>=0; --i) {
  3456. id<MKAnnotation> userAnnotation = [annotationArray objectAtIndex:i];
  3457. if([userAnnotation isKindOfClass:[MapItemAnnotation class]]) {
  3458. [localmapView removeAnnotation:userAnnotation];
  3459. }
  3460. }
  3461. }
  3462. localmapView.delegate = self;
  3463. MapItemAnnotation *annotation;
  3464.  
  3465. if (userDetail.userId == 0) {
  3466. coordinate.latitude = [[ApplicationData sharedInstance].locationManager latitude];
  3467. coordinate.longitude = [[ApplicationData sharedInstance].locationManager longitude];
  3468. }else {
  3469. coordinate.latitude = userDetail.latitude;
  3470. coordinate.longitude = userDetail.longitude;
  3471. }
  3472. [localmapView setShowsUserLocation:YES];
  3473.  
  3474. double region;
  3475. region = 5.50;
  3476. if (coordinate.latitude >= -90 && coordinate.latitude <= 90 &&
  3477. coordinate.longitude >= -180 && coordinate.longitude <= 180) {
  3478. [localmapView setRegion:MKCoordinateRegionMake(coordinate, MKCoordinateSpanMake(region, region))];
  3479. }
  3480. annotation = [[[MapItemAnnotation alloc] initWithCoordinate:coordinate AnnotationTitle:userDetail.userName] autorelease];
  3481. annotation.mapUser = userDetail;
  3482. [localmapView addAnnotation:annotation];
  3483. [localmapView setNeedsDisplay];
  3484. [localmapView setMapType:MKMapTypeStandard];
  3485. }
  3486.  
  3487.  
  3488. //////////////////////////////////////////////////////////////////////////////////////////////////////////////
  3489. /////////////////////////////////////// ImageUploaderDelegate ////////////////////////////////////////////////
  3490. //////////////////////////////////////////////////////////////////////////////////////////////////////////////
  3491.  
  3492. - (void)appImageDidUpload {
  3493. userImg.image = userImage;
  3494. userDetail.avatarImg = userImage;
  3495. // if([ErrorHangler hasError:self errorCode:(int)[[dict objectForKey:TAG_CODE] intValue] errorMessage:(NSString*)[dict objectForKey:TAG_ERROR_MESSAGE]]){
  3496. [self requestCompleted];
  3497. // };
  3498. imageUploader = nil;
  3499. }
  3500.  
  3501. ///------------------------------- Pull down to Refresh start ---------------------------------///
  3502.  
  3503.  
  3504. - (void)addPullToRefreshHeader {
  3505. textPull = [[NSString alloc] initWithString:@"Pull down to refresh..."];
  3506. textRelease = [[NSString alloc] initWithString:@"Release to refresh..."];
  3507. textLoading = [[NSString alloc] initWithString:@"Loading..."];
  3508. refreshHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0 - REFRESH_HEADER_HEIGHT, 320, REFRESH_HEADER_HEIGHT)];
  3509. refreshHeaderView.backgroundColor = [UIColor clearColor];
  3510.  
  3511. refreshLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, pullTable.frame.size.width, REFRESH_HEADER_HEIGHT)];
  3512. refreshLabel.backgroundColor = [UIColor clearColor];
  3513. refreshLabel.font = [UIFont boldSystemFontOfSize:12.0];
  3514. refreshLabel.textColor = [ApplicationData sharedInstance].textcolor;
  3515. refreshLabel.textAlignment = UITextAlignmentCenter;
  3516.  
  3517. refreshArrow = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrowpull.png"]];
  3518. [refreshArrow setContentMode:UIViewContentModeCenter];
  3519. refreshArrow.frame = CGRectMake((REFRESH_HEADER_HEIGHT - 27) / 2,
  3520. (REFRESH_HEADER_HEIGHT - 44) / 2,
  3521. 27, 44);
  3522.  
  3523. [refreshHeaderView addSubview:refreshLabel];
  3524. [refreshHeaderView addSubview:refreshArrow];
  3525. [self->pullTable addSubview:refreshHeaderView];
  3526. }
  3527.  
  3528.  
  3529. - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
  3530.  
  3531. if (isLoading) return;
  3532. isDragging = YES;
  3533. }
  3534.  
  3535. - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  3536. if (isLoading) {
  3537. // Update the content inset, good for section headers
  3538. if (scrollView.contentOffset.y > 0)
  3539. self->pullTable.contentInset = UIEdgeInsetsZero;
  3540. else if (scrollView.contentOffset.y >= -REFRESH_HEADER_HEIGHT)
  3541. self->pullTable.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
  3542. } else if (isDragging && scrollView.contentOffset.y < 0) {
  3543. // Update the arrow direction and label
  3544. [UIView beginAnimations:nil context:NULL];
  3545. if (scrollView.contentOffset.y < -REFRESH_HEADER_HEIGHT) {
  3546. // User is scrolling above the header
  3547. refreshLabel.text = self->textRelease;
  3548. [refreshArrow layer].transform = CATransform3DMakeRotation(M_PI, 0, 0, 1);
  3549. } else { // User is scrolling somewhere within the header
  3550. refreshLabel.text = self->textPull;
  3551. [refreshArrow layer].transform = CATransform3DMakeRotation(M_PI * 2, 0, 0, 1);
  3552. }
  3553. [UIView commitAnimations];
  3554. }
  3555. }
  3556.  
  3557. - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
  3558. if (txtStatus.text.length == 0)
  3559. {
  3560. btnwtsonurmind.hidden = NO;
  3561.  
  3562. }else{
  3563. btnwtsonurmind.hidden = YES;
  3564.  
  3565. }
  3566. if (txtPhotoCaption.text.length == 0)
  3567. {
  3568. btnPhotocaption.hidden = NO;
  3569.  
  3570. }else{
  3571. btnPhotocaption.hidden = YES;
  3572. }
  3573.  
  3574. [txtStatus resignFirstResponder];
  3575. [Voiceover.txtStaus resignFirstResponder];
  3576. [txtPhotoCaption resignFirstResponder];
  3577.  
  3578. if (isLoading) return;
  3579. isDragging = NO;
  3580. if (scrollView.contentOffset.y <= -REFRESH_HEADER_HEIGHT) {
  3581. // Released above the header
  3582. [self startLoading];
  3583. }
  3584. }
  3585.  
  3586. - (void)startLoading {
  3587. isLoading = YES;
  3588.  
  3589. // Show the header
  3590. [UIView beginAnimations:nil context:NULL];
  3591. [UIView setAnimationDuration:0.3];
  3592. self->pullTable.contentInset = UIEdgeInsetsMake(REFRESH_HEADER_HEIGHT, 0, 0, 0);
  3593. refreshLabel.text = self->textLoading;
  3594. refreshArrow.hidden = YES;
  3595. [refreshSpinner startAnimating];
  3596. [UIView commitAnimations];
  3597.  
  3598. // Refresh action!
  3599. [self refresh];
  3600. }
  3601.  
  3602. - (void) refresh {
  3603. if (![spinner isAnimating]) {
  3604. [spinner startAnimating];
  3605. self.view.userInteractionEnabled = NO;
  3606. pageNo = 1;
  3607. [userDetail.wallList removeAllObjects];
  3608. [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(profileRequest) userInfo:nil repeats:NO];
  3609. }
  3610. }
  3611.  
  3612. - (void)stopLoading {
  3613. isLoading = NO;
  3614.  
  3615. // Hide the header
  3616. [UIView beginAnimations:nil context:NULL];
  3617. [UIView setAnimationDelegate:self];
  3618. [UIView setAnimationDuration:0.3];
  3619. [UIView setAnimationDidStopSelector:@selector(stopLoadingComplete:finished:context:)];
  3620. self->pullTable.contentInset = UIEdgeInsetsZero;
  3621. [refreshArrow layer].transform = CATransform3DMakeRotation(M_PI * 2, 0, 0, 1);
  3622. [UIView commitAnimations];
  3623. }
  3624.  
  3625. - (void)stopLoadingComplete:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
  3626. // Reset the header
  3627. refreshLabel.text = self->textPull;
  3628. refreshArrow.hidden = NO;
  3629. [refreshSpinner stopAnimating];
  3630. }
  3631.  
  3632. -(IBAction)simanswers:(id)sender {
  3633. myWebview.hidden = NO;
  3634. myWebview.tag = 394;
  3635. [spinner startAnimating];
  3636. myWebview.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
  3637. NSString *theUrl;
  3638. Wall *record = [tempArray objectAtIndex:[sender tag]];
  3639.  
  3640. theUrl = [NSString stringWithFormat:@"http://iremember.gr/el/component/simanswers/?view=question&qid=%d&Itemid=150", record.qid];
  3641. [myWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:theUrl]]];
  3642. [self.view addSubview:myWebview];
  3643.  
  3644.  
  3645. UIBarButtonItem *navigationBarbackButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"button_back",@"") style:UIBarButtonItemStyleBordered target:self action:@selector(close:)];
  3646. self.navigationItem.leftBarButtonItem = navigationBarbackButton;
  3647.  
  3648. }
  3649.  
  3650.  
  3651. - (IBAction)close:(id)sender {
  3652.  
  3653. [[self.view viewWithTag:394] removeFromSuperview];
  3654. self.navigationItem.leftBarButtonItem = nil;
  3655. }
  3656.  
  3657. - (void)webViewDidFinishLoad:(UIWebView *)webView {
  3658. [spinner stopAnimating];
  3659. }
  3660.  
  3661. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement