ResultActivity.java 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. package com.usai.apex;
  2. import java.util.ArrayList;
  3. import java.util.HashMap;
  4. import java.util.Iterator;
  5. import java.util.Locale;
  6. import org.json.JSONException;
  7. import org.json.JSONObject;
  8. import com.usai.util.Network;
  9. import com.usai.util.dbUtil;
  10. import android.net.Uri;
  11. import android.os.AsyncTask;
  12. import android.os.Build;
  13. import android.os.Bundle;
  14. import android.animation.Animator;
  15. import android.animation.AnimatorListenerAdapter;
  16. import android.app.Activity;
  17. import android.app.AlertDialog;
  18. import android.app.Dialog;
  19. import android.app.DownloadManager;
  20. import android.app.AlertDialog.Builder;
  21. import android.app.DownloadManager.Request;
  22. import android.content.DialogInterface;
  23. import android.content.Intent;
  24. import android.content.SharedPreferences;
  25. import android.content.pm.PackageManager.NameNotFoundException;
  26. import android.database.Cursor;
  27. import android.database.sqlite.SQLiteDatabase;
  28. import android.text.Html;
  29. import android.text.style.URLSpan;
  30. import android.util.Log;
  31. import android.util.SparseArray;
  32. import android.view.ContextMenu;
  33. import android.view.Gravity;
  34. import android.view.Menu;
  35. import android.view.MenuItem;
  36. import android.view.View;
  37. import android.view.ContextMenu.ContextMenuInfo;
  38. import android.view.View.OnClickListener;
  39. import android.view.View.OnCreateContextMenuListener;
  40. import android.widget.AdapterView.AdapterContextMenuInfo;
  41. import android.widget.Button;
  42. import android.widget.LinearLayout;
  43. import android.widget.TableLayout;
  44. import android.widget.TableRow;
  45. import android.widget.TextView;
  46. import android.widget.Toast;
  47. public class ResultActivity extends Activity {
  48. String user = null;
  49. String password = null;
  50. String function_name = null;
  51. private SearchTask m_task = null;
  52. int sel = -1;
  53. Bundle searchParms = null;
  54. SearchResult searchresult = new SearchResult();
  55. SparseArray<String> showfieldmap = new SparseArray<String>();
  56. // HashMap<Integer, String> showfieldmap = new HashMap<Integer, String>();
  57. private TextView mStatusMessageView;
  58. // private View mSearchFormView;
  59. private View footview;
  60. private View mStatusView;
  61. int actioncount=0;
  62. // private class resultAdapter extends SimpleAdapter
  63. // {
  64. //
  65. //
  66. // }
  67. @Override
  68. protected void onCreate(Bundle savedInstanceState) {
  69. user = ApexTrackingApplication.get_user();
  70. password = ApexTrackingApplication.get_pass();
  71. function_name = getIntent().getStringExtra("function_name");
  72. searchParms = getIntent().getBundleExtra("searchParms");
  73. super.onCreate(savedInstanceState);
  74. setContentView(R.layout.activity_result);
  75. SQLiteDatabase db = dbUtil.OpenDB(ResultActivity.this, null, false);
  76. Cursor cursor = db.query("actions_info",
  77. new String[] { "count(*)" }, "function_name='"
  78. + function_name + "' and user='" + user + "'",
  79. null, null, null, "priority", null);
  80. if (cursor.moveToNext()) {
  81. actioncount = cursor.getInt(0);
  82. }
  83. dbUtil.CloseCursor(cursor);
  84. dbUtil.CloseDB(db);
  85. footview = findViewById(R.id.foot);
  86. // mSearchFormView = findViewById(R.id.search_form);
  87. Button btnnext = (Button) findViewById(R.id.btn_next);
  88. btnnext.setOnClickListener(new View.OnClickListener() {
  89. @Override
  90. public void onClick(View v) {
  91. // TextView tv_head = (TextView) findViewById(R.id.tv_head);
  92. // searchresult.set_direction(1);
  93. if (searchresult.get_totalcount() == -1)
  94. requestdata(true);
  95. else {
  96. // if (searchresult.get_direction() == -1)
  97. searchresult.set_offset(searchresult.get_offset() + 10);
  98. requestdata(false);
  99. }
  100. }
  101. });
  102. Button btnpre = (Button) findViewById(R.id.btn_pre);
  103. btnpre.setOnClickListener(new View.OnClickListener() {
  104. @Override
  105. public void onClick(View v) {
  106. // TextView tv_head = (TextView) findViewById(R.id.tv_head);
  107. // searchresult.set_direction(-1);
  108. if (searchresult.get_totalcount() == -1)
  109. requestdata(true);
  110. else {
  111. searchresult.set_offset(searchresult.get_offset() - 10);
  112. requestdata(false);
  113. }
  114. }
  115. });
  116. mStatusView = findViewById(R.id.status);
  117. mStatusMessageView = (TextView) findViewById(R.id.status_message);
  118. LinearLayout ll = (LinearLayout) findViewById(R.id.ll_refresh);
  119. Button btn_refresh = (Button) ll.findViewById(R.id.btn_refresh);
  120. btn_refresh.setOnClickListener(new View.OnClickListener() {
  121. @Override
  122. public void onClick(View v) {
  123. LinearLayout ll = (LinearLayout) findViewById(R.id.ll_refresh);
  124. ll.setVisibility(View.INVISIBLE);
  125. if (searchresult.get_totalcount() == -1)
  126. requestdata(true);
  127. else
  128. requestdata(false);
  129. }
  130. });
  131. SharedPreferences RunOnce = getSharedPreferences("Apex", 0);
  132. String vername;
  133. try {
  134. vername = getPackageManager().getPackageInfo("com.usai.apex", 0).versionName;
  135. boolean bFirstRun = RunOnce.getBoolean("FirstRun" + vername
  136. + "_result", true);
  137. if (bFirstRun) {
  138. SharedPreferences.Editor editor = RunOnce.edit();
  139. editor.putBoolean("FirstRun" + vername + "_result", false);
  140. // Don't forget to commit your edits!!!
  141. editor.commit();
  142. Intent intent = new Intent();
  143. intent.setClass(this, HelpActivity.class);
  144. intent.putExtra("caller", "result");
  145. startActivity(intent);
  146. }
  147. } catch (NameNotFoundException e) {
  148. // TODO Auto-generated catch block
  149. e.printStackTrace();
  150. }
  151. initTableHeader();
  152. if(savedInstanceState!=null)
  153. {
  154. searchresult=(SearchResult) savedInstanceState.getSerializable("searchresult");
  155. if(searchresult.get_totalcount()==-1)
  156. requestdata(true);
  157. else
  158. initTable();
  159. }
  160. else
  161. requestdata(true);
  162. }
  163. @Override
  164. protected void onDestroy()
  165. {
  166. if(m_task!=null)
  167. m_task.cancel(false);
  168. super.onDestroy();
  169. }
  170. private void initTable()
  171. {
  172. // int loadcount = searchresult.get_count();
  173. int totalcount = searchresult.get_totalcount();
  174. TextView tv_head = (TextView) findViewById(R.id.head);
  175. if (totalcount == 0) {
  176. tv_head.setText("0 record found");
  177. return;
  178. } else
  179. tv_head.setText(/*
  180. * loadcount + "/" +
  181. */searchresult.get_totalcount()
  182. + " records");
  183. TableLayout tl = (TableLayout) findViewById(R.id.result_table);
  184. tl.removeViews(1, tl.getChildCount() - 1);
  185. // int newcount = loadcount - showcount + 1;// +1 header row
  186. for (int i = 0; i < searchresult.get_recordscount(); i++) {
  187. TableRow recordRow = new TableRow(ResultActivity.this);
  188. recordRow
  189. .setOnLongClickListener(new View.OnLongClickListener() {
  190. @Override
  191. public boolean onLongClick(View v) {
  192. // TODO Auto-generated method stub
  193. // v.setBackgroundColor(Color.GRAY);
  194. // v.showContextMenu();
  195. // return true;
  196. TableRow tr = (TableRow) v;
  197. TextView tvno = (TextView) tr.getChildAt(0);
  198. sel = Integer.parseInt(tvno.getText()
  199. .toString()) % 10;
  200. registerForContextMenu(v);
  201. openContextMenu(v);
  202. unregisterForContextMenu(v);
  203. return true;
  204. }
  205. });
  206. // registerForContextMenu(recordRow);
  207. // recordRow.setClickable(true);
  208. // registerForContextMenu(recordRow);
  209. // recordRow.setOnCreateContextMenuListener(m_tableMenu);
  210. // recordRow.SETSE
  211. HashMap<String, String> record = searchresult.get_record(i);
  212. TextView field = new TextView(ResultActivity.this);
  213. field.setBackgroundResource(R.drawable.tableitem);
  214. field.setText(searchresult.get_offset() + i + "");
  215. Log.d("offset=" + searchresult.get_offset(), "");
  216. field.setGravity(Gravity.CENTER);
  217. field.setPadding(10, 5, 10, 5);
  218. field.setTextSize(20);
  219. recordRow.addView(field);
  220. for (int j = 0; j < showfieldmap.size(); j++) {
  221. TextView field1 = new TextView(ResultActivity.this);
  222. Log.d("onPostExecute", showfieldmap.get(j));
  223. String str = record.get(showfieldmap.get(j));
  224. field1.setBackgroundResource(R.drawable.tableitem);
  225. if (str.toLowerCase().trim().equals("null"))
  226. str = "";
  227. // field1.setBackgroundColor(0xFFFFFFFF);
  228. field1.setText(Html.fromHtml(str));
  229. if(actioncount==0)
  230. field1.setOnClickListener(new OnClickListener() {
  231. @Override
  232. public void onClick(View v) {
  233. URLSpan span[] = ((TextView) v).getUrls();
  234. if (span.length < 1)
  235. return;
  236. span[0].getURL();
  237. Log.d("Text", span[0].getURL());
  238. final DownloadManager downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
  239. Uri uri = Uri.parse(span[0].getURL());
  240. final Request request = new Request(uri);
  241. // 设置允许使用的网络类型,这里是移动网络和wifi都可以
  242. request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE
  243. | DownloadManager.Request.NETWORK_WIFI);
  244. // 禁止发出通知,既后台下载,如果要使用这一句必须声明一个权限:android.permission.DOWNLOAD_WITHOUT_NOTIFICATION
  245. // request.setShowRunningNotification(false);
  246. // 不显示下载界面
  247. request.setVisibleInDownloadsUi(false);
  248. request.setNotificationVisibility(Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
  249. /*
  250. * 设置下载后文件存放的位置,如果sdcard不可用,那么设置这个将报错,
  251. * 因此最好不设置如果sdcard可用,下载后的文件
  252. * 在/mnt/sdcard/Android/
  253. * data/packageName/files目录下面
  254. * ,如果sdcard不可用,设置了下面这个将报错,不设置,下载后的文件在/cache这个
  255. * 目录下面
  256. */
  257. // request.setDestinationInExternalFilesDir(this,
  258. // null, "tar.apk");
  259. AlertDialog.Builder builder = new Builder(ResultActivity.this);
  260. builder.setMessage("Click start button to begin download");
  261. builder.setTitle("Confirm download");
  262. builder.setPositiveButton("Start", new Dialog.OnClickListener() {
  263. @Override
  264. public void onClick(DialogInterface dialog, int which) {
  265. long id = downloadManager.enqueue(request);
  266. dialog.dismiss();
  267. }
  268. });
  269. builder.setNegativeButton("Cancel", new Dialog.OnClickListener() {
  270. @Override
  271. public void onClick(DialogInterface dialog, int which) {
  272. dialog.dismiss();
  273. }
  274. });
  275. builder.create().show();
  276. }
  277. });
  278. // field1.setText(str);
  279. field1.setGravity(Gravity.CENTER);
  280. field1.setPadding(10, 5, 10, 5);
  281. field1.setTextSize(20);
  282. // field.setTextAppearance(ResultActivity.this,
  283. // android.R.attr.textAppearanceMedium);
  284. recordRow.addView(field1);
  285. }
  286. tl.addView(recordRow);
  287. }
  288. Button btnnext = (Button) findViewById(R.id.btn_next);
  289. Button btnpre = (Button) findViewById(R.id.btn_pre);
  290. if (searchresult.get_offset() == 0)
  291. btnpre.setEnabled(false);
  292. else {
  293. btnpre.setEnabled(true);
  294. }
  295. if (searchresult.get_totalcount() - searchresult.get_offset() <= 10)
  296. btnnext.setEnabled(false);
  297. else
  298. btnnext.setEnabled(true);
  299. }
  300. private OnCreateContextMenuListener m_tableMenu = new OnCreateContextMenuListener() {
  301. @Override
  302. public void onCreateContextMenu(ContextMenu contextmenu, View view,
  303. ContextMenuInfo contextmenuinfo) {
  304. contextmenu.add(Menu.NONE, 0, 0, "Detail");
  305. }
  306. };
  307. @Override
  308. public boolean onContextItemSelected(MenuItem item) {
  309. // menuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
  310. // Log.d("table row select", sel+ "");
  311. Intent intent = new Intent();
  312. intent.setClass(this, DetailActivity.class);
  313. SQLiteDatabase db = dbUtil.OpenDB(this, null, false);
  314. Cursor cursor = db.query("actions_info",
  315. new String[] { "name", "_id" }, "function_name='"
  316. + function_name + "' and user='" + user + "'", null,
  317. null, null, "priority", null);
  318. int i = 0;
  319. while (cursor.moveToNext()) {
  320. String name = cursor.getString(0);
  321. Log.d("actionname", name);
  322. intent.putExtra("action" + i, name);
  323. i++;
  324. }
  325. intent.putExtra("function_name", function_name);
  326. intent.putExtra("actions_count", i);
  327. intent.putExtra("_id", searchresult.get_record(sel).get("_id")
  328. .toString());
  329. dbUtil.CloseCursor(cursor);
  330. dbUtil.CloseDB(db);
  331. startActivity(intent);
  332. return super.onContextItemSelected(item);
  333. }
  334. // @Override
  335. // public void onCreateContextMenu(ContextMenu menu, View v,
  336. // ContextMenuInfo menuInfo)
  337. // {
  338. // // // TODO Auto-generated method stub
  339. // menu.add(Menu.NONE, 0, 0, "Detail");
  340. // // // contextmenu.add(Menu.NONE, 1, 1, "�༭");
  341. // super.onCreateContextMenu(menu, v, menuInfo);
  342. // }
  343. void initTableHeader() {
  344. TableLayout tl = (TableLayout) findViewById(R.id.result_table);
  345. tl.setFocusable(true);
  346. tl.setOnCreateContextMenuListener(m_tableMenu);
  347. SQLiteDatabase db = dbUtil.OpenDB(this, null, false);
  348. Cursor cursor = db.query("fields_info", new String[] { "aname", "name",
  349. "_id" }, "function_name='" + function_name + "' and user='"
  350. + user + "' and behavior=" + Network.BEHAVIOR_RESULT
  351. + " and show = 1", null, null, null, "priority , aname", null);
  352. TableRow headerRow = (TableRow) findViewById(R.id.tr_header);
  353. int pos = 0;
  354. showfieldmap.clear();
  355. headerRow.removeAllViews();
  356. ArrayList<HashMap<String, String>> gridheader = new ArrayList<HashMap<String, String>>();
  357. HashMap<String, String> map = new HashMap<String, String>();
  358. map.put("key", "no.");
  359. gridheader.add(map);
  360. Button btn = new Button(this);
  361. btn.setBackgroundResource(R.drawable.tablehead);
  362. btn.setPadding(0, 0, 0, 0);
  363. btn.setText("No.");
  364. headerRow.addView(btn);
  365. while (cursor.moveToNext()) {
  366. String aname = cursor.getString(0);
  367. Button btn1 = new Button(this);
  368. btn1.setBackgroundResource(R.drawable.tablehead);
  369. btn1.setText(aname);
  370. headerRow.addView(btn1);
  371. showfieldmap.put(pos, cursor.getString(1));
  372. map.put("key", "header");
  373. gridheader.add(map);
  374. pos++;
  375. }
  376. dbUtil.CloseCursor(cursor);
  377. dbUtil.CloseDB(db);
  378. // SimpleAdapter adapter = new SimpleAdapter(this,
  379. // gridheader,// �����Դ
  380. // R.layout.result_item,//XMLʵ��
  381. // new String[] { "key" }, // ��̬������ImageItem��Ӧ������
  382. // new int[] { R.id.tv_value });
  383. //
  384. // GridView gridview = (GridView) findViewById(R.id.grid_result);
  385. // gridview.setNumColumns(2);
  386. // gridview.setAdapter(adapter);
  387. }
  388. @Override
  389. public boolean onCreateOptionsMenu(Menu menu) {
  390. // Inflate the menu; this adds items to the action bar if it is present.
  391. getMenuInflater().inflate(R.menu.result, menu);
  392. return true;
  393. }
  394. @Override
  395. public boolean onOptionsItemSelected(MenuItem item) {
  396. Intent intent = new Intent();
  397. switch (item.getItemId()) {
  398. case R.id.action_custom_fields:
  399. intent.setClass(this, CustomizeFieldsActivity.class);
  400. intent.putExtra("user", user);
  401. // intent.putExtra("password", password);
  402. intent.putExtra("function_name", function_name);
  403. intent.putExtra("behavior", Network.BEHAVIOR_RESULT);
  404. startActivity(intent);
  405. break;
  406. case R.id.action_help:
  407. // Intent intent = new Intent();
  408. intent.setClass(this, HelpActivity.class);
  409. intent.putExtra("caller", "result");
  410. // // intent.putExtra("password", password);
  411. // intent.putExtra("function_name", function_name);
  412. // intent.putExtra("behavior", Network.BEHAVIOR_SEARCH);
  413. startActivity(intent);
  414. break;
  415. default:
  416. break;
  417. }
  418. return super.onOptionsItemSelected(item);
  419. }
  420. public void requestdata(boolean requestcount) {
  421. if (m_task != null) {
  422. return;
  423. }
  424. mStatusMessageView.setText("Loading");
  425. showProgress(true);
  426. m_task = new SearchTask();
  427. m_task.execute(requestcount);
  428. }
  429. private void showProgress(final boolean show) {
  430. // On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
  431. // for very easy animations. If available, use these APIs to fade-in
  432. // the progress spinner.
  433. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
  434. int shortAnimTime = getResources().getInteger(
  435. android.R.integer.config_shortAnimTime);
  436. mStatusView.setVisibility(View.VISIBLE);
  437. mStatusView.animate().setDuration(shortAnimTime)
  438. .alpha(show ? 1 : 0)
  439. .setListener(new AnimatorListenerAdapter() {
  440. @Override
  441. public void onAnimationEnd(Animator animation) {
  442. mStatusView.setVisibility(show ? View.VISIBLE
  443. : View.INVISIBLE);
  444. }
  445. });
  446. footview.setVisibility(View.VISIBLE);
  447. footview.animate().setDuration(shortAnimTime).alpha(show ? 0 : 1)
  448. .setListener(new AnimatorListenerAdapter() {
  449. @Override
  450. public void onAnimationEnd(Animator animation) {
  451. footview.setVisibility(show ? View.INVISIBLE
  452. : View.VISIBLE);
  453. }
  454. });
  455. // mSearchFormView.setVisibility(View.VISIBLE);
  456. // mSearchFormView.animate().setDuration(shortAnimTime)
  457. // .alpha(show ? 0 : 1)
  458. // .setListener(new AnimatorListenerAdapter()
  459. // {
  460. // @Override
  461. // public void onAnimationEnd(Animator animation)
  462. // {
  463. // mSearchFormView.setVisibility(show ? View.INVISIBLE
  464. // : View.VISIBLE);
  465. // }
  466. // });
  467. } else {
  468. // The ViewPropertyAnimator APIs are not available, so simply show
  469. // and hide the relevant UI components.
  470. mStatusView.setVisibility(show ? View.VISIBLE : View.INVISIBLE);
  471. footview.setVisibility(show ? View.INVISIBLE : View.VISIBLE);
  472. // mSearchFormView.setVisibility(show ? View.INVISIBLE :
  473. // View.VISIBLE);
  474. }
  475. }
  476. public class SearchTask extends AsyncTask<Boolean, Void, Boolean> {
  477. // int err_code = ERR_CODE_NONE;
  478. int errorcode;
  479. @Override
  480. protected Boolean doInBackground(Boolean... params) {
  481. if (!Network.NetworkIsAvailable())
  482. {
  483. errorcode = Network.RESULT_NET_NOTAVAILABLE;
  484. return false;
  485. }
  486. if (params[0]) {
  487. int ret = Network.get_recordcount(user, password, searchParms);
  488. if (ret >= 0) {
  489. searchresult.put_totalcount(ret);
  490. if (ret == 0)
  491. return true;
  492. } else {
  493. errorcode = ret;
  494. return false;
  495. }
  496. }
  497. // if (searchresult.get_direction() == -1)
  498. // searchresult.set_offset(searchresult.get_offset() - 20);
  499. searchParms.putString("offset", searchresult.get_offset() + "");
  500. String jstr = Network.get_records(user, password, searchParms);
  501. if (jstr == null || jstr.length() <= 0) {
  502. // Log.d(TAG, "json is wrong");
  503. errorcode = Network.RESULT_NET_ERROR;
  504. return false;
  505. }
  506. JSONObject jsobj;
  507. //
  508. // array = new JSONArray(json);
  509. try {
  510. jsobj = new JSONObject(jstr);
  511. // if (searchresult.get_fieldscount() == 0)
  512. // {
  513. // JSONObject objfields = jsobj.getJSONObject("fields");
  514. // if (objfields != null)
  515. // searchresult.init_fields(objfields.toString());
  516. // }
  517. JSONObject objrecords = jsobj.getJSONObject("records");
  518. if (objrecords != null)
  519. searchresult.add_records(objrecords.toString());
  520. errorcode = Network.RESULT_TRUE;
  521. return true;
  522. } catch (JSONException e) {
  523. // TODO Auto-generated catch block
  524. e.printStackTrace();
  525. }
  526. errorcode = Network.RESULT_NET_ERROR;
  527. return false;
  528. }
  529. @Override
  530. protected void onPostExecute(final Boolean success) {
  531. Log.i("onPostExecute", "entry");
  532. m_task = null;
  533. showProgress(false);
  534. switch (errorcode) {
  535. case Network.RESULT_NET_NOTAVAILABLE: {
  536. Toast toast = Toast.makeText(getApplicationContext(),
  537. getText(R.string.msg_connection_none),
  538. Toast.LENGTH_LONG);
  539. toast.setGravity(Gravity.CENTER, 0, 0);
  540. toast.show();
  541. return;
  542. }
  543. case Network.RESULT_NET_ERROR: {
  544. Toast toast = Toast.makeText(getApplicationContext(),
  545. getText(R.string.msg_net_error), Toast.LENGTH_LONG);
  546. toast.setGravity(Gravity.CENTER, 0, 0);
  547. toast.show();
  548. return;
  549. }
  550. case Network.RESULT_ERROR:
  551. // case Network.RESULT_RESPONSE_NULL:
  552. {
  553. Toast toast = Toast.makeText(getApplicationContext(),
  554. getText(R.string.msg_net_resulterror),
  555. Toast.LENGTH_LONG);
  556. toast.setGravity(Gravity.CENTER, 0, 0);
  557. toast.show();
  558. return;
  559. }
  560. default:
  561. break;
  562. }
  563. if (success) {
  564. initTable();
  565. } else {
  566. LinearLayout ll = (LinearLayout) findViewById(R.id.ll_refresh);
  567. ll.setVisibility(View.VISIBLE);
  568. }
  569. }
  570. @Override
  571. protected void onCancelled() {
  572. m_task = null;
  573. showProgress(false);
  574. }
  575. }
  576. @Override
  577. protected void onSaveInstanceState(Bundle outState)
  578. {
  579. outState.putSerializable("searchresult", searchresult);
  580. super.onSaveInstanceState(outState);
  581. }
  582. }