app/src/main/java/nerd/tuxmobil/fahrplan/congress/schedule/FahrplanFragment.java
/**
     * jump to current time or session, if we are on today's session list
     */
jump to current time or session, if we are on today's session list
jump to current time or session if we are on today ' s session list
private void scrollToCurrent(int boxHeight) {
        if (sessionId != null) {
            return;
        }
        int currentDayIndex = scheduleData.getDayIndex();
        if (currentDayIndex != MyApp.dateInfos.getIndexOfToday()) {
            return;
        }
        Moment nowMoment = new Moment();
        HorizontalSnapScrollView horiz = null;
        switch (getResources().getConfiguration().orientation) {
            case Configuration.ORIENTATION_LANDSCAPE:
                break;
            default:
                horiz = getView().findViewById(R.id.horizScroller);
                break;
        }
        int columnIndex = -1;
        if (horiz != null) {
            columnIndex = horiz.getColumnIndex();
            MyApp.LogDebug(LOG_TAG, "y pos  = " + columnIndex);
        }
        int time = conference.getFirstSessionStartsAt();
        int printTime = time;
        int scrollAmount = 0;
        if (!(nowMoment.getMinuteOfDay() < conference.getFirstSessionStartsAt() &&
                MyApp.dateInfos.sameDay(nowMoment, currentDayIndex))) {
            TimeSegment timeSegment;
            while (time < conference.getLastSessionEndsAt()) {
                timeSegment = new TimeSegment(printTime);
                if (timeSegment.isMatched(nowMoment, FIFTEEN_MINUTES)) {
                    break;
                } else {
                    scrollAmount += boxHeight * 3;
                }
                time += FIFTEEN_MINUTES;
                printTime = time;
                if (printTime >= ONE_DAY) {
                    printTime -= ONE_DAY;
                }
            }
            List<RoomData> roomDataList = scheduleData.getRoomDataList();
            if (columnIndex >= 0 && columnIndex < roomDataList.size()) {
                RoomData roomData = roomDataList.get(columnIndex);
                for (Session session : roomData.getSessions()) {
                    if (session.startTime <= time && session.startTime + session.duration > time) {
                        MyApp.LogDebug(LOG_TAG, session.title);
                        MyApp.LogDebug(LOG_TAG, time + " " + session.startTime + "/" + session.duration);
                        scrollAmount -= ((time - session.startTime) / 5) * boxHeight;
                        time = session.startTime;
                    }
                }
            }
        } else {
        }
        final int pos = scrollAmount;
        final ScrollView scrollView = requireViewByIdCompat(getView(), R.id.scrollView1);
        scrollView.scrollTo(0, scrollAmount);
        scrollView.post(() -> scrollView.scrollTo(0, pos));
    }
private void scrollToCurrent ( int boxHeight ) { if ( sessionId != null ) { return ; } int currentDayIndex = scheduleData . getDayIndex ( ) ; if ( currentDayIndex != MyApp . dateInfos . getIndexOfToday ( ) ) { return ; } Moment nowMoment = new Moment ( ) ; HorizontalSnapScrollView horiz = null ; switch ( getResources ( ) . getConfiguration ( ) . orientation ) { case Configuration . ORIENTATION_LANDSCAPE : break ; default : horiz = getView ( ) . findViewById ( R . id . horizScroller ) ; break ; } int columnIndex = - 1 ; if ( horiz != null ) { columnIndex = horiz . getColumnIndex ( ) ; MyApp . LogDebug ( LOG_TAG , "y pos  = " + columnIndex ) ; } int time = conference . getFirstSessionStartsAt ( ) ; int printTime = time ; int scrollAmount = 0 ; if ( ! ( nowMoment . getMinuteOfDay ( ) < conference . getFirstSessionStartsAt ( ) && MyApp . dateInfos . sameDay ( nowMoment , currentDayIndex ) ) ) { TimeSegment timeSegment ; while ( time < conference . getLastSessionEndsAt ( ) ) { timeSegment = new TimeSegment ( printTime ) ; if ( timeSegment . isMatched ( nowMoment , FIFTEEN_MINUTES ) ) { break ; } else { scrollAmount += boxHeight * 3 ; } time += FIFTEEN_MINUTES ; printTime = time ; if ( printTime >= ONE_DAY ) { printTime -= ONE_DAY ; } } List < RoomData > roomDataList = scheduleData . getRoomDataList ( ) ; if ( columnIndex >= 0 && columnIndex < roomDataList . size ( ) ) { RoomData roomData = roomDataList . get ( columnIndex ) ; for ( Session session : roomData . getSessions ( ) ) { if ( session . startTime <= time && session . startTime + session . duration > time ) { MyApp . LogDebug ( LOG_TAG , session . title ) ; MyApp . LogDebug ( LOG_TAG , time + " " + session . startTime + "/" + session . duration ) ; scrollAmount -= ( ( time - session . startTime ) / 5 ) * boxHeight ; time = session . startTime ; } } } } else { } final int pos = scrollAmount ; final ScrollView scrollView = requireViewByIdCompat ( getView ( ) , R . id . scrollView1 ) ; scrollView . scrollTo ( 0 , scrollAmount ) ; scrollView . post ( ( ) -> scrollView . scrollTo ( 0 , pos ) ) ; }
jump to current time or session, if we are on today's session list
jump to current time or session if we are on today ' s session list
// Log.d(LOG_TAG, "sessionListDay: " + MyApp.sessionListDay); //noinspection SwitchStatementWithTooFewBranches // Log.d(LOG_TAG, "we are before " + firstSessionStart + " " + ((now.hour * 60) + now.minute)); // Log.d(LOG_TAG, "scrolltoCurrent to " + scrollAmount);