summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/widget
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/widget')
-rw-r--r--src/com/android/launcher3/widget/WidgetHostViewLoader.java27
-rw-r--r--src/com/android/launcher3/widget/WidgetsContainerView.java15
2 files changed, 33 insertions, 9 deletions
diff --git a/src/com/android/launcher3/widget/WidgetHostViewLoader.java b/src/com/android/launcher3/widget/WidgetHostViewLoader.java
index 461aebb6b..5d3af5254 100644
--- a/src/com/android/launcher3/widget/WidgetHostViewLoader.java
+++ b/src/com/android/launcher3/widget/WidgetHostViewLoader.java
@@ -4,13 +4,13 @@ import android.appwidget.AppWidgetHostView;
import android.appwidget.AppWidgetManager;
import android.content.Context;
import android.graphics.Rect;
-import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
+import android.util.Log;
import android.view.View;
import com.android.launcher3.AppWidgetResizeFrame;
-import com.android.launcher3.DragController.DragListener;
+import com.android.launcher3.DragController;
import com.android.launcher3.DragLayer;
import com.android.launcher3.DragSource;
import com.android.launcher3.Launcher;
@@ -19,7 +19,9 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.compat.AppWidgetManagerCompat;
import com.android.launcher3.util.Thunk;
-public class WidgetHostViewLoader implements DragListener {
+public class WidgetHostViewLoader implements DragController.DragListener {
+ private static final String TAG = "WidgetHostViewLoader";
+ private static final boolean LOGD = false;
/* Runnables to handle inflation and binding. */
@Thunk Runnable mInflateWidgetRunnable = null;
@@ -48,6 +50,10 @@ public class WidgetHostViewLoader implements DragListener {
@Override
public void onDragEnd() {
+ if (LOGD) {
+ Log.d(TAG, "Cleaning up in onDragEnd()...");
+ }
+
// Cleanup up preloading state.
mLauncher.getDragController().removeDragListener(this);
@@ -62,6 +68,9 @@ public class WidgetHostViewLoader implements DragListener {
// The widget was inflated and added to the DragLayer -- remove it.
if (mInfo.boundWidget != null) {
+ if (LOGD) {
+ Log.d(TAG, "...removing widget from drag layer");
+ }
mLauncher.getDragLayer().removeView(mInfo.boundWidget);
mLauncher.getAppWidgetHost().deleteAppWidgetId(mInfo.boundWidget.getAppWidgetId());
mInfo.boundWidget = null;
@@ -89,6 +98,9 @@ public class WidgetHostViewLoader implements DragListener {
@Override
public void run() {
mWidgetLoadingId = mLauncher.getAppWidgetHost().allocateAppWidgetId();
+ if (LOGD) {
+ Log.d(TAG, "Binding widget, id: " + mWidgetLoadingId);
+ }
if(AppWidgetManagerCompat.getInstance(mLauncher).bindAppWidgetIdIfAllowed(
mWidgetLoadingId, pInfo, options)) {
@@ -101,6 +113,9 @@ public class WidgetHostViewLoader implements DragListener {
mInflateWidgetRunnable = new Runnable() {
@Override
public void run() {
+ if (LOGD) {
+ Log.d(TAG, "Inflating widget, id: " + mWidgetLoadingId);
+ }
if (mWidgetLoadingId == -1) {
return;
}
@@ -120,11 +135,17 @@ public class WidgetHostViewLoader implements DragListener {
lp.x = lp.y = 0;
lp.customPosition = true;
hostView.setLayoutParams(lp);
+ if (LOGD) {
+ Log.d(TAG, "Adding host view to drag layer");
+ }
mLauncher.getDragLayer().addView(hostView);
mView.setTag(mInfo);
}
};
+ if (LOGD) {
+ Log.d(TAG, "About to bind/inflate widget");
+ }
mHandler.post(mBindWidgetRunnable);
return true;
}
diff --git a/src/com/android/launcher3/widget/WidgetsContainerView.java b/src/com/android/launcher3/widget/WidgetsContainerView.java
index 64d33aa09..b780f590b 100644
--- a/src/com/android/launcher3/widget/WidgetsContainerView.java
+++ b/src/com/android/launcher3/widget/WidgetsContainerView.java
@@ -52,10 +52,9 @@ import com.android.launcher3.util.Thunk;
* The widgets list view container.
*/
public class WidgetsContainerView extends BaseContainerView
- implements View.OnLongClickListener, View.OnClickListener, DragSource{
-
+ implements View.OnLongClickListener, View.OnClickListener, DragSource {
private static final String TAG = "WidgetsContainerView";
- private static final boolean DEBUG = false;
+ private static final boolean LOGD = false;
/* Coefficient multiplied to the screen height for preloading widgets. */
private static final int PRELOAD_SCREEN_HEIGHT_MULTIPLE = 1;
@@ -92,13 +91,14 @@ public class WidgetsContainerView extends BaseContainerView
mDragController = mLauncher.getDragController();
mAdapter = new WidgetsListAdapter(context, this, this, mLauncher);
mIconCache = (LauncherAppState.getInstance()).getIconCache();
- if (DEBUG) {
+ if (LOGD) {
Log.d(TAG, "WidgetsContainerView constructor");
}
}
@Override
protected void onFinishInflate() {
+ super.onFinishInflate();
mContent = findViewById(R.id.content);
mView = (WidgetsRecyclerView) findViewById(R.id.widgets_list_view);
mView.setAdapter(mAdapter);
@@ -158,7 +158,7 @@ public class WidgetsContainerView extends BaseContainerView
@Override
public boolean onLongClick(View v) {
- if (DEBUG) {
+ if (LOGD) {
Log.d(TAG, String.format("onLonglick [v=%s]", v));
}
// Return early if this is not initiated from a touch
@@ -173,7 +173,7 @@ public class WidgetsContainerView extends BaseContainerView
if (status && v.getTag() instanceof PendingAddWidgetInfo) {
WidgetHostViewLoader hostLoader = new WidgetHostViewLoader(mLauncher, v);
boolean preloadStatus = hostLoader.preloadWidget();
- if (DEBUG) {
+ if (LOGD) {
Log.d(TAG, String.format("preloading widget [status=%s]", preloadStatus));
}
mLauncher.getDragController().addDragListener(hostLoader);
@@ -302,6 +302,9 @@ public class WidgetsContainerView extends BaseContainerView
@Override
public void onDropCompleted(View target, DragObject d, boolean isFlingToDelete,
boolean success) {
+ if (LOGD) {
+ Log.d(TAG, "onDropCompleted");
+ }
if (isFlingToDelete || !success || (target != mLauncher.getWorkspace() &&
!(target instanceof DeleteDropTarget) && !(target instanceof Folder))) {
// Exit spring loaded mode if we have not successfully dropped or have not handled the