|
|
@@ -11,17 +11,26 @@ import org.json.JSONObject;
|
|
|
import com.usai.util.Network;
|
|
|
import com.usai.util.dbUtil;
|
|
|
|
|
|
+import android.net.Uri;
|
|
|
import android.os.AsyncTask;
|
|
|
import android.os.Build;
|
|
|
import android.os.Bundle;
|
|
|
import android.animation.Animator;
|
|
|
import android.animation.AnimatorListenerAdapter;
|
|
|
import android.app.Activity;
|
|
|
+import android.app.AlertDialog;
|
|
|
+import android.app.Dialog;
|
|
|
+import android.app.DownloadManager;
|
|
|
+import android.app.AlertDialog.Builder;
|
|
|
+import android.app.DownloadManager.Request;
|
|
|
+import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
|
import android.content.SharedPreferences;
|
|
|
import android.content.pm.PackageManager.NameNotFoundException;
|
|
|
import android.database.Cursor;
|
|
|
import android.database.sqlite.SQLiteDatabase;
|
|
|
+import android.text.Html;
|
|
|
+import android.text.style.URLSpan;
|
|
|
import android.util.Log;
|
|
|
import android.util.SparseArray;
|
|
|
import android.view.ContextMenu;
|
|
|
@@ -30,6 +39,7 @@ import android.view.Menu;
|
|
|
import android.view.MenuItem;
|
|
|
import android.view.View;
|
|
|
import android.view.ContextMenu.ContextMenuInfo;
|
|
|
+import android.view.View.OnClickListener;
|
|
|
import android.view.View.OnCreateContextMenuListener;
|
|
|
import android.widget.AdapterView.AdapterContextMenuInfo;
|
|
|
import android.widget.Button;
|
|
|
@@ -39,8 +49,7 @@ import android.widget.TableRow;
|
|
|
import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
-public class ResultActivity extends Activity
|
|
|
-{
|
|
|
+public class ResultActivity extends Activity {
|
|
|
String user = null;
|
|
|
String password = null;
|
|
|
String function_name = null;
|
|
|
@@ -57,6 +66,7 @@ public class ResultActivity extends Activity
|
|
|
// private View mSearchFormView;
|
|
|
private View footview;
|
|
|
private View mStatusView;
|
|
|
+ int actioncount=0;
|
|
|
|
|
|
// private class resultAdapter extends SimpleAdapter
|
|
|
// {
|
|
|
@@ -64,30 +74,40 @@ 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");
|
|
|
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()) {
|
|
|
+ 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);
|
|
|
@@ -97,18 +117,15 @@ 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);
|
|
|
}
|
|
|
@@ -119,12 +136,10 @@ 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)
|
|
|
@@ -138,13 +153,11 @@ 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!!!
|
|
|
@@ -155,9 +168,7 @@ public class ResultActivity extends Activity
|
|
|
startActivity(intent);
|
|
|
|
|
|
}
|
|
|
- }
|
|
|
- catch (NameNotFoundException e)
|
|
|
- {
|
|
|
+ } catch (NameNotFoundException e) {
|
|
|
// TODO Auto-generated catch block
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -166,28 +177,21 @@ public class ResultActivity extends Activity
|
|
|
|
|
|
}
|
|
|
|
|
|
- private OnCreateContextMenuListener m_tableMenu = new OnCreateContextMenuListener()
|
|
|
- {
|
|
|
+ private OnCreateContextMenuListener m_tableMenu = new OnCreateContextMenuListener() {
|
|
|
|
|
|
@Override
|
|
|
public void onCreateContextMenu(ContextMenu contextmenu, View view,
|
|
|
- ContextMenuInfo contextmenuinfo)
|
|
|
- {
|
|
|
- // TODO Auto-generated method stub
|
|
|
- // TableLayout tl = (TableLayout) view;
|
|
|
- //
|
|
|
- // TableRow tr = (TableRow) tl.getFocusedChild();
|
|
|
- // View v = (View) tl.getFocusedChild();
|
|
|
- contextmenu.add(Menu.NONE, 0, 0, "Detail");
|
|
|
- // contextmenu.add(Menu.NONE, 1, 1, "�༭");
|
|
|
+ ContextMenuInfo contextmenuinfo) {
|
|
|
+
|
|
|
+
|
|
|
+ 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+ "");
|
|
|
|
|
|
@@ -200,8 +204,7 @@ 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);
|
|
|
@@ -229,8 +232,7 @@ public class ResultActivity extends Activity
|
|
|
// super.onCreateContextMenu(menu, v, menuInfo);
|
|
|
// }
|
|
|
|
|
|
- void initTable()
|
|
|
- {
|
|
|
+ void initTable() {
|
|
|
|
|
|
TableLayout tl = (TableLayout) findViewById(R.id.result_table);
|
|
|
tl.setFocusable(true);
|
|
|
@@ -253,8 +255,7 @@ 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);
|
|
|
@@ -282,19 +283,16 @@ 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())
|
|
|
- {
|
|
|
+ switch (item.getItemId()) {
|
|
|
case R.id.action_custom_fields:
|
|
|
|
|
|
intent.setClass(this, CustomizeFieldsActivity.class);
|
|
|
@@ -319,11 +317,9 @@ public class ResultActivity extends Activity
|
|
|
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");
|
|
|
@@ -333,24 +329,20 @@ 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);
|
|
|
}
|
|
|
@@ -358,11 +350,9 @@ 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);
|
|
|
}
|
|
|
@@ -379,9 +369,7 @@ 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);
|
|
|
@@ -391,14 +379,12 @@ 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;
|
|
|
|
|
|
@Override
|
|
|
- protected Boolean doInBackground(Boolean... params)
|
|
|
- {
|
|
|
+ protected Boolean doInBackground(Boolean... params) {
|
|
|
|
|
|
if (!Network.NetworkIsAvailable())
|
|
|
|
|
|
@@ -407,17 +393,13 @@ 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;
|
|
|
}
|
|
|
@@ -428,8 +410,7 @@ 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;
|
|
|
@@ -438,8 +419,7 @@ public class ResultActivity extends Activity
|
|
|
JSONObject jsobj;
|
|
|
//
|
|
|
// array = new JSONArray(json);
|
|
|
- try
|
|
|
- {
|
|
|
+ try {
|
|
|
jsobj = new JSONObject(jstr);
|
|
|
// if (searchresult.get_fieldscount() == 0)
|
|
|
// {
|
|
|
@@ -454,9 +434,7 @@ public class ResultActivity extends Activity
|
|
|
|
|
|
return true;
|
|
|
|
|
|
- }
|
|
|
- catch (JSONException e)
|
|
|
- {
|
|
|
+ } catch (JSONException e) {
|
|
|
// TODO Auto-generated catch block
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -466,16 +444,13 @@ 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:
|
|
|
- {
|
|
|
+ switch (errorcode) {
|
|
|
+ case Network.RESULT_NET_NOTAVAILABLE: {
|
|
|
Toast toast = Toast.makeText(getApplicationContext(),
|
|
|
getText(R.string.msg_connection_none),
|
|
|
Toast.LENGTH_LONG);
|
|
|
@@ -483,8 +458,7 @@ public class ResultActivity extends Activity
|
|
|
toast.show();
|
|
|
return;
|
|
|
}
|
|
|
- case Network.RESULT_NET_ERROR:
|
|
|
- {
|
|
|
+ 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);
|
|
|
@@ -506,19 +480,16 @@ public class ResultActivity extends Activity
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- if (success)
|
|
|
- {
|
|
|
+ if (success) {
|
|
|
|
|
|
// 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
|
|
|
+ } else
|
|
|
tv_head.setText(/*
|
|
|
* loadcount + "/" +
|
|
|
*/searchresult.get_totalcount()
|
|
|
@@ -527,17 +498,14 @@ public class ResultActivity extends Activity
|
|
|
|
|
|
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()
|
|
|
- {
|
|
|
+ .setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
|
|
@Override
|
|
|
- public boolean onLongClick(View v)
|
|
|
- {
|
|
|
+ public boolean onLongClick(View v) {
|
|
|
// TODO Auto-generated method stub
|
|
|
// v.setBackgroundColor(Color.GRAY);
|
|
|
// v.showContextMenu();
|
|
|
@@ -568,10 +536,9 @@ 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"))
|
|
|
@@ -579,7 +546,76 @@ public class ResultActivity extends Activity
|
|
|
|
|
|
// field1.setBackgroundColor(0xFFFFFFFF);
|
|
|
|
|
|
- field1.setText(str);
|
|
|
+ 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();
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ // field1.setText(str);
|
|
|
field1.setGravity(Gravity.CENTER);
|
|
|
field1.setPadding(10, 5, 10, 5);
|
|
|
field1.setTextSize(20);
|
|
|
@@ -595,8 +631,7 @@ 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)
|
|
|
@@ -604,24 +639,20 @@ public class ResultActivity extends Activity
|
|
|
else
|
|
|
btnnext.setEnabled(true);
|
|
|
|
|
|
- }
|
|
|
- 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);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private class SearchResult
|
|
|
- {
|
|
|
+ private class SearchResult {
|
|
|
int total_count = -1;
|
|
|
// int direction = 1;
|
|
|
int offset = 0;
|
|
|
@@ -637,24 +668,19 @@ public class ResultActivity extends Activity
|
|
|
//
|
|
|
// }
|
|
|
|
|
|
- public int get_recordscount()
|
|
|
- {
|
|
|
+ public int get_recordscount() {
|
|
|
return records.size();
|
|
|
}
|
|
|
|
|
|
- public HashMap<String, String> get_record(int i)
|
|
|
- {
|
|
|
+ public HashMap<String, String> get_record(int i) {
|
|
|
return records.get(i);
|
|
|
}
|
|
|
|
|
|
- public void add_records(String jsonstr)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
+ public void add_records(String jsonstr) {
|
|
|
+ try {
|
|
|
records.clear();
|
|
|
JSONObject objrecords = new JSONObject(jsonstr);
|
|
|
- for (int i = 0; i < objrecords.length(); i++)
|
|
|
- {
|
|
|
+ for (int i = 0; i < objrecords.length(); i++) {
|
|
|
// offset++;
|
|
|
JSONObject rec = objrecords.getJSONObject("record" + i);
|
|
|
Iterator<?> it = rec.keys();
|
|
|
@@ -672,9 +698,7 @@ public class ResultActivity extends Activity
|
|
|
// searchresult.set_offset(offset);
|
|
|
// Log.e("records count:",objrecords.length()+"");
|
|
|
|
|
|
- }
|
|
|
- catch (JSONException e)
|
|
|
- {
|
|
|
+ } catch (JSONException e) {
|
|
|
// TODO Auto-generated catch block
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -682,18 +706,15 @@ public class ResultActivity extends Activity
|
|
|
Log.d(TAG, jsonstr);
|
|
|
}
|
|
|
|
|
|
- public int get_totalcount()
|
|
|
- {
|
|
|
+ public int get_totalcount() {
|
|
|
return total_count;
|
|
|
}
|
|
|
|
|
|
- public void put_totalcount(int c)
|
|
|
- {
|
|
|
+ public void put_totalcount(int c) {
|
|
|
total_count = c;
|
|
|
}
|
|
|
|
|
|
- public int get_offset()
|
|
|
- {
|
|
|
+ public int get_offset() {
|
|
|
return offset;
|
|
|
}
|
|
|
|
|
|
@@ -702,8 +723,7 @@ public class ResultActivity extends Activity
|
|
|
// return direction;
|
|
|
// }
|
|
|
|
|
|
- public void set_offset(int i)
|
|
|
- {
|
|
|
+ public void set_offset(int i) {
|
|
|
offset = i;
|
|
|
|
|
|
}
|