Search in sources :

Example 1 with InfoItemBuilder

use of org.schabi.newpipe.info_list.InfoItemBuilder in project NewPipe by TeamNewPipe.

the class VideoItemDetailFragment method onStart.

@Override
public void onStart() {
    super.onStart();
    Activity a = getActivity();
    infoItemBuilder = new InfoItemBuilder(a, a.findViewById(android.R.id.content));
    if (android.os.Build.VERSION.SDK_INT < 18) {
        playVideoButton = (FloatingActionButton) a.findViewById(R.id.play_video_button);
    }
    thumbnailWindowLayout = a.findViewById(R.id.detail_stream_thumbnail_window_layout);
    Button backgroundButton = (Button) a.findViewById(R.id.detail_stream_thumbnail_window_background_button);
    // Otherwise the applications would crash.
    if (backgroundButton != null) {
        streamingServiceId = getArguments().getInt(NavStack.SERVICE_ID);
        String videoUrl = getArguments().getString(NavStack.URL);
        StreamInfoWorker siw = StreamInfoWorker.getInstance();
        siw.search(streamingServiceId, videoUrl, getActivity());
        autoPlayEnabled = getArguments().getBoolean(AUTO_PLAY);
        if (Build.VERSION.SDK_INT >= 18) {
            ImageView thumbnailView = (ImageView) activity.findViewById(R.id.detail_thumbnail_view);
            thumbnailView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {

                // This is used to synchronize the thumbnailWindowButton and the playVideoButton
                // inside the ScrollView with the actual size of the thumbnail.
                //todo: onLayoutChage sometimes not triggered
                // background buttons area seem to overlap the thumbnail view
                // So although you just clicked slightly beneath the thumbnail the action still
                // gets triggered.
                @Override
                public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
                    RelativeLayout.LayoutParams newWindowLayoutParams = (RelativeLayout.LayoutParams) thumbnailWindowLayout.getLayoutParams();
                    newWindowLayoutParams.height = bottom - top;
                    thumbnailWindowLayout.setLayoutParams(newWindowLayoutParams);
                    //noinspection SuspiciousNameCombination
                    initialThumbnailPos.set(top, left);
                }
            });
        }
    }
}
Also used : Button(android.widget.Button) FloatingActionButton(android.support.design.widget.FloatingActionButton) RelativeLayout(android.widget.RelativeLayout) ReCaptchaActivity(org.schabi.newpipe.ReCaptchaActivity) ExoPlayerActivity(org.schabi.newpipe.player.ExoPlayerActivity) AppCompatActivity(android.support.v7.app.AppCompatActivity) PlayVideoActivity(org.schabi.newpipe.player.PlayVideoActivity) ErrorActivity(org.schabi.newpipe.report.ErrorActivity) Activity(android.app.Activity) InfoItemBuilder(org.schabi.newpipe.info_list.InfoItemBuilder) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) Point(android.graphics.Point)

Aggregations

Activity (android.app.Activity)1 Point (android.graphics.Point)1 FloatingActionButton (android.support.design.widget.FloatingActionButton)1 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 Button (android.widget.Button)1 ImageView (android.widget.ImageView)1 RelativeLayout (android.widget.RelativeLayout)1 TextView (android.widget.TextView)1 ReCaptchaActivity (org.schabi.newpipe.ReCaptchaActivity)1 InfoItemBuilder (org.schabi.newpipe.info_list.InfoItemBuilder)1 ExoPlayerActivity (org.schabi.newpipe.player.ExoPlayerActivity)1 PlayVideoActivity (org.schabi.newpipe.player.PlayVideoActivity)1 ErrorActivity (org.schabi.newpipe.report.ErrorActivity)1