Android代码12月22日提交

This commit is contained in:
Levi 2024-12-22 15:47:20 +08:00
parent e7a053d35d
commit 3f8f640c38
32 changed files with 938 additions and 38 deletions

View File

@ -42,6 +42,11 @@ dependencies {
androidTestImplementation(libs.espresso.core) androidTestImplementation(libs.espresso.core)
implementation ("de.hdodenhof:circleimageview:3.1.0") implementation ("de.hdodenhof:circleimageview:3.1.0")
implementation ("com.squareup.okhttp3:okhttp:4.11.0")
implementation ("com.squareup.retrofit2:retrofit:2.9.0")
implementation ("com.squareup.retrofit2:converter-gson:2.9.0") // 如果你需要使用 Gson 转换器
implementation ("com.google.code.gson:gson:2.10.1")
implementation ("com.squareup.okhttp3:logging-interceptor:4.9.3")
// 基础依赖包,必须要依赖 // 基础依赖包,必须要依赖
implementation ("com.geyifeng.immersionbar:immersionbar:3.2.2") implementation ("com.geyifeng.immersionbar:immersionbar:3.2.2")

View File

@ -2,7 +2,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<application <application
android:usesCleartextTraffic="true"
android:allowBackup="true" android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules" android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules" android:fullBackupContent="@xml/backup_rules"
@ -12,6 +15,9 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.CourseDesign" android:theme="@style/Theme.CourseDesign"
tools:targetApi="31"> tools:targetApi="31">
<activity
android:name=".MyOrderActivity"
android:exported="false" />
<activity <activity
android:name=".MyReleaseActivity" android:name=".MyReleaseActivity"
android:exported="false" /> android:exported="false" />

View File

@ -0,0 +1,44 @@
package com.example.coursedesign;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Query;
public interface Api {
//http://127.0.0.1:8080/system/person/login
@GET("/system/person/login")
Call<LoginResult> login(@Header("Authorization") String token, @Query("phone") String username, @Query("password") String password);
//http://127.0.0.1:8080/system/commodity/list
@GET("/system/commodity/list2")
Call<CommodityListResult> getCommodityList(@Header("Authorization") String token);
//http://127.0.0.1:8080/system/commodity/list
@GET("/system/commodity/list2")
Call<CommodityListResult> getCommodityListById(@Header("Authorization") String token, @Query("id") Integer id);
//http://127.0.0.1:8080/system/commodity/list
@GET("/system/commodity/list2")
Call<CommodityListResult> getCommodityListByNameOrClassification(@Header("Authorization") String token, @Query("name") String name, @Query("classification") String classification);
//http://127.0.0.1:8080/system/comment/list2
@GET("/system/comment/list2")
Call<CommentListResult> getCommentListByCommodityId(@Header("Authorization") String token, @Query("commodityid") Integer commodityId);
//http://127.0.0.1:8080/system/favorite/list2
@GET("/system/favorite/list2")
Call<FavoriteListResult> getFavoriteListByPersonId(@Header("Authorization") String token, @Query("personid") Integer personId);
//http://127.0.0.1:8080/system/order/list2
@GET("/system/order/list2")
Call<OrderListResult> getOrderListByBuyerId(@Header("Authorization") String token, @Query("buyerid") Integer buyerId);
}

View File

@ -0,0 +1,28 @@
package com.example.coursedesign;
import java.util.List;
public class CommentListResult {
public Integer total;
public List<RowsDTO> rows;
public Integer code;
public String msg;
public static class RowsDTO {
public Object createBy;
public Object createTime;
public Object updateBy;
public Object updateTime;
public Object remark;
public Integer id;
public Integer personid;
public String personname;
public Object personpicture;
public Integer commodityid;
public String commodityname;
public Object commoditypicture;
public String content;
public String time;
}
}

View File

@ -4,6 +4,7 @@ import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -22,10 +23,25 @@ import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import retrofit2.Call;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class CommodityActivity extends AppCompatActivity { public class CommodityActivity extends AppCompatActivity {
MyAdapter myAdapter; MyAdapter myAdapter;
RecyclerView recyclerView; RecyclerView recyclerView;
TextView back;
TextView commodityNameTV;
TextView priceTV;
TextView timeTV;
TextView classificationTV;
ImageView commodityImage;
TextView descriptionTV;
TextView sellerNameTV;
ImageView sellerImage;
CommentListResult result;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -42,6 +58,77 @@ public class CommodityActivity extends AppCompatActivity {
myAdapter = new MyAdapter(); myAdapter = new MyAdapter();
recyclerView.setAdapter(myAdapter); recyclerView.setAdapter(myAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(CommodityActivity.this)); recyclerView.setLayoutManager(new LinearLayoutManager(CommodityActivity.this));
back = findViewById(R.id.textView13);
sellerNameTV = findViewById(R.id.textView14);
priceTV = findViewById(R.id.textView15);
commodityNameTV = findViewById(R.id.textView12);
descriptionTV = findViewById(R.id.textView17);
timeTV = findViewById(R.id.textView16);
classificationTV = findViewById(R.id.textView34);
sellerImage = findViewById(R.id.imageView10);
commodityImage = findViewById(R.id.imageView9);
SharedPreferences sharedPreferences = getSharedPreferences("commodity", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
int id = sharedPreferences.getInt("id", 0);
//获取数据
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://10.138.63.204:8080/")
.addConverterFactory(GsonConverterFactory.create()) //返回结果用Gson解析
.build();
Api api = retrofit.create(Api.class);
Call<CommodityListResult> commodityListCall = api.getCommodityListById("Bearer ", id);
commodityListCall.enqueue(new retrofit2.Callback<CommodityListResult>() {
@Override
public void onResponse(Call<CommodityListResult> call, retrofit2.Response<CommodityListResult> response) {
CommodityListResult result = response.body();
if(result.code == 200){
CommodityListResult.RowsDTO rowsDTO = result.rows.get(0);
commodityNameTV.setText(rowsDTO.name);
priceTV.setText("¥" + rowsDTO.price);
descriptionTV.setText(rowsDTO.description);
timeTV.setText(rowsDTO.time);
classificationTV.setText(rowsDTO.classification);
sellerNameTV.setText(rowsDTO.sellername);
Glide.with(getApplicationContext()).load(rowsDTO.picture).into(commodityImage);
Glide.with(getApplicationContext()).load(rowsDTO.sellerpicture).into(sellerImage);
}
}
@Override
public void onFailure(Call<CommodityListResult> call, Throwable t) {
}
});
Call<CommentListResult> commentListCall = api.getCommentListByCommodityId("Bearer ", id);
commentListCall.enqueue(new retrofit2.Callback<CommentListResult>() {
@Override
public void onResponse(Call<CommentListResult> call, retrofit2.Response<CommentListResult> response) {
result = response.body();
Log.e("result", result.toString());
if(result.code == 200){
myAdapter.notifyDataSetChanged();
}
}
@Override
public void onFailure(Call<CommentListResult> call, Throwable t) {
}
});
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
} }
public class MyAdapter extends RecyclerView.Adapter<MyViewHolder> { public class MyAdapter extends RecyclerView.Adapter<MyViewHolder> {
@ -57,18 +144,34 @@ public class CommodityActivity extends AppCompatActivity {
@Override @Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
holder.personNameTV.setText(result.rows.get(position).personname);
holder.contentTV.setText(result.rows.get(position).content);
Glide.with(getApplicationContext()).load(result.rows.get(position).personpicture).into(holder.personImage);
} }
@Override @Override
public int getItemCount() { public int getItemCount() {
return 4; if(result != null){
return result.rows.size();
}else{
return 0;
}
} }
} }
public class MyViewHolder extends RecyclerView.ViewHolder { public class MyViewHolder extends RecyclerView.ViewHolder {
TextView personNameTV;
TextView contentTV;
ImageView personImage;
ConstraintLayout constraintLayout;
public MyViewHolder(@NonNull View itemView) { public MyViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
personNameTV = itemView.findViewById(R.id.textView19);
contentTV = itemView.findViewById(R.id.textView20);
personImage = itemView.findViewById(R.id.imageView12);
constraintLayout = itemView.findViewById(R.id.constraintLayout2);
} }
} }
} }

View File

@ -0,0 +1,30 @@
package com.example.coursedesign;
import java.util.List;
public class CommodityListResult {
public Integer total;
public List<RowsDTO> rows;
public Integer code;
public String msg;
public static class RowsDTO {
public Object createBy;
public Object createTime;
public Object updateBy;
public Object updateTime;
public Object remark;
public Integer id;
public String name;
public Integer sellerid;
public String sellername;
public Object sellerpicture;
public Double price;
public String classification;
public String description;
public Object picture;
public String state;
public String time;
}
}

View File

@ -11,18 +11,33 @@ import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.scwang.smart.refresh.footer.ClassicsFooter;
import com.scwang.smart.refresh.header.ClassicsHeader;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshListener;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class FavoriteFragment extends Fragment { public class FavoriteFragment extends Fragment {
MyAdapter myAdapter; MyAdapter myAdapter;
RecyclerView recyclerView; RecyclerView recyclerView;
SmartRefreshLayout smartRefreshLayout;
FavoriteListResult result;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
@ -30,11 +45,62 @@ public class FavoriteFragment extends Fragment {
// Inflate the layout for this fragment // Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_favorite, container, false); View view = inflater.inflate(R.layout.fragment_favorite, container, false);
recyclerView = view.findViewById(R.id.recycleView2); recyclerView = view.findViewById(R.id.recyclerView2);
myAdapter = new MyAdapter(); myAdapter = new MyAdapter();
recyclerView.setAdapter(myAdapter); recyclerView.setAdapter(myAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
//获取数据
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://10.138.63.204:8080/")
.addConverterFactory(GsonConverterFactory.create()) //返回结果用Gson解析
.build();
Api api = retrofit.create(Api.class);
Call<FavoriteListResult> favoriteListCall = api.getFavoriteListByPersonId("Bearer ", 1);
favoriteListCall.enqueue(new Callback<FavoriteListResult>() {
@Override
public void onResponse(Call<FavoriteListResult> call, retrofit2.Response<FavoriteListResult> response) {
result = response.body();
if(result.code == 200){
myAdapter.notifyDataSetChanged();
}
}
@Override
public void onFailure(Call<FavoriteListResult> call, Throwable t) {
Log.e("error", t.getMessage());
}
});
//列表刷新
smartRefreshLayout = view.findViewById(R.id.smartLayout2);
smartRefreshLayout.setRefreshHeader(new ClassicsHeader(getContext()));
smartRefreshLayout.setRefreshFooter(new ClassicsFooter(getContext()));
smartRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
Call<FavoriteListResult> favoriteListCall = api.getFavoriteListByPersonId("Bearer ", 1);
favoriteListCall.enqueue(new Callback<FavoriteListResult>() {
@Override
public void onResponse(Call<FavoriteListResult> call, retrofit2.Response<FavoriteListResult> response) {
result = response.body();
if(result.code == 200){
myAdapter.notifyDataSetChanged();
}
}
@Override
public void onFailure(Call<FavoriteListResult> call, Throwable t) {
Log.e("error", t.getMessage());
}
});
smartRefreshLayout.finishRefresh(500);
}
});
return view; return view;
} }
@ -51,20 +117,63 @@ public class FavoriteFragment extends Fragment {
@Override @Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
holder.commodityNameTV.setText(result.rows.get(position).commodityname);
holder.priceTV.setText("¥" + result.rows.get(position).price);
holder.descriptionTV.setText(result.rows.get(position).description);
holder.sellerNameTV.setText(result.rows.get(position).sellername);
holder.timeTV.setText(result.rows.get(position).time);
Glide.with(getContext()).load(result.rows.get(position).commoditypicture).into(holder.commodityImage);
Glide.with(getContext()).load(result.rows.get(position).sellerpicture).into(holder.sellerImage);
holder.constraintLayout.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
int adapterPosition = holder.getAdapterPosition();
if(adapterPosition != RecyclerView.NO_POSITION){
SharedPreferences sharedPreferences = getActivity().getSharedPreferences("commodity", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.clear();
editor.putInt("id", result.rows.get(adapterPosition).id);
editor.commit();
startActivity(new Intent(getActivity(), CommodityActivity.class));
}
}
});
} }
@Override @Override
public int getItemCount() { public int getItemCount() {
return 4; if(result != null){
return result.rows.size();
}else{
return 0;
}
} }
} }
public class MyViewHolder extends RecyclerView.ViewHolder { public class MyViewHolder extends RecyclerView.ViewHolder {
TextView commodityNameTV;
TextView priceTV;
ImageView commodityImage;
TextView descriptionTV;
TextView sellerNameTV;
ImageView sellerImage;
TextView timeTV;
ConstraintLayout constraintLayout;
public MyViewHolder(@NonNull View itemView) { public MyViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
commodityNameTV = itemView.findViewById(R.id.textView8);
priceTV = itemView.findViewById(R.id.textView9);
commodityImage = itemView.findViewById(R.id.imageView7);
descriptionTV = itemView.findViewById(R.id.textView18);
sellerNameTV = itemView.findViewById(R.id.textView10);
sellerImage = itemView.findViewById(R.id.imageView8);
timeTV = itemView.findViewById(R.id.textView25);
constraintLayout = itemView.findViewById(R.id.commodityLayout);
} }
} }
} }

View File

@ -0,0 +1,35 @@
package com.example.coursedesign;
import java.util.List;
public class FavoriteListResult {
public Integer total;
public List<RowsDTO> rows;
public Integer code;
public String msg;
public static class RowsDTO {
public Object createBy;
public Object createTime;
public Object updateBy;
public Object updateTime;
public Object remark;
public Integer id;
public Integer personid;
public String personname;
public String personpicture;
public Integer commodityid;
public String commodityname;
public String commoditypicture;
public Integer sellerid;
public String sellername;
public String sellerpicture;
public Double price;
public String classification;
public String description;
public String state;
public String time;
}
}

View File

@ -1,6 +1,8 @@
package com.example.coursedesign; package com.example.coursedesign;
import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -9,14 +11,40 @@ import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.scwang.smart.refresh.footer.ClassicsFooter;
import com.scwang.smart.refresh.header.ClassicsHeader;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshListener;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class HomeFragment extends Fragment { public class HomeFragment extends Fragment {
MyAdapter myAdapter; MyAdapter myAdapter;
RecyclerView recyclerView; RecyclerView recyclerView;
SmartRefreshLayout smartRefreshLayout;
CommodityListResult result;
Spinner spinner;
EditText search;
ImageView searchImage;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
@ -24,11 +52,107 @@ public class HomeFragment extends Fragment {
// Inflate the layout for this fragment // Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_home, container, false); View view = inflater.inflate(R.layout.fragment_home, container, false);
recyclerView = view.findViewById(R.id.recycleView); recyclerView = view.findViewById(R.id.recyclerView);
myAdapter = new MyAdapter(); myAdapter = new MyAdapter();
recyclerView.setAdapter(myAdapter); recyclerView.setAdapter(myAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
spinner = view.findViewById(R.id.spinner);
search = view.findViewById(R.id.editTextText2);
searchImage = view.findViewById(R.id.imageView6);
//获取数据
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://10.138.63.204:8080/")
.addConverterFactory(GsonConverterFactory.create()) //返回结果用Gson解析
.build();
Api api = retrofit.create(Api.class);
//设置item的被选择的监听
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
//当item被选择后调用此方法
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
//获取我们所选中的内容
String classcification = parent.getItemAtPosition(position).toString();
if(classcification.equals("全部")){
Call<CommodityListResult> commodityListCall = api.getCommodityList("Bearer ");
commodityListCall.enqueue(new Callback<CommodityListResult>() {
@Override
public void onResponse(Call<CommodityListResult> call, Response<CommodityListResult> response) {
result = response.body();
if(result.code == 200){
myAdapter.notifyDataSetChanged();
}
}
@Override
public void onFailure(Call<CommodityListResult> call, Throwable t) {
Log.e("error", t.getMessage());
}
});
}else{
Call<CommodityListResult> commodityListCall = api.getCommodityListByNameOrClassification("Bearer ", null, classcification);
commodityListCall.enqueue(new Callback<CommodityListResult>() {
@Override
public void onResponse(Call<CommodityListResult> call, Response<CommodityListResult> response) {
result = response.body();
if(result.code == 200){
myAdapter.notifyDataSetChanged();
}
}
@Override
public void onFailure(Call<CommodityListResult> call, Throwable t) {
Log.e("error", t.getMessage());
}
});
}
}
//只有当patent中的资源没有时调用此方法
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
//列表刷新
smartRefreshLayout = view.findViewById(R.id.smartLayout);
smartRefreshLayout.setRefreshHeader(new ClassicsHeader(getContext()));
smartRefreshLayout.setRefreshFooter(new ClassicsFooter(getContext()));
smartRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
search.setText("");
spinner.setSelection(0);
smartRefreshLayout.finishRefresh(500);
}
});
searchImage.setOnClickListener(v -> {
spinner.setSelection(0);
Call<CommodityListResult> commodityListCall = api.getCommodityListByNameOrClassification("Bearer ", search.getText().toString(), null);
commodityListCall.enqueue(new Callback<CommodityListResult>() {
@Override
public void onResponse(Call<CommodityListResult> call, Response<CommodityListResult> response) {
result = response.body();
if(result.code == 200){
myAdapter.notifyDataSetChanged();
}
}
@Override
public void onFailure(Call<CommodityListResult> call, Throwable t) {
Log.e("error", t.getMessage());
}
});
});
return view; return view;
} }
@ -45,28 +169,62 @@ public class HomeFragment extends Fragment {
@Override @Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
holder.commodityNameTV.setText(result.rows.get(position).name);
holder.priceTV.setText("¥" + result.rows.get(position).price);
holder.descriptionTV.setText(result.rows.get(position).description);
holder.sellerNameTV.setText(result.rows.get(position).sellername);
holder.timeTV.setText(result.rows.get(position).time);
Glide.with(getContext()).load(result.rows.get(position).picture).into(holder.commodityImage);
Glide.with(getContext()).load(result.rows.get(position).sellerpicture).into(holder.sellerImage);
holder.constraintLayout.setOnClickListener(new View.OnClickListener(){ holder.constraintLayout.setOnClickListener(new View.OnClickListener(){
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Intent intent = new Intent(getActivity(), CommodityActivity.class);
startActivity(intent); int adapterPosition = holder.getAdapterPosition();
if(adapterPosition != RecyclerView.NO_POSITION){
SharedPreferences sharedPreferences = getActivity().getSharedPreferences("commodity", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.clear();
editor.putInt("id", result.rows.get(adapterPosition).id);
editor.commit();
startActivity(new Intent(getActivity(), CommodityActivity.class));
}
} }
}); });
} }
@Override @Override
public int getItemCount() { public int getItemCount() {
return 10; if(result != null){
return result.rows.size();
}else{
return 0;
}
} }
} }
public class MyViewHolder extends RecyclerView.ViewHolder { public class MyViewHolder extends RecyclerView.ViewHolder {
TextView commodityNameTV;
TextView priceTV;
ImageView commodityImage;
TextView descriptionTV;
TextView sellerNameTV;
ImageView sellerImage;
TextView timeTV;
ConstraintLayout constraintLayout; ConstraintLayout constraintLayout;
public MyViewHolder(@NonNull View itemView) { public MyViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
commodityNameTV = itemView.findViewById(R.id.textView8);
priceTV = itemView.findViewById(R.id.textView9);
commodityImage = itemView.findViewById(R.id.imageView7);
descriptionTV = itemView.findViewById(R.id.textView18);
sellerNameTV = itemView.findViewById(R.id.textView10);
sellerImage = itemView.findViewById(R.id.imageView8);
timeTV = itemView.findViewById(R.id.textView25);
constraintLayout = itemView.findViewById(R.id.commodityLayout); constraintLayout = itemView.findViewById(R.id.commodityLayout);
} }
} }

View File

@ -1,9 +1,12 @@
package com.example.coursedesign; package com.example.coursedesign;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Toast;
import androidx.activity.EdgeToEdge; import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
@ -11,10 +14,19 @@ import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat; import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat; import androidx.core.view.WindowInsetsCompat;
import java.util.HashMap;
import java.util.Map;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class LoginActivity extends AppCompatActivity { public class LoginActivity extends AppCompatActivity {
EditText phone, password; EditText phone, password;
Button login, register; Button login, register;
LoginResult result;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -32,9 +44,48 @@ public class LoginActivity extends AppCompatActivity {
login = findViewById(R.id.button2); login = findViewById(R.id.button2);
register = findViewById(R.id.button); register = findViewById(R.id.button);
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://10.138.63.204:8080/")
.addConverterFactory(GsonConverterFactory.create()) //返回结果用Gson解析
.build();
Api api = retrofit.create(Api.class);
//登录按钮监听 //登录按钮监听
login.setOnClickListener(v -> { login.setOnClickListener(v -> {
Call<LoginResult> loginResultCall = api.login("Bearer ", phone.getText().toString(), password.getText().toString());
startActivity(new Intent(LoginActivity.this, HomeActivity.class)); startActivity(new Intent(LoginActivity.this, HomeActivity.class));
loginResultCall.enqueue(new Callback<LoginResult>() {
@Override
public void onResponse(Call<LoginResult> call, retrofit2.Response<LoginResult> response) {
result = response.body();
if (result != null && result.data != null) {
SharedPreferences sharedPreferences = getSharedPreferences("user", MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.clear();
// editor.putString("token", loginResult.token);
editor.putBoolean("isLogin", true);
editor.putInt("id", result.data.id);
editor.putString("phone", result.data.phone);
editor.putString("name", result.data.name);
editor.putString("picture", result.data.picture);
editor.commit();
Toast.makeText(LoginActivity.this, "登录成功", Toast.LENGTH_LONG).show();
startActivity(new Intent(LoginActivity.this, HomeActivity.class));
finish();
} else {
Toast.makeText(LoginActivity.this, "账号或者密码错误", Toast.LENGTH_LONG).show();
}
}
@Override
public void onFailure(Call<LoginResult> call, Throwable t) {
Log.e("error", t.getMessage());
}
});
}); });
//注册按钮监听 //注册按钮监听

View File

@ -0,0 +1,25 @@
package com.example.coursedesign;
public class LoginResult {
public String msg;
public Integer code;
public DataDTO data;
public static class DataDTO {
public Object createBy;
public Object createTime;
public Object updateBy;
public Object updateTime;
public Object remark;
public Integer id;
public String name;
public String picture;
public Object gender;
public Object age;
public String phone;
public Object password;
public Object address;
public Object major;
}
}

View File

@ -12,7 +12,7 @@ import android.widget.Button;
public class MineFragment extends Fragment { public class MineFragment extends Fragment {
Button button; Button button, button2;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
@ -24,6 +24,10 @@ public class MineFragment extends Fragment {
button.setOnClickListener(v -> { button.setOnClickListener(v -> {
startActivity(new Intent(getActivity(), MyReleaseActivity.class)); startActivity(new Intent(getActivity(), MyReleaseActivity.class));
}); });
button2 = view.findViewById(R.id.button10);
button2.setOnClickListener(v -> {
startActivity(new Intent(getActivity(), MyOrderActivity.class));
});
return view; return view;
} }
} }

View File

@ -0,0 +1,160 @@
package com.example.coursedesign;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.activity.EdgeToEdge;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import retrofit2.Call;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class MyOrderActivity extends AppCompatActivity {
MyAdapter myAdapter;
RecyclerView recyclerView;
TextView back;
OrderListResult result;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_my_order);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets;
});
recyclerView = findViewById(R.id.recyclerView5);
myAdapter = new MyAdapter();
recyclerView.setAdapter(myAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(MyOrderActivity.this));
back = findViewById(R.id.textView33);
SharedPreferences sharedPreferences = getSharedPreferences("user", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
int id = sharedPreferences.getInt("id", 0);
//获取数据
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://10.138.63.204:8080/")
.addConverterFactory(GsonConverterFactory.create()) //返回结果用Gson解析
.build();
Api api = retrofit.create(Api.class);
Call<OrderListResult> orderListCall = api.getOrderListByBuyerId("Bearer ", id);
orderListCall.enqueue(new retrofit2.Callback<OrderListResult>() {
@Override
public void onResponse(Call<OrderListResult> call, retrofit2.Response<OrderListResult> response) {
result = response.body();
if (result.code == 200) {
myAdapter.notifyDataSetChanged();
}
}
@Override
public void onFailure(Call<OrderListResult> call, Throwable t) {
Log.e("error", t.getMessage());
}
});
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
public class MyAdapter extends RecyclerView.Adapter<MyViewHolder> {
@NonNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(MyOrderActivity.this).inflate(R.layout.commodity_item_layout, parent, false);
MyViewHolder myViewHolder = new MyViewHolder(view);
return myViewHolder;
}
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
holder.commodityNameTV.setText(result.rows.get(position).commodityname);
holder.priceTV.setText("¥" + result.rows.get(position).price);
holder.descriptionTV.setText(result.rows.get(position).description);
holder.sellerNameTV.setText(result.rows.get(position).sellername);
holder.timeTV.setText(result.rows.get(position).time);
Glide.with(getApplicationContext()).load(result.rows.get(position).commoditypicture).into(holder.commodityImage);
Glide.with(getApplicationContext()).load(result.rows.get(position).sellerpicture).into(holder.sellerImage);
holder.constraintLayout.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
int adapterPosition = holder.getAdapterPosition();
if(adapterPosition != RecyclerView.NO_POSITION){
SharedPreferences sharedPreferences = getSharedPreferences("commodity", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.clear();
editor.putInt("id", result.rows.get(adapterPosition).commodityid);
editor.commit();
startActivity(new Intent(MyOrderActivity.this, CommodityActivity.class));
}
}
});
}
@Override
public int getItemCount() {
if(result != null){
return result.rows.size();
}else{
return 0;
}
}
}
public class MyViewHolder extends RecyclerView.ViewHolder {
TextView commodityNameTV;
TextView priceTV;
ImageView commodityImage;
TextView descriptionTV;
TextView sellerNameTV;
ImageView sellerImage;
TextView timeTV;
ConstraintLayout constraintLayout;
public MyViewHolder(@NonNull View itemView) {
super(itemView);
commodityNameTV = itemView.findViewById(R.id.textView8);
priceTV = itemView.findViewById(R.id.textView9);
commodityImage = itemView.findViewById(R.id.imageView7);
descriptionTV = itemView.findViewById(R.id.textView18);
sellerNameTV = itemView.findViewById(R.id.textView10);
sellerImage = itemView.findViewById(R.id.imageView8);
timeTV = itemView.findViewById(R.id.textView25);
constraintLayout = itemView.findViewById(R.id.commodityLayout);
}
}
}

View File

@ -22,7 +22,7 @@ public class NotOnSaleFragment extends Fragment {
Bundle savedInstanceState) { Bundle savedInstanceState) {
// Inflate the layout for this fragment // Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_not_on_sale, container, false); View view = inflater.inflate(R.layout.fragment_not_on_sale, container, false);
recyclerView = view.findViewById(R.id.recycleView4); recyclerView = view.findViewById(R.id.recyclerView4);
myAdapter = new MyAdapter(); myAdapter = new MyAdapter();
recyclerView.setAdapter(myAdapter); recyclerView.setAdapter(myAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));

View File

@ -1,8 +1,5 @@
package com.example.coursedesign; package com.example.coursedesign;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -14,11 +11,10 @@ import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.bumptech.glide.Glide;
public class OnSaleFragment extends Fragment { public class OnSaleFragment extends Fragment {
MyAdapter myAdapter; MyAdapter myAdapter;
@ -29,7 +25,7 @@ public class OnSaleFragment extends Fragment {
Bundle savedInstanceState) { Bundle savedInstanceState) {
// Inflate the layout for this fragment // Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_on_sale, container, false); View view = inflater.inflate(R.layout.fragment_on_sale, container, false);
recyclerView = view.findViewById(R.id.recycleView3); recyclerView = view.findViewById(R.id.recyclerView6);
myAdapter = new MyAdapter(); myAdapter = new MyAdapter();
recyclerView.setAdapter(myAdapter); recyclerView.setAdapter(myAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
@ -58,11 +54,24 @@ public class OnSaleFragment extends Fragment {
} }
public class MyViewHolder extends RecyclerView.ViewHolder { public class MyViewHolder extends RecyclerView.ViewHolder {
TextView commodityNameTV;
TextView commodityPriceTV;
TextView descriptionTV;
Button switchButton;
Button deleteButton;
ImageView commodityPictureIV;
ConstraintLayout constraintLayout; ConstraintLayout constraintLayout;
public MyViewHolder(@NonNull View itemView) { public MyViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
commodityNameTV = itemView.findViewById(R.id.textView29);
commodityPriceTV = itemView.findViewById(R.id.textView30);
descriptionTV = itemView.findViewById(R.id.textView31);
switchButton = itemView.findViewById(R.id.button9);
deleteButton = itemView.findViewById(R.id.button8);
commodityPictureIV = itemView.findViewById(R.id.imageView14);
constraintLayout = itemView.findViewById(R.id.constraintLayout3);
} }
} }
} }

View File

@ -0,0 +1,35 @@
package com.example.coursedesign;
import java.util.List;
public class OrderListResult {
public Integer total;
public List<RowsDTO> rows;
public Integer code;
public String msg;
public static class RowsDTO {
public Object createBy;
public Object createTime;
public Object updateBy;
public Object updateTime;
public Object remark;
public Integer id;
public Integer buyerid;
public String buyername;
public String buyerpicture;
public Integer commodityid;
public String commodityname;
public String commoditypicture;
public Integer sellerid;
public String sellername;
public String sellerpicture;
public Double price;
public String classification;
public String description;
public String state;
public String time;
public String status;
}
}

View File

@ -13,7 +13,7 @@ import androidx.core.view.WindowInsetsCompat;
public class RegistrationActivity extends AppCompatActivity { public class RegistrationActivity extends AppCompatActivity {
EditText username,phone,password; EditText username,phone,password;
Button register; Button register, back;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -30,10 +30,15 @@ public class RegistrationActivity extends AppCompatActivity {
phone = findViewById(R.id.editTextPhone); phone = findViewById(R.id.editTextPhone);
password = findViewById(R.id.editTextTextPassword); password = findViewById(R.id.editTextTextPassword);
register = findViewById(R.id.button3); register = findViewById(R.id.button3);
back = findViewById(R.id.button11);
// 注册按钮监听 // 注册按钮监听
register.setOnClickListener(v -> { register.setOnClickListener(v -> {
}); });
back.setOnClickListener(v -> {
finish();
});
} }
} }

View File

@ -0,0 +1,6 @@
package com.example.coursedesign;
public class Result {
public String msg;
public Integer code;
}

View File

@ -22,7 +22,7 @@ public class SoldOutFragment extends Fragment {
Bundle savedInstanceState) { Bundle savedInstanceState) {
// Inflate the layout for this fragment // Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_sold_out, container, false); View view = inflater.inflate(R.layout.fragment_sold_out, container, false);
recyclerView = view.findViewById(R.id.recycleView4); recyclerView = view.findViewById(R.id.recyclerView4);
myAdapter = new MyAdapter(); myAdapter = new MyAdapter();
recyclerView.setAdapter(myAdapter); recyclerView.setAdapter(myAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));

View File

@ -25,14 +25,15 @@
android:id="@+id/textView13" android:id="@+id/textView13"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="24dp" android:layout_marginStart="16dp"
android:text="Back" android:text="Back"
android:textColor="@color/teal_200" android:textColor="@color/teal_200"
android:textSize="24sp" android:textSize="24sp"
android:textStyle="bold" android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/textView12" app:layout_constraintBottom_toBottomOf="@+id/textView12"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/textView12" /> app:layout_constraintTop_toTopOf="@+id/textView12"
app:layout_constraintVertical_bias="0.0" />
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayout8" android:id="@+id/constraintLayout8"
@ -116,6 +117,14 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView16" /> app:layout_constraintTop_toBottomOf="@+id/textView16" />
<TextView
android:id="@+id/textView34"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="分类"
app:layout_constraintBottom_toBottomOf="@+id/imageView10"
app:layout_constraintEnd_toEndOf="@+id/textView15" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
tools:context=".MyOrderActivity">
<com.scwang.smart.refresh.layout.SmartRefreshLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView32">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView5"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
<TextView
android:id="@+id/textView32"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="48dp"
android:text="我的订单"
android:textColor="@color/teal_200"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView33"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:text="Back"
android:textColor="@color/teal_200"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/textView32"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/textView32" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -90,9 +90,24 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="32dp" android:layout_marginTop="32dp"
android:layout_marginEnd="24dp"
android:backgroundTint="#5FEDFF" android:backgroundTint="#5FEDFF"
android:text="注册" android:text="注册"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/button11"
app:layout_constraintTop_toBottomOf="@+id/editTextTextPassword" />
<Button
android:id="@+id/button11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="32dp"
android:backgroundTint="#BB94FF"
android:text="返回"
app:layout_constraintEnd_toStartOf="@+id/button3"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editTextTextPassword" /> app:layout_constraintTop_toBottomOf="@+id/editTextTextPassword" />

View File

@ -6,13 +6,14 @@
android:layout_height="120dp"> android:layout_height="120dp">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/commodityLayout2"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:background="@drawable/shape"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:background="@drawable/shape"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
@ -25,10 +26,10 @@
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:src="@drawable/avatar"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent" />
android:src="@drawable/avatar" />
<TextView <TextView
android:id="@+id/textView19" android:id="@+id/textView19"

View File

@ -21,8 +21,8 @@
<ImageView <ImageView
android:id="@+id/imageView7" android:id="@+id/imageView7"
android:layout_width="wrap_content" android:layout_width="110dp"
android:layout_height="wrap_content" android:layout_height="110dp"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"

View File

@ -14,14 +14,16 @@
android:layout_height="match_parent"> android:layout_height="match_parent">
<com.scwang.smart.refresh.layout.SmartRefreshLayout <com.scwang.smart.refresh.layout.SmartRefreshLayout
android:layout_width="409dp" android:id="@+id/smartLayout2"
android:layout_height="729dp" android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"> app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycleView2" android:id="@+id/recyclerView2"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
</com.scwang.smart.refresh.layout.SmartRefreshLayout> </com.scwang.smart.refresh.layout.SmartRefreshLayout>

View File

@ -52,7 +52,7 @@
app:layout_constraintTop_toBottomOf="@+id/constraintLayout7" /> app:layout_constraintTop_toBottomOf="@+id/constraintLayout7" />
<com.scwang.smart.refresh.layout.SmartRefreshLayout <com.scwang.smart.refresh.layout.SmartRefreshLayout
android:id="@+id/smarlayout" android:id="@+id/smartLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
@ -61,7 +61,7 @@
app:layout_constraintTop_toBottomOf="@+id/spinner"> app:layout_constraintTop_toBottomOf="@+id/spinner">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycleView" android:id="@+id/recyclerView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
</com.scwang.smart.refresh.layout.SmartRefreshLayout> </com.scwang.smart.refresh.layout.SmartRefreshLayout>

View File

@ -14,8 +14,16 @@
android:id="@+id/button7" android:id="@+id/button7"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Button" android:text="我的发布"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/button10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="我的订单"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/button7" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout> </FrameLayout>

View File

@ -19,7 +19,7 @@
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycleView4" android:id="@+id/recyclerView4"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
</com.scwang.smart.refresh.layout.SmartRefreshLayout> </com.scwang.smart.refresh.layout.SmartRefreshLayout>

View File

@ -19,7 +19,7 @@
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycleView3" android:id="@+id/recyclerView6"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
</com.scwang.smart.refresh.layout.SmartRefreshLayout> </com.scwang.smart.refresh.layout.SmartRefreshLayout>

View File

@ -19,7 +19,7 @@
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycleView4" android:id="@+id/recyclerView4"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
</com.scwang.smart.refresh.layout.SmartRefreshLayout> </com.scwang.smart.refresh.layout.SmartRefreshLayout>

View File

@ -6,6 +6,7 @@
android:layout_height="160dp"> android:layout_height="160dp">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayout3"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"

View File

@ -2,8 +2,8 @@
<resources> <resources>
<string-array name="spinner"> <string-array name="spinner">
<item>全部</item> <item>全部</item>
<item>上海</item> <item>运动用品</item>
<item>天津</item> <item>书籍</item>
<item>深圳</item> <item>深圳</item>
</string-array> </string-array>
</resources> </resources>