|
@@ -10,6 +10,7 @@ import android.database.DataSetObserver;
|
|
|
import android.graphics.Color;
|
|
import android.graphics.Color;
|
|
|
import android.net.Uri;
|
|
import android.net.Uri;
|
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
|
|
+import android.support.v4.widget.SwipeRefreshLayout;
|
|
|
import android.support.v7.app.AlertDialog;
|
|
import android.support.v7.app.AlertDialog;
|
|
|
import android.support.v7.app.AppCompatActivity;
|
|
import android.support.v7.app.AppCompatActivity;
|
|
|
import android.text.Html;
|
|
import android.text.Html;
|
|
@@ -55,7 +56,7 @@ import java.util.Iterator;
|
|
|
public class SearchResultActivity extends AppCompatActivity implements AbsListView.OnScrollListener {
|
|
public class SearchResultActivity extends AppCompatActivity implements AbsListView.OnScrollListener {
|
|
|
|
|
|
|
|
protected Bundle mParams;
|
|
protected Bundle mParams;
|
|
|
- protected JSONObject resultData;
|
|
|
|
|
|
|
+ protected JSONObject resultData = new JSONObject();
|
|
|
|
|
|
|
|
protected Context mContext;
|
|
protected Context mContext;
|
|
|
protected ListView resultListView;
|
|
protected ListView resultListView;
|
|
@@ -411,12 +412,19 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
|
|
|
|
|
- mParams.putInt("offset",adapter.getCount());
|
|
|
|
|
|
|
+ mParams.putInt("offset",0);
|
|
|
mParams.putInt("limit",25);
|
|
mParams.putInt("limit",25);
|
|
|
- resultData = Network.query(mParams);
|
|
|
|
|
- if (resultData == null) {
|
|
|
|
|
- resultData = new JSONObject();
|
|
|
|
|
|
|
+ JSONObject new_resultData = Network.query(mParams);
|
|
|
|
|
+
|
|
|
|
|
+ if (new_resultData != null) {
|
|
|
|
|
+ Iterator<String> iterator = new_resultData.keys();
|
|
|
|
|
+ while (iterator.hasNext()) {
|
|
|
|
|
+ String key = iterator.next();
|
|
|
|
|
+ Object value = new_resultData.get(key);
|
|
|
|
|
+ resultData.put(key,value);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
runOnUiThread(new Runnable() {
|
|
runOnUiThread(new Runnable() {
|
|
|
@Override
|
|
@Override
|
|
|
public void run() {
|
|
public void run() {
|
|
@@ -667,12 +675,12 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void registerDataSetObserver(DataSetObserver observer) {
|
|
public void registerDataSetObserver(DataSetObserver observer) {
|
|
|
-
|
|
|
|
|
|
|
+ super.registerDataSetObserver(observer);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void unregisterDataSetObserver(DataSetObserver observer) {
|
|
public void unregisterDataSetObserver(DataSetObserver observer) {
|
|
|
-
|
|
|
|
|
|
|
+ super.unregisterDataSetObserver(observer);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -776,10 +784,13 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
|
|
|
margin_b = convertDp2Px(margin_b);
|
|
margin_b = convertDp2Px(margin_b);
|
|
|
margin_r = convertDp2Px(margin_r);
|
|
margin_r = convertDp2Px(margin_r);
|
|
|
|
|
|
|
|
|
|
+
|
|
|
HorizontalScrollView.LayoutParams listViewLayoutParams = (HorizontalScrollView.LayoutParams)resultListView.getLayoutParams();
|
|
HorizontalScrollView.LayoutParams listViewLayoutParams = (HorizontalScrollView.LayoutParams)resultListView.getLayoutParams();
|
|
|
listViewLayoutParams.width = width;
|
|
listViewLayoutParams.width = width;
|
|
|
resultListView.setLayoutParams(listViewLayoutParams);
|
|
resultListView.setLayoutParams(listViewLayoutParams);
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
JSONArray obj = (JSONArray)getItem(position);
|
|
JSONArray obj = (JSONArray)getItem(position);
|
|
|
JSONArray arr_col = header.getJSONArray("col");
|
|
JSONArray arr_col = header.getJSONArray("col");
|
|
|
|
|
|
|
@@ -822,27 +833,27 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
|
|
|
TextView tv = (TextView)holder.row.findViewById(i);
|
|
TextView tv = (TextView)holder.row.findViewById(i);
|
|
|
if (tv == null) {
|
|
if (tv == null) {
|
|
|
tv = new TextView(mContext);
|
|
tv = new TextView(mContext);
|
|
|
- tv.setWidth(col_w);
|
|
|
|
|
- tv.setHeight(height);
|
|
|
|
|
- tv.setGravity(convertGravity("h_align",h_align) | convertGravity("v_center",v_center));
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
+ tv.setGravity(convertGravity("h_align",h_align) | convertGravity("v_center",v_center));
|
|
|
tv.setSingleLine();
|
|
tv.setSingleLine();
|
|
|
tv.setEllipsize(TextUtils.TruncateAt.END);
|
|
tv.setEllipsize(TextUtils.TruncateAt.END);
|
|
|
-
|
|
|
|
|
- tv.setPadding(margin_l,margin_t,margin_r,margin_b);
|
|
|
|
|
-
|
|
|
|
|
- TableRow.LayoutParams tvLayoutParams = new TableRow.LayoutParams(col_w, height);
|
|
|
|
|
-// tv.setLayoutParams(tvLayoutParams);
|
|
|
|
|
-
|
|
|
|
|
tv.setId(i);
|
|
tv.setId(i);
|
|
|
- holder.row.addView(tv,i,tvLayoutParams);
|
|
|
|
|
tv.setBackgroundDrawable(getResources().getDrawable(R.drawable.result_black_border));
|
|
tv.setBackgroundDrawable(getResources().getDrawable(R.drawable.result_black_border));
|
|
|
-
|
|
|
|
|
tv.setOnTouchListener(resultRowClickListener);
|
|
tv.setOnTouchListener(resultRowClickListener);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ holder.row.removeView(tv);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // layout
|
|
|
|
|
+ tv.setWidth(col_w);
|
|
|
|
|
+ tv.setHeight(height);
|
|
|
|
|
+ tv.setPadding(margin_l,margin_t,margin_r,margin_b);
|
|
|
|
|
+
|
|
|
|
|
+ TableRow.LayoutParams tvLayoutParams = new TableRow.LayoutParams(col_w, height);
|
|
|
|
|
+
|
|
|
|
|
+ holder.row.addView(tv,i,tvLayoutParams);
|
|
|
|
|
+
|
|
|
|
|
+ // content
|
|
|
tv.setTextColor(Color.parseColor(f_color));
|
|
tv.setTextColor(Color.parseColor(f_color));
|
|
|
|
|
|
|
|
|
|
|
|
@@ -913,25 +924,27 @@ public class SearchResultActivity extends AppCompatActivity implements AbsListVi
|
|
|
TextView tv = (TextView) holder.row.findViewById(i);
|
|
TextView tv = (TextView) holder.row.findViewById(i);
|
|
|
if (tv == null) {
|
|
if (tv == null) {
|
|
|
tv = new TextView(mContext);
|
|
tv = new TextView(mContext);
|
|
|
- tv.setWidth(col_w);
|
|
|
|
|
- tv.setHeight(col_h);
|
|
|
|
|
- tv.setGravity(convertGravity("h_align",h_align) | convertGravity("v_center",v_center));
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
+ tv.setGravity(convertGravity("h_align",h_align) | convertGravity("v_center",v_center));
|
|
|
tv.setSingleLine();
|
|
tv.setSingleLine();
|
|
|
tv.setEllipsize(TextUtils.TruncateAt.END);
|
|
tv.setEllipsize(TextUtils.TruncateAt.END);
|
|
|
-
|
|
|
|
|
- tv.setPadding(margin_l,margin_t,margin_r,margin_b);
|
|
|
|
|
-
|
|
|
|
|
- TableRow.LayoutParams tvLayoutParams = new TableRow.LayoutParams(col_w, col_h);
|
|
|
|
|
-
|
|
|
|
|
tv.setId(i);
|
|
tv.setId(i);
|
|
|
- holder.row.addView(tv,i,tvLayoutParams);
|
|
|
|
|
-
|
|
|
|
|
tv.setOnTouchListener(resultRowClickListener);
|
|
tv.setOnTouchListener(resultRowClickListener);
|
|
|
tv.setBackgroundDrawable(getResources().getDrawable(R.drawable.result_black_border));
|
|
tv.setBackgroundDrawable(getResources().getDrawable(R.drawable.result_black_border));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ holder.row.removeView(tv);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // layout
|
|
|
|
|
+ tv.setWidth(col_w);
|
|
|
|
|
+ tv.setHeight(col_h);
|
|
|
|
|
+ tv.setPadding(margin_l,margin_t,margin_r,margin_b);
|
|
|
|
|
+
|
|
|
|
|
+ TableRow.LayoutParams tvLayoutParams = new TableRow.LayoutParams(col_w, col_h);
|
|
|
|
|
+ holder.row.addView(tv,i,tvLayoutParams);
|
|
|
|
|
+
|
|
|
|
|
+ // content
|
|
|
|
|
+
|
|
|
tv.setTextColor(Color.parseColor(col_f_color));
|
|
tv.setTextColor(Color.parseColor(col_f_color));
|
|
|
|
|
|
|
|
if (value.contains("</")) {
|
|
if (value.contains("</")) {
|