• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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.launcher3.allapps.search;
17 
18 import android.view.LayoutInflater;
19 import android.view.View;
20 import android.view.ViewGroup;
21 
22 import com.android.launcher3.BubbleTextView;
23 import com.android.launcher3.allapps.AllAppsGridAdapter;
24 import com.android.launcher3.model.data.ItemInfo;
25 import com.android.launcher3.views.ActivityContext;
26 
27 /**
28  * Provides views for local search results.
29  */
30 public class DefaultSearchAdapterProvider extends SearchAdapterProvider<ActivityContext> {
31     private View mHighlightedView;
32 
DefaultSearchAdapterProvider(ActivityContext launcher)33     public DefaultSearchAdapterProvider(ActivityContext launcher) {
34         super(launcher);
35     }
36 
37     @Override
onBindView(AllAppsGridAdapter.ViewHolder holder, int position)38     public void onBindView(AllAppsGridAdapter.ViewHolder holder, int position) {
39         if (position == 0) {
40             mHighlightedView = holder.itemView;
41         }
42     }
43 
44     @Override
isViewSupported(int viewType)45     public boolean isViewSupported(int viewType) {
46         return false;
47     }
48 
49     @Override
onCreateViewHolder(LayoutInflater layoutInflater, ViewGroup parent, int viewType)50     public AllAppsGridAdapter.ViewHolder onCreateViewHolder(LayoutInflater layoutInflater,
51             ViewGroup parent, int viewType) {
52         return null;
53     }
54 
55     @Override
launchHighlightedItem()56     public boolean launchHighlightedItem() {
57         if (mHighlightedView instanceof BubbleTextView
58                 && mHighlightedView.getTag() instanceof ItemInfo) {
59             ItemInfo itemInfo = (ItemInfo) mHighlightedView.getTag();
60             return mLauncher.startActivitySafely(
61                     mHighlightedView, itemInfo.getIntent(), itemInfo) != null;
62         }
63         return false;
64     }
65 
66     @Override
getHighlightedItem()67     public View getHighlightedItem() {
68         return mHighlightedView;
69     }
70 
71     @Override
clearHighlightedItem()72     public void clearHighlightedItem() {
73         mHighlightedView = null;
74     }
75 }
76