use of com.afollestad.materialdialogs.DialogAction in project PocketHub by pockethub.
the class AssigneeDialogFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
Activity activity = getActivity();
Bundle arguments = getArguments();
final MaterialDialog.Builder dialogBuilder = createDialogBuilder().negativeText(R.string.cancel).onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
AssigneeDialogFragment.this.onClick(dialog, BUTTON_NEGATIVE);
}
}).neutralText(R.string.clear).onNeutral(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
AssigneeDialogFragment.this.onClick(dialog, BUTTON_NEUTRAL);
}
});
LayoutInflater inflater = activity.getLayoutInflater();
ListView view = (ListView) inflater.inflate(R.layout.dialog_list_view, null);
view.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
onClick(getDialog(), position);
}
});
ArrayList<User> choices = getChoices();
int selected = arguments.getInt(ARG_SELECTED_CHOICE);
UserListAdapter adapter = new UserListAdapter(inflater, choices.toArray(new User[choices.size()]), selected, loader);
view.setAdapter(adapter);
if (selected >= 0) {
view.setSelection(selected);
}
dialogBuilder.customView(view, false);
return dialogBuilder.build();
}
use of com.afollestad.materialdialogs.DialogAction in project CoCoin by Nightonke.
the class AccountBookSettingActivity method changeLogo.
// change the user logo/////////////////////////////////////////////////////////////////////////////
private void changeLogo() {
User user = BmobUser.getCurrentUser(CoCoinApplication.getAppContext(), User.class);
if (user == null) {
new MaterialDialog.Builder(this).iconRes(R.drawable.cocoin_logo).typeface(CoCoinUtil.GetTypeface(), CoCoinUtil.GetTypeface()).limitIconToDefaultSize().title(R.string.login_first_title).content(R.string.login_first_content).positiveText(R.string.ok).neutralText(R.string.cancel).onAny(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
if (which == DialogAction.POSITIVE) {
userOperator();
}
}
}).show();
return;
}
new MaterialDialog.Builder(this).iconRes(R.drawable.cocoin_logo).typeface(CoCoinUtil.GetTypeface(), CoCoinUtil.GetTypeface()).limitIconToDefaultSize().title(R.string.change_logo_title).content(R.string.change_logo_content).positiveText(R.string.from_gallery).negativeText(R.string.from_camera).neutralText(R.string.cancel).onAny(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
if (which == DialogAction.POSITIVE) {
Intent intent1 = new Intent(Intent.ACTION_PICK, null);
intent1.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
startActivityForResult(intent1, 1);
} else if (which == DialogAction.NEGATIVE) {
Intent intent2 = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent2.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(CoCoinApplication.getAppContext().getFilesDir() + CoCoinUtil.LOGO_NAME)));
startActivityForResult(intent2, 2);
}
}
}).show();
}
use of com.afollestad.materialdialogs.DialogAction in project Timber by naman14.
the class LastFmLoginDialog method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new MaterialDialog.Builder(getActivity()).positiveText("Login").negativeText("Cancel").title("Login to LastFM").customView(R.layout.dialog_lastfm_login, false).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
String username = ((EditText) dialog.findViewById(R.id.lastfm_username)).getText().toString();
String password = ((EditText) dialog.findViewById(R.id.lastfm_password)).getText().toString();
if (username.length() == 0 || password.length() == 0)
return;
final ProgressDialog progressDialog = new ProgressDialog(getActivity());
progressDialog.setMessage("Logging in..");
progressDialog.show();
LastFmClient.getInstance(getActivity()).getUserLoginInfo(new UserLoginQuery(username, password), new UserListener() {
@Override
public void userSuccess() {
progressDialog.dismiss();
if (getTargetFragment() instanceof SettingsFragment) {
((SettingsFragment) getTargetFragment()).updateLastFM();
}
}
@Override
public void userInfoFailed() {
progressDialog.dismiss();
Toast.makeText(getTargetFragment().getActivity(), "Failed to Login", Toast.LENGTH_SHORT).show();
}
});
}
}).build();
}
use of com.afollestad.materialdialogs.DialogAction in project AisenWeiBo by wangdan.
the class OtherItemFragment method checkPhotoPermission.
// private void setLanguage(int value) {
// String[] valueTitleArr = getResources().getStringArray(R.array.pLanguage);
//
// pLanguage.setSummary(valueTitleArr[value]);
// }
public static void checkPhotoPermission(final BaseActivity activity, final boolean shownever) {
APermissionsAction permissionsAction = new APermissionsAction(activity, null, activity.getActivityHelper(), Manifest.permission.CALL_PHONE) {
@Override
protected void onPermissionDenied(boolean alwaysDenied) {
if (alwaysDenied) {
if (shownever && ActivityHelper.getBooleanShareData(GlobalContext.getInstance(), "donot_crash_remind", false)) {
return;
}
MaterialDialog.Builder builder = new MaterialDialog.Builder(activity).forceStacking(true).content(R.string.crash_hint).negativeText(R.string.crash_settings).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(MaterialDialog dialog, DialogAction which) {
ActivityHelper.putBooleanShareData(GlobalContext.getInstance(), "donot_crash_remind", true);
}
}).onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(MaterialDialog dialog, DialogAction which) {
AisenUtils.gotoSettings(activity);
}
});
if (shownever)
builder.positiveText(R.string.donnot_remind);
builder.show();
}
}
};
// 开启日志上报
new IAction(activity, permissionsAction) {
@Override
public void doAction() {
Log.d("Main", "setupCrash");
((MyApplication) GlobalContext.getInstance()).setupCrash();
}
}.run();
}
use of com.afollestad.materialdialogs.DialogAction in project Weather by Sparker0i.
the class GPSTracker method showSettingsAlert.
/**
* Function to show settings alert dialog
* On pressing Settings button will launch Settings Options
* */
public void showSettingsAlert() {
new MaterialDialog.Builder(mContext).title("Enable GPS").content("You need to enable GPS for this function to work").positiveText("ENABLE").onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
mContext.startActivity(intent);
}
}).negativeText("CANCEL").onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
}
}).show();
}
Aggregations