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();
}
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;
}
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);
}
}
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();
}
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();
}
Aggregations