//
//  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"
@interface ActiveViewController ()

@end

@implementation ActiveViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.refresh_type = REFRESH_DATA;
    // 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 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) 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
{
    
}
@end
