package com.cygnusa.hyperm.adapter;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.cygnusa.hyperm.R;

public class MyHyperRankingAdapter extends RecyclerView.Adapter<MyHyperRankingAdapter.ViewHolder> {

    private Activity activity;

    public MyHyperRankingAdapter(Activity activity) {
        this.activity = activity;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.leader_board_item, parent, false);
        return new ViewHolder(v);
    }

    @SuppressLint("SetTextI18n")
    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        if (position == 0) {
            holder.score.setText("70%");
            holder.name.setText("Sharmila");
        } else if (position == 1) {
            holder.score.setText("60%");
            holder.name.setText("Dhileep");
        } else if (position == 2) {
            holder.score.setText("50%");
            holder.name.setText("Ranjith");
        } else if (position == 3) {
            holder.score.setText("40%");
            holder.name.setText("Lokesh");
        } else if (position == 4) {
            holder.score.setText("30%");
            holder.name.setText("Jack");
        }

    }


    @Override
    public int getItemCount() {
        return 5;
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        TextView name, location, duration, dateTime, position, score, dealerName;
        ImageView userImage, cup, imgBadge;
        View view;

        private ViewHolder(View itemView) {
            super(itemView);
            view = itemView;
            name = itemView.findViewById(R.id.name);
            location = itemView.findViewById(R.id.location);
            duration = itemView.findViewById(R.id.duration);
            dealerName = itemView.findViewById(R.id.dealer_name);
            dateTime = itemView.findViewById(R.id.dateTime);
            score = itemView.findViewById(R.id.score);
            position = itemView.findViewById(R.id.position);
            userImage = itemView.findViewById(R.id.userImage);
            imgBadge = view.findViewById(R.id.myPositionBadge);
            cup = itemView.findViewById(R.id.cup);
        }
    }
}