Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void show_alert(String title, String message) {
- Log.d("ipov","show_alert(+)");
- SMSDialogFragment smsDialogFragment = new SMSDialogFragment();
- smsDialogFragment.title = title;
- smsDialogFragment.message = message;
- smsDialogFragment.show(getFragmentManager(), "smsDialog");
- Log.d("ipov","show_alert(-)");
- }
- public class SMSDialogFragment extends DialogFragment {
- public String title;
- public String message;
- /* The activity that creates an instance of this dialog fragment must
- * implement this interface in order to receive event callbacks.
- * Each method passes the DialogFragment in case the host needs to query it. */
- public interface SMSDialogFragmentListener {
- public void onDialogPositiveClick(DialogFragment dialog);
- //public void onDialogNegativeClick(DialogFragment dialog);
- }
- // Use this instance of the interface to deliver action events
- SMSDialogFragmentListener mListener;
- // Override the Fragment.onAttach() method to instantiate the NoticeDialogListener
- @Override
- public void onAttach(Activity activity) {
- Log.d("ipov","dialog onAttach activity.getClass().getName()="+activity.getClass().getName());
- super.onAttach(activity);
- // Verify that the host activity implements the callback interface
- try {
- // Instantiate the NoticeDialogListener so we can send events to the host
- mListener = (SMSDialogFragmentListener) activity;
- } catch (ClassCastException e) {
- // The activity doesn't implement the interface, throw exception
- throw new ClassCastException(activity.toString()
- + " must implement SMSDialogFragmentListener");
- }
- }
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- if(savedInstanceState != null)
- Log.d("ipov","dialog onCreateDialog savedInstanceState.toString()="+savedInstanceState.toString());
- Log.d("ipov","dialog onCreateDialog getActivity().getClass().getName()="+getActivity().getClass().getName());
- // Use the Builder class for convenient dialog construction
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- builder.setTitle(title)
- .setMessage(message)
- .setPositiveButton("button_1", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- //mListener.onDialogPositiveClick(SMSDialogFragment.this);
- }
- })
- .setNegativeButton("button_2", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- // User cancelled the dialog
- }
- });
- // Create the AlertDialog object and return it
- return builder.create();
- }
- private class LoadSMSTask extends AsyncTask<Void, Void, String> {
- public AsyncResponse delegate = null;
- @Override
- protected String doInBackground(Void... params) {
- // получаем данные с внешнего ресурса
- processSmsForSender( account.getSMSSenderName() );
- return null;
- }
- @Override
- protected void onPostExecute(String strJson) {
- Log.d("ipov","LoadSMSTask onPostExecute(+)");
- super.onPostExecute(strJson);
- JSONObject dataJsonObj = null;
- // выводим целиком полученную json-строку
- try {
- dataJsonObj = new JSONObject(
- "{n" +
- " "type": "smses_processed"n" +
- "}n"
- );
- } catch (JSONException e) {
- e.printStackTrace();
- }
- delegate.onJSONReceived(dataJsonObj,null);
- //RFin.initMainScreen();
- }
- }
- public class AddAccount extends AppCompatActivity implements AsyncResponse, SMSDialogFragment.SMSDialogFragmentListener {
- ...
- @Override
- public void onJSONReceived(JSONObject jsonObject, String jsonErrorText){
- Log.d("ipov","onJSONReceived(+)");
- ...
- Log.d("ipov","onJSONReceived smses_processed show_alert");
- show_alert("sms processig error", parsingErrors[i]);
- ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement