|
@@ -613,6 +613,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
|
|
|
|
|
JSONObject sub_action = item_json.optJSONObject("item_" + subaction_tag);
|
|
JSONObject sub_action = item_json.optJSONObject("item_" + subaction_tag);
|
|
|
int refresh = sub_action.optInt("refresh");
|
|
int refresh = sub_action.optInt("refresh");
|
|
|
|
|
+ boolean discardDirty =sub_action.optBoolean("discarddirty");
|
|
|
String refresh_trigger = sub_action.optString("name");
|
|
String refresh_trigger = sub_action.optString("name");
|
|
|
JSONObject restore_json = sub_action.optJSONObject("restore");
|
|
JSONObject restore_json = sub_action.optJSONObject("restore");
|
|
|
|
|
|
|
@@ -767,7 +768,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- refresh(refresh_trigger);
|
|
|
|
|
|
|
+ refresh(refresh_trigger,discardDirty);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
adapter.notifyDataSetChanged();
|
|
adapter.notifyDataSetChanged();
|
|
@@ -775,6 +776,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
// is_subaction
|
|
// is_subaction
|
|
|
} else {
|
|
} else {
|
|
|
int refresh = item_json.optInt("refresh");
|
|
int refresh = item_json.optInt("refresh");
|
|
|
|
|
+ boolean discardDirty = item_json.optBoolean("discardDirty");
|
|
|
String refresh_trigger = item_json.optString("name");
|
|
String refresh_trigger = item_json.optString("name");
|
|
|
JSONObject restore_json = item_json.optJSONObject("restore");
|
|
JSONObject restore_json = item_json.optJSONObject("restore");
|
|
|
|
|
|
|
@@ -916,7 +918,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- refresh(refresh_trigger);
|
|
|
|
|
|
|
+ refresh(refresh_trigger,discardDirty);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1123,7 +1125,13 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public int url_type = URL_REMOTE;
|
|
public int url_type = URL_REMOTE;
|
|
|
- public void refresh(String trigger) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+// public void refresh(String trigger)
|
|
|
|
|
+// {
|
|
|
|
|
+// refresh(trigger,false);
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ public void refresh(String trigger,boolean discardDirty) {
|
|
|
|
|
|
|
|
if (lastEditText != null) {
|
|
if (lastEditText != null) {
|
|
|
endEditting();
|
|
endEditting();
|
|
@@ -1167,7 +1175,12 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
if (Integer.valueOf(editor_json.optString("result")) == 2) {
|
|
if (Integer.valueOf(editor_json.optString("result")) == 2) {
|
|
|
- content_data_download = copyDirtyTo(content_data_download,editor_json);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if(!discardDirty)
|
|
|
|
|
+ {
|
|
|
|
|
+ content_data_download = copyDirtyTo(content_data_download,editor_json);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
content_data_control = translateChange(content_data_download,changed_data);
|
|
content_data_control = translateChange(content_data_download,changed_data);
|
|
|
|
|
|
|
|
download_success();
|
|
download_success();
|
|
@@ -2392,61 +2405,63 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
{
|
|
{
|
|
|
item_json.put("value",value);
|
|
item_json.put("value",value);
|
|
|
item_json.put("dirty",true);
|
|
item_json.put("dirty",true);
|
|
|
- } catch (JSONException e)
|
|
|
|
|
- {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
if(TextUtils.isEmpty(subid))
|
|
if(TextUtils.isEmpty(subid))
|
|
|
{
|
|
{
|
|
|
- section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
|
|
|
|
|
|
|
+ section_json =content_data_download.optJSONObject("section_"+groupindex);
|
|
|
|
|
+// JSONObject item_json = ((JSONArray)content_data_control.getJSONArray(group)).getJSONObject(child);
|
|
|
|
|
+// [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
|
|
|
int count=0;
|
|
int count=0;
|
|
|
|
|
|
|
|
- count=[[section_json valueForKey:@"count"] intValue];
|
|
|
|
|
|
|
+ count=section_json.optInt("count");
|
|
|
|
|
|
|
|
for(int i=0;i<count;i++)
|
|
for(int i=0;i<count;i++)
|
|
|
{
|
|
{
|
|
|
- NSDictionary * olditem=[section_json objectForKey:[NSString stringWithFormat:@"item_%d",i ]];
|
|
|
|
|
- if([[olditem valueForKey:@"name"] isEqualToString:[item_json valueForKey:@"name" ]])
|
|
|
|
|
- [section_json setObject:item_json forKey:[NSString stringWithFormat:@"item_%d",i ]];
|
|
|
|
|
-
|
|
|
|
|
|
|
+ JSONObject olditem=section_json.optJSONObject("item_"+i);
|
|
|
|
|
+ if(olditem.optString("name").equals(item_json.optString("name")))
|
|
|
|
|
+ {
|
|
|
|
|
+ section_json.put("item_"+i,item_json);
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- NSArray* idarr=[subid componentsSeparatedByString:@"_"];
|
|
|
|
|
- int section = [(String)idarr[0] intValue];
|
|
|
|
|
- int item=[(String)idarr[1] intValue];
|
|
|
|
|
|
|
+ String [] idarr=subid.split("_");
|
|
|
|
|
|
|
|
|
|
+ int section = Integer.parseInt(idarr[0]);
|
|
|
|
|
+ int item=Integer.parseInt(idarr[1]);
|
|
|
|
|
|
|
|
- section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d", section]] mutableCopy];
|
|
|
|
|
- NSDictionary * olditem=[section_json objectForKey:[NSString stringWithFormat:@"item_%d",item ]];
|
|
|
|
|
- item_json= [self enum_subitem_changed:[olditem mutableCopy] subid:idarr value:item_json step:2];
|
|
|
|
|
- [item_json setValue:@"true" forKey:@"dirty"];
|
|
|
|
|
- [section_json setObject:item_json forKey:[NSString stringWithFormat:@"item_%d",item ]];
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
+ section_json =content_data_download.optJSONObject("section_"+section);
|
|
|
|
|
+ JSONObject olditem=section_json.optJSONObject("item_"+item);
|
|
|
|
|
|
|
|
|
|
+ item_json = enum_subitem_changed(olditem,idarr,item_json,2);
|
|
|
|
|
|
|
|
- [self.content_data_download setObject:section_json forKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]];
|
|
|
|
|
|
|
|
|
|
- self.content_data_control = [self translate_json:self.content_data_download changed: self.changed_data];
|
|
|
|
|
|
|
+ item_json.put("dirty",true);
|
|
|
|
|
+ section_json.put("item_"+item,item_json);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ content_data_download.put("section_"+groupindex,section_json);
|
|
|
|
|
+
|
|
|
|
|
+ content_data_control = translateChange(content_data_download,changed_data);
|
|
|
|
|
+
|
|
|
|
|
|
|
|
// NSRange range = NSMakeRange(indexPath.section, 1);
|
|
// NSRange range = NSMakeRange(indexPath.section, 1);
|
|
|
// NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndexesInRange:range];
|
|
// NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndexesInRange:range];
|
|
|
// [self.editorTable reloadSections:sectionToReload withRowAnimation:UITableViewRowAnimationAutomatic];
|
|
// [self.editorTable reloadSections:sectionToReload withRowAnimation:UITableViewRowAnimationAutomatic];
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- if(refresh==1)
|
|
|
|
|
|
|
+ } catch (JSONException e)
|
|
|
{
|
|
{
|
|
|
- if(!discardDirty)
|
|
|
|
|
- [self refresh:refresh_trigger] ;
|
|
|
|
|
- else
|
|
|
|
|
- [self refresh:refresh_trigger discardDirty:true];
|
|
|
|
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
}
|
|
|
- [self.editorTable reloadData ];
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ refresh(refresh_trigger,discardDirty);
|
|
|
|
|
+ adapter.notifyDataSetChanged();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -3509,6 +3524,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
JSONObject section_json = null;
|
|
JSONObject section_json = null;
|
|
|
JSONObject item_json = content_data_control.optJSONArray(group).optJSONObject(child);
|
|
JSONObject item_json = content_data_control.optJSONArray(group).optJSONObject(child);
|
|
|
int refresh = item_json.optInt("refresh");
|
|
int refresh = item_json.optInt("refresh");
|
|
|
|
|
+ boolean discardDirty = item_json.optBoolean("discarddirty");
|
|
|
String refresh_trigger = item_json.optString("name");
|
|
String refresh_trigger = item_json.optString("name");
|
|
|
String subid = item_json.optString("subid");
|
|
String subid = item_json.optString("subid");
|
|
|
item_json.put("img_url_" + index,url_down);
|
|
item_json.put("img_url_" + index,url_down);
|
|
@@ -3543,9 +3559,9 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
content_data_download.put("section_" + group,section_json);
|
|
content_data_download.put("section_" + group,section_json);
|
|
|
content_data_control = translateChange(content_data_download,changed_data);
|
|
content_data_control = translateChange(content_data_download,changed_data);
|
|
|
|
|
|
|
|
- if (refresh == 1) {
|
|
|
|
|
- refresh(refresh_trigger);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ refresh(refresh_trigger,discardDirty);
|
|
|
|
|
+
|
|
|
|
|
|
|
|
adapter.notifyDataSetChanged();
|
|
adapter.notifyDataSetChanged();
|
|
|
|
|
|
|
@@ -3571,6 +3587,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
JSONObject item_json = content_data_control.optJSONArray(group).optJSONObject(child);
|
|
JSONObject item_json = content_data_control.optJSONArray(group).optJSONObject(child);
|
|
|
|
|
|
|
|
int refresh = item_json.optInt("refresh");
|
|
int refresh = item_json.optInt("refresh");
|
|
|
|
|
+ boolean discardDirty = item_json.optBoolean("discarddirty");
|
|
|
String refresh_trigger = item_json.optString("name");
|
|
String refresh_trigger = item_json.optString("name");
|
|
|
String subid = item_json.optString("subid");
|
|
String subid = item_json.optString("subid");
|
|
|
String check = "false";
|
|
String check = "false";
|
|
@@ -3612,7 +3629,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
adapter.notifyDataSetChanged();
|
|
adapter.notifyDataSetChanged();
|
|
|
|
|
|
|
|
if (refresh == 1) {
|
|
if (refresh == 1) {
|
|
|
- refresh(refresh_trigger);
|
|
|
|
|
|
|
+ refresh(refresh_trigger,discardDirty);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -3642,6 +3659,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
int i = Integer.valueOf(arr[2]);
|
|
int i = Integer.valueOf(arr[2]);
|
|
|
|
|
|
|
|
int refresh = 0;
|
|
int refresh = 0;
|
|
|
|
|
+ boolean discardDirty = false;
|
|
|
JSONObject section_json = null;
|
|
JSONObject section_json = null;
|
|
|
JSONObject item_json = content_data_control.optJSONArray(group).optJSONObject(child);
|
|
JSONObject item_json = content_data_control.optJSONArray(group).optJSONObject(child);
|
|
|
String subid = item_json.optString("subid");
|
|
String subid = item_json.optString("subid");
|
|
@@ -3654,6 +3672,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
// end edit
|
|
// end edit
|
|
|
|
|
|
|
|
refresh = sub_action.optInt("refresh");
|
|
refresh = sub_action.optInt("refresh");
|
|
|
|
|
+ discardDirty = sub_action.optBoolean("discarddirty");
|
|
|
JSONObject keymap = sub_action.optJSONObject("key_map");
|
|
JSONObject keymap = sub_action.optJSONObject("key_map");
|
|
|
JSONObject value = create_value_map(keymap);
|
|
JSONObject value = create_value_map(keymap);
|
|
|
|
|
|
|
@@ -3728,7 +3747,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (refresh == 1) {
|
|
if (refresh == 1) {
|
|
|
- refresh(refresh_trigger);
|
|
|
|
|
|
|
+ refresh(refresh_trigger,discardDirty);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
adapter.notifyDataSetChanged();
|
|
adapter.notifyDataSetChanged();
|
|
@@ -4144,6 +4163,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
content_data_control = translateChange(content_data_download,changed_data);
|
|
content_data_control = translateChange(content_data_download,changed_data);
|
|
|
|
|
|
|
|
int refresh = item_json.optInt("refresh");
|
|
int refresh = item_json.optInt("refresh");
|
|
|
|
|
+ boolean discardDirty = item_json.optBoolean("discarddirty");
|
|
|
JSONObject restore_json = item_json.optJSONObject("restore");
|
|
JSONObject restore_json = item_json.optJSONObject("restore");
|
|
|
boolean partial_refresh = item_json.optBoolean("partial_refresh");
|
|
boolean partial_refresh = item_json.optBoolean("partial_refresh");
|
|
|
if (refresh == 1) {
|
|
if (refresh == 1) {
|
|
@@ -4167,7 +4187,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- refresh(refresh_trigger);
|
|
|
|
|
|
|
+ refresh(refresh_trigger,discardDirty);
|
|
|
|
|
|
|
|
} // refresh == 1
|
|
} // refresh == 1
|
|
|
else if (partial_refresh) {
|
|
else if (partial_refresh) {
|
|
@@ -4241,6 +4261,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
content_data_control = translateChange(content_data_download,changed_data);
|
|
content_data_control = translateChange(content_data_download,changed_data);
|
|
|
|
|
|
|
|
int refresh = item_json.optInt("refresh");
|
|
int refresh = item_json.optInt("refresh");
|
|
|
|
|
+ boolean discardDirty = item_json.optBoolean("discarddirty");
|
|
|
JSONObject restore_json = item_json.optJSONObject("restore");
|
|
JSONObject restore_json = item_json.optJSONObject("restore");
|
|
|
boolean partial_refresh = item_json.optBoolean("partial_refresh");
|
|
boolean partial_refresh = item_json.optBoolean("partial_refresh");
|
|
|
if (refresh == 1) {
|
|
if (refresh == 1) {
|
|
@@ -4264,7 +4285,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- refresh(refresh_trigger);
|
|
|
|
|
|
|
+ refresh(refresh_trigger,discardDirty);
|
|
|
|
|
|
|
|
} // refresh == 1
|
|
} // refresh == 1
|
|
|
else if (partial_refresh) {
|
|
else if (partial_refresh) {
|
|
@@ -4378,6 +4399,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
JSONObject item_json = content_data_control.optJSONArray(group).optJSONObject(child);
|
|
JSONObject item_json = content_data_control.optJSONArray(group).optJSONObject(child);
|
|
|
|
|
|
|
|
int refresh = item_json.optInt("refresh");
|
|
int refresh = item_json.optInt("refresh");
|
|
|
|
|
+ boolean discardDirty = item_json.optBoolean("discarddirty");
|
|
|
String refresh_trigger = item_json.optString("name");
|
|
String refresh_trigger = item_json.optString("name");
|
|
|
String subid = item_json.optString("subid");
|
|
String subid = item_json.optString("subid");
|
|
|
|
|
|
|
@@ -4433,7 +4455,7 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- refresh(refresh_trigger);
|
|
|
|
|
|
|
+ refresh(refresh_trigger,discardDirty);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
adapter.notifyDataSetChanged();
|
|
adapter.notifyDataSetChanged();
|