Search in sources :

Example 11 with MaterialDialog

use of com.afollestad.materialdialogs.MaterialDialog in project material-camera by afollestad.

the class BaseCameraFragment method onClick.

@Override
public void onClick(View view) {
    final int id = view.getId();
    if (id == R.id.facing) {
        mInterface.toggleCameraPosition();
        setImageRes(mButtonFacing, mInterface.getCurrentCameraPosition() == BaseCaptureActivity.CAMERA_POSITION_BACK ? mInterface.iconFrontCamera() : mInterface.iconRearCamera());
        closeCamera();
        openCamera();
        setupFlashMode();
    } else if (id == R.id.video) {
        if (mIsRecording) {
            stopRecordingVideo(false);
            mIsRecording = false;
        } else {
            if (getArguments().getBoolean(CameraIntentKey.SHOW_PORTRAIT_WARNING, true) && Degrees.isPortrait(getActivity())) {
                new MaterialDialog.Builder(getActivity()).title(R.string.mcam_portrait).content(R.string.mcam_portrait_warning).positiveText(R.string.mcam_yes).negativeText(android.R.string.cancel).onPositive(new MaterialDialog.SingleButtonCallback() {

                    @Override
                    public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
                        mIsRecording = startRecordingVideo();
                    }
                }).show();
            } else {
                mIsRecording = startRecordingVideo();
            }
        }
    } else if (id == R.id.stillshot) {
        takeStillshot();
    } else if (id == R.id.flash) {
        invalidateFlash(true);
    }
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) DialogAction(com.afollestad.materialdialogs.DialogAction) SuppressLint(android.annotation.SuppressLint)

Example 12 with MaterialDialog

use of com.afollestad.materialdialogs.MaterialDialog in project Timber by naman14.

the class SubStyleSelectorFragment method showPurchaseDialog.

private void showPurchaseDialog() {
    MaterialDialog dialog = new MaterialDialog.Builder(getActivity()).title("Purchase").content("This now playing style is available after a one time purchase of any amount. Support development and unlock this style?").positiveText("Support development").neutralText("Restore purchases").onPositive(new MaterialDialog.SingleButtonCallback() {

        @Override
        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
            startActivity(new Intent(getActivity(), DonateActivity.class));
            dialog.dismiss();
        }
    }).onNeutral(new MaterialDialog.SingleButtonCallback() {

        @Override
        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
            Intent intent = new Intent(getActivity(), DonateActivity.class);
            intent.putExtra("title", "Restoring purchases..");
            intent.setAction("restore");
            startActivity(intent);
            dialog.dismiss();
        }
    }).show();
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) DialogAction(com.afollestad.materialdialogs.DialogAction) NonNull(android.support.annotation.NonNull) Intent(android.content.Intent)

Example 13 with MaterialDialog

use of com.afollestad.materialdialogs.MaterialDialog in project PocketHub by pockethub.

the class CommitDiffListFragment method showFileOptions.

private void showFileOptions(CharSequence line, final int position, final GitHubFile file) {
    MaterialDialog.Builder builder = new MaterialDialog.Builder(getActivity()).title(CommitUtils.getName(file));
    final MaterialDialog[] dialogHolder = new MaterialDialog[1];
    View view = getActivity().getLayoutInflater().inflate(R.layout.diff_line_dialog, null);
    ViewFinder finder = new ViewFinder(view);
    TextView diff = finder.textView(R.id.tv_diff);
    diff.setText(line);
    diffStyler.updateColors(line, diff);
    finder.setText(R.id.tv_commit, getString(R.string.commit_prefix) + CommitUtils.abbreviate(commit));
    finder.find(R.id.ll_view_area).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            dialogHolder[0].dismiss();
            openFile(file);
        }
    });
    finder.find(R.id.ll_comment_area).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            dialogHolder[0].dismiss();
            startActivityForResult(CreateCommentActivity.createIntent(repository, commit.sha(), file.filename(), position), COMMENT_CREATE);
        }
    });
    builder.customView(view, false).negativeText(R.string.cancel).onNegative(new MaterialDialog.SingleButtonCallback() {

        @Override
        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
            dialog.dismiss();
        }
    });
    MaterialDialog dialog = builder.build();
    dialogHolder[0] = dialog;
    dialog.setCanceledOnTouchOutside(true);
    dialog.show();
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) ViewFinder(com.github.kevinsawicki.wishlist.ViewFinder) DialogAction(com.afollestad.materialdialogs.DialogAction) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Example 14 with MaterialDialog

use of com.afollestad.materialdialogs.MaterialDialog in project PocketHub by pockethub.

the class LoginWebViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    WebView webView = new WebView(this);
    webView.loadUrl(getIntent().getStringExtra(LoginActivity.INTENT_EXTRA_URL));
    webView.setWebViewClient(new WebViewClient() {

        MaterialDialog dialog = new MaterialDialog.Builder(LoginWebViewActivity.this).content(R.string.loading).progress(true, 0).build();

        @Override
        public void onPageStarted(android.webkit.WebView view, String url, Bitmap favicon) {
            dialog.show();
        }

        @Override
        public void onPageFinished(android.webkit.WebView view, String url) {
            dialog.dismiss();
        }

        @Override
        public boolean shouldOverrideUrlLoading(android.webkit.WebView view, String url) {
            Uri uri = Uri.parse(url);
            if (uri.getScheme().equals(getString(R.string.github_oauth_scheme))) {
                Intent data = new Intent();
                data.setData(uri);
                setResult(RESULT_OK, data);
                finish();
                return true;
            }
            return super.shouldOverrideUrlLoading(view, url);
        }
    });
    setContentView(webView);
}
Also used : Bitmap(android.graphics.Bitmap) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Intent(android.content.Intent) WebView(com.github.pockethub.android.ui.WebView) Uri(android.net.Uri) WebViewClient(android.webkit.WebViewClient)

Example 15 with MaterialDialog

use of com.afollestad.materialdialogs.MaterialDialog in project PocketHub by pockethub.

the class RefDialogFragment 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) {
            RefDialogFragment.this.onClick(dialog, BUTTON_NEGATIVE);
        }
    });
    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<GitReference> choices = getChoices();
    int selected = arguments.getInt(ARG_SELECTED_CHOICE);
    RefListAdapter adapter = new RefListAdapter(inflater, choices.toArray(new GitReference[choices.size()]), selected);
    view.setAdapter(adapter);
    if (selected >= 0) {
        view.setSelection(selected);
    }
    dialogBuilder.customView(view, false);
    return dialogBuilder.build();
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) 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) GitReference(com.meisolsson.githubsdk.model.git.GitReference)

Aggregations

MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)80 View (android.view.View)49 DialogAction (com.afollestad.materialdialogs.DialogAction)44 NonNull (android.support.annotation.NonNull)32 TextView (android.widget.TextView)32 Intent (android.content.Intent)19 ImageView (android.widget.ImageView)19 RecyclerView (android.support.v7.widget.RecyclerView)17 File (java.io.File)17 MenuItem (android.view.MenuItem)14 PopupMenu (android.widget.PopupMenu)12 List (java.util.List)12 ListView (android.widget.ListView)11 Activity (android.app.Activity)9 Toast (android.widget.Toast)9 SuppressLint (android.annotation.SuppressLint)8 Context (android.content.Context)8 Bundle (android.os.Bundle)8 ArrayList (java.util.ArrayList)8 LayoutInflater (android.view.LayoutInflater)7