Api Service Interface
class GETAGREEREPORT extends AsyncTask {
String Content = null;
private ProgressDialog dialog = new ProgressDialog(context);
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
dialog = ProgressDialog.show(context,
"Please wait", "Please wait while we getting details", true);
dialog.show();
}
@Override
protected String doInBackground(String... params) {
try {
String url = APIUrl.BASE_URL_CANE_DEVELOPMENT + "/GetEmployeeSalesReport";
HttpClient httpClient = new DefaultHttpClient();
List entity = new LinkedList();
entity.add(new BasicNameValuePair("sup", params[0]));// 22001 // 2
entity.add(new BasicNameValuePair("Fdate",params[1]));//2022-05-06
entity.add(new BasicNameValuePair("Tdate",params[2]));//2023-05-06
HttpPost httpPost = new HttpPost(url);
httpPost.setHeader(HTTP.CONTENT_TYPE, "application/x-www-form-urlencoded");
httpPost.setEntity(new UrlEncodedFormEntity(entity, "utf-8"));
ResponseHandler responseHandler = new BasicResponseHandler();
Content = httpClient.execute(httpPost, responseHandler);
System.out.println("sdfsdsd : " + Content);
} catch (Exception e) {
if (dialog.isShowing())
dialog.dismiss();
}
return null;
}
@Override
protected void onPostExecute(String sResponse) {
try {
if(agriInputList.size()>0)
agriInputList.clear();
if (dialog.isShowing())
dialog.dismiss();
JSONObject jsonObject = new JSONObject(Content);
if (jsonObject.getString("API_STATUS").equalsIgnoreCase("OK")) {
JSONArray jsonArray = jsonObject.getJSONArray("DATA");
JSONObject object = jsonArray.getJSONObject(0);
Iterator keys = object.keys();
ArrayList stringsKey = new ArrayList<>();
ArrayList stringsvalue = new ArrayList<>();
while (keys.hasNext()) {
String key = keys.next();
String value = object.getString(key);
stringsKey.add(key);
}
date = stringsKey.get(0).toString(); //>>
villageCode = stringsKey.get(1).toString(); //>>
vilageName = stringsKey.get(2).toString(); //>
grocode = stringsKey.get(3).toString(); //>
growerName = stringsKey.get(4).toString(); //>
bleachingP = stringsKey.get(5).toString(); //>
TrichoP = stringsKey.get(6).toString(); //>>
TrichoL = stringsKey.get(7).toString(); //>
emida = stringsKey.get(8).toString(); //>
corajen = stringsKey.get(9).toString(); //>
hexa = stringsKey.get(10).toString(); //>
ferrous = stringsKey.get(11).toString(); //>
date1.setText("Date");//date
vilageName1.setText("Village Name");//vilageName
growerName1.setText("Grower Name");//growerName
bleachingP1.setText(bleachingP);
hexa1.setText(hexa);
TrichoP1.setText(TrichoP);
TrichoL1.setText(TrichoL);
emida1.setText(emida);
corajen1.setText(corajen);
ferrous1.setText(ferrous);
/* JSONObject jsonObj = new JSONObject(result);
Iterator -String- keys = jsonObj.keys();
while (keys.hasNext()) {
String key = keys.next();
String value = jsonObj.getString(key);
Log.d("JSON", "Key: " + key + ", Value: " + value);
JSONObject jsonObject = new JSONObject(jsonString);
StringBuilder stringBuilder = new StringBuilder();
Iterator -String- keys = jsonObject.keys();
while(keys.hasNext()) {
String key = keys.next();
String value = jsonObject.getString(key);
stringBuilder.append(key).append(": ").append(value).append("\n");
}*/
for (int i = 0; i < jsonArray.length(); i++) {
object = jsonArray.getJSONObject(i);
AgriInput model = new AgriInput();
model.setDate(object.getString(date));//DATE
model.setVillCode(object.getString(villageCode));//VILLCODE
model.setVillName(object.getString(vilageName));//VILLNAME
model.setGroCode(object.getString(grocode));//GROCODE
model.setGroName(object.getString(growerName));//GRONAME
model.setBleachingPowder(object.getString(bleachingP));//Bleaching Powder @ 384.00
model.setTrichormePowder(object.getString(TrichoP));//Trichoderma Power @ 76.16
model.setTrichormeLiquid(object.getString(TrichoL));//Trichoderma Liquid @ 208.00
model.setEmida(object.getString(emida));//Emida 100 ml @ 145.00
model.setCorajen(object.getString(corajen));//Corajen @ 1750.00
model.setFerrosSulphate(object.getString(ferrous));//Ferrous Sulphate @ 150.00
model.setHexaStop(object.getString(hexa));//Hexastop @ 97.00
agriInputList.add(model);
}
linearReport.setVisibility(View.VISIBLE);
RecyclerView recyclerView = findViewById(R.id.agriInputRecycler);
AgreeInpuAdapter adapter = new AgreeInpuAdapter(context, agriInputList);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(context, RecyclerView.VERTICAL, false));
recyclerView.setAdapter(adapter);
}
else {
linearReport.setVisibility(View.GONE);
new AlertDialogManager().RedDialog(context, "" +Content.toString());
}
} catch (JSONException e) {
System.out.println("Error : " + Content);
Log.e(e.getClass().getName(), e.getMessage(), e);
new AlertDialogManager().RedDialog(context,Content);
linearReport.setVisibility(View.GONE);
RecyclerView recyclerView = findViewById(R.id.agriInputRecycler);
AgreeInpuAdapter adapter = new AgreeInpuAdapter(context, agriInputList);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(context, RecyclerView.VERTICAL, false));
recyclerView.setAdapter(adapter);
} catch(Exception e){
if (dialog.isShowing())
dialog.dismiss();
linearReport.setVisibility(View.GONE);
System.out.println("Error : " + e.toString());
Log.e(e.getClass().getName(), e.getMessage(), e);
new AlertDialogManager().RedDialog(context, "Error :- " + e.getClass().getName() + " - " + e.getMessage());
}
}
}
Api Service Interface
Api Service Interface
Api Service Interface
Api Service Interface
Api Service Interface