package com.zhangda.lianliankan.onepiece;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashSet;
import com.admogo.AdMogoLayout;
import com.admogo.AdMogoListener;
import com.admogo.AdMogoManager;
import com.admogo.AdMogoTargeting;
import com.waps.AppConnect;
import com.waps.UpdatePointsNotifier;
import android.R.integer;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ContentValues;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
public class ImgListActivity extends Activity implements AdMogoListener,View.OnClickListener,
UpdatePointsNotifier{
private Button btn_img1;
private Button btn_img2;
private Button btn_img3;
private Button btn_img4;
private Button btn_img5;
private Button btn_img6;
private Button btn_img7;
private Button btn_img8;
private Button btn_img9;
private Button btn_img10;
private Button btn_img11;
private final String mogoID = "62fc639ec0f5412a8c9bafebf7b0be85";
public int jifen=0;
private SQLiteDatabase sqld;
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
AppConnect.getInstance(this).getPoints(this);
sqld =openDatabase();
int openmun=0;
int chengji=0;
Cursor cursor = sqld.rawQuery("SELECT sum(isopen),sum(chengji) FROM guan",null);
while (cursor.moveToNext()) {
openmun = cursor.getInt(0); //获取第一列的值,第一列的索引从0开始
chengji = cursor.getInt(1);//获取第二列的值
}
btn_img1 = (Button)this.findViewById(R.id.btn_img1);
btn_img1.setBackgroundResource(R.drawable.g1);
btn_img1.setEnabled(true);
btn_img1.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v)
{
Intent intent = new Intent(ImgListActivity.this,ImgInfoActivity.class);
intent.putExtra("bid", "1");
startActivity(intent);
}
});
btn_img2 = (Button)this.findViewById(R.id.btn_img2);
if(openmun>=12){
btn_img2.setBackgroundResource(R.drawable.g2);
btn_img2.setEnabled(true);
}else{
btn_img2.setBackgroundResource(R.drawable.gs2);
btn_img2.setEnabled(false);
}
btn_img2.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v)
{
Intent intent = new Intent(ImgListActivity.this,ImgInfoActivity.class);
intent.putExtra("bid", "2");
startActivity(intent);
}
});
btn_img3 = (Button)this.findViewById(R.id.btn_img3);
if(openmun>=24){
btn_img3.setBackgroundResource(R.drawable.g3);
btn_img3.setEnabled(true);
}else{
btn_img3.setBackgroundResource(R.drawable.gs3);
btn_img3.setEnabled(false);
}
btn_img3.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v)
{
Intent intent = new Intent(ImgListActivity.this,ImgInfoActivity.class);
intent.putExtra("bid", "3");
startActivity(intent);
}
});
btn_img4 = (Button)this.findViewById(R.id.btn_img4);
if(openmun>=36){
btn_img4.setBackgroundResource(R.drawable.g4);
btn_img4.setEnabled(true);
}else{
btn_img4.setBackgroundResource(R.drawable.gs4);
btn_img4.setEnabled(false);
}
btn_img4.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v)
{
Intent intent = new Intent(ImgListActivity.this,ImgInfoActivity.class);
intent.putExtra("bid", "4");
startActivity(intent);
}
});
btn_img5 = (Button)this.findViewById(R.id.btn_img5);
if(openmun>=48){
btn_img5.setBackgroundResource(R.drawable.g5);
btn_img5.setEnabled(true);
}else{
btn_img5.setBackgroundResource(R.drawable.gs5);
btn_img5.setEnabled(false);
}
btn_img5.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v)
{
Intent intent = new Intent(ImgListActivity.this,ImgInfoActivity.class);
intent.putExtra("bid", "5");
startActivity(intent);
}
});
btn_img6 = (Button)this.findViewById(R.id.btn_img6);
if(openmun>=60){
btn_img6.setBackgroundResource(R.drawable.g6);
btn_img6.setEnabled(true);
}else{
btn_img6.setBackgroundResource(R.drawable.gs6);
btn_img6.setEnabled(false);
}
btn_img6.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v)
{
Intent intent = new Intent(ImgListActivity.this,ImgInfoActivity.class);
intent.putExtra("bid", "6");
startActivity(intent);
}
});
btn_img7 = (Button)this.findViewById(R.id.btn_img7);
if(openmun>=72){
btn_img7.setBackgroundResource(R.drawable.g7);
btn_img7.setEnabled(true);
}else{
btn_img7.setBackgroundResource(R.drawable.gs7);
btn_img7.setEnabled(false);
}
btn_img7.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v)
{
Intent intent = new Intent(ImgListActivity.this,ImgInfoActivity.class);
intent.putExtra("bid", "7");
startActivity(intent);
}
});
btn_img8 = (Button)this.findViewById(R.id.btn_img8);
if(openmun>=84){
btn_img8.setBackgroundResource(R.drawable.g8);
btn_img8.setEnabled(true);
}else{
btn_img8.setBackgroundResource(R.drawable.gs8);
btn_img8.setEnabled(false);
}
btn_img8.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v)
{
Intent intent = new Intent(ImgListActivity.this,ImgInfoActivity.class);
intent.putExtra("bid", "8");
startActivity(intent);
}
});
btn_img9 = (Button)this.findViewById(R.id.btn_img9);
if(openmun>=12){
btn_img9.setBackgroundResource(R.drawable.g9);
btn_img9.setEnabled(true);
}else{
btn_img9.setBackgroundResource(R.drawable.gs9);
btn_img9.setEnabled(false);
}
btn_img9.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v)
{
if(jifen<100){
showDialog(jifen+"","100");
}else{
Intent intent = new Intent(ImgListActivity.this,ImgInfoActivity.class);
intent.putExtra("bid", "9");
startActivity(intent);
}
}
});
btn_img10 = (Button)this.findViewById(R.id.btn_img10);
if(openmun>=12){
btn_img10.setBackgroundResource(R.drawable.g10);
btn_img10.setEnabled(true);
}else{
btn_img10.setBackgroundResource(R.drawable.gs10);
btn_img10.setEnabled(false);
}
btn_img10.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v)
{
if(jifen<200){
showDialog(jifen+"","200");
}else{
Intent intent = new Intent(ImgListActivity.this,ImgInfoActivity.class);
intent.putExtra("bid", "10");
startActivity(intent);
}
}
});
btn_img11 = (Button)this.findViewById(R.id.btn_img11);
if(openmun>=12){
btn_img11.setBackgroundResource(R.drawable.g11);
btn_img11.setEnabled(true);
}else{
btn_img11.setBackgroundResource(R.drawable.gs11);
btn_img11