OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.contextmenu; | 5 package org.chromium.chrome.browser.contextmenu; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.app.Dialog; | 8 import android.app.Dialog; |
9 import android.content.DialogInterface; | 9 import android.content.DialogInterface; |
10 import android.content.res.Resources; | 10 import android.content.res.Resources; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 displayHeaderIfVisibleItems(params, baseLayout); | 153 displayHeaderIfVisibleItems(params, baseLayout); |
154 if (isImage) { | 154 if (isImage) { |
155 // #displayHeaderIfVisibleItems() sets these two views to GONE if th
e header text is | 155 // #displayHeaderIfVisibleItems() sets these two views to GONE if th
e header text is |
156 // empty but they should still be visible because we have an image t
o display. | 156 // empty but they should still be visible because we have an image t
o display. |
157 baseLayout.findViewById(R.id.context_header_layout).setVisibility(Vi
ew.VISIBLE); | 157 baseLayout.findViewById(R.id.context_header_layout).setVisibility(Vi
ew.VISIBLE); |
158 baseLayout.findViewById(R.id.context_divider).setVisibility(View.VIS
IBLE); | 158 baseLayout.findViewById(R.id.context_divider).setVisibility(View.VIS
IBLE); |
159 displayImageHeader(baseLayout, params, activity.getResources()); | 159 displayImageHeader(baseLayout, params, activity.getResources()); |
160 } | 160 } |
161 | 161 |
162 // Set the list adapter and get the height to display it appropriately i
n a dialog. | 162 // Set the list adapter and get the height to display it appropriately i
n a dialog. |
| 163 Runnable onDirectShare = new Runnable() { |
| 164 @Override |
| 165 public void run() { |
| 166 mOnShareItemClicked.run(); |
| 167 mDialog.dismiss(); |
| 168 } |
| 169 }; |
163 TabularContextMenuListAdapter listAdapter = | 170 TabularContextMenuListAdapter listAdapter = |
164 new TabularContextMenuListAdapter(items, activity, mOnShareItemC
licked); | 171 new TabularContextMenuListAdapter(items, activity, onDirectShare
); |
165 ViewGroup.LayoutParams layoutParams = listView.getLayoutParams(); | 172 ViewGroup.LayoutParams layoutParams = listView.getLayoutParams(); |
166 layoutParams.height = measureApproximateListViewHeight(listView, listAda
pter, maxCount); | 173 layoutParams.height = measureApproximateListViewHeight(listView, listAda
pter, maxCount); |
167 listView.setLayoutParams(layoutParams); | 174 listView.setLayoutParams(layoutParams); |
168 listView.setAdapter(listAdapter); | 175 listView.setAdapter(listAdapter); |
169 listView.setOnItemClickListener(this); | 176 listView.setOnItemClickListener(this); |
170 | 177 |
171 return baseLayout; | 178 return baseLayout; |
172 } | 179 } |
173 | 180 |
174 private void displayHeaderIfVisibleItems(ContextMenuParams params, ViewGroup
baseLayout) { | 181 private void displayHeaderIfVisibleItems(ContextMenuParams params, ViewGroup
baseLayout) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 mHeaderImageView.setImageBitmap(bitmap); | 263 mHeaderImageView.setImageBitmap(bitmap); |
257 } | 264 } |
258 } | 265 } |
259 | 266 |
260 @Override | 267 @Override |
261 public void onItemClick(AdapterView<?> adapterView, View view, int position,
long id) { | 268 public void onItemClick(AdapterView<?> adapterView, View view, int position,
long id) { |
262 mDialog.dismiss(); | 269 mDialog.dismiss(); |
263 mCallback.onResult((int) id); | 270 mCallback.onResult((int) id); |
264 } | 271 } |
265 } | 272 } |
OLD | NEW |