|
@@ -51,7 +51,7 @@ public class ResultActivity extends Activity
|
|
|
HashMap<Integer, String> showfieldmap = new HashMap<Integer, String>();
|
|
HashMap<Integer, String> showfieldmap = new HashMap<Integer, String>();
|
|
|
private TextView mStatusMessageView;
|
|
private TextView mStatusMessageView;
|
|
|
// private View mSearchFormView;
|
|
// private View mSearchFormView;
|
|
|
- private Button mbtnMore;
|
|
|
|
|
|
|
+ private View footview;
|
|
|
private View mStatusView;
|
|
private View mStatusView;
|
|
|
|
|
|
|
|
// private class resultAdapter extends SimpleAdapter
|
|
// private class resultAdapter extends SimpleAdapter
|
|
@@ -68,9 +68,10 @@ public class ResultActivity extends Activity
|
|
|
searchParms = getIntent().getBundleExtra("searchParms");
|
|
searchParms = getIntent().getBundleExtra("searchParms");
|
|
|
super.onCreate(savedInstanceState);
|
|
super.onCreate(savedInstanceState);
|
|
|
setContentView(R.layout.activity_result);
|
|
setContentView(R.layout.activity_result);
|
|
|
|
|
+ footview = findViewById(R.id.foot);
|
|
|
// mSearchFormView = findViewById(R.id.search_form);
|
|
// mSearchFormView = findViewById(R.id.search_form);
|
|
|
- mbtnMore = (Button) findViewById(R.id.btn_more);
|
|
|
|
|
- mbtnMore.setOnClickListener(new View.OnClickListener()
|
|
|
|
|
|
|
+ Button btnnext = (Button) findViewById(R.id.btn_next);
|
|
|
|
|
+ btnnext.setOnClickListener(new View.OnClickListener()
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -78,6 +79,26 @@ public class ResultActivity extends Activity
|
|
|
{
|
|
{
|
|
|
// TextView tv_head = (TextView) findViewById(R.id.tv_head);
|
|
// TextView tv_head = (TextView) findViewById(R.id.tv_head);
|
|
|
|
|
|
|
|
|
|
+ searchresult.set_direction(1);
|
|
|
|
|
+ if (searchresult.get_totalcount()==-1)
|
|
|
|
|
+ requestdata(true);
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ requestdata(false);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Button btnpre = (Button) findViewById(R.id.btn_pre);
|
|
|
|
|
+ btnpre.setOnClickListener(new View.OnClickListener()
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(View v)
|
|
|
|
|
+ {
|
|
|
|
|
+// TextView tv_head = (TextView) findViewById(R.id.tv_head);
|
|
|
|
|
+ searchresult.set_direction(-1);
|
|
|
if (searchresult.get_totalcount()==-1)
|
|
if (searchresult.get_totalcount()==-1)
|
|
|
requestdata(true);
|
|
requestdata(true);
|
|
|
else
|
|
else
|
|
@@ -109,12 +130,15 @@ public class ResultActivity extends Activity
|
|
|
HashMap<String, String> map = new HashMap<String, String>();
|
|
HashMap<String, String> map = new HashMap<String, String>();
|
|
|
map.put("key", "no.");
|
|
map.put("key", "no.");
|
|
|
gridheader.add(map);
|
|
gridheader.add(map);
|
|
|
|
|
+ Button btn = new Button(this);
|
|
|
|
|
+ btn.setText("No.");
|
|
|
|
|
+ headerRow.addView(btn);
|
|
|
while (cursor.moveToNext())
|
|
while (cursor.moveToNext())
|
|
|
{
|
|
{
|
|
|
String aname = cursor.getString(0);
|
|
String aname = cursor.getString(0);
|
|
|
- Button btn = new Button(this);
|
|
|
|
|
- btn.setText(aname);
|
|
|
|
|
- headerRow.addView(btn);
|
|
|
|
|
|
|
+ Button btn1 = new Button(this);
|
|
|
|
|
+ btn1.setText(aname);
|
|
|
|
|
+ headerRow.addView(btn1);
|
|
|
showfieldmap.put(pos, cursor.getString(1));
|
|
showfieldmap.put(pos, cursor.getString(1));
|
|
|
|
|
|
|
|
map.put("key", "header");
|
|
map.put("key", "header");
|
|
@@ -167,6 +191,7 @@ public class ResultActivity extends Activity
|
|
|
|
|
|
|
|
public void requestdata(boolean requestcount)
|
|
public void requestdata(boolean requestcount)
|
|
|
{
|
|
{
|
|
|
|
|
+
|
|
|
if (m_task != null)
|
|
if (m_task != null)
|
|
|
{
|
|
{
|
|
|
return;
|
|
return;
|
|
@@ -201,14 +226,14 @@ public class ResultActivity extends Activity
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- mbtnMore.setVisibility(View.VISIBLE);
|
|
|
|
|
- mbtnMore.animate().setDuration(shortAnimTime).alpha(show ? 0 : 1)
|
|
|
|
|
|
|
+ footview.setVisibility(View.VISIBLE);
|
|
|
|
|
+ footview.animate().setDuration(shortAnimTime).alpha(show ? 0 : 1)
|
|
|
.setListener(new AnimatorListenerAdapter()
|
|
.setListener(new AnimatorListenerAdapter()
|
|
|
{
|
|
{
|
|
|
@Override
|
|
@Override
|
|
|
public void onAnimationEnd(Animator animation)
|
|
public void onAnimationEnd(Animator animation)
|
|
|
{
|
|
{
|
|
|
- mbtnMore.setVisibility(show ? View.INVISIBLE
|
|
|
|
|
|
|
+ footview.setVisibility(show ? View.INVISIBLE
|
|
|
: View.VISIBLE);
|
|
: View.VISIBLE);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
@@ -230,7 +255,7 @@ public class ResultActivity extends Activity
|
|
|
// The ViewPropertyAnimator APIs are not available, so simply show
|
|
// The ViewPropertyAnimator APIs are not available, so simply show
|
|
|
// and hide the relevant UI components.
|
|
// and hide the relevant UI components.
|
|
|
mStatusView.setVisibility(show ? View.VISIBLE : View.INVISIBLE);
|
|
mStatusView.setVisibility(show ? View.VISIBLE : View.INVISIBLE);
|
|
|
- mbtnMore.setVisibility(show ? View.INVISIBLE : View.VISIBLE);
|
|
|
|
|
|
|
+ footview.setVisibility(show ? View.INVISIBLE : View.VISIBLE);
|
|
|
// mSearchFormView.setVisibility(show ? View.INVISIBLE :
|
|
// mSearchFormView.setVisibility(show ? View.INVISIBLE :
|
|
|
// View.VISIBLE);
|
|
// View.VISIBLE);
|
|
|
}
|
|
}
|
|
@@ -268,7 +293,10 @@ public class ResultActivity extends Activity
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- searchParms.putString("offset", searchresult.get_count()+"");
|
|
|
|
|
|
|
+ if(searchresult.get_direction()==-1)
|
|
|
|
|
+ searchresult.set_offset(searchresult.get_offset()-20);
|
|
|
|
|
+ searchParms.putString("offset", searchresult.get_offset()+"");
|
|
|
|
|
+
|
|
|
String jstr = Network.get_records(user, password, searchParms);
|
|
String jstr = Network.get_records(user, password, searchParms);
|
|
|
if (jstr == null || jstr.length() <= 0)
|
|
if (jstr == null || jstr.length() <= 0)
|
|
|
{
|
|
{
|
|
@@ -283,12 +311,12 @@ public class ResultActivity extends Activity
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
|
jsobj = new JSONObject(jstr);
|
|
jsobj = new JSONObject(jstr);
|
|
|
- if (searchresult.get_fieldscount() == 0)
|
|
|
|
|
- {
|
|
|
|
|
- JSONObject objfields = jsobj.getJSONObject("fields");
|
|
|
|
|
- if (objfields != null)
|
|
|
|
|
- searchresult.init_fields(objfields.toString());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// if (searchresult.get_fieldscount() == 0)
|
|
|
|
|
+// {
|
|
|
|
|
+// JSONObject objfields = jsobj.getJSONObject("fields");
|
|
|
|
|
+// if (objfields != null)
|
|
|
|
|
+// searchresult.init_fields(objfields.toString());
|
|
|
|
|
+// }
|
|
|
JSONObject objrecords = jsobj.getJSONObject("records");
|
|
JSONObject objrecords = jsobj.getJSONObject("records");
|
|
|
if (objrecords != null)
|
|
if (objrecords != null)
|
|
|
searchresult.add_records(objrecords.toString());
|
|
searchresult.add_records(objrecords.toString());
|
|
@@ -351,37 +379,60 @@ public class ResultActivity extends Activity
|
|
|
if (success)
|
|
if (success)
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
- int loadcount = searchresult.get_count();
|
|
|
|
|
|
|
+// int loadcount = searchresult.get_count();
|
|
|
int totalcount = searchresult.get_totalcount();
|
|
int totalcount = searchresult.get_totalcount();
|
|
|
- TextView tv_head = (TextView) findViewById(R.id.tv_head);
|
|
|
|
|
|
|
+ TextView tv_head = (TextView) findViewById(R.id.head);
|
|
|
if (totalcount == 0)
|
|
if (totalcount == 0)
|
|
|
tv_head.setText("0 record found");
|
|
tv_head.setText("0 record found");
|
|
|
else
|
|
else
|
|
|
- tv_head.setText(loadcount + "/"
|
|
|
|
|
- + searchresult.get_totalcount() + " records");
|
|
|
|
|
|
|
+ tv_head.setText(/*loadcount + "/"
|
|
|
|
|
+ + */searchresult.get_totalcount() + " records");
|
|
|
TableLayout tl = (TableLayout) findViewById(R.id.result_table);
|
|
TableLayout tl = (TableLayout) findViewById(R.id.result_table);
|
|
|
|
|
|
|
|
int showcount = tl.getChildCount();
|
|
int showcount = tl.getChildCount();
|
|
|
- int newcount = loadcount - showcount + 1;// +1 header row
|
|
|
|
|
- for (int i = 0; i < newcount; i++)
|
|
|
|
|
|
|
+ tl.removeViews(1, tl.getChildCount()-1);
|
|
|
|
|
+// int newcount = loadcount - showcount + 1;// +1 header row
|
|
|
|
|
+ for (int i = 0; i < 10; i++)
|
|
|
{
|
|
{
|
|
|
- TableRow recordRow = new TableRow(ResultActivity.this);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ TableRow recordRow= new TableRow(ResultActivity.this);
|
|
|
|
|
+
|
|
|
HashMap<String, String> record = searchresult
|
|
HashMap<String, String> record = searchresult
|
|
|
- .get_record(loadcount - newcount);
|
|
|
|
|
|
|
+ .get_record(i);
|
|
|
|
|
+ TextView field = new TextView(ResultActivity.this);
|
|
|
|
|
+ field.setText(searchresult.get_offset()-10+i+"");
|
|
|
|
|
+ Log.d("offset="+searchresult.get_offset(), "direction="+searchresult.get_direction());
|
|
|
|
|
+ field.setGravity(Gravity.CENTER);
|
|
|
|
|
+ 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 field = new TextView(ResultActivity.this);
|
|
|
|
|
- field.setText(record.get(showfieldmap.get(j)));
|
|
|
|
|
- field.setGravity(Gravity.CENTER);
|
|
|
|
|
- field.setPadding(10, 5, 10, 5);
|
|
|
|
|
- field.setTextSize(20);
|
|
|
|
|
|
|
+ TextView field1 = new TextView(ResultActivity.this);
|
|
|
|
|
+ field1.setText(record.get(showfieldmap.get(j)));
|
|
|
|
|
+ field1.setGravity(Gravity.CENTER);
|
|
|
|
|
+ field1.setPadding(10, 5, 10, 5);
|
|
|
|
|
+ field1.setTextSize(20);
|
|
|
// field.setTextAppearance(ResultActivity.this,
|
|
// field.setTextAppearance(ResultActivity.this,
|
|
|
// android.R.attr.textAppearanceMedium);
|
|
// android.R.attr.textAppearanceMedium);
|
|
|
- recordRow.addView(field);
|
|
|
|
|
|
|
+ recordRow.addView(field1);
|
|
|
}
|
|
}
|
|
|
tl.addView(recordRow);
|
|
tl.addView(recordRow);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ Button btnnext = (Button) findViewById(R.id.btn_next);
|
|
|
|
|
+
|
|
|
|
|
+ Button btnpre = (Button) findViewById(R.id.btn_pre);
|
|
|
|
|
+ if(searchresult.get_offset()<=10)
|
|
|
|
|
+ btnpre.setEnabled(false);
|
|
|
|
|
+ else {
|
|
|
|
|
+ btnpre.setEnabled(true);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(searchresult.get_totalcount()-searchresult.get_offset()<=10)
|
|
|
|
|
+ btnnext.setEnabled(false);
|
|
|
|
|
+ else
|
|
|
|
|
+ btnnext.setEnabled(true);
|
|
|
// // fill fake data
|
|
// // fill fake data
|
|
|
// for(int i=0;i<10;i++)
|
|
// for(int i=0;i<10;i++)
|
|
|
// {
|
|
// {
|
|
@@ -432,16 +483,18 @@ public class ResultActivity extends Activity
|
|
|
private class SearchResult
|
|
private class SearchResult
|
|
|
{
|
|
{
|
|
|
int total_count = -1;
|
|
int total_count = -1;
|
|
|
|
|
+ int direction = 1;
|
|
|
|
|
+ int offset = 0;
|
|
|
// int count = 0;
|
|
// int count = 0;
|
|
|
ArrayList<HashMap<String, String>> records = new ArrayList<HashMap<String, String>>();
|
|
ArrayList<HashMap<String, String>> records = new ArrayList<HashMap<String, String>>();
|
|
|
- ArrayList<field> fields = new ArrayList<field>();
|
|
|
|
|
|
|
+// ArrayList<field> fields = new ArrayList<field>();
|
|
|
|
|
|
|
|
- public void init_fields(String jsonfields)
|
|
|
|
|
- {
|
|
|
|
|
- String TAG = "init_fields@ResultActivity.SearchResult";
|
|
|
|
|
- Log.d(TAG, jsonfields);
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// public void init_fields(String jsonfields)
|
|
|
|
|
+// {
|
|
|
|
|
+// String TAG = "init_fields@ResultActivity.SearchResult";
|
|
|
|
|
+// Log.d(TAG, jsonfields);
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
public HashMap<String, String> get_record(int i)
|
|
public HashMap<String, String> get_record(int i)
|
|
|
{
|
|
{
|
|
@@ -452,9 +505,11 @@ public class ResultActivity extends Activity
|
|
|
{
|
|
{
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
|
|
|
+ records.clear();
|
|
|
JSONObject objrecords = new JSONObject(jsonstr);
|
|
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);
|
|
JSONObject rec = objrecords.getJSONObject("record" + i);
|
|
|
Iterator it = rec.keys();
|
|
Iterator it = rec.keys();
|
|
|
HashMap<String, String> record = new HashMap<String, String>();
|
|
HashMap<String, String> record = new HashMap<String, String>();
|
|
@@ -467,6 +522,7 @@ public class ResultActivity extends Activity
|
|
|
records.add(record);
|
|
records.add(record);
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+// searchresult.set_offset(offset);
|
|
|
// Log.e("records count:",objrecords.length()+"");
|
|
// Log.e("records count:",objrecords.length()+"");
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -489,15 +545,33 @@ public class ResultActivity extends Activity
|
|
|
total_count = c;
|
|
total_count = c;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public int get_count()
|
|
|
|
|
|
|
+ public int get_offset()
|
|
|
{
|
|
{
|
|
|
- return records.size();
|
|
|
|
|
|
|
+ return offset;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- public int get_fieldscount()
|
|
|
|
|
|
|
+ public int get_direction()
|
|
|
|
|
+ {
|
|
|
|
|
+ return direction;
|
|
|
|
|
+ }
|
|
|
|
|
+ public void set_offset(int i)
|
|
|
{
|
|
{
|
|
|
- return fields.size();
|
|
|
|
|
|
|
+ offset=i;
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
+ public void set_direction(int i)
|
|
|
|
|
+ {
|
|
|
|
|
+ direction=i;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+// public int get_count()
|
|
|
|
|
+// {
|
|
|
|
|
+// return records.size();
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+// public int get_fieldscount()
|
|
|
|
|
+// {
|
|
|
|
|
+// return fields.size();
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
// private class record
|
|
// private class record
|
|
|
// {
|
|
// {
|
|
@@ -505,28 +579,28 @@ public class ResultActivity extends Activity
|
|
|
//
|
|
//
|
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
- private class field
|
|
|
|
|
- {
|
|
|
|
|
- String name = null;
|
|
|
|
|
- String aliasname = null;
|
|
|
|
|
- String type = null;
|
|
|
|
|
-
|
|
|
|
|
- public String get_name()
|
|
|
|
|
- {
|
|
|
|
|
- return name;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public String get_aliasname()
|
|
|
|
|
- {
|
|
|
|
|
- return aliasname;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public String get_type()
|
|
|
|
|
- {
|
|
|
|
|
- return type;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// private class field
|
|
|
|
|
+// {
|
|
|
|
|
+// String name = null;
|
|
|
|
|
+// String aliasname = null;
|
|
|
|
|
+// String type = null;
|
|
|
|
|
+//
|
|
|
|
|
+// public String get_name()
|
|
|
|
|
+// {
|
|
|
|
|
+// return name;
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// public String get_aliasname()
|
|
|
|
|
+// {
|
|
|
|
|
+// return aliasname;
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// public String get_type()
|
|
|
|
|
+// {
|
|
|
|
|
+// return type;
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|