I'm moving from java to kotlin and I faced with some difficulties which are connected with static method usage at kotlin. I'd like to get access from recyclerView adapter to views at my activity. At Java I did smth like that at adapter:
WriteResponseMess.deleteAttachment(position);
and static method at my activity:
public static void deleteAttachment(int adapterPosition) {
mNames = adapter.getItems();
mNames.remove(adapterPosition);
adapter.updateNames(mNames);
adapter.notifyDataSetChanged();
mNames = adapter.getItems();
}
right now I want to do it via kotlin. The main tack is that I have to delete item of RV and update views. I have read this and this resources and I have done smth like that:
companion object {
@JvmStatic
fun deleteAttachment(position: Int) {
}
}
but I don't have any access to activity variables, so what I have to do in that situation?