//
//  AWM_wallpaperViewController.m

#import "AWM_wallpaperViewController.h"
#import "AWM_DetailViewController.h"
#import "AppDelegate.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_wallpaperViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) UITableView *table;
@property (nonatomic,strong) NSMutableArray *data;
@property(nonatomic,strong)UIButton *backItem;
@property(nonatomic,strong)UIImageView *navImage;

@end

@implementation AWM_wallpaperViewController
- (void)backItemEventLove:(id)sender{
        
NSDateFormatter *savant_9 = [NSDateFormatter new];
[savant_9 setDateFormat:@"yyyy-MM-dd HH:mm"];
NSString *hemophilia_i = [savant_9 stringFromDate:[NSDate date]];
[[NSUserDefaults standardUserDefaults] setObject:hemophilia_i forKey:@"pillory_G"];


    __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 wonderful_I = 5;
NSInteger formula_6 = [[NSUserDefaults standardUserDefaults] integerForKey:@"pavement_9"];
formula_6 *= wonderful_I;
[[NSUserDefaults standardUserDefaults] setInteger:formula_6 forKey:@"pavement_9"];


    [super viewWillAppear:animated];
    [self.navigationController.navigationBar addSubview:self.backItem];
    [self.navigationController.navigationBar addSubview:self.navImage];
}
- (void)viewWillDisappear:(BOOL)animated{
        
NSInteger tardy_A = 9;
NSInteger impertinent_4 = [[NSUserDefaults standardUserDefaults] integerForKey:@"native_9"];
impertinent_4 *= tardy_A;
[[NSUserDefaults standardUserDefaults] setInteger:impertinent_4 forKey:@"native_9"];


    [super viewWillDisappear:animated];
    [self.backItem removeFromSuperview];
    [self.navImage removeFromSuperview];
}
- (instancetype)init
{
    self = [super init];
    if (self) {
        self.hidesBottomBarWhenPushed = YES;
    }
    return self;
}
- (void)viewDidLoad {
        
NSDateFormatter *outnumbered_u = [NSDateFormatter new];
[outnumbered_u setDateFormat:@"yyyy-MM-dd HH:mm"];
NSString *sincerity_5 = [outnumbered_u stringFromDate:[NSDate date]];
[[NSUserDefaults standardUserDefaults] setObject:sincerity_5 forKey:@"sediment_m"];


    [super viewDidLoad];
    self.title = @"";
    self.navigationItem.hidesBackButton = YES;

    AppDelegate *app = (AppDelegate *)[[UIApplication  sharedApplication] delegate];
    self.data = app.saveImages;
    UIImageView *bgImage = [[UIImageView alloc] initWithFrame:self.view.bounds];
    NSString *greeting = KLS(@"bg", @"A friendly greeting");
    bgImage.image = [UIImage imageNamed:greeting];
    bgImage.userInteractionEnabled = YES;
    [self.view addSubview:bgImage];
    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;
    NSString *greeting3 = KLS(@"navmy", @"A friendly greeting");
    UIImageView *navImage = [[UIImageView alloc] initWithFrame:CGRectMake(WPScreen_w-150-1,8-1,130-1,28-1)];
    navImage.image = [UIImage imageNamed:greeting3];
    self.navImage = navImage;
    
    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{
        
NSInteger subjection_4 = 7;
NSInteger scope_B = [[NSUserDefaults standardUserDefaults] integerForKey:@"curfew_p"];
scope_B *= subjection_4;
[[NSUserDefaults standardUserDefaults] setInteger:scope_B forKey:@"curfew_p"];


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


    return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
        
NSDateFormatter *imbroglio_i = [NSDateFormatter new];
[imbroglio_i setDateFormat:@"yyyy-MM-dd HH:mm"];
NSString *corridor_j = [imbroglio_i stringFromDate:[NSDate date]];
[[NSUserDefaults standardUserDefaults] setObject:corridor_j forKey:@"wallet_1"];


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


    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 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[i]] forState:UIControlStateNormal];
        btn.layer.cornerRadius = 5;
        btn.layer.masksToBounds = YES;
        [btn addTarget:self action:@selector(headerEventLove:) forControlEvents:UIControlEventTouchUpInside];
        [cell.contentView addSubview:btn];
    }
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
        
NSDateFormatter *remonstrate_K = [NSDateFormatter new];
[remonstrate_K setDateFormat:@"yyyy-MM-dd HH:mm"];
NSString *protracted_H = [remonstrate_K stringFromDate:[NSDate date]];
[[NSUserDefaults standardUserDefaults] setObject:protracted_H forKey:@"plumb_t"];


    return 40;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
        
NSInteger restorative_d = 5;
NSInteger mythical_T = [[NSUserDefaults standardUserDefaults] integerForKey:@"ulcer_P"];
mythical_T *= restorative_d;
[[NSUserDefaults standardUserDefaults] setInteger:mythical_T forKey:@"ulcer_P"];


    return 10;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
        
NSInteger sexual_L = 5;
NSInteger radar_T = [[NSUserDefaults standardUserDefaults] integerForKey:@"purse_y"];
radar_T *= sexual_L;
[[NSUserDefaults standardUserDefaults] setInteger:radar_T forKey:@"purse_y"];


    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];
    headerLabel.text = [NSString stringWithFormat:@"    %@",@"保存的壁纸"];
    return headerLabel;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
        
NSInteger motorcycle_3 = 7;
NSInteger discovery_3 = [[NSUserDefaults standardUserDefaults] integerForKey:@"dehumanize_U"];
discovery_3 *= motorcycle_3;
[[NSUserDefaults standardUserDefaults] setInteger:discovery_3 forKey:@"dehumanize_U"];


    return [[UIView alloc] init];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
        
NSInteger farrow_2 = 9;
NSInteger impenetrable_S = [[NSUserDefaults standardUserDefaults] integerForKey:@"afloat_X"];
impenetrable_S *= farrow_2;
[[NSUserDefaults standardUserDefaults] setInteger:impenetrable_S forKey:@"afloat_X"];


    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    AWM_DetailViewController *wpdetail = [[AWM_DetailViewController alloc] init];
    wpdetail.data = self.data;
    [self.navigationController pushViewController:wpdetail animated:YES];
}
- (void)headerEventLove:(id)sender{
        
NSDateFormatter *disaffected_p = [NSDateFormatter new];
[disaffected_p setDateFormat:@"yyyy-MM-dd HH:mm"];
NSString *consign_D = [disaffected_p stringFromDate:[NSDate date]];
[[NSUserDefaults standardUserDefaults] setObject:consign_D forKey:@"intelligence_v"];


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