Search in sources :

Example 41 with LayoutParams

use of android.support.v7.app.ActionBar.LayoutParams in project Tusky by tuskyapp.

the class ComposeActivity method addMediaToQueue.

private void addMediaToQueue(QueuedMedia.Type type, Bitmap preview, Uri uri, long mediaSize, QueuedMedia.ReadyStage readyStage, @Nullable String description) {
    final QueuedMedia item = new QueuedMedia(type, uri, new ProgressImageView(this), mediaSize, description);
    item.readyStage = readyStage;
    ImageView view = item.preview;
    Resources resources = getResources();
    int side = resources.getDimensionPixelSize(R.dimen.compose_media_preview_side);
    int margin = resources.getDimensionPixelSize(R.dimen.compose_media_preview_margin);
    int marginBottom = resources.getDimensionPixelSize(R.dimen.compose_media_preview_margin_bottom);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(side, side);
    layoutParams.setMargins(margin, 0, margin, marginBottom);
    view.setLayoutParams(layoutParams);
    view.setScaleType(ImageView.ScaleType.CENTER_CROP);
    view.setImageBitmap(preview);
    view.setOnClickListener(v -> onMediaClick(item, v));
    view.setContentDescription(getString(R.string.action_delete));
    mediaPreviewBar.addView(view);
    mediaQueued.add(item);
    int queuedCount = mediaQueued.size();
    if (queuedCount == 1) {
        /* The media preview bar is actually not inset in the EditText, it just overlays it and
             * is aligned to the bottom. But, so that text doesn't get hidden under it, extra
             * padding is added at the bottom of the EditText. */
        int totalHeight = side + margin + marginBottom;
        textEditor.setPadding(textEditor.getPaddingLeft(), textEditor.getPaddingTop(), textEditor.getPaddingRight(), totalHeight);
        // If there's one video in the queue it is full, so disable the button to queue more.
        if (item.type == QueuedMedia.Type.VIDEO) {
            disableMediaButtons();
        }
    } else if (queuedCount >= Status.MAX_MEDIA_ATTACHMENTS) {
        // Limit the total media attachments, also.
        disableMediaButtons();
    }
    if (queuedCount >= 1) {
        showMarkSensitive(true);
    }
    if (item.readyStage != QueuedMedia.ReadyStage.UPLOADED) {
        waitForMediaLatch.countUp();
        if (mediaSize > STATUS_MEDIA_SIZE_LIMIT && type == QueuedMedia.Type.IMAGE) {
            downsizeMedia(item);
        } else {
            uploadMedia(item);
        }
    }
}
Also used : ImageView(android.widget.ImageView) ProgressImageView(com.keylesspalace.tusky.view.ProgressImageView) AppCompatResources(android.support.v7.content.res.AppCompatResources) Resources(android.content.res.Resources) ProgressImageView(com.keylesspalace.tusky.view.ProgressImageView) SuppressLint(android.annotation.SuppressLint) LinearLayout(android.widget.LinearLayout)

Example 42 with LayoutParams

use of android.support.v7.app.ActionBar.LayoutParams in project lzc_app_lib by httplzc.

the class DragScrollRecycleView method init.

private void init(Context context) {
    recyclerView = new RecyclerView(context);
    runnable = new Runnable() {

        @Override
        public void run() {
            if (choiceWrapper == null || choiceWrapper.dragView == null)
                return;
            FrameLayout.LayoutParams lp = (LayoutParams) choiceWrapper.dragView.getLayoutParams();
            if (lp.topMargin < 0) {
                recyclerView.scrollBy(0, -autoScrollRatio);
                recyclerView.postDelayed(runnable, autoScrollTime);
            } else if (lp.topMargin > recyclerView.getHeight() - lp.height) {
                recyclerView.scrollBy(0, autoScrollRatio);
                recyclerView.postDelayed(runnable, autoScrollTime);
            }
        }
    };
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView)

Example 43 with LayoutParams

use of android.support.v7.app.ActionBar.LayoutParams in project lzc_app_lib by httplzc.

the class DragScrollRecycleView method doBackAnim.

private void doBackAnim() {
    Log.i("lzc", "backAnim" + choiceWrapper.choicePosition + "---" + choiceWrapper.moveToPosition + "--" + choiceWrapper.choiceView);
    View endView = null;
    if (choiceWrapper.choiceView != null) {
        endView = choiceWrapper.choiceView;
    } else {
        endView = recyclerView.getLayoutManager().findViewByPosition(choiceWrapper.moveToPosition);
    }
    PropertyValuesHolder propertyValuesHolder1 = PropertyValuesHolder.ofFloat("marginLeft", choiceWrapper.dragView.getLeft(), endView.getLeft());
    PropertyValuesHolder propertyValuesHolder2 = PropertyValuesHolder.ofFloat("marginTop", choiceWrapper.dragView.getTop(), endView.getTop());
    PropertyValuesHolder propertyValuesHolder3 = PropertyValuesHolder.ofFloat("scale", scale, 1);
    ValueAnimator valueAnimator = ValueAnimator.ofPropertyValuesHolder(propertyValuesHolder1, propertyValuesHolder2, propertyValuesHolder3);
    valueAnimator.setDuration(200);
    final View finalEndView = endView;
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float marginLeft = (float) animation.getAnimatedValue("marginLeft");
            float marginTop = (float) animation.getAnimatedValue("marginTop");
            float scale = (float) animation.getAnimatedValue("scale");
            FrameLayout.LayoutParams layoutParams = (LayoutParams) choiceWrapper.dragView.getLayoutParams();
            layoutParams.width = (int) (finalEndView.getWidth() * scale);
            layoutParams.height = (int) (finalEndView.getHeight() * scale);
            layoutParams.leftMargin = (int) marginLeft;
            layoutParams.topMargin = (int) marginTop;
            choiceWrapper.dragView.setLayoutParams(layoutParams);
        }
    });
    valueAnimator.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            onBackAnimFinish();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
    valueAnimator.start();
}
Also used : ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(com.nineoldandroids.animation.Animator) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) PropertyValuesHolder(com.nineoldandroids.animation.PropertyValuesHolder) ValueAnimator(com.nineoldandroids.animation.ValueAnimator) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 44 with LayoutParams

use of android.support.v7.app.ActionBar.LayoutParams in project lzc_app_lib by httplzc.

the class RefreshRecycleViewParentView method addExtraView.

@Override
protected void addExtraView() {
    // 加载更多 失败刷新
    refreshFoot.getFootView().setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (reFreshFootStatus == ReFreshFootStatus.Failure) {
                reFreshFootStatus = ReFreshFootStatus.OnRefresh;
                refreshFoot.changeState(reFreshFootStatus);
                refreshFoot.getFootView().postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        if (loaddingMoreListener != null)
                            loaddingMoreListener.loadMore();
                    }
                }, 500);
            }
        }
    });
    LinearLayout linearLayout = new LinearLayout(context);
    RecycleView.LayoutParams lp = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    linearLayout.setLayoutParams(lp);
    linearLayout.addView(refreshHead.getHeadView());
    scrollView.addHeadView(linearLayout, 0, null);
    LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) refreshHead.getHeadView().getLayoutParams();
    layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
    layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
    refreshHead.getHeadView().setLayoutParams(layoutParams);
    linearLayout.setPadding(linearLayout.getPaddingLeft(), (int) (-refreshHeadHeight), linearLayout.getPaddingRight(), linearLayout.getPaddingBottom());
    scrollView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        private int scrollState;

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
            this.scrollState = newState;
            if (scrollState == RecyclerView.SCROLL_STATE_IDLE && isInEnd()) {
                scrollView.scrollToPosition(scrollView.getItemCount() - 1);
            }
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            checkOnScroll(stickyTagHelper.groupViews);
            if (enableFreshFoot && isReadyForPullEnd() && scrollState != RecyclerView.SCROLL_STATE_IDLE) {
                if (reFreshFootStatus == ReFreshFootStatus.OnRefresh || reFreshFootStatus == ReFreshFootStatus.Finish || reFreshStatus != ReFreshStatus.Normal || reFreshFootStatus == ReFreshFootStatus.Failure) {
                    if (reFreshFootStatus == ReFreshFootStatus.Finish && scrollView.getFootCount() != footcount) {
                        scrollView.addFootView(refreshFoot.getFootView(), null);
                    }
                    return;
                }
                reFreshFootStatus = ReFreshFootStatus.OnRefresh;
                refreshFoot.changeState(reFreshFootStatus);
                scrollView.addFootView(refreshFoot.getFootView(), null);
                loaddingMoreListener.loadMore();
            }
        }
    });
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Example 45 with LayoutParams

use of android.support.v7.app.ActionBar.LayoutParams in project vlc-android by GeoffreyMetais.

the class VideoPlayerActivity method initOverlay.

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void initOverlay() {
    final ViewStubCompat vsc = findViewById(R.id.player_hud_stub);
    if (vsc != null) {
        mSeekButtons = mSettings.getBoolean("enable_seek_buttons", false);
        vsc.inflate();
        mHudBinding = DataBindingUtil.bind(findViewById(R.id.progress_overlay));
        mHudBinding.setPlayer(this);
        updateTimeValues();
        mHudBinding.setProgress(mProgress);
        mHudBinding.setLength(mMediaLength);
        final RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mHudBinding.progressOverlay.getLayoutParams();
        if (AndroidDevices.isPhone || !AndroidDevices.hasNavBar)
            layoutParams.width = LayoutParams.MATCH_PARENT;
        else
            layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
        mHudBinding.progressOverlay.setLayoutParams(layoutParams);
        mOverlayBackground = findViewById(R.id.player_overlay_background);
        mNavMenu = findViewById(R.id.player_overlay_navmenu);
        if (!AndroidDevices.isChromeBook && AndroidUtil.isJellyBeanMR1OrLater) {
            mRendererBtn = findViewById(R.id.video_renderer);
            RendererDelegate.INSTANCE.getSelectedRenderer().observe(this, new Observer<RendererItem>() {

                @Override
                public void onChanged(@android.support.annotation.Nullable RendererItem rendererItem) {
                    if (mRendererBtn != null)
                        mRendererBtn.setImageResource(rendererItem == null ? R.drawable.ic_renderer_circle : R.drawable.ic_renderer_on_circle);
                }
            });
            RendererDelegate.INSTANCE.getRenderers().observe(this, new Observer<List<RendererItem>>() {

                @Override
                public void onChanged(@Nullable List<RendererItem> rendererItems) {
                    UiTools.setViewVisibility(mRendererBtn, Util.isListEmpty(rendererItems) ? View.GONE : View.VISIBLE);
                }
            });
        }
        if (mSeekButtons)
            initSeekButton();
        resetHudLayout();
        updateOverlayPausePlay();
        updateSeekable(mService.isSeekable());
        updatePausable(mService.isPausable());
        updateNavStatus();
        setListeners(true);
        initPlaylistUi();
        if (!mDisplayManager.isPrimary()) {
            mHudBinding.lockOverlayButton.setVisibility(View.GONE);
            mHudBinding.playerOverlaySize.setVisibility(View.GONE);
        }
    }
}
Also used : ViewStubCompat(android.support.v7.widget.ViewStubCompat) LayoutParams(android.view.ViewGroup.LayoutParams) RelativeLayout(android.widget.RelativeLayout) ArrayList(java.util.ArrayList) List(java.util.List) RendererItem(org.videolan.libvlc.RendererItem) TargetApi(android.annotation.TargetApi)

Aggregations

View (android.view.View)140 RecyclerView (android.support.v7.widget.RecyclerView)127 TextView (android.widget.TextView)46 ImageView (android.widget.ImageView)38 ViewGroup (android.view.ViewGroup)33 LinearLayout (android.widget.LinearLayout)27 LayoutParams (android.support.v7.widget.RecyclerView.LayoutParams)17 Paint (android.graphics.Paint)15 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)15 FrameLayout (android.widget.FrameLayout)15 BindView (butterknife.BindView)12 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)11 Toolbar (android.support.v7.widget.Toolbar)11 Rect (android.graphics.Rect)9 EditText (android.widget.EditText)9 OrientationHelperEx (com.alibaba.android.vlayout.OrientationHelperEx)9 AdapterView (android.widget.AdapterView)8 RelativeLayout (android.widget.RelativeLayout)8 VirtualLayoutManager (com.alibaba.android.vlayout.VirtualLayoutManager)8 SuppressLint (android.annotation.SuppressLint)7