Skip to content

Commit 562dae8

Browse files
authored
Disable Serializable State (#21)
1 parent c8a58df commit 562dae8

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

app/src/main/java/com/djangofiles/djangofiles/ui/FilesFragment.kt

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,24 @@ class FilesFragment : Fragment() {
6565

6666
// TODO: Implement Parcelize/Parcelable
6767
//val savedData = savedInstanceState?.getParcelableArrayList<RecentResponse>("recent_data")
68-
val savedData =
69-
savedInstanceState?.getSerializable("recent_data") as? ArrayList<RecentResponse>
70-
Log.d("getFiles", "savedData: ${savedData?.size}")
71-
if (savedData != null) {
72-
Log.i("File[onViewCreated]", "LOADING SAVED DATA")
73-
atEnd = savedInstanceState.getBoolean("at_end")
74-
Log.i("File[onViewCreated]", "atEnd: $atEnd")
75-
filesAdapter.addData(savedData)
76-
binding.loadingSpinner.visibility = View.GONE
77-
} else {
78-
lifecycleScope.launch {
79-
getFiles(perPage)
80-
}
68+
//val savedData = savedInstanceState?.getSerializable("recent_data") as? ArrayList<RecentResponse>
69+
//Log.d("getFiles", "savedData: ${savedData?.size}")
70+
//if (savedData != null) {
71+
// Log.i("File[onViewCreated]", "LOADING SAVED DATA")
72+
// atEnd = savedInstanceState.getBoolean("at_end")
73+
// Log.i("File[onViewCreated]", "atEnd: $atEnd")
74+
// filesAdapter.addData(savedData)
75+
// binding.loadingSpinner.visibility = View.GONE
76+
//} else {
77+
// lifecycleScope.launch {
78+
// getFiles(perPage)
79+
// }
80+
//}
81+
82+
lifecycleScope.launch {
83+
getFiles(perPage)
8184
}
8285

83-
// TODO: Since atEnd is false this almost always triggers when loading saved data...
8486
binding.filesRecyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
8587
override fun onScrolled(rv: RecyclerView, dx: Int, dy: Int) {
8688
if (!rv.canScrollVertically(1)) {
@@ -143,11 +145,11 @@ class FilesFragment : Fragment() {
143145
}
144146

145147
override fun onSaveInstanceState(outState: Bundle) {
146-
Log.d("File[onSave]", "outState: ${outState.size()}")
148+
Log.d("File[onSave]", "ON SAVE: ${outState.size()}")
147149
super.onSaveInstanceState(outState)
148150
//outState.putParcelableArrayList("recent_data", ArrayList(filesAdapter.getData()))
149-
outState.putSerializable("recent_data", ArrayList(filesAdapter.getData()))
150-
outState.putBoolean("at_end", atEnd)
151+
//outState.putSerializable("recent_data", ArrayList(filesAdapter.getData()))
152+
//outState.putBoolean("at_end", atEnd)
151153
}
152154

153155
override fun onPause() {

0 commit comments

Comments
 (0)