消息闪退问题

master
fangshicai 3 years ago
parent 61ac6b0f2c
commit 652af3cdca

Binary file not shown.

@ -0,0 +1,20 @@
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.android",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 1,
"versionName": "1.0",
"outputFile": "app-release.apk"
}
],
"elementType": "File"
}

@ -17,6 +17,7 @@ import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import com.android.R; import com.android.R;
import com.android.bean.Good; import com.android.bean.Good;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -77,6 +78,8 @@ public class StaggerAdapter extends RecyclerView.Adapter<StaggerAdapter.InnerHol
Glide.with(context) Glide.with(context)
.load(imageUrl) .load(imageUrl)
// .skipMemoryCache(true)//开启内容缓存
// .diskCacheStrategy(DiskCacheStrategy.NONE)//设置磁盘缓存模式:
.into(holder.getIvGoods()); .into(holder.getIvGoods());
} }
} }

@ -39,12 +39,19 @@ public class UserRecordsAdapter extends RecyclerView.Adapter<UserRecordsAdapter.
@Override @Override
public void onBindViewHolder(@NonNull UserRecordsAdapterHolder holder, int position) { public void onBindViewHolder(@NonNull UserRecordsAdapterHolder holder, int position) {
SimpleDateFormat sdf=new SimpleDateFormat("yyyy 年 MM 月 dd 日 HH 时 mm 分 ss 秒"); Date date=new Date();
String sd = sdf.format(new Date(Long.parseLong(String.valueOf(recordsData.getRecords().get(position).getCreateTime())))); // 时间戳转换成时间 date.setTime(recordsData.getRecords().get(position).getCreateTime()+ 8 * 60 * 60 * 1000);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String fmDate=simpleDateFormat.format(date);
Log.e("1",String.valueOf(recordsData.getRecords().get(position).getCreateTime()));
Log.e("1",fmDate);
Log.e("1",String.valueOf(recordsData.getRecords().get(position).getSellerId()));
Log.e("1",String.valueOf(userId));
if (recordsData.getRecords().get(position).getSellerId() == userId){ if (recordsData.getRecords().get(position).getSellerId() == userId){
holder.getTvName().setText("当前用户发布了:"+recordsData.getRecords().get(position).getGoodsDescription()+" "+sd); holder.getTvName().setText("当前用户商品被购买了:"+recordsData.getRecords().get(position).getGoodsDescription()+" "+fmDate);
}else { }else {
holder.getTvName().setText("当前用户购买了: "+recordsData.getRecords().get(position).getGoodsDescription()+" "+sd); holder.getTvName().setText("当前用户购买了: "+recordsData.getRecords().get(position).getGoodsDescription()+" "+fmDate);
} }
} }

@ -95,17 +95,11 @@ public class HomePageFragment extends Fragment implements View.OnClickListener,
goodsModelimpl = new GoodsModelimpl(); goodsModelimpl = new GoodsModelimpl();
} }
Map<String, Object> map = new HashMap<>(); // Map<String, Object> map = new HashMap<>();
goodsModelimpl.getAllGoodsType(this); goodsModelimpl.getAllGoodsType(this);
Log.e("1",String.valueOf(user.getId()));
//发送获取用户交易记录 //发送获取用户交易记录
goodsModelimpl.getUserRecords(user.getId(),map,this); // goodsModelimpl.getUserRecords(user.getId(),map,this);
// new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
// initRecyclerview();
//
// }
// },2000);
} }
@ -131,7 +125,7 @@ public class HomePageFragment extends Fragment implements View.OnClickListener,
@Override @Override
public void onGetUserRecordsSuccess(ResponseData<BaseRecords<UserGoodsRecords>> responseData) { public void onGetUserRecordsSuccess(ResponseData<BaseRecords<UserGoodsRecords>> responseData) {
//通过EventBus传输用户的交易记录 //通过EventBus传输用户的交易记录
EventBus.getDefault().postSticky(responseData.getData()); // EventBus.getDefault().postSticky(responseData.getData());
} }
private void initRecyclerview() { private void initRecyclerview() {

@ -14,26 +14,35 @@ import android.view.ViewGroup;
import com.android.R; import com.android.R;
import com.android.activity.adapter.UserRecordsAdapter; import com.android.activity.adapter.UserRecordsAdapter;
import com.android.bean.BaseRecords; import com.android.bean.BaseRecords;
import com.android.bean.GoodRecords;
import com.android.bean.GoodsType;
import com.android.bean.ResponseData; import com.android.bean.ResponseData;
import com.android.bean.User; import com.android.bean.User;
import com.android.bean.queryBean.UserGoodsRecords; import com.android.bean.queryBean.UserGoodsRecords;
import com.android.model.goods.GoodsListener;
import com.android.model.goods.GoodsModelimpl;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode; import org.greenrobot.eventbus.ThreadMode;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
* Use the {@link MessagePageFragment#newInstance} factory method to * Use the {@link MessagePageFragment#newInstance} factory method to
* create an instance of this fragment. * create an instance of this fragment.
*/ */
public class MessagePageFragment extends Fragment{ public class MessagePageFragment extends Fragment implements GoodsListener {
BaseRecords<UserGoodsRecords> recordsData; BaseRecords<UserGoodsRecords> recordsData;
private View view; private View view;
private RecyclerView recyclerView; private RecyclerView recyclerView;
private UserRecordsAdapter userRecordsAdapter; private UserRecordsAdapter userRecordsAdapter;
private User user; private User user;
private GoodsModelimpl modelimpl;
public MessagePageFragment() { public MessagePageFragment() {
@ -61,11 +70,11 @@ public class MessagePageFragment extends Fragment{
super.onDestroy(); super.onDestroy();
} }
//获取用户交易记录 // //获取用户交易记录
@Subscribe(threadMode = ThreadMode.MAIN,sticky = true) // @Subscribe(threadMode = ThreadMode.MAIN,sticky = true)
public void getUserGoodsRecords(BaseRecords<UserGoodsRecords> recordsData){ // public void getUserGoodsRecords(BaseRecords<UserGoodsRecords> recordsData){
this.recordsData = recordsData; // this.recordsData = recordsData;
} // }
//获取当前用户信息 //获取当前用户信息
@Subscribe(threadMode = ThreadMode.MAIN,sticky = true) @Subscribe(threadMode = ThreadMode.MAIN,sticky = true)
@ -78,9 +87,13 @@ public class MessagePageFragment extends Fragment{
Bundle savedInstanceState) { Bundle savedInstanceState) {
// Inflate the layout for this fragment // Inflate the layout for this fragment
view = inflater.inflate(R.layout.fragment_message_page, container, false); view = inflater.inflate(R.layout.fragment_message_page, container, false);
Log.e("MessagePageFragment",recordsData.getSize().toString());
initView(); modelimpl = new GoodsModelimpl();
Log.e("11111",String.valueOf(user.getId()));
Map<String, Object> map = new HashMap<>();
// map.put("size",10);
modelimpl.getUserRecords(user.getId(),map,this);
return view; return view;
} }
@ -99,4 +112,22 @@ public class MessagePageFragment extends Fragment{
} }
} }
@Override
public void onGetAllGoodsType(ResponseData<List<GoodsType>> responseData) {
}
@Override
public void onGetAllGoodSuccess(ResponseData<GoodRecords> responseData) {
}
@Override
public void onGetUserRecordsSuccess(ResponseData<BaseRecords<UserGoodsRecords>> recordsData) {
this.recordsData = recordsData.getData();
Log.e("MessagePageFragment",this.recordsData.getSize().toString());
initView();
}
} }

@ -137,6 +137,8 @@ public class PublishProductFragment extends Fragment implements View.OnClickList
if (imageBean == null){ if (imageBean == null){
ToastUtil.showMsg(getActivity(),"请先上传图片"); ToastUtil.showMsg(getActivity(),"请先上传图片");
return; return;
}else {
ToastUtil.showMsg(getActivity(),"上传图片成功");
} }
goods.setImageCode(imageBean.getImageCode()); goods.setImageCode(imageBean.getImageCode());

@ -21,24 +21,24 @@ import retrofit2.http.QueryMap;
public interface GoodsHttp_interface { public interface GoodsHttp_interface {
@GET("tran/goods/type") @GET("tran/goods/type")
@Headers({"appId:e843562fefa144bf808a9621b107b3a4", @Headers({"appId:b34ac21286ae45938add627b418a4871",
"appSecret:76387a99d8b52fad54b94bea1118262573381"}) "appSecret:67526def9de11d4a64f5e80e60ed3372eea69"})
Observable<ResponseData<List<GoodsType>>> sendGetAllGoodsType(); Observable<ResponseData<List<GoodsType>>> sendGetAllGoodsType();
@GET("tran/goods/all") @GET("tran/goods/all")
@Headers({"appId:e843562fefa144bf808a9621b107b3a4", @Headers({"appId:b34ac21286ae45938add627b418a4871",
"appSecret:76387a99d8b52fad54b94bea1118262573381"}) "appSecret:67526def9de11d4a64f5e80e60ed3372eea69"})
Observable<ResponseData<GoodRecords>> sendGetAllGood(@Query("userId") Long userId, Observable<ResponseData<GoodRecords>> sendGetAllGood(@Query("userId") Long userId,
@QueryMap Map<String, Object> map @QueryMap Map<String, Object> map
); );
@GET("tran/trading/buy") @GET("tran/trading/buy")
@Headers({"appId:e843562fefa144bf808a9621b107b3a4", @Headers({"appId:b34ac21286ae45938add627b418a4871",
"appSecret:76387a99d8b52fad54b94bea1118262573381"}) "appSecret:67526def9de11d4a64f5e80e60ed3372eea69"})
Observable<ResponseData<BaseRecords<UserGoodsRecords>>> sendUserBuyGoods(@Query("userId") Long userId, Observable<ResponseData<BaseRecords<UserGoodsRecords>>> sendUserBuyGoods(@Query("userId") Long userId,
@QueryMap Map<String, Object> map); @QueryMap Map<String, Object> map);
@GET("tran/trading/records") @GET("tran/trading/records")
@Headers({"appId:e843562fefa144bf808a9621b107b3a4", @Headers({"appId:b34ac21286ae45938add627b418a4871",
"appSecret:76387a99d8b52fad54b94bea1118262573381"}) "appSecret:67526def9de11d4a64f5e80e60ed3372eea69"})
Observable<ResponseData<BaseRecords<UserGoodsRecords>>> sendUserRecords(@Query("userId") Long userId, Observable<ResponseData<BaseRecords<UserGoodsRecords>>> sendUserRecords(@Query("userId") Long userId,
@QueryMap Map<String, Object> map); @QueryMap Map<String, Object> map);

@ -144,7 +144,6 @@ public class GoodsModelimpl implements GoodsModel{
@Override @Override
public void onNext(@NonNull ResponseData<BaseRecords<UserGoodsRecords>> baseRecordsResponseData) { public void onNext(@NonNull ResponseData<BaseRecords<UserGoodsRecords>> baseRecordsResponseData) {
goodsListener.onGetUserRecordsSuccess(baseRecordsResponseData); goodsListener.onGetUserRecordsSuccess(baseRecordsResponseData);
} }
@Override @Override

@ -18,19 +18,19 @@ import retrofit2.http.Query;
public interface longinHttp_Interface { public interface longinHttp_Interface {
//登录 //登录
@POST("tran/user/login") @POST("tran/user/login")
@Headers({"appId:e843562fefa144bf808a9621b107b3a4", @Headers({"appId:b34ac21286ae45938add627b418a4871",
"appSecret:76387a99d8b52fad54b94bea1118262573381"}) "appSecret:67526def9de11d4a64f5e80e60ed3372eea69"})
Observable<ResponseData<User>> login(@Body User user); Observable<ResponseData<User>> login(@Body User user);
//获取验证码 //获取验证码
@GET("tran/user/send") @GET("tran/user/send")
@Headers({"appId:e843562fefa144bf808a9621b107b3a4", @Headers({"appId:b34ac21286ae45938add627b418a4871",
"appSecret:76387a99d8b52fad54b94bea1118262573381"}) "appSecret:67526def9de11d4a64f5e80e60ed3372eea69"})
Observable<ResponseData<String>> sendCode(@Query("phone") String phone); Observable<ResponseData<String>> sendCode(@Query("phone") String phone);
@POST("tran/user/register") @POST("tran/user/register")
@Headers({"appId:e843562fefa144bf808a9621b107b3a4", @Headers({"appId:b34ac21286ae45938add627b418a4871",
"appSecret:76387a99d8b52fad54b94bea1118262573381"}) "appSecret:67526def9de11d4a64f5e80e60ed3372eea69"})
Observable<ResponseData<String>> register(@Body User user); Observable<ResponseData<String>> register(@Body User user);

@ -15,8 +15,8 @@ import retrofit2.http.Query;
public interface Purchase_interface { public interface Purchase_interface {
@FormUrlEncoded @FormUrlEncoded
@POST("tran/trading") @POST("tran/trading")
@Headers({"appId:e843562fefa144bf808a9621b107b3a4", @Headers({"appId:b34ac21286ae45938add627b418a4871",
"appSecret:76387a99d8b52fad54b94bea1118262573381"}) "appSecret:67526def9de11d4a64f5e80e60ed3372eea69"})
Observable<ResponseData<String>> sendTrading(@Field("buyerId") Long buyerId, Observable<ResponseData<String>> sendTrading(@Field("buyerId") Long buyerId,
@Field("goodsId") Long goodsId, @Field("goodsId") Long goodsId,
@Field("price") Integer price, @Field("price") Integer price,

@ -18,13 +18,13 @@ import retrofit2.http.Part;
public interface UpHttp_interface { public interface UpHttp_interface {
@Multipart @Multipart
@POST("tran/image/upload") @POST("tran/image/upload")
@Headers({"appId:e843562fefa144bf808a9621b107b3a4", @Headers({"appId:b34ac21286ae45938add627b418a4871",
"appSecret:76387a99d8b52fad54b94bea1118262573381"}) "appSecret:67526def9de11d4a64f5e80e60ed3372eea69"})
Observable<ResponseData<ImageBean>> sendUpImage(@Part List<MultipartBody.Part> fileList); Observable<ResponseData<ImageBean>> sendUpImage(@Part List<MultipartBody.Part> fileList);
@POST("tran/goods/add") @POST("tran/goods/add")
@Headers({"appId:e843562fefa144bf808a9621b107b3a4", @Headers({"appId:b34ac21286ae45938add627b418a4871",
"appSecret:76387a99d8b52fad54b94bea1118262573381"}) "appSecret:67526def9de11d4a64f5e80e60ed3372eea69"})
Observable<ResponseData<Good>> sendAddGoods(@Body Good goods); Observable<ResponseData<Good>> sendAddGoods(@Body Good goods);
} }

@ -5,6 +5,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:padding="8dp" android:padding="8dp"
android:background="@color/tag_bg"
tools:context=".activity.LoginActivity"> tools:context=".activity.LoginActivity">
<!-- 登录的图标--> <!-- 登录的图标-->
@ -64,6 +65,7 @@
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:hint="验证码"> android:hint="验证码">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
@ -105,15 +107,17 @@
style="@style/Widget.Material3.Button.ElevatedButton" style="@style/Widget.Material3.Button.ElevatedButton"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="210dp"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginEnd="210dp"
android:text="登录" android:text="登录"
android:textColor="@color/orange"
android:textSize="24sp" /> android:textSize="24sp" />
<Button <Button
android:id="@+id/bt_register" android:id="@+id/bt_register"
style="@style/Widget.Material3.Button.ElevatedButton" style="@style/Widget.Material3.Button.ElevatedButton"
android:layout_width="match_parent" android:layout_width="match_parent"
android:textColor="@color/orange"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="210dp" android:layout_marginStart="210dp"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"

@ -16,3 +16,5 @@ dependencyResolutionManagement {
} }
rootProject.name = "Android_Couser_Design" rootProject.name = "Android_Couser_Design"
include ':app' include ':app'

Loading…
Cancel
Save