hbb20 / CountryCodePickerProject

Country Code Picker (CCP) is an android library which provides an easy way to search and select country or international phone code. Also supports Android EditText phone mask and international phone validation.
Apache License 2.0
1.51k stars 503 forks source link

[feature_request] custom xml layout for dialog and recyclerview #424

Open mohamedagamy opened 4 years ago

mohamedagamy commented 4 years ago

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 commented 4 years ago

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.