Created
June 30, 2017 09:36
-
-
Save vtthach/7257c21cb02e4a905afca3c953c24ac1 to your computer and use it in GitHub Desktop.
Bottom dialog select phooto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.piing.fragment.dialog; | |
import android.app.Dialog; | |
import android.graphics.drawable.ColorDrawable; | |
import android.os.Bundle; | |
import android.support.v4.app.DialogFragment; | |
import android.view.Gravity; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.view.Window; | |
import com.piing.R; | |
import butterknife.ButterKnife; | |
import butterknife.OnClick; | |
/** | |
* Created by Thach.Vo on 7/23/2015. | |
*/ | |
public class DialogChoosePhotoMethodFragment extends DialogFragment { | |
private IChoosePhotoMethodCallback mCallback; | |
@Override | |
public View onCreateView(LayoutInflater inflater, ViewGroup container, | |
Bundle savedInstanceState) { | |
requestLayoutDialog(); | |
View view = inflater.inflate(getLayoutId(), null); | |
ButterKnife.bind(this, view); | |
return view; | |
} | |
@Override | |
public void onDestroyView() { | |
super.onDestroyView(); | |
ButterKnife.unbind(this); | |
} | |
private void requestLayoutDialog() { | |
getDialog().getWindow().setGravity(Gravity.BOTTOM); | |
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); | |
getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE); | |
getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); | |
} | |
private int getLayoutId() { | |
return R.layout.fragment_dialog_choose_photo_method; | |
} | |
@Override | |
public void onStart() { | |
super.onStart(); | |
Dialog dialog = getDialog(); | |
if (dialog != null) { | |
int width = ViewGroup.LayoutParams.MATCH_PARENT; | |
int height = ViewGroup.LayoutParams.WRAP_CONTENT; | |
dialog.getWindow().setLayout(width, height); | |
getDialog().getWindow().setWindowAnimations(R.style.bottom_sheet_dialog_anim); | |
} | |
} | |
@OnClick(R.id.tv_1) | |
public void onChooseCamera() { | |
if (mCallback != null) { | |
mCallback.onChooseCamera(); | |
} | |
dismiss(); | |
} | |
@OnClick(R.id.tv_2) | |
public void onChooseGallery() { | |
if (mCallback != null) { | |
mCallback.onChooseGallery(); | |
} | |
dismiss(); | |
} | |
@OnClick(R.id.tv_3) | |
public void onCancelButtonClicked() { | |
dismiss(); | |
} | |
public void setCallback(IChoosePhotoMethodCallback callback) { | |
this.mCallback = callback; | |
} | |
public interface IChoosePhotoMethodCallback { | |
void onChooseGallery(); | |
void onChooseCamera(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment