[libbluray-devel] UserEventRepository: avoid duplicate entries
hpi1
git at videolan.org
Sat Dec 21 08:52:25 CET 2013
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Thu Dec 19 10:07:43 2013 +0200| [94c05d07d4fc9c4a9e7a434cdc1685256f52b59e] | committer: hpi1
UserEventRepository: avoid duplicate entries
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=94c05d07d4fc9c4a9e7a434cdc1685256f52b59e
---
.../java/org/dvb/event/UserEventRepository.java | 23 ++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/src/libbluray/bdj/java/org/dvb/event/UserEventRepository.java b/src/libbluray/bdj/java/org/dvb/event/UserEventRepository.java
index d86b63d..f0432b4 100644
--- a/src/libbluray/bdj/java/org/dvb/event/UserEventRepository.java
+++ b/src/libbluray/bdj/java/org/dvb/event/UserEventRepository.java
@@ -34,6 +34,10 @@ public class UserEventRepository extends RepositoryDescriptor {
public void addUserEvent(UserEvent event)
{
+ if (contains(event)) {
+ return;
+ }
+
events.add(event);
}
@@ -53,10 +57,10 @@ public class UserEventRepository extends RepositoryDescriptor {
public void addKey(int keycode)
{
- events.add(new UserEvent(this, UserEvent.UEF_KEY_EVENT,
- KeyEvent.KEY_PRESSED, keycode, 0, 0));
- events.add(new UserEvent(this, UserEvent.UEF_KEY_EVENT,
- KeyEvent.KEY_RELEASED, keycode, 0, 0));
+ addUserEvent(new UserEvent(this, UserEvent.UEF_KEY_EVENT,
+ KeyEvent.KEY_PRESSED, keycode, 0, 0));
+ addUserEvent(new UserEvent(this, UserEvent.UEF_KEY_EVENT,
+ KeyEvent.KEY_RELEASED, keycode, 0, 0));
}
public void removeKey(int keycode)
@@ -129,5 +133,16 @@ public class UserEventRepository extends RepositoryDescriptor {
removeKey(HRcEvent.VK_DOWN);
}
+ boolean contains(UserEvent event)
+ {
+ for(Iterator it = events.iterator(); it.hasNext() == true; ) {
+ UserEvent e = (UserEvent)it.next();
+ if (e.getFamily() == event.getFamily() && e.getType() == event.getType() && e.getCode() == event.getCode()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
private LinkedList events = new LinkedList();
}
More information about the libbluray-devel
mailing list