package com.cygnusa.hyperm;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.github.siyamed.shapeimageview.CircularImageView;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.reflect.TypeToken;
import com.cygnusa.hyperm.tooltip.Tooltip;
import com.cygnusa.hyperm.util.ApiService;
import com.cygnusa.hyperm.util.GlobalData;
import com.cygnusa.hyperm.util.MainApplication;
import com.cygnusa.hyperm.util.UtilService;
import com.cygnusa.hyperm.wrappers.CommonResponse;
import com.cygnusa.hyperm.wrappers.ErrorResponse;
import com.cygnusa.hyperm.wrappers.GetCancelOrRescheduleList;
import com.cygnusa.hyperm.wrappers.Reasons;

import net.danlew.android.joda.JodaTimeAndroid;

import org.joda.time.LocalDate;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Objects;

import jp.wasabeef.recyclerview.animators.SlideInLeftAnimator;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class ViewScheduleActivity extends AppCompatActivity {

    ParticipantListAdapter dateAdapter;
    List<String> eTime = new ArrayList<>();
    List<String> sTime = new ArrayList<>();
    private TextView txtDate, txtLocation;
    private TextView txtTrainingStartDate, txtTrainingEndDate, txtTrainingName, txtTrainingUID;
    private TextView txtDescription, txtTotalParticipant, txtSubmissionDays;
    private ApiService restService;
    private List<Reasons> REASONS = new ArrayList<>();
    private String[] reasonName = {"None"};
    private String[] reasonId = {"None"};
    private String reasonIdString = "";
    private Button btnPublish, btnCancel, btnList, btnModify;
    private List<Integer> PARTICIPANTIDS = new ArrayList<>();
    private LinearLayout layoutBtn, layoutDate, lloutModify;
    private String id1;
    private String id2;
    private ImageView imgSchedule;

    @SuppressLint("SetTextI18n")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        JodaTimeAndroid.init(this);
        setContentView(R.layout.activity_view_training_schedule);

        Toolbar toolbar = findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        toolbar.setContentInsetStartWithNavigation(0);
        toolbar.setTitle("");
        Objects.requireNonNull(getSupportActionBar()).setTitle("");
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowHomeEnabled(true);


        @SuppressLint("PrivateResource")
        Drawable backArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_material);
        backArrow.setColorFilter(getResources().getColor(R.color.btn_bg_color), PorterDuff.Mode.SRC_ATOP);
        getSupportActionBar().setHomeAsUpIndicator(backArrow);

        restService = ((MainApplication) getApplication()).getClient();

        txtDate = findViewById(R.id.txtDate);
        txtLocation = findViewById(R.id.txtLocation);

        txtTrainingStartDate = findViewById(R.id.txtTrainingStartDate);
        txtTrainingEndDate = findViewById(R.id.txtTrainingEndDate);
        txtTrainingName = findViewById(R.id.txtTrainingName);
        txtDescription = findViewById(R.id.txtDescription);
        txtTotalParticipant = findViewById(R.id.txtTotalParticipant);
        txtSubmissionDays = findViewById(R.id.txtSubmissionDays);
        txtTrainingUID = findViewById(R.id.txtTrainingUID);

        btnPublish = findViewById(R.id.btnPublish);
        btnCancel = findViewById(R.id.btnCancel);
        btnModify = findViewById(R.id.btnModify);
        btnList = findViewById(R.id.btnList);
        lloutModify = findViewById(R.id.lloutModify);
        imgSchedule = findViewById(R.id.imgSchedule);

        if (GlobalData.scheduledDataList.get(0).isTraining_update_status() && GlobalData.scheduledDataList.get(0).getIsActiveHours().equalsIgnoreCase("1"))
            lloutModify.setVisibility(View.VISIBLE);
        else
            lloutModify.setVisibility(View.GONE);

        layoutBtn = findViewById(R.id.layoutBtn);
        layoutDate = findViewById(R.id.layoutDate);


        if (GlobalData.scheduledDataList.get(0).getStatus().equalsIgnoreCase("1")) {
            layoutBtn.setVisibility(View.GONE);
        }

        if (GlobalData.scheduledDataList.get(0).getIsDeleted().equalsIgnoreCase("1")) {
            btnPublish.setVisibility(View.GONE);
            btnCancel.setText("Training Cancelled");
            btnCancel.setBackground(getResources().getDrawable(R.drawable.border_full_red));
            btnCancel.setEnabled(false);
            imgSchedule.setVisibility(View.GONE);
            lloutModify.setVisibility(View.GONE);
            layoutBtn.setVisibility(View.VISIBLE);
            btnModify.setVisibility(View.GONE);
        }

        btnList.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if ((GlobalData.scheduledDataList.get(0).getParticipant() != null) && GlobalData.scheduledDataList.get(0).getParticipant().size() > 0)
                    openPopup();
                else
                    GlobalData.toast(ViewScheduleActivity.this, "No Participant List Available");

            }
        });

        imgSchedule.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if ((GlobalData.scheduledDataList.get(0).getParticipant() != null) && GlobalData.scheduledDataList.get(0).getParticipant().size() > 0)
                    openPopup();
                else
                    GlobalData.toast(ViewScheduleActivity.this, "No Participant List Available");
            }
        });

        btnCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });

        btnPublish.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                try {
                    sendAllTrainingDatasToServer("1");
                } catch (JSONException e) {
                    e.printStackTrace();
                }

            }
        });


        if (GlobalData.scheduledDataList != null && GlobalData.scheduledDataList.size() > 0) {
            txtDate.setText(GlobalData.scheduledDataList.get(0).getTitle());

            String startDate = GlobalData.scheduledDataList.get(0).getStartDate();
            String endDate = GlobalData.scheduledDataList.get(0).getEndDate();

            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
            String startDateString = "", endDateString = "";
            try {
                startDateString = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault()).format(Objects.requireNonNull(format.parse(startDate)));
                endDateString = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault()).format(Objects.requireNonNull(format.parse(endDate)));
            } catch (ParseException e) {
                e.printStackTrace();
            }

            String s = GlobalData.scheduledDataList.get(0).getStartdate();
            String e = GlobalData.scheduledDataList.get(0).getEnddate();

            LocalDate start = LocalDate.parse(s);
            LocalDate end = LocalDate.parse(e);
            List<LocalDate> totalDates = new ArrayList<>();
            while (!start.isAfter(end)) {
                totalDates.add(start);

                start = start.plusDays(1);
            }

            String startTime = GlobalData.scheduledDataList.get(0).getStarttime();
            String endTime = GlobalData.scheduledDataList.get(0).getEndtime();

            try {
                JSONArray arrayFromTime = new JSONArray(startTime);
                for (int i = 0; i < arrayFromTime.length(); i++) {
                    id1 = (String) arrayFromTime.get(i);
                    sTime.add(id1);
                }
                JSONArray arrayToTime = new JSONArray(endTime);
                for (int i = 0; i < arrayToTime.length(); i++) {
                    id2 = (String) arrayToTime.get(i);
                    eTime.add(id2);
                }
            } catch (JSONException e1) {
                sTime.add(startTime);
                eTime.add(endTime);
                e1.printStackTrace();
            }
            int trainingDays = Integer.parseInt(GlobalData.scheduledDataList.get(0).getTrainingDays());

            for (int i = 0; i < trainingDays; i++) {
                TextView txtDays = new TextView(this);
                txtDays.setTextSize(15);
                txtDays.setTextColor(Color.parseColor("#00344C"));
                txtDays.setPadding(0, 0, 0, 0);
                if (sTime.size() - 1 >= i && eTime.size() - 1 >= i)
                    txtDays.setText("Day " + (i + 1) + " : " + totalDates.get(i) + " " + sTime.get(i) + " - " + eTime.get(i));
                txtDays.setTypeface(Typeface.DEFAULT_BOLD);
                layoutDate.addView(txtDays);
            }

            txtLocation.setText(GlobalData.scheduledDataList.get(0).getVenueAddress());
            txtTrainingStartDate.setText(startDateString);
            txtTrainingEndDate.setText(endDateString);
            txtDescription.setText(GlobalData.scheduledDataList.get(0).getScheduleName());
            txtTrainingName.setText(GlobalData.scheduledDataList.get(0).getTitle());
            if (GlobalData.scheduledDataList.get(0).getParticipant() != null && GlobalData.scheduledDataList.get(0).getParticipant().size() > 0)
                txtTotalParticipant.setText(String.valueOf(GlobalData.scheduledDataList.get(0).getParticipant().size()));
            txtSubmissionDays.setText(String.valueOf(GlobalData.scheduledDataList.get(0).getTrainingDays()));
            txtTrainingUID.setText("TRAINING UID : " + "");
        }

        getReasons();
//        getScheduledList();


        LinearLayout lloutEdit = findViewById(R.id.lloutEdit);

        txtTrainingUID.setText("TRAINING UID : " + GlobalData.scheduledDataList.get(0).

                getTraining_id());

        if (GlobalData.user.getData().

                getRole().

                equalsIgnoreCase("5")) {
            lloutEdit.setVisibility(View.VISIBLE);
        } else {
            lloutEdit.setVisibility(View.GONE);
        }

        lloutModify.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(ViewScheduleActivity.this, ModifyClassRoomActivity.class));
                finish();
            }
        });
        btnModify.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                startActivity(new Intent(ViewScheduleActivity.this, ModifyClassRoomActivity.class));
                finish();
            }
        });
    }

    public void openPopup() {
        final Dialog aDialog = new Dialog(this);
        aDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        aDialog.setContentView(R.layout.particiapnt_popup);
        aDialog.setCancelable(true);
        aDialog.show();
        TextView textTrainer = aDialog.findViewById(R.id.txtTrainer);
        textTrainer.setText(GlobalData.scheduledDataList.get(0).getOrganizerName());

        ImageView imgTrainer = aDialog.findViewById(R.id.imgTrainer);

        ImageView close = aDialog.findViewById(R.id.closeButton);

        close.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                aDialog.dismiss();
            }
        });

        if (GlobalData.scheduledDataList.get(0).getTrainingGroupImage() != null || !GlobalData.scheduledDataList.get(0).getTrainingGroupImage().isEmpty()) {
            Glide.with(ViewScheduleActivity.this).load(GlobalData.scheduledDataList.get(0).getTrainingGroupImage())
                    .thumbnail(Glide.with(ViewScheduleActivity.this).load(R.drawable.gif_loader))
                    .apply(new RequestOptions().fitCenter().diskCacheStrategy(DiskCacheStrategy.ALL)
                            .placeholder(R.drawable.placeholder)).into(imgTrainer);
        } else {
            Glide.with(ViewScheduleActivity.this).load(R.drawable.placeholder)
                    .thumbnail(Glide.with(ViewScheduleActivity.this).load(R.drawable.gif_loader))
                    .apply(new RequestOptions().fitCenter().diskCacheStrategy(DiskCacheStrategy.ALL)
                            .placeholder(R.drawable.placeholder)).into(imgTrainer);
        }
        RecyclerView rcvParticipant = aDialog.findViewById(R.id.rcvParticipant);
        rcvParticipant.setHasFixedSize(true);
        rcvParticipant.setItemAnimator(new SlideInLeftAnimator());
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getBaseContext());
        rcvParticipant.setLayoutManager(linearLayoutManager);
        dateAdapter = new ParticipantListAdapter();
        rcvParticipant.setAdapter(dateAdapter);
    }

    private void getReasons() {
        if (new UtilService().isNetworkAvailable(Objects.requireNonNull(ViewScheduleActivity.this))) {
            try {
                restService.getCancelOrReschedule().enqueue(new Callback<GetCancelOrRescheduleList>() {
                    @Override
                    public void onResponse(Call<GetCancelOrRescheduleList> call, Response<GetCancelOrRescheduleList> response) {
                        if (response.body() != null && response.body().getStatus() == 200) {
                            if (response.body().getReasonsList() != null && response.body().getReasonsList().size() > 0) {
                                REASONS = response.body().getReasonsList();
                                reasonName = new String[REASONS.size()];
                                reasonId = new String[REASONS.size()];
                                for (int i = 0; i < response.body().getReasonsList().size(); i++) {
                                    reasonName[i] = REASONS.get(i).getName();
                                    reasonId[i] = REASONS.get(i).getId();
                                }
                            }
                        } else if (response.body() != null && response.body().getStatus() == 401) {
                            GlobalData.canLogout = true;
                            finish();
                        } else if (response.body() != null) {
                            GlobalData.showToast(getBaseContext(), response.body().getMessage(), Toast.LENGTH_SHORT).show();
                        } else if (response.errorBody() != null) {
                            Gson gson = new Gson();
                            ErrorResponse message = gson.fromJson(response.errorBody().charStream(), ErrorResponse.class);
                            GlobalData.showToast(getBaseContext(), message.getMessage(), Toast.LENGTH_SHORT).show();
                            if (message.getStatus() == 401) {
                                GlobalData.canLogout = true;
                                finish();
                            }
                        }
                    }

                    @Override
                    public void onFailure(Call<GetCancelOrRescheduleList> call, Throwable t) {
                    }
                });
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    private void sendAllTrainingDatasToServer(String s) throws JSONException {

        JSONObject assessment = new JSONObject();
        try {
            for (int j = 0; j < GlobalData.scheduledDataList.get(0).getAssessment().size(); j++) {
                assessment.put("name", GlobalData.scheduledDataList.get(0).getAssessment().get(j).getAssessmentname());
                assessment.put("ques_count", GlobalData.scheduledDataList.get(0).getAssessment().get(j).getTotalQuestion());
                assessment.put("duration", GlobalData.scheduledDataList.get(0).getAssessment().get(j).getAssessmenttime());
                assessment.put("assessment", GlobalData.scheduledDataList.get(0).getAssessment().get(j).getAssessmenttype());
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

        JSONArray jsonArray = new JSONArray();
        jsonArray.put(assessment);

        JSONObject assessmentObj = new JSONObject();
        assessmentObj.put("assessments", jsonArray);

        Gson gson = new Gson();
        JsonElement dseJsonElement = null;

        for (int i = 0; i < GlobalData.scheduledDataList.get(0).getParticipant().size(); i++) {
            PARTICIPANTIDS.add(Integer.valueOf(GlobalData.scheduledDataList.get(0).getParticipant().get(i).getUserid()));
        }

        dseJsonElement = gson.toJsonTree(
                PARTICIPANTIDS, new TypeToken<ArrayList<String>>() {
                }.getType());


        HashMap<String, String> map = new HashMap<>();

        map.put("title", GlobalData.scheduledDataList.get(0).getLvlId());
        map.put("description", GlobalData.scheduledDataList.get(0).getScheduleName());
        map.put("startdate", GlobalData.scheduledDataList.get(0).getStartdate());
        map.put("enddate", GlobalData.scheduledDataList.get(0).getEnddate());
        map.put("starttime", GlobalData.scheduledDataList.get(0).getStarttime());
        map.put("endtime", GlobalData.scheduledDataList.get(0).getEndtime());
        map.put("venue_am", GlobalData.scheduledDataList.get(0).getVenueAm());
        map.put("schedule_id", GlobalData.scheduledDataList.get(0).getScheduleId());

        map.put("is_feedback", GlobalData.scheduledDataList.get(0).getIsFeedback());
        map.put("venue_type", GlobalData.scheduledDataList.get(0).getVenueType());
        map.put("venue_address", GlobalData.scheduledDataList.get(0).getVenueAddress());
        map.put("venue_dealer", GlobalData.scheduledDataList.get(0).getVenueDealer());
        map.put("assessments", jsonArray.toString());
        map.put("dse", dseJsonElement.toString());

        map.put("adhoc_training", GlobalData.scheduledDataList.get(0).getAdhocTraining());
        map.put("business_segment", GlobalData.scheduledDataList.get(0).getBusinessSegment());
        map.put("training_other_title", GlobalData.scheduledDataList.get(0).getTrainingOtherTitle());
        map.put("date_restriction", GlobalData.scheduledDataList.get(0).getDateRestriction());
        map.put("status", s);

        Log.e("MapValue", map.toString());

        restService.sendAllUpdateTrainingToServer(map).enqueue(new Callback<CommonResponse>() {
            @Override
            public void onResponse(Call<CommonResponse> call, Response<CommonResponse> response) {
                if (response.body() != null) {
                    if (response.body().getResponse().equalsIgnoreCase("Success")) {
                        GlobalData.toast(ViewScheduleActivity.this, "Published Successfully");
                        startActivity(new Intent(ViewScheduleActivity.this, ClassRoomTrainerTainingActivity.class));
                        finish();
                    } else {
                        GlobalData.toast(ViewScheduleActivity.this, response.body().getResponseText());
                    }

                } else if (response.body() != null && response.body().getStatus() == 401) {
                    GlobalData.canLogout = true;
                    finish();
                } else if (response.errorBody() != null) {
                    Gson gson = new Gson();
                    ErrorResponse message = gson.fromJson(response.errorBody().charStream(), ErrorResponse.class);
                    GlobalData.showToast(getBaseContext(), message.getMessage(), Toast.LENGTH_SHORT).show();
                    if (message.getStatus() == 401) {
                        GlobalData.canLogout = true;
                        finish();
                    }
                }
            }

            @Override
            public void onFailure(Call<CommonResponse> call, Throwable t) {

            }
        });
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        startActivity(new Intent(ViewScheduleActivity.this, ClassRoomTrainerTainingActivity.class));
        finish();
        this.overridePendingTransition(R.anim.animation_f_enter,
                R.anim.animation_f_leave);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            finish();
            onBackPressed();
        }
        return super.onOptionsItemSelected(item);
    }

    private static class ParticipantViewHolder extends RecyclerView.ViewHolder {

        TextView txtName, txtStatus;
        CircularImageView imgPic;
        ImageView info;

        public ParticipantViewHolder(@NonNull View itemView) {
            super(itemView);

            txtName = itemView.findViewById(R.id.txt_Name);
            txtStatus = itemView.findViewById(R.id.txtStatus);
            imgPic = itemView.findViewById(R.id.imgPic);
            info = itemView.findViewById(R.id.info);

        }

    }

    private class ParticipantListAdapter extends RecyclerView.Adapter<ParticipantViewHolder> {

        @NonNull
        @Override
        public ParticipantViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
            View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.participant_view_holder, parent, false);

            return new ParticipantViewHolder(v);
        }

        @Override
        public void onBindViewHolder(@NonNull ParticipantViewHolder holder, int position) {

            if (GlobalData.scheduledDataList.get(0).getParticipant().get(position).getName() == null || GlobalData.scheduledDataList.get(0).getParticipant().get(position).getName().isEmpty()) {
                holder.txtName.setText("No Name");
            } else {
                holder.txtName.setText(GlobalData.scheduledDataList.get(0).getParticipant().get(position).getSmpin() + " " +
                        GlobalData.scheduledDataList.get(0).getParticipant().get(position).getName());
            }
            if (GlobalData.scheduledDataList.get(0).getParticipant().get(position).getStatus().equalsIgnoreCase("0")) {
                holder.txtStatus.setText("Waiting for response");
                holder.txtStatus.setTextColor(Color.parseColor("#808080"));
            } else if (GlobalData.scheduledDataList.get(0).getParticipant().get(position).getStatus().equalsIgnoreCase("1")) {
                holder.txtStatus.setText("Acknowledged");
                holder.txtStatus.setTextColor(Color.parseColor("#348E00"));
            } else if (GlobalData.scheduledDataList.get(0).getParticipant().get(position).getStatus().equalsIgnoreCase("2")) {
                holder.txtStatus.setText("Declined");
                holder.info.setVisibility(View.VISIBLE);
                holder.txtStatus.setTextColor(Color.parseColor("#F90303"));
            }

            holder.info.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    String header = GlobalData.scheduledDataList.get(0).getParticipant().get(position).getDeclineReasonName() + "/" + GlobalData.scheduledDataList.get(0).getParticipant().get(position).getDeclineReasonDesc();
                    View mView = LayoutInflater.from(ViewScheduleActivity.this).inflate(R.layout.tooltip_layout, null);
                    TextView text = mView.findViewById(R.id.text11);
                    TextView txtReasonTitle = mView.findViewById(R.id.txtReasonTitle);
                    txtReasonTitle.setText(GlobalData.scheduledDataList.get(0).getParticipant().get(position).getDeclineReasonName());
                    text.setText(header);
                    Tooltip.TooltipView tooltip = Tooltip.make(ViewScheduleActivity.this,
                            new Tooltip.Builder(101)
                                    .anchor(view, Tooltip.Gravity.TOP)
                                    .closePolicy(new Tooltip.ClosePolicy()
                                            .insidePolicy(true, false)
                                            .outsidePolicy(true, false), 0)
                                    .activateDelay(300)
                                    .withStyleId(R.style.ToolTipLayoutCustomStyle)
                                    .showDelay(300)
                                    .text("")
                                    .setBgColor(getResources().getColor(R.color.bg_color))
                                    .view(mView)
                                    .maxWidth(300)
                                    .withArrow(true)
                                    .build()
                    );
                    tooltip.setTextColor(Color.WHITE);
                    tooltip.show();
                }
            });

            if (GlobalData.scheduledDataList.get(0).getParticipant().get(position).getProfilePhoto() != null || !GlobalData.scheduledDataList.get(0).getParticipant().get(position).getProfilePhoto().isEmpty()) {
                Glide.with(ViewScheduleActivity.this).load(GlobalData.scheduledDataList.get(0).getParticipant().get(position).getProfilePhoto())
                        .thumbnail(Glide.with(ViewScheduleActivity.this).load(R.drawable.gif_loader))
                        .apply(new RequestOptions().fitCenter().diskCacheStrategy(DiskCacheStrategy.ALL)
                                .placeholder(R.drawable.placeholder)).into(holder.imgPic);
            } else {
                Glide.with(ViewScheduleActivity.this).load(R.drawable.placeholder)
                        .thumbnail(Glide.with(ViewScheduleActivity.this).load(R.drawable.gif_loader))
                        .apply(new RequestOptions().fitCenter().diskCacheStrategy(DiskCacheStrategy.ALL)
                                .placeholder(R.drawable.placeholder)).into(holder.imgPic);
            }
        }


        @Override
        public int getItemCount() {
            return GlobalData.scheduledDataList.get(0).getParticipant().size();
        }

    }
}
