mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-16 10:48:46 +00:00
Merge pull request #131 from ClaytonWWilson/aaron-branch-2
Aaron branch 2
This commit is contained in:
commit
f5d71a0fff
@ -3,6 +3,7 @@ package com.example.listify;
|
|||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.*;
|
import android.view.*;
|
||||||
@ -10,6 +11,7 @@ import android.widget.*;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
import com.example.listify.ui.home.HomeFragment;
|
import com.example.listify.ui.home.HomeFragment;
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
@ -38,6 +40,8 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
|||||||
Button shareList;
|
Button shareList;
|
||||||
|
|
||||||
TextView tvTotalPrice;
|
TextView tvTotalPrice;
|
||||||
|
TextView emptyMessage;
|
||||||
|
|
||||||
ProgressBar loadingListItems;
|
ProgressBar loadingListItems;
|
||||||
|
|
||||||
ArrayList<String> pNames = new ArrayList<>();
|
ArrayList<String> pNames = new ArrayList<>();
|
||||||
@ -56,7 +60,6 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
|||||||
|
|
||||||
DecimalFormat df = new DecimalFormat("0.00");
|
DecimalFormat df = new DecimalFormat("0.00");
|
||||||
|
|
||||||
// TODO: Display a message if their list is empty
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -83,8 +86,9 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
|||||||
loadingListItems.setVisibility(View.VISIBLE);
|
loadingListItems.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
tvTotalPrice = (TextView) findViewById(R.id.total_price);
|
tvTotalPrice = (TextView) findViewById(R.id.total_price);
|
||||||
|
emptyMessage = (TextView) findViewById(R.id.textViewEmpty2);
|
||||||
|
|
||||||
clearAll = (Button) findViewById(R.id.buttonClear);
|
/*clearAll = (Button) findViewById(R.id.buttonClear);
|
||||||
clearAll.setOnClickListener(new View.OnClickListener() {
|
clearAll.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@ -94,6 +98,8 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
|||||||
pQuantity.clear();
|
pQuantity.clear();
|
||||||
pImages.clear();
|
pImages.clear();
|
||||||
|
|
||||||
|
emptyMessage.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
while(!pListItemPair.isEmpty()) {
|
while(!pListItemPair.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
requestor.deleteObject(pListItemPair.remove(0));
|
requestor.deleteObject(pListItemPair.remove(0));
|
||||||
@ -138,7 +144,7 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
|||||||
AlertDialog dialog = builder.create();
|
AlertDialog dialog = builder.create();
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
});
|
});*/
|
||||||
|
|
||||||
refreshList = (SwipeRefreshLayout) findViewById(R.id.refresh_list);
|
refreshList = (SwipeRefreshLayout) findViewById(R.id.refresh_list);
|
||||||
refreshList.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
refreshList.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||||
@ -160,8 +166,10 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
//Inflate the menu; this adds items to the action bar if it is present.
|
//Inflate the menu; this adds items to the action bar if it is present.
|
||||||
|
|
||||||
getMenuInflater().inflate(R.menu.list, menu);
|
getMenuInflater().inflate(R.menu.list, menu);
|
||||||
// return super.onCreateOptionsMenu(menu);
|
|
||||||
|
//return super.onCreateOptionsMenu(menu);
|
||||||
|
|
||||||
MenuItem renameItem = menu.findItem(R.id.action_rename_list);
|
MenuItem renameItem = menu.findItem(R.id.action_rename_list);
|
||||||
renameItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
renameItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||||
@ -226,6 +234,12 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
|||||||
|
|
||||||
if(list != null) {
|
if(list != null) {
|
||||||
for (ListEntry entry : list.getEntries()) {
|
for (ListEntry entry : list.getEntries()) {
|
||||||
|
this.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
emptyMessage.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
});
|
||||||
int product = entry.getProductID();
|
int product = entry.getProductID();
|
||||||
SynchronousReceiver<Item> pr = new SynchronousReceiver<>();
|
SynchronousReceiver<Item> pr = new SynchronousReceiver<>();
|
||||||
requestor.getObject(Integer.toString(product), Item.class, pr, pr);
|
requestor.getObject(Integer.toString(product), Item.class, pr, pr);
|
||||||
@ -422,7 +436,6 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
|||||||
totalPriceByStore.put(storeName, totalPriceByStore.get(storeName) - (Double.parseDouble(pPrices.get(position)) * Integer.parseInt(pQuantity.get(position))));
|
totalPriceByStore.put(storeName, totalPriceByStore.get(storeName) - (Double.parseDouble(pPrices.get(position)) * Integer.parseInt(pQuantity.get(position))));
|
||||||
pPrices.set(storeHeaderIndex.get(storeName), df.format(totalPriceByStore.get(storeName)));
|
pPrices.set(storeHeaderIndex.get(storeName), df.format(totalPriceByStore.get(storeName)));
|
||||||
|
|
||||||
|
|
||||||
totalPrice -= (Double.parseDouble(pPrices.get(position)) * Double.parseDouble(pQuantity.get(position)));
|
totalPrice -= (Double.parseDouble(pPrices.get(position)) * Double.parseDouble(pQuantity.get(position)));
|
||||||
tvTotalPrice.setText(String.format("$%.2f", totalPrice));
|
tvTotalPrice.setText(String.format("$%.2f", totalPrice));
|
||||||
|
|
||||||
@ -431,8 +444,35 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
|||||||
pPrices.remove(position);
|
pPrices.remove(position);
|
||||||
pQuantity.remove(position);
|
pQuantity.remove(position);
|
||||||
pImages.remove(position);
|
pImages.remove(position);
|
||||||
|
|
||||||
requestor.deleteObject(pListItemPair.remove(position));
|
requestor.deleteObject(pListItemPair.remove(position));
|
||||||
|
|
||||||
|
for(String str : storeHeaderIndex.keySet()) {
|
||||||
|
if(storeHeaderIndex.get(str) > position) {
|
||||||
|
storeHeaderIndex.put(str, storeHeaderIndex.get(str) - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(String.format("$%.2f", totalPriceByStore.get(storeName)).equals("$0.00") || String.format("$%.2f", totalPriceByStore.get(storeName)).equals("$-0.00")) {
|
||||||
|
int index = storeHeaderIndex.remove(storeName);
|
||||||
|
|
||||||
|
pNames.remove(index);
|
||||||
|
pStores.remove(index);
|
||||||
|
pPrices.remove(index);
|
||||||
|
pQuantity.remove(index);
|
||||||
|
pImages.remove(index);
|
||||||
|
pListItemPair.remove(index);
|
||||||
|
|
||||||
|
for(String str : storeHeaderIndex.keySet()) {
|
||||||
|
if(storeHeaderIndex.get(str) > index) {
|
||||||
|
storeHeaderIndex.put(str, storeHeaderIndex.get(str) - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pNames.isEmpty()) {
|
||||||
|
emptyMessage.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
myAdapter.notifyDataSetChanged();
|
myAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -457,6 +497,14 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
|||||||
decrQuan.setVisibility(View.GONE);
|
decrQuan.setVisibility(View.GONE);
|
||||||
incrQuan.setVisibility(View.GONE);
|
incrQuan.setVisibility(View.GONE);
|
||||||
removeItem.setVisibility(View.GONE);
|
removeItem.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
listproduct.setBackgroundColor(Color.parseColor("#BBBBBB"));
|
||||||
|
|
||||||
|
ConstraintLayout constraintLayout = listproduct.findViewById(R.id.constraintLayout);
|
||||||
|
constraintLayout.setMaxHeight(250);
|
||||||
|
|
||||||
|
name.setPadding(0, 175, 0, 0);
|
||||||
|
price.setPadding(0, 175, 0, 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
quantity.setText(pQuantity.get(position));
|
quantity.setText(pQuantity.get(position));
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
android:indeterminate="true"
|
android:indeterminate="true"
|
||||||
android:visibility="gone"/>
|
android:visibility="gone"/>
|
||||||
|
|
||||||
<LinearLayout
|
<!--<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
@ -35,7 +35,7 @@
|
|||||||
android:text="Share"
|
android:text="Share"
|
||||||
android:textSize="10sp"/>
|
android:textSize="10sp"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>-->
|
||||||
|
|
||||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
android:id="@+id/refresh_list"
|
android:id="@+id/refresh_list"
|
||||||
@ -51,6 +51,14 @@
|
|||||||
|
|
||||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textViewEmpty2"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:text="This list is empty."/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user