Search in sources :

Example 66 with Builder

use of android.support.v7.app.AlertDialog.Builder in project ListenerMusicPlayer by hefuyicoder.

the class MusicService method buildNotification.

/**
     * 构建Notification
     * @return
     */
private Notification buildNotification() {
    final String albumName = getAlbumName();
    final String artistName = getArtistName();
    final boolean isPlaying = isPlaying();
    String text = TextUtils.isEmpty(albumName) ? artistName : artistName + " - " + albumName;
    int playButtonResId = isPlaying ? R.drawable.ic_pause_white_36dp : R.drawable.ic_play_white_36dp;
    Intent nowPlayingIntent = NavigationUtil.getNowPlayingIntent(this);
    PendingIntent clickIntent = PendingIntent.getActivity(this, 0, nowPlayingIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    Bitmap artwork;
    artwork = ImageLoader.getInstance().loadImageSync(ListenerUtil.getAlbumArtUri(getAlbumId()).toString());
    if (artwork == null) {
        artwork = ImageLoader.getInstance().loadImageSync("drawable://" + R.drawable.icon_album_default);
    }
    if (mNotificationPostTime == 0) {
        mNotificationPostTime = System.currentTimeMillis();
    }
    android.support.v4.app.NotificationCompat.Builder builder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_music_note_white_48dp).setLargeIcon(artwork).setContentIntent(clickIntent).setContentTitle(getTrackName()).setContentText(text).setWhen(mNotificationPostTime).addAction(R.drawable.ic_skip_previous_white_36dp, "", retrievePlaybackAction(PREVIOUS_ACTION)).addAction(playButtonResId, "", retrievePlaybackAction(TOGGLEPAUSE_ACTION)).addAction(R.drawable.ic_skip_next_white_36dp, "", retrievePlaybackAction(NEXT_ACTION));
    if (ListenerUtil.isJellyBeanMR1()) {
        builder.setShowWhen(false);
    }
    if (ListenerUtil.isLollipop()) {
        builder.setVisibility(Notification.VISIBILITY_PUBLIC);
        NotificationCompat.MediaStyle style = new NotificationCompat.MediaStyle().setMediaSession(mSession.getSessionToken()).setShowActionsInCompactView(0, 1, 2, 3);
        builder.setStyle(style);
    }
    if (artwork != null && ListenerUtil.isLollipop()) {
        builder.setColor(Palette.from(artwork).generate().getMutedColor(ATEUtil.getThemePrimaryColor(getApplicationContext())));
    }
    return builder.build();
}
Also used : PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) SuppressLint(android.annotation.SuppressLint) Bitmap(android.graphics.Bitmap) NotificationCompat(android.support.v7.app.NotificationCompat) PendingIntent(android.app.PendingIntent)

Example 67 with Builder

use of android.support.v7.app.AlertDialog.Builder in project ToolBarLib by jjhesk.

the class BeastBar method withToolbar.

public static BeastBar withToolbar(AppCompatActivity res, Toolbar original, final Builder beastbuilder) {
    Display display = res.getWindowManager().getDefaultDisplay();
    res.setSupportActionBar(original);
    ActionBar actionbar = res.getSupportActionBar();
    actionbar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    actionbar.setDisplayShowHomeEnabled(false);
    actionbar.setDefaultDisplayHomeAsUpEnabled(false);
    original.setBackgroundResource(beastbuilder.ic_background);
    View homeIcon = res.findViewById(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ? android.R.id.home : android.R.id.home);
    // ((View) homeIcon.getParent()).setLayoutParams(new LinearLayout.LayoutParams(0, 0));
    //  ((View) homeIcon).setVisibility(View.GONE);
    final BeastBar bb = new BeastBar(res);
    bb.setToolBar(original);
    bb.setup = beastbuilder;
    display.getSize(bb.size);
    bb.init();
    return bb;
}
Also used : ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ActionBar(android.support.v7.app.ActionBar) Display(android.view.Display)

Example 68 with Builder

use of android.support.v7.app.AlertDialog.Builder in project android-gif-drawable by koral--.

the class GifSourcesAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final GifSourceItemHolder holder, int position) {
    final String[] descriptions = holder.itemView.getResources().getStringArray(R.array.sources);
    position %= descriptions.length;
    final GifDrawable existingOriginalDrawable = (GifDrawable) holder.gifImageViewOriginal.getDrawable();
    final GifDrawable existingSampledDrawable = (GifDrawable) holder.gifImageViewSampled.getDrawable();
    final GifDrawableBuilder builder = new GifDrawableBuilder().with(existingOriginalDrawable);
    try {
        mGifSourcesResolver.bindSource(position, builder);
        final GifDrawable fullSizeDrawable = builder.build();
        holder.gifImageViewOriginal.setImageDrawable(fullSizeDrawable);
        holder.gifImageViewOriginal.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (fullSizeDrawable.isPlaying())
                    fullSizeDrawable.stop();
                else
                    fullSizeDrawable.start();
            }
        });
        builder.with(existingSampledDrawable).sampleSize(3);
        mGifSourcesResolver.bindSource(position, builder);
        final GifDrawable subsampledDrawable = builder.build();
        final SpannableStringBuilder stringBuilder = new SpannableStringBuilder(descriptions[position] + '');
        stringBuilder.setSpan(new ImageSpan(subsampledDrawable), stringBuilder.length() - 1, stringBuilder.length(), 0);
        holder.descriptionTextView.setText(stringBuilder);
        holder.gifImageViewSampled.setImageDrawable(subsampledDrawable);
        subsampledDrawable.setCallback(holder.multiCallback);
        holder.multiCallback.addView(holder.gifImageViewSampled);
        holder.multiCallback.addView(holder.descriptionTextView);
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}
Also used : GifDrawableBuilder(pl.droidsonroids.gif.GifDrawableBuilder) GifDrawable(pl.droidsonroids.gif.GifDrawable) IOException(java.io.IOException) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) SpannableStringBuilder(android.text.SpannableStringBuilder) ImageSpan(android.text.style.ImageSpan)

Example 69 with Builder

use of android.support.v7.app.AlertDialog.Builder in project android-oss by kickstarter.

the class ThanksActivity method showConfirmGamesNewsletterDialog.

private void showConfirmGamesNewsletterDialog() {
    final String optInDialogMessageString = ksString.format(optInMessageString, "newsletter", newsletterGamesString);
    final AlertDialog.Builder builder = new AlertDialog.Builder(this).setMessage(optInDialogMessageString).setTitle(optInTitleString).setPositiveButton(okString, (__, ___) -> {
    });
    builder.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) KSString(com.kickstarter.libs.KSString) BindString(butterknife.BindString)

Example 70 with Builder

use of android.support.v7.app.AlertDialog.Builder in project qianghongbao by lendylongli.

the class MainActivity method showOpenAccessibilityServiceDialog.

/** 显示未开启辅助服务的对话框*/
private void showOpenAccessibilityServiceDialog() {
    if (mTipsDialog != null && mTipsDialog.isShowing()) {
        return;
    }
    View view = getLayoutInflater().inflate(R.layout.dialog_tips_layout, null);
    view.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            openAccessibilityServiceSettings();
        }
    });
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.open_service_title);
    builder.setView(view);
    builder.setPositiveButton(R.string.open_service_button, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            openAccessibilityServiceSettings();
        }
    });
    mTipsDialog = builder.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) View(android.view.View)

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