I am currently learning to programm android applications, so please be patient with me, i’m a beginner.
I am trying to communicate between different activities, to set an alarm, i found this page Is it possible to add an array or object to SharedPreferences on Android
that helped me to share the info about the alarm.
Also, as of now i have only implemented the MathMethodSetActivity of all the methods to turn off the alarm, for setting stuff like difficulty and specific task. Also the QueueRecViewAdapter (adapter for the recyclerView) is currently only supporting mathMethods.
My implementation of this can be found at https://github.com/divi0001/
To be specific, in EditAlarmActivity (https://github.com/divi0001/Alarm/blob/master/main/java/com/example/alarm/EditAlarmActivity.java)
currently this is line 366+
right above that i set an adapter for the recyclerView, that should display basic info about the set Method. Problem is, even though i think that i solved, that the activities, where settings are made and EditAlarmAcitivity do communicate, still the recyclerView doesn’t update. I have called notifyDataSetChanged(); in the adapter class multiple times, so i don’t get, why it is not showing.
Can someone help me?
I tried communication via a ValContainer class, which didn’t work, because i don’t think you can use the ressources of a class in a anonymous subclass. I don’t want to use GSON, so i made my own JSONHandler class to translate an Alarm Object to and from JSONArray. Also i tried to work with standard (de)-serialization from Java (ObjectIn/OutputStream). I also made sure, that everything that is required is set visible in xml files, normally i expected that when i change the ArrayList, that the RecyclerView is getting each item from, then it should also update it’s View to a new CardView with the info specified.
I also tried to work with Intents (putExtra, onActivityResult)
2
Answers
hmm, i sorted out the error now, it seems, holder.parent.setOnClickListener caused it, dont quite know why, but i dont really need it, so i just commented it out for now :)
There is DiffUtil for example.
but data should be updated if you are calling
notifyDataSetChanged()
insidesetAlarmParameters()
method after setting value.