mercredi 25 juin 2014

Get the data from array list from onPost execute method of async task


Vote count:

0




I am using asynck task to get the json and parse it.The value of parsed json i am storing it in ArrayList. Now what i want is that i want to us this Arraylist in different class.I have made a method getList() to get the arraylist but there i m getting null value


Async Class



public class SearchJobAsync extends AsyncTask<String, String, String> {
private String response;
Context c;
SearchModel data;
ArrayList<Search> values;

public SearchJobAsync(Context c) {
this.c = c;
}

public SearchJobAsync(Context c, ArrayList<SearchModel> values) {
this.c = c;
this.values = values;
}

@Override
protected void onPreExecute() {
super.onPreExecute ();
CommonFunctions.showProgress (c, "Please Wait...", true);

}

@Override
protected void onPostExecute(String s) {
values = new ArrayList<SearchModel> ();

super.onPostExecute (s);
if (!s.trim ().contains ("Table")) {
Crouton.makeText ((android.app.Activity) c, "Nothing found", Style.INFO).show ();
} else {
try {

JSONObject jsonObject = new JSONObject (s);
JSONObject NewDataSet = jsonObject.getJSONObject ("NewDataSet");
if (NewDataSet.get ("Table") instanceof JSONObject) {
JSONObject table = NewDataSet.getJSONObject ("Table");
data = new SearchModel (table.getString ("Job_Category"), table.getString ("Min_Exp"), table.getString ("Max_Exp"), table.getString ("Posted_On"), table.getString ("Candidate_Counts"), table.getString ("Applications"), table.getString ("No_Of_Pos"), table.getString ("Job_Desc"), table.getString ("Job_Type"), table.getString ("Job_Hours"), table.getString ("Job_Status"), table.getString ("Job_Exp_Date"), table.getString ("Address"), table.getString ("Gender_Name"), table.getString ("Religion_Name"), table.getString ("Exp_Summary"), table.getString ("IJob_Request_ID"), table.getString ("Requestor_Name"));
values.add (data);
} else if (NewDataSet.get ("Table") instanceof JSONArray) {
JSONArray tableArray = NewDataSet.getJSONArray ("Table");

for (int i = 0; i < tableArray.length (); i++) {
JSONObject table = tableArray.getJSONObject (i);
data = new SearchModel (table.getString ("Job_Category"), table.getString ("Min_Exp"), table.getString ("Max_Exp"), table.getString ("Posted_On"), table.getString ("Candidate_Counts"), table.getString ("Applications"), table.getString ("No_Of_Pos"), table.getString ("Job_Desc"), table.getString ("Job_Type"), table.getString ("Job_Hours"), table.getString ("Job_Status"), table.getString ("Job_Exp_Date"), table.getString ("Address"), table.getString ("Gender_Name"), table.getString ("Religion_Name"), table.getString ("Exp_Summary"), table.getString ("IJob_Request_ID"), table.getString ("Requestor_Name"));
values.add (data);

}

}


} catch (JSONException e) {
e.printStackTrace ();
}
}



CommonFunctions.showProgress (c, "", false);
Intent i = new Intent (c, SearchJobListActivity.class);
c.startActivity (i);
}

@Override
protected String doInBackground(String... s) {
response = HttpRequest.post ("http://ift.tt/1pL40TP").send ("Vendor_IEntity_Code=" + "34588A34-E969-4723-84FE-E5409B66A5B7" + "&Job_Code=" + "&Job_Category=1" + "&Exp_Years_From=0" + "&Exp_Months_From=0" + "&Exp_Years_To=0" + "&Exp_Months_To=0").body ();
response = response.replaceAll ("<[^>]*>", "").replaceAll ("\n", "");
Log.e ("Search Jobs", "" + response);
return response;
}

public ArrayList<Search> getList(){
return values;
}
}


now how to get the arrayList????? i was getting the arrylist by making it static ,bt its not the right way.So please help me



asked 53 secs ago






Aucun commentaire:

Enregistrer un commentaire