Display shopping list name in titlebar

This commit is contained in:
Clayton Wilson 2020-11-14 19:12:03 -05:00
parent bae3d77c57
commit 680c545d76
3 changed files with 7 additions and 23 deletions

View File

@ -70,7 +70,9 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);
final int listID = (int) getIntent().getSerializableExtra("listID");
final int LIST_ID = (int) getIntent().getSerializableExtra("listID");
final String LIST_NAME = (String) getIntent().getSerializableExtra("listName");
setTitle(LIST_NAME);
Properties configs = new Properties();
try {
@ -79,7 +81,7 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
e.printStackTrace();
}
requestor = new Requestor(am, configs.getProperty("apiKey"));
requestor.getObject(Integer.toString(listID), List.class, this);
requestor.getObject(Integer.toString(LIST_ID), List.class, this);
listView = findViewById(R.id.listView);
myAdapter = new MyAdapter(this, pNames, pStores, pPrices, pQuantity, pImages);
@ -125,7 +127,7 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
public void onClick(DialogInterface dialog, int which) {
EditText sharedEmailText = (EditText) codeView.findViewById(R.id.editTextTextSharedEmail);
String sharedEmail = sharedEmailText.getText().toString();
ListShare listShare = new ListShare(listID, sharedEmail);
ListShare listShare = new ListShare(LIST_ID, sharedEmail);
try {
requestor.postObject(listShare);
}

View File

@ -157,8 +157,9 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
public void onClick(View v) {
Intent listPage = new Intent(activity, ListPage.class);
// Send the list ID
// Send the list ID and list name
listPage.putExtra("listID", curList.getItemID());
listPage.putExtra("listName", curList.getName());
activity.startActivity(listPage);
}
});

View File

@ -1,19 +0,0 @@
package com.example.listify.ui.home;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
public class HomeViewModel extends ViewModel {
private MutableLiveData<String> mText;
public HomeViewModel() {
mText = new MutableLiveData<>();
mText.setValue("This is home fragment");
}
public LiveData<String> getText() {
return mText;
}
}