Skip to content

Commit

Permalink
Set the ability to call a memory setting from intent, offset/tone/nam…
Browse files Browse the repository at this point in the history
…e included also, prevent nullpointer-exception. (#124)
  • Loading branch information
programmin1 authored Dec 3, 2024
1 parent c5d9b58 commit 6fc36e1
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ kv4p HT (see http://kv4p.com)
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.ViewModelProvider;

import com.google.android.material.textfield.TextInputEditText;
import com.vagell.kv4pht.R;
Expand Down Expand Up @@ -122,6 +123,25 @@ public void run() {
AutoCompleteTextView editMemoryGroupTextInputEditText = findViewById(R.id.editMemoryGroupTextInputEditText);
editMemoryGroupTextInputEditText.setText(selectedMemoryGroup, false);
}

String offset = extras.getString("offset");
if (offset != null) {
AutoCompleteTextView editOffset = findViewById(R.id.editOffsetTextView);
editOffset.setText(offset, false);
}

String tone = extras.getString("tone");
if (tone != null) {
AutoCompleteTextView editTone = findViewById(R.id.editToneTextView);
editTone.setText(tone, false);
}

String name = extras.getString("name");
if (name != null) {
TextInputEditText editNameTextInputEditText = findViewById(R.id.editNameTextInputEditText);
editNameTextInputEditText.setText(name);
}

}
}

Expand Down Expand Up @@ -160,6 +180,13 @@ private void populateMemoryGroups() {
threadPoolExecutor.execute(new Runnable() {
@Override
public void run() {
if( MainViewModel.appDb == null ) {
//For example direct call other app intent.
//If app is not already open do not nullpointer-exception.
MainViewModel preloader = new MainViewModel();
preloader.setActivity(activity);
preloader.loadData();
}
List<String> memoryGroups = MainViewModel.appDb.channelMemoryDao().getGroups();

// Remove any blank memory groups from the list (shouldn't have been saved, ideally).
Expand Down

0 comments on commit 6fc36e1

Please sign in to comment.