Skip to content

Commit

Permalink
SharedPref: save process & file Name
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanGIG committed Aug 14, 2023
1 parent f4e3bec commit c2bf621
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions app/src/main/java/com/dumper/android/ui/memory/MemoryFragment.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dumper.android.ui.memory

import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
Expand All @@ -21,17 +22,29 @@ class MemoryFragment : Fragment() {

private val memViewModel: MemoryViewModel by activityViewModels()
private val console: ConsoleViewModel by activityViewModels()
private val sharedPref by lazy { activity?.getPreferences(Context.MODE_PRIVATE) }

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = FragmentMemoryBinding.inflate(inflater, container, false)
//save out package name into sharedpreferences

memViewModel.packageName.observe(viewLifecycleOwner) {
binding.processText.editText?.setText(it)
with(sharedPref!!) {
getString("libName", null)?.let {
binding.libName.editText!!.setText(it)
}
getString("packageName", null)?.let {
binding.processText.editText!!.setText(it)
}
}

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

selectedApps.observe(viewLifecycleOwner) {
binding.processText.editText?.setText(it)
}
Expand Down Expand Up @@ -71,11 +84,10 @@ class MemoryFragment : Fragment() {
if (binding.metadata.isChecked)
listDump.add("global-metadata.dat")

getMainActivity()?.sendRequestDump(
process,
listDump.toTypedArray(),
binding.autoFix.isChecked
)
with(getMainActivity()!!) {
sendRequestDump(process, listDump.toTypedArray(), binding.autoFix.isChecked)
toConsoleFragment()
}
}
return binding.root
}
Expand Down

0 comments on commit c2bf621

Please sign in to comment.