forked from BryanGIG/PADumper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
45 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
app/src/main/java/com/dumper/android/ui/memory/MemoryViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,36 @@ | ||
package com.dumper.android.ui.memory | ||
|
||
import android.content.Context | ||
import androidx.lifecycle.MutableLiveData | ||
import androidx.lifecycle.ViewModel | ||
import com.dumper.android.dumper.process.ProcessData | ||
import com.google.android.material.dialog.MaterialAlertDialogBuilder | ||
|
||
class MemoryViewModel : ViewModel() { | ||
|
||
val selectedApps = MutableLiveData<String>() | ||
val packageName = MutableLiveData<String>() | ||
val libName = MutableLiveData<String>() | ||
|
||
|
||
fun showProcess(ctx: Context, list: ArrayList<ProcessData>) { | ||
list.sortBy { lists -> lists.appName } | ||
|
||
val appNames = list.map { processData -> | ||
val processName = processData.processName | ||
if (processName.contains(":")) | ||
"${processData.appName} (${processName.substringAfter(":")})" | ||
else | ||
processData.appName | ||
} | ||
|
||
MaterialAlertDialogBuilder(ctx) | ||
.setTitle("Select process") | ||
.setSingleChoiceItems(appNames.toTypedArray(), -1) { dialog, which -> | ||
selectedApps.value = list[which].processName | ||
dialog.dismiss() | ||
} | ||
.show() | ||
} | ||
|
||
} |