You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.5 KiB
69 lines
2.5 KiB
package kong.qingwei.opencv320;
|
|
|
|
import android.content.DialogInterface;
|
|
import android.content.Intent;
|
|
import android.net.Uri;
|
|
import android.support.v7.app.AlertDialog;
|
|
import android.support.v7.app.AppCompatActivity;
|
|
import android.os.Bundle;
|
|
import android.widget.Toast;
|
|
|
|
import com.kongqw.permissionslibrary.PermissionsManager;
|
|
|
|
public class BaseActivity extends AppCompatActivity {
|
|
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
}
|
|
|
|
/**
|
|
* 显示缺少权限的对话框
|
|
*/
|
|
protected void showPermissionDialog() {
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
builder.setTitle("请求权限");
|
|
builder.setMessage("Android 6.0+ 动态请求相机权限");
|
|
builder.setPositiveButton("去设置权限", new DialogInterface.OnClickListener() {
|
|
@Override
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
dialog.dismiss();
|
|
PermissionsManager.startAppSettings(getApplicationContext());
|
|
}
|
|
});
|
|
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
|
@Override
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
dialog.dismiss();
|
|
}
|
|
});
|
|
builder.create().show();
|
|
}
|
|
|
|
/**
|
|
* 显示没有安装OpenCV Manager的对话框
|
|
*/
|
|
protected void showInstallDialog() {
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
builder.setCancelable(false);
|
|
builder.setTitle("您还没有安装OpenCV Manager");
|
|
builder.setMessage("是否下载安装?");
|
|
builder.setPositiveButton("去下载", new DialogInterface.OnClickListener() {
|
|
@Override
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
Toast.makeText(getApplicationContext(), "去下载", Toast.LENGTH_SHORT).show();
|
|
dialog.dismiss();
|
|
startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse("https://github.com/kongqw/FaceDetectLibrary/tree/opencv3.2.0/OpenCVManager")));
|
|
}
|
|
});
|
|
builder.setNegativeButton("退出", new DialogInterface.OnClickListener() {
|
|
@Override
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
dialog.dismiss();
|
|
finish();
|
|
}
|
|
});
|
|
builder.create().show();
|
|
}
|
|
}
|