Skip to content

Commit

Permalink
Merge pull request #16 from B515/WildHunter
Browse files Browse the repository at this point in the history
Wild hunter
  • Loading branch information
WHHunter authored Sep 2, 2017
2 parents c5387af + 2b6fc8b commit 05a58b3
Show file tree
Hide file tree
Showing 16 changed files with 343 additions and 203 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import android.os.Looper;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.telephony.TelephonyManager;
import android.widget.TextView;

import java.io.IOException;
Expand Down Expand Up @@ -37,7 +36,7 @@ public void handleMessage(Message msg) {
if (msg.what == 1) {
String[] userInfo = msg.obj.toString().split("&");
tvTP.setText(userInfo[7] + "TP");
tvCP.setText("信用积分" + userInfo[8]);
tvCP.setText("信用积分" + userInfo[8]);
}
}
};
Expand All @@ -46,15 +45,14 @@ public void handleMessage(Message msg) {
//从网络获取用户个人信息
private void getInfo() {
String id = UserInfoManager.getID(BalanceActivity.this);
TelephonyManager TelephonyMgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
String imei = TelephonyMgr.getDeviceId();
String session = UserInfoManager.getSession(BalanceActivity.this);
String path = "http://www.chronoswap.cn/userinfo_get.php";
//创建okHttpClient对象
OkHttpClient ohc = new OkHttpClient();
//表单数据
RequestBody fb = new FormBody.Builder()
.add("userid", id)
.add("session", imei)
.add("session", session)
.build();
//创建一个Request
Request req = new Request.Builder()
Expand Down
105 changes: 36 additions & 69 deletions app/src/main/java/cn/chronoswap/chronoswap/UI/InfoActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import android.os.Looper;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.telephony.TelephonyManager;
import android.text.InputType;
import android.view.View;
import android.widget.DatePicker;
Expand Down Expand Up @@ -47,68 +46,24 @@ protected void onCreate(Bundle savedInstanceState) {
tvUni = (TextView) findViewById(R.id.info_tv_uni);
tvSID = (TextView) findViewById(R.id.info_tv_stu_id);
tvPhong = (TextView) findViewById(R.id.info_tv_phong);
getInfo();
mHandler = new Handler(Looper.getMainLooper()) {
@Override
public void handleMessage(Message msg) {
if (msg.what == 1) {
String[] userInfo = msg.obj.toString().split("&");
tvID.setText(userInfo[0]);
tvNickname.setText(userInfo[6]);
tvGender.setText(userInfo[1]);
tvBirthday.setText(userInfo[2]);
tvUni.setText(userInfo[3]);
tvSID.setText(userInfo[4]);
tvPhong.setText(userInfo[5]);
}
}
};
InfoIni();
}

//从网络获取用户个人信息
private void getInfo() {
String id = UserInfoManager.getID(InfoActivity.this);
TelephonyManager TelephonyMgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
String imei = TelephonyMgr.getDeviceId();
String path = "http://www.chronoswap.cn/userinfo_get.php";
//创建okHttpClient对象
OkHttpClient ohc = new OkHttpClient();
//表单数据
RequestBody fb = new FormBody.Builder()
.add("userid", id)
.add("session", imei)
.build();
//创建一个Request
Request req = new Request.Builder()
.url(path)
.post(fb)
.build();
Call call = ohc.newCall(req);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}

@Override
public void onResponse(Call call, Response response) throws IOException {
String text = response.body().string();
Message msg = new Message();
if (text == null) {
msg.what = 0;
} else {
msg.what = 1;
msg.obj = text;
}
mHandler.sendMessage(msg);
}
});
//获取用户个人信息
private void InfoIni() {
tvID.setText(UserInfoManager.getID(InfoActivity.this));
tvNickname.setText(UserInfoManager.getNickname(InfoActivity.this));
tvGender.setText(UserInfoManager.getGender(InfoActivity.this));
tvBirthday.setText(UserInfoManager.getBirthday(InfoActivity.this));
tvUni.setText(UserInfoManager.getUniversity(InfoActivity.this));
tvSID.setText(UserInfoManager.getStudentID(InfoActivity.this));
tvPhong.setText(UserInfoManager.getPhoneNumber(InfoActivity.this));
}

//更改用户个人信息
private void setInfo(int what, String obj) {
String id = UserInfoManager.getID(InfoActivity.this);
TelephonyManager TelephonyMgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
String imei = TelephonyMgr.getDeviceId();
String session = UserInfoManager.getSession(InfoActivity.this);
String path = "";
String name = "";
switch (what) {
Expand Down Expand Up @@ -143,7 +98,7 @@ private void setInfo(int what, String obj) {
RequestBody fb = new FormBody.Builder()
.add("userid", id)
.add(name, obj)
.add("session", imei)
.add("session", session)
.build();
//创建一个Request
Request req = new Request.Builder()
Expand Down Expand Up @@ -182,12 +137,14 @@ public void onClick(DialogInterface dialog, int which) {
public void handleMessage(Message msg) {
if (msg.obj.toString().charAt(0) == '1') {
tvGender.setText(str);
UserInfoManager.setGender(InfoActivity.this, str);
Toast.makeText(InfoActivity.this, "修改成功", Toast.LENGTH_SHORT).show();
}else if (msg.obj.toString().charAt(0) == '0'){
} else if (msg.obj.toString().charAt(0) == '0') {
Toast.makeText(InfoActivity.this, "会话过期,请重新登录", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(InfoActivity.this, LoginActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}else Toast.makeText(InfoActivity.this, msg.obj.toString(), Toast.LENGTH_SHORT).show();
} else
Toast.makeText(InfoActivity.this, msg.obj.toString(), Toast.LENGTH_SHORT).show();
}
};
dialog.dismiss();
Expand All @@ -213,12 +170,14 @@ public void onClick(DialogInterface dialog, int which) {
public void handleMessage(Message msg) {
if (msg.obj.toString().charAt(0) == '1') {
tvNickname.setText(str);
UserInfoManager.setNickname(InfoActivity.this, str);
Toast.makeText(InfoActivity.this, "修改成功", Toast.LENGTH_SHORT).show();
}else if (msg.obj.toString().charAt(0) == '0'){
} else if (msg.obj.toString().charAt(0) == '0') {
Toast.makeText(InfoActivity.this, "会话过期,请重新登录", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(InfoActivity.this, LoginActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}else Toast.makeText(InfoActivity.this, msg.obj.toString(), Toast.LENGTH_SHORT).show();
} else
Toast.makeText(InfoActivity.this, msg.obj.toString(), Toast.LENGTH_SHORT).show();
}
};
}
Expand All @@ -240,12 +199,14 @@ public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth
public void handleMessage(Message msg) {
if (msg.obj.toString().charAt(0) == '1') {
tvBirthday.setText(str);
UserInfoManager.setBirthday(InfoActivity.this, str);
Toast.makeText(InfoActivity.this, "修改成功", Toast.LENGTH_SHORT).show();
}else if (msg.obj.toString().charAt(0) == '0'){
} else if (msg.obj.toString().charAt(0) == '0') {
Toast.makeText(InfoActivity.this, "会话过期,请重新登录", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(InfoActivity.this, LoginActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}else Toast.makeText(InfoActivity.this, msg.obj.toString(), Toast.LENGTH_SHORT).show();
} else
Toast.makeText(InfoActivity.this, msg.obj.toString(), Toast.LENGTH_SHORT).show();
}
};
}
Expand All @@ -272,12 +233,14 @@ public void onClick(DialogInterface dialog, int which) {
public void handleMessage(Message msg) {
if (msg.obj.toString().charAt(0) == '1') {
tvUni.setText(str);
UserInfoManager.setUniversity(InfoActivity.this, str);
Toast.makeText(InfoActivity.this, "修改成功", Toast.LENGTH_SHORT).show();
}else if (msg.obj.toString().charAt(0) == '0'){
} else if (msg.obj.toString().charAt(0) == '0') {
Toast.makeText(InfoActivity.this, "会话过期,请重新登录", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(InfoActivity.this, LoginActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}else Toast.makeText(InfoActivity.this, msg.obj.toString(), Toast.LENGTH_SHORT).show();
} else
Toast.makeText(InfoActivity.this, msg.obj.toString(), Toast.LENGTH_SHORT).show();
}
};
}
Expand All @@ -302,12 +265,14 @@ public void onClick(DialogInterface dialog, int which) {
public void handleMessage(Message msg) {
if (msg.obj.toString().charAt(0) == '1') {
tvSID.setText(str);
UserInfoManager.setStudentID(InfoActivity.this, str);
Toast.makeText(InfoActivity.this, "修改成功", Toast.LENGTH_SHORT).show();
}else if (msg.obj.toString().charAt(0) == '0'){
} else if (msg.obj.toString().charAt(0) == '0') {
Toast.makeText(InfoActivity.this, "会话过期,请重新登录", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(InfoActivity.this, LoginActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}else Toast.makeText(InfoActivity.this, msg.obj.toString(), Toast.LENGTH_SHORT).show();
} else
Toast.makeText(InfoActivity.this, msg.obj.toString(), Toast.LENGTH_SHORT).show();
}
};
}
Expand All @@ -332,12 +297,14 @@ public void onClick(DialogInterface dialog, int which) {
public void handleMessage(Message msg) {
if (msg.obj.toString().charAt(0) == '1') {
tvPhong.setText(str);
UserInfoManager.setPhoneNumber(InfoActivity.this, str);
Toast.makeText(InfoActivity.this, "修改成功", Toast.LENGTH_SHORT).show();
}else if (msg.obj.toString().charAt(0) == '0'){
} else if (msg.obj.toString().charAt(0) == '0') {
Toast.makeText(InfoActivity.this, "会话过期,请重新登录", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(InfoActivity.this, LoginActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}else Toast.makeText(InfoActivity.this, msg.obj.toString(), Toast.LENGTH_SHORT).show();
} else
Toast.makeText(InfoActivity.this, msg.obj.toString(), Toast.LENGTH_SHORT).show();
}
};
}
Expand Down
27 changes: 0 additions & 27 deletions app/src/main/java/cn/chronoswap/chronoswap/UI/IssuedFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -11,27 +10,9 @@

public class IssuedFragment extends Fragment {

Toolbar tbCreate;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
/* tbCreate = (Toolbar) getActivity().findViewById(R.id.issued_tb_create);
((AppCompatActivity) getActivity()).setSupportActionBar(tbCreate);
tbCreate.setNavigationIcon(R.drawable.ic_task_create);
setHasOptionsMenu(true);
tbCreate.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_create:
Intent intent = new Intent(getActivity(), TaskCreateActivity.class);
startActivity(intent);
break;
}
return true;
}
});*/
return inflater.inflate(R.layout.fragment_issued_list, container, false);
}

Expand All @@ -40,12 +21,4 @@ public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);

}


/* @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
Log.e(TAG, "onCreateOptionsMenu()");
menu.clear();
inflater.inflate(R.menu.menu_fragment_issued, menu);
}*/
}
Loading

0 comments on commit 05a58b3

Please sign in to comment.