Java Code Examples for android.support.design.widget.AppBarLayout#addOnOffsetChangedListener()

The following examples show how to use android.support.design.widget.AppBarLayout#addOnOffsetChangedListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java    From FlexibleSearchBar with Apache License 2.0 6 votes vote down vote up
private void initView() {
    ActionBar supportActionBar = getSupportActionBar();
    if (supportActionBar != null) {
        supportActionBar.hide();
    }
    searchbarview = (SearchBarView) findViewById(R.id.searchbarview);
    searchbarview.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // enter search activity
            Toast.makeText(MainActivity.this, "enter search activity", Toast.LENGTH_SHORT).show();
        }
    });
    AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.appbarlayout);
    appBarLayout.addOnOffsetChangedListener(this);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    RecyclerView mRecyclerView = (RecyclerView) findViewById(R.id.recyclerview);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.setVerticalScrollBarEnabled(true);
    mRecyclerView.setNestedScrollingEnabled(false);
    mRecyclerView.setAdapter(new MyAdapter());
}
 
Example 2
Source File: MainActivity.java    From QuickLyric with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
    if (nfcAdapter != null) {
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, ((Object) this).getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
        IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
        try {
            ndef.addDataType("application/lyrics");
        } catch (IntentFilter.MalformedMimeTypeException e) {
            return;
        }
        IntentFilter[] intentFiltersArray = new IntentFilter[]{ndef,};
        try {
            nfcAdapter.enableForegroundDispatch(this, pendingIntent, intentFiltersArray, null);
        } catch (Exception ignored) {
        }
    }
    updatePrefsChanges();
    AppBarLayout appBarLayout = findViewById(id.appbar);
    appBarLayout.removeOnOffsetChangedListener(this);
    appBarLayout.addOnOffsetChangedListener(this);
}
 
Example 3
Source File: UserProfileActivity.java    From AndroidMaterialDesign with Apache License 2.0 6 votes vote down vote up
protected void initViews() {
    tvLeft = (TextView) findViewById(R.id.tv_title);
    tvName = (TextView) findViewById(R.id.tv_name);
    ivAvatar = (ImageView) findViewById(R.id.iv_avatar);
    ivCover = (ImageView) findViewById(R.id.iv_avatar_cover);
    ivBlur = (ImageView) findViewById(R.id.iv_title_blur);
    viewBlurMask = findViewById(R.id.view_blur_mask);

    animFromBottom = AnimationUtils.loadAnimation(this, R.anim.slide_from_bottom);
    appBarLayout = (AppBarLayout) findViewById(R.id.main_appbar);
    appBarLayout.addOnOffsetChangedListener(this);

    viewPager = (ViewPager) findViewById(R.id.viewpager);
    tabLayout = (TabLayout) findViewById(R.id.tl_tab_layout);
    initTabTitles();

    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            generateToolbarBlurImg();
        }
    }, 1000);


}
 
Example 4
Source File: ScrimHelper.java    From ForPDA with GNU General Public License v3.0 6 votes vote down vote up
public ScrimHelper(AppBarLayout appBarLayout, CollapsingToolbarLayout toolbarLayout) {
    appBarLayout.addOnOffsetChangedListener((appBarLayout1, verticalOffset) -> {
        if (scrimListener == null) return;
        if (appBarLayout1.getHeight() + verticalOffset <= toolbarLayout.getScrimVisibleHeightTrigger()) {
            if (!scrim) {
                scrim = true;
                scrimListener.onScrimChanged(true);
            }
        } else {
            if (scrim) {
                scrim = false;
                scrimListener.onScrimChanged(false);
            }
        }
    });
}
 
Example 5
Source File: MainActivity.java    From CollapsingToolbar-With-Webview with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mToolbar = (Toolbar) findViewById(R.id.mainToolbar);
    textToolBarUserName = (TextView) findViewById(R.id.textToolBarUserName);
    textUserName = (TextView) findViewById(R.id.textUserName);
    imageToolBar = (CircleImageView) findViewById(R.id.imageToolBar);
    imageProfile = (CircleImageView) findViewById(R.id.imageProfile);
    mTitleContainer = (RelativeLayout) findViewById(R.id.relativeLayoutTitle);
    mAppBarLayout = (AppBarLayout) findViewById(R.id.mainAppbar);
    webView = (WebView) findViewById(R.id.webView);
    mAppBarLayout.addOnOffsetChangedListener(this);
    startAlphaAnimation(textToolBarUserName, 0, View.INVISIBLE);
    startAlphaAnimation(imageToolBar, 0, View.INVISIBLE);


    webView.setWebViewClient(new MyWebViewClient());
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    webView.loadUrl("http://docs.google.com/gview?embedded=true&url=https://static.googleusercontent.com/media/www.google.com/en//pdf/google_ftc_dec2012.pdf");
    webView.getSettings().setLoadsImagesAutomatically(true);




}
 
Example 6
Source File: CollapsingToolbarLayoutActivity.java    From Android-skin-support with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_collapsing_toolbar_layout);
    mIvPlaceholder = (ImageView) findViewById(R.id.main_iv_placeholder);
    mLlTitleContainer = (LinearLayout) findViewById(R.id.main_ll_title_container);
    mFlTitleContainer = (FrameLayout) findViewById(R.id.main_fl_title);
    mAblAppBar = (AppBarLayout) findViewById(R.id.main_abl_app_bar);
    mTvToolbarTitle = (TextView) findViewById(R.id.main_tv_toolbar_title);
    mTbToolbar = (Toolbar) findViewById(R.id.main_tb_toolbar);
    mTbToolbar.setTitle("");

    // AppBar的监听
    mAblAppBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            int maxScroll = appBarLayout.getTotalScrollRange();
            float percentage = (float) Math.abs(verticalOffset) / (float) maxScroll;
            handleAlphaOnTitle(percentage);
            handleToolbarTitleVisibility(percentage);
        }
    });

    findViewById(R.id.small_photo).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            startActivity(new Intent(CollapsingToolbarLayoutActivity.this, SettingsActivity.class));
        }
    });

    initParallaxValues(); // 自动滑动效果
}
 
Example 7
Source File: SheetDetailActivity.java    From Musicoco with Apache License 2.0 5 votes vote down vote up
private void initSelfView() {
    toolbar = (Toolbar) findViewById(R.id.sheet_detail_toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    toTop = (FloatingActionButton) findViewById(R.id.sheet_detail_top);
    initToTopPos();

    songList = (RecyclerView) findViewById(R.id.sheet_detail_songs_list);
    appBarLayout = (AppBarLayout) findViewById(R.id.sheet_detail_app_bar);
    collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.sheet_detail_toolbar_layout);
    barStateChangeListener = new AppBarStateChangeListener() {
        @Override
        public void onStateChanged(AppBarLayout appBarLayout, State state) {
            switch (state) {
                case EXPANDED:
                    collapsingToolbarLayout.setTitle(" ");
                    songList.setNestedScrollingEnabled(false);
                    transToTopBt(true);
                    break;
                case COLLAPSED:
                    collapsingToolbarLayout.setTitle(infoController.getTitle());
                    songList.setNestedScrollingEnabled(true);
                    toTop.setVisibility(View.VISIBLE);
                    transToTopBt(false);
                    break;
                case IDLE:
                    collapsingToolbarLayout.setTitle(" ");
                    break;
            }
        }
    };
    appBarLayout.addOnOffsetChangedListener(barStateChangeListener);

}
 
Example 8
Source File: ScrollingActivity.java    From journaldev with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scrolling);
    final Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    AppBarLayout mAppBarLayout = (AppBarLayout) findViewById(R.id.app_bar);
    mAppBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
        boolean isShow = false;
        int scrollRange = -1;

        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            if (scrollRange == -1) {
                scrollRange = appBarLayout.getTotalScrollRange();
            }
            if (scrollRange + verticalOffset == 0) {
                isShow = true;
                showOption(R.id.action_info);
            } else if (isShow) {
                isShow = false;
                hideOption(R.id.action_info);
            }
        }
    });
}
 
Example 9
Source File: ViewPagerNew.java    From CoordinatorLayoutExample with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_pager_new);
    mView = findViewById(R.id.view);
    ll_content = findViewById(R.id.ll_content);
    mViewPager = (ViewPager) findViewById(R.id.viewpager);
    mAppBarLayout = (AppBarLayout) findViewById(R.id.appBar);

    mView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {


        @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
        @Override
        public void onGlobalLayout() {
            mView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            mHeight = findViewById(R.id.headview).getHeight();
            mHeightContent = ll_content.getHeight() - findViewById(R.id.tabs).getHeight();

            WriteLogUtil.i(" mHeight=" + mHeight);
            WriteLogUtil.i(" mHeightContent=" + mHeightContent);
        }
    });

    mAppBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            int abs = Math.abs(verticalOffset);
        }
    });


    setupViewPager();
}
 
Example 10
Source File: MainActivity.java    From adjustablelayout with Apache License 2.0 5 votes vote down vote up
private void initAppBarLayout(){
    LayoutTransition mTransition = new LayoutTransition();
    /**
     * 添加View时过渡动画效果
     */
    ObjectAnimator addAnimator = ObjectAnimator.ofFloat(null, "translationY", 0, 1.f).
            setDuration(mTransition.getDuration(LayoutTransition.APPEARING));
    mTransition.setAnimator(LayoutTransition.APPEARING, addAnimator);

    //header layout height
    final int headerHeight = getResources().getDimensionPixelOffset(R.dimen.header_height);
    mAppBarLayout = (AppBarLayout) findViewById(R.id.appbar);
    mAppBarLayout.setLayoutTransition(mTransition);

    mAppBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            verticalOffset = Math.abs(verticalOffset);
            if ( verticalOffset >= headerHeight ){
                isHideHeaderLayout = true;
                //当偏移量超过顶部layout的高度时,我们认为他已经完全移动出屏幕了
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        AppBarLayout.LayoutParams mParams = (AppBarLayout.LayoutParams) headerLayout.getLayoutParams();
                        mParams.setScrollFlags(0);
                        headerLayout.setLayoutParams(mParams);
                        headerLayout.setVisibility(View.GONE);
                    }
                },100);
            }
        }
    });
}
 
Example 11
Source File: AppbarRefreshLayout.java    From FastAccess with GNU General Public License v3.0 5 votes vote down vote up
@Override protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    if (getContext() instanceof Activity) {
        appBarLayout = (AppBarLayout) ((Activity) getContext()).findViewById(R.id.appbar);
        if (appBarLayout != null) {
            appBarLayout.addOnOffsetChangedListener(this);
        }
    }
}
 
Example 12
Source File: VideoPlayActivity.java    From meiShi with Apache License 2.0 5 votes vote down vote up
private void initView() {
    toolbar= (Toolbar) findViewById(R.id.tool_bar);
    setUpCommonBackTooblBar(R.id.tool_bar, "视频播放");
    appBarLayout = (AppBarLayout) findViewById(R.id.appbar);
    appBarLayout.addOnOffsetChangedListener(this);
    CollapsingToolbarLayout collapsing_toolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    ViewCompat.requestApplyInsets(collapsing_toolbar);
    collapsing_toolbar.setTitleEnabled(false);
    collapsing_toolbar.setExpandedTitleColor(Color.TRANSPARENT);
    resetCollapsingToolbarLayout(collapsing_toolbar);
    mVideoPlayHeader = new VideoPlayHeader(this, findViewById(R.id.video_header));
    initRecyclerView();
}
 
Example 13
Source File: ScrollingSearchExampleFragment.java    From floatingsearchview with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mSearchView = (FloatingSearchView) view.findViewById(R.id.floating_search_view);
    mAppBar = (AppBarLayout) view.findViewById(R.id.appbar);

    mAppBar.addOnOffsetChangedListener(this);

    setupDrawer();
    setupSearchBar();
}
 
Example 14
Source File: CustomBehaviorActivity.java    From CoordinatorLayoutSample with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_custom_behavior);

    mHeader = findViewById(R.id.activity_custom_behavior_header);

    AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.appbar);
    appBarLayout.addOnOffsetChangedListener(this);

    ImageView teamImage = (ImageView) findViewById(R.id.custom_behavior_image_teamA);
    teamImage.setColorFilter(Color.BLUE, PorterDuff.Mode.SRC_IN);

}
 
Example 15
Source File: ScrollingActivity.java    From XPlayer2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scrolling);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    mCollapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.toolbar_layout);
    mCollapsingToolbarLayout.setTitle("XPlayer");

    mAppBarLayout = (AppBarLayout) findViewById(R.id.app_bar);
    mAppBarLayout.addOnOffsetChangedListener(this);

    videoUrl = "http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f30.mp4";

    mSmallVideoView = findViewById(R.id.drag_video_view);
    mVideoView = findViewById(R.id.video_view);

    mMediaPlayer = XMediaPlayerDelegate.getInstance();

    mSmallVideoView.setMediaPlayer(mMediaPlayer);
    mSmallVideoView.setDisplayAspectRatio(IXRenderView.AR_MATCH_PARENT);

    mVideoView.setMediaPlayer(mMediaPlayer);
    mVideoView.setDisplayAspectRatio(IXRenderView.AR_MATCH_PARENT);

    mMediaPlayer.setVideoPath(videoUrl);
    mMediaPlayer.setLooping(false);
    mMediaPlayer.play();
}
 
Example 16
Source File: AlipayHomeActivity.java    From LRecyclerView with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_alipay_home);

    StatusBarUtil.setColor(AlipayHomeActivity.this, ContextCompat.getColor(this,R.color.blue_black), 0);

    //AppBarLayout
    abl_bar = (AppBarLayout) findViewById(R.id.abl_bar);
    abl_bar.addOnOffsetChangedListener(this);
    //顶部搜索布局
    include_toolbar_search = findViewById(R.id.include_toolbar_search);
    //扫一扫 付一付 聊一聊 咻一咻 的小图标布局
    include_toolbar_small = findViewById(R.id.include_toolbar_small);


    //顶部搜索布局遮罩
    v_toolbar_search_mask = findViewById(R.id.v_toolbar_search_mask);
    //扫一扫 付一付 聊一聊 咻一咻 的大图标布局遮罩
    v_title_big_mask = findViewById(R.id.v_title_big_mask);
    //扫一扫 付一付 聊一聊 咻一咻 的大图标布局遮罩
    v_toolbar_small_mask = findViewById(R.id.v_toolbar_small_mask);
    //背景颜色
    mMaskColor = getResources().getColor(R.color.blue_dark);


    mRecyclerView = findViewById(R.id.list);
    //init data
    ArrayList<ItemModel> dataList = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        ItemModel itemModel = new ItemModel();
        itemModel.title = "item" + i;
        dataList.add(itemModel);
    }

    mDataAdapter = new DataAdapter(this);
    mDataAdapter.setDataList(dataList);

    mLRecyclerViewAdapter = new LRecyclerViewAdapter(mDataAdapter);
    mRecyclerView.setAdapter(mLRecyclerViewAdapter);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    //禁用自动加载更多功能
    mRecyclerView.setLoadMoreEnabled(false);

    SampleFooter sampleFooter = new SampleFooter(this);
    //add a FooterView
    mLRecyclerViewAdapter.addFooterView(sampleFooter);

    mRecyclerView.setOnRefreshListener(new OnRefreshListener() {
        @Override
        public void onRefresh() {

            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    mRecyclerView.refreshComplete(10);
                }
            }, 800);

        }
    });

}
 
Example 17
Source File: ViewPagerParallax2.java    From CoordinatorLayoutExample with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_four2);
    mAppBarLayout = (AppBarLayout) findViewById(R.id.mainappbar);
    mViewPager = (ViewPager) findViewById(R.id.viewpager);

    mTitle =  findViewById(R.id.rl_title);
    mTitle.setVisibility(View.GONE);


    setupViewPager();

    AppBarStateChangeListener listener = new AppBarStateChangeListener();
    listener.setOnStateChangedListener(new AppBarStateChangeListener.OnStateChangedListener() {
        @Override
        public void onExpanded() {
            Log.i(TAG, "onExpanded: =");
            mTitle.setVisibility(View.GONE);
        }

        @Override
        public void onCollapsed() {
            Log.i(TAG, "onCollapsed: =");
            mTitle.setVisibility(View.VISIBLE);
        }

        @Override
        public void onInternediateFromExpand() {
            Log.i(TAG, "onInternediateFromExpand: =");
            mTitle.setVisibility(View.GONE);
        }

        @Override
        public void onInternediateFromCollapsed() {
            Log.i(TAG, "onInternediateFromCollapsed: =");
            mTitle.setVisibility(View.GONE);
        }

        @Override
        public void onInternediate() {

        }
    });
    mAppBarLayout.addOnOffsetChangedListener(listener);
}
 
Example 18
Source File: BlurZoomCoordinatorLayout.java    From BlurZoomGallery with MIT License 4 votes vote down vote up
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);

    appBarLayout = (AppBarLayout) findViewById(R.id.gallery_coordinator_appbarlayout);
    if(appBarLayout == null) {
        throw new IllegalStateException("No AppBarLayout found in BlurZoomCoordinatorLayout");
    }

    scrollView = findViewById(R.id.gallery_coordinator_scroll);
    if(scrollView == null) {
        throw new IllegalStateException("No scrolling view found in BlurZoomCoordinatorLayout");
    }

    toolbar = findViewById(R.id.gallery_coordinator_toolbar);
    if(toolbar == null) {
        throw new IllegalStateException("No toolbar found in BlurZoomCoordinatorLayout");
    }

    placeholder = findViewById(R.id.gallery_coordinator_placeholder);
    if(placeholder == null) {
        throw new IllegalStateException("No placeholder view found in scrolling view in BlurZoomCoordinatorLayout");
    }

    galleryContainerView = findViewById(R.id.gallery_coordinator_gallery_container);
    if(galleryContainerView == null) {
        throw new IllegalStateException("No gallery container view found in BlurZoomCoordinatorLayout");
    }

    galleryView = galleryContainerView.findViewById(R.id.gallery_coordinator_gallery);
    if(galleryView == null) {
        throw new IllegalStateException("No gallery view found in container in BlurZoomCoordinatorLayout");
    }

    prepareViews();

    prepareHeights();

    appBarLayout.addOnOffsetChangedListener(offsetChangedListener);

    appBarLayout.setOnClickListener(expandListener);
}
 
Example 19
Source File: CommentsActivity.java    From Hews with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Set theme
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    String theme = SharedPrefsManager.getTheme(prefs);
    switch (theme) {
        case SharedPrefsManager.THEME_SEPIA:
            setTheme(R.style.AppTheme_Sepia);
            break;
        case SharedPrefsManager.THEME_DARK:
            setTheme(R.style.AppTheme_Dark);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                getWindow().setStatusBarColor(getResources().getColor(R.color.grey_900));
            }
            break;
        case SharedPrefsManager.THEME_AMOLED_BLACK:
            setTheme(R.style.AppTheme_AMOLEDBlack);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                getWindow().setStatusBarColor(getResources().getColor(android.R.color.black));
            }
            break;
    }
    setContentView(R.layout.activity_comments);
    Firebase.setAndroidContext(this);
    appbar = (AppBarLayout) findViewById(R.id.appbar);
    appbar.addOnOffsetChangedListener(this);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setTitle("Comments");
        actionBar.setHomeButtonEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    mWindow = new PopupFloatingWindow(this, toolbar);
    mFab = (FloatingScrollDownButton) findViewById(R.id.fab);
    coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinator_layout);
    layoutReply = (LinearLayout) findViewById(R.id.layout_reply);
    btnReplySend = (FloatingActionButton) findViewById(R.id.btn_reply_send);
    etReply = (EditText) findViewById(R.id.et_reply);

    Intent intent = getIntent();
    CommentsFragment commentsFragment = null;
    Parcelable postParcel = intent.getParcelableExtra(Constants.KEY_POST_PARCEL);
    if (postParcel != null) {
        commentsFragment = CommentsFragment.newInstance(postParcel,
            intent.getBooleanExtra(Constants.KEY_IS_BOOKMARKED, false));
        Post post = Parcels.unwrap(postParcel);
        //FIXME how the url could be null?!
        mUrl = (post.getUrl() != null ? post.getUrl() : "https://news.ycombinator.com/");
        mPostId = post.getId();
    } else {
        final Uri data = intent.getData();
        if (data != null && data.getQueryParameter("id") != null) {
            long storyId = Long.parseLong(data.getQueryParameter("id"));
            commentsFragment = CommentsFragment.newInstance(storyId);
            mPostId = storyId;
        }
    }

    if (savedInstanceState == null) {
        if (commentsFragment != null) {
            getFragmentManager().beginTransaction()
                .add(R.id.container, commentsFragment, Constants.FRAGMENT_TAG_COMMENT)
                .commit();
        }
    }

    mDataManager = new DataManager();
    mCompositeSubscription = new CompositeSubscription();
}