Last active
August 29, 2015 14:03
-
-
Save matthew-carroll/a208e76066c967e2560c to your computer and use it in GitHub Desktop.
Handling KindleTV Remote Events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public boolean onKeyDown(int keyCode, KeyEvent event) { | |
Log.d("mgm:t1", "MainActivity.onKeyDown " + event); | |
if ( keyCode == KeyEvent.KEYCODE_MENU) { | |
handler.post(new Runnable() { | |
@Override | |
public void run() { | |
mDrawerFragment.openDrawer(); | |
} | |
}); | |
} else if ( keyCode == KeyEvent.KEYCODE_DPAD_CENTER) { | |
mVideoPlayerFragment.handleVideoPlayerClicked(); | |
} else if ( keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD ) { | |
mVideoPlayerFragment.fforward(); | |
} else if ( keyCode == KeyEvent.KEYCODE_MEDIA_REWIND ) { | |
mVideoPlayerFragment.reverse(); | |
} | |
return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public boolean onKeyDown(int keyCode, KeyEvent event) { | |
Log.d("mgm:t1", "MainActivity.onKeyDown " + event); | |
if ( keyCode == KeyEvent.KEYCODE_MENU) { | |
CommBus.getInstance().post(new FireTvControlEvent(keyCode)); | |
} else if ( keyCode == KeyEvent.KEYCODE_DPAD_CENTER) { | |
CommBus.getInstance().post(new FireTvControlEvent(keyCode)); | |
} else if ( keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD ) { | |
CommBus.getInstance().post(new FireTvControlEvent(keyCode)); | |
} else if ( keyCode == KeyEvent.KEYCODE_MEDIA_REWIND ) { | |
CommBus.getInstance().post(new FireTvControlEvent(keyCode)); | |
} | |
return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void onEventMainThread(FireTvControlEvent event) { | |
if ( event.getKeyCode() == KeyEvent.KEYCODE_MENU) { | |
handler.post(new Runnable() { | |
@Override | |
public void run() { | |
mDrawerFragment.openDrawer(); | |
} | |
}); | |
} | |
// let the video fragment handle its own reaction to the event, no need to do that here | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void onEventMainThread(FireTvControlEvent event) { | |
if ( event.getKeyCode() == KeyEvent.KEYCODE_DPAD_CENTER) { | |
this.handleVideoPlayerClicked(); | |
} else if ( kevent.getKeyCode()== KeyEvent.KEYCODE_MEDIA_FAST_FORWARD ) { | |
this.fforward(); | |
} else if ( kevent.getKeyCode()== KeyEvent.KEYCODE_MEDIA_REWIND ) { | |
this.reverse(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment