mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-15 18:28:47 +00:00
Display logos in Stores page
This commit is contained in:
parent
2478a6c49a
commit
4c2fd8844d
@ -1,7 +1,13 @@
|
|||||||
package com.example.listify.ui.store;
|
package com.example.listify.ui.store;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.net.Uri;
|
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.widget.TextView;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -9,41 +15,119 @@ import android.view.ViewGroup;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import com.example.listify.ListSharees;
|
||||||
import com.example.listify.R;
|
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 {
|
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) {
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View root = inflater.inflate(R.layout.fragment_stores, container, false);
|
View root = inflater.inflate(R.layout.fragment_stores, container, false);
|
||||||
|
|
||||||
TextView krogerText = (TextView) root.findViewById(R.id.textView11);
|
storeLogos.add(-1);
|
||||||
krogerText.setOnClickListener(new View.OnClickListener() {
|
storeLogos.add(R.drawable.kroger);
|
||||||
@Override
|
storeLogos.add(R.drawable.kohls);
|
||||||
public void onClick(View v) {
|
storeLogos.add(R.drawable.ebay);
|
||||||
gotoUrl("https://www.kroger.com/");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
TextView kohlsText = (TextView) root.findViewById(R.id.textView12);
|
storeNames.add("");
|
||||||
krogerText.setOnClickListener(new View.OnClickListener() {
|
storeNames.add("Kroger");
|
||||||
@Override
|
storeNames.add("Kohl's");
|
||||||
public void onClick(View v) {
|
storeNames.add("Ebay");
|
||||||
gotoUrl("https://www.kohls.com/");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
TextView ebayText = (TextView) root.findViewById(R.id.textView13);
|
storeURLs.add("");
|
||||||
krogerText.setOnClickListener(new View.OnClickListener() {
|
storeURLs.add("https://www.kroger.com/");
|
||||||
@Override
|
storeURLs.add("https://www.kohls.com/");
|
||||||
public void onClick(View v) {
|
storeURLs.add("https://www.ebay.com/");
|
||||||
gotoUrl("https://www.ebay.com/");
|
|
||||||
}
|
listView = root.findViewById(R.id.listOfStores);
|
||||||
});
|
myAdapter = new StoreFragment.MyAdapter(this.getContext(), storeLogos, storeNames, storeNames);
|
||||||
|
listView.setAdapter(myAdapter);
|
||||||
|
|
||||||
return root;
|
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) {
|
private void gotoUrl(String url) {
|
||||||
Uri u = Uri.parse(url);
|
Uri u = Uri.parse(url);
|
||||||
startActivity(new Intent(Intent.ACTION_VIEW, u));
|
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"?>
|
<RelativeLayout
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
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_width="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:layout_height="match_parent"
|
|
||||||
>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/textView10"
|
android:id="@+id/textStoresAvailable"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="22dp"
|
android:padding="15dp"
|
||||||
android:layout_marginTop="30dp"
|
|
||||||
android:text="Stores available:"
|
android:text="Stores available:"
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"/>
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<TextView
|
<ListView
|
||||||
android:id="@+id/textView11"
|
android:id="@+id/listOfStores"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="60dp"/>
|
||||||
android:text="Kroger"
|
|
||||||
android:textSize="20sp"
|
|
||||||
app:layout_constraintStart_toStartOf="@+id/textView10"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/textView10" />
|
|
||||||
|
|
||||||
<TextView
|
</RelativeLayout>
|
||||||
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>
|
|
||||||
Loading…
Reference in New Issue
Block a user