use of android.support.v7.app.AlertDialog in project vlc-android by videolan.
the class EqualizerFragment method createSaveCustomSetDialog.
public void createSaveCustomSetDialog(final int positionToSave, final boolean displayedByUser, final boolean onPause) {
final String oldName = allSets.get(positionToSave);
final MediaPlayer.Equalizer temporarySet = MediaPlayer.Equalizer.create();
temporarySet.setPreAmp(mEqualizer.getPreAmp());
for (int i = 0; i < MediaPlayer.Equalizer.getBandCount(); i++) temporarySet.setAmp(i, mEqualizer.getAmp(i));
final EditText input = new EditText(context);
input.setText(oldName);
input.setSelectAllOnFocus(true);
final AlertDialog saveEqualizer = new AlertDialog.Builder(context).setTitle(getResources().getString(displayedByUser ? R.string.custom_set_save_title : R.string.custom_set_save_warning)).setMessage(getResources().getString((getEqualizerType(positionToSave) == TYPE_CUSTOM) ? R.string.existing_custom_set_save_message : R.string.new_custom_set_save_message)).setView(input).setPositiveButton(R.string.save, null).setNegativeButton(R.string.do_not_save, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (onPause)
VLCOptions.saveEqualizerInSettings(context, mEqualizer, allSets.get(positionToSave), binding.equalizerButton.isChecked(), false);
}
}).setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
if (onPause)
VLCOptions.saveEqualizerInSettings(context, mEqualizer, allSets.get(positionToSave), binding.equalizerButton.isChecked(), false);
}
}).create();
saveEqualizer.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
// HACK to prevent closure
saveEqualizer.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
final Button positiveButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);
positiveButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final String newName = input.getText().toString();
if (newName.contains("_") || TextUtils.equals(newName, newPresetName)) {
Toast.makeText(VLCApplication.getAppContext(), VLCApplication.getAppContext().getResources().getString(R.string.custom_set_wrong_input), Toast.LENGTH_SHORT).show();
} else if (allSets.contains(newName) && !TextUtils.equals(newName, oldName)) {
Toast.makeText(VLCApplication.getAppContext(), VLCApplication.getAppContext().getResources().getString(R.string.custom_set_already_exist), Toast.LENGTH_SHORT).show();
} else {
VLCOptions.saveCustomSet(context, temporarySet, newName);
if (onPause) {
if (binding.equalizerButton.isChecked())
VLCOptions.saveEqualizerInSettings(context, temporarySet, newName, true, true);
} else {
if (TextUtils.equals(newName, oldName)) {
if (displayedByUser) {
mState.update(allSets.indexOf(newName), true);
}
} else {
// insert new item before the one being saved in order to keep position
allSets.add(positionToSave, newName);
customCount++;
if (displayedByUser) {
adapter.notifyDataSetChanged();
mState.update(allSets.indexOf(newName), true);
updateAlreadyHandled = true;
}
}
}
saveEqualizer.dismiss();
}
}
});
}
});
saveEqualizer.show();
}
use of android.support.v7.app.AlertDialog in project Applozic-Android-SDK by AppLozic.
the class MainActivity method onNavigationDrawerItemSelected.
@Override
public void onNavigationDrawerItemSelected(int position) {
if (position == 1) {
Intent intent = new Intent(this, ConversationActivity.class);
if (ApplozicClient.getInstance(this).isContextBasedChat()) {
intent.putExtra(ConversationUIService.CONTEXT_BASED_CHAT, true);
}
startActivity(intent);
return;
}
/*
if (position == 1) {
ConversationFragment conversationFragment = new ConversationFragment();
Contact contact = new Contact(this, "mobicomkit");
mTitle = getString(R.string.user_id);
addFragment(this, conversationFragment, "conversationFragment");
conversationFragment.loadConversation(contact);
return;
}*/
if (position == 0) {
mTitle = getString(R.string.ecommerce);
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.container, EcommerceFragment.newInstance("", "")).commit();
return;
}
if (position == 2) {
UserLogoutTask.TaskListener userLogoutTaskListener = new UserLogoutTask.TaskListener() {
@Override
public void onSuccess(Context context) {
userLogoutTask = null;
Toast.makeText(getBaseContext(), getBaseContext().getString(R.string.log_out_successful), Toast.LENGTH_SHORT).show();
Intent intent = new Intent(context, LoginActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
finish();
}
@Override
public void onFailure(Exception exception) {
userLogoutTask = null;
AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
alertDialog.setTitle(getString(R.string.text_alert));
alertDialog.setMessage(exception.toString());
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.ok_alert), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
if (!isFinishing()) {
alertDialog.show();
}
}
};
userLogoutTask = new UserLogoutTask(userLogoutTaskListener, this);
userLogoutTask.execute((Void) null);
}
if (position == 3) {
Map<String, String> messageMetaData = new HashMap<>();
messageMetaData.put(Message.MetaDataType.KEY.getValue(), Message.MetaDataType.HIDDEN.getValue());
Message message = new Message();
MobiComUserPreference userPreferences = MobiComUserPreference.getInstance(MainActivity.this);
message.setContactIds("android");
message.setTo("android");
message.setContentType(Message.ContentType.CUSTOM.getValue());
message.setMessage("this is meta data hidden");
message.setMetadata(messageMetaData);
message.setStoreOnDevice(Boolean.TRUE);
message.setRead(Boolean.TRUE);
message.setCreatedAtTime(System.currentTimeMillis() + userPreferences.getDeviceTimeOffset());
message.setSendToDevice(Boolean.FALSE);
message.setType(Message.MessageType.MT_OUTBOX.getValue());
message.setDeviceKeyString(userPreferences.getDeviceKeyString());
message.setSource(Message.Source.MT_MOBILE_APP.getValue());
new MobiComConversationService(MainActivity.this).sendMessage(message, MessageIntentService.class);
}
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.container, PlaceholderFragment.newInstance(position + 1)).commit();
}
use of android.support.v7.app.AlertDialog in project Taskzilla by CMPUT301W18T05.
the class ViewTaskActivity method thePinkButton.
/**
*@param view pretty much the page it's on
* @author myapplestory
* thePinkButton
* upon pressing place button on task page
* prompts user to enter in a bid amount
* if valid input, will add bid to task
*
* notes
* can probably add more stuff to dialog
*/
public void thePinkButton(android.view.View view) {
final AlertDialog mBuilder = new AlertDialog.Builder(ViewTaskActivity.this).create();
final View mView = getLayoutInflater().inflate(R.layout.dialog_place_bid, null);
final EditText incomingBidText = mView.findViewById(R.id.place_bid_edittext);
// Taken from https://gist.github.com/gaara87/3607765
// 2018-03-19
// Limits the number of decimals allowed in input
incomingBidText.setFilters(new InputFilter[] { new DigitsKeyListener(Boolean.FALSE, Boolean.TRUE) {
@Override
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
StringBuilder builder = new StringBuilder(dest);
builder.insert(dstart, source);
String temp = builder.toString();
if (temp.contains(".")) {
temp = temp.substring(temp.indexOf(".") + 1);
if (temp.length() > 2) {
return "";
}
}
return super.filter(source, start, end, dest, dstart, dend);
}
} });
// bring up keyboard when user taps place bid
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
final Button submitBidButton = mView.findViewById(R.id.submit_bid_button);
submitBidButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Float incomingBidFloat;
try {
incomingBidFloat = Float.parseFloat(incomingBidText.getText().toString());
incomingBidFloat = (float) (Math.round(incomingBidFloat * 100.0) / 100.0);
} catch (Exception exception) {
Toast.makeText(ViewTaskActivity.this, "Please enter in a valid bid amount", Toast.LENGTH_SHORT).show();
return;
}
// do stuff here to actually add bid
task.addBid(new Bid(currentUserId, taskID, incomingBidFloat));
task.setStatus("bidded");
TaskStatus.setText("bidded");
Toast.makeText(ViewTaskActivity.this, "Bid placed", Toast.LENGTH_SHORT).show();
// hide keyboard upon pressing button
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(submitBidButton.getWindowToken(), 0);
mBuilder.dismiss();
}
});
mBuilder.setView(mView);
mBuilder.show();
}
use of android.support.v7.app.AlertDialog in project mongol-library by suragch.
the class MongolTextViewActivity method onPaddingClick.
public void onPaddingClick(View view) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Padding");
final String[] paddings = { "0dp", "10dp", "10dp, 0dp, 20dp, 30dp" };
builder.setSingleChoiceItems(paddings, mCheckedPaddingItem, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
float density = getResources().getDisplayMetrics().density;
switch(which) {
case 0:
mtvExample.setPadding(0, 0, 0, 0);
break;
case 1:
int px = (int) (10 * density);
mtvExample.setPadding(px, px, px, px);
break;
case 2:
int left = (int) (10 * density);
int top = (int) (0 * density);
int right = (int) (20 * density);
int bottom = (int) (30 * density);
mtvExample.setPadding(left, top, right, bottom);
break;
}
mCheckedPaddingItem = which;
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
use of android.support.v7.app.AlertDialog in project mongol-library by suragch.
the class MongolTextViewActivity method onSizeClick.
public void onSizeClick(View view) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Font Size");
final String[] fontSizesSP = { "10sp", "20sp", "30sp", "40sp", "50sp" };
builder.setSingleChoiceItems(fontSizesSP, mCheckedSizeItem, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
int size = 30;
switch(which) {
case 0:
size = 10;
break;
case 1:
size = 20;
break;
case 2:
size = 30;
break;
case 3:
size = 40;
break;
case 4:
size = 50;
break;
}
mtvExample.setTextSize(size);
mCheckedSizeItem = which;
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
Aggregations