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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 ListView listView = (ListView) baseLayout.findViewById(R.id.selectable_i
tems); | 112 ListView listView = (ListView) baseLayout.findViewById(R.id.selectable_i
tems); |
113 | 113 |
114 if (title == R.string.contextmenu_image_title) { | 114 if (title == R.string.contextmenu_image_title) { |
115 displayImageHeader(baseLayout, params, activity.getResources()); | 115 displayImageHeader(baseLayout, params, activity.getResources()); |
116 } else { | 116 } else { |
117 displayHeaderIfVisibleItems(params, baseLayout); | 117 displayHeaderIfVisibleItems(params, baseLayout); |
118 } | 118 } |
119 | 119 |
120 // Set the list adapter and get the height to display it appropriately i
n a dialog. | 120 // Set the list adapter and get the height to display it appropriately i
n a dialog. |
121 TabularContextMenuListAdapter listAdapter = | 121 TabularContextMenuListAdapter listAdapter = |
122 new TabularContextMenuListAdapter(items, activity); | 122 new TabularContextMenuListAdapter(items, activity, mContextMenuH
elper); |
123 ViewGroup.LayoutParams layoutParams = listView.getLayoutParams(); | 123 ViewGroup.LayoutParams layoutParams = listView.getLayoutParams(); |
124 layoutParams.height = measureApproximateListViewHeight(listView, listAda
pter, maxCount); | 124 layoutParams.height = measureApproximateListViewHeight(listView, listAda
pter, maxCount); |
125 listView.setLayoutParams(layoutParams); | 125 listView.setLayoutParams(layoutParams); |
126 listView.setAdapter(listAdapter); | 126 listView.setAdapter(listAdapter); |
127 listView.setOnItemClickListener(this); | 127 listView.setOnItemClickListener(this); |
128 | 128 |
129 return baseLayout; | 129 return baseLayout; |
130 } | 130 } |
131 | 131 |
132 private void displayHeaderIfVisibleItems(ContextMenuParams params, ViewGroup
baseLayout) { | 132 private void displayHeaderIfVisibleItems(ContextMenuParams params, ViewGroup
baseLayout) { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 236 |
237 return view; | 237 return view; |
238 } | 238 } |
239 | 239 |
240 @Override | 240 @Override |
241 public void onItemClick(AdapterView<?> adapterView, View view, int position,
long id) { | 241 public void onItemClick(AdapterView<?> adapterView, View view, int position,
long id) { |
242 mDialog.dismiss(); | 242 mDialog.dismiss(); |
243 mCallback.onResult((int) id); | 243 mCallback.onResult((int) id); |
244 } | 244 } |
245 } | 245 } |
OLD | NEW |