Search in sources :

Example 61 with Builder

use of android.support.v7.app.AlertDialog.Builder in project apps-android-commons by commons-app.

the class CategorizationFragment method backButtonDialog.

public void backButtonDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setMessage("Are you sure you want to go back? The image will not have any categories saved.").setTitle("Warning");
    builder.setPositiveButton("No", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
        //No need to do anything, user remains on categorization screen
        }
    });
    builder.setNegativeButton("Yes", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            getActivity().finish();
        }
    });
    AlertDialog dialog = builder.create();
    dialog.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface)

Example 62 with Builder

use of android.support.v7.app.AlertDialog.Builder in project MadMax by deviz92.

the class DetailCommentDialogFragment method onCreateDialog.

@Override
@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the Builder class for convenient dialog construction
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    // Get the layout inflater
    LayoutInflater inflater = getActivity().getLayoutInflater();
    // Inflate and set the layout for the dialog
    // Pass null as the parent view because its going in the dialog layout
    builder.setTitle("Autore ha commentato:").setView(inflater.inflate(R.layout.detail_comment, null)).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {
        }
    });
    // Create the AlertDialog object and return it
    return builder.create();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) LayoutInflater(android.view.LayoutInflater) NonNull(android.support.annotation.NonNull)

Example 63 with Builder

use of android.support.v7.app.AlertDialog.Builder in project MadMax by deviz92.

the class FirebaseServiceMessage method onMessageReceived.

/*    @Override
    public void onCreate() {
        super.onCreate();
        Log.d(TAG, "onCreate");
    }*/
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    String body = remoteMessage.getNotification().getBody();
    Map<String, String> data = remoteMessage.getData();
    Log.d(TAG, "notification body: " + body);
    String message[], messageContent = null;
    // Creates an explicit intent for an Activity in the app
    Intent resultIntent = null;
    messageContent = body;
    switch(data.get("notificationTitle")) {
        case "notification_invite":
            resultIntent = new Intent(getApplicationContext(), GroupDetailActivity.class);
            resultIntent.putExtra("groupID", data.get("groupID"));
            break;
        case "notification_expense_added":
            resultIntent = new Intent(getApplicationContext(), ExpenseDetailActivity.class);
            resultIntent.putExtra("groupID", data.get("groupID"));
            resultIntent.putExtra("expenseID", data.get("expenseID"));
            break;
        case "notification_expense_removed":
            resultIntent = new Intent(getApplicationContext(), GroupDetailActivity.class);
            resultIntent.putExtra("groupID", data.get("groupID"));
            resultIntent.putExtra("expenseID", data.get("expenseID"));
            break;
        case "notification_proposalExpense_added":
            resultIntent = new Intent(getApplicationContext(), PendingExpenseDetailActivity.class);
            resultIntent.putExtra("expenseID", data.get("expenseID"));
            break;
    }
    // User provaCurrent = MainActivity.getCurrentUser();
    resultIntent.putExtra("userID", getCurrentUser().getID());
    NotificationCompat.Builder mBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(getApplicationContext()).setSmallIcon(R.mipmap.icon).setContentTitle(remoteMessage.getNotification().getTitle()).setContentText(messageContent);
    // The stack builder object will contain an artificial back stack for the started Activity.
    // This ensures that navigating backward from the Activity leads out of your application to the Home screen.
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(getApplicationContext());
    // Adds the back stack for the Intent (but not the Intent itself)
    stackBuilder.addParentStack(MainActivity.class);
    // Adds the Intent that starts the Activity to the top of the stack
    stackBuilder.addNextIntent(resultIntent);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT);
    mBuilder.setContentIntent(resultPendingIntent);
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification = mBuilder.build();
    notification.flags = Notification.FLAG_AUTO_CANCEL;
    // mId allows you to update the notification later on.
    mNotificationManager.notify(1, notification);
/*String body = remoteMessage.getNotification().getBody();
        Log.d(TAG, "notification body: "+body);
        Map<String, String> data = remoteMessage.getData();
        showNotification(remoteMessage.getNotification().getTitle(), body, data);*/
}
Also used : NotificationManager(android.app.NotificationManager) TaskStackBuilder(android.app.TaskStackBuilder) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification) GroupDetailActivity(com.polito.mad17.madmax.activities.groups.GroupDetailActivity) ExpenseDetailActivity(com.polito.mad17.madmax.activities.expenses.ExpenseDetailActivity) PendingExpenseDetailActivity(com.polito.mad17.madmax.activities.expenses.PendingExpenseDetailActivity) NotificationCompat(android.support.v7.app.NotificationCompat) PendingExpenseDetailActivity(com.polito.mad17.madmax.activities.expenses.PendingExpenseDetailActivity) PendingIntent(android.app.PendingIntent) TaskStackBuilder(android.app.TaskStackBuilder)

Example 64 with Builder

use of android.support.v7.app.AlertDialog.Builder in project FlexibleAdapter by davideas.

the class MessageDialog method onCreateDialog.

@SuppressLint("InflateParams")
@Override
public AlertDialog onCreateDialog(Bundle savedInstanceState) {
    View dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_message, null);
    TextView messageView = (TextView) dialogView.findViewById(R.id.message);
    messageView.setMovementMethod(LinkMovementMethod.getInstance());
    messageView.setText(Html.fromHtml(getArguments().getString(ARG_MESSAGE)));
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AppTheme_AlertDialog);
    builder.setTitle(getArguments().getString(ARG_TITLE)).setIcon(getArguments().getInt(ARG_ICON)).setView(dialogView).setPositiveButton(R.string.OK, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    return builder.create();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Example 65 with Builder

use of android.support.v7.app.AlertDialog.Builder in project android-UniversalMusicPlayer by googlesamples.

the class MediaNotificationManager method addPlayPauseAction.

private void addPlayPauseAction(NotificationCompat.Builder builder) {
    LogHelper.d(TAG, "updatePlayPauseAction");
    String label;
    int icon;
    PendingIntent intent;
    if (mPlaybackState.getState() == PlaybackStateCompat.STATE_PLAYING) {
        label = mService.getString(R.string.label_pause);
        icon = R.drawable.uamp_ic_pause_white_24dp;
        intent = mPauseIntent;
    } else {
        label = mService.getString(R.string.label_play);
        icon = R.drawable.uamp_ic_play_arrow_white_24dp;
        intent = mPlayIntent;
    }
    builder.addAction(new NotificationCompat.Action(icon, label, intent));
}
Also used : NotificationCompat(android.support.v7.app.NotificationCompat) PendingIntent(android.app.PendingIntent)

Aggregations

AlertDialog (android.support.v7.app.AlertDialog)114 DialogInterface (android.content.DialogInterface)76 View (android.view.View)67 TextView (android.widget.TextView)48 Intent (android.content.Intent)36 RecyclerView (android.support.v7.widget.RecyclerView)27 ListView (android.widget.ListView)23 Dialog (android.app.Dialog)22 LayoutInflater (android.view.LayoutInflater)20 ImageView (android.widget.ImageView)20 EditText (android.widget.EditText)18 SuppressLint (android.annotation.SuppressLint)17 Context (android.content.Context)17 Bundle (android.os.Bundle)15 NonNull (android.support.annotation.NonNull)14 Button (android.widget.Button)13 ArrayList (java.util.ArrayList)12 BrowserDialog (acr.browser.lightning.dialog.BrowserDialog)10 OnClickListener (android.content.DialogInterface.OnClickListener)10 ScrollView (android.widget.ScrollView)10