目錄
主頁.xml
主頁.java
登陸.xml
登陸.java
注冊.xml
注冊.java
個人資訊.xml
個人資訊.java
修改個人資訊.xml
修改個人資訊.java
修改密碼.xml
修改密碼.java
意見反饋.xml
意見反饋.java
訂單串列.xml
訂單串列.構造
訂單配接器
配接器里面的布局
訂單串列.java
工具類,GongJuLei.java
主頁.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal">
<ImageView
android:layout_marginTop="30dp"
android:layout_width="150dp"
android:layout_height="150dp"
android:id="@+id/imageView"
android:background="#F1F1F1"
/>
<TextView
android:layout_marginTop="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView"
android:text="賬號名"
/>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
app:cardCornerRadius="30dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
app:cardBackgroundColor="#EFEFEF"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:text="個人資訊"
android:gravity="center"
/>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
app:cardCornerRadius="30dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
app:cardBackgroundColor="#EFEFEF"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:text="訂單串列"
android:gravity="center"
/>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
app:cardCornerRadius="30dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
app:cardBackgroundColor="#EFEFEF"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:text="修改密碼"
android:gravity="center"
/>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
app:cardCornerRadius="30dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
app:cardBackgroundColor="#EFEFEF"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:text="意見反饋"
android:gravity="center"
/>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
app:cardCornerRadius="30dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
app:cardBackgroundColor="#EFEFEF"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:text="退出"
android:gravity="center"
/>
</androidx.cardview.widget.CardView>
</LinearLayout>
主頁.java
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import com.bumptech.glide.Glide;
import com.example.smartcity.GongJuLei;
import com.example.smartcity.R;
import com.example.smartcity.gerenzhongxing.denglu.DengLu;
import com.example.smartcity.gerenzhongxing.gerenxingxi.DingDangLieBiao;
import com.example.smartcity.gerenzhongxing.gerenxingxi.FangKuiXingXi;
import com.example.smartcity.gerenzhongxing.gerenxingxi.GeRenXingXi;
import com.example.smartcity.gerenzhongxing.gerenxingxi.XiuGaiMiMa;
import com.example.smartcity.gerenzhongxing.gerenxingxi.XiuGaiXingXi;
import org.json.JSONException;
import org.json.JSONObject;
public class GeRenZhongXing extends Fragment implements View.OnClickListener {
TextView textView1,textView,textView2,textView3,textView4,textView5;
ImageView imageView;
View view;
String token="";
@Override
public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState) {
view= LayoutInflater.from(getContext()).inflate(R.layout.xinwen,null,false);
SharedPreferences sharedPreferences=getActivity().getSharedPreferences("name",0);
token=sharedPreferences.getString("token","");
textView=view.findViewById(R.id.textView);
textView1=view.findViewById(R.id.textView1);
textView2=view.findViewById(R.id.textView2);
textView3=view.findViewById(R.id.textView3);
textView4=view.findViewById(R.id.textView4);
textView5=view.findViewById(R.id.textView5);
imageView=view.findViewById(R.id.imageView);
textView.setOnClickListener(this);
imageView.setOnClickListener(this);
textView1.setOnClickListener(this);
textView2.setOnClickListener(this);
textView3.setOnClickListener(this);
textView4.setOnClickListener(this);
textView5.setOnClickListener(this);
// 獲取資料
huoqushuju();
return view;
}
private void huoqushuju() {
if (!token.equals("")){
new Thread(new Runnable() {
@Override
public void run() {
try {
String data=new GongJuLei().getHuoquGeRenXingXi(token);
JSONObject jsonObject=new JSONObject(data);
JSONObject jsonObject1=jsonObject.getJSONObject("user");
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
try {
textView.setText("賬號名:"+jsonObject1.getString("userName"));
Glide.with(getContext()).load(url).into(imageView);
} catch (JSONException e) {
e.printStackTrace();
}
}
});
}catch (Exception e){
e.printStackTrace();
}
}
}).start();
}
}
@Override
public void onClick(View view) {
switch (view.getId()){
case R.id.imageView:
if (token.equals("")){
startActivity(new Intent(getContext(), DengLu.class));
}
break;
case R.id.textView:
if (token.equals("")){
startActivity(new Intent(getContext(), DengLu.class));
}
break;
case R.id.textView1:
if (token.equals("")){
startActivity(new Intent(getContext(), DengLu.class));
}else {
startActivity(new Intent(getContext(), GeRenXingXi.class));
}
break;
case R.id.textView2:
if (token.equals("")){
startActivity(new Intent(getContext(), DengLu.class));
}else {
startActivity(new Intent(getContext(), DingDangLieBiao.class));
}
break;
case R.id.textView3:
if (token.equals("")){
startActivity(new Intent(getContext(), DengLu.class));
}else {
startActivity(new Intent(getContext(), XiuGaiMiMa.class));
}
break;
case R.id.textView4:
if (token.equals("")){
startActivity(new Intent(getContext(), DengLu.class));
}else {
startActivity(new Intent(getContext(), FangKuiXingXi.class));
}
break;
case R.id.textView5:
startActivity(new Intent(getContext(), DengLu.class));
break;
}
}
}
登陸.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".gerenzhongxing.denglu.DengLu"
android:orientation="vertical"
android:gravity="right"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:text="登陸"
android:gravity="center"
android:textSize="30dp"
android:textStyle="bold"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText1"
android:hint="請輸入賬號"
android:singleLine="true"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText2"
android:hint="請輸入密碼"
android:singleLine="true"
android:inputType="textPassword"
/>
<TextView
android:id="@+id/textView"
android:padding="10dp"
android:layout_marginRight="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="注冊賬號"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button"
android:text="登陸"
/>
</LinearLayout>
</LinearLayout>
登陸.java
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.example.smartcity.GongJuLei;
import com.example.smartcity.R;
import com.example.smartcity.daohanglang.DaoHangLang;
import org.json.JSONException;
import org.json.JSONObject;
public class DengLu extends AppCompatActivity {
EditText editText1,editText2;
Button button;
TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_deng_lu);
editText1=findViewById(R.id.editText1);
editText2=findViewById(R.id.editText2);
button=findViewById(R.id.button);
textView=findViewById(R.id.textView);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(DengLu.this,ZhuChe.class));
}
});
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!editText1.getText().equals("")&&!editText2.getText().equals("")){
// 獲取資料
new Thread(new Runnable() {
@Override
public void run() {
try {
String data=new GongJuLei().getDengLu(editText1.getText().toString().trim(),editText2.getText().toString().trim());
JSONObject jsonObject=new JSONObject(data);
runOnUiThread(new Runnable() {
@Override
public void run() {
try {
if (jsonObject.getString("msg").equals("操作成功")){
SharedPreferences sharedPreferences=getSharedPreferences("name",0);
SharedPreferences.Editor editor=sharedPreferences.edit();
editor.putString("token",jsonObject.getString("token"));
editor.commit();
startActivity(new Intent(DengLu.this, DaoHangLang.class));
finish();
}
Toast.makeText(DengLu.this,jsonObject.getString("msg") +"", Toast.LENGTH_SHORT).show();
} catch (JSONException e) {
e.printStackTrace();
}
}
});
}catch (Exception e){
e.printStackTrace();
}
}
}).start();
}else {
Toast.makeText(DengLu.this, "資料未填寫完整", Toast.LENGTH_SHORT).show();
}
}
});
}
}
注冊.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".gerenzhongxing.denglu.DengLu"
android:orientation="vertical"
android:gravity="right"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView"
android:text="回傳"
android:padding="10dp"
/>
<TextView
android:text="注冊"
android:gravity="center"
android:textSize="30dp"
android:textStyle="bold"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText1"
android:hint="請輸入賬號名"
android:singleLine="true"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText2"
android:hint="請輸入手機號"
android:singleLine="true"
android:inputType="textPassword"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText3"
android:hint="請輸入密碼"
android:singleLine="true"
android:inputType="textPassword"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText4"
android:hint="請重復密碼"
android:singleLine="true"
android:inputType="textPassword"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button"
android:text="注冊"
/>
</LinearLayout>
</LinearLayout>
注冊.java
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
import com.example.smartcity.GongJuLei;
import com.example.smartcity.R;
import org.json.JSONException;
import org.json.JSONObject;
public class ZhuChe extends AppCompatActivity {
TextView textView;
Button button;
EditText editText1,editText2,editText3,editText4;
String xinbie="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_zhu_che);
textView=findViewById(R.id.textView);
button=findViewById(R.id.button);
editText1=findViewById(R.id.editText1);
editText2=findViewById(R.id.editText2);
editText3=findViewById(R.id.editText3);
editText4=findViewById(R.id.editText4);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new Thread(new Runnable() {
@Override
public void run() {
try {
String data=new GongJuLei().getZhuChe(editText1.getText().toString(),editText2.getText().toString(),editText3.getText().toString(),xinbie);
JSONObject jsonObject=new JSONObject(data);
runOnUiThread(new Runnable() {
@Override
public void run() {
try {
if (jsonObject.getString("msg").equals("操作成功")){
finish();
}
Toast.makeText(ZhuChe.this, jsonObject.getString("msg")+"", Toast.LENGTH_SHORT).show();
} catch (JSONException e) {
e.printStackTrace();
}
}
});
}catch (Exception e){
e.printStackTrace();
}
}
}).start();
}
});
}
}
個人資訊.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_horizontal"
tools:context=".gerenzhongxing.gerenxingxi.GeRenXingXi">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView"
android:text="回傳"
android:padding="10dp"
/>
<TextView
android:text="個人資訊"
android:gravity="center"
android:textSize="30dp"
android:textStyle="bold"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
<ImageView
android:background="#F5F5F5"
android:layout_marginTop="20dp"
android:layout_width="150dp"
android:layout_height="150dp"
android:id="@+id/imageView"
/>
<LinearLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:background="#F2F2F2"
android:padding="10dp"
android:layout_height="wrap_content">
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="賬號名:"
/>
<TextView
android:id="@+id/textView1"
android:layout_weight="2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="賬號名:"
/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:background="#F2F2F2"
android:padding="10dp"
android:layout_height="wrap_content">
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="昵稱:"
/>
<TextView
android:id="@+id/textView2"
android:layout_weight="2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="賬號名:"
/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:background="#F2F2F2"
android:padding="10dp"
android:layout_height="wrap_content">
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="郵箱號:"
/>
<TextView
android:id="@+id/textView3"
android:layout_weight="2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="賬號名:"
/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:background="#F2F2F2"
android:padding="10dp"
android:layout_height="wrap_content">
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="電話號碼:"
/>
<TextView
android:id="@+id/textView4"
android:layout_weight="2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="賬號名:"
/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:background="#F2F2F2"
android:padding="10dp"
android:layout_height="wrap_content">
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="性別:"
/>
<TextView
android:id="@+id/textView5"
android:layout_weight="2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="賬號名:"
/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:background="#F2F2F2"
android:padding="10dp"
android:layout_height="wrap_content">
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="身份證號碼:"
/>
<TextView
android:id="@+id/textView6"
android:layout_weight="2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="賬號名:"
/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:background="#F2F2F2"
android:padding="10dp"
android:layout_height="wrap_content">
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="余額:"
/>
<TextView
android:id="@+id/textView7"
android:layout_weight="2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="賬號名:"
/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:background="#F2F2F2"
android:padding="10dp"
android:layout_height="wrap_content">
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="積分:"
/>
<TextView
android:id="@+id/textView8"
android:layout_weight="2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="賬號名:"
/>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="修改"
android:id="@+id/button"
/>
</LinearLayout>
個人資訊.java
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.example.smartcity.GongJuLei;
import com.example.smartcity.R;
import org.json.JSONException;
import org.json.JSONObject;
public class GeRenXingXi extends AppCompatActivity {
TextView textView,textView1,textView2,textView3,textView4,
textView5,textView6,textView7,textView8;
ImageView imageView;
String token="";
Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ge_ren_xing_xi);
token=getSharedPreferences("name",0).getString("token","");
textView=findViewById(R.id.textView);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
imageView=findViewById(R.id.imageView);
textView1=findViewById(R.id.textView1);
textView2=findViewById(R.id.textView2);
textView3=findViewById(R.id.textView3);
textView4=findViewById(R.id.textView4);
textView5=findViewById(R.id.textView5);
textView6=findViewById(R.id.textView6);
textView7=findViewById(R.id.textView7);
textView8=findViewById(R.id.textView8);
button=findViewById(R.id.button) ;
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(GeRenXingXi.this,XiuGaiXingXi.class));
}
});
// 獲取資料
new Thread(new Runnable() {
@Override
public void run() {
try {
String data=new GongJuLei().getHuoquGeRenXingXi(token);
JSONObject jsonObject=new JSONObject(data);
JSONObject jsonObject1=jsonObject.getJSONObject("user");
runOnUiThread(new Runnable() {
@Override
public void run() {
try {
Glide.with(GeRenXingXi.this).load(url).into(imageView);
textView1.setText(jsonObject1.getString("userName"));
textView2.setText(jsonObject1.getString("nickName"));
textView3.setText(jsonObject1.getString("email"));
textView4.setText(jsonObject1.getString("phonenumber"));
if (jsonObject1.getString("sex").equals("0")){
textView5.setText("男");
}else {
textView5.setText("女");
}
StringBuffer stringBuffer=new StringBuffer(jsonObject1.getString("idCard"));
stringBuffer.replace(2,14,"***");
textView6.setText(stringBuffer);
textView7.setText(jsonObject1.getString("balance"));
textView8.setText(jsonObject1.getString("score"));
} catch (JSONException e) {
e.printStackTrace();
}
}
});
}catch (Exception e){
e.printStackTrace();
}
}
}).start();
}
}
修改個人資訊.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_horizontal"
tools:context=".gerenzhongxing.gerenxingxi.XiuGaiXingXi">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView"
android:text="回傳"
android:padding="10dp"
/>
<TextView
android:text="修改資訊"
android:gravity="center"
android:textSize="30dp"
android:textStyle="bold"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
<EditText
android:id="@+id/editText1"
android:hint="請輸入昵稱"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/editText2"
android:hint="請輸入電話號碼"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/editText3"
android:hint="請輸入身份證號碼"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<RadioGroup
android:layout_width="match_parent"
android:orientation="horizontal"
android:gravity="center_horizontal"
android:id="@+id/radioGroup"
android:layout_height="wrap_content">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/radioButton1"
android:text="男"
/>
<RadioButton
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/radioButton2"
android:text="女"
/>
</RadioGroup>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button"
android:text="修改"
/>
</LinearLayout>
修改個人資訊.java
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
import com.example.smartcity.GongJuLei;
import com.example.smartcity.R;
import org.json.JSONException;
import org.json.JSONObject;
public class XiuGaiXingXi extends AppCompatActivity {
TextView textView;
Button button;
EditText editText1,editText2,editText3;
RadioGroup radioGroup;
String token="",xinbie="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_xiu_gai_xing_xi);
textView=findViewById(R.id.textView);
button=findViewById(R.id.button);
editText1=findViewById(R.id.editText1);
editText2=findViewById(R.id.editText2);
editText3=findViewById(R.id.editText3);
radioGroup=findViewById(R.id.radioGroup);
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
switch (i) {
case R.id.radioButton1:
xinbie="0";
break;
case R.id.radioButton2:
xinbie="1";
break;
}
}
});
token=getSharedPreferences("name",0).getString("token","");
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!editText1.getText().toString().trim().equals("")&&
!editText2.getText().toString().trim().equals("")&&
!editText3.getText().toString().trim().equals("")&&
!xinbie.equals("")
){
if (editText2.length()==11){
if (editText3.length()==18){
new Thread(new Runnable() {
@Override
public void run() {
try {
String data=new GongJuLei().getXiuGaiXingXi(token,
editText1.getText().toString().trim(),
editText2.getText().toString().trim(),
editText3.getText().toString().trim(),xinbie);
JSONObject jsonObject=new JSONObject(data);
runOnUiThread(new Runnable() {
@Override
public void run() {
try {
if (jsonObject.getString("msg").equals("操作成功")){
finish();
}
Toast.makeText(XiuGaiXingXi.this, jsonObject.getString("msg")+"", Toast.LENGTH_SHORT).show();
} catch (JSONException e) {
e.printStackTrace();
}
}
});
}catch (Exception e){
e.printStackTrace();
}
}
}).start();
}else {
Toast.makeText(XiuGaiXingXi.this, "請輸入18位身份證號碼", Toast.LENGTH_SHORT).show();
}
}else {
Toast.makeText(XiuGaiXingXi.this, "請輸入11位電話號碼", Toast.LENGTH_SHORT).show();
}
}else {
Toast.makeText(XiuGaiXingXi.this, "請輸入完整", Toast.LENGTH_SHORT).show();
}
}
});
}
}
修改密碼.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_horizontal"
tools:context=".gerenzhongxing.gerenxingxi.XiuGaiMiMa">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView"
android:text="回傳"
android:padding="10dp"
/>
<TextView
android:text="修改密碼"
android:gravity="center"
android:textSize="30dp"
android:textStyle="bold"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText1"
android:hint="請輸入舊密碼"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText2"
android:hint="請輸入新密碼"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText3"
android:hint="請重復密碼"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button"
android:text="修改"
/>
</LinearLayout>
修改密碼.java
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.example.smartcity.GongJuLei;
import com.example.smartcity.R;
import org.json.JSONException;
import org.json.JSONObject;
public class XiuGaiMiMa extends AppCompatActivity {
TextView textView;
EditText editText1,editText2,editText3;
Button button;
String token="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_xiu_gai_mi_ma);
token=getSharedPreferences("name",0).getString("token","");
textView=findViewById(R.id.textView);
editText1=findViewById(R.id.editText1);
editText2=findViewById(R.id.editText2);
editText3=findViewById(R.id.editText3);
button=findViewById(R.id.button);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (editText2.getText().toString().trim().equals(editText3.getText().toString().trim())){
new Thread(new Runnable() {
@Override
public void run() {
try {
String data=new GongJuLei().getXiuGaiMiMa(token,editText1.getText().toString().trim(),editText2.getText().toString().trim());
JSONObject jsonObject=new JSONObject(data);
runOnUiThread(new Runnable() {
@Override
public void run() {
try {
if (!editText1.getText().toString().trim().equals("")&&!editText2.getText().toString().trim().equals("")){
if (jsonObject.getString("msg").equals("操作成功")){
finish();
}
Toast.makeText(XiuGaiMiMa.this, jsonObject.getString("msg")+"", Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(XiuGaiMiMa.this, "未填寫完整", Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
});
}catch (Exception e){
e.printStackTrace();
}
}
}).start();
}else {
Toast.makeText(XiuGaiMiMa.this, "新密碼不一致", Toast.LENGTH_SHORT).show();
}
}
});
}
}
意見反饋.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_horizontal"
tools:context=".gerenzhongxing.gerenxingxi.FangKuiXingXi">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView"
android:text="回傳"
android:padding="10dp"
/>
<TextView
android:text="反饋資訊"
android:gravity="center"
android:textSize="30dp"
android:textStyle="bold"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_margin="20dp"
android:background="#fff"
app:cardCornerRadius="30dp"
app:cardBackgroundColor="#EEEEEE"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:background="@null"
android:id="@+id/editText"
android:hint="請輸入反饋資訊"
android:gravity="left"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:maxLength="150"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="還剩150個字可以輸入"
android:id="@+id/textView1"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_margin="30dp"
/>
</RelativeLayout>
</androidx.cardview.widget.CardView>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button"
android:text="提交"
/>
</LinearLayout>
意見反饋.java
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.example.smartcity.GongJuLei;
import com.example.smartcity.R;
import org.json.JSONException;
import org.json.JSONObject;
public class FangKuiXingXi extends AppCompatActivity {
TextView textView,textView1;
EditText editText;
Button button;
String token="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fang_kui_xing_xi);
token=getSharedPreferences("name",0).getString("token","");
textView=findViewById(R.id.textView);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
textView1=findViewById(R.id.textView1);
editText=findViewById(R.id.editText);
button=findViewById(R.id.button );
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
textView1.setText("還剩"+(150-editText.length())+"個字可以輸入");
if (editText.length()==150){
Toast.makeText(FangKuiXingXi.this, "不可以輸入了", Toast.LENGTH_SHORT).show();
}
}
});
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!editText.getText().toString().trim().equals("")){
new Thread(new Runnable() {
@Override
public void run() {
try {
String data=new GongJuLei().getFangKuiXingXi(token,editText.getText().toString().trim());
JSONObject jsonObject=new JSONObject(data );
runOnUiThread(new Runnable() {
@Override
public void run() {
try {
if (jsonObject.getString("msg").equals("操作成功")){
finish();
}
Toast.makeText(FangKuiXingXi.this, jsonObject.getString("msg")+"", Toast.LENGTH_SHORT).show();
} catch (JSONException e) {
e.printStackTrace();
}
}
});
}catch (Exception e){
e.printStackTrace();
}
}
}).start();
}else {
Toast.makeText(FangKuiXingXi.this, "未填寫", Toast.LENGTH_SHORT).show();
}
}
});
}
}
訂單串列.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".gerenzhongxing.gerenxingxi.DingDangLieBiao">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView"
android:text="回傳"
android:padding="10dp"
/>
<TextView
android:text="訂單串列"
android:gravity="center"
android:textSize="30dp"
android:textStyle="bold"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView1"
android:layout_weight="1"
android:gravity="center"
android:layout_width="0dp"
android:text="訂單編號"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/textView2"
android:layout_weight="1"
android:gravity="center"
android:layout_width="0dp"
android:text="訂單型別"
android:layout_height="wrap_content"/>
<TextView
android:text="電影院名"
android:id="@+id/textView3"
android:layout_weight="1"
android:gravity="center"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/recyclerView"
/>
</LinearLayout>
訂單串列.構造
public class DingDangGozhao {
String id,bianhao,leixing,time;
public DingDangGozhao(String id, String bianhao, String leixing, String time) {
this.id = id;
this.bianhao = bianhao;
this.leixing = leixing;
this.time = time;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getBianhao() {
return bianhao;
}
public void setBianhao(String bianhao) {
this.bianhao = bianhao;
}
public String getLeixing() {
return leixing;
}
public void setLeixing(String leixing) {
this.leixing = leixing;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
}
訂單配接器
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.text.Layout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.smartcity.R;
import java.util.List;
public class DingDangAdapter extends RecyclerView.Adapter<DingDangAdapter.ViewHolder> {
List<DingDangGozhao> list;
Context context;
public DingDangAdapter(List<DingDangGozhao> list, Context context) {
this.list = list;
this.context = context;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new ViewHolder(LayoutInflater.from(context).inflate(R.layout.dingdan,parent,false));
}
@Override
public void onBindViewHolder(DingDangAdapter.ViewHolder holder, int position) {
holder.textView1.setText(list.get(position).getBianhao());
holder.textView2.setText(list.get(position).getLeixing());
holder.textView3.setText(list.get(position).getTime());
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent=new Intent(context,DingDangXiangQing.class);
intent.putExtra("id",list.get(position).getId());
((Activity)context).startActivity(intent);
}
});
}
@Override
public int getItemCount() {
return list.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
TextView textView1,textView2,textView3;
public ViewHolder(View itemView) {
super(itemView);
textView1=itemView.findViewById(R.id.textView1);
textView2=itemView.findViewById(R.id.textView2);
textView3=itemView.findViewById(R.id.textView3);
}
}
}
配接器里面的布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
>
<TextView
android:id="@+id/textView1"
android:layout_weight="1"
android:gravity="center"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/textView2"
android:layout_weight="1"
android:gravity="center"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/textView3"
android:layout_weight="1"
android:gravity="center"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
</LinearLayout>
訂單串列.java
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import com.example.smartcity.GongJuLei;
import com.example.smartcity.R;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
public class DingDangLieBiao extends AppCompatActivity {
TextView textView;
RecyclerView recyclerView;
List<DingDangGozhao> list=new ArrayList<>();
String token="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ding_dang_lie_biao);
token=getSharedPreferences("name",0).getString("token","");
textView=findViewById(R.id.textView);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
recyclerView=findViewById(R.id.recyclerView);
LinearLayoutManager linearLayoutManager=new LinearLayoutManager(this);
recyclerView.setLayoutManager( linearLayoutManager);
new Thread(new Runnable() {
@Override
public void run() {
try {
String data=new GongJuLei().getDingDang(token);
JSONObject jsonObject=new JSONObject(data);
JSONArray jsonArray=jsonObject.getJSONArray("rows");
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject1=jsonArray.getJSONObject(i);
DingDangGozhao gozhao=new DingDangGozhao(jsonObject1.getInt("id")+"",
jsonObject1.getString("orderNo"),
jsonObject1.getString("orderType"),
jsonObject1.getString("name"));
list.add(gozhao);
}
runOnUiThread(new Runnable() {
@Override
public void run() {
DingDangAdapter adapter=new DingDangAdapter(list,DingDangLieBiao.this);
recyclerView.setAdapter(adapter);
}
});
}catch (Exception e){
e.printStackTrace();
}
}
}).start();
}
}
工具類,GongJuLei.java
import android.text.Editable;
import java.io.IOException;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
public class GongJuLei {
public String getDengLu(String username, String password) throws IOException {
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n\"username\":\""+username+"\",\r\n\"password\":\""+password+"\"\r\n}");
Request request = new Request.Builder()
.url(url)
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
return response.body().string();
}
public String getZhuChe(String username,String phone, String password,String xinbie) throws IOException {
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n\"userName\": \""+username+"\",\r\n\"password\": \""+password+"\",\r\n\"phonenumber\": \""+phone+"\",\r\n\"sex\": \""+xinbie+"\"\r\n}");
Request request = new Request.Builder()
.url(url)
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
return response.body().string();
}
public String getHuoquGeRenXingXi(String token) throws IOException {
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url(url)
.method("GET", null)
.addHeader("Authorization", token)
.build();
Response response = client.newCall(request).execute();
return response.body().string();
}
public String getXiuGaiXingXi(String token,String name,String phone,String shengfengzheng,String xinbie) throws IOException {
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n\"idCard\": \""+shengfengzheng+"\",\r\n\"nickName\": \""+name+"\",\r\n\"phonenumber\": \""+phone+"\",\r\n\"sex\": \""+xinbie+"\"\r\n}");
Request request = new Request.Builder()
.url(url)
.method("PUT", body)
.addHeader("Authorization", token)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
return response.body().string();
}
public String getXiuGaiMiMa(String token,String jiumima,String xinmima) throws IOException {
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n\"newPassword\": \""+xinmima+"\",\r\n\"oldPassword\": \""+jiumima+"\"\r\n}");
Request request = new Request.Builder()
.url(url)
.method("PUT", body)
.addHeader("Authorization", token)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
return response.body().string();
}
public String getFangKuiXingXi(String token,String content) throws IOException {
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n\"content\": \""+content+"\"\r\n}");
Request request = new Request.Builder()
.url(url)
.method("POST", body)
.addHeader("Authorization", token)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
return response.body().string();
}
public String getDingDang(String token) throws IOException {
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url(url)
.method("GET", null)
.addHeader("Authorization", token)
.build();
Response response = client.newCall(request).execute();
return response.body().string();
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/390657.html
標籤:其他
