package com.teebik.android.app;
import java.util.ArrayList;
import java.util.Date;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.Display;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.webkit.WebView;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.LinearLayout.LayoutParams;
import com.teebik.android.adapter.MyOrderListAdapter;
import com.teebik.android.adapter.RegionAdapter;
import com.teebik.android.utils.LineEditText;
import com.teebik.android.utils.TeebikStaticData;
import com.teebik.android.utils.TimeLeftSurfaceview;
import com.teebik.android.vo.AddressBookVO;
import com.teebik.android.vo.ConfirmOrderVO;
import com.teebik.android.vo.DealVO;
import com.teebik.android.vo.IdVO;
public class MainActivity extends ActivityFather {
int titleBarHeight ;//顶部标题高度
int screenWidth;//屏幕宽度
int screenHeight;//屏幕高度
LinearLayout todaydealMenu;//底部菜单按钮today's deals
ImageView todaydealimg;//底部菜单图片
LinearLayout myOrdersMenu;//底部菜单 mydeals
ImageView myordersimg;//底部菜单图片
LinearLayout settingsMenu;//底部菜单settings
ImageView settingsimg;//底部菜单图片
LinearLayout bodyLayout;//主题显示布局
LinearLayout menuLayout;//地步菜单总布局
LinearLayout addbodyLayout;//用于移除
Bitmap todaydealBitmap = null;//底部菜单图片
Bitmap todaydealdownBitmap = null; //底部菜单图片
Bitmap myorderBitmap = null; //底部菜单图片
Bitmap myorderdownBitmap = null;//底部菜单图片
Bitmap settingsBitmap = null; //底部菜单图片
Bitmap settingsdownBitmap = null; //底部菜单图片
Bitmap checkboximg = null; //底部菜单图片
// TimeLeftView timeView;//倒计时
TimeLeftSurfaceview timeView;
RelativeLayout bodytitlemain;//标题记时
RelativeLayout bodytimerLayout;//倒计时布局
RelativeLayout highlightsRelative;//
RelativeLayout dealLayout;
TextView dealTitle;//deal信息
TextView soldCount;//
TextView value;//
TextView discount;//
TextView saving;//
TextView valueduty;//
TextView discountduty;//
TextView savingduty;//
TextView dollars;//团购价格
TextView highlightsbtn;//
TextView fineprintbtn;//
TextView countryText;
Button sharebtn;//共享deal按钮
ImageView dealimg;//deal图片显示
ImageView checkbuy;
WebView webview;
ProgressDialog mDialog;//进度条
Button countryBtn;
Button dealsbtn;
Button buybtn;
DealVO dealVO;//当前显示 deal
LinearLayout myorderListLayout;//myorders布局
ListView myorderlistview;
MyOrderListAdapter myorderListAdapter;//
LinearLayout myorderbodyLayout;
LinearLayout settingsignoutLay;//注销布局
ImageView settingArrow;
TextView arrowtext;
RelativeLayout confirmLayouts;//定单提交
LinearLayout safeinfoLayout;
ImageView safelock;
TextView safeinfoText;//安全信息
private Bitmap safelockBitmap = null;//安全锁
TextView confirmChengH;
TextView confirmJiaH;
ImageView Radiotop;
Button confirmOrderbtn;
ImageView Radiobottom;
Bitmap radiobuttonno;
Bitmap radiobuttonyes;
TextView purchaseCountry;
TextView payInfojt;
LinearLayout confirmbody;
LinearLayout confirmbodyvalue;
RelativeLayout creitcardRelat;
TextView paymenttypText;
LinearLayout addcreditcard;
boolean deallistViewT = false;
LinearLayout confirmaddressLayout;
RelativeLayout jumptocreatcadbtn;
Button adresscancelbtn;
Button cardCanlcelbtn;
Button creataddress;
TextView SignoutUserValue;
TextView SignoutCreditsvalue;
Button SignoutBtn;
TextView ConfirmDealInfo;
EditText dealquantityvalue;
TextView confirmPriceValue;
TextView DealTotalvalue;
ListView addressList;
Bitmap imagecancel;
Button savebtn;
Button deletebtn;
BaseAdapter addresslistAdapter;
TextView creitcardtext;
TextView creitcardtext2;
Spinner countryidSpinner;
Spinner regionidSpinner;
RegionAdapter regionadapter;
String conuntryID;
String regionID;
boolean paresjson;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WindowManager windowManager = getWindowManager();
Display display = windowManager.getDefaultDisplay();
screenWidth = display.getWidth(); //屏幕宽度
screenHeight = display.getHeight();//屏幕高度
initDialog();//初始化弹出窗口
bodyLayout = (LinearLayout) findViewById(R.id.bodyLayout);
menuLayout = (LinearLayout) findViewById(R.id.menuLayout);
addbodyLayout = (LinearLayout) findViewById(R.id.addbodyLayout);
bodytitlemain = (RelativeLayout) findViewById(R.id.bodytitlemain);
bodytimerLayout = (RelativeLayout) findViewById(R.id.bodytimerLayout);
dealLayout = (RelativeLayout) findViewById(R.id.dealRelative);
sharebtn = (Button)findViewById(R.id.sharebtn);
dealTitle = (TextView) findViewById(R.id.dealTitle);
dollars = (TextView) findViewById(R.id.dollars);
highlightsbtn = (TextView) findViewById(R.id.highlightsbtn);
fineprintbtn = (TextView) findViewById(R.id.fineprintbtn);
soldCount = (TextView) findViewById(R.id.soldcount);
value = (TextView) findViewById(R.id.value);
discount = (TextView) findViewById(R.id.discount);
saving = (TextView) findViewById(R.id.saving);
valueduty = (TextView) findViewById(R.id.valueduty);
discountduty = (TextView) findViewById(R.id.discountduty);
savingduty = (TextView) findViewById(R.id.savingduty);
dealimg = (ImageView) findViewById(R.id.dealimg);
checkbuy = (ImageView) findViewById(R.id.checkboximg);
webview = (WebView)findViewById(R.id.webview);
countryBtn = (Button)findViewById(R.id.countrybtn);
dealsbtn = (Button)findViewById(R.id.dealsbtn);
countryText = (TextView)findViewById(R.id.countriyTextView);
buybtn = (Button)findViewById(R.id.buybtn);
myorderListLayout = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.myorderlist,null);
settingsignoutLay = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.settingsignout,null);
confirmLayouts = (RelativeLayout) LayoutInflater.from(this).inflate(R.layout.confirmoreder,null);
addcreditcard = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.addcreditcard,null);
confirmaddressLayout = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.confirmaddress,null);
/*************************************************** 初始化数据*******************************************************/
if(getLocalIpAddress()!=null){
mDialog.show();
new Thread() {
public void run() {
try {
// wakelock = getWakeLock(MainActivity.this);
// wakelock.acquire();
paresjson = parseJson(TeebikStaticData.dealBean, gethttpJsonString((TeebikStaticData.dealsUrl).replace("Country",getinitCountriey() )));
if(paresjson&&deallist.size()>0){
Message message = new Message();