1 /* 2 * Copyright (C) 2019 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.internal.app; 18 19 import android.content.Context; 20 import android.content.Intent; 21 import android.content.pm.ResolveInfo; 22 23 import androidx.test.espresso.idling.CountingIdlingResource; 24 25 import com.android.internal.app.chooser.DisplayResolveInfo; 26 27 import java.util.List; 28 29 public class ResolverWrapperAdapter extends ResolverListAdapter { 30 31 private CountingIdlingResource mLabelIdlingResource = 32 new CountingIdlingResource("LoadLabelTask"); 33 ResolverWrapperAdapter(Context context, List<Intent> payloadIntents, Intent[] initialIntents, List<ResolveInfo> rList, boolean filterLastUsed, ResolverListController resolverListController, ResolverListCommunicator resolverListCommunicator)34 public ResolverWrapperAdapter(Context context, 35 List<Intent> payloadIntents, 36 Intent[] initialIntents, 37 List<ResolveInfo> rList, boolean filterLastUsed, 38 ResolverListController resolverListController, 39 ResolverListCommunicator resolverListCommunicator) { 40 super(context, payloadIntents, initialIntents, rList, filterLastUsed, 41 resolverListController, resolverListCommunicator, false); 42 } 43 getLabelIdlingResource()44 public CountingIdlingResource getLabelIdlingResource() { 45 return mLabelIdlingResource; 46 } 47 48 @Override getLoadLabelTask(DisplayResolveInfo info, ViewHolder holder)49 protected LoadLabelTask getLoadLabelTask(DisplayResolveInfo info, ViewHolder holder) { 50 return new LoadLabelWrapperTask(info, holder); 51 } 52 53 class LoadLabelWrapperTask extends LoadLabelTask { 54 LoadLabelWrapperTask(DisplayResolveInfo dri, ViewHolder holder)55 protected LoadLabelWrapperTask(DisplayResolveInfo dri, ViewHolder holder) { 56 super(dri, holder); 57 } 58 59 @Override onPreExecute()60 protected void onPreExecute() { 61 mLabelIdlingResource.increment(); 62 } 63 64 @Override onPostExecute(CharSequence[] result)65 protected void onPostExecute(CharSequence[] result) { 66 super.onPostExecute(result); 67 mLabelIdlingResource.decrement(); 68 } 69 } 70 } 71