Skip to content

Commit

Permalink
added feature ... half quantity and quarter quantity !
Browse files Browse the repository at this point in the history
  • Loading branch information
SumeetMoray committed Apr 15, 2020
1 parent da2c812 commit a319a11
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public class ShopItem{
private int availableItemQuantity;
private double itemPrice;

private boolean allowQuarterQuantity;
private boolean allowHalfQuantity;




Expand All @@ -50,10 +53,21 @@ public class ShopItem{
private Timestamp lastUpdateDateTime;


public boolean isAllowQuarterQuantity() {
return allowQuarterQuantity;
}

public void setAllowQuarterQuantity(boolean allowQuarterQuantity) {
this.allowQuarterQuantity = allowQuarterQuantity;
}

public boolean isAllowHalfQuantity() {
return allowHalfQuantity;
}


public void setAllowHalfQuantity(boolean allowHalfQuantity) {
this.allowHalfQuantity = allowHalfQuantity;
}

public double getItemPrice() {
return itemPrice;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class PrefServiceConfig {



public static final String SERVICE_URL_SDS = SDS_URL_NEARBY_SHOPS;
public static final String SERVICE_URL_SDS = SDS_URL_LOCAL_HOTSPOT;



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public class ViewHolderShopItem extends RecyclerView.ViewHolder{
@BindView(R.id.itemQuantity) TextView itemQuantityText;
@BindView(R.id.reduceQuantity) ImageView reduceQuantity;

@BindView(R.id.quantity_half) TextView quantityHalf;
@BindView(R.id.quantity_quarter) TextView quantityQuarter;




@BindView(R.id.out_of_stock_indicator) TextView outOfStockIndicator;
Expand Down Expand Up @@ -299,12 +303,13 @@ void quarterQuantityClick()

if (!itemQuantityText.getText().toString().equals("")){

itemQuantityText.setText("0.25");
// itemQuantityText.setText("0.25");

itemQuantityText.setText(String.valueOf(Double.parseDouble(itemQuantityText.getText().toString()) + 0.25));
}


// itemQuantityText.setText(String.valueOf(Double.parseDouble(itemQuantityText.getText().toString()) + 0.25));
itemQuantityText.setText("0.25");
// itemQuantityText.setText("0.25");

addToCartTimer();
}
Expand All @@ -322,14 +327,12 @@ void halfQuantityClick()

if (!itemQuantityText.getText().toString().equals("")){

itemQuantityText.setText("0.50");
}

// itemQuantityText.setText(String.valueOf(Double.parseDouble(itemQuantityText.getText().toString()) + 0.5));

// itemQuantityText.setText("0.50");

itemQuantityText.setText(String.valueOf(Double.parseDouble(itemQuantityText.getText().toString()) + 0.50));
}

itemQuantityText.setText("0.50");
// itemQuantityText.setText("0.50");

addToCartTimer();
}
Expand All @@ -350,6 +353,26 @@ public void bindShopItems(ShopItem shopItem)
// holder.distance.setText(String.format( "%.2f", dataset.get(position).getDistance() )+ " Km");


if(shopItem.isAllowQuarterQuantity())
{
quantityQuarter.setVisibility(View.VISIBLE);
}
else
{
quantityQuarter.setVisibility(View.GONE);
}




if(shopItem.isAllowHalfQuantity())
{
quantityHalf.setVisibility(View.VISIBLE);
}
else
{
quantityHalf.setVisibility(View.GONE);
}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import android.widget.Toast;

import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
Expand Down Expand Up @@ -71,6 +72,14 @@ public class ViewHolderShopItemSeller extends RecyclerView.ViewHolder{
@BindView(R.id.increaseQuantity)
ImageView increaseQuantity;


@BindView(R.id.allow_quarter_quantity)
TextView allowQuarterQuantity;

@BindView(R.id.allow_half_quantity)
TextView allowHalfQuantity;


@BindView(R.id.priceText)
TextView priceText;

Expand All @@ -84,8 +93,8 @@ public class ViewHolderShopItemSeller extends RecyclerView.ViewHolder{
ImageView increasePrice;

@BindView(R.id.removeButton) TextView removeButton;
@BindView(R.id.progress_bar_remove)
ProgressBar progressBarRemove;
@BindView(R.id.progress_bar_remove) ProgressBar progressBarRemove;


@BindView(R.id.updateButton) TextView updateButton;
@BindView(R.id.progress_bar) ProgressBar progressBarUpdate;
Expand Down Expand Up @@ -696,10 +705,79 @@ public void setShopItem(ShopItem shopItem)
priceText.setText("Price : " + shopItem.getItemPrice() + " per Item");
}



bindQuarterQuantity();
bindHalfQuantity();
}





private void bindQuarterQuantity()
{

if(shopItem.isAllowQuarterQuantity())
{
allowQuarterQuantity.setBackgroundColor(ContextCompat.getColor(context,R.color.buttonColor));
allowQuarterQuantity.setTextColor(ContextCompat.getColor(context,R.color.white));
}
else
{
allowQuarterQuantity.setBackgroundColor(ContextCompat.getColor(context,R.color.light_grey));
allowQuarterQuantity.setTextColor(ContextCompat.getColor(context,R.color.blueGrey800));
}

}





private void bindHalfQuantity()
{

if(shopItem.isAllowHalfQuantity())
{
allowHalfQuantity.setBackgroundColor(ContextCompat.getColor(context,R.color.buttonColor));
allowHalfQuantity.setTextColor(ContextCompat.getColor(context,R.color.white));
}
else
{
allowHalfQuantity.setBackgroundColor(ContextCompat.getColor(context,R.color.light_grey));
allowHalfQuantity.setTextColor(ContextCompat.getColor(context,R.color.blueGrey800));
}

}






@OnClick(R.id.allow_half_quantity)
void halfQuantityClick()
{
shopItem.setAllowHalfQuantity(!shopItem.isAllowHalfQuantity());

bindHalfQuantity();
}



@OnClick(R.id.allow_quarter_quantity)
void quarterQuantityClick()
{
shopItem.setAllowQuarterQuantity(!shopItem.isAllowQuarterQuantity());

bindQuarterQuantity();
}






private void showToastMessage(String message)
{
Expand Down
8 changes: 2 additions & 6 deletions app/src/main/res/layout/list_item_shop_item_seller.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@


<TextView
android:visibility="gone"
android:textColor="@color/white"
android:padding="5dp"
android:background="@color/gplus_color_1"
Expand All @@ -57,7 +56,6 @@


<LinearLayout
android:visibility="gone"
android:layout_marginTop="5dp"
android:id="@+id/quantities"
app:layout_constraintEnd_toEndOf="parent"
Expand All @@ -69,6 +67,7 @@


<TextView
android:id="@+id/allow_quarter_quantity"
android:layout_marginEnd="2.5dp"
android:background="@color/light_grey"
android:padding="5dp"
Expand All @@ -78,8 +77,8 @@
android:layout_width="0dp"
android:layout_height="wrap_content"/>


<TextView
android:id="@+id/allow_half_quantity"
android:background="@color/light_grey"
android:layout_marginStart="2.5dp"
android:padding="5dp"
Expand All @@ -89,9 +88,6 @@
android:layout_width="0dp"
android:layout_height="wrap_content"/>




</LinearLayout>


Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/list_item_shop_item_small.xml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@


<LinearLayout
android:visibility="gone"
android:layout_marginEnd="10dp"
app:layout_constraintBottom_toBottomOf="@id/reduceQuantity"
app:layout_constraintTop_toTopOf="@id/reduceQuantity"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/string_layouts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
<string name="list_item_shop_item_small_item_title_text">Item Name</string>
<string name="list_item_shop_item_small_item_price_text">Rs. 43 per Dozen</string>
<string name="list_item_shop_item_small_itemQuantity_text">0</string>
<string name="list_item_shop_item_small_quantity_quarter_text">Quarter</string>
<string name="list_item_shop_item_small_quantity_half_text">Half</string>
<string name="list_item_shop_item_small_quantity_quarter_text">+ Quarter</string>
<string name="list_item_shop_item_small_quantity_half_text">+ Half</string>
<string name="list_item_shop_item_small_add_label_text">Add</string>
<string name="list_item_shop_item_small_out_of_stock_indicator_text">Out of Stock</string>
<string name="list_item_shop_item_small_item_total_text"> - </string>
Expand Down

0 comments on commit a319a11

Please sign in to comment.