// Path: app/src/main/java/com/zsorg/neteasecloudmusic/LineItemDecorator.java
// public class LineItemDecorator extends RecyclerView.ItemDecoration {
// 
//     private static LineItemDecorator lineItemDecorator;
//     private int dimension;
//     private boolean isDrawHorizontal=false;
//     private boolean isDrawVertical=true;
// 
//     public LineItemDecorator() {
//         super();
//     }
// 
//     public void recycle() {
//         lineItemDecorator = null;
//     }
// 
//     public void setDrawHorizontal(boolean isDraw) {
//         isDrawHorizontal = isDraw;
//     }
// 
//     public void setDrawVertical(boolean isDraw) {
//         isDrawVertical = isDraw;
//     }
// 
//     public static LineItemDecorator getInstance() {
//         if (null == lineItemDecorator) {
//             synchronized (LineItemDecorator.class) {
//                 lineItemDecorator = new LineItemDecorator();
//             }
//         }
//         return lineItemDecorator;
//     }
// 
//     @Override
//     public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
//         super.getItemOffsets(outRect, view, parent, state);
//         if (isDrawVertical) {
//             outRect.top = 1;
// //        outRect.left = dimension;
// //        outRect.right = dimension;
//             outRect.bottom = 1;
//         }
//         if (isDrawHorizontal){
//             outRect.left = 1;
// //        outRect.left = dimension;
// //        outRect.right = dimension;
//             outRect.right = 1;
//         }
//     }
// 
// 
//     @Override
//     public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
//         super.onDraw(c, parent, state);
//         if (isDrawHorizontal) {
//             drawHrozontal(c, parent);
//         }
//         if (isDrawVertical){
//             drawVertical(c, parent);
//         }
//     }
// 
// 
// 
//     private void drawVertical(Canvas c, RecyclerView parent) {
//         int childCount = parent.getChildCount();
//         if (childCount<1)return;
// //        int left = parent.getPaddingLeft()+leftView.getLeft()+leftView.getPaddingLeft();
//         int left = parent.getPaddingLeft();
//         int right = parent.getWidth() - parent.getPaddingRight();
// 
//         Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
//         paint.setColor(Color.LTGRAY);
//         for (int i = 0; i < childCount; i++) {
//             View child = parent.getChildAt(i);
//             RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
//                     .getLayoutParams();
//             int top = child.getBottom()+params.bottomMargin;
//             int bottom = top + 1;
//             c.drawRect(left, top, right, bottom, paint);
//         }
//     }
// 
//     private void drawHrozontal(Canvas c, RecyclerView parent) {
//         int childCount = parent.getChildCount();
//         if (childCount<1)return;
// //        int left = parent.getPaddingLeft()+leftView.getLeft()+leftView.getPaddingLeft();
//         int top = parent.getPaddingTop();
//         int bottom = parent.getHeight() - parent.getPaddingBottom();
// 
//         Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
//         paint.setColor(Color.LTGRAY);
//         for (int i = 0; i < childCount-1; i++) {
//             View child = parent.getChildAt(i);
//             RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
//                     .getLayoutParams();
//             int left = child.getRight()+params.rightMargin;
//             int right = left + 1;
//             c.drawRect(left, top, right, bottom, paint);
// 
//         }
//     }
// 
// }
// 
// Path: app/src/main/java/com/zsorg/neteasecloudmusic/utils/ScreenUtil.java
// public class ScreenUtil {
// 
//     public static int getScreenHeight(Activity activity) {
//         DisplayMetrics displaymetrics = new DisplayMetrics();
//         activity.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
//         return displaymetrics.heightPixels;
//     }
// 
//     public static int getStatusBarHeight(Context context) {
//         int statusBarHeight = 0;
//         Resources res = context.getResources();
//         int resourceId = res.getIdentifier("status_bar_height", "dimen", "android");
//         if (resourceId > 0) {
//             statusBarHeight = res.getDimensionPixelSize(resourceId);
//         }
//         return statusBarHeight;
//     }
// }


import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.StyleRes;
import android.support.design.widget.BottomSheetBehavior;
import android.support.design.widget.BottomSheetDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import com.zsorg.neteasecloudmusic.LineItemDecorator;
import com.zsorg.neteasecloudmusic.R;
import com.zsorg.neteasecloudmusic.utils.ScreenUtil;
import butterknife.BindView;
import butterknife.ButterKnife;
        int measuredHeight = mParent.getMeasuredHeight();
        int height = ScreenUtil.getScreenHeight(activity) - ScreenUtil.getStatusBarHeight(getContext());

        measuredHeight = measuredHeight > height * 0.5 ? (int) (height * 0.5) : measuredHeight;

        mBehavior.setPeekHeight(measuredHeight);
        mBehavior.setHideable(true);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mParent.measure(0, 0);
    }

    private void init() {

        View view = View.inflate(getContext(), R.layout.bottom_sheet_playlist, null);
        setContentView(view);

        mParent = (View) view.getParent();
        mBehavior = BottomSheetBehavior.from(mParent);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        }

        ButterKnife.bind(this,view);

// Path: app/src/main/java/com/zsorg/neteasecloudmusic/LineItemDecorator.java
// public class LineItemDecorator extends RecyclerView.ItemDecoration {
// 
//     private static LineItemDecorator lineItemDecorator;
//     private int dimension;
//     private boolean isDrawHorizontal=false;
//     private boolean isDrawVertical=true;
// 
//     public LineItemDecorator() {
//         super();
//     }
// 
//     public void recycle() {
//         lineItemDecorator = null;
//     }
// 
//     public void setDrawHorizontal(boolean isDraw) {
//         isDrawHorizontal = isDraw;
//     }
// 
//     public void setDrawVertical(boolean isDraw) {
//         isDrawVertical = isDraw;
//     }
// 
//     public static LineItemDecorator getInstance() {
//         if (null == lineItemDecorator) {
//             synchronized (LineItemDecorator.class) {
//                 lineItemDecorator = new LineItemDecorator();
//             }
//         }
//         return lineItemDecorator;
//     }
// 
//     @Override
//     public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
//         super.getItemOffsets(outRect, view, parent, state);
//         if (isDrawVertical) {
//             outRect.top = 1;
// //        outRect.left = dimension;
// //        outRect.right = dimension;
//             outRect.bottom = 1;
//         }
//         if (isDrawHorizontal){
//             outRect.left = 1;
// //        outRect.left = dimension;
// //        outRect.right = dimension;
//             outRect.right = 1;
//         }
//     }
// 
// 
//     @Override
//     public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
//         super.onDraw(c, parent, state);
//         if (isDrawHorizontal) {
//             drawHrozontal(c, parent);
//         }
//         if (isDrawVertical){
//             drawVertical(c, parent);
//         }
//     }
// 
// 
// 
//     private void drawVertical(Canvas c, RecyclerView parent) {
//         int childCount = parent.getChildCount();
//         if (childCount<1)return;
// //        int left = parent.getPaddingLeft()+leftView.getLeft()+leftView.getPaddingLeft();
//         int left = parent.getPaddingLeft();
//         int right = parent.getWidth() - parent.getPaddingRight();
// 
//         Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
//         paint.setColor(Color.LTGRAY);
//         for (int i = 0; i < childCount; i++) {
//             View child = parent.getChildAt(i);
//             RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
//                     .getLayoutParams();
//             int top = child.getBottom()+params.bottomMargin;
//             int bottom = top + 1;
//             c.drawRect(left, top, right, bottom, paint);
//         }
//     }
// 
//     private void drawHrozontal(Canvas c, RecyclerView parent) {
//         int childCount = parent.getChildCount();
//         if (childCount<1)return;
// //        int left = parent.getPaddingLeft()+leftView.getLeft()+leftView.getPaddingLeft();
//         int top = parent.getPaddingTop();
//         int bottom = parent.getHeight() - parent.getPaddingBottom();
// 
//         Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
//         paint.setColor(Color.LTGRAY);
//         for (int i = 0; i < childCount-1; i++) {
//             View child = parent.getChildAt(i);
//             RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
//                     .getLayoutParams();
//             int left = child.getRight()+params.rightMargin;
//             int right = left + 1;
//             c.drawRect(left, top, right, bottom, paint);
// 
//         }
//     }
// 
// }
// 
// Path: app/src/main/java/com/zsorg/neteasecloudmusic/utils/ScreenUtil.java
// public class ScreenUtil {
// 
//     public static int getScreenHeight(Activity activity) {
//         DisplayMetrics displaymetrics = new DisplayMetrics();
//         activity.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
//         return displaymetrics.heightPixels;
//     }
// 
//     public static int getStatusBarHeight(Context context) {
//         int statusBarHeight = 0;
//         Resources res = context.getResources();
//         int resourceId = res.getIdentifier("status_bar_height", "dimen", "android");
//         if (resourceId > 0) {
//             statusBarHeight = res.getDimensionPixelSize(resourceId);
//         }
//         return statusBarHeight;
//     }
// }


// Path: app/src/main/java/com/zsorg/neteasecloudmusic/widgets/BaseBottomSheetDialog.java
import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.StyleRes;
import android.support.design.widget.BottomSheetBehavior;
import android.support.design.widget.BottomSheetDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import com.zsorg.neteasecloudmusic.LineItemDecorator;
import com.zsorg.neteasecloudmusic.R;
import com.zsorg.neteasecloudmusic.utils.ScreenUtil;
import butterknife.BindView;
import butterknife.ButterKnife;

        int measuredHeight = mParent.getMeasuredHeight();
        int height = ScreenUtil.getScreenHeight(activity) - ScreenUtil.getStatusBarHeight(getContext());

        measuredHeight = measuredHeight > height * 0.5 ? (int) (height * 0.5) : measuredHeight;

        mBehavior.setPeekHeight(measuredHeight);
        mBehavior.setHideable(true);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mParent.measure(0, 0);
    }

    private void init() {

        View view = View.inflate(getContext(), R.layout.bottom_sheet_playlist, null);
        setContentView(view);

        mParent = (View) view.getParent();
        mBehavior = BottomSheetBehavior.from(mParent);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        }

        ButterKnife.bind(this,view);

        LineItemDecorator decorator = LineItemDecorator.getInstance();