|
|
@@ -53,6 +53,7 @@ import org.json.JSONException;
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
+import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.io.InputStreamReader;
|
|
|
import java.io.OutputStreamWriter;
|
|
|
@@ -506,7 +507,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void showWarningAlert(String msg) {
|
|
|
+ public void showWarningAlert(String msg) {
|
|
|
|
|
|
new AlertDialog.Builder(mCtx)
|
|
|
.setTitle("Warning")
|
|
|
@@ -2322,8 +2323,10 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
|
|
|
if (cancommit == false && required.equals("true") && (value == null || value.length() == 0)) {
|
|
|
// 阴影 red
|
|
|
+ holder.title_lb.setBackground(getResources().getDrawable(R.drawable.red_border));
|
|
|
} else {
|
|
|
// 无阴影
|
|
|
+ holder.title_lb.setBackground(null);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -2420,53 +2423,61 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
|
|
|
private void loadImageForPosition(int group, int child, int item_tag, final String path) {
|
|
|
|
|
|
- return;
|
|
|
+// return;
|
|
|
|
|
|
-// if (path == null || path.isEmpty()) {
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// new Thread(new Runnable() {
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
-// HttpURLConnection cnn = null;
|
|
|
-// Bitmap bitmap = null;
|
|
|
-// try {
|
|
|
-// URL url = new URL(path);
|
|
|
-// cnn = (HttpURLConnection)url.openConnection();
|
|
|
-// cnn.setRequestMethod("GET");
|
|
|
-// cnn.setUseCaches(false);
|
|
|
-// cnn.setConnectTimeout(1500);
|
|
|
-// cnn.setReadTimeout(1500);
|
|
|
-// bitmap = BitmapFactory.decodeStream(cnn.getInputStream());
|
|
|
-// if (bitmap == null) {
|
|
|
-// // 缓存not found
|
|
|
-// bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.not_found);
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// } catch (IOException e) {
|
|
|
-// e.printStackTrace();
|
|
|
-//
|
|
|
-// bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.not_found);
|
|
|
-//
|
|
|
-// } finally {
|
|
|
-// if (cnn != null) {
|
|
|
-// cnn.disconnect();
|
|
|
-// }
|
|
|
-// if (bitmap == null) {
|
|
|
-// bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.not_found);
|
|
|
-// }
|
|
|
-// Utils.cacheImage(path,bitmap);
|
|
|
-// // 更新数据,刷新行
|
|
|
-// runOnUiThread(new Runnable() {
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
-// adapter.notifyDataSetChanged();
|
|
|
-// }
|
|
|
-// });
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }).start();
|
|
|
+ if (path == null || path.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ new Thread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ HttpURLConnection cnn = null;
|
|
|
+ Bitmap bitmap = null;
|
|
|
+
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ bitmap = Utils.loadCacheImage(path,null);
|
|
|
+
|
|
|
+
|
|
|
+ if (bitmap == null) {
|
|
|
+ URL url = new URL(path);
|
|
|
+ cnn = (HttpURLConnection)url.openConnection();
|
|
|
+ cnn.setRequestMethod("GET");
|
|
|
+ cnn.setUseCaches(false);
|
|
|
+ cnn.setConnectTimeout(1500);
|
|
|
+ cnn.setReadTimeout(1500);
|
|
|
+ bitmap = BitmapFactory.decodeStream(cnn.getInputStream());
|
|
|
+ if (bitmap == null) {
|
|
|
+ // 缓存not found
|
|
|
+ bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.not_found);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+
|
|
|
+ bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.not_found);
|
|
|
+
|
|
|
+ } finally {
|
|
|
+ if (cnn != null) {
|
|
|
+ cnn.disconnect();
|
|
|
+ }
|
|
|
+ if (bitmap == null) {
|
|
|
+ bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.not_found);
|
|
|
+ }
|
|
|
+ Utils.cacheImage(path,bitmap);
|
|
|
+ // 更新数据,刷新行
|
|
|
+ runOnUiThread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ adapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).start();
|
|
|
}
|
|
|
|
|
|
public void setUpEditCellHolder(final CommonEditorEditCellHolder holder, View cell, JSONObject item_json, boolean readonly, int group, int child) {
|
|
|
@@ -2478,6 +2489,9 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
String keyboard = null;
|
|
|
String required = null;
|
|
|
|
|
|
+ if (holder.textWatcher != null) {
|
|
|
+ holder.text_field.removeTextChangedListener(holder.textWatcher);
|
|
|
+ }
|
|
|
// 重用时先保存
|
|
|
if (holder.text_field.getText().length() > 0) {
|
|
|
editTextEndEditing(holder.text_field,true,holder.group,holder.child);
|
|
|
@@ -2584,8 +2598,10 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
|
|
|
if (cancommit == false && required != null && required.equals("true") && (value == null || value.length() == 0)) {
|
|
|
// 阴影 red
|
|
|
+ holder.name_lb.setBackground(getResources().getDrawable(R.drawable.red_border));
|
|
|
} else {
|
|
|
// 无阴影
|
|
|
+ holder.name_lb.setBackground(null);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -2839,8 +2855,10 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
|
|
|
if (cancommit == false && required.equals("true") && (value == null || value.length() == 0)) {
|
|
|
// 阴影 red
|
|
|
+ holder.title_lb.setBackground(getResources().getDrawable(R.drawable.red_border));
|
|
|
} else {
|
|
|
// 无阴影
|
|
|
+ holder.title_lb.setBackground(null);
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
@@ -3197,7 +3215,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
|
|
|
}
|
|
|
|
|
|
- private Context mCtx = this;
|
|
|
+ public Context mCtx = this;
|
|
|
|
|
|
/**Month Picker*/
|
|
|
public void MPValueChanged(String value,int group,int child) {
|
|
|
@@ -3933,7 +3951,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
new Thread(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- final JSONObject editor_json = Utils.commoneditor_partialrefresh(final_params,url);
|
|
|
+ final JSONObject editor_json = Network.commoneditor_partialrefresh(final_params,url);
|
|
|
|
|
|
runOnUiThread(new Runnable() {
|
|
|
@Override
|
|
|
@@ -4030,7 +4048,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
@Override
|
|
|
public void run() {
|
|
|
|
|
|
- final JSONObject editor_json = Utils.commoneditor_partialrefresh(final_params,url);
|
|
|
+ final JSONObject editor_json = Network.commoneditor_partialrefresh(final_params,url);
|
|
|
|
|
|
runOnUiThread(new Runnable() {
|
|
|
@Override
|
|
|
@@ -4397,6 +4415,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
} else {
|
|
|
|
|
|
editTextEndEditing(et,is_text_field,group,child);
|
|
|
+ endEditting();
|
|
|
lastEditText = null;
|
|
|
last_edit_group = -1;
|
|
|
last_edit_child = -1;
|
|
|
@@ -4419,7 +4438,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
}
|
|
|
|
|
|
public void editTextEndEditing(EditText et,boolean is_text_field,int group,int child) {
|
|
|
- Log.e("Edit", "end editing");
|
|
|
+ Log.d("Edit", "end editing");
|
|
|
if (is_text_field) {
|
|
|
|
|
|
JSONObject item_json = content_data_control.optJSONArray(group).optJSONObject(child);
|
|
|
@@ -4427,7 +4446,9 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
return;
|
|
|
}
|
|
|
String fillText = item_json.optString("fill");
|
|
|
- if (fillText != null && et.getText().length() == 0) {
|
|
|
+
|
|
|
+ // 没有判断fillText empty会导致重复不断的调用focusChange,并且不能输入
|
|
|
+ if (fillText != null && et.getText().length() == 0 && !fillText.isEmpty()) {
|
|
|
et.setText(fillText);
|
|
|
}
|
|
|
textFieldSetValue(et.getText().toString(),group,child);
|
|
|
@@ -4481,7 +4502,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
}
|
|
|
|
|
|
public void editTextBeginEditing(EditText et,boolean is_text_field,int group,int child) {
|
|
|
- Log.e("Edit", "begin editing");
|
|
|
+ Log.d("Edit", "begin editing");
|
|
|
|
|
|
lastEditText = et;
|
|
|
last_edit_group = group;
|