1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.nn.benchmark.app; 18 19 import android.app.AlertDialog; 20 import android.app.DialogFragment; 21 import android.app.Dialog; 22 import android.content.DialogInterface; 23 import android.os.Bundle; 24 25 public class NNSettings extends DialogFragment { 26 private boolean[] mEnables; 27 public boolean mOk = false; 28 NNSettings(boolean[] enables)29 public NNSettings(boolean[] enables) { 30 mEnables = enables; 31 } 32 33 @Override onCreateDialog(Bundle savedInstanceState)34 public Dialog onCreateDialog(Bundle savedInstanceState) { 35 AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 36 builder.setTitle(R.string.settings); 37 38 // Specify the list array, the items to be selected by default (null for none), 39 // and the listener through which to receive callbacks when items are selected 40 builder.setMultiChoiceItems(R.array.settings_array, mEnables, 41 new DialogInterface.OnMultiChoiceClickListener() { 42 @Override 43 public void onClick(DialogInterface dialog, int which, boolean isChecked) { 44 mEnables[which] = isChecked; 45 } 46 }); 47 48 // Set the action buttons 49 builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { 50 @Override 51 public void onClick(DialogInterface dialog, int id) { 52 mOk = true; 53 } 54 }); 55 builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { 56 @Override 57 public void onClick(DialogInterface dialog, int id) { 58 } 59 }); 60 61 return builder.create(); 62 } 63 } 64