1/* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.support.design.widget; 18 19import android.content.Intent; 20import android.support.design.test.R; 21import android.widget.LinearLayout; 22 23 24public class BottomSheetBehaviorActivity extends BaseTestActivity { 25 26 public static String EXTRA_INITIAL_STATE = "initial_state"; 27 28 CoordinatorLayout mCoordinatorLayout; 29 30 LinearLayout mBottomSheet; 31 32 BottomSheetBehavior mBehavior; 33 34 FloatingActionButton mFab; 35 36 @Override 37 protected int getContentViewLayoutResId() { 38 return R.layout.test_design_bottom_sheet_behavior; 39 } 40 41 @Override 42 protected void onContentViewSet() { 43 mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinator); 44 mBottomSheet = (LinearLayout) findViewById(R.id.bottom_sheet); 45 mBehavior = BottomSheetBehavior.from(mBottomSheet); 46 mFab = (FloatingActionButton) findViewById(R.id.fab); 47 Intent intent = getIntent(); 48 if (intent != null) { 49 int initialState = intent.getIntExtra(EXTRA_INITIAL_STATE, -1); 50 if (initialState != -1) { 51 //noinspection ResourceType 52 mBehavior.setState(initialState); 53 } 54 } 55 } 56 57} 58