Search in sources :

Example 6 with LEFT

use of android.support.v7.widget.helper.ItemTouchHelper.LEFT in project remusic by aa112901.

the class DividerItemDecoration method drawHorizontal.

public void drawHorizontal(Canvas c, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getHeight() - parent.getPaddingBottom();
    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int left = child.getRight() + params.rightMargin;
        final int right = left + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 7 with LEFT

use of android.support.v7.widget.helper.ItemTouchHelper.LEFT in project remusic by aa112901.

the class SwipeRefreshLayout method onLayout.

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    final int width = getMeasuredWidth();
    final int height = getMeasuredHeight();
    if (getChildCount() == 0) {
        return;
    }
    if (mTarget == null) {
        ensureTarget();
    }
    if (mTarget == null) {
        return;
    }
    int distance = mCurrentTargetOffsetTop + mHeadViewContainer.getHeight();
    if (!targetScrollWithLayout) {
        // 判断标志位,如果目标View不跟随手指的滑动而滑动,将下拉偏移量设置为0
        distance = 0;
    }
    final View child = mTarget;
    final int childLeft = getPaddingLeft();
    // 根据偏移量distance更新
    final int childTop = getPaddingTop() + distance - pushDistance;
    final int childWidth = width - getPaddingLeft() - getPaddingRight();
    final int childHeight = height - getPaddingTop() - getPaddingBottom();
    Log.d(LOG_TAG, "debug:onLayout childHeight = " + childHeight);
    child.layout(childLeft, childTop, childLeft + childWidth, childTop + // 更新目标View的位置
    childHeight);
    int headViewWidth = mHeadViewContainer.getMeasuredWidth();
    int headViewHeight = mHeadViewContainer.getMeasuredHeight();
    mHeadViewContainer.layout((width / 2 - headViewWidth / 2), mCurrentTargetOffsetTop, (width / 2 + headViewWidth / 2), // 更新头布局的位置
    mCurrentTargetOffsetTop + headViewHeight);
    int footViewWidth = mFooterViewContainer.getMeasuredWidth();
    int footViewHeight = mFooterViewContainer.getMeasuredHeight();
    mFooterViewContainer.layout((width / 2 - footViewWidth / 2), height - pushDistance, (width / 2 + footViewWidth / 2), height + footViewHeight - pushDistance);
}
Also used : View(android.view.View) AbsListView(android.widget.AbsListView) RecyclerView(android.support.v7.widget.RecyclerView) ScrollView(android.widget.ScrollView) SuppressLint(android.annotation.SuppressLint) Paint(android.graphics.Paint)

Example 8 with LEFT

use of android.support.v7.widget.helper.ItemTouchHelper.LEFT in project NewPipe by TeamNewPipe.

the class VideoItemDetailFragment method updateInfo.

private void updateInfo(final StreamInfo info) {
    Activity a = getActivity();
    RelativeLayout textContentLayout = (RelativeLayout) activity.findViewById(R.id.detail_text_content_layout);
    final TextView videoTitleView = (TextView) activity.findViewById(R.id.detail_video_title_view);
    TextView uploaderView = (TextView) activity.findViewById(R.id.detail_uploader_view);
    TextView viewCountView = (TextView) activity.findViewById(R.id.detail_view_count_view);
    TextView thumbsUpView = (TextView) activity.findViewById(R.id.detail_thumbs_up_count_view);
    TextView thumbsDownView = (TextView) activity.findViewById(R.id.detail_thumbs_down_count_view);
    TextView uploadDateView = (TextView) activity.findViewById(R.id.detail_upload_date_view);
    TextView descriptionView = (TextView) activity.findViewById(R.id.detail_description_view);
    RecyclerView nextStreamView = (RecyclerView) activity.findViewById(R.id.detail_next_stream_content);
    RelativeLayout nextVideoRootFrame = (RelativeLayout) activity.findViewById(R.id.detail_next_stream_root_layout);
    TextView similarTitle = (TextView) activity.findViewById(R.id.detail_similar_title);
    Button backgroundButton = (Button) activity.findViewById(R.id.detail_stream_thumbnail_window_background_button);
    View thumbnailView = activity.findViewById(R.id.detail_thumbnail_view);
    View topView = activity.findViewById(R.id.detailTopView);
    Button channelButton = (Button) activity.findViewById(R.id.channel_button);
    // prevents a crash if the activity/fragment was already left when the response came
    if (channelButton != null) {
        progressBar.setVisibility(View.GONE);
        if (info.next_video != null) {
            // todo: activate this function or remove it
            nextStreamView.setVisibility(View.GONE);
        } else {
            nextStreamView.setVisibility(View.GONE);
            activity.findViewById(R.id.detail_similar_title).setVisibility(View.GONE);
        }
        textContentLayout.setVisibility(View.VISIBLE);
        if (android.os.Build.VERSION.SDK_INT < 18) {
            playVideoButton.setVisibility(View.VISIBLE);
        } else {
            ImageView playArrowView = (ImageView) activity.findViewById(R.id.play_arrow_view);
            playArrowView.setVisibility(View.VISIBLE);
        }
        if (!showNextStreamItem) {
            nextVideoRootFrame.setVisibility(View.GONE);
            similarTitle.setVisibility(View.GONE);
        }
        videoTitleView.setText(info.title);
        topView.setOnTouchListener(new View.OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == android.view.MotionEvent.ACTION_UP) {
                    ImageView arrow = (ImageView) activity.findViewById(R.id.toggle_description_view);
                    View extra = activity.findViewById(R.id.detailExtraView);
                    if (extra.getVisibility() == View.VISIBLE) {
                        extra.setVisibility(View.GONE);
                        arrow.setImageResource(R.drawable.arrow_down);
                    } else {
                        extra.setVisibility(View.VISIBLE);
                        arrow.setImageResource(R.drawable.arrow_up);
                    }
                }
                return true;
            }
        });
        // Since newpipe is designed to work even if certain information is not available,
        // the UI has to react on missing information.
        videoTitleView.setText(info.title);
        if (!info.uploader.isEmpty()) {
            uploaderView.setText(info.uploader);
        } else {
            activity.findViewById(R.id.detail_uploader_view).setVisibility(View.GONE);
        }
        if (info.view_count >= 0) {
            viewCountView.setText(Localization.localizeViewCount(info.view_count, a));
        } else {
            viewCountView.setVisibility(View.GONE);
        }
        if (info.dislike_count >= 0) {
            thumbsDownView.setText(Localization.localizeNumber(info.dislike_count, a));
        } else {
            thumbsDownView.setVisibility(View.INVISIBLE);
            activity.findViewById(R.id.detail_thumbs_down_count_view).setVisibility(View.GONE);
        }
        if (info.like_count >= 0) {
            thumbsUpView.setText(Localization.localizeNumber(info.like_count, a));
        } else {
            thumbsUpView.setVisibility(View.GONE);
            activity.findViewById(R.id.detail_thumbs_up_img_view).setVisibility(View.GONE);
            thumbsDownView.setVisibility(View.GONE);
            activity.findViewById(R.id.detail_thumbs_down_img_view).setVisibility(View.GONE);
        }
        if (!info.upload_date.isEmpty()) {
            uploadDateView.setText(Localization.localizeDate(info.upload_date, a));
        } else {
            uploadDateView.setVisibility(View.GONE);
        }
        if (!info.description.isEmpty()) {
            descriptionView.setText(Html.fromHtml(info.description));
        } else {
            descriptionView.setVisibility(View.GONE);
        }
        descriptionView.setMovementMethod(LinkMovementMethod.getInstance());
        // parse streams
        Vector<VideoStream> streamsToUse = new Vector<>();
        for (VideoStream i : info.video_streams) {
            if (useStream(i, streamsToUse)) {
                streamsToUse.add(i);
            }
        }
        textContentLayout.setVisibility(View.VISIBLE);
        if (info.next_video == null) {
            activity.findViewById(R.id.detail_next_stream_title).setVisibility(View.GONE);
        }
        if (info.related_streams != null && !info.related_streams.isEmpty()) {
            initSimilarVideos(info);
        } else {
            activity.findViewById(R.id.detail_similar_title).setVisibility(View.GONE);
            activity.findViewById(R.id.similar_streams_view).setVisibility(View.GONE);
        }
        setupActionBarHandler(info);
        if (autoPlayEnabled) {
            playVideo(info);
        }
        if (android.os.Build.VERSION.SDK_INT < 18) {
            playVideoButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    playVideo(info);
                }
            });
        }
        backgroundButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                playVideo(info);
            }
        });
        //todo: make backgroundButton handle this
        thumbnailView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                playVideo(info);
            }
        });
        if (info.channel_url != null && info.channel_url != "") {
            channelButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    NavStack.getInstance().openChannelActivity(getActivity(), info.channel_url, info.service_id);
                }
            });
        } else {
            channelButton.setVisibility(Button.GONE);
        }
        initThumbnailViews(info);
    }
}
Also used : VideoStream(org.schabi.newpipe.extractor.stream_info.VideoStream) 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) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) MotionEvent(android.view.MotionEvent) Button(android.widget.Button) FloatingActionButton(android.support.design.widget.FloatingActionButton) RelativeLayout(android.widget.RelativeLayout) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) ImageView(android.widget.ImageView) Vector(java.util.Vector)

Example 9 with LEFT

use of android.support.v7.widget.helper.ItemTouchHelper.LEFT 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)

Example 10 with LEFT

use of android.support.v7.widget.helper.ItemTouchHelper.LEFT in project FlexibleAdapter by davideas.

the class DividerItemDecoration method draw.

private void draw(Canvas c, RecyclerView parent) {
    int left = parent.getPaddingLeft();
    int right = parent.getWidth() - parent.getPaddingRight();
    int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = parent.getChildAt(i);
        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        int top = child.getBottom() + params.bottomMargin + Math.round(ViewCompat.getTranslationY(child));
        int bottom = top + mDivider.getIntrinsicHeight() + 1;
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Aggregations

View (android.view.View)291 RecyclerView (android.support.v7.widget.RecyclerView)276 Paint (android.graphics.Paint)43 TextView (android.widget.TextView)36 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)22 ImageView (android.widget.ImageView)20 Rect (android.graphics.Rect)11 Intent (android.content.Intent)9 SuppressLint (android.annotation.SuppressLint)8 OnLayoutChangeListener (android.view.View.OnLayoutChangeListener)8 OrientationHelperEx (com.alibaba.android.vlayout.OrientationHelperEx)8 ArrayList (java.util.ArrayList)8 AlertDialog (android.support.v7.app.AlertDialog)7 Toolbar (android.support.v7.widget.Toolbar)7 ViewGroup (android.view.ViewGroup)7 GridLayoutManager (android.support.v7.widget.GridLayoutManager)6 Button (android.widget.Button)6 Animator (android.animation.Animator)5 TargetApi (android.annotation.TargetApi)5 Activity (android.app.Activity)5