package com.bn.summer;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.view.MenuItem.OnMenuItemClickListener;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.CompoundButton.OnCheckedChangeListener;
import static com.bn.summer.Constant.*;
enum WhichView {MAIN_VIEW,//主界面
LOGIN_VIEW,//登录界面
REGISTER_VIEW,//注册斤面
USERINFO_VIEW,//显示用户信息的界面,也可以
ALLRESOURCE_VIEW,//显示所有资源的界面
RESOURCEDETAIL_VIEW,//显示所选资源详细信息的界面
ORDERLIST_VIEW,//显示当前用户所有订单的界面
ORDERDETAIL_VIEW,//订单详情的界面
KEFANG_VIEW,//显示客房资源的界面
MEETINGROOM_VIEW,//显示会议室资源的界面
WELCOME_VIEW,
GY_VIEW,
HELP_VIEW
}
public class MainActivity extends Activity {
Handler hd;
WhichView curr;
WelcomeView wv;
String[] gNameAndgDetail;//分组资源名数组
String[] userInfoArray;//用户信息数组
String[] listArray;//订单列表数组
String[] orderDetail;//订单详情数组
String[] msgOrder;
String[] resourceNameArray;
String rgid;//资源编号
String msgscale="";
String msgscalemeeting="";
String sex="女";
Dialog dateInputDialog;//时间对话框1
Dialog dateInputDialog1;//时间对话框2
Dialog exitDialog;
int[] drawableIds={R.drawable.room,R.drawable.meeting};//客房和会议室的数组
int[] kfmsg2={R.string.drbj,R.string.srbj,R.string.drgbj,R.string.srgbj};//客房规格
int[] hysmsg={R.string.sr,R.string.swr,R.string.eswr,R.string.ss,R.string.bs,R.string.yb,R.string.ybes};//会议室规格
final int MENU_OK=5;
final int GENDER_GROUP=0; //性别子菜单项组的编号
MenuItem[] miaHobby=new MenuItem[3];//爱好菜单项组
MenuItem male=null;//男性性别菜单
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//设置全屏显示
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags
(
WindowManager.LayoutParams.FLAG_FULLSCREEN ,
WindowManager.LayoutParams.FLAG_FULLSCREEN
);
//强制为横屏
//this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
//强制为竖屏
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
//gotoLoginView();
gotoWelcomeView();
//创建消息处理器对象
hd=new Handler()
{
@Override
public void handleMessage(Message msg)
{
//调用父类处理
super.handleMessage(msg);
//获取消息中的数据
Bundle b;
b=msg.getData();
//获取内容字符串
String msgStr=b.getString("msg");
//根据消息what编号的不同,执行不同的业务逻辑
switch(msg.what)
{
case Constant.GOTOLOGIN:
gotoLoginView();
break;
//将消息中的内容提取出来显示在EditText中
case Constant.LOGINVIEW:
if(msgStr.equals("登录成功"))
{
Toast.makeText(MainActivity.this, "登录成功!", Toast.LENGTH_SHORT).show();
gotoMainView();
}
else
{
Toast.makeText(MainActivity.this, "登录失败", Toast.LENGTH_SHORT).show();
}
break;
/*case Constant.CHANGE_EDIT2:
//获取消息中的数据
b=msg.getData();
//获取内容字符串
msgStr=b.getString("msg");
Toast.makeText(MainActivity.this, msgStr, Toast.LENGTH_SHORT).show();
if(msgStr.equals("注册成功,请输入用户名和密码以登录!"))//如果从jsp得到的字符串为登录成功,则转到首页
{
gotoLoginView();
}
break;*/
case Constant.MAINVIEW:
//获取消息中的数据
b=msg.getData();
//获取内容字符串
msgStr=b.getString("msg");
gNameAndgDetail=msgStr.split("\\|");
TextView maintv1=(TextView)findViewById(R.id.mainTextView01);
maintv1.setText(gNameAndgDetail[0]);
TextView maintv2=(TextView)findViewById(R.id.mainTextView02);
maintv2.setText(gNameAndgDetail[1]);
TextView maintv3=(TextView)findViewById(R.id.mainTextView03);
maintv3.setText(gNameAndgDetail[2]);
TextView maintv4=(TextView)findViewById(R.id.mainTextView04);
maintv4.setText(gNameAndgDetail[3]);
break;
case Constant.KFVIEW:
b=msg.getData();
msgStr=b.getString("msg");
//initListView1(msgStr);
initListViewf(msgStr,Constant.RESOURCEDIVIDEDBYGROUPLISTVIEW01);
break;
case Constant.MEETINTVIEW:
b=msg.getData();
msgStr=b.getString("msg");
Toast.makeText(MainActivity.this, msgStr,Toast.LENGTH_SHORT);
//initListView11(msgStr);
initListViewf(msgStr,Constant.RESOURCEDIVIDEDBYGROUP1LISTVIEW01);
break;
case Constant.RESOURCEDETAIL:
b=msg.getData();
msgStr=b.getString("msg");
msgOrder=msgStr.split("\\|");
TextView tv2=(TextView)findViewById(R.id.resourcedetailTextView02);
tv2.setText(msgOrder[0]);
TextView tv3=(TextView)findViewById(R.id.resourcedetailTextView03);
tv3.setText(msgOrder[1]);
break;
case Constant.ALLRESOURCE:
b=msg.getData();
msgStr=b.getString("msg");
//initListView3(msgStr);
initListViewf(msgStr,Constant.ALLRESOURCELISTVIEW01);
break;
/*case Constant.CHANGE_EDIT6:
b=msg.getData();
msgStr=b.getString("msg");
Toast.makeText(MainActivity.this, msgStr, Toast.LENGTH_SHORT).show();
break;*/
case Constant.MODIFYINFO:
b=msg.getData();
//获取内容字符串
msgStr=b.getString("msg");
System.out.println(msgStr);
Toast.makeText(MainActivity.this, msgStr, Toast.LENGTH_SHORT).show();
gotoLoginView();
break;
case Constant.REGISTER:
//获取消息中的数据
b=msg.getData();
//获取内容字符串
msgStr=b.getString("msg");
Toast.makeText(MainActivity.this, msgStr, Toast.LENGTH_SHORT).show();
System.out.println(msgStr);
if(msgSt
- 1
- 2
- 3
- 4
前往页