[Android] Reuse mContextMenuInfo object whenever possible
Geoffrey Métais
git at videolan.org
Thu Apr 23 14:08:05 CEST 2015
vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Apr 23 10:23:40 2015 +0200| [d68311ac200e7a2aa86f6809a99486c2d328bce6] | committer: Geoffrey Métais
Reuse mContextMenuInfo object whenever possible
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=d68311ac200e7a2aa86f6809a99486c2d328bce6
---
.../vlc/widget/ContextMenuRecyclerView.java | 23 ++++++++++++--------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/widget/ContextMenuRecyclerView.java b/vlc-android/src/org/videolan/vlc/widget/ContextMenuRecyclerView.java
index 435c6fe..60d3d81 100644
--- a/vlc-android/src/org/videolan/vlc/widget/ContextMenuRecyclerView.java
+++ b/vlc-android/src/org/videolan/vlc/widget/ContextMenuRecyclerView.java
@@ -51,25 +51,30 @@ public class ContextMenuRecyclerView extends RecyclerView {
}
public void openContextMenu(int position) {
- if (position >= 0) {
- final long childId = getAdapter().getItemId(position);
- mContextMenuInfo = createContextMenuInfo(position, childId);
- }
+ if (position >= 0)
+ createContextMenuInfo(position, getAdapter().getItemId(position));
showContextMenu();
}
- private ContextMenu.ContextMenuInfo createContextMenuInfo(int position, long id) {
- return new RecyclerContextMenuInfo(position, id);
+ private void createContextMenuInfo(int position, long id) {
+ if (mContextMenuInfo == null)
+ mContextMenuInfo = new RecyclerContextMenuInfo(position, id);
+ else
+ ((RecyclerContextMenuInfo)mContextMenuInfo).setValues(position, id);
}
public static class RecyclerContextMenuInfo implements ContextMenu.ContextMenuInfo {
+ public int position;
+ public long id;
+
public RecyclerContextMenuInfo(int position, long id) {
+ setValues(position, id);
+ }
+
+ public void setValues(int position, long id){
this.position = position;
this.id = id;
}
-
- public int position;
- public long id;
}
}
More information about the Android
mailing list