1 /* 2 * Copyright (C) 2022 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.secondarydisplay; 17 18 import static com.android.launcher3.util.OnboardingPrefs.ALL_APPS_VISITED_COUNT; 19 20 import android.content.Context; 21 22 import com.android.launcher3.appprediction.AppsDividerView; 23 import com.android.launcher3.appprediction.PredictionRowView; 24 import com.android.launcher3.model.BgDataModel; 25 import com.android.launcher3.views.ActivityContext; 26 27 /** 28 * Implementation of SecondaryDisplayPredictions. 29 */ 30 @SuppressWarnings("unused") 31 public final class SecondaryDisplayPredictionsImpl extends SecondaryDisplayPredictions { 32 33 private final ActivityContext mActivityContext; 34 private final Context mContext; 35 SecondaryDisplayPredictionsImpl(Context context)36 public SecondaryDisplayPredictionsImpl(Context context) { 37 mContext = context; 38 mActivityContext = ActivityContext.lookupContext(context); 39 } 40 41 @Override updateAppDivider()42 void updateAppDivider() { 43 mActivityContext.getAppsView().getFloatingHeaderView() 44 .findFixedRowByType(AppsDividerView.class) 45 .setShowAllAppsLabel(!ALL_APPS_VISITED_COUNT.hasReachedMax(mContext)); 46 ALL_APPS_VISITED_COUNT.increment(mContext); 47 } 48 49 @Override setPredictedApps(BgDataModel.FixedContainerItems item)50 public void setPredictedApps(BgDataModel.FixedContainerItems item) { 51 mActivityContext.getAppsView().getFloatingHeaderView() 52 .findFixedRowByType(PredictionRowView.class) 53 .setPredictedApps(item.items); 54 } 55 } 56