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.wifi;
17 
18 import android.content.Context;
19 
20 import androidx.fragment.app.Fragment;
21 import androidx.preference.PreferenceViewHolder;
22 
23 import com.android.settingslib.wifi.AccessPoint;
24 import com.android.settingslib.wifi.AccessPointPreference;
25 
26 public class LongPressAccessPointPreference extends AccessPointPreference {
27 
28     private final Fragment mFragment;
29 
LongPressAccessPointPreference(AccessPoint accessPoint, Context context, UserBadgeCache cache, boolean forSavedNetworks, int iconResId, Fragment fragment)30     public LongPressAccessPointPreference(AccessPoint accessPoint, Context context,
31             UserBadgeCache cache, boolean forSavedNetworks, int iconResId, Fragment fragment) {
32         super(accessPoint, context, cache, iconResId, forSavedNetworks);
33         mFragment = fragment;
34     }
35 
36     @Override
onBindViewHolder(final PreferenceViewHolder view)37     public void onBindViewHolder(final PreferenceViewHolder view) {
38         super.onBindViewHolder(view);
39         if (mFragment != null) {
40             view.itemView.setOnCreateContextMenuListener(mFragment);
41             view.itemView.setTag(this);
42             view.itemView.setLongClickable(true);
43         }
44     }
45 }
46