Moving some methods from various activities to the base interface

This allows creating some custom views in the absence of
activity context

Bug: 118758696
Change-Id: I23999290e972a2a8cbd725a521a4e0c7c2e5023e
This commit is contained in:
Sunny Goyal committed 2018-11-19 13:04:35 -08:00
1 parent 3386fbf674
commit fe8e4a90be
6 files changed
+43 -27

No files matched your search

@@ -18,10 +18,15 @@ package com.android.launcher3.views;
import android.content.Context;
import android.content.ContextWrapper;
import android.view.ContextThemeWrapper;
import android.view.View.AccessibilityDelegate;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.badge.BadgeInfo;
/**
* An interface to be used along with a context. This allows a generic class to depend on Context
* subclass instead of an Activity.
* An interface to be used along with a context for various activities in Launcher. This allows a
* generic class to depend on Context subclass instead of an Activity.
*/
public interface ActivityContext {
@@ -29,8 +34,28 @@ public interface ActivityContext {
return false;
}
default BadgeInfo getBadgeInfoForItem(ItemInfo info) {
return null;
}
/**
* For items with tree hierarchy, notifies the activity to invalidate the parent when a root
* is invalidated
* @param info info associated with a root node.
*/
default void invalidateParent(ItemInfo info) { }
default AccessibilityDelegate getAccessibilityDelegate() {
return null;
}
/**
* The root view to support drag-and-drop and popup support.
*/
BaseDragLayer getDragLayer();
DeviceProfile getDeviceProfile();
static ActivityContext lookupContext(Context context) {
if (context instanceof ActivityContext) {
return (ActivityContext) context;