Skip to content

Commit

Permalink
Save state fixELF & dumpMetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanGIG committed Aug 14, 2023
1 parent 3ebce4a commit f4e3bec
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
35 changes: 27 additions & 8 deletions app/src/main/java/com/dumper/android/ui/memory/MemoryFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,21 @@ class MemoryFragment : Fragment() {
binding.processText.editText?.setText(it)
}

memViewModel.selectedApps.observe(viewLifecycleOwner) {
binding.processText.editText?.setText(it)
}
selectedApps.observe(viewLifecycleOwner) {
binding.processText.editText?.setText(it)
}

memViewModel.libName.observe(viewLifecycleOwner) {
binding.libName.editText?.setText(it)
libName.observe(viewLifecycleOwner) {
binding.libName.editText?.setText(it)
}

isFixELF.observe(viewLifecycleOwner) {
binding.autoFix.isChecked = it
}

isDumpMetadata.observe(viewLifecycleOwner) {
binding.metadata.isChecked = it
}
}

binding.selectApps.setOnClickListener {
Expand Down Expand Up @@ -74,12 +83,22 @@ class MemoryFragment : Fragment() {
override fun onDestroyView() {
super.onDestroyView()
//Save state into view-models before destroying view
memViewModel.packageName.value = binding.processText.editText?.text.toString()
memViewModel.libName.value = binding.libName.editText?.text.toString()
with(memViewModel) {
packageName.value = binding.processText.editText?.text.toString()
libName.value = binding.libName.editText?.text.toString()
isFixELF.value = binding.autoFix.isChecked
isDumpMetadata.value = binding.metadata.isChecked
}

with(sharedPref!!.edit()) {
putString("packageName", binding.processText.editText?.text.toString())
putString("libName", binding.libName.editText?.text.toString())
commit()
}
_binding = null
}

private fun getMainActivity() : MainActivity? {
private fun getMainActivity(): MainActivity? {
val activity = requireActivity()
return if (activity is MainActivity) {
activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class MemoryViewModel : ViewModel() {
val selectedApps = MutableLiveData<String>()
val packageName = MutableLiveData<String>()
val libName = MutableLiveData<String>()
val isFixELF = MutableLiveData<Boolean>()
val isDumpMetadata = MutableLiveData<Boolean>()


fun showProcess(ctx: Context, list: ArrayList<ProcessData>) {
Expand Down

0 comments on commit f4e3bec

Please sign in to comment.