本文整理汇总了Java中com.android.launcher3.util.ComponentKey类的典型用法代码示例。如果您正苦于以下问题:Java ComponentKey类的具体用法?Java ComponentKey怎么用?Java ComponentKey使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ComponentKey类属于com.android.launcher3.util包,在下文中一共展示了ComponentKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createLauncherEvent
import com.android.launcher3.util.ComponentKey; //导入依赖的package包/类
protected LauncherEvent createLauncherEvent(View v, Intent intent) {
LauncherEvent event = LoggerUtils.initLauncherEvent(
Action.TOUCH, v, Target.CONTAINER);
event.action.touch = Action.TAP;
// Fill in grid(x,y), pageIndex of the child and container type of the parent
// TODO: make this percolate up the view hierarchy if needed.
int idx = 0;
LaunchSourceProvider provider = getLaunchProviderRecursive(v);
if (v == null || !(v.getTag() instanceof ItemInfo) || provider == null) {
return null;
}
ItemInfo itemInfo = (ItemInfo) v.getTag();
provider.fillInLaunchSourceData(v, itemInfo, event.srcTarget[idx], event.srcTarget[idx + 1]);
event.srcTarget[idx].intentHash = intent.hashCode();
ComponentName cn = intent.getComponent();
if (cn != null) {
event.srcTarget[idx].packageNameHash = cn.getPackageName().hashCode();
event.srcTarget[idx].componentHash = cn.hashCode();
if (mPredictedApps != null) {
event.srcTarget[idx].predictedRank = mPredictedApps.indexOf(
new ComponentKey(cn, itemInfo.user));
}
}
return event;
}
示例2: updateCacheAndGetContentValues
import com.android.launcher3.util.ComponentKey; //导入依赖的package包/类
@Thunk ContentValues updateCacheAndGetContentValues(LauncherActivityInfoCompat app,
boolean replaceExisting) {
final ComponentKey key = new ComponentKey(app.getComponentName(), app.getUser());
CacheEntry entry = null;
if (!replaceExisting) {
entry = mCache.get(key);
// We can't reuse the entry if the high-res icon is not present.
if (entry == null || entry.isLowResIcon || entry.icon == null) {
entry = null;
}
}
if (entry == null) {
entry = new CacheEntry();
entry.icon = Utilities.createBadgedIconBitmap(
mIconProvider.getIcon(app, mIconDpi), app.getUser(),
mContext);
}
entry.title = app.getLabel();
entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, app.getUser());
mCache.put(new ComponentKey(app.getComponentName(), app.getUser()), entry);
Bitmap lowResIcon = generateLowResIcon(entry.icon, mActivityBgColor);
return newContentValues(entry.icon, lowResIcon, entry.title.toString(),
app.getApplicationInfo().packageName);
}
示例3: cachePackageInstallInfo
import com.android.launcher3.util.ComponentKey; //导入依赖的package包/类
/**
* Adds a default package entry in the cache. This entry is not persisted and will be removed
* when the cache is flushed.
*/
public synchronized void cachePackageInstallInfo(String packageName, UserHandleCompat user,
Bitmap icon, CharSequence title) {
removeFromMemCacheLocked(packageName, user);
ComponentKey cacheKey = getPackageKey(packageName, user);
CacheEntry entry = mCache.get(cacheKey);
// For icon caching, do not go through DB. Just update the in-memory entry.
if (entry == null) {
entry = new CacheEntry();
mCache.put(cacheKey, entry);
}
if (!TextUtils.isEmpty(title)) {
entry.title = title;
}
if (icon != null) {
entry.icon = Utilities.createIconBitmap(icon, mContext);
}
}
示例4: updateDeepShortcutMap
import com.android.launcher3.util.ComponentKey; //导入依赖的package包/类
/**
* Clear all the shortcuts for the given package, and re-add the new shortcuts.
*/
private void updateDeepShortcutMap(
String packageName, UserHandleCompat user, List<ShortcutInfoCompat> shortcuts) {
if (packageName != null) {
Iterator<ComponentKey> keysIter = mBgDeepShortcutMap.keySet().iterator();
while (keysIter.hasNext()) {
ComponentKey next = keysIter.next();
if (next.componentName.getPackageName().equals(packageName)
&& next.user.equals(user)) {
keysIter.remove();
}
}
}
// Now add the new shortcuts to the map.
for (ShortcutInfoCompat shortcut : shortcuts) {
boolean shouldShowInContainer = shortcut.isEnabled()
&& (shortcut.isDeclaredInManifest() || shortcut.isDynamic());
if (shouldShowInContainer) {
ComponentKey targetComponent
= new ComponentKey(shortcut.getActivity(), shortcut.getUserHandle());
mBgDeepShortcutMap.addToList(targetComponent, shortcut.getId());
}
}
}
示例5: updateCacheAndGetContentValues
import com.android.launcher3.util.ComponentKey; //导入依赖的package包/类
@Thunk ContentValues updateCacheAndGetContentValues(LauncherActivityInfoCompat app,
boolean replaceExisting) {
final ComponentKey key = new ComponentKey(app.getComponentName(), app.getUser());
CacheEntry entry = null;
if (!replaceExisting) {
entry = mCache.get(key);
// We can't reuse the entry if the high-res icon is not present.
if (entry == null || entry.isLowResIcon || entry.icon == null) {
entry = null;
}
}
if (entry == null) {
entry = new CacheEntry();
entry.icon = Utilities.createIconBitmap(app.getBadgedIcon(mIconDpi), mContext);
}
entry.title = app.getLabel();
entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, app.getUser());
mCache.put(new ComponentKey(app.getComponentName(), app.getUser()), entry);
return newContentValues(entry.icon, entry.title.toString(), mActivityBgColor);
}
示例6: tryAndUpdatePredictedApps
import com.android.launcher3.util.ComponentKey; //导入依赖的package包/类
/**
* Updates the set of predicted apps if it hasn't been updated since the last time Launcher was
* resumed.
*/
public void tryAndUpdatePredictedApps() {
List<ComponentKey> apps;
if (mLauncherCallbacks != null) {
apps = mLauncherCallbacks.getPredictedApps();
} else {
apps = predictiveAppsProvider.getPredictions();
predictiveAppsProvider.updateTopPredictedApps();
}
if (apps != null) {
mAppsView.setPredictedApps(apps);
}
}
示例7: getShortcutIdsForItem
import com.android.launcher3.util.ComponentKey; //导入依赖的package包/类
public List<String> getShortcutIdsForItem(ItemInfo info) {
if (!DeepShortcutManager.supportsShortcuts(info)) {
return Collections.EMPTY_LIST;
}
ComponentName component = info.getTargetComponent();
if (component == null) {
return Collections.EMPTY_LIST;
}
List<String> ids = mDeepShortcutMap.get(new ComponentKey(component, info.user));
return ids == null ? Collections.EMPTY_LIST : ids;
}
示例8: getAllProvidersMap
import com.android.launcher3.util.ComponentKey; //导入依赖的package包/类
@Override
public HashMap<ComponentKey, AppWidgetProviderInfo> getAllProvidersMap() {
HashMap<ComponentKey, AppWidgetProviderInfo> result = new HashMap<>();
UserHandleCompat user = UserHandleCompat.myUserHandle();
for (AppWidgetProviderInfo info : mAppWidgetManager.getInstalledProviders()) {
result.put(new ComponentKey(info.provider, user), info);
}
return result;
}
示例9: getAllProvidersMap
import com.android.launcher3.util.ComponentKey; //导入依赖的package包/类
@Override
public HashMap<ComponentKey, AppWidgetProviderInfo> getAllProvidersMap() {
HashMap<ComponentKey, AppWidgetProviderInfo> result = new HashMap<>();
for (UserHandle user : mUserManager.getUserProfiles()) {
UserHandleCompat userHandle = UserHandleCompat.fromUser(user);
for (AppWidgetProviderInfo info :
mAppWidgetManager.getInstalledProvidersForProfile(user)) {
result.put(new ComponentKey(info.provider, userHandle), info);
}
}
return result;
}
示例10: doSearch
import com.android.launcher3.util.ComponentKey; //导入依赖的package包/类
public void doSearch(final String query,
final AllAppsSearchBarController.Callbacks callback) {
final ArrayList<ComponentKey> result = getTitleMatchResult(query);
mResultHandler.post(new Runnable() {
@Override
public void run() {
callback.onSearchResult(query, result);
}
});
}
示例11: getTitleMatchResult
import com.android.launcher3.util.ComponentKey; //导入依赖的package包/类
protected ArrayList<ComponentKey> getTitleMatchResult(String query) {
// Do an intersection of the words in the query and each title, and filter out all the
// apps that don't match all of the words in the query.
final String queryTextLower = query.toLowerCase();
final ArrayList<ComponentKey> result = new ArrayList<>();
for (AppInfo info : mApps) {
if (matches(info, queryTextLower)) {
result.add(info.toComponentKey());
}
}
return result;
}
示例12: getPredictions
import com.android.launcher3.util.ComponentKey; //导入依赖的package包/类
public List<ComponentKey> getPredictions() {
String predictions = sharedPreferences.getString(TOP_PREDICTIVE_APPS_KEY, "");
if (predictions.isEmpty()) {
return new ArrayList<>();
}
String[] topPredictions = predictions.split(" ");
List<ComponentKey> keys = new ArrayList<>();
for (int i = 0; i < topPredictions.length - 1; i++) {
keys.add(buildComponentKey(topPredictions[i] + " " + topPredictions[i + 1]));
}
return keys;
}
示例13: setOrderedFilter
import com.android.launcher3.util.ComponentKey; //导入依赖的package包/类
/**
* Sets the sorted list of filtered components.
*/
public boolean setOrderedFilter(ArrayList<ComponentKey> f) {
if (mSearchResults != f) {
boolean same = mSearchResults != null && mSearchResults.equals(f);
mSearchResults = f;
updateAdapterItems();
return !same;
}
return false;
}
示例14: getFiltersAppInfos
import com.android.launcher3.util.ComponentKey; //导入依赖的package包/类
private List<AppInfo> getFiltersAppInfos() {
if (mSearchResults == null) {
return mApps;
}
ArrayList<AppInfo> result = new ArrayList<>();
for (ComponentKey key : mSearchResults) {
AppInfo match = mComponentToAppMap.get(key);
if (match != null) {
result.add(match);
}
}
return result;
}
示例15: onSearchResult
import com.android.launcher3.util.ComponentKey; //导入依赖的package包/类
@Override
public void onSearchResult(String query, ArrayList<ComponentKey> apps) {
if (apps != null) {
if (mApps.setOrderedFilter(apps)) {
mAppsRecyclerView.onSearchResultsChanged();
}
mAdapter.setLastSearchQuery(query);
}
}