|
|
@@ -50,24 +50,25 @@ import android.widget.TableRow;
|
|
|
import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
-public class ResultActivity extends Activity {
|
|
|
- String user = null;
|
|
|
- String password = null;
|
|
|
- String function_name = null;
|
|
|
- private SearchTask m_task = null;
|
|
|
+public class ResultActivity extends Activity
|
|
|
+{
|
|
|
+ String user = null;
|
|
|
+ String password = null;
|
|
|
+ String function_name = null;
|
|
|
+ private SearchTask m_task = null;
|
|
|
|
|
|
- int sel = -1;
|
|
|
+ int sel = -1;
|
|
|
|
|
|
- Bundle searchParms = null;
|
|
|
- SearchResult searchresult = new SearchResult();
|
|
|
+ Bundle searchParms = null;
|
|
|
+ SearchResult searchresult = new SearchResult();
|
|
|
|
|
|
- SparseArray<String> showfieldmap = new SparseArray<String>();
|
|
|
+ SparseArray<String> showfieldmap = new SparseArray<String>();
|
|
|
// HashMap<Integer, String> showfieldmap = new HashMap<Integer, String>();
|
|
|
- private TextView mStatusMessageView;
|
|
|
+ private TextView mStatusMessageView;
|
|
|
// private View mSearchFormView;
|
|
|
- private View footview;
|
|
|
- private View mStatusView;
|
|
|
- int actioncount=0;
|
|
|
+ private View footview;
|
|
|
+ private View mStatusView;
|
|
|
+ int actioncount = 0;
|
|
|
|
|
|
// private class resultAdapter extends SimpleAdapter
|
|
|
// {
|
|
|
@@ -75,49 +76,54 @@ public class ResultActivity extends Activity {
|
|
|
//
|
|
|
// }
|
|
|
@Override
|
|
|
- protected void onCreate(Bundle savedInstanceState) {
|
|
|
+ protected void onCreate(Bundle savedInstanceState)
|
|
|
+ {
|
|
|
user = ApexTrackingApplication.get_user();
|
|
|
password = ApexTrackingApplication.get_pass();
|
|
|
function_name = getIntent().getStringExtra("function_name");
|
|
|
- if(function_name.equals("Ocean Booking"))
|
|
|
+ if (function_name.equals("Ocean Booking"))
|
|
|
setTitle("Booking Result");
|
|
|
- else if(function_name.equals("Ocean B/L info."))
|
|
|
+ else if (function_name.equals("Ocean B/L info."))
|
|
|
setTitle("B/L info. Result");
|
|
|
- else if(function_name.equals("Container detail"))
|
|
|
+ else if (function_name.equals("Container detail"))
|
|
|
setTitle("Container Result");
|
|
|
- else if(function_name.equals("Download Document"))
|
|
|
+ else if (function_name.equals("Download Document"))
|
|
|
setTitle("Document Result");
|
|
|
-
|
|
|
+
|
|
|
searchParms = getIntent().getBundleExtra("searchParms");
|
|
|
super.onCreate(savedInstanceState);
|
|
|
setContentView(R.layout.activity_result);
|
|
|
-
|
|
|
+
|
|
|
SQLiteDatabase db = dbUtil.OpenDB(ResultActivity.this, null, false);
|
|
|
- Cursor cursor = db.query("actions_info",
|
|
|
- new String[] { "count(*)" }, "function_name='"
|
|
|
- + function_name + "' and user='" + user + "'",
|
|
|
- null, null, null, "priority", null);
|
|
|
- if (cursor.moveToNext()) {
|
|
|
+ Cursor cursor = db
|
|
|
+ .query("actions_info", new String[] { "count(*)" },
|
|
|
+ "function_name='" + function_name + "' and user='"
|
|
|
+ + user + "'", null, null, null, "priority",
|
|
|
+ null);
|
|
|
+ if (cursor.moveToNext())
|
|
|
+ {
|
|
|
actioncount = cursor.getInt(0);
|
|
|
}
|
|
|
|
|
|
dbUtil.CloseCursor(cursor);
|
|
|
dbUtil.CloseDB(db);
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
footview = findViewById(R.id.foot);
|
|
|
// mSearchFormView = findViewById(R.id.search_form);
|
|
|
Button btnnext = (Button) findViewById(R.id.btn_next);
|
|
|
- btnnext.setOnClickListener(new View.OnClickListener() {
|
|
|
+ btnnext.setOnClickListener(new View.OnClickListener()
|
|
|
+ {
|
|
|
|
|
|
@Override
|
|
|
- public void onClick(View v) {
|
|
|
+ public void onClick(View v)
|
|
|
+ {
|
|
|
// TextView tv_head = (TextView) findViewById(R.id.tv_head);
|
|
|
|
|
|
// searchresult.set_direction(1);
|
|
|
if (searchresult.get_totalcount() == -1)
|
|
|
requestdata(true);
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
// if (searchresult.get_direction() == -1)
|
|
|
searchresult.set_offset(searchresult.get_offset() + 10);
|
|
|
requestdata(false);
|
|
|
@@ -127,15 +133,18 @@ public class ResultActivity extends Activity {
|
|
|
});
|
|
|
|
|
|
Button btnpre = (Button) findViewById(R.id.btn_pre);
|
|
|
- btnpre.setOnClickListener(new View.OnClickListener() {
|
|
|
+ btnpre.setOnClickListener(new View.OnClickListener()
|
|
|
+ {
|
|
|
|
|
|
@Override
|
|
|
- public void onClick(View v) {
|
|
|
+ public void onClick(View v)
|
|
|
+ {
|
|
|
// TextView tv_head = (TextView) findViewById(R.id.tv_head);
|
|
|
// searchresult.set_direction(-1);
|
|
|
if (searchresult.get_totalcount() == -1)
|
|
|
requestdata(true);
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
searchresult.set_offset(searchresult.get_offset() - 10);
|
|
|
requestdata(false);
|
|
|
}
|
|
|
@@ -146,10 +155,12 @@ public class ResultActivity extends Activity {
|
|
|
mStatusMessageView = (TextView) findViewById(R.id.status_message);
|
|
|
LinearLayout ll = (LinearLayout) findViewById(R.id.ll_refresh);
|
|
|
Button btn_refresh = (Button) ll.findViewById(R.id.btn_refresh);
|
|
|
- btn_refresh.setOnClickListener(new View.OnClickListener() {
|
|
|
+ btn_refresh.setOnClickListener(new View.OnClickListener()
|
|
|
+ {
|
|
|
|
|
|
@Override
|
|
|
- public void onClick(View v) {
|
|
|
+ public void onClick(View v)
|
|
|
+ {
|
|
|
LinearLayout ll = (LinearLayout) findViewById(R.id.ll_refresh);
|
|
|
ll.setVisibility(View.INVISIBLE);
|
|
|
if (searchresult.get_totalcount() == -1)
|
|
|
@@ -163,11 +174,13 @@ public class ResultActivity extends Activity {
|
|
|
SharedPreferences RunOnce = getSharedPreferences("Apex", 0);
|
|
|
|
|
|
String vername;
|
|
|
- try {
|
|
|
+ try
|
|
|
+ {
|
|
|
vername = getPackageManager().getPackageInfo("com.usai.apex", 0).versionName;
|
|
|
boolean bFirstRun = RunOnce.getBoolean("FirstRun" + vername
|
|
|
+ "_result", true);
|
|
|
- if (bFirstRun) {
|
|
|
+ if (bFirstRun)
|
|
|
+ {
|
|
|
SharedPreferences.Editor editor = RunOnce.edit();
|
|
|
editor.putBoolean("FirstRun" + vername + "_result", false);
|
|
|
// Don't forget to commit your edits!!!
|
|
|
@@ -178,28 +191,31 @@ public class ResultActivity extends Activity {
|
|
|
startActivity(intent);
|
|
|
|
|
|
}
|
|
|
- } catch (NameNotFoundException e) {
|
|
|
+ }
|
|
|
+ catch (NameNotFoundException e)
|
|
|
+ {
|
|
|
// TODO Auto-generated catch block
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
initTableHeader();
|
|
|
- if(savedInstanceState!=null)
|
|
|
+ if (savedInstanceState != null)
|
|
|
{
|
|
|
- searchresult=(SearchResult) savedInstanceState.getSerializable("searchresult");
|
|
|
- if(searchresult.get_totalcount()==-1)
|
|
|
+ searchresult = (SearchResult) savedInstanceState
|
|
|
+ .getSerializable("searchresult");
|
|
|
+ if (searchresult.get_totalcount() == -1)
|
|
|
requestdata(true);
|
|
|
else
|
|
|
initTable();
|
|
|
}
|
|
|
else
|
|
|
- requestdata(true);
|
|
|
+ requestdata(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected void onDestroy()
|
|
|
{
|
|
|
- if(m_task!=null)
|
|
|
+ if (m_task != null)
|
|
|
m_task.cancel(false);
|
|
|
super.onDestroy();
|
|
|
}
|
|
|
@@ -209,45 +225,47 @@ public class ResultActivity extends Activity {
|
|
|
// int loadcount = searchresult.get_count();
|
|
|
int totalcount = searchresult.get_totalcount();
|
|
|
TextView tv_head = (TextView) findViewById(R.id.head);
|
|
|
- if (totalcount == 0) {
|
|
|
+ if (totalcount == 0)
|
|
|
+ {
|
|
|
tv_head.setText("0 record found");
|
|
|
|
|
|
return;
|
|
|
- } else if(searchresult.get_totalcount()>2000)
|
|
|
+ }
|
|
|
+ else if (searchresult.get_totalcount() > 2000)
|
|
|
{
|
|
|
tv_head.setText("2000+ records");
|
|
|
}
|
|
|
else
|
|
|
tv_head.setText(/*
|
|
|
* loadcount + "/" +
|
|
|
- */searchresult.get_totalcount()
|
|
|
- + " records");
|
|
|
+ */searchresult.get_totalcount() + " records");
|
|
|
TableLayout tl = (TableLayout) findViewById(R.id.result_table);
|
|
|
|
|
|
tl.removeViews(1, tl.getChildCount() - 1);
|
|
|
// int newcount = loadcount - showcount + 1;// +1 header row
|
|
|
- for (int i = 0; i < searchresult.get_recordscount(); i++) {
|
|
|
+ for (int i = 0; i < searchresult.get_recordscount(); i++)
|
|
|
+ {
|
|
|
|
|
|
TableRow recordRow = new TableRow(ResultActivity.this);
|
|
|
- recordRow
|
|
|
- .setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
+ recordRow.setOnLongClickListener(new View.OnLongClickListener()
|
|
|
+ {
|
|
|
|
|
|
- @Override
|
|
|
- public boolean onLongClick(View v) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
- // v.setBackgroundColor(Color.GRAY);
|
|
|
- // v.showContextMenu();
|
|
|
- // return true;
|
|
|
- TableRow tr = (TableRow) v;
|
|
|
- TextView tvno = (TextView) tr.getChildAt(0);
|
|
|
- sel = Integer.parseInt(tvno.getText()
|
|
|
- .toString()) % 10;
|
|
|
- registerForContextMenu(v);
|
|
|
- openContextMenu(v);
|
|
|
- unregisterForContextMenu(v);
|
|
|
- return true;
|
|
|
- }
|
|
|
- });
|
|
|
+ @Override
|
|
|
+ public boolean onLongClick(View v)
|
|
|
+ {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+ // v.setBackgroundColor(Color.GRAY);
|
|
|
+ // v.showContextMenu();
|
|
|
+ // return true;
|
|
|
+ TableRow tr = (TableRow) v;
|
|
|
+ TextView tvno = (TextView) tr.getChildAt(0);
|
|
|
+ sel = Integer.parseInt(tvno.getText().toString()) % 10;
|
|
|
+ registerForContextMenu(v);
|
|
|
+ openContextMenu(v);
|
|
|
+ unregisterForContextMenu(v);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
// registerForContextMenu(recordRow);
|
|
|
// recordRow.setClickable(true);
|
|
|
@@ -264,9 +282,10 @@ public class ResultActivity extends Activity {
|
|
|
field.setPadding(10, 5, 10, 5);
|
|
|
field.setTextSize(20);
|
|
|
recordRow.addView(field);
|
|
|
- for (int j = 0; j < showfieldmap.size(); j++) {
|
|
|
+ for (int j = 0; j < showfieldmap.size(); j++)
|
|
|
+ {
|
|
|
TextView field1 = new TextView(ResultActivity.this);
|
|
|
- Log.d("onPostExecute", showfieldmap.get(j));
|
|
|
+// Log.d("onPostExecute", showfieldmap.get(j));
|
|
|
String str = record.get(showfieldmap.get(j));
|
|
|
field1.setBackgroundResource(R.drawable.tableitem);
|
|
|
if (str.toLowerCase().trim().equals("null"))
|
|
|
@@ -276,73 +295,86 @@ public class ResultActivity extends Activity {
|
|
|
|
|
|
field1.setText(Html.fromHtml(str));
|
|
|
|
|
|
- if(actioncount==0)
|
|
|
- field1.setOnClickListener(new OnClickListener() {
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- URLSpan span[] = ((TextView) v).getUrls();
|
|
|
- if (span.length < 1)
|
|
|
- return;
|
|
|
- span[0].getURL();
|
|
|
- Log.d("Text", span[0].getURL());
|
|
|
-
|
|
|
- final DownloadManager downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
|
|
|
-
|
|
|
- Uri uri = Uri.parse(span[0].getURL());
|
|
|
- final Request request = new Request(uri);
|
|
|
-
|
|
|
- // 设置允许使用的网络类型,这里是移动网络和wifi都可以
|
|
|
- request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE
|
|
|
- | DownloadManager.Request.NETWORK_WIFI);
|
|
|
-
|
|
|
- // 禁止发出通知,既后台下载,如果要使用这一句必须声明一个权限:android.permission.DOWNLOAD_WITHOUT_NOTIFICATION
|
|
|
- // request.setShowRunningNotification(false);
|
|
|
-
|
|
|
- // 不显示下载界面
|
|
|
- request.setVisibleInDownloadsUi(false);
|
|
|
- request.setNotificationVisibility(Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
|
|
|
-
|
|
|
- /*
|
|
|
- * 设置下载后文件存放的位置,如果sdcard不可用,那么设置这个将报错,
|
|
|
- * 因此最好不设置如果sdcard可用,下载后的文件
|
|
|
- * 在/mnt/sdcard/Android/
|
|
|
- * data/packageName/files目录下面
|
|
|
- * ,如果sdcard不可用,设置了下面这个将报错,不设置,下载后的文件在/cache这个
|
|
|
- * 目录下面
|
|
|
- */
|
|
|
- // request.setDestinationInExternalFilesDir(this,
|
|
|
- // null, "tar.apk");
|
|
|
-
|
|
|
- AlertDialog.Builder builder = new Builder(ResultActivity.this);
|
|
|
- builder.setMessage("Click start button to begin download");
|
|
|
-
|
|
|
- builder.setTitle("Confirm download");
|
|
|
-
|
|
|
- builder.setPositiveButton("Start", new Dialog.OnClickListener() {
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onClick(DialogInterface dialog, int which) {
|
|
|
- long id = downloadManager.enqueue(request);
|
|
|
- dialog.dismiss();
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- builder.setNegativeButton("Cancel", new Dialog.OnClickListener() {
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onClick(DialogInterface dialog, int which) {
|
|
|
- dialog.dismiss();
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- builder.create().show();
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
+ if (actioncount == 0)
|
|
|
+ field1.setOnClickListener(new OnClickListener()
|
|
|
+ {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(View v)
|
|
|
+ {
|
|
|
+// if (true)
|
|
|
+// return;
|
|
|
+ URLSpan span[] = ((TextView) v).getUrls();
|
|
|
+ if (span.length < 1)
|
|
|
+ return;
|
|
|
+ span[0].getURL();
|
|
|
+ Log.d("Text", span[0].getURL());
|
|
|
+
|
|
|
+ final DownloadManager downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
|
|
|
+
|
|
|
+ Uri uri = Uri.parse(span[0].getURL());
|
|
|
+ final Request request = new Request(uri);
|
|
|
+
|
|
|
+ // 设置允许使用的网络类型,这里是移动网络和wifi都可以
|
|
|
+ request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE
|
|
|
+ | DownloadManager.Request.NETWORK_WIFI);
|
|
|
+
|
|
|
+ // 禁止发出通知,既后台下载,如果要使用这一句必须声明一个权限:android.permission.DOWNLOAD_WITHOUT_NOTIFICATION
|
|
|
+ // request.setShowRunningNotification(false);
|
|
|
+
|
|
|
+ // 不显示下载界面
|
|
|
+ request.setVisibleInDownloadsUi(false);
|
|
|
+ request.setNotificationVisibility(Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 设置下载后文件存放的位置,如果sdcard不可用,那么设置这个将报错,
|
|
|
+ * 因此最好不设置如果sdcard可用,下载后的文件 在/mnt/sdcard/Android/
|
|
|
+ * data/packageName/files目录下面
|
|
|
+ * ,如果sdcard不可用,设置了下面这个将报错,不设置,下载后的文件在/cache这个 目录下面
|
|
|
+ */
|
|
|
+ // request.setDestinationInExternalFilesDir(this,
|
|
|
+ // null, "tar.apk");
|
|
|
+
|
|
|
+ AlertDialog.Builder builder = new Builder(
|
|
|
+ ResultActivity.this);
|
|
|
+ builder.setMessage("Click start button to begin download");
|
|
|
+
|
|
|
+ builder.setTitle("Confirm download");
|
|
|
+
|
|
|
+ builder.setPositiveButton("Start",
|
|
|
+ new Dialog.OnClickListener()
|
|
|
+ {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(
|
|
|
+ DialogInterface dialog,
|
|
|
+ int which)
|
|
|
+ {
|
|
|
+ long id = downloadManager
|
|
|
+ .enqueue(request);
|
|
|
+ dialog.dismiss();
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ builder.setNegativeButton("Cancel",
|
|
|
+ new Dialog.OnClickListener()
|
|
|
+ {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(
|
|
|
+ DialogInterface dialog,
|
|
|
+ int which)
|
|
|
+ {
|
|
|
+ dialog.dismiss();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ builder.create().show();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
// field1.setText(str);
|
|
|
field1.setGravity(Gravity.CENTER);
|
|
|
field1.setPadding(10, 5, 10, 5);
|
|
|
@@ -359,29 +391,38 @@ public class ResultActivity extends Activity {
|
|
|
Button btnpre = (Button) findViewById(R.id.btn_pre);
|
|
|
if (searchresult.get_offset() == 0)
|
|
|
btnpre.setEnabled(false);
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
btnpre.setEnabled(true);
|
|
|
}
|
|
|
if (searchresult.get_totalcount() - searchresult.get_offset() <= 10)
|
|
|
btnnext.setEnabled(false);
|
|
|
else
|
|
|
- btnnext.setEnabled(true);
|
|
|
+ btnnext.setEnabled(true);
|
|
|
}
|
|
|
- private OnCreateContextMenuListener m_tableMenu = new OnCreateContextMenuListener() {
|
|
|
|
|
|
- @Override
|
|
|
- public void onCreateContextMenu(ContextMenu contextmenu, View view,
|
|
|
- ContextMenuInfo contextmenuinfo) {
|
|
|
+ private OnCreateContextMenuListener m_tableMenu = new OnCreateContextMenuListener()
|
|
|
+ {
|
|
|
|
|
|
+ @Override
|
|
|
+ public void onCreateContextMenu(
|
|
|
+ ContextMenu contextmenu,
|
|
|
+ View view,
|
|
|
+ ContextMenuInfo contextmenuinfo)
|
|
|
+ {
|
|
|
|
|
|
- contextmenu.add(Menu.NONE, 0, 0, "Detail");
|
|
|
+ contextmenu.add(
|
|
|
+ Menu.NONE,
|
|
|
+ 0, 0,
|
|
|
+ "Detail");
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- };
|
|
|
+ };
|
|
|
|
|
|
@Override
|
|
|
- public boolean onContextItemSelected(MenuItem item) {
|
|
|
+ public boolean onContextItemSelected(MenuItem item)
|
|
|
+ {
|
|
|
// menuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
|
|
|
// Log.d("table row select", sel+ "");
|
|
|
|
|
|
@@ -394,7 +435,8 @@ public class ResultActivity extends Activity {
|
|
|
+ function_name + "' and user='" + user + "'", null,
|
|
|
null, null, "priority", null);
|
|
|
int i = 0;
|
|
|
- while (cursor.moveToNext()) {
|
|
|
+ while (cursor.moveToNext())
|
|
|
+ {
|
|
|
String name = cursor.getString(0);
|
|
|
Log.d("actionname", name);
|
|
|
intent.putExtra("action" + i, name);
|
|
|
@@ -422,7 +464,8 @@ public class ResultActivity extends Activity {
|
|
|
// super.onCreateContextMenu(menu, v, menuInfo);
|
|
|
// }
|
|
|
|
|
|
- void initTableHeader() {
|
|
|
+ void initTableHeader()
|
|
|
+ {
|
|
|
|
|
|
TableLayout tl = (TableLayout) findViewById(R.id.result_table);
|
|
|
tl.setFocusable(true);
|
|
|
@@ -445,7 +488,8 @@ public class ResultActivity extends Activity {
|
|
|
btn.setPadding(0, 0, 0, 0);
|
|
|
btn.setText("No.");
|
|
|
headerRow.addView(btn);
|
|
|
- while (cursor.moveToNext()) {
|
|
|
+ while (cursor.moveToNext())
|
|
|
+ {
|
|
|
String aname = cursor.getString(0);
|
|
|
Button btn1 = new Button(this);
|
|
|
btn1.setBackgroundResource(R.drawable.tablehead);
|
|
|
@@ -473,43 +517,48 @@ public class ResultActivity extends Activity {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
+ public boolean onCreateOptionsMenu(Menu menu)
|
|
|
+ {
|
|
|
// Inflate the menu; this adds items to the action bar if it is present.
|
|
|
getMenuInflater().inflate(R.menu.result, menu);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
+ public boolean onOptionsItemSelected(MenuItem item)
|
|
|
+ {
|
|
|
Intent intent = new Intent();
|
|
|
- switch (item.getItemId()) {
|
|
|
- case R.id.action_custom_fields:
|
|
|
-
|
|
|
- intent.setClass(this, CustomizeFieldsActivity.class);
|
|
|
- intent.putExtra("user", user);
|
|
|
- // intent.putExtra("password", password);
|
|
|
- intent.putExtra("function_name", function_name);
|
|
|
- intent.putExtra("behavior", Network.BEHAVIOR_RESULT);
|
|
|
- startActivity(intent);
|
|
|
- break;
|
|
|
- case R.id.action_help:
|
|
|
- // Intent intent = new Intent();
|
|
|
- intent.setClass(this, HelpActivity.class);
|
|
|
- intent.putExtra("caller", "result");
|
|
|
- // // intent.putExtra("password", password);
|
|
|
- // intent.putExtra("function_name", function_name);
|
|
|
- // intent.putExtra("behavior", Network.BEHAVIOR_SEARCH);
|
|
|
- startActivity(intent);
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
+ switch (item.getItemId())
|
|
|
+ {
|
|
|
+ case R.id.action_custom_fields:
|
|
|
+
|
|
|
+ intent.setClass(this, CustomizeFieldsActivity.class);
|
|
|
+ intent.putExtra("user", user);
|
|
|
+ // intent.putExtra("password", password);
|
|
|
+ intent.putExtra("function_name", function_name);
|
|
|
+ intent.putExtra("behavior", Network.BEHAVIOR_RESULT);
|
|
|
+ startActivity(intent);
|
|
|
+ break;
|
|
|
+ case R.id.action_help:
|
|
|
+ // Intent intent = new Intent();
|
|
|
+ intent.setClass(this, HelpActivity.class);
|
|
|
+ intent.putExtra("caller", "result");
|
|
|
+ // // intent.putExtra("password", password);
|
|
|
+ // intent.putExtra("function_name", function_name);
|
|
|
+ // intent.putExtra("behavior", Network.BEHAVIOR_SEARCH);
|
|
|
+ startActivity(intent);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
}
|
|
|
|
|
|
- public void requestdata(boolean requestcount) {
|
|
|
+ public void requestdata(boolean requestcount)
|
|
|
+ {
|
|
|
|
|
|
- if (m_task != null) {
|
|
|
+ if (m_task != null)
|
|
|
+ {
|
|
|
return;
|
|
|
}
|
|
|
mStatusMessageView.setText("Loading");
|
|
|
@@ -519,20 +568,24 @@ public class ResultActivity extends Activity {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void showProgress(final boolean show) {
|
|
|
+ private void showProgress(final boolean show)
|
|
|
+ {
|
|
|
// On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
|
|
|
// for very easy animations. If available, use these APIs to fade-in
|
|
|
// the progress spinner.
|
|
|
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2)
|
|
|
+ {
|
|
|
int shortAnimTime = getResources().getInteger(
|
|
|
android.R.integer.config_shortAnimTime);
|
|
|
|
|
|
mStatusView.setVisibility(View.VISIBLE);
|
|
|
mStatusView.animate().setDuration(shortAnimTime)
|
|
|
.alpha(show ? 1 : 0)
|
|
|
- .setListener(new AnimatorListenerAdapter() {
|
|
|
+ .setListener(new AnimatorListenerAdapter()
|
|
|
+ {
|
|
|
@Override
|
|
|
- public void onAnimationEnd(Animator animation) {
|
|
|
+ public void onAnimationEnd(Animator animation)
|
|
|
+ {
|
|
|
mStatusView.setVisibility(show ? View.VISIBLE
|
|
|
: View.INVISIBLE);
|
|
|
}
|
|
|
@@ -540,9 +593,11 @@ public class ResultActivity extends Activity {
|
|
|
|
|
|
footview.setVisibility(View.VISIBLE);
|
|
|
footview.animate().setDuration(shortAnimTime).alpha(show ? 0 : 1)
|
|
|
- .setListener(new AnimatorListenerAdapter() {
|
|
|
+ .setListener(new AnimatorListenerAdapter()
|
|
|
+ {
|
|
|
@Override
|
|
|
- public void onAnimationEnd(Animator animation) {
|
|
|
+ public void onAnimationEnd(Animator animation)
|
|
|
+ {
|
|
|
footview.setVisibility(show ? View.INVISIBLE
|
|
|
: View.VISIBLE);
|
|
|
}
|
|
|
@@ -559,7 +614,9 @@ public class ResultActivity extends Activity {
|
|
|
// : View.VISIBLE);
|
|
|
// }
|
|
|
// });
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
// The ViewPropertyAnimator APIs are not available, so simply show
|
|
|
// and hide the relevant UI components.
|
|
|
mStatusView.setVisibility(show ? View.VISIBLE : View.INVISIBLE);
|
|
|
@@ -569,13 +626,14 @@ public class ResultActivity extends Activity {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public class SearchTask extends AsyncTask<Boolean, Void, Boolean> {
|
|
|
+ public class SearchTask extends AsyncTask<Boolean, Void, Boolean>
|
|
|
+ {
|
|
|
// int err_code = ERR_CODE_NONE;
|
|
|
- int errorcode;
|
|
|
+ int errorcode;
|
|
|
|
|
|
@Override
|
|
|
- protected Boolean doInBackground(Boolean... params) {
|
|
|
-
|
|
|
+ protected Boolean doInBackground(Boolean... params)
|
|
|
+ {
|
|
|
|
|
|
if (!Network.NetworkIsAvailable())
|
|
|
|
|
|
@@ -584,13 +642,17 @@ public class ResultActivity extends Activity {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if (params[0]) {
|
|
|
+ if (params[0])
|
|
|
+ {
|
|
|
int ret = Network.get_recordcount(user, password, searchParms);
|
|
|
- if (ret >= 0) {
|
|
|
+ if (ret >= 0)
|
|
|
+ {
|
|
|
searchresult.put_totalcount(ret);
|
|
|
if (ret == 0)
|
|
|
return true;
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
errorcode = ret;
|
|
|
return false;
|
|
|
}
|
|
|
@@ -601,7 +663,8 @@ public class ResultActivity extends Activity {
|
|
|
searchParms.putString("offset", searchresult.get_offset() + "");
|
|
|
|
|
|
String jstr = Network.get_records(user, password, searchParms);
|
|
|
- if (jstr == null || jstr.length() <= 0) {
|
|
|
+ if (jstr == null || jstr.length() <= 0)
|
|
|
+ {
|
|
|
// Log.d(TAG, "json is wrong");
|
|
|
errorcode = Network.RESULT_NET_ERROR;
|
|
|
return false;
|
|
|
@@ -610,7 +673,8 @@ public class ResultActivity extends Activity {
|
|
|
JSONObject jsobj;
|
|
|
//
|
|
|
// array = new JSONArray(json);
|
|
|
- try {
|
|
|
+ try
|
|
|
+ {
|
|
|
jsobj = new JSONObject(jstr);
|
|
|
// if (searchresult.get_fieldscount() == 0)
|
|
|
// {
|
|
|
@@ -625,7 +689,9 @@ public class ResultActivity extends Activity {
|
|
|
|
|
|
return true;
|
|
|
|
|
|
- } catch (JSONException e) {
|
|
|
+ }
|
|
|
+ catch (JSONException e)
|
|
|
+ {
|
|
|
// TODO Auto-generated catch block
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -635,59 +701,66 @@ public class ResultActivity extends Activity {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- protected void onPostExecute(final Boolean success) {
|
|
|
+ protected void onPostExecute(final Boolean success)
|
|
|
+ {
|
|
|
Log.i("onPostExecute", "entry");
|
|
|
m_task = null;
|
|
|
showProgress(false);
|
|
|
|
|
|
- switch (errorcode) {
|
|
|
- case Network.RESULT_NET_NOTAVAILABLE: {
|
|
|
- Toast toast = Toast.makeText(getApplicationContext(),
|
|
|
- getText(R.string.msg_connection_none),
|
|
|
- Toast.LENGTH_LONG);
|
|
|
- toast.setGravity(Gravity.CENTER, 0, 0);
|
|
|
- toast.show();
|
|
|
- break;
|
|
|
- }
|
|
|
- case Network.RESULT_NET_ERROR: {
|
|
|
- Toast toast = Toast.makeText(getApplicationContext(),
|
|
|
- getText(R.string.msg_net_error), Toast.LENGTH_LONG);
|
|
|
- toast.setGravity(Gravity.CENTER, 0, 0);
|
|
|
- toast.show();
|
|
|
- break;
|
|
|
- }
|
|
|
- case Network.RESULT_ERROR:
|
|
|
- // case Network.RESULT_RESPONSE_NULL:
|
|
|
+ switch (errorcode)
|
|
|
{
|
|
|
- Toast toast = Toast.makeText(getApplicationContext(),
|
|
|
- getText(R.string.msg_net_resulterror),
|
|
|
- Toast.LENGTH_LONG);
|
|
|
- toast.setGravity(Gravity.CENTER, 0, 0);
|
|
|
- toast.show();
|
|
|
- break;
|
|
|
- }
|
|
|
+ case Network.RESULT_NET_NOTAVAILABLE:
|
|
|
+ {
|
|
|
+ Toast toast = Toast.makeText(getApplicationContext(),
|
|
|
+ getText(R.string.msg_connection_none),
|
|
|
+ Toast.LENGTH_LONG);
|
|
|
+ toast.setGravity(Gravity.CENTER, 0, 0);
|
|
|
+ toast.show();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case Network.RESULT_NET_ERROR:
|
|
|
+ {
|
|
|
+ Toast toast = Toast.makeText(getApplicationContext(),
|
|
|
+ getText(R.string.msg_net_error), Toast.LENGTH_LONG);
|
|
|
+ toast.setGravity(Gravity.CENTER, 0, 0);
|
|
|
+ toast.show();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case Network.RESULT_ERROR:
|
|
|
+ // case Network.RESULT_RESPONSE_NULL:
|
|
|
+ {
|
|
|
+ Toast toast = Toast.makeText(getApplicationContext(),
|
|
|
+ getText(R.string.msg_net_resulterror),
|
|
|
+ Toast.LENGTH_LONG);
|
|
|
+ toast.setGravity(Gravity.CENTER, 0, 0);
|
|
|
+ toast.show();
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- default:
|
|
|
- break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
- if (success) {
|
|
|
+ if (success)
|
|
|
+ {
|
|
|
|
|
|
initTable();
|
|
|
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
LinearLayout ll = (LinearLayout) findViewById(R.id.ll_refresh);
|
|
|
ll.setVisibility(View.VISIBLE);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- protected void onCancelled() {
|
|
|
+ protected void onCancelled()
|
|
|
+ {
|
|
|
m_task = null;
|
|
|
showProgress(false);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
|
|
|
@Override
|
|
|
protected void onSaveInstanceState(Bundle outState)
|
|
|
@@ -696,5 +769,4 @@ public class ResultActivity extends Activity {
|
|
|
super.onSaveInstanceState(outState);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
}
|