Search in sources :

Example 36 with DialogAction

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();
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) User(com.meisolsson.githubsdk.model.User) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) Bundle(android.os.Bundle) BaseActivity(com.github.pockethub.android.ui.BaseActivity) Activity(android.app.Activity) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ListView(android.widget.ListView) DialogAction(com.afollestad.materialdialogs.DialogAction) LayoutInflater(android.view.LayoutInflater)

Example 37 with DialogAction

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();
}
Also used : BmobUser(cn.bmob.v3.BmobUser) User(com.nightonke.saver.model.User) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) DialogAction(com.afollestad.materialdialogs.DialogAction) NonNull(android.support.annotation.NonNull) Intent(android.content.Intent) BmobFile(cn.bmob.v3.datatype.BmobFile) File(java.io.File)

Example 38 with DialogAction

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();
}
Also used : SettingsFragment(com.naman14.timber.fragments.SettingsFragment) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) DialogAction(com.afollestad.materialdialogs.DialogAction) NonNull(android.support.annotation.NonNull) UserLoginQuery(com.naman14.timber.lastfmapi.models.UserLoginQuery) ProgressDialog(android.app.ProgressDialog) UserListener(com.naman14.timber.lastfmapi.callbacks.UserListener)

Example 39 with DialogAction

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();
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) IAction(org.aisen.android.support.action.IAction) DialogAction(com.afollestad.materialdialogs.DialogAction) APermissionsAction(org.aisen.android.support.permissions.APermissionsAction)

Example 40 with DialogAction

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();
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) DialogAction(com.afollestad.materialdialogs.DialogAction) NonNull(android.support.annotation.NonNull) Intent(android.content.Intent)

Aggregations

DialogAction (com.afollestad.materialdialogs.DialogAction)43 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)43 NonNull (android.support.annotation.NonNull)28 View (android.view.View)28 TextView (android.widget.TextView)22 ImageView (android.widget.ImageView)15 RecyclerView (android.support.v7.widget.RecyclerView)13 MenuItem (android.view.MenuItem)12 PopupMenu (android.widget.PopupMenu)12 Intent (android.content.Intent)8 File (java.io.File)8 LayoutInflater (android.view.LayoutInflater)7 List (java.util.List)7 Song (io.hefuyi.listener.mvp.model.Song)6 SuppressLint (android.annotation.SuppressLint)5 IOException (java.io.IOException)5 Activity (android.app.Activity)4 ProgressDialog (android.app.ProgressDialog)4 Context (android.content.Context)4 Bundle (android.os.Bundle)4