Commit 174d25a6 authored by ltian's avatar ltian Committed by Commit bot

[Android] Fix direct share in context menu does not close dialog when clicked

After the direct share icon is clicked, the dialog of context menu
does not dissmiss. This is because onClick event of the direct share
icon does not call dialog to dismiss. To fix the problem, add an
delegate interface for direct share action and implement it in the
TabularContextMenuUi.

BUG=None

Review-Url: https://codereview.chromium.org/2853483003
Cr-Commit-Position: refs/heads/master@{#468454}
parent 65003efd
......@@ -26,7 +26,7 @@ import java.util.List;
class TabularContextMenuListAdapter extends BaseAdapter {
private final List<ContextMenuItem> mMenuItems;
private final Activity mActivity;
private final Runnable mOnShareItemClicked;
private final Runnable mOnDirectShare;
/**
* Adapter for the tabular context menu UI
......@@ -34,10 +34,10 @@ class TabularContextMenuListAdapter extends BaseAdapter {
* @param activity Used to inflate the layout.
*/
TabularContextMenuListAdapter(
List<ContextMenuItem> menuItems, Activity activity, Runnable onShareItemClicked) {
List<ContextMenuItem> menuItems, Activity activity, Runnable onDirectShare) {
mMenuItems = menuItems;
mActivity = activity;
mOnShareItemClicked = onShareItemClicked;
mOnDirectShare = onDirectShare;
}
@Override
......@@ -91,7 +91,7 @@ class TabularContextMenuListAdapter extends BaseAdapter {
viewHolder.mShareIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mOnShareItemClicked.run();
mOnDirectShare.run();
}
});
}
......
......@@ -160,8 +160,15 @@ public class TabularContextMenuUi implements ContextMenuUi, AdapterView.OnItemCl
}
// Set the list adapter and get the height to display it appropriately in a dialog.
Runnable onDirectShare = new Runnable() {
@Override
public void run() {
mOnShareItemClicked.run();
mDialog.dismiss();
}
};
TabularContextMenuListAdapter listAdapter =
new TabularContextMenuListAdapter(items, activity, mOnShareItemClicked);
new TabularContextMenuListAdapter(items, activity, onDirectShare);
ViewGroup.LayoutParams layoutParams = listView.getLayoutParams();
layoutParams.height = measureApproximateListViewHeight(listView, listAdapter, maxCount);
listView.setLayoutParams(layoutParams);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment