Compare commits

..

4 Commits

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 KiB

After

Width:  |  Height:  |  Size: 11 KiB

@ -19,9 +19,9 @@
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/activity_history.xml" value="0.22" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/activity_main.xml" value="0.1" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/activity_main2.xml" value="0.10235507246376811" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/activity_menu.xml" value="0.33" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/activity_menu.xml" value="0.25" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/activity_no_pick.xml" value="0.2" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/activity_sign_up.xml" value="0.10235507246376811" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/activity_sign_up.xml" value="0.22" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/activity_wait.xml" value="0.18" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/buttom.xml" value="0.10235507246376811" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/forget.xml" value="0.2630208333333333" />

@ -16,16 +16,16 @@
android:supportsRtl="true"
android:theme="@style/Theme.Logistics">
<activity
android:name=".ui.HistoryActivity"
android:name=".ui.HistoryUI"
android:exported="false" />
<activity
android:name=".ui.NoPickActivity"
android:name=".ui.SearchUI"
android:exported="false" />
<activity
android:name=".ui.MenuActivity"
android:exported="false" />
<activity
android:name=".ui.LoginActivity"
android:name=".ui.LoginUI"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@ -33,7 +33,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ui.SignUpActivity" />
<activity android:name=".ui.SignUpUI" />
<activity
android:name="com.journeyapps.barcodescanner.CaptureActivity"
android:screenOrientation="portrait"

@ -0,0 +1,90 @@
package com.example.logistics.ui;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.example.logistics.R;
import com.example.logistics.manager.goodManager;
public class FindUI extends Fragment implements View.OnClickListener{
private String TAG = "FindUI";
private Context mContext;
private Button mButton;
private EditText mPickUpCode;
private EditText mPhoneNum;
public FindUI(){
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Log.d(TAG, "onCreate");
View view = inflater.inflate(R.layout.my_fragment1,container,false);
mButton = (Button)view.findViewById(R.id.Sea_Button);
mPickUpCode = (EditText)view.findViewById(R.id.Sea_PickUpCode);
mPhoneNum = (EditText)view.findViewById(R.id.Sea_PhoneNum);
mButton.setOnClickListener(this);
mContext = getActivity();
return view;
}
@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.Sea_Button:
Log.d(TAG, "search");
search(v);
break;
}
}
public void search(View view){
new Thread(){
@Override
public void run(){
goodManager goodManager = new goodManager();
int msg = goodManager.search(mPickUpCode.getText().toString().trim(), mPhoneNum.getText().toString().trim(), getActivity());
Log.e("Main", "msg");
hand1.sendEmptyMessage(msg);
}
}.start();
}
@SuppressLint("HandlerLeak")
final Handler hand1 = new Handler(){
@Override
public void handleMessage(Message msg){
if(msg.what == 0){
Toast.makeText(mContext, "搜索失败", Toast.LENGTH_SHORT).show();
}else if(msg.what == 2){
Toast.makeText(mContext, "手机尾号错误", Toast.LENGTH_SHORT).show();
}else if(msg.what == 3){
Toast.makeText(mContext, "取件码不存在", Toast.LENGTH_SHORT).show();
}
}
};
}

@ -25,7 +25,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class HistoryActivity extends Activity implements OnItemClickListener, OnScrollListener, View.OnClickListener {
public class HistoryUI extends Activity implements OnItemClickListener, OnScrollListener, View.OnClickListener {
private String TAG = "HistoryActivity";
private ListView lv_history;
@ -111,7 +111,7 @@ public class HistoryActivity extends Activity implements OnItemClickListener, On
@Override
public void handleMessage(Message msg){
if(msg.what == 1){
simp_adapter=new SimpleAdapter(HistoryActivity.this, dataList, R.layout.item, new String[]{"pickupcode","time"}, new int[]{R.id.np_id,R.id.np_time});
simp_adapter=new SimpleAdapter(HistoryUI.this, dataList, R.layout.item, new String[]{"pickupcode","time"}, new int[]{R.id.np_id,R.id.np_time});
lv_history.setAdapter(simp_adapter);
}
}

@ -1,15 +1,12 @@
package com.example.logistics.ui;
import com.example.logistics.R;
import com.example.logistics.manager.goodManager;
import com.example.logistics.manager.operationManager;
import com.example.logistics.manager.userManager;
import com.example.logistics.entity.User;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
@ -20,11 +17,8 @@ import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import org.json.JSONException;
import org.json.JSONObject;
public class LoginActivity extends Activity {
public class LoginUI extends Activity {
private int islogin = 0;
private Button loginButton;
@ -50,9 +44,9 @@ public class LoginActivity extends Activity {
phonenumButton = (Button) this.findViewById(R.id.phonenum);
AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
AlertDialog.Builder builder = new AlertDialog.Builder(LoginUI.this);
View view2 = View.inflate(LoginActivity.this, R.layout.forget, null);
View view2 = View.inflate(LoginUI.this, R.layout.forget, null);
builder.setTitle("取件").setView(view2);
@ -76,7 +70,7 @@ public class LoginActivity extends Activity {
new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(LoginActivity.this, SignUpActivity.class);
Intent intent = new Intent(LoginUI.this, SignUpUI.class);
Log.d(TAG, "signup");
startActivity(intent);
}
@ -156,7 +150,7 @@ public class LoginActivity extends Activity {
hand1.sendEmptyMessage(msg);
if(msg == 1){
User owner = userManager.findUser(userName.getText().toString().trim());
Intent intent = new Intent(LoginActivity.this, MenuActivity.class);
Intent intent = new Intent(LoginUI.this, MenuActivity.class);
if(flag == 1){
intent.putExtra("user", userName.getText().toString().trim());
}else{
@ -190,9 +184,9 @@ public class LoginActivity extends Activity {
@Override
public void handleMessage(Message msg) {
if(msg.what == 0){
Toast.makeText(LoginActivity.this, "修改失败", Toast.LENGTH_SHORT).show();
Toast.makeText(LoginUI.this, "修改失败", Toast.LENGTH_SHORT).show();
}else if(msg.what == 1) {
Toast.makeText(LoginActivity.this, "修改成功", Toast.LENGTH_SHORT).show();
Toast.makeText(LoginUI.this, "修改成功", Toast.LENGTH_SHORT).show();
}
}
};

@ -17,6 +17,7 @@ import androidx.fragment.app.FragmentManager;
import com.example.logistics.R;
public class MenuActivity extends AppCompatActivity implements View.OnClickListener{
private LinearLayout ly_one,ly_two,ly_three;
private TextView mTextView1,mTextView2,mTextView3;
private TextView mTextNum1,mTextNum2,mTextNum3;
@ -29,6 +30,7 @@ public class MenuActivity extends AppCompatActivity implements View.OnClickListe
private String owner;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
@ -93,7 +95,7 @@ public class MenuActivity extends AppCompatActivity implements View.OnClickListe
mTextView1.setSelected(true);
mTextNum1.setVisibility(View.INVISIBLE);
if (mFrag1 == null) {
mFrag1 = new SearchUI();
mFrag1 = new FindUI();
transaction.add(R.id.fragment_container, mFrag1);
@ -120,7 +122,7 @@ public class MenuActivity extends AppCompatActivity implements View.OnClickListe
mTextView3.setSelected(true);
mTextNum3.setVisibility(View.INVISIBLE);
if (mFrag3 == null) {
mFrag3 = new MeUI();
mFrag3 = new SetUI();
Bundle bundle = new Bundle();
bundle.putString("user", owner);
mFrag3.setArguments(bundle);

@ -1,123 +0,0 @@
package com.example.logistics.ui;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;
import com.example.logistics.R;
import com.example.logistics.manager.goodManager;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class NoPickActivity extends Activity implements OnItemClickListener, OnScrollListener, View.OnClickListener {
private String TAG = "NoPickActivity";
private ListView lv_nopick;
private ArrayAdapter<String> arr_adapter;
private SimpleAdapter simp_adapter;
private String phonenum;
private List<Map<String, Object>> dataList;
private ImageButton sync_np;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_no_pick);
dataList=new ArrayList<Map<String,Object>>();
lv_nopick = (ListView) findViewById(R.id.lv_nopick);
sync_np = (ImageButton) findViewById(R.id.sync_np);
simp_adapter=new SimpleAdapter(this, dataList, R.layout.item, new String[]{"id","time"}, new int[]{R.id.np_id,R.id.np_time});
lv_nopick.setAdapter(simp_adapter);
lv_nopick.setOnItemClickListener(this);
lv_nopick.setOnScrollListener(this);
sync_np.setOnClickListener(this);
Intent intent = getIntent();
phonenum = intent.getStringExtra("user");
sync();
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// TODO Auto-generated method stub
String text=lv_nopick.getItemAtPosition(position)+"";
Toast.makeText(this, "position="+position+" text="+text, Toast.LENGTH_SHORT).show();
}
@Override
public void onClick(View v){
switch(v.getId()){
case R.id.sync_np:
sync();
Toast.makeText(this, "同步成功", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState){
// TODO Auto-generated method stub
switch(scrollState){
case SCROLL_STATE_FLING:
Log.i(TAG, "用户在手指离开屏幕之前,由于用力划了一下,试图仍依靠惯性继续滑动");
break;
case SCROLL_STATE_IDLE:
Log.i(TAG, "视图已经停止滑动");
break;
case SCROLL_STATE_TOUCH_SCROLL:
Log.i(TAG, "手指没有离开屏幕,视图正在滑动");
break;
default:
break;
}
}
@Override
public void onScroll(AbsListView view, int arg1, int arg2, int arg3){
// TODO Auto-generated method stub
}
public void sync(){
new Thread(){
@Override
public void run(){
goodManager goodManager = new goodManager();
dataList = goodManager.nopick(phonenum);
int msg = 1;
hand1.sendEmptyMessage(msg);
}
}.start();
}
@SuppressLint("HandlerLeak")
final Handler hand1 = new Handler(){
@Override
public void handleMessage(Message msg){
if(msg.what == 1){
simp_adapter=new SimpleAdapter(NoPickActivity.this, dataList, R.layout.item, new String[]{"id","time"}, new int[]{R.id.np_id,R.id.np_time});
lv_nopick.setAdapter(simp_adapter);
}
}
};
}

@ -246,9 +246,12 @@ public class PickUpUI extends Fragment implements View.OnClickListener{
boolean flag1 = operationManager.add(pickupcode, user);
boolean flag2 = goodManager.delete(pickupcode);
boolean flag = flag1 & flag2;
if (flag) {
msg = 1;
if (!flag1) {
msg = 2;
}
if(!flag2){
msg = 3;
}
hand1.sendEmptyMessage(msg);
@ -268,9 +271,9 @@ public class PickUpUI extends Fragment implements View.OnClickListener{
Toast.makeText(mContext, "加入队列成功", Toast.LENGTH_SHORT).show();
joinQueue();
}else if(msg.what == 2){
Toast.makeText(mContext, "手机号错误", Toast.LENGTH_SHORT).show();
Toast.makeText(mContext, "出库失败", Toast.LENGTH_SHORT).show();
}else if(msg.what == 3){
Toast.makeText(mContext, "取件码不存在", Toast.LENGTH_SHORT).show();
Toast.makeText(mContext, "保存记录失败", Toast.LENGTH_SHORT).show();
}
}
};

@ -1,64 +1,108 @@
package com.example.logistics.ui;
import android.annotation.SuppressLint;
import android.content.Context;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.example.logistics.R;
import com.example.logistics.manager.goodManager;
public class SearchUI extends Fragment implements View.OnClickListener{
private Context mContext;
private Button mButton;
private EditText mPickUpCode;
private EditText mPhoneNum;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class SearchUI extends Activity implements OnItemClickListener, OnScrollListener, View.OnClickListener {
private String TAG = "NoPickActivity";
private ListView lv_nopick;
private ArrayAdapter<String> arr_adapter;
private SimpleAdapter simp_adapter;
private String phonenum;
private List<Map<String, Object>> dataList;
private ImageButton sync_np;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_no_pick);
dataList=new ArrayList<Map<String,Object>>();
lv_nopick = (ListView) findViewById(R.id.lv_nopick);
sync_np = (ImageButton) findViewById(R.id.sync_np);
simp_adapter=new SimpleAdapter(this, dataList, R.layout.item, new String[]{"id","time"}, new int[]{R.id.np_id,R.id.np_time});
lv_nopick.setAdapter(simp_adapter);
lv_nopick.setOnItemClickListener(this);
lv_nopick.setOnScrollListener(this);
sync_np.setOnClickListener(this);
public SearchUI(){
Intent intent = getIntent();
phonenum = intent.getStringExtra("user");
sync();
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.my_fragment1,container,false);
mButton = (Button)view.findViewById(R.id.Sea_Button);
mPickUpCode = (EditText)view.findViewById(R.id.Sea_PickUpCode);
mPhoneNum = (EditText)view.findViewById(R.id.Sea_PhoneNum);
mButton.setOnClickListener(this);
mContext = getActivity();
return view;
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// TODO Auto-generated method stub
String text=lv_nopick.getItemAtPosition(position)+"";
Toast.makeText(this, "position="+position+" text="+text, Toast.LENGTH_SHORT).show();
}
@Override
public void onClick(View v) {
public void onClick(View v){
switch(v.getId()){
case R.id.Sea_Button:
search(v);
case R.id.sync_np:
sync();
Toast.makeText(this, "同步成功", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState){
// TODO Auto-generated method stub
switch(scrollState){
case SCROLL_STATE_FLING:
Log.i(TAG, "用户在手指离开屏幕之前,由于用力划了一下,试图仍依靠惯性继续滑动");
break;
case SCROLL_STATE_IDLE:
Log.i(TAG, "视图已经停止滑动");
break;
case SCROLL_STATE_TOUCH_SCROLL:
Log.i(TAG, "手指没有离开屏幕,视图正在滑动");
break;
default:
break;
}
}
public void search(View view){
@Override
public void onScroll(AbsListView view, int arg1, int arg2, int arg3){
// TODO Auto-generated method stub
}
public void sync(){
new Thread(){
@Override
public void run(){
goodManager goodManager = new goodManager();
int msg = goodManager.search(mPickUpCode.getText().toString().trim(), mPhoneNum.getText().toString().trim(), getActivity());
Log.e("Main", "msg");
dataList = goodManager.nopick(phonenum);
int msg = 1;
hand1.sendEmptyMessage(msg);
}
}.start();
@ -68,13 +112,12 @@ public class SearchUI extends Fragment implements View.OnClickListener{
final Handler hand1 = new Handler(){
@Override
public void handleMessage(Message msg){
if(msg.what == 0){
Toast.makeText(mContext, "搜索失败", Toast.LENGTH_SHORT).show();
}else if(msg.what == 2){
Toast.makeText(mContext, "手机尾号错误", Toast.LENGTH_SHORT).show();
}else if(msg.what == 3){
Toast.makeText(mContext, "取件码不存在", Toast.LENGTH_SHORT).show();
if(msg.what == 1){
simp_adapter=new SimpleAdapter(SearchUI.this, dataList, R.layout.item, new String[]{"id","time"}, new int[]{R.id.np_id,R.id.np_time});
lv_nopick.setAdapter(simp_adapter);
}
}
};
}

@ -15,14 +15,14 @@ import androidx.annotation.Nullable;
import com.example.logistics.R;
public class MeUI extends Fragment implements View.OnClickListener{
public class SetUI extends Fragment implements View.OnClickListener{
private LinearLayout ll_waiting;
private LinearLayout ll_history;
private LinearLayout ll_exit;
private Context mContext;
private String user;
public MeUI(){
public SetUI(){
}
@Nullable
@ -52,19 +52,19 @@ public class MeUI extends Fragment implements View.OnClickListener{
Intent intent;
switch(view.getId()){
case R.id.waiting:
intent = new Intent(mContext, NoPickActivity.class);
intent = new Intent(mContext, SearchUI.class);
intent.putExtra("user", user);
startActivity(intent);
break;
case R.id.history:
intent = new Intent(mContext, HistoryActivity.class);
intent = new Intent(mContext, HistoryUI.class);
intent.putExtra("user", user);
startActivity(intent);
break;
case R.id.exit:
Toast.makeText(mContext, "exit", Toast.LENGTH_SHORT).show();
intent = new Intent(mContext, LoginActivity.class);
intent = new Intent(mContext, LoginUI.class);
startActivity(intent);
getActivity().finish();
break;

@ -6,6 +6,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
@ -15,9 +16,13 @@ import com.example.logistics.R;
import com.example.logistics.manager.userManager;
import com.example.logistics.entity.User;
public class SignUpActivity extends Activity {
public class SignUpUI extends Activity {
private String TAG = "SignUpUI";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_up);
@ -28,17 +33,21 @@ public class SignUpActivity extends Activity {
new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d(TAG, "SignUp:onClick");
register(v);
}
}
);
// 返回登录按钮监听器
backLoginButton.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
// 跳转到登录界面
Intent intent = new Intent(SignUpActivity.this, LoginActivity.class);
Log.d(TAG, "BackLogin:onClick");
Intent intent = new Intent(SignUpUI.this, LoginUI.class);
startActivity(intent);
}
}
@ -47,6 +56,9 @@ public class SignUpActivity extends Activity {
}
public void register(View view){
Log.d(TAG, "register");
EditText userName = (EditText) this.findViewById(R.id.UserNameEdit);
EditText passWord = (EditText) this.findViewById(R.id.PassWordEdit);
EditText passWordAgain = (EditText) this.findViewById(R.id.PassWordAgainEdit);
@ -58,17 +70,34 @@ public class SignUpActivity extends Activity {
String strPhoneNumber = phone.getText().toString().trim();
if (strUserName.length() > 10) {
Toast.makeText(SignUpActivity.this, "用户名长度必须小于10", Toast.LENGTH_SHORT).show();
Log.d(TAG, "username out of length");
Toast.makeText(SignUpUI.this, "用户名长度必须小于10", Toast.LENGTH_SHORT).show();
} else if (strUserName.length() == 0) {
Toast.makeText(SignUpActivity.this, "用户名不能为空!", Toast.LENGTH_SHORT).show();
Log.d(TAG, "username is none");
Toast.makeText(SignUpUI.this, "用户名不能为空!", Toast.LENGTH_SHORT).show();
} else if (strPassWord.length() > 16) {
Toast.makeText(SignUpActivity.this, "密码长度必须小于16", Toast.LENGTH_SHORT).show();
Log.d(TAG, "password out of length");
Toast.makeText(SignUpUI.this, "密码长度必须小于16", Toast.LENGTH_SHORT).show();
} else if (strPassWord.length() == 0) {
Toast.makeText(SignUpActivity.this, "密码不能为空!", Toast.LENGTH_SHORT).show();
Log.d(TAG, "password is none");
Toast.makeText(SignUpUI.this, "密码不能为空!", Toast.LENGTH_SHORT).show();
} else if (!strPassWord.equals(strPassWordAgain)) {
Toast.makeText(SignUpActivity.this, "两次密码输入不一致!", Toast.LENGTH_SHORT).show();
Log.d(TAG, "password is not same");
Toast.makeText(SignUpUI.this, "两次密码输入不一致!", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(SignUpActivity.this, "注册成功!", Toast.LENGTH_SHORT).show();
Log.d(TAG, "register success");
Toast.makeText(SignUpUI.this, "注册成功!", Toast.LENGTH_SHORT).show();
User user = new User();
user.setUserName(strUserName);
@ -78,17 +107,27 @@ public class SignUpActivity extends Activity {
new Thread(){
@Override
public void run(){
Log.d(TAG, "register thread");
int msg = 0;
userManager userManager = new userManager();
User uu = userManager.findUser(user.getUserName());
if(uu != null){
Log.d(TAG, "have this account");
msg = 1; //have this account
}else{
Log.d(TAG, "have no this account");
boolean flag = userManager.register(user);
if(flag){
Log.d(TAG, "register success");
msg = 2;
}
}
hand.sendEmptyMessage(msg);
@ -100,14 +139,24 @@ public class SignUpActivity extends Activity {
@SuppressLint("HandlerLeak")
final Handler hand = new Handler(){
public void handleMessage(Message msg){
Log.d(TAG, "msg is:" + msg.toString());
if(msg.what == 0){
Toast.makeText(getApplicationContext(), "注册失败", Toast.LENGTH_SHORT).show();
}else if(msg.what == 1){
Toast.makeText(getApplicationContext(), "该账号已存在,请换一个注册", Toast.LENGTH_SHORT).show();
}else if(msg.what == 2){
Toast.makeText(getApplicationContext(), "注册成功", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(SignUpActivity.this, LoginActivity.class);
Intent intent = new Intent(SignUpUI.this, LoginUI.class);
startActivity(intent);
}
}
};

@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.logistics.ui.LoginActivity">
tools:context="com.example.logistics.ui.LoginUI">
<!--使用线性布局-->
<LinearLayout
android:id="@+id/linearLayout2"

@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.logistics.ui.SignUpActivity">
tools:context="com.example.logistics.ui.SignUpUI">
<!--使用线性布局-->
<LinearLayout

Loading…
Cancel
Save