|
|
@@ -20,20 +20,24 @@ import android.widget.TextView;
|
|
|
import androidx.appcompat.app.AlertDialog;
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
|
|
+import com.usai.redant.rautils.application.RedantApplication;
|
|
|
import com.usai.redant.rautils.utils.Network;
|
|
|
import com.usai.redant.rautils.utils.RAUtil;
|
|
|
|
|
|
+import org.json.JSONException;
|
|
|
import org.json.JSONObject;
|
|
|
import org.w3c.dom.Text;
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
|
+import static com.usai.redant.rautils.utils.RAUtil.getJsonFromAsset;
|
|
|
+
|
|
|
public class EnumSlectOnlineActivity extends AppCompatActivity {
|
|
|
|
|
|
static String MAX_SELECT = "max_select";
|
|
|
static String GROUP_POSITION = "group";
|
|
|
static String CHILD_POSITION = "child";
|
|
|
- static String CADEDATE = "cadedate";
|
|
|
+// static String CADEDATE = "cadedate";
|
|
|
static String SINGLE_SELECT = "single_select";
|
|
|
static String TITLE = "title";
|
|
|
static String AUTO_CLOSE = "auto_close";
|
|
|
@@ -52,6 +56,11 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
|
|
|
|
|
|
void LoadData(int option)
|
|
|
{
|
|
|
+
|
|
|
+ RedantApplication application= (RedantApplication) getApplication();
|
|
|
+
|
|
|
+ boolean fakedata = application.useFakeData();
|
|
|
+
|
|
|
Intent intent = getIntent();
|
|
|
Bundle params = intent.getBundleExtra(PARAMETERS);
|
|
|
|
|
|
@@ -77,32 +86,63 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
|
|
|
new Thread(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- final JSONObject result_json = Network.GetCadedate(url, finalParams);
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ JSONObject result_json = null;
|
|
|
+
|
|
|
+ if(fakedata)
|
|
|
+ {
|
|
|
+
|
|
|
+ result_json = getJsonFromAsset(getApplicationContext(),"enum_cadedate.json");
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ result_json=Network.GetCadedate(url, finalParams);
|
|
|
+
|
|
|
+ JSONObject finalResult_json = result_json;
|
|
|
runOnUiThread(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
|
|
|
+
|
|
|
+
|
|
|
pd.dismiss();
|
|
|
+ try
|
|
|
+ {
|
|
|
|
|
|
- int result = result_json.optInt("result");
|
|
|
+ int result = finalResult_json.optInt("result");
|
|
|
if (result == 2) {
|
|
|
|
|
|
if (option != LoadDataOptionLoadMore) {
|
|
|
mCadedate = new JSONObject();
|
|
|
}
|
|
|
|
|
|
- int count = result_json.optInt("count");
|
|
|
+ int count = finalResult_json.optInt("count");
|
|
|
+ int ccount = mCadedate.optInt("count");
|
|
|
for (int ipr = 0; ipr < count; ipr++) {
|
|
|
- JSONObject pr_item = editor_json.optJSONObject("item_" + ipr);
|
|
|
- String name = pr_item.optString("name");
|
|
|
- String value = pr_item.optString("value");
|
|
|
- setValue(name,value);
|
|
|
+
|
|
|
+ JSONObject item = finalResult_json.optJSONObject("val_" + ipr);
|
|
|
+
|
|
|
+
|
|
|
+ mCadedate.put("val_"+(ccount+ipr),item);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
+ mCadedate.put("count",ccount+count);
|
|
|
+ offset = ccount+count;
|
|
|
+
|
|
|
+ adapter.notifyDataSetChanged();
|
|
|
+
|
|
|
} else {
|
|
|
- RAUtil.alertMessage(mCtx,"",result_json.optString("err_msg"));
|
|
|
+ RAUtil.alertMessage(mCtx,"", finalResult_json.optString("err_msg"));
|
|
|
+ }
|
|
|
+ } catch (JSONException e)
|
|
|
+ {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -112,7 +152,7 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
|
|
|
}
|
|
|
|
|
|
public static class Builder {
|
|
|
- public Intent build(Context context,String title, int max_select, int group, int child, String cadedate,boolean single_select,boolean auto_close,String url, Bundle params) {
|
|
|
+ public Intent build(Context context,String title, int max_select, int group, int child, boolean single_select,boolean auto_close,String url, Bundle params) {
|
|
|
if (context == null) {
|
|
|
return null;
|
|
|
}
|
|
|
@@ -125,9 +165,9 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
|
|
|
intent.putExtra(PARAMETERS,params);
|
|
|
intent.putExtra(URL,url);
|
|
|
|
|
|
- if (cadedate != null) {
|
|
|
- intent.putExtra(CADEDATE,(Serializable) cadedate);
|
|
|
- }
|
|
|
+// if (cadedate != null) {
|
|
|
+// intent.putExtra(CADEDATE,(Serializable) cadedate);
|
|
|
+// }
|
|
|
intent.putExtra(SINGLE_SELECT,single_select);
|
|
|
if (title != null) {
|
|
|
intent.putExtra(TITLE,title);
|
|
|
@@ -264,7 +304,7 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
|
|
|
|
|
|
if (mDirty != false) {
|
|
|
Intent intent = new Intent();
|
|
|
- intent.putExtra(CADEDATE,mCadedate.toString());
|
|
|
+// intent.putExtra(CADEDATE,mCadedate.toString());
|
|
|
intent.putExtra(GROUP_POSITION,mGroup);
|
|
|
intent.putExtra(CHILD_POSITION,mChild);
|
|
|
|
|
|
@@ -278,12 +318,14 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
|
|
|
private void init() {
|
|
|
mCtx = this;
|
|
|
Intent intent = getIntent();
|
|
|
- String cadedate_str = intent.getStringExtra(CADEDATE);
|
|
|
- try {
|
|
|
- mCadedate = new JSONObject(cadedate_str);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+
|
|
|
+ LoadData(LoadDataOptionInitial);
|
|
|
+// String cadedate_str = intent.getStringExtra(CADEDATE);
|
|
|
+// try {
|
|
|
+// mCadedate = new JSONObject(cadedate_str);
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
mSingleSelect = intent.getBooleanExtra(SINGLE_SELECT,true);
|
|
|
mGroup = intent.getIntExtra(GROUP_POSITION,0);
|
|
|
mChild = intent.getIntExtra(CHILD_POSITION,0);
|