//
//  SupportDeviceViewController.m
//  kneet
//
//  Created by Jason Lee on 6/22/15.
//  Copyright (c) 2015 ntels. All rights reserved.
//

#import "CommonUtil.h"
#import "SupportDeviceViewController.h"
#import "CustomLabel.h"
#import "ImageUtil.h"


@interface SupportDeviceViewController () {
    UIImage *_bgCellImage1, *_bgCellImage2;
}
@end


#pragma mark - Class Definition

@implementation SupportDeviceViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self initUI];
    [self prepareViewDidLoad];
}


- (void)initUI {
    self.title = NSLocalizedString(@"지원 기기 목록", @"지원 기기 목록");
    
    
    
    
    //set tableview option
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.backgroundColor = [UIColor clearColor];
    
    UIEdgeInsets insets = UIEdgeInsetsMake(4, 4, 4, 4);
    _bgCellImage1 = [ImageUtil resizableImageWithCapInsets:insets resizingMode:UIImageResizingModeStretch img:[UIImage imageNamed:@"tp_01_img_list_bg_02"]];
    _bgCellImage2 = [ImageUtil resizableImageWithCapInsets:insets resizingMode:UIImageResizingModeStretch img:[UIImage imageNamed:@"tp_01_img_list_bg_01"]];
    
    //Localization
    _lblFoscamDesc.text = NSLocalizedString(@"FOSCAM (MJPEG지원모델)", @"FOSCAM (MJPEG지원모델)");
}

- (void)prepareViewDidLoad {
    
}

#pragma mark - UITableView DataSource & Delegate

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];
    
    //set background image
    if (indexPath.row % 2 == 1) {
        cell.backgroundView = [[UIImageView alloc] initWithImage:_bgCellImage1];
    } else {
        cell.backgroundView = [[UIImageView alloc] initWithImage:_bgCellImage2];
    }
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}


- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    
    // Remove seperator inset
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
    
    // Prevent the cell from inheriting the Table View's margin settings
    if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
        [cell setPreservesSuperviewLayoutMargins:NO];
    }
    
    // Explictly set your cell's layout margins
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}


#pragma mark - UI Events



#pragma mark - MemoryWarning
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
