Search in sources :

Example 1 with AppBarStateChangeEvent

use of com.hotbitmapgg.bilibili.event.AppBarStateChangeEvent in project bilibili-android-client by HotBitmapGG.

the class VideoDetailsActivity method initViews.

@Override
public void initViews(Bundle savedInstanceState) {
    Intent intent = getIntent();
    if (intent != null) {
        av = intent.getIntExtra(ConstantUtil.EXTRA_AV, -1);
        imgUrl = intent.getStringExtra(ConstantUtil.EXTRA_IMG_URL);
    }
    Glide.with(VideoDetailsActivity.this).load(UrlHelper.getClearVideoPreviewUrl(imgUrl)).centerCrop().diskCacheStrategy(DiskCacheStrategy.ALL).placeholder(R.drawable.bili_default_image_tv).dontAnimate().into(mVideoPreview);
    loadData();
    mFAB.setClickable(false);
    mFAB.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.gray_20)));
    mFAB.setTranslationY(-getResources().getDimension(R.dimen.floating_action_button_size_half));
    mFAB.setOnClickListener(v -> VideoPlayerActivity.launch(VideoDetailsActivity.this, mVideoDetailsInfo.getPages().get(0).getCid(), mVideoDetailsInfo.getTitle()));
    mAppBarLayout.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> setViewsTranslation(verticalOffset));
    mAppBarLayout.addOnOffsetChangedListener(new AppBarStateChangeEvent() {

        @Override
        public void onStateChanged(AppBarLayout appBarLayout, State state, int verticalOffset) {
            if (state == State.EXPANDED) {
                //展开状态
                mTvPlayer.setVisibility(View.GONE);
                mAvText.setVisibility(View.VISIBLE);
                mToolbar.setContentInsetsRelative(DisplayUtil.dp2px(VideoDetailsActivity.this, 15), 0);
            } else if (state == State.COLLAPSED) {
                //折叠状态
                mTvPlayer.setVisibility(View.VISIBLE);
                mAvText.setVisibility(View.GONE);
                mToolbar.setContentInsetsRelative(DisplayUtil.dp2px(VideoDetailsActivity.this, 150), 0);
            } else {
                mTvPlayer.setVisibility(View.GONE);
                mAvText.setVisibility(View.VISIBLE);
                mToolbar.setContentInsetsRelative(DisplayUtil.dp2px(VideoDetailsActivity.this, 15), 0);
            }
        }
    });
}
Also used : AppBarStateChangeEvent(com.hotbitmapgg.bilibili.event.AppBarStateChangeEvent) Intent(android.content.Intent) AppBarLayout(android.support.design.widget.AppBarLayout) SuppressLint(android.annotation.SuppressLint) TextPaint(android.text.TextPaint)

Example 2 with AppBarStateChangeEvent

use of com.hotbitmapgg.bilibili.event.AppBarStateChangeEvent in project bilibili-android-client by HotBitmapGG.

the class UserInfoDetailsActivity method initToolBar.

@Override
public void initToolBar() {
    mToolbar.setTitle("");
    setSupportActionBar(mToolbar);
    ActionBar supportActionBar = getSupportActionBar();
    if (supportActionBar != null) {
        supportActionBar.setDisplayHomeAsUpEnabled(true);
    }
    //设置StatusBar透明
    SystemBarHelper.immersiveStatusBar(this);
    SystemBarHelper.setHeightAndPadding(this, mToolbar);
    //设置AppBar展开折叠状态监听
    mAppBarLayout.addOnOffsetChangedListener(new AppBarStateChangeEvent() {

        @Override
        public void onStateChanged(AppBarLayout appBarLayout, State state, int verticalOffset) {
            if (state == State.EXPANDED) {
                //展开状态
                mCollapsingToolbarLayout.setTitle("");
                mLineView.setVisibility(View.VISIBLE);
            } else if (state == State.COLLAPSED) {
                //折叠状态
                mCollapsingToolbarLayout.setTitle(name);
                mLineView.setVisibility(View.GONE);
            } else {
                mCollapsingToolbarLayout.setTitle("");
                mLineView.setVisibility(View.VISIBLE);
            }
        }
    });
}
Also used : AppBarStateChangeEvent(com.hotbitmapgg.bilibili.event.AppBarStateChangeEvent) AppBarLayout(android.support.design.widget.AppBarLayout) ActionBar(android.support.v7.app.ActionBar) TextPaint(android.text.TextPaint)

Aggregations

AppBarLayout (android.support.design.widget.AppBarLayout)2 TextPaint (android.text.TextPaint)2 AppBarStateChangeEvent (com.hotbitmapgg.bilibili.event.AppBarStateChangeEvent)2 SuppressLint (android.annotation.SuppressLint)1 Intent (android.content.Intent)1 ActionBar (android.support.v7.app.ActionBar)1