Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0f5fd79a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "VideoView2: Remove redundant listeners"

parents b3936de2 a35d1b19
Loading
Loading
Loading
Loading
+12 −102
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ import android.os.Bundle;
import android.util.AttributeSet;
import android.view.View;

import com.android.internal.annotations.VisibleForTesting;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.List;
@@ -343,72 +345,32 @@ public class VideoView2 extends ViewGroupHelper<VideoView2Provider> {
        mProvider.setCustomActions_impl(actionList, executor, listener);
    }

    /**
     * Registers a callback to be invoked when the media file is loaded and ready to go.
     *
     * @param executor executor to run callbacks on.
     * @param l the callback that will be run.
     */
    public void setOnPreparedListener(Executor executor, OnPreparedListener l) {
        mProvider.setOnPreparedListener_impl(executor, l);
    }

    /**
     * Registers a callback to be invoked when the end of a media file has been reached during
     * playback.
     *
     * @param executor executor to run callbacks on.
     * @param l the callback that will be run.
     */
    public void setOnCompletionListener(Executor executor, OnCompletionListener l) {
        mProvider.setOnCompletionListener_impl(executor, l);
    }

    /**
     * Registers a callback to be invoked when an error occurs during playback or setup.  If no
     * listener is specified, or if the listener returned false, VideoView2 will inform the user of
     * any errors.
     *
     * @param executor executor to run callbacks on.
     * @param l The callback that will be run
     */
    public void setOnErrorListener(Executor executor, OnErrorListener l) {
        mProvider.setOnErrorListener_impl(executor, l);
    }

    /**
     * Registers a callback to be invoked when an informational event occurs during playback or
     * setup.
     *
     * @param executor executor to run callbacks on.
     * @param l The callback that will be run
     */
    public void setOnInfoListener(Executor executor, OnInfoListener l) {
        mProvider.setOnInfoListener_impl(executor, l);
    }

    /**
     * Registers a callback to be invoked when a view type change is done.
     * {@see #setViewType(int)}
     * @param executor executor to run callbacks on.
     * @param l The callback that will be run
     *
     * @hide
     */
    public void setOnViewTypeChangedListener(Executor executor, OnViewTypeChangedListener l) {
        mProvider.setOnViewTypeChangedListener_impl(executor, l);
    @VisibleForTesting
    public void setOnViewTypeChangedListener(OnViewTypeChangedListener l) {
        mProvider.setOnViewTypeChangedListener_impl(l);
    }

    /**
     * Registers a callback to be invoked when the fullscreen mode should be changed.
     * @param executor executor to run callbacks on.
     * @param l The callback that will be run
     */
    public void setFullScreenRequestListener(Executor executor, OnFullScreenRequestListener l) {
        mProvider.setFullScreenRequestListener_impl(executor, l);
    public void setFullScreenRequestListener(OnFullScreenRequestListener l) {
        mProvider.setFullScreenRequestListener_impl(l);
    }

    /**
     * Interface definition of a callback to be invoked when the view type has been changed.
     *
     * @hide
     */
    @VisibleForTesting
    public interface OnViewTypeChangedListener {
        /**
         * Called when the view type has been changed.
@@ -423,58 +385,6 @@ public class VideoView2 extends ViewGroupHelper<VideoView2Provider> {
        void onViewTypeChanged(View view, @ViewType int viewType);
    }

    /**
     * Interface definition of a callback to be invoked when the media source is ready for playback.
     */
    public interface OnPreparedListener {
        /**
         * Called when the media file is ready for playback.
         */
        void onPrepared(View view);
    }

    /**
     * Interface definition for a callback to be invoked when playback of a media source has
     * completed.
     */
    public interface OnCompletionListener {
        /**
         * Called when the end of a media source is reached during playback.
         */
        void onCompletion(View view);
    }

    /**
     * Interface definition of a callback to be invoked when there has been an error during an
     * asynchronous operation.
     */
    public interface OnErrorListener {
        // TODO: Redefine error codes.
        /**
         * Called to indicate an error.
         * @param what the type of error that has occurred
         * @param extra an extra code, specific to the error.
         * @return true if the method handled the error, false if it didn't.
         * @see MediaPlayer#OnErrorListener
         */
        boolean onError(View view, int what, int extra);
    }

    /**
     * Interface definition of a callback to be invoked to communicate some info and/or warning
     * about the media or its playback.
     */
    public interface OnInfoListener {
        /**
         * Called to indicate an info or a warning.
         * @param what the type of info or warning.
         * @param extra an extra code, specific to the info.
         *
         * @see MediaPlayer#OnInfoListener
         */
        void onInfo(View view, int what, int extra);
    }

    /**
     * Interface definition of a callback to be invoked to inform the fullscreen mode is changed.
     * Application should handle the fullscreen mode accordingly.
+8 −8
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import android.util.AttributeSet;
import android.widget.MediaControlView2;
import android.widget.VideoView2;

import com.android.internal.annotations.VisibleForTesting;

import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;
@@ -70,12 +72,10 @@ public interface VideoView2Provider extends ViewGroupProvider {
    int getViewType_impl();
    void setCustomActions_impl(List<PlaybackState.CustomAction> actionList,
            Executor executor, VideoView2.OnCustomActionListener listener);
    void setOnPreparedListener_impl(Executor executor, VideoView2.OnPreparedListener l);
    void setOnCompletionListener_impl(Executor executor, VideoView2.OnCompletionListener l);
    void setOnErrorListener_impl(Executor executor, VideoView2.OnErrorListener l);
    void setOnInfoListener_impl(Executor executor, VideoView2.OnInfoListener l);
    void setOnViewTypeChangedListener_impl(
            Executor executor, VideoView2.OnViewTypeChangedListener l);
    void setFullScreenRequestListener_impl(
            Executor executor, VideoView2.OnFullScreenRequestListener l);
    /**
     * @hide
     */
    @VisibleForTesting
    void setOnViewTypeChangedListener_impl(VideoView2.OnViewTypeChangedListener l);
    void setFullScreenRequestListener_impl(VideoView2.OnFullScreenRequestListener l);
}