-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[shivanshs9] Added spinner and quantity selection bar.
- Loading branch information
1 parent
d67af52
commit 517f4af
Showing
207 changed files
with
10,064 additions
and
59 deletions.
There are no files selected for viewing
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
app/src/main/java/com/alcatraz/admin/project_alcatraz/Utility/TextBaseAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.