diff options
author | John Reck <jreck@google.com> | 2011-05-18 17:12:33 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2011-05-18 17:12:33 -0700 |
commit | 66302e5f0622fce8f0250afcd722c5597ba76261 (patch) | |
tree | 7255fa772355970ace67c94891ae83005ff570fa /src/com/android/browser/view | |
parent | 31faddc3fa92d51a642249d86df7f769178f7e92 (diff) | |
download | packages_apps_browser-66302e5f0622fce8f0250afcd722c5597ba76261.zip packages_apps_browser-66302e5f0622fce8f0250afcd722c5597ba76261.tar.gz packages_apps_browser-66302e5f0622fce8f0250afcd722c5597ba76261.tar.bz2 |
Initial bookmark drag & drop
Currently can only re-parent (drop into folders, between accounts)
Has no visual feedback yet either
Change-Id: If02c32a98a836c4567f274f1cb1654a25f469b0f
Diffstat (limited to 'src/com/android/browser/view')
-rw-r--r-- | src/com/android/browser/view/BookmarkExpandableGridView.java | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/src/com/android/browser/view/BookmarkExpandableGridView.java b/src/com/android/browser/view/BookmarkExpandableGridView.java index 1d603cc..0c8f669 100644 --- a/src/com/android/browser/view/BookmarkExpandableGridView.java +++ b/src/com/android/browser/view/BookmarkExpandableGridView.java @@ -16,12 +16,15 @@ package com.android.browser.view; +import com.android.browser.BookmarkDragHandler; import com.android.browser.BreadCrumbView; import com.android.browser.BrowserBookmarksAdapter; import com.android.browser.R; +import com.android.browser.BookmarkDragHandler.BookmarkDragAdapter; import com.android.internal.view.menu.MenuBuilder; import android.content.Context; +import android.database.Cursor; import android.database.DataSetObserver; import android.provider.BrowserContract; import android.util.AttributeSet; @@ -51,6 +54,7 @@ public class BookmarkExpandableGridView extends ExpandableListView private OnCreateContextMenuListener mOnCreateContextMenuListener; private boolean mLongClickable; private BreadCrumbView.Controller mBreadcrumbController; + private BookmarkDragHandler mDragHandler; public BookmarkExpandableGridView(Context context) { super(context); @@ -169,8 +173,8 @@ public class BookmarkExpandableGridView extends ExpandableListView int groupPosition = (Integer) originalView.getTag(R.id.group_position); int childPosition = (Integer) originalView.getTag(R.id.child_position); - mContextMenuInfo = new BookmarkContextMenuInfo(originalView, - childPosition, groupPosition); + mContextMenuInfo = new BookmarkContextMenuInfo(childPosition, + groupPosition); if (getParent() != null) { getParent().showContextMenuForChild(this); } @@ -198,6 +202,25 @@ public class BookmarkExpandableGridView extends ExpandableListView return mAdapter.mChildren.get(groupPosition); } + public BookmarkDragAdapter getDragAdapter() { + return mDragAdapter; + } + + private BookmarkDragAdapter mDragAdapter = new BookmarkDragAdapter() { + + @Override + public void setBookmarkDragHandler(BookmarkDragHandler handler) { + mDragHandler = handler; + } + + @Override + public Cursor getItemForView(View v) { + int groupPosition = (Integer) v.getTag(R.id.group_position); + int childPosition = (Integer) v.getTag(R.id.child_position); + return getChildAdapter(groupPosition).getItem(childPosition); + } + }; + private OnClickListener mChildClickListener = new OnClickListener() { @Override @@ -225,6 +248,18 @@ public class BookmarkExpandableGridView extends ExpandableListView } }; + private OnLongClickListener mChildOnLongClickListener = new OnLongClickListener() { + + @Override + public boolean onLongClick(View v) { + int groupPosition = (Integer) v.getTag(R.id.group_position); + int childPosition = (Integer) v.getTag(R.id.child_position); + long id = (Long) v.getTag(R.id.child_id); + Cursor c = getChildAdapter(groupPosition).getItem(childPosition); + return mDragHandler.startDrag(v, c, id); + } + }; + public BreadCrumbView getBreadCrumbs(int groupPosition) { return mAdapter.getBreadCrumbView(groupPosition); } @@ -302,6 +337,10 @@ public class BookmarkExpandableGridView extends ExpandableListView v.setTag(R.id.child_id, childAdapter.getItemId(realChildPosition)); v.setOnClickListener(mChildClickListener); v.setLongClickable(mLongClickable); + if (mDragHandler != null) { + v.setOnLongClickListener(mChildOnLongClickListener); + mDragHandler.registerBookmarkDragHandler(v); + } if (cv == null) { row.addView(v); } else if (cv != v) { @@ -409,14 +448,11 @@ public class BookmarkExpandableGridView extends ExpandableListView public static class BookmarkContextMenuInfo implements ContextMenuInfo { - private BookmarkContextMenuInfo(View targetView, int childPosition, - int groupPosition) { - this.targetView = targetView; + private BookmarkContextMenuInfo(int childPosition, int groupPosition) { this.childPosition = childPosition; this.groupPosition = groupPosition; } - public View targetView; public int childPosition; public int groupPosition; } |