Add insert helper for SlidingDrawerLayout

This commit is contained in:
seven332 committed 2016-04-01 19:18:00 +08:00
1 parent 015bcce8a3
commit 250e1256b9
3 files changed
+69

No files matched your search

@@ -99,6 +99,16 @@ public class SlidingDrawerLayout extends ViewGroup implements ValueAnimator.Anim
Build.VERSION.SDK_INT >= 21;
private static final int DRAWER_ELEVATION = 10; //dp
private static final SlidingDrawerLayoutInsetsHelper INSETS_HELPER;
static {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
INSETS_HELPER = new SlidingDrawerLayoutInsetsHelperL();
} else {
INSETS_HELPER = null;
}
}
private float mDrawerElevation;
private int mMinDrawerMargin;
@@ -221,6 +231,10 @@ public class SlidingDrawerLayout extends ViewGroup implements ValueAnimator.Anim
mNavigationBarPaint.setColor(Color.BLACK);
setWillNotDraw(false);
if (INSETS_HELPER != null) {
INSETS_HELPER.setupForWindowInsets(this);
}
}
public void setDrawerListener(DrawerListener listener) {
@@ -0,0 +1,23 @@
/*
* Copyright 2016 Hippo Seven
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hippo.widget.slidingdrawerlayout;
import android.view.View;
public interface SlidingDrawerLayoutInsetsHelper {
void setupForWindowInsets(View view);
}
@@ -0,0 +1,32 @@
/*
* Copyright 2016 Hippo Seven
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hippo.widget.slidingdrawerlayout;
import android.support.v4.view.ViewCompat;
import android.view.View;
public class SlidingDrawerLayoutInsetsHelperL implements SlidingDrawerLayoutInsetsHelper {
@Override
public void setupForWindowInsets(View view) {
if (ViewCompat.getFitsSystemWindows(view)) {
// Now set the sys ui flags to enable us to lay out in the window insets
view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
}
}