CountryCodePickerProject icon indicating copy to clipboard operation
CountryCodePickerProject copied to clipboard

[feature_request] custom xml layout for dialog and recyclerview

Open mohamedagamy opened this issue 5 years ago • 1 comments

please add the ability to inflate custom xml layout for dialog and recyclerview I need the ability to setRecycleviewCustomLayout , setDialogCustomLayout because I found that I must include the code to update small changes in xml layouts. also there should be xml attribute that control dialog width to be small or large Dialog. as customDialogWidth="large/small" waiting for your reply.

mohamedagamy avatar Jul 19 '20 17:07 mohamedagamy

I have made this extension function On CountryCodePicker Object in kotlin also I copied the following file for dialog layout and recyclerview layout only in my project layout_picker_dialog.xml layout_recycler_country_tile.xml also I used the custom decorator from another library MyDividerItemDecoration

fun CountryCodePicker.customizeDialog(context: Context){
    this.setDialogEventsListener(object : CountryCodePicker.DialogEventsListener {
        override fun onCcpDialogDismiss(dialogInterface: DialogInterface?) {
            dialogInterface?.cancel()
        }
        override fun onCcpDialogCancel(dialogInterface: DialogInterface?) {
            dialogInterface?.cancel()
        }
        override fun onCcpDialogOpen(dialog: Dialog?) {
            val window = dialog?.window
            //window?.setContentView(R.layout.layout_picker_dialog)
            window?.setLayout(
                WindowManager.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.MATCH_PARENT)

            val dividerDrawable = ContextCompat.getDrawable(context, R.drawable.divider_line)
            val recyclerViewCountry = dialog?.window?.decorView?.recycler_countryDialog
            recyclerViewCountry?.addItemDecoration(MyDividerItemDecoration(dividerDrawable))
            recyclerViewCountry?.adapter?.notifyDataSetChanged()
        }
    })
}

I need something like that to be added to the library.

mohamedagamy avatar Jul 19 '20 19:07 mohamedagamy