package xxe.restrant.login.login;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeoutException;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import xxe.restrant.R;
import xxe.restrant.login.Logining;
import xxe.restrant.show.ActivityShowFood;
import xxe.restrant.show.LineAdapter;
import xxe.restrant.utils.FileService;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.DialogInterface.OnClickListener;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
/**
*
* @author /** 用户登录界面
*
*
*
*/
public class LoginActivity extends Activity {
//引用工具包下面的读写文件类 并实例化,用于读出文件中的IP
private FileService fileService = new FileService(
this);
private static final int LOGIN_DIALOG = 1;//登录对话框
private static final int DIALOG2 = 2;//加载进度框
private static final int DIALOG3 = 3; // 修改服务器IP对话框
private static final int DIALOG4 = 4;
private EditText etName, etPsw; //用户名和密码
private String editName;
private String editPwd;
EditText u_nameEditText ;//注册界面的用户名
EditText pwd1 ;//密码1
EditText pwd2 ;//密码2
String registerName ;
String registerPwd1;
String registerPwd2 ;
private String ip; //用户需要连接服务器的IP
private EditText hostip;
private String resultData;
/**
* onCreate方法
*/
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
showDialog(LOGIN_DIALOG); //显示对话框
}
/**
* 创建登录对话框
* @param context
* @return
*/
private Dialog createLoginDialog(Context context) {
View view = LayoutInflater.from(context).inflate(R.layout.login1, null); //引入登录xml界面文件
etName = (EditText) view.findViewById(R.id.et_userName); //用户名
etPsw = (EditText) view.findViewById(R.id.et_password); //密码
AlertDialog.Builder bulder = new AlertDialog.Builder(context);
bulder.setView(view);
bulder.setTitle("用户登录");//设置标题
bulder.setNeutralButton("设置IP或者注册", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
showDialog(DIALOG3);
}
});
//确定按钮
bulder.setPositiveButton("登录", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
editName = etName.getText().toString().trim();
editPwd = etPsw.getText().toString().trim();
if(editName.equals("")){//当用户名为空时
Toast.makeText(LoginActivity.this, "请输入用户名", Toast.LENGTH_LONG).show();
Intent intent = new Intent(
LoginActivity.this,
LoginActivity.class);
startActivity(intent);
}
if(editPwd.equals("")){//当密码为空时
Toast.makeText(LoginActivity.this, "请输入密码", Toast.LENGTH_LONG).show();
Intent intent = new Intent(
LoginActivity.this,
LoginActivity.class);
startActivity(intent);
}
else {
//showDialog(DIALOG2);
//调用连接后台登录接口并返回服务端的信息
String str= callLoginPost("http://"+fileService.read()+":8080/WebRestrant/LoginServlet?action=login");
//Toast.makeText(LoginActivity.this, ":"+str, Toast.LENGTH_SHORT).show();
if(str.equals("0")){
removeDialog(LOGIN_DIALOG);
showDialog("网络连接失败, 请检查网络是否可以或IP是否正确!");
}else{
if(!str.equals("")&&!str.equals("0")){
Intent intent = new Intent(LoginActivity.this, Logining.class);
String[] temp = str.split("#");
if(ActivityShowFood.map!=null){
for(int i=0; i<LineAdapter.data.size(); i++){
ActivityShowFood.mapNum.put((Integer)LineAdapter.data.get(i).get("id"), 1);
ActivityShowFood.map.put((Integer)LineAdapter.data.get(i).get("id"), false);
}
}
Bundle bundle =new Bundle();
bundle.putString("userName", temp[0]);
bundle.putString("userId", temp[1]);
intent.putExtra("UserLogin", bundle);
startActivity(intent);
//myDialog.dismiss();
}else{
Toast.makeText(LoginActivity.this, "用户名或密码错误请重试!", Toast.LENGTH_LONG).show();
Intent intent = new Intent(
LoginActivity.this,
LoginActivity.class);
startActivity(intent);
}
}
}
}
});
//取消按钮,退出登录界面
bulder.setNegativeButton("取消", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
setTitle("Exit");
//LoginActivity.this.finish();
finish();
}
});
return bulder.create();
}
/**
* 创建对话框
*/
@Override
protected Dialog onCreateDialog(int id) {
super.onCreateDialog(id);
switch (id) {
case LOGIN_DIALOG:
return createLoginDialog(this);
case DIALOG2:
return building2(this);
case DIALOG3:
return building3(this);
case DIALOG4:
return building4(this);
}
return null;
}
private Dialog building4(LoginActivity loginActivity) {
View view = LayoutInflater.from(loginActivity).inflate(R.layout.login2, null); //引入登录xml界面文件
u_nameEditText = (EditText) view.findViewById(R.id.r_userName); //用户名
pwd1 = (EditText) view.findViewById(R.id.r_password); //密码
pwd2 = (EditText) view.findViewById(R.id.rr_password); //密码
AlertDialog.Builder bulder = new AlertDialog.Builder(loginActivity);
bulder.setView(view);
bulder.setTitle("用户注册");//设置标题
//确定按钮
bulder.setPositiveButton("注册", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
registerName = u_nameEditText.getText().toString();
registerPwd1 = pwd1.getText().toString();
registerPwd2 = pwd2.getText().toString();
if(registerName.equals("")){//当用户名为空时
removeDialog(DIALOG4);// 空格+“/”:快捷键出来相关的函数
showDialog(DIALOG4);
Toast.makeText(LoginActivity.this, "请输入用户名", Toast.LENGTH_LONG).show();
}
if(registerPwd1.equals("")||registerPwd2.equals("")){//当密码为空时
removeDialog(DIALOG4);// 空格+“/”:快捷键出来相关的函数
showDialog(DIALOG4);
Toast.makeText(LoginActivity.this, "请输入密码", Toast.LENGTH_LONG).show();
}
else {
if(registerPwd1.equals(registerPwd2)){
String str = callRegister("http://"+fileService.read()+":8080/WebRestrant/LoginServlet?action=register");
Log.e("-----------","----------"+str);
if(!"".equals(str)){
Toast.makeText(LoginActivity.this, "恭喜你,注册成功!", Toast.LENGTH_LONG).show();
Intent intent = new Intent(
LoginActivity.this,
LoginActivity.class);
startActivity(intent);
}
else{
removeDialog(DIALOG4);// 空格+“/”:快捷键出来相关的函数
showDialog(DIALOG4);
Toast.makeText(LoginActivity.this, "注册失败,请重试!", Toast.LENGTH_LONG).show();
return ;
}}else{
removeDialog(DIALOG4)
没有合适的资源?快使用搜索试试~ 我知道了~
无线点餐系统android和servlet源代码
共213个文件
class:68个
java:33个
png:26个
4星 · 超过85%的资源 需积分: 11 134 下载量 75 浏览量
2013-03-06
10:40:34
上传
评论 2
收藏 3.93MB ZIP 举报
温馨提示
无线点餐系统,有android客户端和后台servlet。供大家一起共同分享学习。
资源推荐
资源详情
资源评论
收起资源包目录
无线点餐系统android和servlet源代码 (213个子文件)
resources.ap_ 498KB
AndroidRestrant.apk 528KB
ActivityShowFood.class 9KB
ShopCartAdd.class 9KB
LoginActivity.class 8KB
ActivityRecord.class 8KB
OrderAdd.class 5KB
LineAdapter.class 5KB
DownloadInfo.class 5KB
OrderAdd$1.class 4KB
RecordeServlet.class 4KB
LoginServlet.class 4KB
LoginActivity$2.class 4KB
ShopCartAdd$6.class 4KB
LoginView.class 4KB
ConsumeInfoServlet.class 3KB
DetailsActivity.class 3KB
R$id.class 3KB
LineAdapter$MyOnClickListener.class 3KB
ServletShow.class 3KB
LoginActivity$4.class 3KB
ActivityRecord$1.class 2KB
OrderInfoServlet.class 2KB
LoginView$SurfaceThread.class 2KB
ShopCartAdd$3.class 2KB
ActivityShowFood$3.class 2KB
DBUtil.class 2KB
ConsumeInfo.class 2KB
ActivityShowFood$4.class 2KB
ShopCartAdd$1.class 2KB
LoginActivity$7.class 2KB
ConsumeInfoServiceImpl.class 2KB
ShopCartAdd$4.class 2KB
OrderInfoServiceImpl.class 2KB
OrderInfo.class 2KB
Logining.class 2KB
DetailsActivity$1.class 1KB
FileService.class 1KB
LoginView$SurfaceCallBack.class 1KB
ActivityChosenFood.class 1KB
OrderInfo.class 1KB
LoginActivity$5.class 1KB
Food.class 1KB
ActivityShowFood$1.class 1KB
R$drawable.class 1KB
UserInfo.class 1KB
LoginActivity$3.class 1KB
LoginActivity$1.class 965B
LoginActivity$8.class 957B
LoginActivity$6.class 957B
ActivityShowFood$2.class 953B
LoginActivity$9.class 919B
R$layout.class 918B
ServiceConnection.class 892B
ShopCartAdd$7.class 871B
Food.class 837B
ShopCartAdd$2.class 806B
ShopCartAdd$5.class 793B
LoginView$DataLogin.class 738B
R.class 573B
R$color.class 528B
ActivityRestrant.class 517B
ConsumeInfo.class 512B
MyHolder.class 484B
Customer.class 426B
R$string.class 409B
R$style.class 408B
R$attr.class 322B
ConsumeInfoService.class 214B
OrderInfoService.class 206B
.classpath 589B
.classpath 280B
org.eclipse.wst.jsdt.ui.superType.container 49B
styles.css 1KB
Thumbs.db 123KB
classes.dex 56KB
tp009.gif 5KB
insider_cn.gif 2KB
link_cn.gif 2KB
dynamic_cn.gif 2KB
lcart_cn.gif 2KB
buy_cn.gif 1KB
detail_cn.gif 1KB
0.gif 575B
2.gif 574B
5.gif 563B
001.gif 129B
002.gif 65B
004.gif 59B
005.gif 57B
003.gif 52B
mysql-connector-java-5.1.6-bin.jar 687KB
mysql-connector-java-3.1.13-bin.jar 446KB
mysql-connector-java-3.1.13-bin.jar 446KB
LoginActivity.java 12KB
ShopCartAdd.java 10KB
R.java 8KB
ActivityShowFood.java 8KB
ActivityRecord.java 7KB
LineAdapter.java 7KB
共 213 条
- 1
- 2
- 3
战歌IT
- 粉丝: 122
- 资源: 2409
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Three.js介绍.zip
- Android14 CTS Verifier测试手册.pdf
- NC65 UAP65 流程开发 – 业务流 – 推单 详细笔记
- 两种计算CDF累加分布函数的Matlab程序,可以选择使用 .rar
- Windows操作系统介绍.zip
- 汉森的广义t分布的matlab程序(金融)cdf.zip
- Three.js介绍.zip0002
- 人工智能BBSO算法,MATLAB实现,很基本的人工智能算法,里面有很多源程序
- 高端大气科技互联网项目融资商业计划书产品公司品牌介绍PPT模板.pptx
- Sora AI文字生成视频实操教程、由给定的图片生成视频的教程说明书,祝你一臂之力 轻松上手Sora
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页