Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // MainPageViewController.m
- // ijoomer
- //
- // Created by Tailored Solutions on 16/03/12.
- // Copyright 2013 Tailored Solutions. All rights reserved.
- //
- #import "MainPageViewController.h"
- #import "LoginViewController.h"
- #import "RegisterViewController3_0.h"
- #import "UserDetailViewController.h"
- #import "Privacy.h"
- #import "ApplicationData.h"
- #import "User.h"
- #import "WriteMessageViewController.h"
- #import "FindFirstResponder.h"
- #import "FriendsViewController.h"
- #import "NotificationViewController.h"
- #import "Tab.h"
- #import "Jomsocial.h"
- #import "GroupDetailViewController.h"
- #import "JoomlaRegistration.h"
- #import "Core_joomer.h"
- #import "JomEventDetailViewController.h"
- #import "GlobalObjects.h"
- #import "Wall.h"
- #import "WallCell.h"
- #import "Video.h"
- #import "Image.h"
- #import "CommentViewController.h"
- #import "AlbumsViewController.h"
- #import "VideoViewController.h"
- #import "iJoomerAppDelegate.h"
- #import "MessageViewController.h"
- #import "PhotoDetailViewController.h"
- #import "VideoCommentViewController.h"
- #import "GPSLocationListner.h"
- #import "JomEditEventViewController.h"
- #import <AVFoundation/AVFoundation.h>
- #import <MediaPlayer/MediaPlayer.h>
- #import "GroupDetailViewController3_0.h"
- #import "JomEventDetailViewController3_0.h"
- #import "MoreUserSettings.h"
- #import <QuartzCore/QuartzCore.h>
- static NSString *kCellIdentifier = @"WallCell";
- @interface MainPageViewController()
- /*
- #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
- -(void)layoutForCurrentOrientation:(BOOL)animated;
- -(void)createADBannerView;
- #endif
- */
- @end
- @implementation MainPageViewController
- @synthesize userDetail;
- @synthesize imageDownloadsInProgress;
- @synthesize name;
- //@synthesize statusMsg;
- @synthesize profileCount;
- @synthesize userImg;
- @synthesize isMainUserProfileView;
- @synthesize spinner;
- @synthesize commentRecord;
- @synthesize btnsend;
- @synthesize btnPlay,btnReport,lblSecond;
- @synthesize txtStatus;
- @synthesize btnwtsonurmind;
- //for photo caption
- @synthesize btnPhotocaption;
- @synthesize txtPhotoCaption;
- @synthesize btnPhotocaptionSend;
- #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
- @synthesize contentView, banner;
- @synthesize bannerIsVisible;
- #endif
- #pragma mark -
- #pragma mark viewDidLoad & viewWillAppear
- - (id)init {
- self = [super init];
- if(self) {
- self.tabBarItem.image = [UIImage imageNamed:@"profile.png"];
- }
- return self;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- [btnUserFriends setTitle:NSLocalizedString(@"Friends_title",@"") forState:UIControlStateNormal];
- [btnUserPhotos setTitle:NSLocalizedString(@"Photo_title",@"") forState:UIControlStateNormal];
- [btnUserVideos setTitle:NSLocalizedString(@"video_title",@"") forState:UIControlStateNormal];
- [btnUserAbout setTitle:NSLocalizedString(@"button_aboutmeb",@"") forState:UIControlStateNormal];
- lblAbout.text = NSLocalizedString(@"about_title",@"");
- lblMap.text = NSLocalizedString(@"button_map",@"");
- lblRecentTitle.text = NSLocalizedString(@"ractivity_title",@"");
- [btnWritePost setTitle:NSLocalizedString(@"writepost_title",@"") forState:UIControlStateNormal];
- [btnPhotos setTitle:NSLocalizedString(@"Photo_title",@"") forState:UIControlStateNormal];
- [btnVideos setTitle:NSLocalizedString(@"video_title",@"") forState:UIControlStateNormal];
- [btnEvents setTitle:NSLocalizedString(@"Event_title" ,@"")forState:UIControlStateNormal];
- [btnPhotocaptionSend setTitle:NSLocalizedString(@"button_send",@"") forState:UIControlStateNormal];
- [btnMessage setTitle:NSLocalizedString(@"Message",@"") forState:UIControlStateNormal];
- [btnfriend setTitle:NSLocalizedString(@"addFriend",@"") forState:UIControlStateNormal];
- [btnsend setTitle:NSLocalizedString(@"button_send",@"") forState:UIControlStateNormal];
- [btnPhotocaptionSend setTitle:NSLocalizedString(@"button_send",@"") forState:UIControlStateNormal];
- [btnWritePost setTitle:NSLocalizedString(@"button_writepostm",@"") forState:UIControlStateNormal];
- [btnmessage setTitle:NSLocalizedString(@"button_profmess",@"") forState:UIControlStateNormal];
- lblRecentTitle.text = NSLocalizedString(@"button_RecentActivities",@"");
- lblAbout.text = NSLocalizedString(@"button_aboutmeb",@"");
- lblMap.hidden = YES;
- btnMap.hidden = YES;
- btnUnlikeStupid.hidden = YES;
- btnDislike.hidden = YES;
- lblDislikeCount.hidden = YES;
- btnUnlike.hidden = YES;
- btnLikePr.hidden = YES;
- voiceoverView.frame = CGRectMake(voiceoverView.frame.origin.x, voiceoverView.frame.origin.y + 50, voiceoverView.frame.size.width, voiceoverView.frame.size.height);
- newWall = [[Wall alloc]init];
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(movieFinished:)
- name:MPMoviePlayerPlaybackDidFinishNotification
- object:mp];
- multipleDownloadRecord = [[NSMutableDictionary alloc] init];
- pageNo = 1;
- self->pullTable = tableView;
- [self addPullToRefreshHeader];
- tableView.tableHeaderView = headerView;
- cellOwner = [[TableCellOwner alloc]init];
- notifView.hidden = YES;
- permissionValue = 0;
- permissions = [[NSArray arrayWithObjects:NSLocalizedString(@"Public_title",@""),NSLocalizedString(@"sitemember_title",@""),NSLocalizedString(@"friends_title",@""),NSLocalizedString(@"onlyme_title",@""), nil] retain];
- scrollMenu.delegate = self;
- scrollMenu.hidden = YES;
- scrollMenu.contentSize = CGSizeMake(384, 78);
- NSDate *date = [[NSDate alloc]init];
- NSDateFormatter *format = [[NSDateFormatter alloc] init];
- [format setDateFormat:@"a"];
- NSString *str = [format stringFromDate:date];
- btnCancel = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"button_cancel", @"") style:UIBarButtonItemStylePlain target:self action:@selector(cancelButtonPressed:)];
- btnDone = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"button_done", @"") style:UIBarButtonItemStyleDone target:self action:@selector(doneButtonPressed:)];
- // btnLogout = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"button_logout", @"") style:UIBarButtonItemStylePlain target:self action:@selector(logoutButtonPressed:)];
- //lblRecentTitle.textColor = [ApplicationData sharedInstance].textcolor;
- btnEdit.hidden = YES;
- //[btnEdit setBackgroundColor: palletePurple];
- [btnEdit setTitle:NSLocalizedString(@"button_edit", @"") forState:UIControlStateNormal];
- btnEdit.layer.cornerRadius = 3;
- if(!userDetail || ([ApplicationData sharedInstance].isLoggedIn && !userDetail.isFriend && userDetail.userId == 0))
- {
- btnEdit.hidden = NO;
- self.navigationItem.leftBarButtonItem = nil;
- isMainUserProfileView = YES;
- if ([[ApplicationData sharedInstance].tabList count] > 0 && USE_SERVER_TABS)
- {
- dataForTable = [ApplicationData sharedInstance].profilemenuList;
- }
- else
- {
- NSDictionary *plistDict = [[NSDictionary alloc] initWithContentsOfFile:[[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"Data.plist"]];
- dataForTable = [plistDict objectForKey:@"profilemenu"];
- cellImageNames = [ApplicationData sharedInstance].profileMenuImages;
- }
- } else
- {
- [self performSelectorOnMainThread:@selector(profileRequest) withObject:nil waitUntilDone:YES];
- if ([[ApplicationData sharedInstance].tabList count] > 0 && USE_SERVER_TABS)
- {
- dataForTable = [ApplicationData sharedInstance].friendmenuList;
- }
- else
- {
- NSDictionary *plistDict = [[NSDictionary alloc] initWithContentsOfFile:[[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"Data.plist"]];
- dataForTable = [plistDict objectForKey:@"friendmenu"];
- cellImageNames = [ApplicationData sharedInstance].friendMenuImages;
- }
- }
- [lbl_profileCount setText:NSLocalizedString(@"lblProfileCount", @"")];
- [changeImg setTitle:NSLocalizedString(@"button_edit", @"") forState:UIControlStateNormal];
- self.imageDownloadsInProgress = [NSMutableDictionary dictionary];
- backImg.image = [UIImage imageNamed:[ApplicationData sharedInstance].bgImage];
- tableView.backgroundColor = [UIColor clearColor];
- name.delegate = self;
- UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"button_back",@"") style:UIBarButtonItemStyleBordered target:nil action:nil];
- self.navigationItem.backBarButtonItem = backButton;
- [backButton release];
- myWebview.hidden = YES;
- myWebview.delegate = self;
- }
- - (void)viewWillAppear:(BOOL)animated {
- isViewWillDisAapear = NO;
- [super viewWillAppear:animated];
- name.userInteractionEnabled = NO;
- self.title = @"";
- iJoomerAppDelegate *appdelegate = (iJoomerAppDelegate *) [[UIApplication sharedApplication] delegate];
- appdelegate.viewTop.hidden = NO;
- appdelegate.TabView.hidden = YES;
- //tablist
- //##########################################################################################################
- NSMutableArray *arr = [[NSMutableArray alloc] init];
- arr = [appdelegate fetchTabList:@"JomProfile"];
- if ([arr count] == 0 || [[ApplicationData sharedInstance].tabList count] == 0) {
- isTabbarHidden = YES;
- }
- else {
- isTabbarHidden = NO;
- }
- arr = [appdelegate fetchsidemenuList:@"JomProfile"];
- appdelegate.viewTop.hidden = NO;
- appdelegate.SelfViewcontroller = self;
- [appdelegate TabReset];
- ///////////////////////////////////Voiceover Start//////////////////////
- Voiceover.MainPageController = self;
- [Voiceover intialize];
- VoiceoverPhotoCaption.MainPageController = self;
- [VoiceoverPhotoCaption intialize];
- if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
- CGSize result = [[UIScreen mainScreen] bounds].size;
- if(result.height == 480) {
- if (isTabbarHidden == YES) {
- tableView.frame = CGRectMake(0, 0, 320, 415 -30);
- }
- else {
- tableView.frame = CGRectMake(0, 0, 320, 365 -30);
- }
- }
- else if(result.height == 568) {
- if (isTabbarHidden == YES) {
- tableView.frame = CGRectMake(0, 0, 320, 500 -30);
- }
- else {
- tableView.frame = CGRectMake(0, 0, 320, 455 -30);
- } // iPhone 5
- }
- }
- [btnwtsonurmind setTitle:NSLocalizedString(@"Whats_on_Mind", @"") forState:UIControlStateNormal];
- ///////////////////////////////////Voiceover End//////////////////////
- [spinner startAnimating];
- // if(userDetail) {
- // name.text = @"";
- // userImg.image = [UIImage imageNamed:@""];
- //
- // }
- permissionValue = 0;
- [btnPermission setBackgroundImage:[UIImage imageNamed:[ApplicationData sharedInstance].selButton] forState:UIControlStateNormal];
- [btnPermission setTitle:[NSString stringWithFormat:@" %@",[permissions objectAtIndex:0]] forState:UIControlStateNormal];
- //for photo caption
- if (photoSelectIndex == 888) {
- imgPhotoPrev.hidden = NO;
- VoiceoverPhotoCaption.btnSpeakAndHold.hidden = YES;
- VoiceoverPhotoCaption.imgRecord.hidden = YES;
- imgPhotoBackPrev.hidden = NO;
- VoiceoverPhotoCaption.hidden = NO;
- Voiceover.hidden = YES;
- }else if (photoSelectIndex == 999){
- imgPhotoPrev.hidden = YES;
- imgPhotoBackPrev.hidden = YES;
- VoiceoverPhotoCaption.hidden = NO;
- Voiceover.hidden = YES;
- }else{
- imgPhotoPrev.hidden = YES;
- imgPhotoBackPrev.hidden = YES;
- VoiceoverPhotoCaption.hidden = NO;
- Voiceover.hidden = YES;
- }
- [btnPhotocaption setTitle:NSLocalizedString(@"photo_caption", @"") forState:UIControlStateNormal];
- #pragma mark
- #pragma mark Case for Showing and not showing CoverPhoto, Event, Photo and Video
- /* "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}} */
- // BOOL isPhotoUpload = [[[[ApplicationData sharedInstance].dictextentionconfig objectForKey:@"jomsocial"] objectForKey:@"isPhotoUpload"]boolValue];
- // if (isPhotoUpload) {
- // btncoverphoto.hidden = NO;
- // btnPhotos.hidden = NO;
- //
- // btnPhotos.frame = CGRectMake(78, 8, 40, 20);
- // btnVideos.frame = CGRectMake(122, 8, 42, 20);
- // btnEvents.frame = CGRectMake(169, 8, 42, 20);
- // }else {
- // btncoverphoto.hidden = YES;
- // btnPhotos.hidden = YES;
- // btnVideos.frame = CGRectMake(78, 8, 40, 20);
- // }
- //
- // BOOL createEvent = [[[[ApplicationData sharedInstance].dictextentionconfig objectForKey:@"jomsocial"] objectForKey:@"createEvent"]boolValue];
- // if (createEvent) {
- // btnEvents.hidden = NO;
- // btnPhotos.frame = CGRectMake(78, 8, 40, 20);
- // btnVideos.frame = CGRectMake(122, 8, 42, 20);
- // btnEvents.frame = CGRectMake(169, 8, 42, 20);
- // }else {
- // btnEvents.hidden = YES;
- // btnVideos.frame = CGRectMake(78, 8, 40, 20);
- // }
- [self themechange];
- }
- -(void)PhotoCaption{
- [spinner stopAnimating];
- [self showAlert:NSLocalizedString(@"Done_title",@"") Content:NSLocalizedString(@"photo_uploaded", @"")];
- }
- - (IBAction)whatstonurmindButtonPressed{
- btnwtsonurmind.hidden = YES;
- [txtStatus becomeFirstResponder];
- CGPoint tableViewCenter = [tableView contentOffset];
- tableViewCenter.y += tableView.frame.size.height/2;
- [tableView setContentOffset:CGPointMake(0,tableViewCenter.y) animated:YES];}
- -(void)viewDidAppear:(BOOL)animated {
- [super viewDidAppear:animated];
- if ([ApplicationData sharedInstance].flag_cov_photochanged == 1) {
- [ApplicationData sharedInstance].flag_cov_photochanged = 0;
- imgvw_cover.image = [ApplicationData sharedInstance].userDetail.coverImg;
- }
- if(isMainUserProfileView)
- {
- userDetail = [ApplicationData sharedInstance].userDetail;
- }
- if(![ApplicationData sharedInstance].isLoggedIn)
- {
- LoginViewController *controller = [[LoginViewController alloc] init];
- int k = [controller LogincheckDict];
- if (k == 1) {
- [controller LoginDone];
- [self viewDidAppear:NO];
- }
- else if (k==2)
- {
- [controller FBLoginDone];
- [self viewDidAppear:NO];
- }
- else
- {
- [self presentModalViewController:controller animated:YES];
- }
- [controller release];
- }
- else
- {
- if (userDetail.userId == 0)
- {
- btnfriend.hidden = YES;
- btncoverphoto.hidden = NO;
- //btnmessage.frame = CGRectMake(26, 263, 268, 30);
- //[btnmessage setBackgroundImage:[UIImage imageNamed:@"Lea_mesaage_box.png"] forState:UIControlStateNormal];
- }
- else
- {
- btncoverphoto.hidden = YES;
- //[btnmessage setBackgroundImage:[UIImage imageNamed:@"Lea_friend_btn.png"] forState:UIControlStateNormal];
- if (!userDetail.isFriend) {
- btnfriend.hidden = NO;
- [btnfriend setTitle:NSLocalizedString(@"addFriend", @"") forState:UIControlStateNormal];
- [btnfriend removeTarget:self action:@selector(removeFriendButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- [btnfriend addTarget:self action:@selector(addFriendButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- //btnmessage.frame = CGRectMake(169, 263, 118, 30);
- //btnfriend.frame = CGRectMake(34, 263, 118, 30);
- }else {
- btnfriend.hidden = NO;
- [btnfriend setTitle:NSLocalizedString(@"already_friend", @"") forState:UIControlStateNormal];
- [btnfriend removeTarget:self action:@selector(addFriendButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- [btnfriend addTarget:self action:@selector(removeFriendButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- //btnmessage.frame = CGRectMake(169, 263, 118, 30);
- //btnfriend.frame = CGRectMake(34, 263, 118, 30);
- }
- }
- if(userDetail) {
- timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(setUserData) userInfo:nil repeats:NO];
- }
- else {
- if(![ApplicationData sharedInstance].userDetailCached){
- [ApplicationData sharedInstance].userDetailCached = YES;
- timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(setUserData) userInfo:nil repeats:NO];
- }
- else if(btnEdit.hidden == NO)
- {
- //statusMsg.text = [userDetail status];
- CGSize stringsize1 = [[userDetail status] sizeWithFont:[statusMsg font]];
- if (stringsize1.width > 285)
- {
- //statusMsg.frame = CGRectMake(statusMsg.frame.origin.x, statusMsg.frame.origin.y, (stringsize1.width + 10.0), statusMsg.frame.size.height);
- //[scrstatusMsg setContentSize:(CGSizeMake((stringsize1.width + 15), 20))];
- }
- lblvideoMsg.text = [userDetail.profile_video objectForKey:@"title"];
- stringsize1 = [[userDetail.profile_video objectForKey:@"title"] sizeWithFont:[lblvideoMsg font]];
- if (stringsize1.width > 255)
- {
- lblvideoMsg.frame = CGRectMake(lblvideoMsg.frame.origin.x, lblvideoMsg.frame.origin.y, (stringsize1.width + 10.0), lblvideoMsg.frame.size.height);
- [scrvideoMsg setContentSize:(CGSizeMake((stringsize1.width + 15), 20))];
- }
- name.text = [userDetail userName];
- }
- if(![ApplicationData sharedInstance].userDetail.avatarImg ) {
- [self performSelectorOnMainThread:@selector(sendImageRequest) withObject:nil waitUntilDone:NO];
- }
- else {
- [userImg setImage:[userDetail avatarImg]];
- }
- }
- }
- iJoomerAppDelegate *appdelegate = (iJoomerAppDelegate *) [[UIApplication sharedApplication] delegate];
- [appdelegate fetchsidemenuList:@"JomProfile"];
- cellImageNames = [ApplicationData sharedInstance].profileMenuImages;
- [super viewDidAppear:YES];
- scrollMenu.contentSize = CGSizeMake(384, 78);
- if ([userDetail.status rangeOfString:@"{voice}"].location != NSNotFound) {
- Voiceview.hidden = NO;
- scrstatusMsg.hidden = YES;
- NSString *strTitle = userDetail.status;
- strTitle = [strTitle stringByReplacingOccurrencesOfString: @"{voice}" withString:@""];
- strTitle = [strTitle stringByReplacingOccurrencesOfString: @"{/voice}" withString:@""];
- NSArray *arr = [strTitle componentsSeparatedByString:@"&"];
- userDetail.playVoice = [arr objectAtIndex:0];
- lblSecond.text = [NSString stringWithFormat:@"%@ s",[arr objectAtIndex:1]];
- } else {
- Voiceview.hidden = YES;
- scrstatusMsg.hidden = NO;
- }
- }
- #pragma mark -
- #pragma mark themeChange
- -(void) themechange{
- [btnWritePost setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- [btnWritePost setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
- [btnPhotos setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- [btnPhotos setTitleColor:[UIColor blackColor] forState:UIControlStateSelected];
- [btnVideos setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- [btnVideos setTitleColor:[UIColor blackColor] forState:UIControlStateSelected];
- [btnEvents setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- [btnEvents setTitleColor:[UIColor blackColor] forState:UIControlStateSelected];
- if (photoSelectIndex == 888) {
- [btnWritePost setBackgroundColor:[UIColor clearColor]];
- [btnPhotos setBackgroundColor: palleteBlue];
- }
- else{
- [btnPhotos setBackgroundColor:[UIColor clearColor]];
- [btnVideos setBackgroundColor:[UIColor clearColor]];
- [btnEvents setBackgroundColor:[UIColor clearColor]];
- }
- // statusMsg.textColor=[UIColor blackColor];
- if (name.enabled == TRUE)
- {
- //name.textColor =[UIColor blackColor];
- }
- else
- {
- //name.textColor = [ApplicationData sharedInstance].textcolor;
- }
- lblDislikeCount.textColor = [ApplicationData sharedInstance].textcolor;
- tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- tableView.separatorColor = [UIColor clearColor];
- txtComment.textColor = [ApplicationData sharedInstance].textcolor;
- profileCount.textColor=[ApplicationData sharedInstance].textcolor;
- [btnPermission setTitleColor:[ApplicationData sharedInstance].textcolor forState:UIControlStateNormal];
- lbl_profileCount.textColor = [ApplicationData sharedInstance].textcolor;
- //name.font =[ApplicationData sharedInstance].header9;
- //statusMsg.font=[ApplicationData sharedInstance].header4;
- profileCount.font=[ApplicationData sharedInstance].header9;
- lbl_profileCount.font = [ApplicationData sharedInstance].header9;
- backImg.image = [UIImage imageNamed:[ApplicationData sharedInstance].bgImage];
- spinner.layer.cornerRadius = 8;
- spinner.layer.masksToBounds = YES;
- //[spinner setBackgroundColor:[ApplicationData sharedInstance].textcolor];
- txtStatus.layer.cornerRadius = 4;
- txtStatus.layer.masksToBounds = YES;
- btnsend.layer.cornerRadius = 8;
- btnsend.layer.masksToBounds = YES;
- //layer for Send Button
- CALayer *imgLayerSend = [btnsend layer];
- [btnsend setBackgroundColor: palletePurple];
- [imgLayerSend setMasksToBounds:YES];
- [imgLayerSend setCornerRadius:3.0];
- [imgLayerSend setBorderWidth:0.0];
- [imgLayerSend setBorderColor:[[UIColor clearColor] CGColor]];
- //lblViews.textColor = [ApplicationData sharedInstance].textcolorhead;
- //lblAbout.textColor = [ApplicationData sharedInstance].textcolorhead;
- //lblFriends.textColor = [ApplicationData sharedInstance].textcolorhead;
- lblMap.textColor = [ApplicationData sharedInstance].textcolorhead;
- //lblPhotos.textColor = [ApplicationData sharedInstance].textcolorhead;
- //lblVideos.textColor = [ApplicationData sharedInstance].textcolorhead;
- //lblRecentTitle.textColor = [ApplicationData sharedInstance].textcolor;
- //[btnfriend setTitleColor:[ApplicationData sharedInstance].textcolorWhite forState:UIControlStateNormal];
- //[btnmessage setTitleColor:[ApplicationData sharedInstance].textcolorWhite forState:UIControlStateNormal];
- //[btnsend setTitleColor:[ApplicationData sharedInstance].textcolorWhite forState:UIControlStateNormal];
- // [Voiceover setBackgroundColor:[ApplicationData sharedInstance].VoiceViewcolor];
- //for photo caption
- txtPhotoCaption.layer.cornerRadius = 4;
- txtPhotoCaption.layer.masksToBounds = YES;
- CALayer *imgLayerphotocaptionSend = [btnsend layer];
- [btnPhotocaptionSend setBackgroundColor:palletePurple];
- [imgLayerphotocaptionSend setMasksToBounds:YES];
- [imgLayerphotocaptionSend setCornerRadius:3.0];
- [imgLayerphotocaptionSend setBorderWidth:0.0];
- [imgLayerphotocaptionSend setBorderColor:[[UIColor clearColor] CGColor]];
- btnPhotocaptionSend.layer.cornerRadius = 8;
- btnPhotocaptionSend.layer.masksToBounds = YES;
- //[VoiceoverPhotoCaption setBackgroundColor:[ApplicationData sharedInstance].VoiceViewcolor];
- [tableView reloadData];
- }
- #pragma mark -
- #pragma mark textField
- - (BOOL)textFieldShouldReturn: (UITextField *)textField {
- [textField resignFirstResponder];
- return YES;
- }
- - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView {
- if (txtStatus.text.length == 0)
- {
- btnwtsonurmind.hidden = NO;
- }else{
- btnwtsonurmind.hidden = YES;
- }
- }// called on finger up as we are moving
- - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
- }// called when scroll view grinds to a halt
- - (void)textViewDidBeginEditing:(UITextView *)textView {
- // CGPoint tableViewCenter = [tableView contentOffset];
- // tableViewCenter.y += tableView.frame.size.height/2;
- // [tableView setContentOffset:CGPointMake(0,tableViewCenter.y) animated:YES];
- if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
- CGSize result = [[UIScreen mainScreen] bounds].size;
- if(result.height == 480) {
- [tableView setContentOffset:CGPointMake(0,260) animated:YES];
- } else if(result.height == 568) {
- [tableView setContentOffset:CGPointMake(0,170) animated:YES];
- }
- }
- }
- - (void)cancelPressed {
- if (txtComment.text.length > 0) {
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"button_cancel",@"") message:NSLocalizedString(@"sure_cancel", @"") delegate:self cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"lblNo", @"No"), NSLocalizedString(@"lblYes", @"Yes"), nil];
- alert.tag = 2;
- [alert show];
- [alert release];
- } else {
- [[self.view findFirstResponder] resignFirstResponder];
- txtComment.backgroundColor =[UIColor whiteColor];
- txtComment.frame = CGRectMake(10.0, 250.0, 300.0, 45.0);
- if (userDetail.userId == 0)
- {
- btnEdit.hidden = NO;
- self.navigationItem.leftBarButtonItem = nil;
- }
- else
- {
- if (userDetail.isFriend)
- {
- self.navigationItem.rightBarButtonItem = nil;
- btnEdit.hidden = YES;
- }
- else
- {
- btnEdit.hidden = NO;
- }
- }
- txtComment.hidden = YES;
- }
- }
- - (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex {
- if ((buttonIndex == 1) && (alertView.tag == 2)) {
- [[self.view findFirstResponder] resignFirstResponder];
- txtComment.backgroundColor =[UIColor whiteColor];
- txtComment.frame = CGRectMake(10.0, 250.0, 300.0, 45.0);
- txtComment.hidden = YES;
- txtComment.text = @"";
- // [txtStatus setHidden:YES];
- [txtComment resignFirstResponder];
- // self.navigationItem.leftBarButtonItem = nil;
- if (userDetail.userId == 0) {
- btnEdit.hidden = NO;
- self.navigationItem.leftBarButtonItem = nil;
- }else {
- if (userDetail.isFriend) {
- self.navigationItem.rightBarButtonItem = nil;
- btnEdit.hidden = YES;
- }else {
- btnEdit.hidden = NO;
- }
- }
- }
- if ((buttonIndex == 1) && (alertView.tag == 3)) {
- Wall *record = [tempArray objectAtIndex:deleteIndex];
- NSMutableDictionary *postVariables = [[NSMutableDictionary alloc] init];
- [postVariables setObject:[NSString stringWithFormat:@"%d",record.wallId] forKey:@"uniqueID"];
- [postVariables setObject:[NSString stringWithFormat:@"%d",0] forKey:@"comment"];
- NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"wall" ExtTask:@"remove" TaskdataDictionary:postVariables Imagedata:nil];
- currentRequestType = jDeleteWallQuery;
- [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
- // userDetail = [[GlobalObjects Wall:dict] retain];
- // DLog(@"count:%d",[userDetail.groupList count]);
- if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
- [self requestCompleted];
- }else {
- self.view.userInteractionEnabled = YES;
- }
- }
- if ((buttonIndex == 1) && (alertView.tag == 8)) {
- [spinner startAnimating];
- [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(removeFriend) userInfo:nil repeats:NO];
- }
- if ((buttonIndex == 0) && (alertView.tag == 1)){
- [[self.view findFirstResponder] resignFirstResponder];
- [self addNew];
- }
- else if(buttonIndex == 1 && (alertView.tag == 1)){
- [[self.view findFirstResponder] resignFirstResponder];
- }
- }
- -(void)removeFriend {
- NSMutableDictionary *postVariables = [[NSMutableDictionary alloc] init];
- [postVariables setObject:[NSString stringWithFormat:@"%d",userDetail.userId] forKey:@"memberID"];
- NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"friend" ExtTask:@"removeFriend" TaskdataDictionary:postVariables Imagedata:nil];
- currentRequestType =
- [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
- if ([ApplicationData sharedInstance].errorCode == 200) {
- [spinner startAnimating];
- [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(profileRequest) userInfo:nil repeats:NO];
- }
- }
- -(void)update{
- [spinner stopAnimating];
- [self showAlert:NSLocalizedString(@"Done_title",@"") Content:NSLocalizedString(@"update_success", @"")];
- }
- - (void)doneButtonPressed {
- [[self.view findFirstResponder] resignFirstResponder];
- txtStatus.backgroundColor =[UIColor whiteColor];
- // txtStatus.frame = CGRectMake(10.0, 250.0, 300.0, 45.0);
- if (userDetail.userId == 0) {
- btnEdit.hidden = NO;
- self.navigationItem.leftBarButtonItem = nil;
- }else {
- if (userDetail.isFriend) {
- self.navigationItem.rightBarButtonItem = nil;
- btnEdit.hidden = YES;
- }else {
- btnEdit.hidden = NO;
- }
- }
- }
- - (IBAction)dismissActionSheet:(id)sender
- {
- [alertController dismissViewControllerAnimated:NO completion:nil];
- }
- - (IBAction)DoneActionSheet:(id)sender
- {
- [alertController dismissViewControllerAnimated:NO completion:nil];
- [btnPermission setTitle:[permissions objectAtIndex:rowIndex] forState:UIControlStateNormal];
- if ([btnPermission.titleLabel.text isEqualToString:NSLocalizedString(@"Public_title",@"")]) {
- permissionValue = 0;
- }else if ([btnPermission.titleLabel.text isEqualToString:NSLocalizedString(@"sitemember_title",@"")]) {
- permissionValue = 20;
- }else if ([btnPermission.titleLabel.text isEqualToString:NSLocalizedString(@"friends_title",@"")]) {
- permissionValue = 30;
- }else if ([btnPermission.titleLabel.text isEqualToString:NSLocalizedString(@"onlyme_title",@"")]) {
- permissionValue = 40;
- }
- }
- - (IBAction)PermissionButtonPressed:(id)sender {
- if ([[[UIDevice currentDevice]systemVersion]floatValue] >= 8.0) {
- alertController = [UIAlertController alertControllerWithTitle:@" \n\n\n\n\n\n\n\n\n\n\n"
- message:@""
- preferredStyle:UIAlertControllerStyleActionSheet];
- UIPickerView *selectionPicker1=[[UIPickerView alloc]init];
- selectionPicker1 = [[UIPickerView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 120.0)];
- selectionPicker1.showsSelectionIndicator = YES;
- selectionPicker1.dataSource = self;
- selectionPicker1.delegate = self;
- [alertController.view addSubview:selectionPicker1];
- UISegmentedControl *closePicker = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:NSLocalizedString(@"button_Cancel",@"Cancel")]];
- closePicker.momentary = YES;
- closePicker.frame = CGRectMake(5, 175.0f, 140, 30.0f);
- closePicker.segmentedControlStyle = UISegmentedControlStyleBar;
- closePicker.tintColor = [UIColor blackColor];
- [closePicker addTarget:self action:@selector(dismissActionSheet:) forControlEvents:UIControlEventValueChanged];
- [alertController.view addSubview:closePicker];
- UISegmentedControl *donePicker = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:NSLocalizedString(@"button_done", @"Done")]];
- donePicker.momentary = YES;
- donePicker.frame = CGRectMake(160, 175.0f, 140, 30.0f);
- donePicker.segmentedControlStyle = UISegmentedControlStyleBar;
- donePicker.tintColor = [UIColor blackColor];
- [donePicker addTarget:self action:@selector(DoneActionSheet:) forControlEvents:UIControlEventValueChanged];
- [alertController.view addSubview:donePicker];
- [self presentViewController:alertController animated:YES completion:nil];
- }
- else
- {
- UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"\n\n\n\n\n\n\n\n\n\n\n"
- delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil
- otherButtonTitles:NSLocalizedString(@"Done_title",@""),NSLocalizedString(@"button_cancel",@""),nil];
- actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
- actionSheet.tag = 4;
- UIPickerView *selectionPicker = [[UIPickerView alloc] initWithFrame:CGRectZero];
- selectionPicker.delegate = self;
- selectionPicker.dataSource = self;
- selectionPicker.showsSelectionIndicator = YES;
- actionSheet.alpha = 1.0;
- // add this picker to our view controller, initially hidden
- [actionSheet insertSubview:selectionPicker atIndex:0];
- actionSheet.destructiveButtonIndex =1; // make the second button red (destructive)
- [actionSheet showInView:self.view];// showInView:self.view]; // show from our tabbar view (pops up in the middle of the tabbar)
- [actionSheet release];
- }
- }
- -(IBAction)ShareButtonPressed:(id)sender
- {
- sendertag = 0;
- if (txtStatus.text.length == 0)
- {
- [self showAlert:NSLocalizedString(@"no_text",@"") Content:NSLocalizedString(@"Please_enter_text", @"")];
- return;
- }
- if (userDetail.userId == 0)
- {
- NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
- [postVariables setObject:txtStatus.text forKey:@"message"];
- [postVariables setObject:[NSString stringWithFormat:@"%d",permissionValue] forKey:@"privacy"];
- [postVariables setObject:[NSString stringWithFormat:@"%d",0] forKey:@"comment"];
- NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"wall" ExtTask:@"add" TaskdataDictionary:postVariables Imagedata:nil];
- newWall = [GlobalObjects Share:dict];
- [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
- currentRequestType = jStatusQuery;
- if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
- [self requestCompleted];
- }else {
- self.view.userInteractionEnabled = YES;
- }
- }
- else
- {
- NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
- [postVariables setObject:txtStatus.text forKey:@"message"];
- [postVariables setObject:[NSString stringWithFormat:@"%d",userDetail.userId] forKey:@"uniqueID"];
- [postVariables setObject:[NSString stringWithFormat:@"%d",permissionValue] forKey:@"privacy"];
- [postVariables setObject:[NSString stringWithFormat:@"%d",0] forKey:@"comment"];
- // [postVariables setObject:[NSString stringWithFormat:@"%d",permissionValue] forKey:@"permissions"];
- NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"wall" ExtTask:@"add" TaskdataDictionary:postVariables Imagedata:nil];
- [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
- currentRequestType = jShareQuery;
- if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
- [self requestCompleted];
- }else {
- self.view.userInteractionEnabled = YES;
- }
- }
- [txtStatus resignFirstResponder];
- }
- - (IBAction) movieFinished: (id) sender {
- [mp stop];
- }
- //For Playing
- - (IBAction)PlayButtonPressed:(id)sender {
- // Make sure the audio is at the start of the stream.
- if(![sender isSelected]) {
- // Wall *record = [[ApplicationData sharedInstance].updatesList objectAtIndex:[sender tag]];
- // wallRecord = record;
- NSString *strTitle = userDetail.status;
- // strTitle = [strTitle stringByReplacingOccurrencesOfString: @"{voice}" withString:@""];
- // strTitle = [strTitle stringByReplacingOccurrencesOfString: @"{/voice}" withString:@""];
- strTitle = [self stringBetweenString:@"{voice}" andString:@"{/voice}"];
- NSArray *arr = [strTitle componentsSeparatedByString:@"&"];
- userDetail.playVoice = [arr objectAtIndex:0];
- [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
- [[AVAudioSession sharedInstance] setActive: YES error: nil];
- NSURL *url;
- url = [NSURL URLWithString:userDetail.playVoice];
- DLog(@"url : %@",url);
- mp = [[MPMoviePlayerController alloc] initWithContentURL:url];
- [mp prepareToPlay];
- [mp play];
- DLog(@"Play...");
- }else{
- [mp stop];
- DLog(@"Stop...");
- }
- [sender setSelected:![sender isSelected]];
- }
- -(NSString*)stringBetweenString:(NSString*)start andString:(NSString*)end {
- NSRange startRange = [userDetail.status rangeOfString:start];
- if (startRange.location != NSNotFound) {
- NSRange targetRange;
- targetRange.location = startRange.location + startRange.length;
- targetRange.length = [userDetail.status length] - targetRange.location;
- NSRange endRange = [userDetail.status rangeOfString:end options:0 range:targetRange];
- if (endRange.location != NSNotFound) {
- targetRange.length = endRange.location - targetRange.location;
- DLog(@"title : %@",userDetail.status);
- return [userDetail.status substringWithRange:targetRange];
- }
- }
- return nil;
- }
- - (IBAction)PlayContentButtonPressed:(id)sender {
- // Make sure the audio is at the start of the stream.
- if(![sender isSelected]) {
- tempArray = userDetail.wallList;
- Wall *record = [tempArray objectAtIndex:[sender tag]];
- wallRecord = record;
- NSString *strTitle = record.content;
- // strTitle = [strTitle stringByReplacingOccurrencesOfString: @"{voice}" withString:@""];
- // strTitle = [strTitle stringByReplacingOccurrencesOfString: @"{/voice}" withString:@""];
- strTitle = [self stringBetweenStringContent:@"{voice}" andString:@"{/voice}"];
- NSArray *arr = [strTitle componentsSeparatedByString:@"&"];
- record.playVoiceContent = [arr objectAtIndex:0];
- [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
- [[AVAudioSession sharedInstance] setActive: YES error: nil];
- NSURL *url;
- url = [NSURL URLWithString:record.playVoiceContent];
- DLog(@"url : %@",url);
- mp = [[MPMoviePlayerController alloc] initWithContentURL:url];
- [mp prepareToPlay];
- [mp play];
- DLog(@"Play1...");
- }else{
- [mp stop];
- DLog(@"Stop1...");
- ;}
- [sender setSelected:![sender isSelected]];
- }
- -(NSString*)stringBetweenStringContent:(NSString*)start andString:(NSString*)end1 {
- NSRange startRange = [wallRecord.content rangeOfString:start];
- if (startRange.location != NSNotFound) {
- NSRange targetRange;
- targetRange.location = startRange.location + startRange.length;
- targetRange.length = [wallRecord.content length] - targetRange.location;
- NSRange endRange = [wallRecord.content rangeOfString:end1 options:0 range:targetRange];
- if (endRange.location != NSNotFound) {
- targetRange.length = endRange.location - targetRange.location;
- DLog(@"title : %@",wallRecord.content);
- return [wallRecord.content substringWithRange:targetRange];
- }
- }
- return nil;
- }
- - (IBAction)PlayTitleButtonPressed:(id)sender {
- // Make sure the audio is at the start of the stream.
- if(![sender isSelected]) {
- tempArray = userDetail.wallList;
- Wall *record = [tempArray objectAtIndex:[sender tag]];
- wallRecord = record;
- NSString *strTitle = record.title;
- // strTitle = [strTitle stringByReplacingOccurrencesOfString: @"{voice}" withString:@""];
- // strTitle = [strTitle stringByReplacingOccurrencesOfString: @"{/voice}" withString:@""];
- strTitle = [self stringBetweenStringTitle:@"{voice}" andString:@"{/voice}"];
- NSArray *arr = [strTitle componentsSeparatedByString:@"&"];
- record.playVoice = [arr objectAtIndex:0];
- [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
- [[AVAudioSession sharedInstance] setActive: YES error: nil];
- NSURL *url;
- url = [NSURL URLWithString:record.playVoice];
- DLog(@"url : %@",url);
- mp = [[MPMoviePlayerController alloc] initWithContentURL:url];
- [mp prepareToPlay];
- [mp play];
- DLog(@"Play...");
- }else{
- [mp stop];
- DLog(@"Stop...");
- }
- [sender setSelected:![sender isSelected]];
- }
- -(NSString*)stringBetweenStringTitle:(NSString*)start andString:(NSString*)end {
- NSRange startRange = [wallRecord.title rangeOfString:start];
- if (startRange.location != NSNotFound) {
- NSRange targetRange;
- targetRange.location = startRange.location + startRange.length;
- targetRange.length = [wallRecord.title length] - targetRange.location;
- NSRange endRange = [wallRecord.title rangeOfString:end options:0 range:targetRange];
- if (endRange.location != NSNotFound) {
- targetRange.length = endRange.location - targetRange.location;
- DLog(@"title : %@",wallRecord.title);
- return [wallRecord.title substringWithRange:targetRange];
- }
- }
- return nil;
- }
- -(IBAction)voiceSendButtonPressed:(id)sender {
- if (userDetail.userId == 0)
- {
- sendertag = -888;
- [Voiceover HoldAndSpeakButtonPressed:nil];
- if ([[ApplicationData sharedInstance].VoiceCurrentTime isEqualToString:@"00:00"]) {
- [spinner stopAnimating];
- DLog(@"return update...");
- return;
- }
- NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
- [postVariables setObject:txtStatus.text forKey:@"message"];
- [postVariables setObject:[NSString stringWithFormat:@"%d",permissionValue] forKey:@"privacy"];
- [postVariables setObject:[NSString stringWithFormat:@"%d",0] forKey:@"comment"];
- NSDictionary *dict = [Jomsocial JomsocialCommonDictfunctionVoice:@"wall" ExtTask:@"add" TaskdataDictionary:postVariables Voicedata:[ApplicationData sharedInstance].Voicedata voicename:@"voice"];
- newWall = [GlobalObjects Share:dict];
- [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
- currentRequestType = jStatusQuery;
- if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
- [self requestCompleted];
- }else {
- self.view.userInteractionEnabled = YES;
- }
- }
- else
- {
- [Voiceover HoldAndSpeakButtonPressed:nil];
- if ([[ApplicationData sharedInstance].VoiceCurrentTime isEqualToString:@"00:00"]) {
- [spinner stopAnimating];
- DLog(@"return update...");
- return;
- }
- NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
- [postVariables setObject:txtStatus.text forKey:@"message"];
- [postVariables setObject:[NSString stringWithFormat:@"%d",userDetail.userId] forKey:@"uniqueID"];
- [postVariables setObject:[NSString stringWithFormat:@"%d",permissionValue] forKey:@"privacy"];
- [postVariables setObject:[NSString stringWithFormat:@"%d",0] forKey:@"comment"];
- // [postVariables setObject:[NSString stringWithFormat:@"%d",permissionValue] forKey:@"permissions"];
- NSDictionary *dict = [Jomsocial JomsocialCommonDictfunctionVoice:@"wall" ExtTask:@"add" TaskdataDictionary:postVariables Voicedata:[ApplicationData sharedInstance].Voicedata voicename:@"voice"];
- [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
- currentRequestType = jShareQuery;
- if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
- [self requestCompleted];
- }else {
- self.view.userInteractionEnabled = YES;
- }
- }
- }
- -(IBAction)VoiceButtonPressed:(id)sender{
- // self.view.userInteractionEnabled = NO;
- [spinner startAnimating];
- Voiceover.SpeakerView.hidden = YES;
- [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(voiceSendButtonPressed:) userInfo:nil repeats:NO];
- }
- -(IBAction)voicePhotoCaptionSendButtonPressed:(id)sender {
- [ApplicationData sharedInstance].VoicePhotocaption = 199;
- [Voiceover HoldAndSpeakButtonPressed:nil];
- if ([[ApplicationData sharedInstance].VoiceCurrentTime isEqualToString:@"00:00"]) {
- [spinner stopAnimating];
- DLog(@"return update...");
- return;
- }
- NSData *imgData = UIImagePNGRepresentation(userImage); //UIImageJPEGRepresentation(userImage, 1.0);
- NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
- [postVariables setObject:@"0" forKey:@"isDefault"];
- [postVariables setObject:txtPhotoCaption.text forKey:@"caption"];
- [postVariables setObject:@"true" forKey:@"profile"];
- NSDictionary *dict1=[Jomsocial JomsocialCommonDictfunctionVoice:@"media" ExtTask:@"uploadphoto" TaskdataDictionary:postVariables Imagedata:imgData Voicedata:[ApplicationData sharedInstance].Voicedata voicename:@"voice"];
- [ApplicationData sharedInstance].errorCode = [[dict1 objectForKey:TAG_CODE] intValue];
- currentRequestType = jGeneralQuery;
- if([ErrorHandler hasError:self errorCode:[[dict1 objectForKey:TAG_CODE] intValue] errorMessage:[dict1 objectForKey:TAG_ERROR_MESSAGE]]){
- [self requestCompleted];
- }else {
- self.view.userInteractionEnabled = YES;
- }
- }
- -(IBAction)VoicePhotoCaptionButtonPressed:(id)sender{
- // self.view.userInteractionEnabled = NO;
- [spinner startAnimating];
- VoiceoverPhotoCaption.SpeakerView.hidden = YES;
- [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(voicePhotoCaptionSendButtonPressed:) userInfo:nil repeats:NO];
- }
- -(IBAction)WritePostPressed:(id)sender {
- photoSelectIndex = 999;
- [ApplicationData sharedInstance].VoicePhotocaption = 199;
- Voiceover.hidden = NO;
- VoiceoverPhotoCaption.hidden = YES;
- imgPhotoPrev.hidden = YES;
- imgPhotoBackPrev.hidden = YES;
- [btnWritePost setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
- [btnWritePost setBackgroundColor: palleteBlue];
- [btnPhotos setBackgroundColor:[UIColor clearColor]];
- }
- -(IBAction)PhotosPressed:(id)sender {
- if (txtPhotoCaption.text.length >0) {
- btnPhotocaption.hidden = YES;
- }else{
- btnPhotocaption.hidden = NO;
- }
- [ApplicationData sharedInstance].VoicePhotocaption = 9999;;
- isProfilePic = NO;
- imgPhotoPrev.hidden = YES;
- imgPhotoBackPrev.hidden = YES;
- [btnWritePost setBackgroundColor:[UIColor clearColor]];
- Voiceover.hidden = YES;
- VoiceoverPhotoCaption.hidden = NO;
- [self openPhotoGallery:nil];
- [btnPhotos setBackgroundColor: palleteBlue ];
- [btnPhotocaption setTitle:NSLocalizedString(@"photo_caption", @"") forState:UIControlStateNormal];
- }
- -(IBAction)VideosPressed:(id)sender {
- [ApplicationData sharedInstance].VoicePhotocaption = 199;
- [btnVideos setBackgroundColor: palleteBlue];
- photoSelectIndex = 999;
- VideoViewController *controller = [[VideoViewController alloc]init];
- controller.isWall = YES;
- controller.userDetail = userDetail;
- [self.navigationController pushViewController:controller animated:YES];
- [controller release];
- }
- -(IBAction)EventsPressed:(id)sender {
- [btnEvents setBackgroundColor: palleteBlue];
- photoSelectIndex = 999;
- [ApplicationData sharedInstance].VoicePhotocaption = 199;
- JomEditEventViewController *controller = [[JomEditEventViewController alloc] init];
- [[self navigationController] pushViewController:controller animated:YES];
- [controller release];
- }
- - (IBAction)openPhotoGallery:(id) sender {
- // if ([sender isEqual:changeImg]) {
- // isProfilePic = YES;
- // }
- UIActionSheet *actionSheet;
- if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == YES) {
- actionSheet = [[UIActionSheet alloc]
- initWithTitle:NSLocalizedString(@"addPic",@"")
- delegate:self
- cancelButtonTitle:nil
- destructiveButtonTitle:NSLocalizedString(@"button_cancel",@"")
- otherButtonTitles:NSLocalizedString(@"gallery",@""),NSLocalizedString(@"cam",@""),nil];
- } else {
- actionSheet = [[UIActionSheet alloc]
- initWithTitle:NSLocalizedString(@"addPic",@"")
- delegate:self
- cancelButtonTitle:nil
- destructiveButtonTitle:NSLocalizedString(@"button_cancel",@"")
- otherButtonTitles:NSLocalizedString(@"gallery",@""),nil];
- }
- actionSheet.tag = 888;
- actionSheet.alpha = 1.0;
- [actionSheet showInView:self.view]; //showInView:self.view]; // show from our tabbar view (pops up in the middle of the tabbar)
- [actionSheet release];
- }
- //////////////////////////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////// PickerView Delegate //////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////////////////////
- - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView {
- return 1;
- }
- - (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
- return [permissions count];
- }
- - (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
- return [permissions objectAtIndex:row];
- }
- - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {
- return 240;
- }
- - (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
- rowIndex = row;
- [permissions objectAtIndex:row];
- // [btnPermission setTitle:[permissions objectAtIndex:row] forState:UIControlStateNormal];
- [btnPermission setTitle:[NSString stringWithFormat:@" %@",[permissions objectAtIndex:row]] forState:UIControlStateNormal];
- }
- #pragma mark -
- #pragma mark fetchData & requestCompleted
- - (BOOL)Userdata_update
- {
- NSMutableDictionary *postVariables = [[NSMutableDictionary alloc] init];
- [postVariables setObject:[NSString stringWithFormat:@"%d",userDetail.userId] forKey:@"userID"];
- NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"user" ExtTask:@"profile" TaskdataDictionary:postVariables Imagedata:nil];
- [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
- if ([[dict objectForKey:TAG_CODE] intValue] == 200)
- {
- User *userObj = [GlobalObjects ProfileDetail:dict];
- [ApplicationData sharedInstance].loggedUser = userObj.userId;
- [ApplicationData sharedInstance].userDetail.userId = userObj.userId;
- [ApplicationData sharedInstance].sessionId = userObj.sessionid;
- [ApplicationData sharedInstance].userDetail.userName = userObj.userName;
- [ApplicationData sharedInstance].userDetail.userEmail = userObj.userEmail;
- [ApplicationData sharedInstance].userDetail.code = userObj.code;
- [ApplicationData sharedInstance].errorCode = userObj.code;
- [ApplicationData sharedInstance].userDetail.avatarURL = userObj.avatarURL;
- [ApplicationData sharedInstance].userDetail.status = userObj.status;
- [ApplicationData sharedInstance].userDetail.viewCount = userObj.viewCount;
- [ApplicationData sharedInstance].userDetail.Liked = userObj.Liked;
- [ApplicationData sharedInstance].userDetail.Disliked = userObj.Disliked;
- [ApplicationData sharedInstance].userDetail.Likes = userObj.Likes;
- [ApplicationData sharedInstance].userDetail.Dislikes = userObj.Dislikes;
- [ApplicationData sharedInstance].userDetail.coverpicURL = userObj.coverpicURL;
- [ApplicationData sharedInstance].userDetail.profile_video = userObj.profile_video;
- return YES;
- }
- else
- {
- return NO;
- }
- currentRequestType = jProfileQuery;
- if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
- [self requestCompleted];
- }else {
- self.view.userInteractionEnabled = YES;
- }
- }
- -(void)profileRequest
- {
- NSMutableDictionary *postVariables = [[NSMutableDictionary alloc] init];
- [postVariables setObject:[NSString stringWithFormat:@"%d",userDetail.userId] forKey:@"userID"];
- NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"user" ExtTask:@"profile" TaskdataDictionary:postVariables Imagedata:nil];
- [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
- User *userObj = [GlobalObjects ProfileDetail:dict];
- userDetail.userName = userObj.userName;
- userDetail.code = userObj.code;
- [ApplicationData sharedInstance].errorCode = userObj.code;
- userDetail.avatarURL = userObj.avatarURL;
- userDetail.status = userObj.status;
- userDetail.email = userObj.userEmail;
- userDetail.coverpicURL = userObj.coverpicURL;
- userDetail.viewCount = userObj.viewCount;
- userDetail.Liked = userObj.Liked;
- userDetail.Disliked = userObj.Disliked;
- userDetail.Likes = userObj.Likes;
- userDetail.Dislikes = userObj.Dislikes;
- userDetail.isFriend = userObj.isFriend;
- userDetail.pending = userObj.pending;
- userDetail.viewCount = userObj.viewCount;
- userDetail.TotalPhotos = userObj.TotalPhotos;
- userDetail.totalAlbum = userObj.totalAlbum;
- userDetail.TotalFriends = userObj.TotalFriends;
- // userDetail.profile_video = [userObj.profile_video objectForKey:@"url"];
- userDetail.profile_video = [dict valueForKey:@"profile_video"];
- DLog(@"name:%@",userDetail.userName);
- currentRequestType = jProfileQuery;
- if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
- [self requestCompleted];
- }else {
- self.view.userInteractionEnabled = YES;
- }
- }
- -(void)fetchWall {
- [spinner startAnimating];
- [self performSelector:@selector(fetchwallWithSpinner) withObject:nil afterDelay:1];
- }
- -(void)fetchwallWithSpinner{
- DLog(@"lat:%f long:%f",userDetail.latitude,userDetail.longitude);
- NSMutableDictionary *postVariables = [[NSMutableDictionary alloc] init];
- if (userDetail.userId != 0)
- {
- [postVariables setObject:[NSString stringWithFormat:@"%d",userDetail.userId] forKey:@"userID"];
- }
- [postVariables setObject:@"wall" forKey:@"type"];
- [postVariables setObject:[NSString stringWithFormat:@"%d",pageNo] forKey:@"pageNO"];
- NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"wall" ExtTask:@"wall" TaskdataDictionary:postVariables Imagedata:nil];
- currentRequestType = jWallListQuery;
- [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
- tempArray = [GlobalObjects Wall:dict];
- [ApplicationData sharedInstance].totalWall = [[dict objectForKey:@"total"] intValue];
- if ([userDetail.wallList count] == 0) {
- userDetail.wallList = tempArray;
- }else {
- for (int i = 0 ; i < [tempArray count]; i++) {
- Wall *wallObj = [tempArray objectAtIndex:i];
- [userDetail.wallList addObject:wallObj];
- [wallObj release];
- }
- }
- userDetail.wallList = tempArray;
- tempArray = userDetail.wallList;
- if ([ApplicationData sharedInstance].errorCode != 204) {
- if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:@""]){
- [self requestCompleted];
- }else {
- self.view.userInteractionEnabled = YES;
- }
- }else {
- [ApplicationData sharedInstance].totalWall = 0;
- [spinner stopAnimating];
- self.view.userInteractionEnabled = YES;
- }
- }
- -(void)jBadRequest{
- [self showAlert:NSLocalizedString(@"alert_error",@"Error title") Content:NSLocalizedString(@"Wrong Data.", @"")];
- }
- -(void)jErroronServer{
- [self showAlert:NSLocalizedString(@"alert_error",@"Error title") Content:NSLocalizedString(@"Server Error.", @"")];
- }
- -(void)jErrorMessage{
- [self showAlert:NSLocalizedString(@"alert_error",@"Error title") Content:@"No Such Request Found."];
- }
- -(void)jNoContent{
- [self showAlert:NSLocalizedString(@"Message",@"Error title") Content:NSLocalizedString(@"No Content Found.", @"")];
- }
- -(void)jUnsupportedFile {
- [self showAlert:NSLocalizedString(@"alert_error",@"Error title") Content:NSLocalizedString(@"Unsupported File Type.", @"")];
- }
- -(void)jInvalidData {
- [self showAlert:NSLocalizedString(@"alert_error",@"Error title") Content:NSLocalizedString(@"Upload Limit Exceeded.", @"")];
- }
- -(void)jUserNameError {
- [self showAlert:NSLocalizedString(@"Message",@"Error title") Content:NSLocalizedString(@"Username Already Exists.", @"")];
- }
- -(void)jEmailError {
- [self showAlert:NSLocalizedString(@"Message",@"Error title") Content:NSLocalizedString(@"Email Already Exists.", @"")];
- }
- -(void)jFBOption {
- [self showAlert:NSLocalizedString(@"Message",@"Error title") Content:NSLocalizedString(@"Facebook User Not Found.", @"")];
- }
- -(void)jReportedContent {
- [self showAlert:NSLocalizedString(@"Message",@"Error title") Content:NSLocalizedString(@"Permission Denied.", @"")];
- }
- -(void)JPermissionError {
- [self showAlert:NSLocalizedString(@"Message",@"Error title") Content:NSLocalizedString(@"Restricted Access.", @"")];
- }
- -(void)jDuplicateData {
- [self showAlert:NSLocalizedString(@"Message",@"Error title") Content:NSLocalizedString(@"Request already exists.", @"")];
- }
- -(void)jWaitingForPermission {
- [self showAlert:NSLocalizedString(@"Message",@"Error title") Content:NSLocalizedString(@"Awaiting approval.", @"")];
- }
- - (void)requestCompleted {
- [spinner stopAnimating];
- [self stopLoading];
- self.view.userInteractionEnabled = YES;
- if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
- CGSize result = [[UIScreen mainScreen] bounds].size;
- if(result.height == 480) {
- if (isTabbarHidden == YES) {
- tableView.frame = CGRectMake(0, 0, 320, 415 -30);
- }
- else {
- tableView.frame = CGRectMake(0, 0, 320, 365 -30);
- }
- }
- else if(result.height == 568) {
- if (isTabbarHidden == YES) {
- tableView.frame = CGRectMake(0, 0, 320, 500 -30);
- }
- else {
- tableView.frame = CGRectMake(0, 0, 320, 455 -30);
- } // iPhone 5
- }
- }
- if([imageDownloadsInProgress count] == 0)
- {
- }
- [tabBarLayerView removeFromSuperview];
- // switch ([ApplicationData sharedInstance].errorCode)
- // {
- // case jBadRequest:
- // [self performSelectorOnMainThread:@selector(jBadRequest) withObject:nil waitUntilDone:NO];
- // break;
- //
- // case jLoginRequired:
- // [[ApplicationData sharedInstance] logout:self];
- // [self performSelectorOnMainThread:@selector(openLoginView) withObject:nil waitUntilDone:YES];
- // break;
- //
- // case jErroronServer:
- // [self performSelectorOnMainThread:@selector(jErrorMessage) withObject:nil waitUntilDone:NO];
- // break;
- //
- // case jNoContent:
- // [self performSelectorOnMainThread:@selector(jNoContent) withObject:nil waitUntilDone:NO];
- // break;
- //
- // case jErrorMessage:
- // [self performSelectorOnMainThread:@selector(jErrorMessage) withObject:nil waitUntilDone:NO];
- // break;
- //
- // case jUnsupportedFile:
- // [self performSelectorOnMainThread:@selector(jUnsupportedFile) withObject:nil waitUntilDone:NO];
- // break;
- //
- // case jInvalidData:
- // [self performSelectorOnMainThread:@selector(jInvalidData) withObject:nil waitUntilDone:NO];
- // break;
- //
- // case jUserNameError:
- // [self performSelectorOnMainThread:@selector(jUserNameError) withObject:nil waitUntilDone:NO];
- // break;
- //
- // case jEmailError:
- // [self performSelectorOnMainThread:@selector(jEmailError) withObject:nil waitUntilDone:NO];
- // break;
- //
- // case jFBOption:
- // [self performSelectorOnMainThread:@selector(jFBOption) withObject:nil waitUntilDone:NO];
- // break;
- //
- // case jSessionExpire:
- // DLog(@"Session Expired Logging in Again");
- // [[ApplicationData sharedInstance] LoginCheck:self];
- // break;
- //
- // case jReportedContent:
- // [self performSelectorOnMainThread:@selector(jReportedContent) withObject:nil waitUntilDone:NO];
- // break;
- //
- // case JPermissionError:
- // [self performSelectorOnMainThread:@selector(JPermissionError) withObject:nil waitUntilDone:NO];
- // break;
- //
- // case jDuplicateData:
- // [self performSelectorOnMainThread:@selector(jDuplicateData) withObject:nil waitUntilDone:NO];
- // break;
- //
- // case jWaitingForPermission:
- // [self performSelectorOnMainThread:@selector(jWaitingForPermission) withObject:nil waitUntilDone:NO];
- // break;
- // case jSuccess:
- switch (currentRequestType)
- {
- case jShareQuery:
- txtStatus.text = @"";
- btnwtsonurmind.hidden = NO;
- if (![spinner isAnimating]) {
- [spinner startAnimating];
- }
- timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(fetchWall) userInfo:nil repeats:NO];
- break;
- case jDeleteWallQuery:
- [ApplicationData sharedInstance].totalWall --;
- [tempArray removeObjectAtIndex:deleteIndex];
- [tableView reloadData];
- break;
- case jProfileQuery:
- btnfriend.hidden = NO;
- if(!userDetail.isFriend)
- {
- self.navigationItem.rightBarButtonItem = btnEdit1;
- }
- timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(setUserData) userInfo:nil repeats:NO];
- break;
- case jWallListQuery:
- if ([userDetail.wallList count] > 0) {
- [tableView reloadData];
- [self loadImagesForUsers];
- }
- if (sendertag == -888) {
- [self profileRequest];
- }
- if ([userDetail.status rangeOfString:@"{voice}"].location != NSNotFound) {
- //lblContent.text = @"Play";
- // DLog(@"statusvoice : %@",userDetail.status);
- Voiceview.hidden = NO;
- scrstatusMsg.hidden = YES;
- NSString *strTitle = userDetail.status;
- strTitle = [strTitle stringByReplacingOccurrencesOfString: @"{voice}" withString:@""];
- strTitle = [strTitle stringByReplacingOccurrencesOfString: @"{/voice}" withString:@""];
- NSArray *arr = [strTitle componentsSeparatedByString:@"&"];
- userDetail.playVoice = [arr objectAtIndex:0];
- lblSecond.text = [NSString stringWithFormat:@"%@ s",[arr objectAtIndex:1]];
- } else {
- Voiceview.hidden = YES;
- scrstatusMsg.hidden = NO;
- }
- break;
- case jGeneralQuery:
- progressBar.hidden = YES;
- if(userImage && isProfilePic) {
- userImg.image = userImage;
- [ApplicationData sharedInstance].userDetail.avatarImg = userImg.image;
- userDetail.avatarImg = userImage;
- btnEdit.hidden = NO;
- [btnEdit setTitle:NSLocalizedString(@"button_edit", @"") forState:UIControlStateNormal];
- [btnEdit removeTarget:self action:@selector(doneButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- [btnEdit addTarget:self action:@selector(editButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- self.navigationItem.leftBarButtonItem = nil;
- tableView.userInteractionEnabled = YES;
- userImg.alpha = 1.0;
- [self performSelectorOnMainThread:@selector(update) withObject:nil waitUntilDone:YES];
- userImage = nil;
- }
- else if (photoSelectIndex == 888) {
- imgPhotoPrev.hidden = YES;
- imgPhotoBackPrev.hidden = YES;
- VoiceoverPhotoCaption.hidden = YES;
- Voiceover.hidden = NO;
- txtPhotoCaption.text = @"";
- imgPhotoBackPrev.hidden = YES;
- imgPhotoPrev.hidden = YES;
- [btnPhotocaption setTitle:NSLocalizedString(@"photo_caption", @"") forState:UIControlStateNormal];
- [self performSelectorOnMainThread:@selector(PhotoCaption) withObject:nil waitUntilDone:YES];
- }
- else{
- btnEdit.hidden = NO;
- [btnEdit setTitle:NSLocalizedString(@"button_edit", @"") forState:UIControlStateNormal];
- [btnEdit removeTarget:self action:@selector(doneButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- [btnEdit addTarget:self action:@selector(editButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- self.navigationItem.leftBarButtonItem = nil;
- tableView.userInteractionEnabled = YES;
- [self performSelectorOnMainThread:@selector(update) withObject:nil waitUntilDone:YES];
- }
- // [spinner stopAnimating];
- break;
- case jStatusQuery:
- btnwtsonurmind.hidden = NO;
- userDetail.status = txtStatus.text;
- statusMsg.text = [userDetail status];
- CGSize stringsize1 = [[userDetail status] sizeWithFont:[statusMsg font]];
- if (stringsize1.width > 285)
- {
- //statusMsg.frame = CGRectMake(statusMsg.frame.origin.x, statusMsg.frame.origin.y, (stringsize1.width + 10.0), statusMsg.frame.size.height);
- // [scrstatusMsg setContentSize:(CGSizeMake((stringsize1.width + 15), 20))];
- }
- if ([userDetail.status rangeOfString:@"{voice}"].location != NSNotFound) {
- Voiceview.hidden = NO;
- scrstatusMsg.hidden = YES;
- NSString *strTitle = userDetail.status;
- strTitle = [strTitle stringByReplacingOccurrencesOfString: @"{voice}" withString:@""];
- strTitle = [strTitle stringByReplacingOccurrencesOfString: @"{/voice}" withString:@""];
- NSArray *arr = [strTitle componentsSeparatedByString:@"&"];
- userDetail.playVoice = [arr objectAtIndex:0];
- lblSecond.text = [NSString stringWithFormat:@"%@ s",[arr objectAtIndex:1]];
- } else {
- Voiceview.hidden = YES;
- scrstatusMsg.hidden = NO;
- }
- lblvideoMsg.text = [userDetail.profile_video objectForKey:@"title"];
- stringsize1 = [[userDetail.profile_video objectForKey:@"title"] sizeWithFont:[lblvideoMsg font]];
- if (stringsize1.width > 255)
- {
- lblvideoMsg.frame = CGRectMake(lblvideoMsg.frame.origin.x, lblvideoMsg.frame.origin.y, (stringsize1.width + 10.0), lblvideoMsg.frame.size.height);
- [scrvideoMsg setContentSize:(CGSizeMake((stringsize1.width + 15), 20))];
- }
- txtStatus.text = @"";
- // [self performSelectorOnMainThread:@selector(fetchWall) withObject:nil waitUntilDone:YES];
- if (![spinner isAnimating]) {
- [spinner startAnimating];
- }
- timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(fetchWall) userInfo:nil repeats:NO];
- // [tempArray insertObject:newWall atIndex:0];
- // [tableView reloadData];
- // [tempArray add]
- break;
- case jAddFriendQuery:
- [self performSelectorOnMainThread:@selector(addfriend) withObject:nil waitUntilDone:YES];
- userDetail.pending = YES;
- break;
- case jAddCountQuery:
- userDetail.isCounted = YES;
- userDetail.viewCount +=1;
- profileCount.text = [NSString stringWithFormat:@"%d", [userDetail viewCount]];
- break;
- case jLogoutQuery:
- [self.tabBarController.tabBar setHidden:NO];
- [self showAlert:NSLocalizedString(@"logged_out",@"") Content:NSLocalizedString(@"logout_msg", @"")];
- userImg.image = [UIImage imageNamed:@"the face.png"];
- [[ApplicationData sharedInstance] logout:self];
- name.text = @"";
- statusMsg.text = @"";
- profileCount.text = @"";
- [self performSelectorOnMainThread:@selector(openLoginView) withObject:nil waitUntilDone:YES];
- break;
- case jNotificationQuery:
- if([ApplicationData sharedInstance].loggedUser != 0) {
- for(UINavigationController *viewController in self.tabBarController.viewControllers) {
- if([viewController isKindOfClass:[UINavigationController class]] && [[[viewController viewControllers] objectAtIndex:0] isKindOfClass:[NotificationViewController class]]) {
- viewController.tabBarItem.badgeValue = nil;
- [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
- if(([[ApplicationData sharedInstance].notificationList count] > 0)
- || ([[ApplicationData sharedInstance].unreadMsgList count] > 0 ))
- {
- int badgeValue = [[ApplicationData sharedInstance].notificationList count]+[[ApplicationData sharedInstance].unreadMsgList count];
- [viewController.tabBarItem setBadgeValue:[[NSString alloc] initWithFormat:@"%d", badgeValue]];
- [[UIApplication sharedApplication] setApplicationIconBadgeNumber:badgeValue];
- }
- break;
- }
- }
- }
- break;
- case jLikeQuery:
- userDetail.Liked = YES;
- if(!userDetail.isFriend && userDetail.userId == 0) {
- [ApplicationData sharedInstance].userDetail.Liked = YES;
- }
- [btnLike setImage:[UIImage imageNamed:@"unlike_hover_icon.png"] forState:UIControlStateNormal];
- [btnDislike setImage:[UIImage imageNamed:@"unlike_hover_icon.png"] forState:UIControlStateNormal];
- [self performSelectorOnMainThread:@selector(profileRequest) withObject:nil waitUntilDone:YES];
- break;
- case jUnlikeQuery:
- userDetail.Liked = NO;
- if(!userDetail.isFriend && userDetail.userId == 0) {
- [ApplicationData sharedInstance].userDetail.Liked = NO;
- }
- [btnLike setImage:[UIImage imageNamed:@"like_hover_icon.png"] forState:UIControlStateNormal];
- [btnDislike setImage:[UIImage imageNamed:@"unlike_hover_icon.png"] forState:UIControlStateNormal];
- [self performSelectorOnMainThread:@selector(profileRequest) withObject:nil waitUntilDone:YES];
- break;
- case jDislikeQuery:
- userDetail.Disliked = YES;
- if(!userDetail.isFriend && userDetail.userId == 0) {
- [ApplicationData sharedInstance].userDetail.Disliked = YES;
- }
- [btnLike setImage:[UIImage imageNamed:@"like_hover_icon.png"] forState:UIControlStateNormal];
- [btnDislike setImage:[UIImage imageNamed:@"like_hover_icon.png"] forState:UIControlStateNormal];
- [self performSelectorOnMainThread:@selector(profileRequest) withObject:nil waitUntilDone:YES];
- break;
- case jlikeUnlikeQuery:
- wallRecord.liked = !wallRecord.liked;
- if (wallRecord.liked) {
- wallRecord.likes++;
- }
- else {
- wallRecord.likes--;
- }
- [tableView reloadData];
- default:
- break;
- }
- // break;
- //
- // default:
- // break;
- // }
- tableView.userInteractionEnabled = YES;
- self.navigationItem.rightBarButtonItem.enabled = YES;
- self.navigationItem.leftBarButtonItem.enabled = YES;
- }
- -(void)addfriend{
- [self showAlert:NSLocalizedString(@"Success",@"") Content:NSLocalizedString(@"approval_msg", @"")];
- }
- - (void)openLoginView {
- LoginViewController *controller = [[LoginViewController alloc] init];
- userDetail = nil;
- userDetail.avatarImg = nil;
- [ApplicationData sharedInstance].userDetail.avatarImg = nil;
- int k = [controller LogincheckDict];
- if (k == 1) {
- [controller LoginDone];
- [self viewWillAppear:NO];
- }
- else if (k==2)
- {
- [controller FBLoginDone];
- [self viewWillAppear:NO];
- }
- else
- {
- [self presentModalViewController:controller animated:YES];
- }
- [controller release];
- }
- #pragma mark --
- #pragma mark add Functions
- - (void)addNew{
- if(![spinner isAnimating])
- {
- [spinner startAnimating];
- NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
- [postVariables setObject:[NSString stringWithFormat:@"%d",userDetail.userId] forKey:@"memberID"];
- [postVariables setObject:[NSString stringWithFormat:@"%@",msg.text] forKey:@"message"];
- NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"friend" ExtTask:@"addFriend" TaskdataDictionary:postVariables Imagedata:nil];
- [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
- currentRequestType = jAddFriendQuery;
- if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
- [self requestCompleted];
- }else {
- self.view.userInteractionEnabled = YES;
- }
- }
- }
- #pragma mark --
- #pragma mark alert
- - (void)showAlert:(NSString *)title Content:(NSString *)bodyText {
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:bodyText
- delegate:self cancelButtonTitle:NSLocalizedString(@"alert_cancel_btn_title",@"") otherButtonTitles: nil];
- [alert setContentMode:UIViewContentModeScaleAspectFit];
- [alert show];
- [alert release];
- }
- - (void)setUserData {
- DLog(@"friends:%d pics:%d album:%d",userDetail.TotalFriends,userDetail.TotalPhotos,userDetail.totalAlbum);
- lblFriends.text = [NSString stringWithFormat:@"%d",userDetail.TotalFriends];
- lblViews.text = [NSString stringWithFormat:@"%@ %d",NSLocalizedString(@"Views_title",@"") ,userDetail.viewCount];
- lblPhotos.text = [NSString stringWithFormat:@"%d",userDetail.TotalPhotos];
- lblVideos.text = [NSString stringWithFormat:@"%d",userDetail.totalAlbum];
- if([userDetail avatarImg] && !isImageUpdated) {
- userImg.image = [userDetail avatarImg];
- }
- else
- {
- if (!isImageUpdated) {
- [self performSelectorOnMainThread:@selector(sendImageRequest) withObject:nil waitUntilDone:YES];
- }
- }
- if(!userDetail.isFriend && userDetail.userId == 0)
- {
- DLog(@"like:%d Dislike:%d",userDetail.Liked,userDetail.Disliked);
- userDetail = [ApplicationData sharedInstance].userDetail;
- }
- DLog(@"likes:%d",userDetail.Likes);
- DLog(@"Dislikes:%d",userDetail.Dislikes);
- if (userDetail.userId != 0) {
- btnPhotos.hidden = YES;
- btnVideos.hidden = YES;
- btnEvents.hidden = YES;
- }else {
- btnPhotos.hidden = NO;
- btnVideos.hidden = NO;
- btnEvents.hidden = YES;
- }
- if([ApplicationData sharedInstance].frndCount != 0)
- {
- [btnFriendCount setTitle:[NSString stringWithFormat:@"%d",[ApplicationData sharedInstance].frndCount] forState:UIControlStateNormal];
- }
- else
- {
- btnFriendCount.hidden = YES;
- }
- if([ApplicationData sharedInstance].msgCount != 0)
- {
- [btnMsgCount setTitle:[NSString stringWithFormat:@"%d",[ApplicationData sharedInstance].msgCount] forState:UIControlStateNormal];
- }
- else
- {
- btnMsgCount.hidden = YES;
- }
- if([ApplicationData sharedInstance].groupCount != 0)
- {
- [btnGroupCount setTitle:[NSString stringWithFormat:@"%d",[ApplicationData sharedInstance].groupCount] forState:UIControlStateNormal];
- }
- else
- {
- btnGroupCount.hidden = YES;
- }
- if (userDetail.Dislikes == 0)
- {
- //lblDislikeCount.hidden = YES;
- lblDislikeCount.text = [NSString stringWithFormat:@"%d",userDetail.Dislikes];
- }
- else
- {
- if (userDetail.Dislikes == 1)
- {
- //lblDislikeCount.text = [NSString stringWithFormat:@"%d Dislike",userDetail.Dislikes];
- lblDislikeCount.text = [NSString stringWithFormat:@"%d",userDetail.Dislikes];
- }
- else
- {
- //lblDislikeCount.text = [NSString stringWithFormat:@"%d Dislikes",userDetail.Dislikes];
- lblDislikeCount.text = [NSString stringWithFormat:@"%d",userDetail.Dislikes];
- }
- lblDislikeCount.hidden = YES;
- }
- lblLikeCount.text = [NSString stringWithFormat:@"%d",userDetail.Likes];
- if (!userDetail.isLikeAllowed) {
- btnLike.hidden = YES;
- btnDislike.hidden = YES;
- }else {
- btnLike.hidden = NO;
- btnDislike.hidden = NO;
- }
- if (userDetail.Liked) {
- [btnLike setImage: [UIImage imageNamed:@"unlike_hover_icon.png"] forState:UIControlStateNormal];
- }else {
- [btnLike setImage:[UIImage imageNamed:@"like_hover_icon.png"] forState:UIControlStateNormal];
- }
- if (userDetail.Disliked)
- {
- [btnDislike setImage:[UIImage imageNamed:@"like_hover_icon.png"] forState:UIControlStateNormal];
- }
- else
- {
- [btnDislike setImage:[UIImage imageNamed:@"unlike_hover_icon.png"] forState:UIControlStateNormal];
- }
- if (!isImageUpdated) {
- name.text = [userDetail userName];
- }
- if([statusMsg.text length] == 0 || !self.editing)
- {
- if ([ApplicationData sharedInstance].isprofile_video) {
- [self performSelectorOnMainThread:@selector(profileRequest) withObject:nil waitUntilDone:YES];
- }
- [ApplicationData sharedInstance].isprofile_video = NO;
- statusMsg.text = [userDetail status];
- CGSize stringsize1 = [[userDetail status] sizeWithFont:[statusMsg font]];
- lblvideoMsg.text = [userDetail.profile_video objectForKey:@"title"];
- stringsize1 = [[userDetail.profile_video objectForKey:@"title"] sizeWithFont:[lblvideoMsg font]];
- if (stringsize1.width > 255)
- {
- lblvideoMsg.frame = CGRectMake(lblvideoMsg.frame.origin.x, lblvideoMsg.frame.origin.y, (stringsize1.width + 10.0), lblvideoMsg.frame.size.height);
- [scrvideoMsg setContentSize:(CGSizeMake((stringsize1.width + 15), 20))];
- }
- }
- if (userDetail.coverImg) {
- imgvw_cover.image = userDetail.coverImg;
- }
- else {
- userDetail.coverImg = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[userDetail coverpicURL]]]];
- imgvw_cover.image = userDetail.coverImg;
- }
- if ([ApplicationData sharedInstance].isReload) {
- [ApplicationData sharedInstance].isReload = NO;
- [self performSelectorOnMainThread:@selector(sendImageRequest) withObject:nil waitUntilDone:NO];
- }
- profileCount.text = [NSString stringWithFormat:@"%d", [userDetail viewCount]];
- if([ApplicationData sharedInstance].isLoggedIn && userDetail.isFriend) {
- self.navigationItem.rightBarButtonItem = nil;
- btnEdit.hidden = YES;
- }
- if (userDetail.userId == 0)
- {
- btnfriend.hidden = YES;
- btnEdit.hidden = NO;
- btncoverphoto.hidden = NO;
- //btnmessage.frame = CGRectMake(26, 263, 268, 30);
- //[btnmessage setBackgroundImage:[UIImage imageNamed:@"Lea_mesaage_box.png"] forState:UIControlStateNormal];
- }
- else
- {
- btncoverphoto.hidden = YES;
- //[btnmessage setBackgroundImage:[UIImage imageNamed:@"Lea_friend_btn.png"] forState:UIControlStateNormal];
- if (!userDetail.isFriend) {
- btnfriend.hidden = NO;
- [btnfriend setTitle:NSLocalizedString(@"addFriend", @"") forState:UIControlStateNormal];
- [btnfriend removeTarget:self action:@selector(removeFriendButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- [btnfriend addTarget:self action:@selector(addFriendButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- //btnmessage.frame = CGRectMake(169, 263, 118, 30);
- //btnfriend.frame = CGRectMake(34, 263, 118, 30);
- }else {
- btnfriend.hidden = NO;
- [btnfriend setTitle:NSLocalizedString(@"already_friend", @"") forState:UIControlStateNormal];
- [btnfriend removeTarget:self action:@selector(addFriendButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- [btnfriend addTarget:self action:@selector(removeFriendButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- //btnmessage.frame = CGRectMake(169, 263, 118, 30);
- //btnfriend.frame = CGRectMake(34, 263, 118, 30);
- }
- }
- if ([userDetail.wallList count] > 0) {
- tempArray = userDetail.wallList;
- [tableView reloadData];
- [self loadImagesForUsers];
- [spinner stopAnimating];
- } else {
- if (![spinner isAnimating]) {
- [spinner startAnimating];
- }
- [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(fetchWall) userInfo:nil repeats:NO];
- }
- if (lblvideoMsg.text.length == 0) {
- imgVideo.hidden = YES;
- scrvideoMsg.hidden = YES;
- }else {
- imgVideo.hidden = NO;
- scrvideoMsg.hidden = NO;
- }
- }
- - (void)embedYouTube:(NSString *)urlString frame:(CGRect)frame {
- NSString *embedHTML;
- NSString *html;
- if ([[[UIDevice currentDevice]systemVersion]floatValue] >= 5.0) {
- embedHTML = @"\
- <html><head>\
- <style type=\"text/css\">\
- body {\
- background-color: transparent;\
- color: white;\
- }\
- </style>\
- </head><body style=\"margin:0\">\
- <iframe title=\"YouTube Video\" class=\"youtube-player\" type=\"text/html\"\
- width=\"%0.0f\" height=\"%0.0f\" src=\"%@\"\
- frameborder=\"0\" allowFullScreen ></iframe>";
- NSArray *selectedOptions = [urlString componentsSeparatedByString:@"v="];
- if ([selectedOptions count] != 1) {
- urlString = [NSString stringWithFormat:@"http://www.youtube.com/embed/%@",[[selectedOptions objectAtIndex:1] substringToIndex:11]];
- }
- if ([selectedOptions count]== 1) {
- selectedOptions = [urlString componentsSeparatedByString:@".be/"];
- urlString = [NSString stringWithFormat:@"http://www.youtube.com/embed/%@",[[selectedOptions objectAtIndex:1] substringToIndex:11]];
- }
- NSString *myString = @"?showinfo=0";
- urlString = [urlString stringByAppendingString:myString];
- html = [NSString stringWithFormat: embedHTML, frame.size.width,frame.size.height, urlString];
- // [youtubeThumbnail loadHTMLString:html baseURL:nil];
- [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlString]]];
- }else{
- embedHTML = @"\
- <html><head>\
- <style type=\"text/css\">\
- body {\
- background-color: transparent;\
- color: white;\
- }\
- </style>\
- </head><body style=\"margin:0\">\
- <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
- width=\"%0.0f\" height=\"%0.0f\"></embed>\
- </body></html>";
- html = [NSString stringWithFormat:embedHTML, urlString, frame.size.width, frame.size.height];
- [webView loadHTMLString:html baseURL:nil];
- }
- }
- #pragma mark --
- #pragma mark image upload & downloader
- - (IBAction) LikePressed:(id)sender
- {
- [spinner stopAnimating];
- if (userDetail.Liked)
- {
- [spinner startAnimating];
- [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(UnLike) userInfo:nil repeats:NO];
- }
- else
- {
- [spinner startAnimating];
- [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(Like) userInfo:nil repeats:NO];
- }
- }
- - (IBAction)DislikePressed:(id)sender
- {
- [spinner stopAnimating];
- if (userDetail.Disliked)
- {
- [spinner startAnimating];
- [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(UnLike) userInfo:nil repeats:NO];
- }
- else
- {
- [spinner startAnimating];
- [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(DisLike) userInfo:nil repeats:NO];
- }
- }
- -(void)Like {
- NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
- [postVariables setObject:[NSString stringWithFormat:@"%d",userDetail.userId] forKey:@"userID"];
- NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"user" ExtTask:@"like" TaskdataDictionary:postVariables Imagedata:nil];
- [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
- currentRequestType = jLikeQuery;
- if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
- [self requestCompleted];
- }else {
- self.view.userInteractionEnabled = YES;
- }
- }
- -(void)UnLike {
- NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
- [postVariables setObject:[NSString stringWithFormat:@"%d",userDetail.userId] forKey:@"userID"];
- NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"user" ExtTask:@"unlike" TaskdataDictionary:postVariables Imagedata:nil];
- [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
- currentRequestType = jUnlikeQuery;
- if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
- [self requestCompleted];
- }else {
- self.view.userInteractionEnabled = YES;
- }
- }
- -(void)DisLike {
- NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
- [postVariables setObject:[NSString stringWithFormat:@"%d",userDetail.userId] forKey:@"userID"];
- NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"user" ExtTask:@"dislike" TaskdataDictionary:postVariables Imagedata:nil];
- [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
- currentRequestType = jDislikeQuery;
- if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
- [self requestCompleted];
- }else {
- self.view.userInteractionEnabled = YES;
- }
- }
- - (void)sendImageRequest {
- IconDownloader *iconDownloader = [imageDownloadsInProgress objectForKey:[userDetail avatarURL]];
- DLog(@"Download Avatar Image : %@", [userDetail avatarURL]);
- if (iconDownloader == nil)
- {
- [spinner startAnimating];
- iconDownloader = [[IconDownloader alloc] init];
- iconDownloader.appRecord = userDetail;
- iconDownloader.delegate = self;
- iconDownloader.imageKey = [userDetail avatarURL];
- [imageDownloadsInProgress setObject:iconDownloader forKey:[userDetail avatarURL]];
- [iconDownloader startDownload];
- [iconDownloader release];
- }
- }
- - (void)sendImageUploadRequest:(UIImage *)uploadImg {
- if (![spinner isAnimating]) {
- [spinner startAnimating];
- }
- if(uploadImg) {
- NSData *imgData = UIImageJPEGRepresentation(uploadImg, 1.0);
- NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
- [postVariables setObject:name.text forKey:@"name"];
- NSString *jsonString = [Jomsocial CreateDictionary_joomsocial:@"user" ExtTask:@"updateProfile" TaskdataDictionary:postVariables Imagedata:imgData];
- NSDictionary *dict = [JoomlaRegistration JoomSocialDictionary:jsonString Imagedata:imgData];
- [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
- currentRequestType = jGeneralQuery;
- if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
- [self requestCompleted];
- }else {
- self.view.userInteractionEnabled = YES;
- }
- } else if (![statusMsg.text isEqualToString:userDetail.status] || ![name.text isEqualToString:userDetail.userName]) {
- NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
- [postVariables setObject:name.text forKey:@"name"];
- NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"user" ExtTask:@"updateProfile" TaskdataDictionary:postVariables Imagedata:nil];
- [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
- currentRequestType = jGeneralQuery;
- if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
- [self requestCompleted];
- }else {
- self.view.userInteractionEnabled = YES;
- }
- } else {
- [self cancelButtonPressed:nil];
- return;
- }
- }
- #pragma mark -
- #pragma mark editing
- - (void)setEditing:(BOOL)editing animated:(BOOL)animated{
- if(![spinner isAnimating]) {
- if (editing)
- {
- self.navigationItem.leftBarButtonItem.title = NSLocalizedString(@"button_cancel",@"");
- update=TRUE;
- changeImg.hidden = FALSE;
- userImage = nil;
- }
- else
- {
- if([name.text isEqualToString:@""]){
- [self showAlert:NSLocalizedString(@"invalid",@"") Content:NSLocalizedString(@"invalid_msg",@"")];
- [spinner stopAnimating];
- name.text = userDetail.userName;
- }
- else if(!quit) {
- self.navigationItem.leftBarButtonItem.enabled = FALSE;
- tableView.userInteractionEnabled = FALSE;
- self.navigationItem.rightBarButtonItem.enabled = FALSE;
- [self sendImageUploadRequest:userImage];
- }
- self.navigationItem.leftBarButtonItem.title = NSLocalizedString(@"button_logout",@"");
- update = FALSE;
- changeImg.hidden = TRUE;
- // [statusMsg setBorderStyle:UITextBorderStyleNone];
- quit= FALSE;
- //statusMsg.textColor = [ApplicationData sharedInstance].textcolor;
- }
- [super setEditing:editing animated:animated];
- }
- }
- #pragma mark -
- #pragma mark UIButton Events
- - (IBAction)openGallery:(id) sender {
- if ([sender isEqual:changeImg]) {
- isProfilePic = YES;
- }else {
- isProfilePic = NO;
- }
- UIActionSheet *actionSheet;
- if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == YES) {
- actionSheet = [[UIActionSheet alloc]
- initWithTitle:NSLocalizedString(@"addPic",@"")
- delegate:self
- cancelButtonTitle:nil
- destructiveButtonTitle:NSLocalizedString(@"button_cancel",@"")
- otherButtonTitles:NSLocalizedString(@"gallery",@""),NSLocalizedString(@"cam",@""),nil];
- } else {
- actionSheet = [[UIActionSheet alloc]
- initWithTitle:NSLocalizedString(@"addPic",@"")
- delegate:self
- cancelButtonTitle:nil
- destructiveButtonTitle:NSLocalizedString(@"button_cancel",@"")
- otherButtonTitles:NSLocalizedString(@"gallery",@""),nil];
- }
- actionSheet.tag = 1;
- actionSheet.alpha = 1.0;
- [actionSheet showInView:self.view]; //showInView:self.view]; // show from our tabbar view (pops up in the middle of the tabbar)
- [actionSheet release];
- }
- - (IBAction)editButtonPressed:(id)sender {
- /*if(![spinner isAnimating]) {
- [btnEdit setTitle:NSLocalizedString(@"button_done", @"") forState:UIControlStateNormal];
- [btnEdit removeTarget:self action:@selector(editButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- [btnEdit addTarget:self action:@selector(doneButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- self.navigationItem.leftBarButtonItem = btnCancel;
- name.backgroundColor = [UIColor whiteColor];
- name.enabled = TRUE;
- name.userInteractionEnabled = YES;
- name.placeholder = NSLocalizedString(@"status_msg", @"Status Message");
- [name setBorderStyle:UITextBorderStyleRoundedRect];
- name.textColor=[ApplicationData sharedInstance].inputtxtColor;
- changeImg.hidden = FALSE;
- userImage = nil;
- } */
- MoreUserSettingsController *controller = [[MoreUserSettingsController alloc] init];
- controller.userDetail = userDetail;
- [[self navigationController] pushViewController:controller animated:YES];
- }
- - (IBAction)doneButtonPressed:(id)sender {
- if(![spinner isAnimating]) {
- [spinner startAnimating];
- if([name.text isEqualToString:@""]){
- [self showAlert:NSLocalizedString(@"invalid",@"") Content:NSLocalizedString(@"invalid_msg",@"")];
- [spinner stopAnimating];
- name.text = userDetail.userName;
- } else {
- name.userInteractionEnabled = NO;
- [[name findFirstResponder]resignFirstResponder];
- timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(profileUpdate) userInfo:nil repeats:NO];
- }
- changeImg.hidden = TRUE;
- statusMsg.backgroundColor = [UIColor clearColor];
- //statusMsg.textColor = [ApplicationData sharedInstance].textcolor;
- [name setBorderStyle:UITextBorderStyleNone];
- name.backgroundColor = [UIColor clearColor];
- //name.textColor = [ApplicationData sharedInstance].textcolor;
- }
- }
- - (void) profileUpdate {
- [self sendImageUploadRequest:userImage];
- }
- - (IBAction)FriendsButtonPressed:(id)sender {
- FriendsViewController *controller = [[FriendsViewController alloc]init];
- controller.userDetail = userDetail;
- [ApplicationData sharedInstance].totalFriends = 0;
- [self.navigationController pushViewController:controller animated:YES];
- [controller release];
- }
- - (IBAction)MessageButtonPressed:(id)sender {
- if (userDetail.userId == 0) {
- MessageViewController *controller = [[MessageViewController alloc]init];
- [self.navigationController pushViewController:controller animated:YES];
- [controller release];
- }else {
- WriteMessageViewController *controller = [[WriteMessageViewController alloc]init];
- controller.userID = userDetail.userId;
- controller.recipient = userDetail.userName;
- [ApplicationData sharedInstance].recipient = userDetail.userName;
- [ApplicationData sharedInstance].selectedFriend = [NSString stringWithFormat:@"%d",userDetail.userId];
- controller.frndName = userDetail.userName;
- controller.select = FALSE;
- [self.navigationController pushViewController:controller animated:YES];
- [controller release];
- }
- }
- - (IBAction)PhotosButtonPressed:(id)sender
- {
- [ApplicationData sharedInstance].flag_cov_photo = 0;
- AlbumsViewController *controller = [[AlbumsViewController alloc]init];
- controller.userObj = userDetail;
- [self.navigationController pushViewController:controller animated:YES];
- [controller release];
- }
- - (IBAction)CoverPhotosButtonPressed:(id)sender
- {
- [ApplicationData sharedInstance].flag_cov_photo = 1;
- [ApplicationData sharedInstance].cover_photo_TYPE=1;
- AlbumsViewController *controller = [[AlbumsViewController alloc]init];
- controller.userObj = userDetail;
- [self.navigationController pushViewController:controller animated:YES];
- [controller release];
- }
- -(IBAction)VideosButtonPressed:(id)sender {
- VideoViewController *controller = [[VideoViewController alloc]init];
- controller.userDetail = userDetail;
- [self.navigationController pushViewController:controller animated:YES];
- [controller release];
- }
- - (IBAction)UserDetailButtonPressed:(id)sender {
- UserDetailViewController *controller = [[UserDetailViewController alloc]init];
- controller.userDetail = self.userDetail;
- [self.navigationController pushViewController:controller animated:YES];
- [controller release];
- }
- - (IBAction)NotifPressed:(id)sender
- {
- notifView.hidden = !notifView.hidden;
- if ([sender isEqual:btnFrndReq])
- {
- if (notifController.isMsg || notifController.isGroup)
- {
- notifController.isMsg = NO;
- notifController.isGroup = NO;
- notifController.isFriend = YES;
- notifView.hidden = NO;
- [notifController.tableView reloadData];
- }
- else if(notifController.isFriend)
- {
- notifController.isFriend = NO;
- notifView.hidden = YES;
- }
- else
- {
- notifController.isFriend = YES;
- notifView.hidden = NO;
- [notifController.tableView reloadData];
- }
- }
- else if ([sender isEqual:btnMessage])
- {
- if (notifController.isFriend || notifController.isGroup)
- {
- notifController.isFriend = NO;
- notifController.isGroup = NO;
- notifController.isMsg = YES;
- notifView.hidden = NO;
- [notifController.tableView reloadData];
- }
- else if(notifController.isMsg)
- {
- notifController.isMsg = NO;
- notifView.hidden = YES;
- }
- else
- {
- notifController.isMsg = YES;
- notifView.hidden = NO;
- [notifController.tableView reloadData];
- }
- }
- else if ([sender isEqual:btnGroup])
- {
- if (notifController.isFriend || notifController.isMsg)
- {
- notifController.isFriend = NO;
- notifController.isMsg = NO;
- notifController.isGroup = YES;
- notifView.hidden = NO;
- [notifController.tableView reloadData];
- }
- else if(notifController.isGroup)
- {
- notifController.isGroup = NO;
- notifView.hidden = YES;
- }
- else
- {
- notifController.isGroup = YES;
- notifView.hidden = NO;
- [notifController.tableView reloadData];
- }
- }
- }
- - (IBAction)cancelButtonPressed:(id)sender {
- iJoomerAppDelegate *appdelegate = (iJoomerAppDelegate *) [[UIApplication sharedApplication] delegate];
- appdelegate.viewTop.hidden = NO;
- appdelegate.TabView.hidden = YES;
- self.navigationItem.rightBarButtonItem = nil;
- self.navigationItem.hidesBackButton = NO;
- webView.hidden = YES;
- if([spinner isAnimating]) {
- if(currentRequestType == jGeneralQuery) {
- [imageUploader cancelUpload];
- imageUploader = nil;
- }
- progressBar.hidden = YES;
- [spinner stopAnimating];
- userImg.alpha = 1.0;
- userImage = nil;
- }
- [btnEdit setTitle:NSLocalizedString(@"button_edit", @"") forState:UIControlStateNormal];
- [btnEdit removeTarget:self action:@selector(doneButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- [btnEdit addTarget:self action:@selector(editButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- self.navigationItem.leftBarButtonItem = nil;
- btnEdit.hidden = NO;
- statusMsg.backgroundColor = [UIColor clearColor];
- //statusMsg.textColor = [UIColor blackColor];//[ApplicationData sharedInstance].textcolor;
- [statusMsg setText:userDetail.status];
- name.backgroundColor = [UIColor clearColor];
- name.enabled = NO;
- [name setBorderStyle:UITextBorderStyleNone];
- //name.textColor = [ApplicationData sharedInstance].textcolor;
- [name setText:userDetail.userName];
- changeImg.hidden = YES;
- if (userDetail.avatarImg) {
- userImg.image = userDetail.avatarImg;
- } else {
- userImg.image = [UIImage imageNamed:@"the face.png"];
- }
- }
- - (IBAction)addFriendButtonPressed:(id)sender {
- if(![spinner isAnimating]) {
- if(!userDetail.pending) {
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Message", @"") message:@"\n" delegate:self cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"button_add", @""), NSLocalizedString(@"button_cancel", @""),nil];
- msg = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
- [msg setBorderStyle:UITextBorderStyleRoundedRect];
- [msg setPlaceholder:NSLocalizedString(@"addfriend_msg", @"")];
- msg.delegate = self;
- alert.tag = 1;
- alert.alertViewStyle = UIAlertViewStylePlainTextInput;
- [alert textFieldAtIndex:0];
- //[alert setTransform:CGAffineTransformMakeTranslation(0.0, 110.0)];
- [msg becomeFirstResponder];
- [alert show];
- [alert release];
- }
- else {
- [self showAlert:NSLocalizedString(@"Pending",@"") Content:NSLocalizedString(@"waiting", @"waiting msg")];
- }
- }
- }
- - (IBAction)removeFriendButtonPressed:(id)sender {
- 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];
- alert.tag = 8;
- [alert show];
- [alert release];
- }
- //for photo caption
- - (IBAction)PhotocaptionButtonPressed{
- [ApplicationData sharedInstance].VoicePhotocaption = 9999;
- btnPhotocaption.hidden = YES;
- [txtPhotoCaption becomeFirstResponder];
- CGPoint tableViewCenter = [tableView contentOffset];
- tableViewCenter.y += tableView.frame.size.height/2;
- [tableView setContentOffset:CGPointMake(0,tableViewCenter.y) animated:YES];
- }
- - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
- if (actionSheet.tag == 1) {
- photoSelectIndex = 999;
- if (buttonIndex == 0){
- }
- else if (buttonIndex == 1){
- [self openGallery];
- }
- else if (buttonIndex == 2){
- [self openCamera];
- }
- }else if (actionSheet.tag == 888) {
- photoSelectIndex = 888;
- if (buttonIndex == 0){
- }
- else if (buttonIndex == 1){
- [self openGallery];
- }
- else if (buttonIndex == 2){
- [self openCamera];
- }
- }
- else if (actionSheet.tag == 2) {
- if (buttonIndex == 0)
- {
- [self logoutProcess];
- }
- else if(buttonIndex == 1){
- }
- }else if(actionSheet.tag == 4 && buttonIndex == 0) {
- [btnPermission setTitle:[permissions objectAtIndex:rowIndex] forState:UIControlStateNormal];
- if ([btnPermission.titleLabel.text isEqualToString:NSLocalizedString(@"Public_title",@"")]) {
- permissionValue = 0;
- }else if ([btnPermission.titleLabel.text isEqualToString:NSLocalizedString(@"sitemember_title",@"")]) {
- permissionValue = 20;
- }else if ([btnPermission.titleLabel.text isEqualToString:NSLocalizedString(@"friends_title",@"")]) {
- permissionValue = 30;
- }else if ([btnPermission.titleLabel.text isEqualToString:NSLocalizedString(@"onlyme_title",@"")]) {
- permissionValue = 40;
- }
- }
- }
- - (void)openCamera {
- iJoomerAppDelegate *appdelegate = (iJoomerAppDelegate *) [[UIApplication sharedApplication] delegate];
- appdelegate.viewTop.hidden = YES;
- appdelegate.TabView.hidden = YES;
- UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
- imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
- imagePicker.delegate = self;
- imagePicker.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
- [self presentModalViewController:imagePicker animated:YES];
- [imagePicker release];
- }
- - (void)openGallery{
- iJoomerAppDelegate *appdelegate = (iJoomerAppDelegate *) [[UIApplication sharedApplication] delegate];
- appdelegate.viewTop.hidden = YES;
- appdelegate.TabView.hidden = YES;
- appdelegate.BtnSideMenu.hidden = YES;
- UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
- imagePicker.delegate = self;
- imagePicker.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
- [self presentModalViewController:imagePicker animated:YES];
- [imagePicker release];
- }
- - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
- iJoomerAppDelegate *appdelegate = (iJoomerAppDelegate *) [[UIApplication sharedApplication] delegate];
- appdelegate.viewTop.hidden = NO;
- appdelegate.TabView.hidden = YES;
- UIImage *selectedImage = [info objectForKey:UIImagePickerControllerOriginalImage];
- CGSize size = selectedImage.size;
- CGFloat ratio = 0;
- if((selectedImage.size.height > 480) || (selectedImage.size.width > 320)){
- if (size.width > size.height) {
- ratio = 320.0 / size.width;
- }
- else {
- ratio = 480.0 / size.height;
- }
- CGRect rect = CGRectMake(0.0, 0.0, ratio * size.width, ratio * size.height);
- UIGraphicsBeginImageContext(rect.size);
- [selectedImage drawInRect:rect];
- selectedImage = UIGraphicsGetImageFromCurrentImageContext();
- }
- userImage = [selectedImage retain];
- PhotoPrevImage = [selectedImage retain];
- imgPhotoPrev.image = selectedImage;
- if (isProfilePic) {
- [userImg setImage:selectedImage];
- userImg.image = selectedImage;
- isImageUpdated = YES;
- }else {
- [spinner startAnimating];
- [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(photoUpload) userInfo:nil repeats:NO];
- }
- [self dismissModalViewControllerAnimated:YES];
- }
- - (IBAction)PhotocaptionSendButtonPressed{
- [spinner startAnimating];
- [txtPhotoCaption resignFirstResponder];
- [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(photoUpload) userInfo:nil repeats:NO];
- }
- -(void)photoUpload {
- if (txtPhotoCaption.text.length == 0) {
- [self showAlert:NSLocalizedString(@"no_text",@"") Content:NSLocalizedString(@"photo_caption", @"")];
- return;
- }
- NSData *imgData = UIImageJPEGRepresentation(userImage, 1.0);
- NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
- [postVariables setObject:@"0" forKey:@"isDefault"];
- [postVariables setObject:txtPhotoCaption.text forKey:@"caption"];
- [postVariables setObject:@"true" forKey:@"profile"];
- NSString *jsonString = [Jomsocial CreateDictionary_joomsocial:@"media" ExtTask:@"uploadphoto" TaskdataDictionary:postVariables Imagedata:imgData];
- NSDictionary *dict = [JoomlaRegistration JoomSocialDictionary:jsonString Imagedata:imgData];
- [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
- currentRequestType = jGeneralQuery;
- if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
- [self requestCompleted];
- }else {
- self.view.userInteractionEnabled = YES;
- }
- }
- #pragma mark -
- #pragma mark Table Functions
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView1 {
- return 1;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- if(indexPath.row < [tempArray count])
- {
- Wall *record = [tempArray objectAtIndex:indexPath.row];
- if([record.type isEqual:@""]){
- return 130;
- }else{
- 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"]){
- return 260;
- }else if([record.type isEqual:@"photos"]){
- return 280;
- }else{
- return 130;
- }
- }
- }else
- {
- return 44;
- }
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- DLog(@"count:%d",[tempArray count]);
- int rows = [tempArray count];
- if ([ApplicationData sharedInstance].totalWall > [tempArray count] ) {
- rows = [tempArray count] + 1;
- }
- return rows;
- return [tempArray count];
- }
- - (UITableViewCell *)tableView:(UITableView *)tableViewController cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- if(indexPath.row < [tempArray count]) {
- WallCell *cell;
- // = (WallCell *)[tableView dequeueReusableCellWithIdentifier:kCellIdentifier];
- wallRecord = [tempArray objectAtIndex:indexPath.row];
- // if (cell == nil)
- // {
- // will check for the Wallcell customtableview
- [cellOwner loadMyNibFile:kCellIdentifier];
- cell = (WallCell *)cellOwner.cell;
- [cell.btnCommentLike addTarget:self action:@selector(commentLikeButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- [cell.btnComment addTarget:self action:@selector(commentButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- [cell.btnLike addTarget:self action:@selector(likeButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- [cell.btnUser addTarget:self action:@selector(userButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- [cell.thumbnail addTarget:self action:@selector(videoButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- [cell.btnUsersname addTarget:self action:@selector(userButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- [cell.btnFrndName addTarget:self action:@selector(FriendNameButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- [cell.btnDelete addTarget:self action:@selector(deleteWall:) forControlEvents:UIControlEventTouchUpInside];
- [cell.btnPlay addTarget:self action:@selector(PlayTitleButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- [cell.btnPlayContent addTarget:self action:@selector(PlayContentButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- [cell.btnGoToQuestion addTarget:self action:@selector(simanswers:) forControlEvents:UIControlEventTouchUpInside];
- cell.parentView = self;
- // }
- [self loadImagesForRows];
- if (!wallRecord.isLikeAllowed && !wallRecord.isCommentAllowed) {
- cell.backImg.frame = cell.frame;
- }
- if (!wallRecord.videoIcon && wallRecord.videoThumbUrl.length > 0)
- {
- [self performSelectorOnMainThread:@selector(startIconDownload3:) withObject:wallRecord waitUntilDone:NO];
- }
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- cell.btnUsername.hidden = YES;
- cell.wallRecord = wallRecord;
- if([cell.wallRecord.type isEqual:@"event"] || [cell.wallRecord.type isEqual:@"group"] ){
- cell.btnUsername.hidden = NO;
- }
- if([cell.wallRecord.type isEqual:@"event"]){
- [cell.btnUsername addTarget:self action:@selector(EventButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- }else if ([cell.wallRecord.type isEqual:@"group"]){
- [cell.btnUsername addTarget:self action:@selector(GroupButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
- }
- cell.btnGoToQuestion.tag = (NSInteger)indexPath.row;
- cell.btnCommentLike.tag = (NSInteger)indexPath.row;
- cell.btnComment.tag = (NSInteger)indexPath.row;
- cell.btnLike.tag = (NSInteger)indexPath.row;
- cell.btnUser.tag = (NSInteger)indexPath.row;
- cell.btnUsername.tag = (NSInteger)indexPath.row;
- cell.btnFrndName.tag = (NSInteger)indexPath.row;
- cell.btnDelete.tag = (NSInteger)indexPath.row;
- cell.btnPlay.tag = (NSInteger)indexPath.row;
- cell.btnPlayContent.tag = (NSInteger)indexPath.row;
- cell.thumbnail.tag = (NSInteger)indexPath.row;
- [cell reloadCell];
- return cell;
- }
- else {
- static NSString *CellIdentifier = @"Cell";
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- cell.backgroundColor = [ApplicationData sharedInstance].tintColor;
- if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil]autorelease];
- //cell.backgroundColor = [ApplicationData sharedInstance].themeColor;
- cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:15];
- cell.textLabel.textColor = [ApplicationData sharedInstance].textcolor;
- }
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- cell.textLabel.text = NSLocalizedString(@"moreresult_title", @"Get more results...");
- return cell;
- }
- }
- - (void)tableView:(UITableView *)tableViewController didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- if (![spinner isAnimating])
- {
- if(indexPath.row < [tempArray count]) {
- Wall *record = [tempArray objectAtIndex:indexPath.row];
- if ([record.type isEqualToString:@"event"])
- {
- if([[ApplicationData sharedInstance].joomsocialVersion rangeOfString:@"3.0"].length!=0){
- JomEventDetailViewController3_0 *controller = [[JomEventDetailViewController3_0 alloc] init];
- controller.selectedEvent = record.eventDetail;
- controller.title = record.eventDetail.title;
- [ApplicationData sharedInstance].isEditMode = NO;
- [self.navigationController pushViewController:controller animated:YES];
- [controller release];
- }else{
- JomEventDetailViewController *controller = [[JomEventDetailViewController alloc] init];
- controller.selectedEvent = record.eventDetail;
- controller.title = record.eventDetail.title;
- [ApplicationData sharedInstance].isEditMode = NO;
- [self.navigationController pushViewController:controller animated:YES];
- [controller release];
- }
- }
- else if ([record.type isEqualToString:@"group"]) {
- if([[ApplicationData sharedInstance].joomsocialVersion rangeOfString:@"3.0"].length!=0){
- GroupDetailViewController3_0 *controller = [[GroupDetailViewController3_0 alloc] initWithNibName:@"GroupDetailViewController3_0" bundle:nil];
- controller.groupRecords= record.groupDetail;
- controller.groupRecords.Id = record.groupDetail.Id;
- [self.navigationController pushViewController:controller animated:YES];
- [controller release];
- }else {
- GroupDetailViewController *controller = [[GroupDetailViewController alloc] initWithNibName:@"GroupDetailViewController" bundle:nil];
- controller.groupRecords= record.groupDetail;
- controller.groupRecords.Id = record.groupDetail.Id;
- [self.navigationController pushViewController:controller animated:YES];
- [controller release];
- }
- }
- } else {
- if (![spinner isAnimating]) {
- [spinner startAnimating];
- }
- ++pageNo;
- timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(fetchWall) userInfo:nil repeats:NO];
- }
- }
- [tableViewController deselectRowAtIndexPath:indexPath animated:YES];
- }
- - (void)loadImagesForUsers {
- NSMutableArray *temp;
- temp = tempArray;
- for (Wall *appRecord in temp) {
- if (!appRecord.thumbImg) // avoid the app icon download if the app already has an icon
- {
- if([appRecord.thumbURL length] > 0 ) {
- [self performSelectorOnMainThread:@selector(startIconDownload2:) withObject:appRecord waitUntilDone:NO];
- }
- }
- }
- }
- - (void)loadImagesForRows {
- for (Photo *appRecord in wallRecord.imageList) {
- if (!appRecord.thumbImg) // avoid the app icon download if the app already has an icon
- {
- if([appRecord.thumbURL length] > 0 ) {
- [self performSelectorOnMainThread:@selector(startIconDownload:) withObject:appRecord waitUntilDone:NO];
- }
- }
- }
- }
- #pragma mark -
- #pragma mark selectPhoto
- - (void)selectPhoto:(id)sender Record:(Wall *)record {
- UIImage *img1 = [sender imageForState:UIControlStateNormal];
- MyCategory *album = [[MyCategory alloc] init];
- album.photos = record.imageList;
- PhotoDetailViewController *controller = [[PhotoDetailViewController alloc] initWithNibName:@"PhotoDetailView" bundle:nil];
- controller.image = img1;
- controller.albumObj = album;
- controller.indexPathRow = -[sender tag] - 1;
- controller.title = record.title;
- // controller.albumOwner = record.userdetail;
- [self.navigationController pushViewController:controller animated:YES];
- [controller release];
- }
- - (void)selectVideo:(id)sender Record:(Video *)record {
- VideoCommentViewController *controller = [[VideoCommentViewController alloc] init];
- controller.videoObj = wallRecord.videoObj;
- [self.navigationController pushViewController:controller animated:YES];
- [controller release];
- }
- - (void)startIconDownload2:(Wall *)appRecord {
- IconDownloader *iconDownloader = [imageDownloadsInProgress objectForKey:appRecord.thumbURL];
- if (iconDownloader == nil && [appRecord.thumbURL length] > 0) {
- if (![spinner isAnimating]) {
- [spinner startAnimating];
- }
- iconDownloader = [[IconDownloader alloc] init];
- iconDownloader.appRecord = appRecord;
- iconDownloader.delegate = self;
- iconDownloader.imageKey = appRecord.thumbURL;
- [imageDownloadsInProgress setObject:iconDownloader forKey:appRecord.thumbURL];
- [iconDownloader startDownload];
- [iconDownloader release];
- [multipleDownloadRecord setObject:[[NSMutableArray alloc] initWithObjects:appRecord, nil] forKey:appRecord.thumbURL];
- } else {
- NSMutableArray *downloadingRecords = [multipleDownloadRecord objectForKey:appRecord.thumbURL];
- [downloadingRecords addObject:appRecord];
- }
- }
- - (void)startIconDownload3:(Wall *)appRecord {
- IconDownloader *iconDownloader = [imageDownloadsInProgress objectForKey:appRecord.videoThumbUrl];
- if (iconDownloader == nil && [appRecord.videoThumbUrl length] > 0) {
- [spinner startAnimating];
- iconDownloader = [[IconDownloader alloc] init];
- iconDownloader.appRecord = appRecord;
- iconDownloader.delegate = self;
- iconDownloader.imageKey = appRecord.videoThumbUrl;
- [imageDownloadsInProgress setObject:iconDownloader forKey:appRecord.videoThumbUrl];
- [iconDownloader startDownload];
- [iconDownloader release];
- }
- }
- #pragma mark -
- #pragma mark ButtonPressed
- -(IBAction)deleteWall:(id)sender {
- deleteIndex = [sender tag];
- 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];
- alert.tag = 3;
- [alert show];
- [alert release];
- }
- -(IBAction)EventButtonPressed:(id)sender{
- Wall *record = [tempArray objectAtIndex:[sender tag]];
- JomEventDetailViewController3_0 *controller = [[JomEventDetailViewController3_0 alloc] init];
- controller.selectedEvent = record.eventDetail;
- controller.title = record.eventDetail.title;
- [ApplicationData sharedInstance].isEditMode = NO;
- [self.navigationController pushViewController:controller animated:YES];
- [controller release];
- [spinner startAnimating];
- [spinner release];
- }
- -(IBAction)GroupButtonPressed:(id)sender{
- //Wall *record = [[ApplicationData sharedInstance].updatesList objectAtIndex:[sender tag]];
- Wall *record = [tempArray objectAtIndex:[sender tag]];
- GroupDetailViewController3_0 *controller = [[GroupDetailViewController3_0 alloc] initWithNibName:@"GroupDetailViewController3_0"bundle:nil];
- controller.groupRecords= record.groupDetail;
- controller.groupRecords.Id = record.groupDetail.Id;
- [self.navigationController pushViewController:controller animated:YES];
- [controller release];
- [spinner startAnimating];
- [spinner release];
- }
- - (IBAction)userButtonPressed:(id)sender {
- Wall *record = [tempArray objectAtIndex:[sender tag]];
- MainPageViewController *controller = [[MainPageViewController alloc] init];
- controller.userDetail = record.userdetail;
- [self.navigationController pushViewController:controller animated:YES];
- [controller release];
- // [self.splitViewController viewWillDisappear:YES];
- // [[self.appDelegate.splitViewController.viewControllers objectAtIndex:0]popViewControllerAnimated:YES];
- // [[self.appDelegate.splitViewController.viewControllers objectAtIndex:1]popViewControllerAnimated:YES];
- // UIViewController <UISplitViewControllerDelegate>*viewController=[[self.appDelegate.splitViewController.viewControllers objectAtIndex:1] visibleViewController];
- // self.splitViewController.delegate=viewController;
- // [self.splitViewController viewWillAppear:YES];
- }
- - (IBAction)FriendNameButtonPressed:(id)sender {
- Wall *record = [tempArray objectAtIndex:[sender tag]];
- MainPageViewController *controller = [[MainPageViewController alloc] init];
- controller.userDetail = record.tempUser;
- [self.navigationController pushViewController:controller animated:YES];
- [controller release];
- }
- - (IBAction)videoButtonPressed:(id)sender {
- iJoomerAppDelegate *appdelegate = (iJoomerAppDelegate *) [[UIApplication sharedApplication] delegate];
- appdelegate.viewTop.hidden = YES;
- appdelegate.TabView.hidden = YES;
- Video *videoObj = [tempArray objectAtIndex:[sender tag]];
- NSURL *URL = [NSURL URLWithString:videoObj.videoURL];
- [self presentMoviePlayerViewControllerAnimated:moviePlayer];
- if(URL)
- {
- Class mplayerControllerClass = NSClassFromString(@"MPMoviePlayerViewController");
- if(mplayerControllerClass != nil) {
- #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 30200
- moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:URL];
- moviePlayer.wantsFullScreenLayout = YES;
- //[self->moviePlayer shouldAutorotateToInterfaceOrientation:YES];
- // Movie playback is asynchronous, so this method returns immediately.
- if(moviePlayer)
- {
- [self presentMoviePlayerViewControllerAnimated:moviePlayer];
- }
- #else
- // moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:URL];
- // moviePlayer.scalingMode = MPMovieScalingModeFill;
- // moviePlayer.controlStyle = MPMovieControlStyleDefault;
- // moviePlayer.shouldAutoplay = YES;
- // [self.view addSubview:moviePlayer.view];
- movieplayer = [[[CustomMoviePlayerViewController alloc] initWithContentURL:URL] autorelease];
- [self presentModalViewController:movieplayer animated:YES];
- // Prep and play the movie
- [movieplayer readyPlayer];
- // if(moviePlayer)
- // {
- // [self.moviePlayer play];
- // }
- #endif
- }
- }
- }
- -(IBAction)ProfileVideoButtonPressed:(id)sender {
- self.navigationItem.hidesBackButton = YES;
- [self embedYouTube:[userDetail.profile_video objectForKey:@"url"] frame:CGRectZero];
- webView.hidden = NO;
- iJoomerAppDelegate *appdelegate = (iJoomerAppDelegate *) [[UIApplication sharedApplication] delegate];
- appdelegate.viewTop.hidden = YES;
- appdelegate.TabView.hidden = YES;
- self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Close",@"Cancel") style:UIBarButtonItemStylePlain target:self action:@selector(cancelButtonPressed:)] autorelease];
- }
- - (IBAction)commentLikeButtonPressed:(id)sender {
- CommentViewController *controller = [[CommentViewController alloc] init];
- controller.selectedWall = [tempArray objectAtIndex:[sender tag]];
- controller.userDetail = self.userDetail;
- [self.navigationController pushViewController:controller animated:YES];
- [controller release];
- }
- - (IBAction)commentButtonPressed:(id)sender {
- CommentViewController *controller = [[CommentViewController alloc] init];
- controller.selectedWall = [tempArray objectAtIndex:[sender tag]];
- controller.userDetail = self.userDetail;
- // controller.event = self.event;
- [self.navigationController pushViewController:controller animated:YES];
- [controller release];
- }
- - (IBAction)likeButtonPressed:(id)sender {
- if (![spinner isAnimating]) {
- tableView.userInteractionEnabled = FALSE;
- wallRecord = [tempArray objectAtIndex:[sender tag]];
- if ([[sender titleLabel].text isEqualToString:NSLocalizedString(@"unlike_btn", @"")]) {
- NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
- if ([wallRecord.liketype isEqualToString:@"videos"]) {
- [postVariables setObject:[NSString stringWithFormat:@"%d",wallRecord.videoObj.videoID] forKey:@"wallID"];
- }else {
- [postVariables setObject:[NSString stringWithFormat:@"%d",wallRecord.wallId] forKey:@"wallID"];
- }
- [postVariables setObject:wallRecord.liketype forKey:@"type"];
- // [postVariables setObject:[NSString stringWithFormat:@"%d",permissionValue] forKey:@"permissions"];
- NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"wall" ExtTask:@"unlike" TaskdataDictionary:postVariables Imagedata:nil];
- [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
- currentRequestType = jlikeUnlikeQuery;
- if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
- [self requestCompleted];
- }else {
- [spinner stopAnimating];
- [self stopLoading];
- self.view.userInteractionEnabled = YES;
- }
- }
- else
- {
- NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
- if ([wallRecord.liketype isEqualToString:@"videos"]) {
- [postVariables setObject:[NSString stringWithFormat:@"%d",wallRecord.videoObj.videoID] forKey:@"wallID"];
- }else {
- [postVariables setObject:[NSString stringWithFormat:@"%d",wallRecord.wallId] forKey:@"wallID"];
- }
- [postVariables setObject:wallRecord.liketype forKey:@"type"];
- // [postVariables setObject:[NSString stringWithFormat:@"%d",permissionValue] forKey:@"permissions"];
- NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"wall" ExtTask:@"like" TaskdataDictionary:postVariables Imagedata:nil];
- [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
- currentRequestType = jlikeUnlikeQuery;
- if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
- [self requestCompleted];
- }else {
- [spinner stopAnimating];
- [self stopLoading];
- self.view.userInteractionEnabled = YES;
- }
- }
- }
- }
- - (void)postButtonPressed {
- if (![spinner isAnimating]) {
- if (txtComment.text.length == 0) {
- [self showAlert:NSLocalizedString(@"no_text",@"") Content:NSLocalizedString(@"Please_enter_text", @"")];
- return;
- }
- NSMutableDictionary *postVariables = [[NSMutableDictionary alloc]init];
- [postVariables setObject:txtComment.text forKey:@"message"];
- [postVariables setObject:[NSString stringWithFormat:@"%d",wallRecord.wallId] forKey:@"uniqueID"];
- [postVariables setObject:[NSString stringWithFormat:@"%d",1] forKey:@"comment"];
- [postVariables setObject:@"0" forKey:@"privacy"];
- // [postVariables setObject:[NSString stringWithFormat:@"%d",permissionValue] forKey:@"permissions"];
- NSDictionary *dict = [Jomsocial JomsocialCommonDictfunction:@"wall" ExtTask:@"add" TaskdataDictionary:postVariables Imagedata:nil];
- [ApplicationData sharedInstance].errorCode = [[dict objectForKey:TAG_CODE] intValue];
- currentRequestType = jShareQuery;
- if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
- [self requestCompleted];
- }else {
- self.view.userInteractionEnabled = YES;
- }
- [txtComment resignFirstResponder];
- [txtComment setHidden:YES];
- }
- txtComment.hidden = YES;
- }
- #pragma mark -
- #pragma mark user defined functions
- - (void)logoutProcess{
- tableView.userInteractionEnabled = NO;
- self.navigationItem.rightBarButtonItem.enabled = FALSE;
- if(!tabBarLayerView) {
- CGRect frame = CGRectMake(0,0,420,49);
- tabBarLayerView = [[UIImageView alloc] initWithFrame:frame];
- [[self.tabBarController tabBar] addSubview:tabBarLayerView];
- // [self.tabBarController tabBar].userInteractionEnabled = NO;
- [tabBarLayerView setUserInteractionEnabled:YES];
- }
- if (![spinner isAnimating])
- {
- [spinner startAnimating];
- }
- NSDictionary *dict = [JoomlaRegistration CreateDictionary:@"logout" TaskdataDictionary:nil Imagedata:nil];
- //[ijoomer_lib Logout:[ApplicationData sharedInstance].loggedUser static_URL:sever_static_URL];
- NSNumber *num = [dict objectForKey:@"code"];
- int code = [num intValue];
- [ApplicationData sharedInstance].errorCode = code;
- currentRequestType = jLogoutQuery;
- if([ErrorHandler hasError:self errorCode:[[dict objectForKey:TAG_CODE] intValue] errorMessage:[dict objectForKey:TAG_ERROR_MESSAGE]]){
- [self requestCompleted];
- }else {
- self.view.userInteractionEnabled = YES;
- }
- }
- #pragma mark -
- #pragma mark default functions
- - (void)didReceiveMemoryWarning {
- }
- - (void)viewDidUnload{
- [btnLikePr release];
- btnLikePr = nil;
- [btnLike release];
- btnLike = nil;
- [btnUnlike release];
- btnUnlike = nil;
- [btnUnlikeStupid release];
- btnUnlikeStupid = nil;
- [btnMap release];
- btnMap = nil;
- [NSObject cancelPreviousPerformRequestsWithTarget:self];
- #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
- self.contentView = nil;
- banner.delegate = nil;
- self.banner = nil;
- #endif
- }
- - (void)dealloc
- {
- [btnHoldnSpeak release];
- [btnTextFromVoice release];
- [btnUserAbout release];
- [btnUserVideos release];
- [btnUserPhotos release];
- [btnUserFriends release];
- [voiceoverView release];
- [myWebview release];
- [btnLikePr release];
- [btnLike release];
- [btnUnlike release];
- [btnUnlikeStupid release];
- [btnMap release];
- [NSObject cancelPreviousPerformRequestsWithTarget:self];
- #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
- [contentView release]; contentView = nil;
- banner.delegate = nil;
- [banner release]; banner = nil;
- #endif
- [imageDownloadsInProgress release];
- [imageUploader release];
- //[dataForTable release];
- //[tableView release];
- [name release];
- //[statusMsg release];
- [userImg release];
- if (false) {
- [super dealloc];
- }
- }
- - (void)viewWillDisappear:(BOOL)animated {
- isImageUpdated = NO;
- iJoomerAppDelegate *appdelegate = (iJoomerAppDelegate *) [[UIApplication sharedApplication] delegate];
- appdelegate.viewTop.hidden = YES;
- appdelegate.TabView.hidden = YES;
- [NSObject cancelPreviousPerformRequestsWithTarget:self];
- isViewWillDisAapear = YES;
- if([spinner isAnimating]) {
- RequestResponseManager *requestManager = [RequestResponseManager sharedInstance];
- [requestManager cancleRequest];
- [requestManager removeRequestProperty:self ExtraInfo:nil];
- }
- if([imageDownloadsInProgress count] > 0) {
- IconDownloader *downloader;
- for(downloader in [imageDownloadsInProgress objectEnumerator]) {
- [downloader cancelDownload];
- }
- [imageDownloadsInProgress removeAllObjects];
- }
- if(imageUploader) {
- self.navigationItem.rightBarButtonItem.enabled = TRUE;
- self.navigationItem.leftBarButtonItem.enabled = TRUE;
- tableView.userInteractionEnabled = YES;
- if(userDetail.avatarImg) {
- userImg.image = userDetail.avatarImg;
- }
- [imageUploader cancelUpload];
- }
- [spinner stopAnimating];
- [self.tabBarController hidesBottomBarWhenPushed];
- progressBar.hidden = TRUE;
- userImg.alpha = 1;
- }
- - (void)startIconDownload:(Photo *)appRecord {
- if(isViewWillDisAapear){return;};
- IconDownloader *iconDownloader = [imageDownloadsInProgress objectForKey:appRecord.thumbURL];
- if (iconDownloader == nil && [appRecord.thumbURL length] > 0)
- {
- //DLog(@"Start Image Downloading : %@ Total Progress : %d", appRecord.imgURL, [imageDownloadsInProgress count]);
- [spinner startAnimating];
- iconDownloader = [[IconDownloader alloc] init];
- iconDownloader.appRecord = appRecord;
- iconDownloader.delegate = self;
- iconDownloader.imageKey = appRecord.thumbURL;
- [imageDownloadsInProgress setObject:iconDownloader forKey:appRecord.thumbURL];
- [iconDownloader startDownload];
- [iconDownloader release];
- [multipleDownloadRecord setObject:[[[NSMutableArray alloc] initWithObjects:appRecord, nil] autorelease] forKey:appRecord.thumbURL];
- } else {
- NSMutableArray *downloadingRecords = [multipleDownloadRecord objectForKey:appRecord.thumbURL];
- [downloadingRecords addObject:appRecord];
- }
- }
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////// IconDownloaderDelegate ////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////
- - (void)appImageDidLoad:(NSObject *)imageKey
- {
- [imageDownloadsInProgress removeObjectForKey:imageKey];
- if([imageDownloadsInProgress count] == 0)
- {
- [spinner stopAnimating];
- [tableView reloadData];
- if ([userDetail avatarImg])
- {
- DLog(@"image set");
- [userImg setImage:[userDetail avatarImg]];
- //[userImg setBackgroundColor:[UIColor clearColor]];
- }
- }
- // for same url of multiple records
- NSMutableArray *downloadingRecords = [multipleDownloadRecord objectForKey:imageKey];
- if([downloadingRecords count] > 1) {
- if([[downloadingRecords objectAtIndex:0] isKindOfClass:[Wall class]])
- {
- Wall *record = [downloadingRecords objectAtIndex:0];
- for(id<IconRecord> otherRecord in downloadingRecords)
- {
- [otherRecord setImage:record.thumbImg ImageKey:imageKey];
- }
- }
- else if([[downloadingRecords objectAtIndex:0] isKindOfClass:[Image class]])
- {
- Image *record = [downloadingRecords objectAtIndex:0];
- for(id<IconRecord> otherRecord in downloadingRecords)
- {
- [otherRecord setImage:record.imgSource ImageKey:imageKey];
- }
- }
- }
- [downloadingRecords removeAllObjects];
- [multipleDownloadRecord removeObjectForKey:imageKey];
- if([imageDownloadsInProgress count] == 0) {
- [spinner stopAnimating];
- [tableView reloadData];
- }
- }
- /////////////////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////// Friends Map /////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////////////////////
- - (IBAction)mapButtonPressed:(id)sender {
- UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"button_back",@"") style:UIBarButtonItemStylePlain target:self action:@selector(backButtonPressed:)];
- self.navigationItem.rightBarButtonItem = button;
- self.navigationItem.hidesBackButton = YES;
- [button release];
- [self.view addSubview:mapView];
- tableView.hidden = YES;
- mapView.hidden = NO;
- [self showFriendsOnMap];
- }
- - (IBAction)backButtonPressed:(id)sender {
- self.navigationItem.hidesBackButton = NO;
- self.navigationItem.rightBarButtonItem = nil;
- tableView.hidden = NO;
- mapView.hidden = YES;
- }
- - (void)showFriendsOnMap {
- if (!localmapView) {
- if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
- {
- CGSize result = [[UIScreen mainScreen] bounds].size;
- if(result.height == 480)
- {
- localmapView = [[MKMapView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 367.0)];
- }
- if(result.height == 568)
- {
- localmapView = [[MKMapView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 455.0)];
- }
- }
- [mapView addSubview:localmapView];
- }
- else
- {
- NSArray *annotationArray = [localmapView annotations];
- for(int i=[annotationArray count]-1; i>=0; --i) {
- id<MKAnnotation> userAnnotation = [annotationArray objectAtIndex:i];
- if([userAnnotation isKindOfClass:[MapItemAnnotation class]]) {
- [localmapView removeAnnotation:userAnnotation];
- }
- }
- }
- localmapView.delegate = self;
- MapItemAnnotation *annotation;
- if (userDetail.userId == 0) {
- coordinate.latitude = [[ApplicationData sharedInstance].locationManager latitude];
- coordinate.longitude = [[ApplicationData sharedInstance].locationManager longitude];
- }else {
- coordinate.latitude = userDetail.latitude;
- coordinate.longitude = userDetail.longitude;
- }
- [localmapView setShowsUserLocation:YES];
- double region;
- region = 5.50;
- if (coordinate.latitude >= -90 && coordinate.latitude <= 90 &&
- coordinate.longitude >= -180 && coordinate.longitude <= 180) {
- [localmapView setRegion:MKCoordinateRegionMake(coordinate, MKCoordinateSpanMake(region, region))];
- }
- annotation = [[[MapItemAnnotation alloc] initWithCoordinate:coordinate AnnotationTitle:userDetail.userName] autorelease];
- annotation.mapUser = userDetail;
- [localmapView addAnnotation:annotation];
- [localmapView setNeedsDisplay];
- [localmapView setMapType:MKMapTypeStandard];
- }
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////// ImageUploaderDelegate ////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////
- - (void)appImageDidUpload {
- userImg.image = userImage;
- userDetail.avatarImg = userImage;
- // if([ErrorHangler hasError:self errorCode:(int)[[dict objectForKey:TAG_CODE] intValue] errorMessage:(NSString*)[dict objectForKey:TAG_ERROR_MESSAGE]]){
- [self requestCompleted];
- // };
- imageUploader = nil;
- }
- ///------------------------------- Pull down to Refresh start ---------------------------------///
- - (void)addPullToRefreshHeader {
- textPull = [[NSString alloc] initWithString:@"Pull down to refresh..."];
- textRelease = [[NSString alloc] initWithString:@"Release to refresh..."];
- textLoading = [[NSString alloc] initWithString:@"Loading..."];
- refreshHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0 - REFRESH_HEADER_HEIGHT, 320, REFRESH_HEADER_HEIGHT)];
- refreshHeaderView.backgroundColor = [UIColor clearColor];
- refreshLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, pullTable.frame.size.width, REFRESH_HEADER_HEIGHT)];
- refreshLabel.backgroundColor = [UIColor clearColor];
- refreshLabel.font = [UIFont boldSystemFontOfSize:12.0];
- refreshLabel.textColor = [ApplicationData sharedInstance].textcolor;
- refreshLabel.textAlignment = UITextAlignmentCenter;
- refreshArrow = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrowpull.png"]];
- [refreshArrow setContentMode:UIViewContentModeCenter];
- refreshArrow.frame = CGRectMake((REFRESH_HEADER_HEIGHT - 27) / 2,
- (REFRESH_HEADER_HEIGHT - 44) / 2,
- 27, 44);
- [refreshHeaderView addSubview:refreshLabel];
- [refreshHeaderView addSubview:refreshArrow];
- [self->pullTable addSubview:refreshHeaderView];
- }
- - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
- if (isLoading) return;
- isDragging = YES;
- }
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
- if (isLoading) {
- // Update the content inset, good for section headers
- if (scrollView.contentOffset.y > 0)
- self->pullTable.contentInset = UIEdgeInsetsZero;
- else if (scrollView.contentOffset.y >= -REFRESH_HEADER_HEIGHT)
- self->pullTable.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
- } else if (isDragging && scrollView.contentOffset.y < 0) {
- // Update the arrow direction and label
- [UIView beginAnimations:nil context:NULL];
- if (scrollView.contentOffset.y < -REFRESH_HEADER_HEIGHT) {
- // User is scrolling above the header
- refreshLabel.text = self->textRelease;
- [refreshArrow layer].transform = CATransform3DMakeRotation(M_PI, 0, 0, 1);
- } else { // User is scrolling somewhere within the header
- refreshLabel.text = self->textPull;
- [refreshArrow layer].transform = CATransform3DMakeRotation(M_PI * 2, 0, 0, 1);
- }
- [UIView commitAnimations];
- }
- }
- - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
- if (txtStatus.text.length == 0)
- {
- btnwtsonurmind.hidden = NO;
- }else{
- btnwtsonurmind.hidden = YES;
- }
- if (txtPhotoCaption.text.length == 0)
- {
- btnPhotocaption.hidden = NO;
- }else{
- btnPhotocaption.hidden = YES;
- }
- [txtStatus resignFirstResponder];
- [Voiceover.txtStaus resignFirstResponder];
- [txtPhotoCaption resignFirstResponder];
- if (isLoading) return;
- isDragging = NO;
- if (scrollView.contentOffset.y <= -REFRESH_HEADER_HEIGHT) {
- // Released above the header
- [self startLoading];
- }
- }
- - (void)startLoading {
- isLoading = YES;
- // Show the header
- [UIView beginAnimations:nil context:NULL];
- [UIView setAnimationDuration:0.3];
- self->pullTable.contentInset = UIEdgeInsetsMake(REFRESH_HEADER_HEIGHT, 0, 0, 0);
- refreshLabel.text = self->textLoading;
- refreshArrow.hidden = YES;
- [refreshSpinner startAnimating];
- [UIView commitAnimations];
- // Refresh action!
- [self refresh];
- }
- - (void) refresh {
- if (![spinner isAnimating]) {
- [spinner startAnimating];
- self.view.userInteractionEnabled = NO;
- pageNo = 1;
- [userDetail.wallList removeAllObjects];
- [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(profileRequest) userInfo:nil repeats:NO];
- }
- }
- - (void)stopLoading {
- isLoading = NO;
- // Hide the header
- [UIView beginAnimations:nil context:NULL];
- [UIView setAnimationDelegate:self];
- [UIView setAnimationDuration:0.3];
- [UIView setAnimationDidStopSelector:@selector(stopLoadingComplete:finished:context:)];
- self->pullTable.contentInset = UIEdgeInsetsZero;
- [refreshArrow layer].transform = CATransform3DMakeRotation(M_PI * 2, 0, 0, 1);
- [UIView commitAnimations];
- }
- - (void)stopLoadingComplete:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
- // Reset the header
- refreshLabel.text = self->textPull;
- refreshArrow.hidden = NO;
- [refreshSpinner stopAnimating];
- }
- -(IBAction)simanswers:(id)sender {
- myWebview.hidden = NO;
- myWebview.tag = 394;
- [spinner startAnimating];
- myWebview.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
- NSString *theUrl;
- Wall *record = [tempArray objectAtIndex:[sender tag]];
- theUrl = [NSString stringWithFormat:@"http://iremember.gr/el/component/simanswers/?view=question&qid=%d&Itemid=150", record.qid];
- [myWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:theUrl]]];
- [self.view addSubview:myWebview];
- UIBarButtonItem *navigationBarbackButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"button_back",@"") style:UIBarButtonItemStyleBordered target:self action:@selector(close:)];
- self.navigationItem.leftBarButtonItem = navigationBarbackButton;
- }
- - (IBAction)close:(id)sender {
- [[self.view viewWithTag:394] removeFromSuperview];
- self.navigationItem.leftBarButtonItem = nil;
- }
- - (void)webViewDidFinishLoad:(UIWebView *)webView {
- [spinner stopAnimating];
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement