Skip to content

Commit

Permalink
[shivanshs9] Added spinner and quantity selection bar.
Browse files Browse the repository at this point in the history
  • Loading branch information
shivanshs9 committed Jun 10, 2018
1 parent d67af52 commit 517f4af
Show file tree
Hide file tree
Showing 207 changed files with 10,064 additions and 59 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}

dependencies {
Expand All @@ -44,6 +48,6 @@ dependencies {
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'com.yarolegovich:discrete-scrollview:1.4.7'
implementation project(':library:MaterialSearchView')
implementation 'com.github.arcadefire:nice-spinner:1.3.4'
implementation project(':library:NiceSpinner')
implementation 'com.robertlevonyan.view:MaterialChipView:1.2.1'
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
package com.alcatraz.admin.project_alcatraz.Session;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.TextView;

import com.alcatraz.admin.project_alcatraz.R;
import com.alcatraz.admin.project_alcatraz.Utility.TextBaseAdapter;
import com.alcatraz.admin.project_alcatraz.Utility.Util;
import com.yarolegovich.discretescrollview.DiscreteScrollView;
import com.yarolegovich.discretescrollview.transform.ScaleTransformer;

import org.angmarch.views.NiceSpinnerArrowOnly;

import java.util.ArrayList;
import java.util.Arrays;

public class MenuItemAdapter extends RecyclerView.Adapter<MenuItemAdapter.ItemViewHolder> {
private ArrayList<MenuItem> mItemsList;
Expand Down Expand Up @@ -77,21 +86,44 @@ public int getItemCount() {
static class ItemViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
TextView vTitle;
View vPriceLayout;
ImageView vPriceButton;
MenuItem mMenuItem;
// NiceSpinner vSpinner;
NiceSpinnerArrowOnly vSpinner;
DiscreteScrollView vQuantityPicker;

ItemViewHolder(View itemView) {
super(itemView);
vTitle = itemView.findViewById(R.id.item_title);
vPriceLayout = itemView.findViewById(R.id.price_layout);
vPriceButton = itemView.findViewById(R.id.price_button);
vPriceLayout.setOnClickListener(this);
/*vSpinner = itemView.findViewById(R.id.spinner);

vQuantityPicker = itemView.findViewById(R.id.quantity_picker);
vQuantityPicker.setAdapter(new TextBaseAdapter(
Util.range(0, 30),
itemView.getResources().getColor(R.color.light_grey),
itemView.getResources().getColor(R.color.brownish_grey))
);
vQuantityPicker.addOnItemChangedListener(new DiscreteScrollView.OnItemChangedListener<RecyclerView.ViewHolder>() {
@Override
public void onCurrentItemChanged(@Nullable RecyclerView.ViewHolder viewHolder, int adapterPosition) {
if (adapterPosition != 0) {
vPriceButton.setImageResource(R.drawable.menu_selected_item_price);
}
else {
vPriceButton.setImageResource(R.drawable.menu_item_price);
}
}
});

vSpinner = itemView.findViewById(R.id.spinner);
vSpinner.attachDataSource(Arrays.asList(itemView.getResources().getStringArray(R.array.spinner_options)));
vSpinner.addOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Log.e("Spinner", "Selected: #" + vSpinner.getSelectedIndex());
}
});*/
});
}

void bindData(MenuItem menuItem) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package com.alcatraz.admin.project_alcatraz.Utility;

import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v4.graphics.ColorUtils;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.alcatraz.admin.project_alcatraz.R;
import com.yarolegovich.discretescrollview.DiscreteScrollView;
import com.yarolegovich.discretescrollview.transform.ScaleTransformer;

import java.util.Arrays;

public class TextBaseAdapter extends RecyclerView.Adapter<TextBaseAdapter.TextViewHolder> {
private String[] data;
private DiscreteScrollView recyclerView;
private int textColor, selectedColor;

public TextBaseAdapter(int[] data) {
this.data = Arrays.toString(data).split("[\\[\\]]")[1].split(", ");
}

public TextBaseAdapter(int[] data, int textColor, int selectedColor) {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// this.data = Arrays.stream(data).mapToObj(String::valueOf).toArray(String[]::new);
// } else {
this.data = Arrays.toString(data).split("[\\[\\]]")[1].split(", ");
// }
this.textColor = textColor;
this.selectedColor = selectedColor;
}

@Override
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
this.recyclerView = (DiscreteScrollView) recyclerView;

this.recyclerView.setItemTransitionTimeMillis(150);
this.recyclerView.setItemTransformer(new ScaleTransformer() {
@Override
public void transformItem(View item, float position) {
float closenessToCenter = 1f - Math.abs(position);
super.transformItem(item, position);
((TextView) item.findViewById(R.id.item_text)).setTextColor(ColorUtils.blendARGB(textColor, selectedColor, closenessToCenter));
}
});
}

@Override
public int getItemViewType(final int position) {
return R.layout.list_text_layout;
}

@NonNull
@Override
public TextViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
final View view = LayoutInflater.from(parent.getContext()).inflate(viewType, parent, false);
return new TextViewHolder(view);
}

@Override
public void onBindViewHolder(@NonNull TextViewHolder holder, int position) {
holder.bindData(data[position], recyclerView.getCurrentItem() == position);
}

@Override
public int getItemCount() {
return data.length;
}

public class TextViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
TextView vText;

TextViewHolder(View view) {
super(view);
vText = view.findViewById(R.id.item_text);
vText.setOnClickListener(this);
}

void bindData(String value, boolean selected) {
vText.setText(value);
if (selected)
vText.setTextColor(selectedColor);
else
vText.setTextColor(textColor);
}

@Override
public void onClick(View v) {
recyclerView.smoothScrollToPosition(getAdapterPosition());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import android.view.animation.AnimationSet;
import android.widget.TextView;

import java.util.ArrayList;

/**
* Created by shivanshs9 on 12/5/18.
*/
Expand Down Expand Up @@ -146,4 +148,15 @@ public void onAnimationUpdate(ValueAnimator valueAnimator) {
}


public static int[] range(int start, int stop) {
return range(start, stop, 1);
}

private static int[] range(int start, int stop, int step) {
int[] ar = new int[(stop - start) / step];
int j = 0;
for (int i = start; i < stop; i += step)
ar[j++] = i;
return ar;
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions app/src/main/res/layout/list_text_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="center"
android:layout_margin="2dp"
>
<TextView
android:textAlignment="center"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/item_text"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="@color/brownish_grey"
android:text="DUMMY"/>
</FrameLayout>
53 changes: 12 additions & 41 deletions app/src/main/res/layout/menu_filter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,83 +6,54 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:id="@+id/im_breakfast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginStart="15dp"
android:layout_marginTop="12dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_menu_filter_breakfast" />

<TextView
android:id="@+id/lbl_breakfast"
android:id="@+id/btn_breakfast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginStart="15dp"
android:layout_marginTop="8dp"
android:drawableTop="@drawable/ic_menu_filter_breakfast"
android:text="Breakfast"
android:textAlignment="center"
android:textColor="@color/colorPrimaryRed"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/im_breakfast" />
app:layout_constraintTop_toTopOf="parent" />

<ImageView
android:id="@+id/im_lunch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="12dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_menu_filter_lunch" />

<TextView
android:id="@+id/lbl_lunch"
android:id="@+id/btn_lunch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:drawableTop="@drawable/ic_menu_filter_lunch"
android:text="Lunch"
android:textAlignment="center"
android:textColor="@color/colorPrimaryRed"
android:textSize="12sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/im_lunch" />


<ImageView
android:id="@+id/im_dinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="12dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_menu_filter_dinner" />
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/lbl_dinner"
android:id="@+id/btn_dinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="8dp"
android:drawableTop="@drawable/ic_menu_filter_dinner"
android:text="Dinner"
android:textAlignment="center"
android:textColor="@color/colorPrimaryRed"
android:textSize="12sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/im_dinner" />
app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>
Loading

0 comments on commit 517f4af

Please sign in to comment.