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.dialer.app.filterednumber;
17 
18 import android.app.FragmentManager;
19 import android.content.Context;
20 import android.database.Cursor;
21 import android.view.View;
22 import com.android.dialer.app.R;
23 import com.android.dialer.blocking.FilteredNumbersUtil;
24 import com.android.dialer.contactphoto.ContactPhotoManager;
25 import com.android.dialer.location.GeoUtil;
26 import com.android.dialer.phonenumbercache.ContactInfoHelper;
27 
28 /** TODO(calderwoodra): documentation */
29 public class ViewNumbersToImportAdapter extends NumbersAdapter {
30 
ViewNumbersToImportAdapter( Context context, FragmentManager fragmentManager, ContactInfoHelper contactInfoHelper, ContactPhotoManager contactPhotoManager)31   private ViewNumbersToImportAdapter(
32       Context context,
33       FragmentManager fragmentManager,
34       ContactInfoHelper contactInfoHelper,
35       ContactPhotoManager contactPhotoManager) {
36     super(context, fragmentManager, contactInfoHelper, contactPhotoManager);
37   }
38 
newViewNumbersToImportAdapter( Context context, FragmentManager fragmentManager)39   public static ViewNumbersToImportAdapter newViewNumbersToImportAdapter(
40       Context context, FragmentManager fragmentManager) {
41     return new ViewNumbersToImportAdapter(
42         context,
43         fragmentManager,
44         new ContactInfoHelper(context, GeoUtil.getCurrentCountryIso(context)),
45         ContactPhotoManager.getInstance(context));
46   }
47 
48   @Override
bindView(View view, Context context, Cursor cursor)49   public void bindView(View view, Context context, Cursor cursor) {
50     super.bindView(view, context, cursor);
51 
52     final String number = cursor.getString(FilteredNumbersUtil.PhoneQuery.NUMBER_COLUMN_INDEX);
53 
54     view.findViewById(R.id.delete_button).setVisibility(View.GONE);
55     updateView(view, number, null /* countryIso */);
56   }
57 }
58