private void loadFrieghtData() {
progressLoader.startProgress(Frieght_Details.this);
RequestQueue queue = Volley.newRequestQueue(Frieght_Details.this);
StringRequest stringRequest = new StringRequest(Request.Method.POST, UrlConstant.FRIEGHT_DETAILS,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jsonObject = new JSONObject(response);
String status = jsonObject.optString("status");
if (status.equals("1")){
JSONArray jsonArray = jsonObject.getJSONArray("data");
for (int i =0 ; i< jsonArray.length(); i++){
JSONObject jsonObject1 = jsonArray.getJSONObject(i);
dialogPOJO leftDashboardPOJO = new dialogPOJO(jsonObject1.optString("id"),
jsonObject1.optString("date"), jsonObject1.optString("credit"),
jsonObject1.optString("confirm_status"));
leftDashboardPOJOSList.add(leftDashboardPOJO);
}
progressLoader.dismissProgress(Frieght_Details.this);
millWiseReportRecyclerView.setAdapter(FrieghtAdapterPOJO);
FrieghtAdapterPOJO.notifyDataSetChanged();
System.out.println("SOMETHING DATA " + response.toString());
}else {
progressLoader.dismissProgress(Frieght_Details.this);
Toast.makeText(Frieght_Details.this, "Something Went Wrong", Toast.LENGTH_SHORT).show();
}
}catch (JSONException e){
progressLoader.dismissProgress(Frieght_Details.this);
System.out.println("paramsparamsparams===" + e.toString());
Toast.makeText(Frieght_Details.this, e.toString(), Toast.LENGTH_SHORT).show();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
progressLoader.dismissProgress(Frieght_Details.this);
System.out.println("paramsparamsparams===" + error.toString());
Toast.makeText(Frieght_Details.this, error.toString(), Toast.LENGTH_SHORT).show();
}
}){
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
{
/* params.put("user_id", prefManager.getGSTstate());
params.put("godown_id", prefManager.getGodownlocation()); */
params.put("godown_id", "3");
params.put("user_id", "dddd");
params.put("vehicle", "2");
}
System.out.println("paramsparamsparams===" + params.toString());
return params;
}
};
stringRequest.setRetryPolicy(new DefaultRetryPolicy(
DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 8,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
queue.add(stringRequest);
}
This is my Main Method Code
public class FreightAdapter extends RecyclerView.Adapter<FreightAdapter.ViewHolder> {
private List<dialogPOJO> list_data;
private Frieght_Details context;
private PrefManager prefManager;
public FreightAdapter(List<dialogPOJO> list_data, Frieght_Details context) {
this.list_data = list_data;
this.context = context;
prefManager = new PrefManager(context);
}
@Override
public FreightAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.frieght_wiseadapterlayout,parent,false);
return new FreightAdapter.ViewHolder(view);
}
@Override
public void onBindViewHolder(FreightAdapter.ViewHolder holder, int position) {
final dialogPOJO lenaDenaPOJO = list_data.get(position);
if (position %2 == 1){
holder.linearLayout_data.setBackgroundColor(context.getResources().getColor(R.color.white));
}else {
holder.linearLayout_data.setBackgroundColor(context.getResources().getColor(R.color.colorGrey));
}
String countString = lenaDenaPOJO.getCount();
holder.ordernumber.setText( countString );
holder.ordernumber1.setText( lenaDenaPOJO.getKey());
String truck_id = lenaDenaPOJO.getReports();
String vehicle_status = lenaDenaPOJO.getVehicleStatus();
System.out.println("VEHICLE_VALE " + vehicle_status + " " + truck_id + " " + countString);
holder.frieght.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
context.callDialogMethod(countString);
}
});
holder.actionOK.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
context.CallOkStatus(vehicle_status, countString, truck_id);
}
});
}
@Override
public int getItemCount() {
return list_data.size();
}
public class ViewHolder extends RecyclerView.ViewHolder{
private TextView ordernumber, ordernumber1, frieght, actionOK;
private Button view_Reports;
private LinearLayout linearLayout_data;
public ViewHolder(View itemView) {
super(itemView);
ordernumber = itemView.findViewById(R.id.pro_name);
ordernumber1 = itemView.findViewById(R.id.frieght);
frieght = itemView.findViewById(R.id.total_qty);
actionOK = itemView.findViewById(R.id.actionOK);
linearLayout_data = itemView.findViewById(R.id.linearLayout_data);
}
}
}
Here are logs
I/System.out: SOMETHING DATA
{"status":1,"data":[{"id":2876,"credit":1500,"confirm_status":1,"date":"01-01-2021"},{"id":2919,"credit":1900,"confirm_status":1,"date":"02-01-2021"},{"id":2933,"credit":2050,"confirm_status":1,"date":"04-01-2021"},{"id":2964,"credit":3500,"confirm_status":1,"date":"05-01-2021"},{"id":3004,"credit":2450,"confirm_status":1,"date":"06-01-2021"}
And This is my Adapter Code I can't understand What is wrong in this.
Please Help me in this case
I have added image for more details,
When I call Activity First Time it works Perfectly But If call onResume method then There is no data added on Recycler view I can't understand what get wrong in my code
question from:
https://stackoverflow.com/questions/65842572/recycler-view-is-showing-blank-screen-after-resuming-the-activity