· 8 years ago · Aug 26, 2018, 08:08 PM
1how to stop loding in efficient adapter on scroll
2package com.shopzilla.android.search;
3
4import java.io.IOException;
5import java.net.MalformedURLException;
6import java.net.URL;
7import java.util.ArrayList;
8import java.util.HashMap;
9import java.util.Locale;
10
11import org.json.JSONObject;
12
13import android.app.Activity;
14import android.app.Dialog;
15import android.app.ProgressDialog;
16import android.content.ContentValues;
17import android.content.Context;
18import android.content.Intent;
19import android.database.sqlite.SQLiteDatabase;
20import android.graphics.Bitmap;
21import android.graphics.BitmapFactory;
22import android.graphics.Color;
23import android.net.ConnectivityManager;
24import android.net.NetworkInfo;
25import android.os.Bundle;
26import android.os.Handler;
27import android.os.Message;
28import android.view.Display;
29import android.view.LayoutInflater;
30import android.view.View;
31import android.view.ViewGroup;
32import android.view.WindowManager;
33import android.widget.AdapterView;
34import android.widget.AdapterView.OnItemClickListener;
35import android.widget.ArrayAdapter;
36import android.widget.BaseAdapter;
37import android.widget.Button;
38import android.widget.EditText;
39import android.widget.ImageButton;
40import android.widget.ImageView;
41import android.widget.LinearLayout;
42import android.widget.ListView;
43import android.widget.TextView;
44import android.widget.Toast;
45
46import com.flurry.android.FlurryAgent;
47import com.shopzilla.android.common.R;
48import com.shopzilla.android.parsing.SearchResult_Json;
49import com.shopzilla.android.parsing.Search_Refine_Json;
50import com.shopzilla.android.product.ProductComparisonActivity;
51
52public class SearchResultActivity extends Activity{
53public static String keyword;
54
55public static ArrayList<String> type= new ArrayList<String>();
56public static ArrayList<String> title= new ArrayList<String>();
57public static ArrayList<String> des= new ArrayList<String>();
58public static ArrayList<String> manu= new ArrayList<String>();
59public static ArrayList<String> urls= new ArrayList<String>();
60public static ArrayList<String> image_sm= new ArrayList<String>();
61public static ArrayList<String> image_me= new ArrayList<String>();
62public static ArrayList<String> image_la= new ArrayList<String>();
63public static ArrayList<String> image_ex= new ArrayList<String>();
64public static ArrayList<String> rel= new ArrayList<String>();
65public static ArrayList<String> id= new ArrayList<String>();
66public static ArrayList<String> cat_id= new ArrayList<String>();
67public static ArrayList<String> min_price= new ArrayList<String>();
68public static ArrayList<String> max_price= new ArrayList<String>();
69public static ArrayList<String> stores= new ArrayList<String>();
70public static ArrayList<String> rating= new ArrayList<String>();
71
72
73public static ArrayList<String> offer_sku = new ArrayList<String>();
74public static ArrayList<String> offer_detailurl = new ArrayList<String>();
75public static ArrayList<String> offer_price = new ArrayList<String>();
76public static ArrayList<String> offer_ori_price = new ArrayList<String>();
77public static ArrayList<String> offer_markdownperct = new ArrayList<String>();
78public static ArrayList<String> offer_shipcost = new ArrayList<String>();
79public static ArrayList<String> offer_tax = new ArrayList<String>();
80public static ArrayList<String> offer_total_price = new ArrayList<String>();
81public static ArrayList<String> offer_bidded = new ArrayList<String>();
82public static ArrayList<String> offer_merchant_prod_id = new ArrayList<String>();
83public static ArrayList<String> offer_merchant_name = new ArrayList<String>();
84public static ArrayList<String> offer_merchant_rating_img = new ArrayList<String>();
85public static ArrayList<String> offer_merchant_logo = new ArrayList<String>();
86public static ArrayList<String> offer_condition = new ArrayList<String>();
87public static ArrayList<String> offer_stock = new ArrayList<String>();
88public static ArrayList<String> offer_ship_amt = new ArrayList<String>();
89public static ArrayList<String> offer_ship_type = new ArrayList<String>();
90public static ArrayList<String> offer_id = new ArrayList<String>();
91public static ArrayList<String> offer_cat_id = new ArrayList<String>();
92public static ArrayList<String> offer_merchant_id = new ArrayList<String>();
93public static ArrayList<String> offer_rating = new ArrayList<String>();
94public static ArrayList<String> included_results = new ArrayList<String>();
95public static ArrayList<String> brand_list_load = new ArrayList<String>();
96public static ArrayList<String> store_list_load = new ArrayList<String>();
97public static ArrayList<String> brand_count = new ArrayList<String>();
98public static ArrayList<String> brand_id = new ArrayList<String>();
99public static ArrayList<String> brand_array_list = new ArrayList<String>();
100public static ArrayList<String> store_array_list = new ArrayList<String>();
101public static ArrayList<String> store_count = new ArrayList<String>();
102public static ArrayList<String> store_id = new ArrayList<String>();
103public static ArrayList<String> brand_selected = new ArrayList<String>();
104public static ArrayList<Bitmap> me_image = new ArrayList<Bitmap>();
105EditText et_search;
106public static ArrayList<String> store_selected = new ArrayList<String>();
107ArrayAdapter<String> slected_brand;
108ArrayAdapter<String> slected_store;
109ListView brand_list,store_list;
110public static ArrayAdapter<String> arrayAdapter,storeAdapter, store_new_adapter, brand_new_adapter;
111public static ArrayList<HashMap<String, Object>> mylist;
112public static URL url1;
113public static URL me_url1;
114public static JSONObject price;
115public static Bitmap[] bmp;
116public static Bitmap[] me_bmp;
117public static String prod_type;
118public static String prod_type_offer;
119public static String prod_id;
120public static Boolean type_po;
121public static String str;
122ImageButton _gridImageButton, brand_options_btn,color_options_btn,mat_options_btn;
123SQLiteDatabase db;
124ProgressDialog dialog;
125ProgressDialog pd;
126Dialog dialog_refine;
127Bundle bundle;
128String sugg;
129String temp;
130ListView lv;
131int keycount=0;
132String store_name="";
133String brand_name="";
134String key;
135Display display;
136int width;
137int height;
138View v_url;
139public static int count=0;
140public static String final_keyword;
141public static boolean load = false;
142public static int results = 10;
143public static int start = 0;
144View v;
145@Override
146public void onCreate(Bundle savedInstanceState)
147{
148 super.onCreate(savedInstanceState);
149 display = getWindowManager().getDefaultDisplay();
150 width = display.getWidth();
151 height = display.getHeight();
152 System.out.println("Width===="+width);
153 System.out.println("Height==="+height);
154 //setContentView(R.layout.searchresult);
155
156 if(width<=320 && height<=480)
157 {
158
159 setContentView(R.layout.searchresult);
160 }
161 else
162 {
163 setContentView(R.layout.searchresultlarge);
164 }
165
166 //setContentView(R.layout.searchresult);
167 this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
168
169 v = getLayoutInflater().inflate(R.layout.listfooter, null);
170 if(checkConn(SearchResultActivity.this)==false)
171 {
172 Toast.makeText(this, "Wifi Connection is Unavailable", Toast.LENGTH_SHORT).show();
173 finish();
174 }
175 else
176 {
177 final EditText txt_search = (EditText)findViewById(R.id.txt_search);
178 bundle = getIntent().getExtras();
179 if(count==0)
180 {
181 keyword = bundle.getString("keyword");
182 final_keyword = keyword;
183 }
184
185 if(start == 0)
186 {
187 arraylists_clear();
188 refine_clear();
189 }
190 //Opens or Create a database and Table
191 db = openOrCreateDatabase("recentsearches2.db",SQLiteDatabase.CREATE_IF_NECESSARY,null);
192 db.setVersion(1);
193 db.setLocale(Locale.getDefault());
194 db.setLockingEnabled(true);
195
196
197 final String DATA="create table if not exists new_searchtab1("+"id INTEGER PRIMARY KEY AUTOINCREMENT,"+"search TEXT UNIQUE);";
198 db.execSQL(DATA);
199 //=================End
200
201 if(!keyword.equals(""))
202 {
203 ContentValues values = new ContentValues();
204 if(SearchRefine.checkflag==false)
205 {
206 //values.put("search", temp);
207 }
208 else
209 {
210 values.put("search", keyword);
211 }
212 long id1 = db.insert("new_searchtab1", null, values);
213 System.out.println("Id is"+id1);
214 }
215 db.close();
216
217 System.out.println("DEEPPPP");
218 lv = (ListView)findViewById(R.id.list);
219 //final SearchResult_Json obj = new SearchResult_Json();
220 Button btn_grid = (Button)findViewById(R.id.imgbtn_grid);
221
222 Button btn_refine = (Button)findViewById(R.id.btn_Refinesearch);
223
224
225
226 btn_refine.setOnClickListener(new View.OnClickListener() {
227
228
229 public void onClick(View arg0) {
230 // TODO Auto-generated method stub
231
232 Search_Refine_Json.Json_parsing(keyword);
233 arrayAdapter =new ArrayAdapter<String>(SearchResultActivity.this,R.layout.ref_row, R.id.label, brand_list_load);
234
235
236 storeAdapter = new ArrayAdapter<String>(SearchResultActivity.this,R.layout.ref_row, R.id.label, store_list_load);
237 showDialog(0);
238 }
239 });
240 btn_grid.setOnClickListener(new View.OnClickListener() {
241
242 public void onClick(View arg0) {
243 // TODO Auto-generated method stub
244 //obj.json_parse();
245 Intent intent = new Intent(SearchResultActivity.this,SearchGridActivity.class);//Loads Search Grid Activity.
246 intent.putExtra("keyword",txt_search.getText().toString());
247
248 startActivity(intent);
249
250 }
251 });
252
253
254
255 txt_search.setText(keyword);
256 keyword = keyword.replaceAll(" ", "+");
257
258 System.out.println("The String:"+keyword);
259
260
261 dialog = ProgressDialog.show(this, "BIZRATE",
262
263 "Loading.......", true);
264 final Handler handler = new Handler() {
265
266 public void handleMessage(Message msg) {
267
268 callHereForEff();
269
270
271 }
272 };
273
274 Thread checkUpdate = new Thread() {
275
276 public void run() {
277
278 SearchResult_Json.json_parsing(final_keyword);
279 set_image();
280 dialog.dismiss();
281 handler.sendEmptyMessage(0);
282
283 }
284 };
285 checkUpdate.start();
286
287 //new Progress().execute();
288 //set_image();
289 lv.setCacheColorHint(Color.WHITE);
290 lv.setOnItemClickListener(new OnItemClickListener() {
291
292 public void onItemClick(AdapterView<?> parent,View view,int position,long id1)
293 {
294 //System.out.println("Type="+type.get(position));
295 if(type.get(position).equals("OFFER"))
296 {
297
298 prod_id = id.get(position);
299 System.out.println("Offer Id==================="+prod_id);
300 type_po=true;
301 Intent intent = new Intent(SearchResultActivity.this,ProductComparisonActivity.class);
302 intent.putExtra("prod_type", "true");
303 intent.putExtra("keyword", keyword);
304 intent.putExtra("prod_id", id.get(position));
305 startActivity(intent);
306 }
307 else
308 {
309 prod_id = id.get(position);
310 System.out.println("Product Id==================="+prod_id);
311 type_po=false;
312 Intent intent = new Intent(SearchResultActivity.this,ProductComparisonActivity.class);
313 //intent.putExtra("productType", "SZPID");
314 intent.putExtra("prod_type", "false");
315 intent.putExtra("keyword", keyword);
316 intent.putExtra("prod_id", id.get(position));
317 startActivity(intent);
318 }
319 }
320 });
321
322 txt_search.setOnClickListener(new View.OnClickListener() {
323
324 public void onClick(View arg0) {
325 // TODO Auto-generated method stub
326 Intent intent = new Intent(SearchResultActivity.this,SearchSuggestionActivity.class);
327 startActivity(intent);
328 }
329 });
330
331 //Click on Load More
332 LinearLayout layout = (LinearLayout)v.findViewById(R.id.linear_search);
333 layout.setOnClickListener(new View.OnClickListener() {
334
335 @Override
336 public void onClick(View arg0) {
337 // TODO Auto-generated method stub
338 load = true;
339 start = start + 10;
340 Intent intent = new Intent(SearchResultActivity.this, SearchResultActivity.class);
341 intent.putExtra("keyword", txt_search.getText().toString());
342 startActivity(intent);
343 }
344 });
345
346}
347}
348
349//parsing of image from url
350public static void set_image()
351{
352 bmp = new Bitmap[image_sm.size()];
353 me_bmp = new Bitmap[image_me.size()];
354
355 for(int i=0;i<image_sm.size();i++)
356 {
357 try {
358 url1 = new URL(image_sm.get(i));
359 me_url1 = new URL(image_me.get(i));
360 } catch (MalformedURLException e) {
361 // TODO Auto-generated catch block
362 e.printStackTrace();
363 }
364
365 try {
366 bmp[i] = BitmapFactory.decodeStream(url1.openConnection().getInputStream());
367 me_bmp[i] = BitmapFactory.decodeStream(me_url1.openConnection().getInputStream());
368 me_image.add(me_bmp[i]);
369 } catch (IOException e) {
370 // TODO Auto-generated catch block
371 e.printStackTrace();
372 }
373 }
374
375}
376//Clearing Array list
377public static void arraylists_clear() {
378 // TODO Auto-generated method stub
379 image_sm.clear();
380 type.clear();
381 title.clear();
382 min_price.clear();
383 des.clear();
384 manu.clear();
385 urls.clear();
386 image_me.clear();
387 image_la.clear();
388 image_ex.clear();
389 rel.clear();
390 id.clear();
391 cat_id.clear();
392 min_price.clear();
393 max_price.clear();
394 stores.clear();
395
396 offer_sku.clear();
397 offer_detailurl.clear();
398 offer_price.clear();
399 offer_ori_price.clear();
400 offer_markdownperct.clear();
401 offer_shipcost.clear();
402 offer_tax.clear();
403 offer_total_price.clear();
404 offer_bidded.clear();
405 offer_merchant_prod_id.clear();
406 offer_merchant_name.clear();
407 offer_merchant_rating_img.clear();
408 offer_merchant_logo.clear();
409 offer_condition.clear();
410 offer_stock.clear();
411 offer_ship_amt.clear();
412 offer_ship_type.clear();
413 offer_id.clear();
414 offer_cat_id.clear();
415 offer_merchant_id.clear();
416 offer_rating.clear();
417 included_results.clear();
418
419}
420
421public static void refine_clear()
422{
423 brand_list_load.clear();
424 store_list_load.clear();
425 brand_count.clear();
426 brand_id.clear();
427 brand_array_list.clear();
428 store_array_list.clear();
429 store_count.clear();
430 store_id.clear();
431 brand_selected.clear();
432 store_selected.clear();
433}
434
435protected void callHereForEff() {
436
437 // TODO Auto-generated method stub
438 if(included_results.get(0).equals("0"))
439 {
440 Toast.makeText(SearchResultActivity.this, "There is no results regarding to given search item", Toast.LENGTH_LONG).show();
441 //finish();
442
443 }
444 else
445 {
446 lv.addFooterView(v);
447 lv.setAdapter(new EfficientAdapter(this));//Loading Data on ListView
448 }
449}
450
451
452
453
454//Loading of Images, title, min_price
455
456//Efficient Adapter
457public static class EfficientAdapter extends BaseAdapter {
458 private LayoutInflater mInflater;
459
460 public EfficientAdapter(Context context) {
461 mInflater = LayoutInflater.from(context);
462
463 }
464
465 public int getCount() {
466 return image_sm.size();
467 }
468
469 public Object getItem(int position) {
470 return position;
471 }
472
473 public long getItemId(int position) {
474 return position;
475 }
476
477 //this fuction loads images and text views on this ListView
478 public View getView(int position, View convertView, ViewGroup parent) {
479 ViewHolder holder;
480
481 //holder.img.setImageBitmap(bmp);
482 if (convertView == null) {
483 convertView = mInflater.inflate(R.layout.searchlist, null);
484 holder = new ViewHolder();
485 holder.text = (TextView) convertView
486 .findViewById(R.id.lbl_ProductDetail);
487 holder.text2 = (TextView) convertView
488 .findViewById(R.id.lbl_Price);
489 holder.img = (ImageView) convertView.findViewById(R.id.img_ProductImage);
490 holder.rating = (ImageView) convertView.findViewById(R.id.img_Star);
491 holder.rating1 = (ImageView) convertView.findViewById(R.id.img_Star1);
492 holder.rating2 = (ImageView) convertView.findViewById(R.id.img_Star2);
493 holder.rating3 = (ImageView) convertView.findViewById(R.id.img_Star3);
494 holder.rating4 = (ImageView) convertView.findViewById(R.id.img_Star4);
495 convertView.setTag(holder);
496 } else {
497 holder = (ViewHolder) convertView.getTag();
498 }
499 if(offer_rating.get(position).equals("No Value"))
500 {
501 System.out.println("No Rating in this offer");
502 }
503 else{
504 //System.out.println("Rating star:"+Float.parseFloat(offer_rating.get(position).toString()));
505 if(Float.parseFloat(offer_rating.get(position))/2==5.0)
506 {
507 holder.rating.setImageResource(R.drawable.astar);
508 holder.rating1.setImageResource(R.drawable.astar);
509 holder.rating2.setImageResource(R.drawable.astar);
510 holder.rating3.setImageResource(R.drawable.astar);
511 holder.rating4.setImageResource(R.drawable.astar);
512 }else if(Float.parseFloat(offer_rating.get(position))/2>4.0 && Float.parseFloat(offer_rating.get(position))/2<=4.5)
513 {
514 holder.rating.setImageResource(R.drawable.astar);
515 holder.rating1.setImageResource(R.drawable.astar);
516 holder.rating2.setImageResource(R.drawable.astar);
517 holder.rating3.setImageResource(R.drawable.astar);
518 holder.rating4.setImageResource(R.drawable.astarh);
519 }else if(Float.parseFloat(offer_rating.get(position))/2==4)
520 {
521 holder.rating.setImageResource(R.drawable.astar);
522 holder.rating1.setImageResource(R.drawable.astar);
523 holder.rating2.setImageResource(R.drawable.astar);
524 holder.rating3.setImageResource(R.drawable.astar);
525 }else if(Float.parseFloat(offer_rating.get(position))/2>3.0 && Float.parseFloat(offer_rating.get(position))/2<=3.5)
526 {
527 holder.rating.setImageResource(R.drawable.astar);
528 holder.rating1.setImageResource(R.drawable.astar);
529 holder.rating2.setImageResource(R.drawable.astar);
530 holder.rating3.setImageResource(R.drawable.astarh);
531 }else if(Float.parseFloat(offer_rating.get(position))/2==3.0)
532 {
533 holder.rating.setImageResource(R.drawable.astar);
534 holder.rating1.setImageResource(R.drawable.astar);
535 holder.rating2.setImageResource(R.drawable.astar);
536 }else if(Float.parseFloat(offer_rating.get(position))/2>2.0 && Float.parseFloat(offer_rating.get(position))/2<=2.5)
537 {
538 holder.rating.setImageResource(R.drawable.astar);
539 holder.rating1.setImageResource(R.drawable.astar);
540 holder.rating2.setImageResource(R.drawable.astarh);
541 }else if(Float.parseFloat(offer_rating.get(position))/2==2.0)
542 {
543
544 holder.rating.setImageResource(R.drawable.astar);
545 holder.rating1.setImageResource(R.drawable.astar);
546 }else if(Float.parseFloat(offer_rating.get(position))/2>1.0 && Float.parseFloat(offer_rating.get(position))/2<=1.5)
547 {
548 holder.rating.setImageResource(R.drawable.astar);
549 holder.rating1.setImageResource(R.drawable.astarh);
550 }else if(Float.parseFloat(offer_rating.get(position))/2==1.0)
551 {
552 holder.rating.setImageResource(R.drawable.astar);
553 }else if(Float.parseFloat(offer_rating.get(position))/2>0.0 && Float.parseFloat(offer_rating.get(position))/2<=0.5)
554 {
555 holder.rating.setImageResource(R.drawable.astarh);
556 }
557 }
558 holder.text.setText(title.get(position));
559 try{
560 holder.text2.setText(min_price.get(position));
561 }catch(Exception e)
562 {
563 holder.text2.setText("$0.00");
564
565 }
566 holder.img.setImageBitmap(bmp[position]);
567
568
569 return convertView;
570 }
571
572 static class ViewHolder {
573 TextView text;
574 TextView text2;
575 ImageView img;
576 ImageView rating;
577 ImageView rating1;
578 ImageView rating2;
579 ImageView rating3;
580 ImageView rating4;
581 }
582}
583
584//Dialog Creation for Refine Search.
585@Override
586protected Dialog onCreateDialog(int id) {
587 brand_list_load.add(brand_array_list.get(0));
588 store_list_load.add(store_array_list.get(0));
589 store_new_adapter = new ArrayAdapter<String>(this,R.layout.ref_row, R.id.label, store_array_list);
590 brand_new_adapter = new ArrayAdapter<String>(this,R.layout.ref_row, R.id.label, brand_array_list);
591 switch(id) {
592 case 0:
593 dialog_refine = new Dialog(this);
594 dialog_refine.setContentView(R.layout.refine_dialog);
595 brand_list= (ListView)dialog_refine.findViewById(R.id.exp);
596
597 store_list= (ListView)dialog_refine.findViewById(R.id.exp_mat);
598 brand_list.invalidate();
599 store_list.invalidate();
600 brand_options_btn = (ImageButton)dialog_refine.findViewById(R.id.options_btn1);
601 et_search = (EditText)dialog_refine.findViewById(R.id.txt_RefineSearch);
602 String temp_key = keyword.replaceAll("\+", " ").toString();
603 System.out.println("The replaced-----------------------------"+temp_key);
604 et_search.setText(temp_key);
605 mat_options_btn = (ImageButton)dialog_refine.findViewById(R.id.options_btn3);
606
607 //Loads Brands List
608 brand_list.setAdapter(arrayAdapter);
609 //Loads Color List
610
611 //Loads Material List
612 store_list.setAdapter(storeAdapter);
613
614
615 //Click on Search TextBox
616 et_search.setOnClickListener(new View.OnClickListener() {
617
618 @Override
619 public void onClick(View arg0) {
620 // TODO Auto-generated method stub
621 Intent intent = new Intent(SearchResultActivity.this,SearchSuggestionActivity.class);
622 startActivity(intent);
623 }
624 });
625 //Click on any Brand
626 brand_list.setOnItemClickListener(new OnItemClickListener()
627 {
628 public void onItemClick(AdapterView<?> arg0, View arg1,int arg2, long arg3)
629 {
630
631 String brand = (String) (brand_list.getAdapter()).getItem(arg2);
632 brand_name = "+"+brand;
633 temp = (String) (brand_list.getAdapter()).getItem(0);
634 brand_selected.clear();
635 brand_selected.add(brand);
636 //brand_list_load.clear();
637
638
639 arrayAdapter.clear();
640 brand_list.invalidate();
641 reload_list();
642
643
644 //arrayAdapter.add(brand);
645 //slected_brand = new ArrayAdapter<String>(this,R.layout.ref_row, R.id.label, brand_selected);
646 System.out.println("POSITION IS-->"+ brand);
647
648 }
649 });
650
651
652 //Click on any Store
653 store_list.setOnItemClickListener(new OnItemClickListener()
654 {
655 public void onItemClick(AdapterView<?> arg0, View arg1,int arg2, long arg3)
656 {
657
658 String store = (String) (store_list.getAdapter()).getItem(arg2);
659 store_name = "+"+store;
660 store_selected.clear();
661 store_selected.add(store);
662
663 //storeAdapter.add(store);
664
665 storeAdapter.clear();
666 store_list.invalidate();
667 reload_storelist();
668
669
670
671
672 System.out.println("POSITION IS-->"+ store);
673
674 }
675 });
676
677 //Brand options
678
679 brand_options_btn.setOnClickListener(new View.OnClickListener() {
680
681
682 public void onClick(View v) {
683
684 arrayAdapter.clear();
685
686 brand_list.invalidate();
687 brand_list.setAdapter(brand_new_adapter);
688 }
689 });
690
691// Material Options
692mat_options_btn.setOnClickListener(new View.OnClickListener() {
693
694
695 public void onClick(View v) {
696 // TODO Auto-generated method stub
697 storeAdapter.clear();
698
699 store_list.invalidate();
700
701 store_list.setAdapter(store_new_adapter);
702 }
703});
704
705
706 Button btn_reset = (Button)dialog_refine.findViewById(R.id.btn_Refine_reset);
707 btn_reset.setOnClickListener(new View.OnClickListener() {
708
709 public void onClick(View arg0) {
710 // TODO Auto-generated method stub
711 /*if(SearchGridActivity.flag_grid==false)
712 {
713
714 Intent intent = new Intent(SearchResultActivity.this,SearchResultActivity.class);
715 intent.putExtra("keyword", keyword);
716 startActivity(intent);
717 }*/
718 brand_list_load.add(brand_array_list.get(0));
719 store_list_load.add(store_array_list.get(0));
720 brand_selected.clear();
721 brand_list.invalidate();
722 brand_list.setAdapter(arrayAdapter);
723 store_selected.clear();
724 store_list.invalidate();
725 store_list.setAdapter(storeAdapter);
726
727 }
728});
729 //Done Button
730 Button done_btn=(Button)dialog_refine.findViewById(R.id.btn_Refine_Done);
731done_btn.setOnClickListener(new View.OnClickListener() {
732
733
734 public void onClick(View v) {
735 // TODO Auto-generated method stub
736 //checkflag=false;
737 count=1;
738 if(brand_name.equals(""))
739 {
740 brand_name = brand_name.replaceAll(" ", "+");
741 }
742 if(!store_name.equals(""))
743 {
744 store_name = store_name.replaceAll(" ", "+");
745 }
746 final_keyword=et_search.getText().toString()+brand_name+store_name;
747 Intent intent = new Intent(SearchResultActivity.this, SearchResultActivity.class);
748 intent.putExtra("keyword", final_keyword);
749 startActivity(intent);
750
751 }
752 });
753
754 break;
755
756 default:
757 dialog_refine = null;
758 }
759 return dialog_refine;
760}
761
762protected void reload_storelist() {
763 // TODO Auto-generated method stub
764 store_list.invalidate();
765 storeAdapter.clear();
766 slected_store= new ArrayAdapter<String>(this,R.layout.ref_row, R.id.label, store_selected);
767 store_list.setAdapter(slected_store);
768}
769
770protected void reload_list() {
771 //brand_list.invalidate();
772
773 //arrayAdapter.clear();
774
775
776 slected_brand = new ArrayAdapter<String>(this,R.layout.ref_row, R.id.label, brand_selected);
777 brand_list.setAdapter(slected_brand);
778 //brand_selected.clear();
779
780}
781/*public void onPause()
782{
783 super.onPause();
784 dialog.dismiss();
785 super.finish();
786}*/
787
788//Checking Network Connection is available or Not
789
790public static boolean checkConn(Context ctx)
791{
792 ConnectivityManager conMgr = (ConnectivityManager)ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
793
794 NetworkInfo i = conMgr.getActiveNetworkInfo();
795 if (i == null)
796 return false;
797 if (!i.isConnected())
798 return false;
799 if (!i.isAvailable())
800 return false;
801 return true;
802
803}
804
805//Flurry Implementation
806 public void onStart()
807 {
808 super.onStart();
809 FlurryAgent.onStartSession(this, "AJT5DWUVF6IAE78NQV69");
810 // your code
811 }
812
813 public void onStop()
814 {
815 super.onStop();
816 FlurryAgent.onEndSession(this);
817 // your code
818 }
819
820}