use of com.afollestad.materialdialogs.DialogAction 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);
}
}
use of com.afollestad.materialdialogs.DialogAction 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();
}
use of com.afollestad.materialdialogs.DialogAction 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();
}
use of com.afollestad.materialdialogs.DialogAction 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();
}
use of com.afollestad.materialdialogs.DialogAction in project PocketHub by pockethub.
the class LabelsDialogFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
Bundle arguments = getArguments();
Activity activity = getActivity();
ArrayList<Label> choices = getChoices();
boolean[] selectedChoices = arguments.getBooleanArray(ARG_SELECTED_CHOICES);
List<String> selected = new ArrayList<>();
if (selectedChoices != null) {
for (int i = 0; i < choices.size(); i++) {
if (selectedChoices[i]) {
selected.add(choices.get(i).name());
}
}
}
arguments.putStringArrayList(ARG_SELECTED, (ArrayList<String>) selected);
LayoutInflater inflater = activity.getLayoutInflater();
ListView view = (ListView) inflater.inflate(R.layout.dialog_list_view, null);
LabelListAdapter adapter = new LabelListAdapter(inflater, choices.toArray(new Label[choices.size()]), selectedChoices);
view.setAdapter(adapter);
view.setOnItemClickListener(adapter);
return new MaterialDialog.Builder(activity).cancelable(true).cancelListener(this).negativeText(R.string.cancel).onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
LabelsDialogFragment.this.onClick(dialog, BUTTON_NEGATIVE);
}
}).neutralText(R.string.clear).onNeutral(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
LabelsDialogFragment.this.onClick(dialog, BUTTON_NEUTRAL);
}
}).positiveText(R.string.apply).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
LabelsDialogFragment.this.onClick(dialog, BUTTON_POSITIVE);
}
}).title(getTitle()).content(getMessage()).customView(view, false).build();
}
Aggregations