Search in sources :

Example 86 with AlertDialog

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();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface)

Example 87 with AlertDialog

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));
}
Also used : MyListDivider(me.yluo.ruisiapp.widget.MyListDivider) AlertDialog(android.support.v7.app.AlertDialog) Intent(android.content.Intent) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) CircleImageView(me.yluo.ruisiapp.widget.CircleImageView) SimpleListAdapter(me.yluo.ruisiapp.adapter.SimpleListAdapter) FloatingActionButton(android.support.design.widget.FloatingActionButton) RecyclerView(android.support.v7.widget.RecyclerView) Toolbar(android.support.v7.widget.Toolbar)

Example 88 with AlertDialog

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;
}
Also used : Bundle(android.os.Bundle) DimmenUtils(me.yluo.ruisiapp.utils.DimmenUtils) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) Dialog(android.app.Dialog) Intent(android.content.Intent) TextUtils(android.text.TextUtils) AppCompatActivity(android.support.v7.app.AppCompatActivity) AppCompatDelegate(android.support.v7.app.AppCompatDelegate) ViewGroup(android.view.ViewGroup) R(me.yluo.ruisiapp.R) MenuItem(android.view.MenuItem) AlertDialog(android.app.AlertDialog) Gravity(android.view.Gravity) TextView(android.widget.TextView) Calendar(java.util.Calendar) Toast(android.widget.Toast) View(android.view.View) Nullable(android.support.annotation.Nullable) App(me.yluo.ruisiapp.App) Dialog(android.app.Dialog) AlertDialog(android.app.AlertDialog) Intent(android.content.Intent)

Example 89 with AlertDialog

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();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog)

Example 90 with AlertDialog

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());
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) EditText(android.widget.EditText) ViewGroup(android.view.ViewGroup) SuppressLint(android.annotation.SuppressLint) ImageView(android.widget.ImageView) View(android.view.View)

Aggregations

AlertDialog (android.support.v7.app.AlertDialog)410 DialogInterface (android.content.DialogInterface)274 View (android.view.View)219 TextView (android.widget.TextView)165 Intent (android.content.Intent)117 EditText (android.widget.EditText)86 ImageView (android.widget.ImageView)69 Button (android.widget.Button)68 LayoutInflater (android.view.LayoutInflater)59 RecyclerView (android.support.v7.widget.RecyclerView)54 NonNull (android.support.annotation.NonNull)52 AdapterView (android.widget.AdapterView)51 SuppressLint (android.annotation.SuppressLint)50 ArrayList (java.util.ArrayList)49 Bundle (android.os.Bundle)47 ListView (android.widget.ListView)42 Context (android.content.Context)35 SharedPreferences (android.content.SharedPreferences)35 Uri (android.net.Uri)32 LinearLayout (android.widget.LinearLayout)30