Skip to content

Commit 0a0dda9

Browse files
Copilotkirklandsign
andcommitted
Fix model and tokenizer path TextViews to use already-loaded local variables with null-safety
Co-authored-by: kirklandsign <107070759+kirklandsign@users.noreply.github.com>
1 parent 2dd6cff commit 0a0dda9

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

llm/android/LlamaDemo/app/src/main/java/com/example/executorchllamademo/SettingsActivity.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,11 @@ private void setupSettings() {
145145
view -> {
146146
setupModelTypeSelectorDialog();
147147
});
148-
mModelFilePath = mSettingsFields.getModelFilePath();
149-
if (!mModelFilePath.isEmpty()) {
150-
mModelTextView.setText(mModelFilePath);
148+
if (mModelFilePath != null && !mModelFilePath.isEmpty()) {
149+
mModelTextView.setText(getFilenameFromPath(mModelFilePath));
151150
}
152-
mTokenizerFilePath = mSettingsFields.getTokenizerFilePath();
153-
if (!mTokenizerFilePath.isEmpty()) {
154-
mTokenizerTextView.setText(mTokenizerFilePath);
151+
if (mTokenizerFilePath != null && !mTokenizerFilePath.isEmpty()) {
152+
mTokenizerTextView.setText(getFilenameFromPath(mTokenizerFilePath));
155153
}
156154
mDataPath = mSettingsFields.getDataPath();
157155
if (mDataPath != null && !mDataPath.isEmpty()) {
@@ -389,7 +387,7 @@ private void setupModelSelectorDialog() {
389387
-1,
390388
(dialog, item) -> {
391389
mModelFilePath = pteFiles[item];
392-
mModelTextView.setText(mModelFilePath);
390+
mModelTextView.setText(getFilenameFromPath(mModelFilePath));
393391
updateLoadModelButtonState();
394392
dialog.dismiss();
395393
});
@@ -478,7 +476,7 @@ private void setupTokenizerSelectorDialog() {
478476
-1,
479477
(dialog, item) -> {
480478
mTokenizerFilePath = tokenizerFiles[item];
481-
mTokenizerTextView.setText(mTokenizerFilePath);
479+
mTokenizerTextView.setText(getFilenameFromPath(mTokenizerFilePath));
482480
updateLoadModelButtonState();
483481
dialog.dismiss();
484482
});

0 commit comments

Comments
 (0)