Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.crystaldesigncenter.crystalreward.adapter;
- import android.content.Context;
- import android.support.annotation.NonNull;
- import android.support.v7.widget.RecyclerView;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.Button;
- import android.widget.ImageView;
- import android.widget.TextView;
- import com.afollestad.materialdialogs.DialogAction;
- import com.afollestad.materialdialogs.MaterialDialog;
- import com.crystaldesigncenter.crystalreward.R;
- import com.crystaldesigncenter.crystalreward.fragment.LuckyDrawInformationFragment;
- import com.crystaldesigncenter.crystalreward.manager.DialogCustomCountManager;
- import com.crystaldesigncenter.crystalreward.manager.DialogManager;
- import com.crystaldesigncenter.crystalreward.manager.bus.MainBus;
- import com.crystaldesigncenter.crystalreward.manager.bus.event.EventAddToBackStackFragment;
- /**
- * Created by peem-jirayu on 23/9/2559.
- */
- public class LuckyDrawRecyclerAdapter extends RecyclerView.Adapter {
- private static DialogCustomCountManager dialogCount;
- private static DialogManager dialogPopup;
- private static Context mContext;
- int type;
- public LuckyDrawRecyclerAdapter(Context context, DialogCustomCountManager dialog, DialogManager dialogPopup){
- this.mContext = context;
- this.dialogCount = dialog;
- this.dialogPopup = dialogPopup;
- }
- private static class ContentLuckyDraw extends RecyclerView.ViewHolder implements View.OnClickListener {
- public ImageView imgProductLuckyDraw;
- public TextView tvNameProductLuckyDraw;
- public TextView tvTextDescriptionLuckyDraw;
- public TextView tvMyTicketLuckyDraw;
- public TextView tvDrawLuckyDraw;
- public Button btnDrawLuckyDraw;
- public ContentLuckyDraw(View itemView) {
- super(itemView);
- imgProductLuckyDraw = (ImageView) itemView.findViewById(R.id.imgProductLuckyDraw);
- tvNameProductLuckyDraw = (TextView) itemView.findViewById(R.id.tvNameProductLuckyDraw);
- tvTextDescriptionLuckyDraw = (TextView) itemView.findViewById(R.id.tvTextDescriptionLuckyDraw);
- tvMyTicketLuckyDraw = (TextView) itemView.findViewById(R.id.tvMyTicketLuckyDraw);
- tvDrawLuckyDraw = (TextView) itemView.findViewById(R.id.tvDrawLuckyDraw);
- btnDrawLuckyDraw = (Button) itemView.findViewById(R.id.btnDrawLuckyDraw);
- btnDrawLuckyDraw.setOnClickListener(this);
- }
- @Override
- public void onClick(View view) {
- int position = getAdapterPosition();
- if (position != RecyclerView.NO_POSITION) {
- switch (position){
- case 1 : {
- dialogCount.showMsg(mContext, "", new MaterialDialog.SingleButtonCallback() {
- @Override
- public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
- dialogPopup.showMsg(mContext, "ยืนยัน", new MaterialDialog.SingleButtonCallback() {
- @Override
- public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
- }
- });
- }
- });
- }
- }
- }
- }
- }
- private static class HeaderLuckyDraw extends RecyclerView.ViewHolder {
- TextView tvDrawLuckyDrawHeader;
- public HeaderLuckyDraw(View itemView) {
- super(itemView);
- tvDrawLuckyDrawHeader = (TextView) itemView.findViewById(R.id.tvDrawLuckyDrawHeader);
- }
- }
- @Override
- public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- LayoutInflater inflater = LayoutInflater.from(parent.getContext());
- switch (type) {
- case 0: default: {
- View view = inflater.inflate(R.layout.recycler_view_lucky_draw, parent, false);
- ContentLuckyDraw content = new ContentLuckyDraw(view);
- return content;
- }
- case 1: {
- View view = inflater.inflate(R.layout.recycler_view_lucky_draw_header,parent,false);
- HeaderLuckyDraw header = new HeaderLuckyDraw(view);
- return header;
- }
- }
- }
- @Override
- public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
- //TODO : bind view holder with data from server
- }
- @Override
- public int getItemCount() {
- return 20;
- }
- @Override
- public int getItemViewType(int position) {
- //dummy data
- if (position == 0 || position == 2){
- type = 1;
- }else {
- type = 0;
- }
- return type;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement