Back to project page smsnenado.
The source code is released under:
Copyright (c) 2013, Alexander Lopatin All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are me...
If you think the Android project smsnenado listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.sbar.smsnenado.dialogs; /*w w w. ja v a 2 s . c om*/ import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.app.Dialog; import android.app.DialogFragment; import android.app.Activity; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import com.sbar.smsnenado.activities.ActivityClass; import com.sbar.smsnenado.activities.MainActivity; import com.sbar.smsnenado.Common; import com.sbar.smsnenado.R; import static com.sbar.smsnenado.Common.LOGE; import static com.sbar.smsnenado.Common.LOGI; import static com.sbar.smsnenado.Common.LOGW; public class NeedDataDialogFragment extends DialogFragment { private Class<?> mActivity = null; private boolean mDismissed = false; public static NeedDataDialogFragment newInstance( int textId, int activityType) { NeedDataDialogFragment frag = new NeedDataDialogFragment(); Bundle bundle = new Bundle(); bundle.putInt("textId", textId); bundle.putInt("activityType", activityType); frag.setArguments(bundle); return frag; } public static NeedDataDialogFragment newInstance( String text, int activityType) { NeedDataDialogFragment frag = new NeedDataDialogFragment(); Bundle bundle = new Bundle(); bundle.putString("text", text); bundle.putInt("activityType", activityType); frag.setArguments(bundle); return frag; } public NeedDataDialogFragment() { } @Override public void onDismiss(DialogInterface dialog) { doDismiss(); } public void doDismiss() { if (mDismissed || !isAdded() || mActivity == null) return; LOGI("doDismiss"); mDismissed = true; Intent intent = new Intent(MainActivity.getInstance(), mActivity); startActivity(intent); dismiss(); } public Dialog onCreateDialog(Bundle b) { Activity activity = MainActivity.getInstance(); mActivity = ActivityClass.get(getArguments().getInt("activityType")); String text = getArguments().getString("text"); if (text == null) { text = activity.getString(getArguments().getInt("textId")); } Builder builder = new AlertDialog.Builder(activity); builder.setMessage(text); builder.setCancelable(false); builder.setPositiveButton( activity.getText(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { doDismiss(); } } ); return builder.create(); } }