Search in sources :

Example 36 with MainActivity

use of com.odysee.app.MainActivity in project odysee-android by OdyseeTeam.

the class FileViewFragment method scheduleElapsedPlayback.

private void scheduleElapsedPlayback() {
    if (!elapsedPlaybackScheduled) {
        elapsedPlaybackScheduler = Executors.newSingleThreadScheduledExecutor();
        elapsedPlaybackScheduler.scheduleAtFixedRate(new Runnable() {

            @Override
            public void run() {
                Context context = getContext();
                if (context instanceof MainActivity) {
                    ((MainActivity) context).runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            if (MainActivity.appPlayer != null) {
                                elapsedDuration = MainActivity.appPlayer.getCurrentPosition();
                                int elapsedSeconds = Double.valueOf(elapsedDuration / 1000.0).intValue();
                                if (elapsedDuration > 0 && elapsedSeconds % 5 == 0 && elapsedSeconds != lastPositionSaved) {
                                    // save playback position every 5 seconds
                                    savePlaybackPosition();
                                    lastPositionSaved = elapsedSeconds;
                                }
                                renderElapsedDuration();
                            }
                        }
                    });
                }
            }
        }, 0, 500, TimeUnit.MILLISECONDS);
        elapsedPlaybackScheduled = true;
    }
}
Also used : AttributeProviderContext(org.commonmark.renderer.html.AttributeProviderContext) Context(android.content.Context) MainActivity(com.odysee.app.MainActivity) TrackSelectionOverride(com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride) SuppressLint(android.annotation.SuppressLint)

Example 37 with MainActivity

use of com.odysee.app.MainActivity in project odysee-android by OdyseeTeam.

the class FileViewFragment method setPlaybackSpeedToDefault.

private void setPlaybackSpeedToDefault() {
    Context context = getContext();
    if (context instanceof MainActivity) {
        int speed = ((MainActivity) context).playbackDefaultSpeed();
        setPlaybackSpeed(MainActivity.appPlayer, speed);
    }
}
Also used : AttributeProviderContext(org.commonmark.renderer.html.AttributeProviderContext) Context(android.content.Context) MainActivity(com.odysee.app.MainActivity) SuppressLint(android.annotation.SuppressLint)

Example 38 with MainActivity

use of com.odysee.app.MainActivity in project odysee-android by OdyseeTeam.

the class FileViewFragment method disableFullScreenMode.

@SuppressLint("SourceLockedOrientationActivity")
private void disableFullScreenMode() {
    Context context = getContext();
    if (context instanceof MainActivity) {
        MainActivity activity = (MainActivity) context;
        View root = getView();
        if (root != null) {
            RelativeLayout mediaContainer = root.findViewById(R.id.file_view_media_container);
            View exoplayerContainer = root.findViewById(R.id.file_view_exoplayer_container);
            ((ViewGroup) exoplayerContainer.getParent()).removeView(exoplayerContainer);
            mediaContainer.addView(exoplayerContainer);
            View playerView = root.findViewById(R.id.file_view_exoplayer_view);
            ((ImageView) playerView.findViewById(R.id.player_image_full_screen_toggle)).setImageResource(R.drawable.ic_fullscreen);
            exoplayerContainer.setPadding(0, 0, 0, 0);
            activity.exitFullScreenMode();
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
        }
    }
}
Also used : AttributeProviderContext(org.commonmark.renderer.html.AttributeProviderContext) Context(android.content.Context) ViewGroup(android.view.ViewGroup) RelativeLayout(android.widget.RelativeLayout) MainActivity(com.odysee.app.MainActivity) ImageView(android.widget.ImageView) SolidIconView(com.odysee.app.ui.controls.SolidIconView) PlayerView(com.google.android.exoplayer2.ui.PlayerView) NestedScrollView(androidx.core.widget.NestedScrollView) AdapterView(android.widget.AdapterView) RecyclerView(androidx.recyclerview.widget.RecyclerView) PhotoView(com.github.chrisbanes.photoview.PhotoView) ImageView(android.widget.ImageView) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint)

Example 39 with MainActivity

use of com.odysee.app.MainActivity in project odysee-android by OdyseeTeam.

the class FileViewFragment method enableFullScreenMode.

@SuppressLint("SourceLockedOrientationActivity")
private void enableFullScreenMode() {
    Context context = getContext();
    if (context instanceof MainActivity) {
        View root = getView();
        if (root != null) {
            ConstraintLayout globalLayout = root.findViewById(R.id.file_view_global_layout);
            View exoplayerContainer = root.findViewById(R.id.file_view_exoplayer_container);
            ((ViewGroup) exoplayerContainer.getParent()).removeView(exoplayerContainer);
            globalLayout.addView(exoplayerContainer);
            View playerView = root.findViewById(R.id.file_view_exoplayer_view);
            ((ImageView) playerView.findViewById(R.id.player_image_full_screen_toggle)).setImageResource(R.drawable.ic_fullscreen_exit);
            MainActivity activity = (MainActivity) context;
            activity.enterFullScreenMode();
            exoplayerContainer.setPadding(0, 0, 0, 0);
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
        }
    }
}
Also used : AttributeProviderContext(org.commonmark.renderer.html.AttributeProviderContext) Context(android.content.Context) ViewGroup(android.view.ViewGroup) MainActivity(com.odysee.app.MainActivity) ImageView(android.widget.ImageView) SolidIconView(com.odysee.app.ui.controls.SolidIconView) PlayerView(com.google.android.exoplayer2.ui.PlayerView) NestedScrollView(androidx.core.widget.NestedScrollView) AdapterView(android.widget.AdapterView) RecyclerView(androidx.recyclerview.widget.RecyclerView) PhotoView(com.github.chrisbanes.photoview.PhotoView) ImageView(android.widget.ImageView) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) ConstraintLayout(androidx.constraintlayout.widget.ConstraintLayout) SuppressLint(android.annotation.SuppressLint)

Example 40 with MainActivity

use of com.odysee.app.MainActivity in project odysee-android by OdyseeTeam.

the class FileViewFragment method setPlayerQualityToDefault.

private void setPlayerQualityToDefault() {
    Context context = getContext();
    if (context instanceof MainActivity) {
        boolean isOnMobileNetwork = isMeteredNetwork(context);
        int quality = isOnMobileNetwork ? ((MainActivity) context).mobileDefaultQuality() : ((MainActivity) context).wifiDefaultQuality();
        setPlayerQuality(MainActivity.appPlayer, quality);
    }
}
Also used : AttributeProviderContext(org.commonmark.renderer.html.AttributeProviderContext) Context(android.content.Context) MainActivity(com.odysee.app.MainActivity) SuppressLint(android.annotation.SuppressLint)

Aggregations

MainActivity (com.odysee.app.MainActivity)138 Context (android.content.Context)119 Claim (com.odysee.app.model.Claim)39 View (android.view.View)31 TextView (android.widget.TextView)30 RecyclerView (androidx.recyclerview.widget.RecyclerView)26 AttributeProviderContext (org.commonmark.renderer.html.AttributeProviderContext)25 ArrayList (java.util.ArrayList)21 TrackSelectionOverride (com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride)19 ImageView (android.widget.ImageView)18 SuppressLint (android.annotation.SuppressLint)15 AdapterView (android.widget.AdapterView)14 NestedScrollView (androidx.core.widget.NestedScrollView)14 JSONException (org.json.JSONException)13 JSONObject (org.json.JSONObject)13 SolidIconView (com.odysee.app.ui.controls.SolidIconView)12 HashMap (java.util.HashMap)12 ClaimListAdapter (com.odysee.app.adapter.ClaimListAdapter)11 ApiCallException (com.odysee.app.exceptions.ApiCallException)11 WebView (android.webkit.WebView)10