Open Arxcis opened 3 years ago
Well in the code WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION is used which is deprecated. (https://developer.android.com/reference/android/net/wifi/WifiManager#SUPPLICANT_CONNECTION_CHANGE_ACTION). The link also says "This is no longer supported" so it looks like it is outdated.
Ok. Good catch @Bibli2311 . Another option is to display a refresh-button to the user, so user can refresh whenever user feels like
Yeah, that sounds like a good idea. I can start implementing it today.
Background info: I have made a fragment which contains the refresh button. The refresh button has a click-listener which looks like this:
mainXML.btnRefresh.setOnClickListener{
when(currentActivity.activity)
{
"Films" ->(activity as FilmsActivity).fetchFilms()
"People" -> (activity as PeopleActivity).fetchPeople()
null -> Log.d("buttonRefresh", "currentActivity is null")
}
}
.fetchFilms() and .fetchPeople() refetches data from the API and updates the UI. To determine if .fetchFilms() or .fetchPeople() should be called I am using the "currentActivity" class. This class updates a string whenever an Activity is used. This class updates its string this way in the Activities:
class Activity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {...}
override fun onResume() {
super.onResume()
currentActivity.activity = title.toString()
configureBottomNavigation(this, FilmsNavigation, R.id.FilmsMenuItem)
}
override fun onPause() {
super.onPause()
currentActivity.activity = null
}
override fun onDestroy() {
super.onDestroy()
currentActivity.activity = null
}
}
The actions are listed with log messages which are called from the setter in the currentActivity class and in the ButtonRefresh.kt file which controls the refresh button.
Log (currentActivity): currentActivity: currentActivity is Films
Log: currentActivity (currentActivity): currentActivity is Films //currentActivity is set to Films again since onResume() is called again
Log BUG (ButtonRefresh): buttonRefresh: currentActivity is null
No data is updated even after I have enabled the WIFI again.
Why?
Based on feedback on a review comment here - https://github.com/Arxcis/prog2007-gruppearbeid/pull/6#pullrequestreview-810290721
Potential solution from https://stackoverflow.com/a/5890553