| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- //
- // ActiveViewController.m
- // RedAnt ERP Mobile
- //
- // Created by Ray on 12/15/15.
- // Copyright © 2015 United Software Applications, Inc. All rights reserved.
- //
- #import "ActiveViewController.h"
- #import "config.h"
- #import "AppDelegate.h"
- //#import "NotificationNameCenter.h"
- @interface ActiveViewController ()
- @end
- @implementation ActiveViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.refresh_type = REFRESH_DATA;
-
- #ifdef RA_NOTIFICATION
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(OnRefreshUI:) name:RA_NOTIFICATION_REFRESH_UI object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(OnReloadData:) name:RA_NOTIFICATION_RELOAD_DATA object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(OnClearData:) name:RA_NOTIFICATION_CLEAR_DATA object:nil];
- #endif
-
- // Do any additional setup after loading the view.
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
-
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-
- appDelegate.active_controller = self;
-
-
- switch (self.refresh_type)
- {
- case REFRESH_VIEW:
- [self reload_container_getdata:false];
-
- break;
- case REFRESH_DATA: {
- [self reRefreshView];
- [self reload_container_getdata:true];
- }
-
- break;
- }
- // [[self navigationController] setNavigationBarHidden:YES animated:NO];
-
-
- }
- -(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
- {
- // UIApplication * app = [UIApplication sharedApplication];
- // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- // [appDelegate didRotated];
-
- // UIInterfaceOrientation orientation = [[UIApplication sharedApplication]statusBarOrientation];
- // if (UIInterfaceOrientationIsLandscape(orientation)|| UIInterfaceOrientationIsPortrait(orientation))
- // {
- // self.orientation = orientation;
- // [self.collectionview.collectionViewLayout invalidateLayout];
- // DebugLog(@"routed");
- // }
-
-
-
-
- }
- - (void)reRefreshView {
-
- }
- -(void) logout
- {
- self.refresh_type=REFRESH_NONE;
- }
- -(void) showHidePrice
- {
- // [self reload_container_getdata:false];
- }
- -(void) refresh_on_login
- {
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- if(self==appDelegate.active_controller)
- {
- [self reload_container_getdata:true];
- }
- else
- self.refresh_type = REFRESH_DATA;
- }
- -(void) reload_container_getdata:(bool) update_data
- {
- self.refresh_type=REFRESH_NONE;
-
- }
- -(void)refresh_btn_click:(UILongPressGestureRecognizer*)gestureRecognizer
- {
- [self reload_container_getdata:true];
- }
- /*
- #pragma mark - Navigation
-
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- #pragma mark - Support scanner
- -(void) OnUpdateDevicesList
- {
-
- }
- -(void) onDecodedData:(NSString*) value
- {
-
- }
- -(void) onErrorInfo:(NSString*) errorInfo
- {
-
- }
- -(void) onStatusChanged:(NSString*) status
- {
-
- }
- -(void) onLogUpdate
- {
-
- }
- #pragma mark - Notification
- - (void)OnRefreshUI: (NSNotification *)notification
- {
- NSDictionary* dict = [notification userInfo];
- NSArray* arr= dict[@"receiver"];
- if([arr indexOfObject:[self class_name]]==NSNotFound)
- return;
- // if([self class_name] isEqualToString:@"")
-
- if(self.notification_refreshLevel<NotificationRefreshLevelView)
- {
- if([self isVisible])
- {
- if([self respondsToSelector:@selector(refresh_ui)])
- [self refresh_ui];
- }
- else
- {
- self.notification_refreshLevel = NotificationRefreshLevelView;
- }
- }
- }
- - (void)OnReloadData: (NSNotification *)notification
- {
- NSDictionary* dict = [notification userInfo];
- NSArray* arr= dict[@"receiver"];
- if([arr indexOfObject:[self class_name]]==NSNotFound)
- return;
-
- if(self.notification_refreshLevel<NotificationRefreshLevelData)
- {
- if([self isVisible])
- {
- if([self respondsToSelector:@selector(reload_data)])
- [self reload_data];
- }
- else
- {
- self.notification_refreshLevel = NotificationRefreshLevelData;
- }
- }
-
- }
- - (void)OnClearData: (NSNotification *)notification
- {
-
- if([self isVisible])
- {
- if([self respondsToSelector:@selector(clear_data)])
- {
- [self clear_data];
- if([self respondsToSelector:@selector(refresh_ui)])
- [self refresh_ui];
- }
- }
- else
- {
- if([self respondsToSelector:@selector(clear_data)])
- {
- [self clear_data];
- if(self.notification_refreshLevel<NotificationRefreshLevelView)
- self.notification_refreshLevel = NotificationRefreshLevelView;
- }
- }
-
- }
- #pragma mark - utils
- -(BOOL)isVisible
- {
- return (self.isViewLoaded && self.view.window);
- }
- - (NSString *)class_name {
- const char *class_name_ch = object_getClassName([self class]);
- return [NSString stringWithUTF8String:class_name_ch];
- }
- @end
|