If you think the Android project encrypted-camera listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*
* Copyright (C) 2014 Andrew Reitz//fromwww.java2s.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/package com.andrewreitz.encryptedcamera.ui.dialog;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
/**
* Error Dialog for displaying error messages easily in the application
*/publicclass ErrorDialog extends DialogFragment implements DialogInterface.OnClickListener {
privatestaticfinal String TITLE = "error_dialog_title";
privatestaticfinal String MESSAGE = "error_dialog_message";
private String mTitle;
private String mMessage;
private ErrorDialogCallback mCallback;
/**
* Convience method for getting access to this dialog
*
* @param title the title to display
* @param message message to display
* @return newly created ErrorDialog
*/publicstatic ErrorDialog newInstance(@Nullable final String title, @Nullable final String message) {
final ErrorDialog errorDialog = new ErrorDialog();
Bundle args = new Bundle();
args.putString(TITLE, title);
args.putString(MESSAGE, message);
errorDialog.setArguments(args);
return errorDialog;
}
/**
* Set the callback when the error is dismissed If this is not passed in nothing happens when
* the ok button is pressed
*
* @param errorDialogCallback callback to set
*/publicvoid setCallback(ErrorDialogCallback errorDialogCallback) {
mCallback = errorDialogCallback;
}
@Override
publicvoid onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Bundle args = getArguments();
//noinspection ConstantConditions
mTitle = args.getString(TITLE);
mMessage = args.getString(MESSAGE);
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Context context = getActivity();
@SuppressWarnings("ConstantConditions")
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
if (!TextUtils.isEmpty(mTitle)) {
builder.setTitle(mTitle);
}
if (!TextUtils.isEmpty(mMessage)) {
builder.setMessage(mMessage);
}
builder.setPositiveButton(context.getString(android.R.string.ok), this);
final Dialog dialog = builder.create();
dialog.setCanceledOnTouchOutside(false);
return dialog;
}
@Override
publicvoid onClick(DialogInterface dialogInterface, int i) {
if (mCallback != null) {
mCallback.onErrorDialogDismissed();
}
}
publicinterface ErrorDialogCallback {
publicvoid onErrorDialogDismissed();
}
}