//
//  BaseTableViewController.m
//  TaiZhouTobacco_assets
//
//  Created by JianjiYuan on 14-5-19.
//  Copyright (c) 2014年 JianjiYuan. All rights reserved.
//

#import "BaseTableViewController.h"

@interface BaseTableViewController ()


@end

@implementation BaseTableViewController

#pragma mark =============  Memery Release  =============

- (void)dealloc
{
    [self disposeProperties];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    if ([self isViewLoaded] && self.view.window == nil) {
        [self disposeProperties];
    }
}

- (void)disposeProperties
{
    self.arrContents = nil;
    self.tableVContent = nil;
    self.selectedIndexPath = nil;
}

#pragma mark =============  Initiation Method  =============

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization        
    }
    return self;
}

#pragma mark =============  Life Circle  =============

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self.imageVNoResult autoSetDimensionsToSize:CGSizeMake(200, 200)];
   // [self.imageVNoResult autoAlignAxisToSuperviewAxis:ALAxisHorizontal];
    [self.imageVNoResult autoAlignAxisToSuperviewAxis:ALAxisVertical];
    [self.imageVNoResult autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:100];
    self.imageVNoResult.hidden = YES;
    
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    if (self.selectedIndexPath) {
        [self.tableVContent deselectRowAtIndexPath:self.selectedIndexPath animated:YES];
    }
    
}

#pragma mark =============  UITableView DataSource  =============

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return nil;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _arrContents.count;
}

#pragma mark =============  UITableView Delegate  =============

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    self.selectedIndexPath = indexPath;
    DLog(@"You Click At Section: %d Row: %d", (int)indexPath.section, (int)indexPath.row);
}

#pragma mark =============  Properties Lazy Load  =============

- (UITableView *)tableVContent
{
    if (_tableVContent) {
        return _tableVContent;
    }
    self.tableVContent = [UITableView newAutoLayoutView];
    _tableVContent.backgroundColor = [UIColor clearColor];
    _tableVContent.delegate = self;
    _tableVContent.dataSource = self;
    _tableVContent.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    _tableVContent.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
    [self.view addSubview:_tableVContent];
    return _tableVContent;
}

- (NSMutableArray *)arrContents
{
    if (_arrContents) {
        return _arrContents;
    }
    NSMutableArray *arrTemp = [NSMutableArray array];
    self.arrContents = arrTemp;
    return _arrContents;
}

- (UIImageView *)imageVNoResult
{
    
    if (!_imageVNoResult) {
        self.imageVNoResult = [UIImageView newAutoLayoutView];
        _imageVNoResult.image = [UIImage imageNamed:@"pic_zanwushuju.png"];
        
        
        
        [self.view addSubview:_imageVNoResult];
    }
    return _imageVNoResult;
}

@end
