use of android.support.v7.app.AlertDialog in project WordPress-Login-Flow-Android by wordpress-mobile.
the class GoogleFragment method showErrorDialog.
protected void showErrorDialog(String message) {
AlertDialog dialog = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.LoginTheme)).setMessage(message).setPositiveButton(R.string.login_error_button, null).create();
dialog.show();
}
use of android.support.v7.app.AlertDialog in project PocketMaps by junjunguo.
the class MainActivity method addDeleteItemHandler.
public static void addDeleteItemHandler(final Context context, final RecyclerView recView, final OnItemClickListener l) {
// swipe left or right to remove an item
ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ITEM_TOUCH_HELPER_LEFT | ITEM_TOUCH_HELPER_RIGHT) {
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
return false;
}
@Override
public void onSwiped(final RecyclerView.ViewHolder viewHolder, int swipeDir) {
AlertDialog.Builder builder1 = new AlertDialog.Builder(context);
builder1.setMessage(R.string.delete_msg);
builder1.setCancelable(true);
builder1.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
// Remove swiped item from list and notify the RecyclerView
l.onItemClick(null, viewHolder.itemView, viewHolder.getAdapterPosition(), viewHolder.getItemId());
}
});
builder1.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
int vhPos = viewHolder.getAdapterPosition();
recView.getAdapter().notifyItemRemoved(vhPos);
recView.getAdapter().notifyItemInserted(vhPos);
}
});
AlertDialog alert11 = builder1.create();
alert11.show();
}
};
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleItemTouchCallback);
itemTouchHelper.attachToRecyclerView(recView);
}
use of android.support.v7.app.AlertDialog in project PocketMaps by junjunguo.
the class AppSettings method confirmWindow.
private void confirmWindow() {
// 1. Instantiate an AlertDialog.Builder with its constructor
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
final EditText edittext = new EditText(activity);
builder.setTitle(activity.getResources().getString(R.string.dialog_stop_save_tracking));
builder.setMessage("path: " + Variable.getVariable().getTrackingFolder().getAbsolutePath() + "/");
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
String formattedDate = df.format(System.currentTimeMillis());
edittext.setText(formattedDate);
builder.setView(edittext);
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
// builder.setView(inflater.inflate(R.layout.dialog_tracking_exit, null));
// Add action buttons
builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
// save file
Tracking.getTracking().saveAsGPX(edittext.getText().toString());
Tracking.getTracking().stopTracking(AppSettings.this);
trackingBtnClicked();
}
}).setNeutralButton(R.string.stop, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Tracking.getTracking().stopTracking(AppSettings.this);
trackingBtnClicked();
}
}).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
// 3. Get the AlertDialog from create()
AlertDialog dialog = builder.create();
// ((EditText) ((AlertDialog) dialog).findViewById(R.id.dialog_tracking_exit_et)).setText(formattedDate);
dialog.show();
}
use of android.support.v7.app.AlertDialog in project android-diplicity by zond.
the class GameActivity method showPress.
public void showPress() {
hideAllExcept(R.id.press_view);
if (member != null) {
FloatingActionButton button = (FloatingActionButton) findViewById(R.id.create_channel_button);
button.setVisibility(View.VISIBLE);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final List<String> nations = new ArrayList<String>();
for (Member thisMember : game.Members) {
if (!member.Nation.equals(thisMember.Nation)) {
nations.add(thisMember.Nation);
}
}
final boolean[] checked = new boolean[nations.size()];
final AlertDialog dialog = new AlertDialog.Builder(GameActivity.this).setMultiChoiceItems(nations.toArray(new String[] {}), checked, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i, boolean b) {
checked[i] = b;
}
}).setTitle(R.string.members).setPositiveButton(R.string.create, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int j) {
List<String> channelMembers = new ArrayList<String>();
for (int i = 0; i < checked.length; i++) {
if (checked[i]) {
channelMembers.add(nations.get(i));
}
}
channelMembers.add(member.Nation);
Collections.sort(channelMembers);
ChannelService.Channel channel = new ChannelService.Channel();
channel.GameID = game.ID;
channel.Members = channelMembers;
PressActivity.startPressActivity(GameActivity.this, game, channel, member);
dialogInterface.dismiss();
}
}).show();
}
});
} else {
findViewById(R.id.create_channel_button).setVisibility(View.GONE);
}
handleReq(channelService.ListChannels(game.ID), new Sendable<MultiContainer<ChannelService.Channel>>() {
@Override
public void send(MultiContainer<ChannelService.Channel> channelMultiContainer) {
final List<ChannelService.Channel> channels = new ArrayList<>();
for (SingleContainer<ChannelService.Channel> channelSingleContainer : channelMultiContainer.Properties) {
channels.add(channelSingleContainer.Properties);
}
ChannelTable channelTable = (ChannelTable) findViewById(R.id.press_channel_table);
channelTable.setChannels(GameActivity.this, game, member, channels);
}
}, getResources().getString(R.string.loading_channels));
}
use of android.support.v7.app.AlertDialog in project android-diplicity by zond.
the class UserView method getAvatarClickListener.
public static OnClickListener getAvatarClickListener(final RetrofitActivity retrofitActivity, final Game game, final Member member, final User user) {
if (game == null) {
return getAvatarClickListener(retrofitActivity, user);
}
Member me = retrofitActivity.getLoggedInMember(game);
if (me == null || me.Nation.equals(member.Nation)) {
return getAvatarClickListener(retrofitActivity, user);
}
final Member finalMe = me;
return new OnClickListener() {
@Override
public void onClick(View v) {
retrofitActivity.handleReq(JoinObservable.when(JoinObservable.from(retrofitActivity.userStatsService.UserStatsLoad(user.Id)).and(retrofitActivity.gameStateService.GameStateLoad(game.ID, finalMe.Nation)).and(retrofitActivity.banService.BanLoad(retrofitActivity.getLoggedInUser().Id, user.Id).onErrorReturn(new Func1<Throwable, SingleContainer<Ban>>() {
@Override
public SingleContainer<Ban> call(Throwable throwable) {
if (throwable instanceof HttpException) {
HttpException he = (HttpException) throwable;
if (he.code() == 404) {
return null;
}
}
throw new RuntimeException(throwable);
}
})).then(new Func3<SingleContainer<UserStats>, SingleContainer<GameState>, SingleContainer<Ban>, Object>() {
@Override
public Object call(final SingleContainer<UserStats> userStatsSingleContainer, final SingleContainer<GameState> gameStateSingleContainer, final SingleContainer<Ban> banSingleContainer) {
AlertDialog dialog = new AlertDialog.Builder(retrofitActivity).setView(R.layout.user_dialog).show();
setupUserDialog(retrofitActivity, dialog, userStatsSingleContainer, banSingleContainer);
final CheckBox mutedCheckBox = (CheckBox) dialog.findViewById(R.id.muted);
mutedCheckBox.setVisibility(VISIBLE);
mutedCheckBox.setChecked(gameStateSingleContainer.Properties.Muted != null && gameStateSingleContainer.Properties.Muted.contains(member.Nation));
mutedCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked && (gameStateSingleContainer.Properties.Muted == null || !gameStateSingleContainer.Properties.Muted.contains(member.Nation))) {
if (gameStateSingleContainer.Properties.Muted == null) {
gameStateSingleContainer.Properties.Muted = new ArrayList<String>();
}
gameStateSingleContainer.Properties.Muted.add(member.Nation);
} else if (!isChecked && gameStateSingleContainer.Properties.Muted != null && gameStateSingleContainer.Properties.Muted.contains(member.Nation)) {
gameStateSingleContainer.Properties.Muted.remove(member.Nation);
}
retrofitActivity.handleReq(retrofitActivity.gameStateService.GameStateUpdate(gameStateSingleContainer.Properties, game.ID, finalMe.Nation), new Sendable<SingleContainer<GameState>>() {
@Override
public void send(SingleContainer<GameState> gameStateSingleContainer) {
}
}, retrofitActivity.getResources().getString(R.string.updating));
}
});
return null;
}
})).toObservable(), new Sendable<Object>() {
@Override
public void send(Object o) {
}
}, retrofitActivity.getResources().getString(R.string.loading_user_stats));
}
};
}
Aggregations