Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(848)

Unified Diff: remoting/android/java/src/org/chromium/chromoting/NavigationMenuAdapter.java

Issue 1997793002: [Remoting Android] Put Icons and Credits on Navigation Menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer's Feedback Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/android/java/src/org/chromium/chromoting/Chromoting.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/android/java/src/org/chromium/chromoting/NavigationMenuAdapter.java
diff --git a/remoting/android/java/src/org/chromium/chromoting/NavigationMenuAdapter.java b/remoting/android/java/src/org/chromium/chromoting/NavigationMenuAdapter.java
new file mode 100644
index 0000000000000000000000000000000000000000..79961b1b9b83b2267ec3f7847c5b0c2379507da7
--- /dev/null
+++ b/remoting/android/java/src/org/chromium/chromoting/NavigationMenuAdapter.java
@@ -0,0 +1,54 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chromoting;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+
+/**
+ * Describes the appearance and behavior of the navigation menu. This also implements
+ * AdapterView.OnItemClickListener so it can be used as the ListView's onItemClickListener.
+ */
+public class NavigationMenuAdapter extends ArrayAdapter<NavigationMenuAdapter.NavigationMenuItem>
+ implements AdapterView.OnItemClickListener {
+ /**
+ * Defines a menu item.
+ */
+ public static class NavigationMenuItem {
+ private int mLayoutResourceId;
+ private Runnable mCallback;
+ public NavigationMenuItem(int layoutResourceId, Runnable callback) {
+ mLayoutResourceId = layoutResourceId;
+ mCallback = callback;
+ }
+ }
+
+ public NavigationMenuAdapter(Context context, NavigationMenuItem[] objects) {
+ super(context, -1, objects);
+ }
+
+ /** Generates a View corresponding to the particular navigation item. */
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ if (convertView == null) {
+ NavigationMenuItem item = getItem(position);
+ LayoutInflater inflater =
+ (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ convertView = inflater.inflate(item.mLayoutResourceId, null);
+ }
+ return convertView;
+ }
+
+
+ /** AdapterView.OnItemClickListener override. */
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ getItem(position).mCallback.run();
+ }
+}
« no previous file with comments | « remoting/android/java/src/org/chromium/chromoting/Chromoting.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698