this is the method to scroll and navigate on my EPG, but i need to navigate with Remote on AndroidTV.
I've read few things about setClickable, setFocusable but its working only on the main screen and i need to give inside to access each cells.
So basically, i need to navigate between cells inside the EPG.
Anyone has any ideas how?
The EPG project is there -> https://github.com/korre/android-tv-epg
private class OnGestureListener extends GestureDetector.SimpleOnGestureListener {
@Override
public boolean onSingleTapUp(MotionEvent e) {
// This is absolute coordinate on screen not taking scroll into account.
int x = (int) e.getX();
int y = (int) e.getY();
// Adding scroll to clicked coordinate
int scrollX = getScrollX() + x;
int scrollY = getScrollY() + y;
int channelPosition = getChannelPosition(scrollY);
if (channelPosition != -1 && mClickListener != null) {
if (calculateResetButtonHitArea().contains(scrollX,scrollY)) {
// Reset button clicked
mClickListener.onResetButtonClicked();
} else if (calculateChannelsHitArea().contains(x, y)) {
// Channel area is clicked
/*mClickListener.onChannelClicked(channelPosition, epgData.getChannel(channelPosition));*/
} else if (calculateProgramsHitArea().contains(x, y)) {
// Event area is clicked
int programPosition = getProgramPosition(channelPosition, getTimeFrom(getScrollX() + x - calculateProgramsHitArea().left));
if (programPosition != -1) {
/*mClickListener.onEventClicked(channelPosition, programPosition, epgData.getEvent(channelPosition, programPosition));*/
}
}
}
return true;
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY) {
int dx = (int) distanceX;
int dy = (int) distanceY;
int x = getScrollX();
int y = getScrollY();
// Avoid over scrolling
if (x + dx < 0) {
dx = 0 - x;
}
if (y + dy < 0) {
dy = 0 - y;
}
if (x + dx > mMaxHorizontalScroll) {
dx = mMaxHorizontalScroll - x;
}
if (y + dy > mMaxVerticalScroll) {
dy = mMaxVerticalScroll - y;
}
scrollBy(dx, dy);
return true;
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2,
float vX, float vY) {
mScroller.fling(getScrollX(), getScrollY(), -(int) vX,
-(int) vY, 0, mMaxHorizontalScroll, 0, mMaxVerticalScroll);
redraw();
return true;
}
@Override
public boolean onDown(MotionEvent e) {
if (!mScroller.isFinished()) {
mScroller.forceFinished(true);
return true;
}
return true;
}
}
}