mirror of https://github.com/FongMi/TV.git
parent
fac6c9acc0
commit
b4af82bd0e
@ -0,0 +1,64 @@ |
||||
package com.fongmi.android.tv.ui.custom.dialog; |
||||
|
||||
import android.app.Dialog; |
||||
import android.content.DialogInterface; |
||||
import android.os.Bundle; |
||||
import android.view.LayoutInflater; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
import android.view.WindowManager; |
||||
import android.widget.FrameLayout; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.annotation.Nullable; |
||||
import androidx.viewbinding.ViewBinding; |
||||
|
||||
import com.fongmi.android.tv.utils.Utils; |
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior; |
||||
import com.google.android.material.bottomsheet.BottomSheetDialog; |
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment; |
||||
|
||||
public abstract class BaseDialog extends BottomSheetDialogFragment { |
||||
|
||||
protected abstract ViewBinding getBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup container); |
||||
|
||||
@Nullable |
||||
@Override |
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
||||
return getBinding(inflater, container).getRoot(); |
||||
} |
||||
|
||||
@Override |
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
||||
initView(); |
||||
initEvent(); |
||||
} |
||||
|
||||
protected void initView() { |
||||
} |
||||
|
||||
protected void initEvent() { |
||||
} |
||||
|
||||
@NonNull |
||||
@Override |
||||
public Dialog onCreateDialog(Bundle savedInstanceState) { |
||||
BottomSheetDialog dialog = (BottomSheetDialog) super.onCreateDialog(savedInstanceState); |
||||
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); |
||||
dialog.setOnShowListener((DialogInterface f) -> setBehavior(dialog)); |
||||
return dialog; |
||||
} |
||||
|
||||
private void setBehavior(BottomSheetDialog dialog) { |
||||
FrameLayout bottomSheet = dialog.findViewById(com.google.android.material.R.id.design_bottom_sheet); |
||||
BottomSheetBehavior<FrameLayout> behavior = BottomSheetBehavior.from(bottomSheet); |
||||
behavior.setState(BottomSheetBehavior.STATE_EXPANDED); |
||||
behavior.setSkipCollapsed(true); |
||||
} |
||||
|
||||
@Override |
||||
public void onResume() { |
||||
super.onResume(); |
||||
Utils.hideSystemUI(getDialog().getWindow()); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue