private class Task_xmlparse extends AsyncTask { private final ProgressDialog dialog = new ProgressDialog(BlackSheepimage.this); protected void onPreExecute() { this.dialog.setMessage("Loading..."); this.dialog.setCancelable(false); this.dialog.show(); }
@Override
protected Void doInBackground(String... params)
{
try {
DomFeedParser dom = new DomFeedParser(url);
Log.v("thread"," "+url);
List<Message_thbnail> l_obj_tnail = new ArrayList<Message_thbnail>();
List<Message_zoom> l_obj_zoom = new ArrayList<Message_zoom>();
l_obj_tnail = dom.parse_tnail();
l_obj_zoom = dom.parse_zoom();
VAL1 = new String[l_obj_tnail.size()];
VAL2= new String[l_obj_zoom.size()];
//Log.v("bufersize",""+bufferarray.length);
//Log.v("val2Length",""+VAL1.length);
Iterator<Message_thbnail> it_tnail = l_obj_tnail.iterator();
while (it_tnail.hasNext())
{
k++;
Log.v("Zoo",""+zo);
VAL1[k] = it_tnail.next().toString();
bufferarray[zo]=VAL1[k];
Log.v("Buffer",bufferarray[zo]);
zo++;
}
Log.v("threadbuffsize",""+zo);
Iterator<Message_zoom> it_zoom = l_obj_zoom.iterator();
Log.v("zoosize", ""+l_obj_zoom.size());
while (it_zoom.hasNext()) {
k1++;
Log.v("Zoo1",""+zo1);
VAL2[k1] = it_zoom.next().toString();
zoombufferarray[zo1]=VAL2[k1];
zo1++;
Log.v("tag",VAL2[k1].toString());
}
thumbnail_disp=bufferarray;
grid= new GridAdapter(BlackSheepimage.this,bufferarray);
} catch (Exception e) {
//Log.v("Image", "dom" + e);
}
return null;
}
protected void onPostExecute(Void result) {
lay2_gv.setAdapter(grid);
if (this.dialog.isShowing()) {
this.dialog.dismiss();
}
}
}
public void onCreate(Bundle savedInstanceState) { url="http://www.theblacksheeponline.com/partypics.php?page="+pageno; super.onCreate(savedInstanceState); lay2_gv = (GridView) findViewById(R.id.jr_lookbook_grid); new Task_xmlparse().execute(url); tv = (TextView) findViewById(R.id.next_pg); tv.setOnClickListener(this) ; lay2_gv.setOnItemClickListener(this); } public void onClick(View arg0) {
pageno++;
Log.v("pge",""+pageno);
lay2_gv.setVisibility(GridView.GONE);
url="http://www.theblacksheeponline.com/partypics.php?page="+pageno;
//Log.v("URL",url);
new Task_xmlparse().execute(url);
}