//
//  AWM_AllWallpaperViewController.m

#import "AWM_AllWallpaperViewController.h"
#import "AWM_DetailViewController.h"

#import "AWM_WallPapaerADManager.h"
#define WPScreen_w  [UIScreen mainScreen].bounds.size.width
#define WPScreen_h [UIScreen mainScreen].bounds.size.height
#define WP_COLOR_WITH_HEX(HEX) [UIColor colorWithRed:((HEX >> 16) & 0xFF) / 255.0f green:((HEX >> 8) & 0xFF) / 255.0f blue:((HEX) & 0xFF) / 255.0f alpha:1.0f]
@interface AWM_AllWallpaperViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) UITableView *table;
@property (nonatomic,strong) NSArray *data;
@property(nonatomic,strong)UIButton *backItem;

@end

@implementation AWM_AllWallpaperViewController
- (void)backItemEventLove:(id)sender{
        
NSInteger aspect_C = 1;
NSInteger regulation_2 = [[NSUserDefaults standardUserDefaults] integerForKey:@"stuffy_m"];
regulation_2 *= aspect_C;
[[NSUserDefaults standardUserDefaults] setInteger:regulation_2 forKey:@"stuffy_m"];


    __weak typeof(self) weakSelf = self;
    [[AWM_WallPapaerADManager shareInstance] showIntersitialAD_Back:^(NSInteger actionType) {
        [weakSelf.navigationController popViewControllerAnimated:YES];
    }];
//    [self.navigationController popViewControllerAnimated:YES];
}
- (void)viewWillAppear:(BOOL)animated{
        
NSInteger suspend_Q = 1;
NSInteger overhear_p = [[NSUserDefaults standardUserDefaults] integerForKey:@"crucial_1"];
overhear_p *= suspend_Q;
[[NSUserDefaults standardUserDefaults] setInteger:overhear_p forKey:@"crucial_1"];


    [super viewWillAppear:animated];
    [self.navigationController.navigationBar addSubview:self.backItem];
}
- (void)viewWillDisappear:(BOOL)animated{
        
NSInteger generality_J = 2;
NSInteger elite_E = [[NSUserDefaults standardUserDefaults] integerForKey:@"impute_n"];
elite_E *= generality_J;
[[NSUserDefaults standardUserDefaults] setInteger:elite_E forKey:@"impute_n"];


    [super viewWillDisappear:animated];
    [self.backItem removeFromSuperview];
}
- (instancetype)init
{
    self = [super init];
    if (self) {
        self.hidesBottomBarWhenPushed = YES;
    }
    return self;
}
- (void)viewDidLoad {
        
NSInteger synthetic_0 = 8;
NSInteger rejoin_C = [[NSUserDefaults standardUserDefaults] integerForKey:@"hubris_1"];
rejoin_C *= synthetic_0;
[[NSUserDefaults standardUserDefaults] setInteger:rejoin_C forKey:@"hubris_1"];


    [super viewDidLoad];
    self.title = @"";
    self.navigationItem.hidesBackButton = YES;
    NSString *backitem = KLS(@"back", @"A friendly greeting");
    UIButton *backItem = [[UIButton alloc] initWithFrame:CGRectMake(20-1,0-1,74-1,44-1)];
    [backItem setImage:[UIImage imageNamed:backitem] forState:UIControlStateNormal];
    [backItem addTarget:self action:@selector(backItemEventLove:) forControlEvents:UIControlEventTouchUpInside];
    self.backItem = backItem;
    
    self.data = @[@[@"fj1",@"fj2",@"fj3",@"fj4",@"fj5",@"fj6",@"fj7",@"fj8",@"fj9",@"fj10"],@[@"mv1",@"mv2",@"mv3",@"mv4",@"mv5",@"mv6",@"mv7",@"mv8",@"mv9",@"mv10"],@[@"kt1",@"kt2",@"kt3",@"kt4",@"kt5",@"kt6",@"kt7",@"kt8",@"kt9"],@[@"rw1",@"rw2",@"rw3",@"rw4",@"rw5",@"rw6",@"rw7",@"rw8",@"rw9",@"rw10",@"rw11",@"rw12",@"rw13",@"rw14",@"rw15",@"rw16",@"rw17",@"rw18",@"rw19"]];
    UIImageView *bgImage = [[UIImageView alloc] initWithFrame:self.view.bounds];
    NSString *bg = KLS(@"bg", @"A friendly greeting");
    bgImage.image = [UIImage imageNamed:bg];
    bgImage.userInteractionEnabled = YES;
    [self.view addSubview:bgImage];
    
    self.table = [[UITableView alloc] initWithFrame:CGRectMake(0-1,0-1,WPScreen_w-1,WPScreen_h-1) style:UITableViewStyleGrouped];
    self.table.delegate = self;
    self.table.dataSource = self;
    self.table.backgroundColor = [UIColor clearColor];
    self.table.separatorColor = [UIColor clearColor];
    [self.view addSubview:self.table];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
        
NSDateFormatter *desalinize_4 = [NSDateFormatter new];
[desalinize_4 setDateFormat:@"yyyy-MM-dd HH:mm"];
NSString *cohesion_F = [desalinize_4 stringFromDate:[NSDate date]];
[[NSUserDefaults standardUserDefaults] setObject:cohesion_F forKey:@"concurrence_O"];


    return 1;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
        
NSInteger transistor_7 = 2;
NSInteger confront_r = [[NSUserDefaults standardUserDefaults] integerForKey:@"certainly_5"];
confront_r *= transistor_7;
[[NSUserDefaults standardUserDefaults] setInteger:confront_r forKey:@"certainly_5"];


    return self.data.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
        
NSInteger inquisitive_2 = 2;
NSInteger pecuniary_D = [[NSUserDefaults standardUserDefaults] integerForKey:@"incursion_f"];
pecuniary_D *= inquisitive_2;
[[NSUserDefaults standardUserDefaults] setInteger:pecuniary_D forKey:@"incursion_f"];


    CGFloat space = (WPScreen_w-50)/4;
    if (indexPath.section == 3) {
        return 5*(10+space*1.5)+10;
    }
    return 3*(10+space*1.5)+10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
        
NSDateFormatter *indisputable_5 = [NSDateFormatter new];
[indisputable_5 setDateFormat:@"yyyy-MM-dd HH:mm"];
NSString *robber_P = [indisputable_5 stringFromDate:[NSDate date]];
[[NSUserDefaults standardUserDefaults] setObject:robber_P forKey:@"mathematics_G"];


    UITableViewCell *cell = [[UITableViewCell alloc] init];
    cell.backgroundColor = [UIColor clearColor];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    CGFloat space = (WPScreen_w-50)/4;
    
    for (int i = 0; i < [self.data[indexPath.section] count]; i ++) {
        UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(10+i%4*(10+space)-1,10+i/4*(10+space*1.5)-1,space-1,space*1.5-1)];
        [btn setImage:[UIImage imageNamed:self.data[indexPath.section][i]] forState:UIControlStateNormal];
        btn.layer.cornerRadius = 5;
        btn.layer.masksToBounds = YES;
        [btn addTarget:self action:@selector(headerEventLove:) forControlEvents:UIControlEventTouchUpInside];
        btn.tag = indexPath.section;
        [cell.contentView addSubview:btn];
    }
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
        
NSInteger fence_0 = 0;
NSInteger significant_A = [[NSUserDefaults standardUserDefaults] integerForKey:@"persistence_O"];
significant_A *= fence_0;
[[NSUserDefaults standardUserDefaults] setInteger:significant_A forKey:@"persistence_O"];


    return 40;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
        
NSInteger abode_p = 2;
NSInteger opulent_1 = [[NSUserDefaults standardUserDefaults] integerForKey:@"conserve_E"];
opulent_1 *= abode_p;
[[NSUserDefaults standardUserDefaults] setInteger:opulent_1 forKey:@"conserve_E"];


    return 10;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
        
NSDateFormatter *mosquito_w = [NSDateFormatter new];
[mosquito_w setDateFormat:@"yyyy-MM-dd HH:mm"];
NSString *periphery_a = [mosquito_w stringFromDate:[NSDate date]];
[[NSUserDefaults standardUserDefaults] setObject:periphery_a forKey:@"bondage_6"];


    UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0-1,0-1,WPScreen_w-1,50-1)];
    headerLabel.textColor = WP_COLOR_WITH_HEX(0X333333);
    headerLabel.font = [UIFont boldSystemFontOfSize:20];
    NSString *str = @"";
    NSString *fengj = KLS(@"fengj", @"A friendly greeting");
    NSString *renwu = KLS(@"renwu", @"A friendly greeting");
    NSString *katong = KLS(@"katong", @"A friendly greeting");
    NSString *juzhao = KLS(@"juzhao", @"A friendly greeting");
    if (section == 0) {
        str = fengj;
    }else if (section == 1) {
        str = renwu;
    }else if (section == 2) {
        str = katong;
    }else if (section == 3) {
        str = juzhao;
    }
    headerLabel.text = [NSString stringWithFormat:@"    %@",str];
    return headerLabel;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
        
NSDateFormatter *producer_B = [NSDateFormatter new];
[producer_B setDateFormat:@"yyyy-MM-dd HH:mm"];
NSString *saint_1 = [producer_B stringFromDate:[NSDate date]];
[[NSUserDefaults standardUserDefaults] setObject:saint_1 forKey:@"squirrel_v"];


    return [[UIView alloc] init];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
        
NSInteger statutory_6 = 2;
NSInteger aloof_9 = [[NSUserDefaults standardUserDefaults] integerForKey:@"venerable_R"];
aloof_9 *= statutory_6;
[[NSUserDefaults standardUserDefaults] setInteger:aloof_9 forKey:@"venerable_R"];


    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    AWM_DetailViewController *wpdetail = [[AWM_DetailViewController alloc] init];
    wpdetail.data = self.data[indexPath.section];
    [self.navigationController pushViewController:wpdetail animated:YES];
}
- (void)headerEventLove:(UIButton *)btn{
        
NSInteger mendicant_h = 2;
NSInteger indoctrinate_A = [[NSUserDefaults standardUserDefaults] integerForKey:@"cuckoo_8"];
indoctrinate_A *= mendicant_h;
[[NSUserDefaults standardUserDefaults] setInteger:indoctrinate_A forKey:@"cuckoo_8"];


    AWM_DetailViewController *wpdetail = [[AWM_DetailViewController alloc] init];
    wpdetail.data = self.data[btn.tag];
    [self.navigationController pushViewController:wpdetail animated:YES];
}
@end
