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 package com.android.settings.nfc; 17 18 import android.content.Context; 19 import android.content.DialogInterface; 20 import android.util.AttributeSet; 21 22 import androidx.appcompat.app.AlertDialog.Builder; 23 import androidx.preference.PreferenceViewHolder; 24 25 import com.android.settingslib.CustomDialogPreferenceCompat; 26 27 public class NfcPaymentPreference extends CustomDialogPreferenceCompat { 28 29 private Listener mListener; 30 31 interface Listener { onBindViewHolder(PreferenceViewHolder view)32 void onBindViewHolder(PreferenceViewHolder view); 33 onPrepareDialogBuilder(Builder builder, DialogInterface.OnClickListener listener)34 void onPrepareDialogBuilder(Builder builder, 35 DialogInterface.OnClickListener listener); 36 } 37 NfcPaymentPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)38 public NfcPaymentPreference(Context context, AttributeSet attrs, int defStyleAttr, 39 int defStyleRes) { 40 super(context, attrs, defStyleAttr, defStyleRes); 41 } 42 NfcPaymentPreference(Context context, AttributeSet attrs, int defStyleAttr)43 public NfcPaymentPreference(Context context, AttributeSet attrs, int defStyleAttr) { 44 super(context, attrs, defStyleAttr); 45 } 46 NfcPaymentPreference(Context context, AttributeSet attrs)47 public NfcPaymentPreference(Context context, AttributeSet attrs) { 48 super(context, attrs); 49 } 50 initialize(Listener listener)51 void initialize(Listener listener) { 52 mListener = listener; 53 } 54 55 @Override onBindViewHolder(PreferenceViewHolder view)56 public void onBindViewHolder(PreferenceViewHolder view) { 57 super.onBindViewHolder(view); 58 59 if (mListener != null) { 60 mListener.onBindViewHolder(view); 61 } 62 } 63 64 @Override onPrepareDialogBuilder(Builder builder, DialogInterface.OnClickListener listener)65 protected void onPrepareDialogBuilder(Builder builder, 66 DialogInterface.OnClickListener listener) { 67 super.onPrepareDialogBuilder(builder, listener); 68 69 if (mListener != null) { 70 mListener.onPrepareDialogBuilder(builder, listener); 71 } 72 } 73 } 74