use of android.support.v7.app.AlertDialog in project Passenger_Security by ujjwalagr.
the class Login method onBackPressed.
@Override
public void onBackPressed() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Are you sure you want to exit?");
builder.setCancelable(false);
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Login.this.finish();
}
}).setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
}
use of android.support.v7.app.AlertDialog in project Ruisi by freedom10086.
the class UserDetailActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_detail);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.transparent));
}
toolbarLayout = findViewById(R.id.toolbar_layout);
infoList = findViewById(R.id.recycler_view);
CircleImageView imageView = findViewById(R.id.user_detail_img_avatar);
layout = findViewById(R.id.main_window);
progressView = findViewById(R.id.grade_progress);
progresText = findViewById(R.id.progress_text);
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(v -> fab_click());
ViewCompat.setTransitionName(imageView, NAME_IMG_AVATAR);
username = getIntent().getStringExtra("loginName");
imageUrl = getIntent().getStringExtra("avatarUrl");
Picasso.with(this).load(imageUrl).placeholder(R.drawable.image_placeholder).into(imageView);
toolbarLayout.setTitle(username);
Toolbar mToolbar = findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
adapter = new SimpleListAdapter(ListType.INFO, this, datas);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
infoList.setLayoutManager(layoutManager);
infoList.addItemDecoration(new MyListDivider(this, MyListDivider.VERTICAL));
infoList.setAdapter(adapter);
userUid = getIntent().getStringExtra("uid");
if (TextUtils.isEmpty(userUid)) {
userUid = GetId.getId("uid=", imageUrl);
}
// 如果是自己
if (userUid.equals(App.getUid(this))) {
fab.setImageResource(R.drawable.ic_close_24dp);
imageView.setOnClickListener(view -> {
final String[] items = { "修改密码" };
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
alertBuilder.setTitle("操作");
alertBuilder.setItems(items, (arg0, index) -> {
if (index == 0) {
startActivity(new Intent(UserDetailActivity.this, ChangePasswordActivity.class));
}
});
AlertDialog d = alertBuilder.create();
d.show();
});
}
loadData(UrlUtils.getUserHomeUrl(userUid, false));
}
use of android.support.v7.app.AlertDialog in project Ruisi by freedom10086.
the class BaseActivity method isLogin.
// 判断是否需要弹出登录dialog
public boolean isLogin() {
if (!TextUtils.isEmpty(App.getUid(this))) {
return true;
} else {
Dialog alertDialog = new AlertDialog.Builder(this).setTitle("需要登陆").setMessage("你还没有登陆,要去登陆吗??").setPositiveButton("登陆", (dialog, which) -> startActivity(new Intent(BaseActivity.this, LoginActivity.class))).setNegativeButton("取消", null).setCancelable(true).create();
alertDialog.show();
}
return false;
}
use of android.support.v7.app.AlertDialog in project MaxLock by Maxr1998.
the class MaxLockPreferenceFragment method showUpdatedMessage.
private void showUpdatedMessage() {
AlertDialog message = new AlertDialog.Builder(getActivity()).setMessage(R.string.dialog_maxlock_updated).setNegativeButton(R.string.dialog_button_whats_new, (dialog, which) -> showChangelog()).setPositiveButton(R.string.dialog_button_got_it, null).create();
message.setCanceledOnTouchOutside(false);
message.show();
}
use of android.support.v7.app.AlertDialog in project MaxLock by Maxr1998.
the class Util method setPassword.
public static void setPassword(final Context context, final String app) {
@SuppressLint("InflateParams") final View dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_set_password, null);
final AlertDialog dialog = new AlertDialog.Builder(context).setCancelable(false).setTitle(R.string.pref_set_password).setView(dialogView).setPositiveButton(android.R.string.ok, null).setNegativeButton(android.R.string.cancel, null).create();
dialog.show();
((ViewGroup) dialogView.getParent()).setPadding(10, 10, 10, 10);
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(v -> {
EditText p1 = dialogView.findViewById(R.id.edt_password);
EditText p2 = dialogView.findViewById(R.id.edt_re_password);
String v1 = p1.getText().toString();
String v2 = p2.getText().toString();
if (!v1.equals(v2)) {
p1.setText("");
p2.setText("");
Toast.makeText(context, R.string.toast_password_inconsistent, Toast.LENGTH_SHORT).show();
} else if (v1.length() == 0) {
Toast.makeText(context, R.string.toast_password_null, Toast.LENGTH_SHORT).show();
} else {
dialog.dismiss();
if (app == null) {
getPreferencesKeys(context).edit().putString(Common.KEY_PREFERENCE, shaHash(v1)).apply();
getPreferences(context).edit().putString(Common.LOCKING_TYPE, v1.matches("[0-9]+") ? Common.PREF_VALUE_PASS_PIN : Common.PREF_VALUE_PASSWORD).apply();
} else {
getPreferencesKeysPerApp(context).edit().putString(app, v1.matches("[0-9]+") ? Common.PREF_VALUE_PASS_PIN : Common.PREF_VALUE_PASSWORD).putString(app + Common.APP_KEY_PREFERENCE, shaHash(v1)).apply();
}
Toast.makeText(context, R.string.toast_password_changed, Toast.LENGTH_SHORT).show();
}
});
dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setOnClickListener(v -> dialog.dismiss());
}
Aggregations