mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-13 09:48:47 +00:00
Merge pull request #162 from ClaytonWWilson/aaron-branch-2
Aaron branch 2
This commit is contained in:
commit
3053ce5913
@ -63,6 +63,8 @@ public class ShoppingListsAdapter extends BaseAdapter implements Requestor.Recei
|
||||
|
||||
tvListName = (TextView) convertView.findViewById(R.id.shopping_list_name);
|
||||
|
||||
tvListName.setText(curList.getName());
|
||||
|
||||
if(curList.isShared()) {
|
||||
Properties configs = new Properties();
|
||||
try {
|
||||
@ -73,8 +75,11 @@ public class ShoppingListsAdapter extends BaseAdapter implements Requestor.Recei
|
||||
requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||
requestor.getObject(Integer.toString(curList.getListID()), ListShare.class, this);
|
||||
}
|
||||
else {
|
||||
tvListName.setText(curList.getName());
|
||||
|
||||
String listText = tvListName.getText().toString();
|
||||
|
||||
if(listText.length() > 25) {
|
||||
tvListName.setText(listText.substring(0, 25) + "...");
|
||||
}
|
||||
|
||||
return convertView;
|
||||
@ -89,10 +94,16 @@ public class ShoppingListsAdapter extends BaseAdapter implements Requestor.Recei
|
||||
@Override
|
||||
public void run() {
|
||||
if(sharee.getShareWithEmail().equals(am.getEmail(requestor))) {
|
||||
tvListName.setText(curList.getName() + " (shared by me)");
|
||||
tvListName.setText(curList.getName() + " (sh. me)");
|
||||
}
|
||||
else {
|
||||
tvListName.setText(curList.getName() + " (shared by " + sharee.getShareWithEmail() + ")");
|
||||
tvListName.setText(curList.getName() + " (sh. " + sharee.getShareWithEmail() + ")");
|
||||
}
|
||||
|
||||
String listText = tvListName.getText().toString();
|
||||
|
||||
if(listText.length() > 25) {
|
||||
tvListName.setText(listText.substring(0, 25) + "...");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -61,10 +61,16 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter implements Reques
|
||||
@Override
|
||||
public void run() {
|
||||
if(sharee.getShareWithEmail().equals(am.getEmail(requestor))) {
|
||||
holder.listName.setText(curList.getName() + " (shared by me)");
|
||||
holder.listName.setText(curList.getName() + " (sh. me)");
|
||||
}
|
||||
else {
|
||||
holder.listName.setText(curList.getName() + " (shared by " + sharee.getShareWithEmail() + ")");
|
||||
holder.listName.setText(curList.getName() + " (sh. " + sharee.getShareWithEmail() + ")");
|
||||
}
|
||||
|
||||
String listText = holder.listName.getText().toString();
|
||||
|
||||
if(listText.length() > 25) {
|
||||
holder.listName.setText(listText.substring(0, 25) + "...");
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -105,11 +111,16 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter implements Reques
|
||||
// Bind the view to the unique list ID
|
||||
binderHelper.bind(holder.swipeLayout, Integer.toString(curList.getListID()));
|
||||
|
||||
holder.listName.setText(curList.getName());
|
||||
|
||||
if(curList.isShared()) {
|
||||
requestor.getObject(Integer.toString(curList.getListID()), ListShare.class, this);
|
||||
}
|
||||
else {
|
||||
holder.listName.setText(curList.getName());
|
||||
|
||||
String listText = holder.listName.getText().toString();
|
||||
|
||||
if(listText.length() > 25) {
|
||||
holder.listName.setText(listText.substring(0, 25) + "...");
|
||||
}
|
||||
|
||||
if (curList.getEntries() != null) {
|
||||
|
||||
@ -1,7 +1,13 @@
|
||||
package com.example.listify.ui.store;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
@ -9,41 +15,119 @@ import android.view.ViewGroup;
|
||||
import android.view.LayoutInflater;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.example.listify.ListSharees;
|
||||
import com.example.listify.R;
|
||||
import com.example.listify.data.ListShare;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static com.example.listify.MainActivity.am;
|
||||
|
||||
public class StoreFragment extends Fragment {
|
||||
ListView listView;
|
||||
StoreFragment.MyAdapter myAdapter;
|
||||
|
||||
ArrayList<Integer> storeLogos = new ArrayList<>();
|
||||
ArrayList<String> storeNames = new ArrayList<>();
|
||||
ArrayList<String> storeURLs = new ArrayList<>();
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View root = inflater.inflate(R.layout.fragment_stores, container, false);
|
||||
|
||||
TextView krogerText = (TextView) root.findViewById(R.id.textView11);
|
||||
krogerText.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
gotoUrl("https://www.kroger.com/");
|
||||
}
|
||||
});
|
||||
storeLogos.add(-1);
|
||||
storeLogos.add(R.drawable.kroger);
|
||||
storeLogos.add(R.drawable.kohls);
|
||||
storeLogos.add(R.drawable.ebay);
|
||||
|
||||
TextView kohlsText = (TextView) root.findViewById(R.id.textView12);
|
||||
krogerText.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
gotoUrl("https://www.kohls.com/");
|
||||
}
|
||||
});
|
||||
storeNames.add("");
|
||||
storeNames.add("Kroger");
|
||||
storeNames.add("Kohl's");
|
||||
storeNames.add("Ebay");
|
||||
|
||||
TextView ebayText = (TextView) root.findViewById(R.id.textView13);
|
||||
krogerText.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
gotoUrl("https://www.ebay.com/");
|
||||
}
|
||||
});
|
||||
storeURLs.add("");
|
||||
storeURLs.add("https://www.kroger.com/");
|
||||
storeURLs.add("https://www.kohls.com/");
|
||||
storeURLs.add("https://www.ebay.com/");
|
||||
|
||||
listView = root.findViewById(R.id.listOfStores);
|
||||
myAdapter = new StoreFragment.MyAdapter(this.getContext(), storeLogos, storeNames, storeNames);
|
||||
listView.setAdapter(myAdapter);
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
class MyAdapter extends ArrayAdapter<String> {
|
||||
Context context;
|
||||
ArrayList<Integer> storeLogos = new ArrayList<>();
|
||||
ArrayList<String> storeNames = new ArrayList<>();
|
||||
ArrayList<String> storeURLs = new ArrayList<>();
|
||||
|
||||
MyAdapter (Context c, ArrayList<Integer> logos, ArrayList<String> names, ArrayList<String> urls) {
|
||||
super(c, R.layout.shopping_list_product_entry, R.id.productView, names);
|
||||
context = c;
|
||||
storeLogos = logos;
|
||||
storeNames = names;
|
||||
storeURLs = urls;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
||||
LayoutInflater layoutInflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
View listproduct = layoutInflater.inflate(R.layout.shopping_list_product_entry, parent,false);
|
||||
|
||||
TextView store = listproduct.findViewById(R.id.storeView);
|
||||
store.setVisibility(View.GONE);
|
||||
TextView price = listproduct.findViewById(R.id.priceView);
|
||||
price.setVisibility(View.GONE);
|
||||
TextView quantity = listproduct.findViewById(R.id.quantityView);
|
||||
quantity.setVisibility(View.GONE);
|
||||
|
||||
Button increase = listproduct.findViewById(R.id.buttonIncr);
|
||||
increase.setVisibility(View.GONE);
|
||||
Button decrease = listproduct.findViewById(R.id.buttonDecr);
|
||||
decrease.setVisibility(View.GONE);
|
||||
Button remove = listproduct.findViewById(R.id.buttonDel);
|
||||
remove.setVisibility(View.GONE);
|
||||
|
||||
ImageView image = listproduct.findViewById(R.id.imageView);
|
||||
if(position == 0) {
|
||||
image.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
image.setImageResource(storeLogos.get(position));
|
||||
}
|
||||
|
||||
TextView name = listproduct.findViewById(R.id.productView);
|
||||
if(position == 0) {
|
||||
name.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
name.setText(storeNames.get(position));
|
||||
name.setTextColor(Color.parseColor("#0000FF"));
|
||||
name.setTextSize(20);
|
||||
name.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
gotoUrl(storeURLs.get(position));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if(position == 0) {
|
||||
ConstraintLayout constraintLayout = listproduct.findViewById(R.id.constraintLayout);
|
||||
constraintLayout.setMaxHeight(0);
|
||||
}
|
||||
|
||||
return listproduct;
|
||||
}
|
||||
}
|
||||
|
||||
private void gotoUrl(String url) {
|
||||
Uri u = Uri.parse(url);
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, u));
|
||||
|
||||
BIN
Listify/app/src/main/res/drawable/ebay.png
Normal file
BIN
Listify/app/src/main/res/drawable/ebay.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
BIN
Listify/app/src/main/res/drawable/kohls.png
Normal file
BIN
Listify/app/src/main/res/drawable/kohls.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
BIN
Listify/app/src/main/res/drawable/kroger.png
Normal file
BIN
Listify/app/src/main/res/drawable/kroger.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 119 KiB |
@ -1,51 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView10"
|
||||
android:id="@+id/textStoresAvailable"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="22dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:padding="15dp"
|
||||
android:text="Stores available:"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
android:textStyle="bold"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView11"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="Kroger"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView10"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView10" />
|
||||
<ListView
|
||||
android:id="@+id/listOfStores"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="60dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView12"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="Kohl's"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView11"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView11" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView13"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="eBay"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView12"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView12" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</RelativeLayout>
|
||||
Loading…
Reference in New Issue
Block a user