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"?>
<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" />
</component>
<component name="ProjectType">

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:elevation="4dp"
android:elevation="5dp"
card_view:cardUseCompatPadding="true"
card_view:cardElevation="5dp"
card_view:cardCornerRadius="1dp"
@ -20,38 +20,44 @@
android:layout_height="match_parent">
<ImageView
android:id="@+id/image"
android:id="@+id/productimage"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="?attr/selectableItemBackgroundBorderless"
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
android:id="@+id/productname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/image"
android:layout_below="@id/productprice"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"
android:textColor="@color/cardview_dark_background"
android:textSize="12sp"
android:textStyle="normal"
android:typeface="sans" />
android:textColor="@color/cardview_dark_background" />
<TextView
android:id="@+id/productprice"
android:id="@+id/productretailer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/productname"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"
android:textColor="@color/cardview_dark_background"
android:textSize="12sp"
android:textStyle="normal"
android:typeface="sans" />
android:textColor="@color/cardview_dark_background" />
</RelativeLayout>
</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">
<item
android:id="@+id/action_favourite"
android:title="Add to Favorite" />
<item
android:id="@+id/action_watch"
android:title="Watch Movie" />
<item
android:id="@+id/action_book"
android:title="Book Ticket" />
android:title="Dodaj do ulubionych" />
</menu>