Commit 6c747d2e authored by Nastuzzi Samy's avatar Nastuzzi Samy
Browse files

Optimization

Handle action after errorDialog is dismissed
Cleaning
parent b4632617
package fr.utc.simde.payutc;
import android.app.Activity;
<<<<<<< HEAD
=======
import android.content.DialogInterface;
import android.content.Intent;
import android.util.Log;
import com.fasterxml.jackson.databind.JsonNode;
>>>>>>> foundationListActivity
import fr.utc.simde.payutc.tools.CASConnexion;
import fr.utc.simde.payutc.tools.Dialog;
......@@ -30,7 +26,7 @@ public abstract class BaseActivity extends NFCActivity {
casConnexion.disconnect();
}
protected void unregister(Activity activity) {
protected void unregister(final Activity activity) {
nemopaySession.unregister();
disconnect();
......@@ -77,7 +73,7 @@ public abstract class BaseActivity extends NFCActivity {
activity.startActivity(intent);
} catch (Exception e) {
Log.e(LOG_TAG, "error: " + e.getMessage());
dialog.errorDialog(getString(R.string.information_collection), getString(R.string.foundation_error_get_list));
dialog.errorDialog(activity, getString(R.string.information_collection), getString(R.string.foundation_error_get_list));
}
}
});
......
......@@ -33,42 +33,13 @@ public class FoundationListActivity extends BaseActivity {
setFoundationList(new ObjectMapper().readTree(getIntent().getExtras().getString("foundationList")));
} catch (Exception e) {
Log.wtf(LOG_TAG, "error: " + e.getMessage());
dialog.errorDialog(getResources().getString(R.string.information_collection), getResources().getString(R.string.error_unexpected));
/*, new DialogInterface.OnClickListener() {
dialog.errorDialog(this, getResources().getString(R.string.information_collection), getResources().getString(R.string.error_unexpected), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int id) {
finish();
}
<<<<<<< HEAD
runOnUiThread(new Runnable() {
@Override
public void run() {
HTTPRequest request = nemopaySession.getRequest();
dialog.stopLoading();
try {
if (request.getResponseCode() != 200)
throw new Exception("Malformed JSON");
JsonNode foundationList = request.getJsonResponse();
if (!request.isJsonResponse() || !foundationList.isArray())
throw new Exception("JSON unexpected");
setFoundationList(foundationList);
} catch (Exception e) {
Log.e(LOG_TAG, "error: " + e.getMessage());
dialog.errorDialog(FoundationListActivity.this, getString(R.string.information_collection), getString(R.string.foundation_error_get_list));
}
}
});
}
}.start();
=======
}*/
});
}
>>>>>>> foundationListActivity
}
@Override
......
......@@ -3,7 +3,6 @@ package fr.utc.simde.payutc;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AlertDialog;
import android.os.Bundle;
......@@ -77,7 +76,7 @@ public class MainActivity extends BaseActivity {
}
@Override
protected void unregister(Activity activity) {
protected void unregister(final Activity activity) {
super.unregister(activity);
((TextView) findViewById(R.id.text_app_registered)).setText(R.string.app_not_registred);
......
......@@ -3,11 +3,10 @@ package fr.utc.simde.payutc.tools;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.text.method.LinkMovementMethod;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.TextView;
import fr.utc.simde.payutc.R;
......@@ -74,13 +73,14 @@ public class Dialog {
}
}
public void errorDialog(final Activity activity, final String title, final String message) {
public void errorDialog(final Activity activity, final String title, final String message) { errorDialog(activity, title, message, null); }
public void errorDialog(final Activity activity, final String title, final String message, final DialogInterface.OnClickListener onClickListener) {
this.alertDialogBuilder = new AlertDialog.Builder(activity);
this.alertDialogBuilder
.setTitle(title)
.setMessage(message)
.setCancelable(true)
.setNegativeButton(R.string.ok, null);
.setNegativeButton(R.string.ok, onClickListener);
createDialog();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment