Dopracuj kafelki ekranu wyników, dodaj wstępną wersję szablonu popupa

This commit is contained in:
Kacper Dudzic 2020-02-16 00:24:02 +01:00
parent b31d569759
commit 59a9b3d788
7 changed files with 131 additions and 67 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

View File

@ -12,14 +12,9 @@ public class Product extends AppCompatActivity {
setContentView(R.layout.activity_product); setContentView(R.layout.activity_product);
} }
/**
* Created by AndroidBash on 09/05/2016.
*/
private int id; private int id;
private String imageLink; private String imageLink;
private String productPrice; private String productPrice;
private String productCode; private String productCode;
private String productName; private String productName;
private String productRetailer; private String productRetailer;
@ -30,13 +25,12 @@ public class Product extends AppCompatActivity {
private String productSex; private String productSex;
public Product(int id, String imageLink, String productPrice, String productCode, String productName, String productRetailer, public Product(int id, String productCode, String productName, String imageLink, String productPrice, String productRetailer,
String productColour, String productStyle, String productCollection, String productType, String productSex) { String productColour, String productStyle, String productCollection, String productType, String productSex) {
this.id = id; this.id = id;
this.imageLink = imageLink; this.imageLink = imageLink;
this.productPrice = productPrice; this.productPrice = productPrice;
this.productCode = productCode; this.productCode = productCode;
this.productName = productName; this.productName = productName;
this.productRetailer = productRetailer; this.productRetailer = productRetailer;
@ -50,7 +44,6 @@ public class Product extends AppCompatActivity {
public int getId() { public int getId() {
return id; return id;
} }
public void setId(int id) { public void setId(int id) {
this.id = id; this.id = id;
} }
@ -58,7 +51,6 @@ public class Product extends AppCompatActivity {
public String getImageLink() { public String getImageLink() {
return imageLink; return imageLink;
} }
public void setImageLink(String imageLink) { public void setImageLink(String imageLink) {
this.imageLink = imageLink; this.imageLink = imageLink;
} }
@ -66,7 +58,6 @@ public class Product extends AppCompatActivity {
public String getproductPrice() { public String getproductPrice() {
return productPrice; return productPrice;
} }
public void setproductPrice(String productPrice) { public void setproductPrice(String productPrice) {
this.productPrice = productPrice; this.productPrice = productPrice;
} }
@ -74,7 +65,6 @@ public class Product extends AppCompatActivity {
public String getproductCode() { public String getproductCode() {
return productCode; return productCode;
} }
public void setproductCode(String productCode) { public void setproductCode(String productCode) {
this.productCode = productCode; this.productCode = productCode;
} }
@ -82,7 +72,6 @@ public class Product extends AppCompatActivity {
public String getproductName() { public String getproductName() {
return productName; return productName;
} }
public void setproductName(String productName) { public void setproductName(String productName) {
this.productName = productName; this.productName = productName;
} }
@ -90,15 +79,11 @@ public class Product extends AppCompatActivity {
public String getproductRetailer() { public String getproductRetailer() {
return productRetailer; return productRetailer;
} }
public void setproductRetailer(String productRetailer) { this.productRetailer = productRetailer; }
public void setproductRetailer(String productRetailer) {
this.productRetailer = productRetailer;
}
public String getproductColour() { public String getproductColour() {
return productColour; return productColour;
} }
public void setproductColour(String productColour) { public void setproductColour(String productColour) {
this.productColour = productColour; this.productColour = productColour;
} }
@ -106,7 +91,6 @@ public class Product extends AppCompatActivity {
public String getproductStyle() { public String getproductStyle() {
return productStyle; return productStyle;
} }
public void setproductStyle(String productStyle) { public void setproductStyle(String productStyle) {
this.productStyle = productStyle; this.productStyle = productStyle;
} }
@ -114,15 +98,11 @@ public class Product extends AppCompatActivity {
public String getproductCollection() { public String getproductCollection() {
return productCollection; return productCollection;
} }
public void setproductCollection(String productCollection) { this.productCollection = productCollection; }
public void setproductCollection(String productCollection) {
this.productCollection = productCollection;
}
public String getproductType() { public String getproductType() {
return productType; return productType;
} }
public void setproductType(String productType) { public void setproductType(String productType) {
this.productType = productType; this.productType = productType;
} }
@ -130,7 +110,6 @@ public class Product extends AppCompatActivity {
public String getproductSex() { public String getproductSex() {
return productSex; return productSex;
} }
public void setproductSex(String productSex) { public void setproductSex(String productSex) {
this.productSex = productSex; this.productSex = productSex;
} }

View File

@ -12,7 +12,7 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.PopupMenu; //????????????????????? import android.widget.PopupMenu;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -41,9 +41,10 @@ public class ProductsAdapter extends RecyclerView.Adapter<ProductsAdapter.ViewHo
@Override @Override
public void onBindViewHolder(final ViewHolder holder, int position) { public void onBindViewHolder(final ViewHolder holder, int position) {
holder.productName.setText(products.get(position).getproductName());
holder.productPrice.setText(products.get(position).getproductPrice()); //????????????????????????
Glide.with(context).load(products.get(position).getImageLink()).into(holder.imageView); Glide.with(context).load(products.get(position).getImageLink()).into(holder.imageView);
holder.productName.setText(products.get(position).getproductName());
holder.productPrice.setText(products.get(position).getproductPrice());
holder.productRetailer.setText(products.get(position).getproductRetailer());
} }
@Override @Override
@ -51,19 +52,20 @@ public class ProductsAdapter extends RecyclerView.Adapter<ProductsAdapter.ViewHo
return products.size(); return products.size();
} }
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{ public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
public ImageView imageView;
public TextView productName; public TextView productName;
public TextView productPrice; public TextView productPrice;
public ImageView imageView; public TextView productRetailer;
public ViewHolder(View itemView) { public ViewHolder(View itemView) {
super(itemView); super(itemView);
productName = (TextView) itemView.findViewById(R.id.productname); imageView = itemView.findViewById(R.id.productimage);
imageView = (ImageView) itemView.findViewById(R.id.image);
productPrice = (TextView) itemView.findViewById(R.id.productprice);
imageView.setOnClickListener(this); imageView.setOnClickListener(this);
productName = itemView.findViewById(R.id.productname);
productPrice = itemView.findViewById(R.id.productprice);
productRetailer = itemView.findViewById(R.id.productretailer);
} }
@Override @Override
@ -91,13 +93,8 @@ public class ProductsAdapter extends RecyclerView.Adapter<ProductsAdapter.ViewHo
public boolean onMenuItemClick(MenuItem menuItem) { public boolean onMenuItemClick(MenuItem menuItem) {
switch (menuItem.getItemId()) { switch (menuItem.getItemId()) {
case R.id.action_favourite: case R.id.action_favourite:
Toast.makeText(context, products.get(pos).getproductName()+" is added to favourite", Toast.LENGTH_SHORT).show(); Toast.makeText(context, "Produkt \"" + products.get(pos).getproductName() + "\" został dodany do ulubionych",
return true; Toast.LENGTH_SHORT).show();
case R.id.action_watch:
Toast.makeText(context, products.get(pos).getproductName()+" is added to watchlist", Toast.LENGTH_SHORT).show();
return true;
case R.id.action_book:
Toast.makeText(context, "Booked Ticket for "+ products.get(pos).getproductName(), Toast.LENGTH_SHORT).show();
return true; return true;
default: default:
} }

View File

@ -32,7 +32,6 @@ public class Results extends AppCompatActivity {
private GridLayoutManager gridLayout; private GridLayoutManager gridLayout;
private ProductsAdapter adapter; private ProductsAdapter adapter;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -67,9 +66,7 @@ public class Results extends AppCompatActivity {
protected Void doInBackground(Integer... productIds) { protected Void doInBackground(Integer... productIds) {
OkHttpClient client = new OkHttpClient(); OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder() Request request = new Request.Builder().url("http://192.168.8.101/products.php?id=" + productIds[0]).build();
.url("http://192.168.8.101/products.php?id=" + productIds[0]) //???????????????????
.build();
try { try {
Response response = client.newCall(request).execute(); Response response = client.newCall(request).execute();
@ -89,7 +86,6 @@ public class Results extends AppCompatActivity {
Results.this.products.add(product); Results.this.products.add(product);
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} catch (JSONException e) { } catch (JSONException e) {

View File

@ -9,7 +9,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="center" android:layout_gravity="center"
android:elevation="4dp" android:elevation="5dp"
card_view:cardUseCompatPadding="true" card_view:cardUseCompatPadding="true"
card_view:cardElevation="5dp" card_view:cardElevation="5dp"
card_view:cardCornerRadius="1dp" card_view:cardCornerRadius="1dp"
@ -20,38 +20,44 @@
android:layout_height="match_parent"> android:layout_height="match_parent">
<ImageView <ImageView
android:id="@+id/image" android:id="@+id/productimage"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="200dp" android:layout_height="200dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true" android:clickable="true"
android:scaleType="centerCrop" /> android:focusable="true"
android:scaleType="centerCrop"
android:background="?attr/selectableItemBackgroundBorderless"/>
<TextView
android:id="@+id/productprice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/productimage"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"
android:textColor="@color/cardview_dark_background"
android:textStyle="bold" />
<TextView <TextView
android:id="@+id/productname" android:id="@+id/productname"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/image" android:layout_below="@id/productprice"
android:paddingLeft="5dp" android:paddingLeft="5dp"
android:paddingRight="5dp" android:paddingRight="5dp"
android:paddingTop="5dp" android:paddingTop="5dp"
android:textColor="@color/cardview_dark_background" android:textColor="@color/cardview_dark_background" />
android:textSize="12sp"
android:textStyle="normal"
android:typeface="sans" />
<TextView <TextView
android:id="@+id/productprice" android:id="@+id/productretailer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/productname" android:layout_below="@id/productname"
android:paddingLeft="5dp" android:paddingLeft="5dp"
android:paddingRight="5dp" android:paddingRight="5dp"
android:paddingTop="5dp" android:paddingTop="5dp"
android:textColor="@color/cardview_dark_background" android:textColor="@color/cardview_dark_background" />
android:textSize="12sp"
android:textStyle="normal"
android:typeface="sans" />
</RelativeLayout> </RelativeLayout>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>

View File

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="350dp"
android:layout_height="475dp"
android:padding="5dp"
android:layout_gravity="center">
<ImageView
android:id="@+id/productimagedet"
android:layout_width="match_parent"
android:layout_height="300dp"
android:scaleType="fitCenter" />
<TextView
android:id="@+id/productcodedet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"/>
<TextView
android:id="@+id/productnamedet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"/>
<TextView
android:id="@+id/productpricedet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"/>
<TextView
android:id="@+id/productretailerdet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"/>
<TextView
android:id="@+id/productcolourdet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"/>
<TextView
android:id="@+id/productstyledet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp" />
<TextView
android:id="@+id/productcollectiondet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"/>
<Button
android:id="@+id/favourite_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dodaj do "
android:layout_marginTop="5dp"
android:layout_gravity="center_horizontal"/>
<Button
android:id="@+id/back_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Powrót"
android:layout_marginTop="5dp"
android:layout_gravity="center_horizontal"/>
</LinearLayout>
<!--
android:layout_width="match_parent"
android:layout_height="match_parent"
-->

View File

@ -3,11 +3,5 @@ xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<item <item
android:id="@+id/action_favourite" android:id="@+id/action_favourite"
android:title="Add to Favorite" /> android:title="Dodaj do ulubionych" />
<item
android:id="@+id/action_watch"
android:title="Watch Movie" />
<item
android:id="@+id/action_book"
android:title="Book Ticket" />
</menu> </menu>