|
@@ -1,5 +1,6 @@
|
|
|
package com.usai.ratradefiling.tfeditor;
|
|
package com.usai.ratradefiling.tfeditor;
|
|
|
|
|
|
|
|
|
|
+import android.app.AlertDialog;
|
|
|
import android.app.ProgressDialog;
|
|
import android.app.ProgressDialog;
|
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
|
//import android.support.v7.app.AppCompatActivity;
|
|
//import android.support.v7.app.AppCompatActivity;
|
|
@@ -26,6 +27,7 @@ import java.lang.reflect.ParameterizedType;
|
|
|
|
|
|
|
|
import static com.usai.ratradefiling.dataprovider.OnlineDataProvider.URL_CADEDATE;
|
|
import static com.usai.ratradefiling.dataprovider.OnlineDataProvider.URL_CADEDATE;
|
|
|
import static com.usai.ratradefiling.dataprovider.OnlineDataProvider.URL_EDIT;
|
|
import static com.usai.ratradefiling.dataprovider.OnlineDataProvider.URL_EDIT;
|
|
|
|
|
+import static com.usai.ratradefiling.dataprovider.OnlineDataProvider.URL_SAVE_EDITOR;
|
|
|
import static com.usai.redant.rautils.utils.RAUtil.getJsonFromAsset;
|
|
import static com.usai.redant.rautils.utils.RAUtil.getJsonFromAsset;
|
|
|
|
|
|
|
|
public class TFEditorActivity extends CommonEditorActivity
|
|
public class TFEditorActivity extends CommonEditorActivity
|
|
@@ -83,18 +85,25 @@ public class TFEditorActivity extends CommonEditorActivity
|
|
|
|
|
|
|
|
for(int i=0;i<injectMenu.length();i++)
|
|
for(int i=0;i<injectMenu.length();i++)
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
- JSONObject subitem = injectMenu.get(i);
|
|
|
|
|
|
|
|
|
|
|
|
+ JSONObject subitem = null;
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ subitem = injectMenu.getJSONObject(i);
|
|
|
|
|
+ } catch (JSONException e)
|
|
|
|
|
+ {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
// UIAlertAction *injectAction = [UIAlertAction actionWithTitle:NSLocalizedString(item[@"title"], nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
// UIAlertAction *injectAction = [UIAlertAction actionWithTitle:NSLocalizedString(item[@"title"], nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
|
|
|
|
|
if(subitem.optString("name","").equals("save"))
|
|
if(subitem.optString("name","").equals("save"))
|
|
|
{
|
|
{
|
|
|
- JSONObject params= subitem.optJSONObject("params");
|
|
|
|
|
|
|
+ JSONObject params= subitem.optJSONObject("params");
|
|
|
|
|
|
|
|
RAUtil.mergeJson(upparams,params);
|
|
RAUtil.mergeJson(upparams,params);
|
|
|
|
|
+ final Bundle b=RAUtil.Json2Bundle(params);
|
|
|
|
|
|
|
|
final ProgressDialog pd = RAUtil.waiting_alert(mCtx,"Saving","please wait");
|
|
final ProgressDialog pd = RAUtil.waiting_alert(mCtx,"Saving","please wait");
|
|
|
|
|
|
|
@@ -105,11 +114,11 @@ public class TFEditorActivity extends CommonEditorActivity
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
- JSONObject result_json = null;
|
|
|
|
|
|
|
+ JSONObject result_json = RADataProvider.save_editor(URL_SAVE_EDITOR, b);;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- JSONObject finalResult_json = result_json;
|
|
|
|
|
|
|
+ final JSONObject finalResult_json = result_json;
|
|
|
runOnUiThread(new Runnable()
|
|
runOnUiThread(new Runnable()
|
|
|
{
|
|
{
|
|
|
@Override
|
|
@Override
|
|
@@ -119,57 +128,19 @@ public class TFEditorActivity extends CommonEditorActivity
|
|
|
pd.dismiss();
|
|
pd.dismiss();
|
|
|
|
|
|
|
|
|
|
|
|
|
-// pd.dismiss();
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
|
|
|
|
|
int result = finalResult_json.optInt("result");
|
|
int result = finalResult_json.optInt("result");
|
|
|
if (result == 2)
|
|
if (result == 2)
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
- if (option != LoadDataOptionLoadMore)
|
|
|
|
|
- {
|
|
|
|
|
- mCadedate = new JSONObject();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- int count = finalResult_json.optInt("count");
|
|
|
|
|
- if (count >= limit)
|
|
|
|
|
- {
|
|
|
|
|
- hasmore = true;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
-
|
|
|
|
|
- mListFooterView.setText("No more data");
|
|
|
|
|
- mListFooterView.setVisibility(View.VISIBLE);
|
|
|
|
|
- hasmore = false;
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- int ccount = mCadedate.optInt("count");
|
|
|
|
|
- for (int ipr = 0; ipr < count; ipr++)
|
|
|
|
|
- {
|
|
|
|
|
-
|
|
|
|
|
- JSONObject item = finalResult_json.optJSONObject("val_" + ipr);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- mCadedate.put("val_" + (ccount + ipr), item);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- mCadedate.put("count", ccount + count);
|
|
|
|
|
- offset = ccount + count;
|
|
|
|
|
-
|
|
|
|
|
- adapter.notifyDataSetChanged();
|
|
|
|
|
|
|
+ RAUtil.alertMessage(mCtx, "Message", "Save successful");
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- RAUtil.alertMessage(mCtx, "", finalResult_json.optString("err_msg"));
|
|
|
|
|
|
|
+ RAUtil.alertMessage(mCtx, "Warning", finalResult_json.optString("err_msg"));
|
|
|
}
|
|
}
|
|
|
- } catch (JSONException e)
|
|
|
|
|
- {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
@@ -177,247 +148,116 @@ public class TFEditorActivity extends CommonEditorActivity
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- [RADataProvider SaveEditor:upparams completionHandler:^(NSMutableDictionary *result) {
|
|
|
|
|
- int ret=[result[@"result"] intValue];
|
|
|
|
|
-
|
|
|
|
|
- if (ret==RESULT_TRUE)
|
|
|
|
|
- {
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- [RAUtils message_alert:@"Successful" title:@"Save" controller:self action_handler:^(UIAlertAction * _Nonnull action) {
|
|
|
|
|
- [self.navigationController popViewControllerAnimated:YES];
|
|
|
|
|
- [self prepareReturn:nil];
|
|
|
|
|
- } completion:^{
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- }];
|
|
|
|
|
- // NSUser
|
|
|
|
|
-
|
|
|
|
|
-// [self.navigationController popViewControllerAnimated:true];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
- else
|
|
|
|
|
|
|
+ else if(subitem.optString("name","").equals("save&submit"))
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
- [[NSNotificationCenter defaultCenter] postNotificationName:RA_NOTIFICATION_LOGIN_FAILED object:nil];
|
|
|
|
|
- // int a = RESULT_NET_NOTAVAILABLE;
|
|
|
|
|
- NSString* message = nil;
|
|
|
|
|
- switch (ret) {
|
|
|
|
|
- case RESULT_NET_NOTAVAILABLE:
|
|
|
|
|
- message = NSLocalizedString(@"net_not_available", nil);
|
|
|
|
|
- break;
|
|
|
|
|
- case RESULT_NET_ERROR:
|
|
|
|
|
- message = NSLocalizedString(@"net_error", nil);
|
|
|
|
|
- break;
|
|
|
|
|
- case RESULT_FALSE:
|
|
|
|
|
- message = NSLocalizedString(@"auth_error", nil);
|
|
|
|
|
- break;
|
|
|
|
|
- case RESULT_VER_LOW:
|
|
|
|
|
- message = NSLocalizedString(@"ver_low", nil);
|
|
|
|
|
- break;
|
|
|
|
|
- case RESULT_FAILED_WITH_MESSAGE:
|
|
|
|
|
- message = result[@"err_msg"];
|
|
|
|
|
- break;
|
|
|
|
|
- default:
|
|
|
|
|
- message=[NSString stringWithFormat:@"Failed to login code %d",ret];
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"alert_title_error", nil) message:message preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
|
- UIAlertAction *action = [UIAlertAction actionWithTitle:NSLocalizedString(@"ok", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
|
|
|
|
|
|
|
- }];
|
|
|
|
|
-
|
|
|
|
|
- [alertVC addAction:action];
|
|
|
|
|
-
|
|
|
|
|
- [self presentViewController:alertVC animated:YES completion:nil];
|
|
|
|
|
|
|
+ JSONObject params= subitem.optJSONObject("params");
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ RAUtil.mergeJson(upparams,params);
|
|
|
|
|
+ final Bundle b=RAUtil.Json2Bundle(params);
|
|
|
|
|
+ final ProgressDialog pd = RAUtil.waiting_alert(mCtx,"Saving","please wait");
|
|
|
|
|
|
|
|
- }];
|
|
|
|
|
|
|
+ new Thread(new Runnable()
|
|
|
|
|
+ {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void run()
|
|
|
|
|
+ {
|
|
|
|
|
|
|
|
- }else
|
|
|
|
|
- if([item[@"name"] isEqualToString:@"save&submit"])
|
|
|
|
|
- {
|
|
|
|
|
- JSONObject params= item[@"params"];
|
|
|
|
|
- [upparams addEntriesFromDictionary:params];
|
|
|
|
|
-
|
|
|
|
|
- [RADataProvider SaveEditor:upparams completionHandler:^(NSMutableDictionary *result) {
|
|
|
|
|
- int ret=[result[@"result"] intValue];
|
|
|
|
|
|
|
|
|
|
- if (ret==RESULT_TRUE)
|
|
|
|
|
- {
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- [RAUtils message_alert:@"Successful" title:@"Save" controller:self action_handler:^(UIAlertAction * _Nonnull action) {
|
|
|
|
|
- [self.navigationController popViewControllerAnimated:YES];
|
|
|
|
|
- [self prepareReturn:nil];
|
|
|
|
|
|
|
+ JSONObject result_json = RADataProvider.submit_editor(URL_SAVE_EDITOR, b);;
|
|
|
|
|
|
|
|
- } completion:^{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ final JSONObject finalResult_json = result_json;
|
|
|
|
|
+ runOnUiThread(new Runnable()
|
|
|
|
|
+ {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void run()
|
|
|
|
|
+ {
|
|
|
|
|
|
|
|
- }];
|
|
|
|
|
- // NSUser
|
|
|
|
|
|
|
+ pd.dismiss();
|
|
|
|
|
|
|
|
- // [self.navigationController popViewControllerAnimated:true];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ int result = finalResult_json.optInt("result");
|
|
|
|
|
+ if (result == 2)
|
|
|
|
|
+ {
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
-
|
|
|
|
|
- [[NSNotificationCenter defaultCenter] postNotificationName:RA_NOTIFICATION_LOGIN_FAILED object:nil];
|
|
|
|
|
- // int a = RESULT_NET_NOTAVAILABLE;
|
|
|
|
|
- NSString* message = nil;
|
|
|
|
|
- switch (ret) {
|
|
|
|
|
- case RESULT_NET_NOTAVAILABLE:
|
|
|
|
|
- message = NSLocalizedString(@"net_not_available", nil);
|
|
|
|
|
- break;
|
|
|
|
|
- case RESULT_NET_ERROR:
|
|
|
|
|
- message = NSLocalizedString(@"net_error", nil);
|
|
|
|
|
- break;
|
|
|
|
|
- case RESULT_FALSE:
|
|
|
|
|
- message = NSLocalizedString(@"auth_error", nil);
|
|
|
|
|
- break;
|
|
|
|
|
- case RESULT_VER_LOW:
|
|
|
|
|
- message = NSLocalizedString(@"ver_low", nil);
|
|
|
|
|
- break;
|
|
|
|
|
- case RESULT_FAILED_WITH_MESSAGE:
|
|
|
|
|
- message = result[@"err_msg"];
|
|
|
|
|
- break;
|
|
|
|
|
- default:
|
|
|
|
|
- message=[NSString stringWithFormat:@"Failed to login code %d",ret];
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ RAUtil.alertMessage(mCtx, "Message", "Submit successful");
|
|
|
|
|
|
|
|
- UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"alert_title_error", nil) message:message preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
|
- UIAlertAction *action = [UIAlertAction actionWithTitle:NSLocalizedString(@"ok", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ RAUtil.alertMessage(mCtx, "Warning", finalResult_json.optString("err_msg"));
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- }];
|
|
|
|
|
-
|
|
|
|
|
- [alertVC addAction:action];
|
|
|
|
|
-
|
|
|
|
|
- [self presentViewController:alertVC animated:YES completion:nil];
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }).start();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- }];
|
|
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- if([item[@"name"] isEqualToString:@"delete"])
|
|
|
|
|
- {
|
|
|
|
|
- JSONObject params= item[@"params"];
|
|
|
|
|
- [upparams addEntriesFromDictionary:params];
|
|
|
|
|
-
|
|
|
|
|
- [RADataProvider SaveEditor:upparams completionHandler:^(NSMutableDictionary *result) {
|
|
|
|
|
- int ret=[result[@"result"] intValue];
|
|
|
|
|
|
|
|
|
|
- if (ret==RESULT_TRUE)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ else if(subitem.optString("name","").equals("delete"))
|
|
|
|
|
+
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- [RAUtils message_alert:@"Successful" title:@"Delete" controller:self action_handler:^(UIAlertAction * _Nonnull action) {
|
|
|
|
|
- [self.navigationController popViewControllerAnimated:YES];
|
|
|
|
|
- [self prepareReturn:nil];
|
|
|
|
|
- } completion:^{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ JSONObject params= subitem.optJSONObject("params");
|
|
|
|
|
|
|
|
- }];
|
|
|
|
|
- // NSUser
|
|
|
|
|
|
|
+ RAUtil.mergeJson(upparams,params);
|
|
|
|
|
+ final Bundle b=RAUtil.Json2Bundle(params);
|
|
|
|
|
+ final ProgressDialog pd = RAUtil.waiting_alert(mCtx,"Deleting","please wait");
|
|
|
|
|
|
|
|
- // [self.navigationController popViewControllerAnimated:true];
|
|
|
|
|
|
|
+ new Thread(new Runnable()
|
|
|
|
|
+ {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void run()
|
|
|
|
|
+ {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ JSONObject result_json = RADataProvider.delete_editor(URL_SAVE_EDITOR, b);;
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
-
|
|
|
|
|
- [[NSNotificationCenter defaultCenter] postNotificationName:RA_NOTIFICATION_LOGIN_FAILED object:nil];
|
|
|
|
|
- // int a = RESULT_NET_NOTAVAILABLE;
|
|
|
|
|
- NSString* message = nil;
|
|
|
|
|
- switch (ret) {
|
|
|
|
|
- case RESULT_NET_NOTAVAILABLE:
|
|
|
|
|
- message = NSLocalizedString(@"net_not_available", nil);
|
|
|
|
|
- break;
|
|
|
|
|
- case RESULT_NET_ERROR:
|
|
|
|
|
- message = NSLocalizedString(@"net_error", nil);
|
|
|
|
|
- break;
|
|
|
|
|
- case RESULT_FALSE:
|
|
|
|
|
- message = NSLocalizedString(@"auth_error", nil);
|
|
|
|
|
- break;
|
|
|
|
|
- case RESULT_VER_LOW:
|
|
|
|
|
- message = NSLocalizedString(@"ver_low", nil);
|
|
|
|
|
- break;
|
|
|
|
|
- case RESULT_FAILED_WITH_MESSAGE:
|
|
|
|
|
- message = result[@"err_msg"];
|
|
|
|
|
- break;
|
|
|
|
|
- default:
|
|
|
|
|
- message=[NSString stringWithFormat:@"Failed to login code %d",ret];
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"alert_title_error", nil) message:message preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
|
- UIAlertAction *action = [UIAlertAction actionWithTitle:NSLocalizedString(@"ok", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
|
|
|
|
|
|
|
- }];
|
|
|
|
|
-
|
|
|
|
|
- [alertVC addAction:action];
|
|
|
|
|
-
|
|
|
|
|
- [self presentViewController:alertVC animated:YES completion:nil];
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ final JSONObject finalResult_json = result_json;
|
|
|
|
|
+ runOnUiThread(new Runnable()
|
|
|
|
|
+ {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void run()
|
|
|
|
|
+ {
|
|
|
|
|
|
|
|
- }];
|
|
|
|
|
|
|
+ pd.dismiss();
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- else
|
|
|
|
|
- if([item[@"name"] isEqualToString:@"save_party"])
|
|
|
|
|
- {
|
|
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- }];
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- [alertVC addAction:injectAction];
|
|
|
|
|
|
|
+ int result = finalResult_json.optInt("result");
|
|
|
|
|
+ if (result == 2)
|
|
|
|
|
+ {
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
- UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"cancel", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
|
|
|
|
|
|
|
+ RAUtil.alertMessage(mCtx, "Message", "Delete successful");
|
|
|
|
|
|
|
|
- }];
|
|
|
|
|
-
|
|
|
|
|
- [alertVC addAction:cancelAction];
|
|
|
|
|
-
|
|
|
|
|
- [self presentViewController:alertVC animated:YES completion:nil];
|
|
|
|
|
-
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ RAUtil.alertMessage(mCtx, "Warning", finalResult_json.optString("err_msg"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }).start();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
-//
|
|
|
|
|
-// if(type.toLowerCase().equals("quickview"))
|
|
|
|
|
-// {
|
|
|
|
|
-// String url = jitem.optString("url");
|
|
|
|
|
-// showQuickLook(url);
|
|
|
|
|
-// }
|
|
|
|
|
-// else if(type.toLowerCase().equals("editor"))
|
|
|
|
|
-// {
|
|
|
|
|
-//// throw new AssertionError("Editor not impl");
|
|
|
|
|
-//
|
|
|
|
|
-//
|
|
|
|
|
-// Bundle b=RAUtil.Json2Bundle(jitem.optJSONObject("params"));
|
|
|
|
|
-// Intent intent = TFEditorActivity.build(mContext,TFEditorActivity.class,null,URL_REMOTE,URL_EDIT,b);
|
|
|
|
|
-//
|
|
|
|
|
-// startActivity(intent);
|
|
|
|
|
-//
|
|
|
|
|
-//
|
|
|
|
|
-// }
|
|
|
|
|
-// return super.onOptionsItemSelected(item);
|
|
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|