package pl.temomuko.autostoprace.ui.post;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.BottomSheetDialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import butterknife.ButterKnife;
import butterknife.OnClick;
import pl.temomuko.autostoprace.R;
import pl.temomuko.autostoprace.data.local.photo.ImageSourceType;

public class PhotoSourceChooserBottomSheet extends BottomSheetDialogFragment {

    public static final String TAG = PhotoSourceChooserBottomSheet.class.getSimpleName();

    public static PhotoSourceChooserBottomSheet newInstance() {
        return new PhotoSourceChooserBottomSheet();
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.photo_source_chooser_bottom_sheet, container);
        ButterKnife.bind(this, view);
        return view;
    }

    @OnClick({R.id.upload_photo_linear_layout, R.id.take_photo_linear_layout, R.id.cancel_linear_layout})
    public void onClick(View view) {
        Activity callingActivity = getActivity();
        try {
            OnPhotoSourceSelectedListener listener = (OnPhotoSourceSelectedListener) callingActivity;
            switch (view.getId()) {
                case R.id.upload_photo_linear_layout:
                    listener.onImageSourceSelected(ImageSourceType.GALLERY);
                    break;
                case R.id.take_photo_linear_layout:
                    listener.onImageSourceSelected(ImageSourceType.CAMERA);
                    break;
            }
            dismiss();
        } catch (ClassCastException e) {
            throw new ClassCastException(callingActivity.toString()
                    + " must implement OnMediaOptionsSelectedListener");
        }
    }

    public interface OnPhotoSourceSelectedListener {

        void onImageSourceSelected(ImageSourceType imageSourceType);
    }
}

@@ -131,24 +131,138 @@
 n.Nullable;%0A
+import android.support.design.widget.BottomSheetBehavior;%0Aimport android.support.design.widget.BottomSheetDialog;%0A
 import andro
@@ -313,16 +313,16 @@
 agment;%0A
-
 import a
@@ -1145,16 +1145,51 @@
 , view);
+%0A%0A        disableBottomSheetPeek();
 %0A       
@@ -2086,16 +2086,16 @@
 ener%22);%0A
-
         
@@ -2099,24 +2099,441 @@
    %7D%0A    %7D%0A%0A
+    private void disableBottomSheetPeek() %7B%0A        getDialog().setOnShowListener(dialog -%3E %7B%0A            BottomSheetDialog bottomSheetDialog = (BottomSheetDialog) dialog;%0A            View bottomSheetInternal = bottomSheetDialog.findViewById(android.support.design.R.id.design_bottom_sheet);%0A            BottomSheetBehavior.from(bottomSheetInternal).setPeekHeight(bottomSheetInternal.getHeight());%0A        %7D);%0A    %7D%0A%0A
     public i

Disable bottom sheet peek