How to add FlowException inside Flow in Corda? - corda

I am trying to add FlowException inside Corda Flow.
I have added the following part in my code. This is always true. I just want to display the message "Trade id already available"
val a : Int = 10
val b : Int = 10
if (a == b){
throw FlowException("Trade id already available")
}
When i run the code, since Flows end pre-maturely due to exceptions, it should dispays the Flow exception error. But only thing it is doing is ending the flow not displaying the message
My complete code is:
object ExampleFlow {
#InitiatingFlow
#StartableByRPC
class Initiator(val iouValue: Int,
val otherParty: Party) : FlowLogic<SignedTransaction>() {
#Suspendable
override fun call(): SignedTransaction {
// Obtain a reference to the notary we want to use.
val notary = serviceHub.networkMapCache.notaryIdentities[0]
val a : Int = 10
val b : Int = 10
if (a == b){
throw FlowException("Trade id already available")
}
val iouState = IOUState(iouValue, serviceHub.myInfo.legalIdentities.first(), otherParty)
val txCommand = Command(IOUContract.Commands.Create(), iouState.participants.map { it.owningKey })
val txBuilder = TransactionBuilder(notary)
.addOutputState(iouState, IOUContract.ID)
.addCommand(txCommand)
txBuilder.verify(serviceHub)
val partSignedTx = serviceHub.signInitialTransaction(txBuilder)
val otherPartySession = initiateFlow(otherParty)
val fullySignedTx = subFlow(CollectSignaturesFlow(partSignedTx, setOf(otherPartySession), GATHERING_SIGS.childProgressTracker()))
return subFlow(FinalityFlow(fullySignedTx, setOf(otherPartySession), FINALISING_TRANSACTION.childProgressTracker()))
}
}
#InitiatedBy(Initiator::class)
class Acceptor(val otherPartySession: FlowSession) : FlowLogic<SignedTransaction>() {
#Suspendable
override fun call(): SignedTransaction {
val signTransactionFlow = object : SignTransactionFlow(otherPartySession) {
override fun checkTransaction(stx: SignedTransaction) = requireThat {
val output = stx.tx.outputs.single().data
"This must be an IOU transaction." using (output is IOUState)
val iou = output as IOUState
"I won't accept IOUs with a value over 100." using (iou.value <= 100)
}
}
val txId = subFlow(signTransactionFlow).id
return subFlow(ReceiveFinalityFlow(otherPartySession, expectedTxId = txId))
}
}
}

It worked for me, I used the same code as yours:
#Suspendable
override fun call(): SignedTransaction {
// Obtain a reference to the notary we want to use.
val notary = serviceHub.networkMapCache.notaryIdentities[0]
val a : Int = 10
val b : Int = 10
if (a == b){
throw FlowException("Trade id already available")
}
// Stage 1.
progressTracker.currentStep = GENERATING_TRANSACTION
// Generate an unsigned transaction.
val iouState = IOUState(iouValue, serviceHub.myInfo.legalIdentities.first(), otherParty)
val txCommand = Command(IOUContract.Commands.Create(), iouState.participants.map { it.owningKey })
val txBuilder = TransactionBuilder(notary)
.addOutputState(iouState, IOUContract.ID)
.addCommand(txCommand)
// Stage 2.
progressTracker.currentStep = VERIFYING_TRANSACTION
// Verify that the transaction is valid.
txBuilder.verify(serviceHub)
// Stage 3.
progressTracker.currentStep = SIGNING_TRANSACTION
// Sign the transaction.
val partSignedTx = serviceHub.signInitialTransaction(txBuilder)
// Stage 4.
progressTracker.currentStep = GATHERING_SIGS
// Send the state to the counterparty, and receive it back with their signature.
val otherPartySession = initiateFlow(otherParty)
val fullySignedTx = subFlow(CollectSignaturesFlow(partSignedTx, setOf(otherPartySession), GATHERING_SIGS.childProgressTracker()))
// Stage 5.
progressTracker.currentStep = FINALISING_TRANSACTION
// Notarise and record the transaction in both parties' vaults.
return subFlow(FinalityFlow(fullySignedTx, setOf(otherPartySession), FINALISING_TRANSACTION.childProgressTracker()))
}
Here's the node shell:

Related

Set a high quality picture from camera in Kotlin inside a fragment

My problem is that I am getting an extremely low-quality picture from the camera when I display it on the imageView. The size of imageView is set to 250dpx250dp in the .xml.
Here is my code for capturing camera image:
class Category_Description : Fragment() {
var mBitmap: Bitmap? = null
private val ALL_PERMISSIONS_RESULT = 107
private val IMAGE_RESULT = 200
private val REQUEST_IMAGE_CAPTURE = 12345
var photo: Bitmap?=null
var resizedPhoto:Bitmap?=null
var imageUri: Uri?=null
var filePath:String?=null
var cursor:Cursor?=null
var reqFile:RequestBody?=null
var intermediate:String?=null
var outputFileUri: Uri? = null
var camera_FAB: FloatingActionButton? = null
var upload_FAB: FloatingActionButton? = null
var imageView:ImageView?= null
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
// val permissions = arrayOf(android.Manifest.permission.WRITE_EXTERNAL_STORAGE, android.Manifest.permission.READ_EXTERNAL_STORAGE,
// android.Manifest.permission.CAMERA)
// requestPermissions( permissions,1)
val v = inflater.inflate(com.example.atry.R.layout.fragment_category__description, container, false)
camera_FAB = v.findViewById(com.example.atry.R.id.camera)
upload_FAB= v.findViewById(com.example.atry.R.id.upload)
imageView = v.findViewById<ImageView>(com.example.atry.R.id.display_image)
}
upload_FAB!!.setOnClickListener {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) {
// }
// }
pickImageFromGallery()
}
camera_FAB!!.setOnClickListener{
val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
// intent.putExtra(MediaStore.EXTRA_OUTPUT,imageUri)
val frag = this
/** Pass your fragment reference **/
frag.startActivityForResult(
intent,
REQUEST_IMAGE_CAPTURE
) // REQUEST_IMAGE_CAPTURE = 12345
}
fun hasPermissionInManifest(context: Context, permissionName: String): Boolean {
val packageName = context.packageName
try {
val packageInfo = context.packageManager
.getPackageInfo(packageName, PackageManager.GET_PERMISSIONS)
val declaredPermisisons = packageInfo.requestedPermissions
if (declaredPermisisons != null && declaredPermisisons.size > 0) {
for (p in declaredPermisisons) {
if (p == permissionName) {
return true
}
}
}
} catch (e: PackageManager.NameNotFoundException) {
}
return false
}
private fun pickImageFromGallery() {
//Intent to pick image
val intent = Intent(Intent.ACTION_PICK)
intent.type = "image/*"
startActivityForResult(intent, IMAGE_PICK_CODE)
}
companion object {
//image pick code
private val IMAGE_PICK_CODE = 1000;
//Permission code
private val PERMISSION_CODE = 1001;
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode == Activity.RESULT_OK && data !=null) {
if (requestCode == REQUEST_IMAGE_CAPTURE){
val imageView = view!!.findViewById<ImageView>(R.id.display_image)
//FOR CAMERA CAPTURE
photo = data.getExtras()!!.get("data") as Bitmap
val uri = getImageUriFromBitmap(activity!!,photo!!)
filePath = getPathFromURI(uri)
Picasso.get().load(uri).into(imageView)
intermediate = activity!!.contentResolver.getType(uri)
} else if(requestCode== IMAGE_PICK_CODE) {
val imageView = view!!.findViewById<ImageView>(R.id.display_image)
// Get image URI From intent FOR UPLOADING
imageUri = data.data
intermediate = activity!!.contentResolver.getType(imageUri!!)
filePath = getImageFilePath(data)
if (filePath != null) {
mBitmap = BitmapFactory.decodeFile(filePath)
imageView.setImageBitmap(mBitmap)
cursor!!.close()
}
}
}
super.onActivityResult(requestCode, resultCode, data)
}
fun getImageFilePath(data: Intent): String {
return getImageFromFilePath(data)
}
private fun getImageFromFilePath(data: Intent?): String {
val isCamera = data == null || data.data == null
return if (isCamera)
getCaptureImageOutputUri()!!.path!!
else
getPathFromURI(data!!.data!!)
}
private fun getCaptureImageOutputUri(): Uri? {
val getImage = activity!!.getExternalFilesDir("")
if (getImage != null) {
outputFileUri = Uri.fromFile(File(getImage.path, "profile.png"))
}
return outputFileUri
}
private fun getImageUri(inContext: Context, inImage: Bitmap): Uri {
val bytes = ByteArrayOutputStream()
inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes)
val path =
MediaStore.Images.Media.insertImage(inContext.contentResolver, inImage, "Title", null)
return Uri.parse(path)
}
fun getImageUriFromBitmap(activity: Activity, bitmap: Bitmap): Uri{
val bytes = ByteArrayOutputStream()
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytes)
val path = MediaStore.Images.Media.insertImage(activity.contentResolver, bitmap, "Title", null)
return Uri.parse(path.toString())
}
private fun getPathFromURI(contentUri: Uri): String {
val proj = arrayOf(MediaStore.Images.Media.DATA)
cursor = activity!!.contentResolver.query(contentUri, proj, null, null, null)
if(cursor!=null)
cursor!!.moveToFirst()
val column_index = cursor!!.getColumnIndex(proj[0])
return cursor!!.getString(column_index)
}
}

Add a neutral button to androidx EditTextPrefence / DialogPreference

I have been using my own preference class derived from EditTextPreference to include a neutral button (so that the user can select a default value).
I did this by overriding onPrepareDialogBuilder (from searching stackoverflow of course.
)
override fun onPrepareDialogBuilder(builder: AlertDialog.Builder?) { //So can set have a button to set the default value
super.onPrepareDialogBuilder(builder)
builder?.setNeutralButton("Default") { dialogInterface: DialogInterface, i: Int ->
text = sharedPreferences.getString(dftKey, "")
}
}
However, this method does not seem possible with the androidx EditTextPreference.
Any suggestions on how to add a neutral button to androidx's EditTextPreference would be appreciated.
Having set up my settings activity as per
https://developer.android.com/guide/topics/ui/settings
I have found that I can add the PreferenceFragmentCompat.OnPreferenceDisplayDialogCallback
interface to the AppCompatActivity and override onPreferenceDisplayDialog to show my own dialog.
Edit 15/1/23
Someone wanted to know more about fun myPrefDialog, so I have added some more code. Hope it helps. It makes it rather lengthy and not "completely complete"
class MySettingsActivity: AppCompatActivity(), PreferenceFragmentCompat.OnPreferenceDisplayDialogCallback {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
supportFragmentManager
.beginTransaction()
.replace(android.R.id.content, MyPreferenceFragment())
.commit()
}
override fun onPreferenceDisplayDialog(caller: PreferenceFragmentCompat, pref: Preference?): Boolean {
var handeld = false
if(pref is MyEditTextPreference) {
myPrefDialog(caller, pref)
handled = true
}
return handled
}
}
open class TlEditTextPreference: EditTextPreference {
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context) : super(context)
protected var dlgOptions = 0
internal var origTitle = title.toString()
var valueBeforeEdit: String = ""
override fun onAttached() {
super.onAttached()
PrefUtils.chkSetPrefDefault(this)
//These lines are a debug warning
dialogTitle = "Don't use default dialog."
dialogMessage = "Override onPreferenceDisplayDialog in the preference activity\n"
" to call my own dialog"
positiveButtonText = "Hey stupid, read the warning above"
}
override fun setText(text: String?) {
super.setText(text)
updateTitle()
}
fun updateTitle() {
try {
title = "$origTitle [$text]"
} catch (e: Exception) {
e.printStackTrace()
}
}
open fun myPrefDialog(context: Context): Boolean {
valueBeforeEdit = text ?: ""
dlgOptions = dlgOptions or Misc.idoSTART_SELECTED or Misc.idoDONE_KEY
val dft = PrefUtils.chkSetPrefDefault(this)
Misc.inputDlg2(context, title.toString(), "(Default $dft)",valueBeforeEdit, "Cancel", "Default", "OK", dlgOptions)
{ editText, which ->
when(which) {
Misc.BTN_POS -> text = editText.text.toString()
Misc.BTN_NEUTRAL -> text = dft
}
}
return true
}
}
const val idoNONE = 0
const val idoNO_FULLSCREEN = 1
const val idoSTART_SELECTED = 2
const val idoDONE_KEY = 4
const val idoNUMERIC_KEYPAD = 8
const val idoFIRST_LETTER_LOWERCASE = 0x10
const val idoPASSWORD = 0x20
const val idoAll_CAPS = 0x40
class inputDlg2(context: Context, title: String, msg: String, text: String, btnNeg: String?, btnNeutral: String?,
btnPos: String?, options: Int = idoNONE, dialogCallback: (editText: EditText, which: Int) -> Unit){
val inflater = LayoutInflater.from(context)
// val rv = (context as Activity).window.decorView
val rootView: ViewGroup = (context as Activity).findViewById(android.R.id.content) as ViewGroup
val promptView = inflater.inflate(R.layout.input_box, rootView, false)
val db = AlertDialog.Builder(context)
var inputDlgEditText = promptView.findViewById(R.id.edittext) as EditText
val ocListener = DialogInterface.OnClickListener { dialog, which ->
lastInputDlgText = inputDlgEditText.text.toString()
dialogCallback(inputDlgEditText, which)
}
init {
inputDlgEditText.setText(text)
inputDlgEditText.setTextIsSelectable(true)
if (options and idoNUMERIC_KEYPAD != 0) {
// inputDlgEditText.inputType = InputType.TYPE_NUMBER_FLAG_DECIMAL
// inputDlgEditText.setRawInputType(Configuration.KEYBOARD_12KEY)
inputDlgEditText.inputType = InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_FLAG_DECIMAL or InputType.TYPE_NUMBER_FLAG_SIGNED
} else
inputDlgEditText.inputType = InputType.TYPE_TEXT_FLAG_CAP_SENTENCES or inputDlgEditText.inputType
if(options and idoPASSWORD != 0)
inputDlgEditText.inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_PASSWORD
if (options and idoSTART_SELECTED != 0)
inputDlgEditText.setSelectAllOnFocus(true) //So that last current string will be selected and disapear if start typing
if(options and idoFIRST_LETTER_LOWERCASE != 0)
inputDlgEditText.inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
if(options and idoAll_CAPS != 0)
inputDlgEditText.inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS
if(options and idoPASSWORD != 0)
inputDlgEditText.inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_PASSWORD
var editorInfoFlags = 0
if (options and idoNO_FULLSCREEN != 0) {
inputDlgEditText.isSingleLine = true //Added in API29
editorInfoFlags = editorInfoFlags or EditorInfo.IME_FLAG_NO_FULLSCREEN //to disable full screen editor
}
if (options and idoDONE_KEY != 0)
editorInfoFlags = editorInfoFlags or EditorInfo.IME_ACTION_DONE
inputDlgEditText.imeOptions = editorInfoFlags
val message = promptView.findViewById(R.id.inputPrompt) as TextView
message.text = msg
db.setView(promptView)
db.setTitle(title)
if (btnPos != null) db.setPositiveButton(btnPos, ocListener)
if (btnNeutral != null) db.setNeutralButton(btnNeutral, ocListener)
if (btnNeg != null) db.setNegativeButton(btnNeg, ocListener)
db.setIcon(android.R.drawable.ic_dialog_alert)
val dlg = db.create()
dlg.window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) //Show the software keyboard immediately
val wmlp = dlg.window!!.attributes
wmlp.gravity = Gravity.TOP or Gravity.CENTER_HORIZONTAL
wmlp.x = 0 //x position
// wmlp.y = 100; //y position
inputDlgEditText.requestFocus()
dlg.show()
inputDlgEditText.setOnTouchListener { v, event ->
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.showSoftInput(inputDlgEditText, 0)
false
}
if(options and idoDONE_KEY != 0) { //Callback when the done key pressed
inputDlgEditText.setOnEditorActionListener { textView: TextView?, action: Int, keyEvent: KeyEvent? ->
if (action == EditorInfo.IME_ACTION_DONE) {
dialogCallback(inputDlgEditText, Misc.BTN_POS)
dlg.dismiss()
}
false
}
}
}
}

Generic function works, but generic class doesn't?

I would like a class that is a generic for KProperty1, I can do this for a function, but not a class:
import kotlin.reflect.KProperty1
data class Dog(val name: String, val age: Int)
fun <P: KProperty1<*, *>> reflectionHelper(input: P) = input.name
fun <P: KProperty1<*, *>> getReflectionHelper(clazz: P) = ReflectionHelper<P>()
class ReflectionHelper<P: KProperty1<*, *>> {
}
fun main(args : Array<String>) {
println(reflectionHelper(Dog::age)) // Works
val helper1 = getReflectionHelper(Dog::age) // Also Works
val helper2 = ReflectionHelper<Dog::age>() // Error: Type inference failed
}
Dog::age is a value (of type KProperty1<Dog, String>), not a type. In between < and > you need to put a type, or you need to omit them entirely and the type will be inferred (that's what happens in the first two lines).
So the equivalent to your funs would be
class ReflectionHelper<P: KProperty1<*, *>>(input: P) { ... }
val helper2 = ReflectionHelper(Dog::age)
If you don't need input: P as a parameter, you'll have to specify P explicitly both for fun and for class.

Kotlin's reduce() function with different types

I was looking through array extension functions and found reduce() one
inline fun <S, T: S> Array<out T>.reduce(operation: (acc: S, T) -> S): S {
if (isEmpty())
throw UnsupportedOperationException("Empty array can't be reduced.")
var accumulator: S = this[0]
for (index in 1..lastIndex) {
accumulator = operation(accumulator, this[index])
}
return accumulator
}
here the accumulator variable of type S assigned with first element from the array with type T.
Can't wrap my head around the real use case of reduce() function with two data types. Here synthetic example which actually doesn't make any sense.
open class A(var width: Int = 0)
class B(width: Int) : A(width)
val array = arrayOf(A(7), A(4), A(1), A(4), A(3))
val res = array.reduce { acc, s -> B(acc.width + s.width) }
Seems most real life use cases with this function use this signature:
inline fun <T> Array<out T>.reduce(operation: (acc: T, T) -> T): T
Can you help with providing some examples, where reduce() function can be useful with different types.
Here is an example:
interface Expr {
val value: Int
}
class Single(override val value: Int): Expr
class Sum(val a: Expr, val b: Expr): Expr {
override val value: Int
get() = a.value + b.value
}
fun main(args: Array<String>) {
val arr = arrayOf(Single(1), Single(2), Single(3));
val result = arr.reduce<Expr, Single> { a, b -> Sum(a, b) }
println(result.value)
}

yalantis search filter in Fragment gets into background

I am using the Yalantis filter for android. I am having a Fragment rather than activity :
`class IncentiveActivity :Fragment() , FilterListener {
private var incentiveList = ArrayList<Incentive>()
var mAdapter: IncentiveListRecyclerAdapter? = null
val handler: Handler by lazy {
Handler()
}
private var mColors: IntArray? = null
private var mTitles: Array<String>? = null
private var mAllQuestions: List<Incentive>? = null
private var mFilter: Filter<FilterTag>? = null
val that :Context? = null
var fragment : View? =null
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
fragment = inflater!!.inflate(R.layout.activity_incentive_detail, container, false)
return fragment
}
override fun onStart() {
super.onStart()
setIncentiveAdapter()
mColors = getResources().getIntArray(R.array.colorslist);
mTitles = getResources().getStringArray(R.array.job_titles);
mFilter = this.filter as Filter<FilterTag>
mFilter!!.adapter =Adapter(getTags())
mFilter!!.listener = this
//the text to show when there's no selected items
mFilter!!.noSelectedItemText = getString(R.string.str_all_selected)
mFilter!!.build()
}
private fun getTags():List<FilterTag> {
val tags = ArrayList<FilterTag>()
for (i in 0..mTitles!!.size - 1) {
tags.add(FilterTag(mTitles!![i], mColors!![i]))
}
return tags
}
fun setIncentiveAdapter(){
//todo for salafi API call here and set adapter
val in1 = Incentive("Get 100p by completing 10","Description","D","Cash","100","ACTIVE",10,"id-vcxsdt","ACTIVE",8,6,9)
val in2 = Incentive("Get 100p by completing 10","Description","W","Cash","100","OPTED",10,"id-vcxsdt","OPTED",8,6,9)
val in3 = Incentive("Get 100p by completing 10","Description","Y","Cash","100","EXPIRED",10,"id-vcxsdt","EXPIRED",8,6,9)
val in4 = Incentive("Get 100p by completing 10","Description","Y","Cash","100","ACHIEVED",10,"id-vcxsdt","EXPIRED",8,6,9)
val in5 = Incentive("Get 100p by completing 10","Description","Y","Cash","100","NOT_OPTED",10,"id-vcxsdt","NOT_OPTED",8,6,9)
incentiveList.add(in1)
incentiveList.add(in2)
incentiveList.add(in3)
incentiveList.add(in4)
incentiveList.add(in5)
mAdapter = IncentiveListRecyclerAdapter(context, incentiveList)
incentiveListView.adapter = mAdapter
incentiveListView.layoutManager = LinearLayoutManager(context)
}
private fun calculateDiff(oldList: List<Incentive>, newList: List<Incentive >) {
DiffUtil.calculateDiff(object : DiffUtil.Callback() {
override fun getOldListSize(): Int {
return oldList.size
}
override fun getNewListSize(): Int {
return newList.size
}
override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
return oldList[oldItemPosition].equals(newList[newItemPosition])
}
override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
return oldList[oldItemPosition].equals(newList[newItemPosition])
}
}).dispatchUpdatesTo(mAdapter)
}
override fun onFilterDeselected(item: FilterTag) {
}
override fun onFilterSelected(item: FilterTag) {
Log.e("Item",item.getText())
if (item.getText().equals(mTitles!![0])) {
Log.e("mtitle",mTitles!![0])
mFilter!!.deselectAll();
mFilter!!.collapse();
}
}
/*private fun findByTags(tags: List<FilterTag>): List<Incentive> {
val questions = ArrayList<Incentive>()
for (question in mAllQuestions!!) {
for (tag in tags) {
if (question.hasTag(tag.getText()) && !questions.contains(question)) {
questions.add(question)
}
}
}
return questions
}*/
override fun onFiltersSelected(filters: java.util.ArrayList<FilterTag>) {
Log.e("filter",filters.size.toString())
/*val newQuestions = findByTags(filters)
val oldQuestions = mAdapter.getQuestions()
mAdapter.setQuestions(newQuestions)
calculateDiff(oldQuestions, newQuestions)*/
}
override fun onNothingSelected() {
if (this.incentiveListView != null) {
mFilter!!.adapter =Adapter(getTags())
incentiveListView.adapter = mAdapter
}
}
inner class Adapter(#NotNull items: List<FilterTag>) : FilterAdapter<FilterTag>(items) {
override fun createView(position: Int, item: FilterTag): FilterItem {
val filterItem = FilterItem(this#IncentiveActivity.activity)
filterItem.strokeColor = mColors!![0]
filterItem.textColor = mColors!![0]
filterItem.cornerRadius = 14f
filterItem.checkedTextColor = ContextCompat.getColor(this#IncentiveActivity.activity, android.R.color.white)
filterItem.color = ContextCompat.getColor(this#IncentiveActivity.activity, R.color.m_color2)
filterItem.checkedColor = mColors!![position]
filterItem.text = item.getText()
filterItem.deselect()
return filterItem
}
}
}`
i am facing problem when i expand the filter it comes in background of my list keeping my list visible .
this is my listView when i first open the fragment
this is the listview after i select the filter
also i am sorry if i have not provided all details and my question doesn't follow the SOF conditions thank you

Resources