ViewScheduleActivity.java 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. package com.cygnusa.hyperm;
  2. import android.annotation.SuppressLint;
  3. import android.app.Dialog;
  4. import android.content.Intent;
  5. import android.graphics.Color;
  6. import android.graphics.PorterDuff;
  7. import android.graphics.Typeface;
  8. import android.graphics.drawable.Drawable;
  9. import android.os.Bundle;
  10. import android.util.Log;
  11. import android.view.LayoutInflater;
  12. import android.view.MenuItem;
  13. import android.view.View;
  14. import android.view.ViewGroup;
  15. import android.view.Window;
  16. import android.widget.Button;
  17. import android.widget.ImageView;
  18. import android.widget.LinearLayout;
  19. import android.widget.TextView;
  20. import android.widget.Toast;
  21. import androidx.annotation.NonNull;
  22. import androidx.appcompat.app.AppCompatActivity;
  23. import androidx.appcompat.widget.Toolbar;
  24. import androidx.recyclerview.widget.LinearLayoutManager;
  25. import androidx.recyclerview.widget.RecyclerView;
  26. import com.bumptech.glide.Glide;
  27. import com.bumptech.glide.load.engine.DiskCacheStrategy;
  28. import com.bumptech.glide.request.RequestOptions;
  29. import com.github.siyamed.shapeimageview.CircularImageView;
  30. import com.google.gson.Gson;
  31. import com.google.gson.JsonElement;
  32. import com.google.gson.reflect.TypeToken;
  33. import com.cygnusa.hyperm.tooltip.Tooltip;
  34. import com.cygnusa.hyperm.util.ApiService;
  35. import com.cygnusa.hyperm.util.GlobalData;
  36. import com.cygnusa.hyperm.util.MainApplication;
  37. import com.cygnusa.hyperm.util.UtilService;
  38. import com.cygnusa.hyperm.wrappers.CommonResponse;
  39. import com.cygnusa.hyperm.wrappers.ErrorResponse;
  40. import com.cygnusa.hyperm.wrappers.GetCancelOrRescheduleList;
  41. import com.cygnusa.hyperm.wrappers.Reasons;
  42. import net.danlew.android.joda.JodaTimeAndroid;
  43. import org.joda.time.LocalDate;
  44. import org.json.JSONArray;
  45. import org.json.JSONException;
  46. import org.json.JSONObject;
  47. import java.text.ParseException;
  48. import java.text.SimpleDateFormat;
  49. import java.util.ArrayList;
  50. import java.util.HashMap;
  51. import java.util.List;
  52. import java.util.Locale;
  53. import java.util.Objects;
  54. import jp.wasabeef.recyclerview.animators.SlideInLeftAnimator;
  55. import retrofit2.Call;
  56. import retrofit2.Callback;
  57. import retrofit2.Response;
  58. public class ViewScheduleActivity extends AppCompatActivity {
  59. ParticipantListAdapter dateAdapter;
  60. List<String> eTime = new ArrayList<>();
  61. List<String> sTime = new ArrayList<>();
  62. private TextView txtDate, txtLocation;
  63. private TextView txtTrainingStartDate, txtTrainingEndDate, txtTrainingName, txtTrainingUID;
  64. private TextView txtDescription, txtTotalParticipant, txtSubmissionDays;
  65. private ApiService restService;
  66. private List<Reasons> REASONS = new ArrayList<>();
  67. private String[] reasonName = {"None"};
  68. private String[] reasonId = {"None"};
  69. private String reasonIdString = "";
  70. private Button btnPublish, btnCancel, btnList, btnModify;
  71. private List<Integer> PARTICIPANTIDS = new ArrayList<>();
  72. private LinearLayout layoutBtn, layoutDate, lloutModify;
  73. private String id1;
  74. private String id2;
  75. private ImageView imgSchedule;
  76. @SuppressLint("SetTextI18n")
  77. @Override
  78. protected void onCreate(Bundle savedInstanceState) {
  79. super.onCreate(savedInstanceState);
  80. JodaTimeAndroid.init(this);
  81. setContentView(R.layout.activity_view_training_schedule);
  82. Toolbar toolbar = findViewById(R.id.toolbar);
  83. setSupportActionBar(toolbar);
  84. toolbar.setContentInsetStartWithNavigation(0);
  85. toolbar.setTitle("");
  86. Objects.requireNonNull(getSupportActionBar()).setTitle("");
  87. getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  88. getSupportActionBar().setDisplayShowHomeEnabled(true);
  89. @SuppressLint("PrivateResource")
  90. Drawable backArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_material);
  91. backArrow.setColorFilter(getResources().getColor(R.color.btn_bg_color), PorterDuff.Mode.SRC_ATOP);
  92. getSupportActionBar().setHomeAsUpIndicator(backArrow);
  93. restService = ((MainApplication) getApplication()).getClient();
  94. txtDate = findViewById(R.id.txtDate);
  95. txtLocation = findViewById(R.id.txtLocation);
  96. txtTrainingStartDate = findViewById(R.id.txtTrainingStartDate);
  97. txtTrainingEndDate = findViewById(R.id.txtTrainingEndDate);
  98. txtTrainingName = findViewById(R.id.txtTrainingName);
  99. txtDescription = findViewById(R.id.txtDescription);
  100. txtTotalParticipant = findViewById(R.id.txtTotalParticipant);
  101. txtSubmissionDays = findViewById(R.id.txtSubmissionDays);
  102. txtTrainingUID = findViewById(R.id.txtTrainingUID);
  103. btnPublish = findViewById(R.id.btnPublish);
  104. btnCancel = findViewById(R.id.btnCancel);
  105. btnModify = findViewById(R.id.btnModify);
  106. btnList = findViewById(R.id.btnList);
  107. lloutModify = findViewById(R.id.lloutModify);
  108. imgSchedule = findViewById(R.id.imgSchedule);
  109. if (GlobalData.scheduledDataList.get(0).isTraining_update_status() && GlobalData.scheduledDataList.get(0).getIsActiveHours().equalsIgnoreCase("1"))
  110. lloutModify.setVisibility(View.VISIBLE);
  111. else
  112. lloutModify.setVisibility(View.GONE);
  113. layoutBtn = findViewById(R.id.layoutBtn);
  114. layoutDate = findViewById(R.id.layoutDate);
  115. if (GlobalData.scheduledDataList.get(0).getStatus().equalsIgnoreCase("1")) {
  116. layoutBtn.setVisibility(View.GONE);
  117. }
  118. if (GlobalData.scheduledDataList.get(0).getIsDeleted().equalsIgnoreCase("1")) {
  119. btnPublish.setVisibility(View.GONE);
  120. btnCancel.setText("Training Cancelled");
  121. btnCancel.setBackground(getResources().getDrawable(R.drawable.border_full_red));
  122. btnCancel.setEnabled(false);
  123. imgSchedule.setVisibility(View.GONE);
  124. lloutModify.setVisibility(View.GONE);
  125. layoutBtn.setVisibility(View.VISIBLE);
  126. btnModify.setVisibility(View.GONE);
  127. }
  128. btnList.setOnClickListener(new View.OnClickListener() {
  129. @Override
  130. public void onClick(View v) {
  131. if ((GlobalData.scheduledDataList.get(0).getParticipant() != null) && GlobalData.scheduledDataList.get(0).getParticipant().size() > 0)
  132. openPopup();
  133. else
  134. GlobalData.toast(ViewScheduleActivity.this, "No Participant List Available");
  135. }
  136. });
  137. imgSchedule.setOnClickListener(new View.OnClickListener() {
  138. @Override
  139. public void onClick(View v) {
  140. if ((GlobalData.scheduledDataList.get(0).getParticipant() != null) && GlobalData.scheduledDataList.get(0).getParticipant().size() > 0)
  141. openPopup();
  142. else
  143. GlobalData.toast(ViewScheduleActivity.this, "No Participant List Available");
  144. }
  145. });
  146. btnCancel.setOnClickListener(new View.OnClickListener() {
  147. @Override
  148. public void onClick(View v) {
  149. onBackPressed();
  150. }
  151. });
  152. btnPublish.setOnClickListener(new View.OnClickListener() {
  153. @Override
  154. public void onClick(View v) {
  155. try {
  156. sendAllTrainingDatasToServer("1");
  157. } catch (JSONException e) {
  158. e.printStackTrace();
  159. }
  160. }
  161. });
  162. if (GlobalData.scheduledDataList != null && GlobalData.scheduledDataList.size() > 0) {
  163. txtDate.setText(GlobalData.scheduledDataList.get(0).getTitle());
  164. String startDate = GlobalData.scheduledDataList.get(0).getStartDate();
  165. String endDate = GlobalData.scheduledDataList.get(0).getEndDate();
  166. SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
  167. String startDateString = "", endDateString = "";
  168. try {
  169. startDateString = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault()).format(Objects.requireNonNull(format.parse(startDate)));
  170. endDateString = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault()).format(Objects.requireNonNull(format.parse(endDate)));
  171. } catch (ParseException e) {
  172. e.printStackTrace();
  173. }
  174. String s = GlobalData.scheduledDataList.get(0).getStartdate();
  175. String e = GlobalData.scheduledDataList.get(0).getEnddate();
  176. LocalDate start = LocalDate.parse(s);
  177. LocalDate end = LocalDate.parse(e);
  178. List<LocalDate> totalDates = new ArrayList<>();
  179. while (!start.isAfter(end)) {
  180. totalDates.add(start);
  181. start = start.plusDays(1);
  182. }
  183. String startTime = GlobalData.scheduledDataList.get(0).getStarttime();
  184. String endTime = GlobalData.scheduledDataList.get(0).getEndtime();
  185. try {
  186. JSONArray arrayFromTime = new JSONArray(startTime);
  187. for (int i = 0; i < arrayFromTime.length(); i++) {
  188. id1 = (String) arrayFromTime.get(i);
  189. sTime.add(id1);
  190. }
  191. JSONArray arrayToTime = new JSONArray(endTime);
  192. for (int i = 0; i < arrayToTime.length(); i++) {
  193. id2 = (String) arrayToTime.get(i);
  194. eTime.add(id2);
  195. }
  196. } catch (JSONException e1) {
  197. sTime.add(startTime);
  198. eTime.add(endTime);
  199. e1.printStackTrace();
  200. }
  201. int trainingDays = Integer.parseInt(GlobalData.scheduledDataList.get(0).getTrainingDays());
  202. for (int i = 0; i < trainingDays; i++) {
  203. TextView txtDays = new TextView(this);
  204. txtDays.setTextSize(15);
  205. txtDays.setTextColor(Color.parseColor("#00344C"));
  206. txtDays.setPadding(0, 0, 0, 0);
  207. if (sTime.size() - 1 >= i && eTime.size() - 1 >= i)
  208. txtDays.setText("Day " + (i + 1) + " : " + totalDates.get(i) + " " + sTime.get(i) + " - " + eTime.get(i));
  209. txtDays.setTypeface(Typeface.DEFAULT_BOLD);
  210. layoutDate.addView(txtDays);
  211. }
  212. txtLocation.setText(GlobalData.scheduledDataList.get(0).getVenueAddress());
  213. txtTrainingStartDate.setText(startDateString);
  214. txtTrainingEndDate.setText(endDateString);
  215. txtDescription.setText(GlobalData.scheduledDataList.get(0).getScheduleName());
  216. txtTrainingName.setText(GlobalData.scheduledDataList.get(0).getTitle());
  217. if (GlobalData.scheduledDataList.get(0).getParticipant() != null && GlobalData.scheduledDataList.get(0).getParticipant().size() > 0)
  218. txtTotalParticipant.setText(String.valueOf(GlobalData.scheduledDataList.get(0).getParticipant().size()));
  219. txtSubmissionDays.setText(String.valueOf(GlobalData.scheduledDataList.get(0).getTrainingDays()));
  220. txtTrainingUID.setText("TRAINING UID : " + "");
  221. }
  222. getReasons();
  223. // getScheduledList();
  224. LinearLayout lloutEdit = findViewById(R.id.lloutEdit);
  225. txtTrainingUID.setText("TRAINING UID : " + GlobalData.scheduledDataList.get(0).
  226. getTraining_id());
  227. if (GlobalData.user.getData().
  228. getRole().
  229. equalsIgnoreCase("5")) {
  230. lloutEdit.setVisibility(View.VISIBLE);
  231. } else {
  232. lloutEdit.setVisibility(View.GONE);
  233. }
  234. lloutModify.setOnClickListener(new View.OnClickListener() {
  235. @Override
  236. public void onClick(View v) {
  237. startActivity(new Intent(ViewScheduleActivity.this, ModifyClassRoomActivity.class));
  238. finish();
  239. }
  240. });
  241. btnModify.setOnClickListener(new View.OnClickListener() {
  242. @Override
  243. public void onClick(View v) {
  244. startActivity(new Intent(ViewScheduleActivity.this, ModifyClassRoomActivity.class));
  245. finish();
  246. }
  247. });
  248. }
  249. public void openPopup() {
  250. final Dialog aDialog = new Dialog(this);
  251. aDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
  252. aDialog.setContentView(R.layout.particiapnt_popup);
  253. aDialog.setCancelable(true);
  254. aDialog.show();
  255. TextView textTrainer = aDialog.findViewById(R.id.txtTrainer);
  256. textTrainer.setText(GlobalData.scheduledDataList.get(0).getOrganizerName());
  257. ImageView imgTrainer = aDialog.findViewById(R.id.imgTrainer);
  258. ImageView close = aDialog.findViewById(R.id.closeButton);
  259. close.setOnClickListener(new View.OnClickListener() {
  260. @Override
  261. public void onClick(View v) {
  262. aDialog.dismiss();
  263. }
  264. });
  265. if (GlobalData.scheduledDataList.get(0).getTrainingGroupImage() != null || !GlobalData.scheduledDataList.get(0).getTrainingGroupImage().isEmpty()) {
  266. Glide.with(ViewScheduleActivity.this).load(GlobalData.scheduledDataList.get(0).getTrainingGroupImage())
  267. .thumbnail(Glide.with(ViewScheduleActivity.this).load(R.drawable.gif_loader))
  268. .apply(new RequestOptions().fitCenter().diskCacheStrategy(DiskCacheStrategy.ALL)
  269. .placeholder(R.drawable.placeholder)).into(imgTrainer);
  270. } else {
  271. Glide.with(ViewScheduleActivity.this).load(R.drawable.placeholder)
  272. .thumbnail(Glide.with(ViewScheduleActivity.this).load(R.drawable.gif_loader))
  273. .apply(new RequestOptions().fitCenter().diskCacheStrategy(DiskCacheStrategy.ALL)
  274. .placeholder(R.drawable.placeholder)).into(imgTrainer);
  275. }
  276. RecyclerView rcvParticipant = aDialog.findViewById(R.id.rcvParticipant);
  277. rcvParticipant.setHasFixedSize(true);
  278. rcvParticipant.setItemAnimator(new SlideInLeftAnimator());
  279. LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getBaseContext());
  280. rcvParticipant.setLayoutManager(linearLayoutManager);
  281. dateAdapter = new ParticipantListAdapter();
  282. rcvParticipant.setAdapter(dateAdapter);
  283. }
  284. private void getReasons() {
  285. if (new UtilService().isNetworkAvailable(Objects.requireNonNull(ViewScheduleActivity.this))) {
  286. try {
  287. restService.getCancelOrReschedule().enqueue(new Callback<GetCancelOrRescheduleList>() {
  288. @Override
  289. public void onResponse(Call<GetCancelOrRescheduleList> call, Response<GetCancelOrRescheduleList> response) {
  290. if (response.body() != null && response.body().getStatus() == 200) {
  291. if (response.body().getReasonsList() != null && response.body().getReasonsList().size() > 0) {
  292. REASONS = response.body().getReasonsList();
  293. reasonName = new String[REASONS.size()];
  294. reasonId = new String[REASONS.size()];
  295. for (int i = 0; i < response.body().getReasonsList().size(); i++) {
  296. reasonName[i] = REASONS.get(i).getName();
  297. reasonId[i] = REASONS.get(i).getId();
  298. }
  299. }
  300. } else if (response.body() != null && response.body().getStatus() == 401) {
  301. GlobalData.canLogout = true;
  302. finish();
  303. } else if (response.body() != null) {
  304. GlobalData.showToast(getBaseContext(), response.body().getMessage(), Toast.LENGTH_SHORT).show();
  305. } else if (response.errorBody() != null) {
  306. Gson gson = new Gson();
  307. ErrorResponse message = gson.fromJson(response.errorBody().charStream(), ErrorResponse.class);
  308. GlobalData.showToast(getBaseContext(), message.getMessage(), Toast.LENGTH_SHORT).show();
  309. if (message.getStatus() == 401) {
  310. GlobalData.canLogout = true;
  311. finish();
  312. }
  313. }
  314. }
  315. @Override
  316. public void onFailure(Call<GetCancelOrRescheduleList> call, Throwable t) {
  317. }
  318. });
  319. } catch (Exception e) {
  320. e.printStackTrace();
  321. }
  322. }
  323. }
  324. private void sendAllTrainingDatasToServer(String s) throws JSONException {
  325. JSONObject assessment = new JSONObject();
  326. try {
  327. for (int j = 0; j < GlobalData.scheduledDataList.get(0).getAssessment().size(); j++) {
  328. assessment.put("name", GlobalData.scheduledDataList.get(0).getAssessment().get(j).getAssessmentname());
  329. assessment.put("ques_count", GlobalData.scheduledDataList.get(0).getAssessment().get(j).getTotalQuestion());
  330. assessment.put("duration", GlobalData.scheduledDataList.get(0).getAssessment().get(j).getAssessmenttime());
  331. assessment.put("assessment", GlobalData.scheduledDataList.get(0).getAssessment().get(j).getAssessmenttype());
  332. }
  333. } catch (JSONException e) {
  334. e.printStackTrace();
  335. }
  336. JSONArray jsonArray = new JSONArray();
  337. jsonArray.put(assessment);
  338. JSONObject assessmentObj = new JSONObject();
  339. assessmentObj.put("assessments", jsonArray);
  340. Gson gson = new Gson();
  341. JsonElement dseJsonElement = null;
  342. for (int i = 0; i < GlobalData.scheduledDataList.get(0).getParticipant().size(); i++) {
  343. PARTICIPANTIDS.add(Integer.valueOf(GlobalData.scheduledDataList.get(0).getParticipant().get(i).getUserid()));
  344. }
  345. dseJsonElement = gson.toJsonTree(
  346. PARTICIPANTIDS, new TypeToken<ArrayList<String>>() {
  347. }.getType());
  348. HashMap<String, String> map = new HashMap<>();
  349. map.put("title", GlobalData.scheduledDataList.get(0).getLvlId());
  350. map.put("description", GlobalData.scheduledDataList.get(0).getScheduleName());
  351. map.put("startdate", GlobalData.scheduledDataList.get(0).getStartdate());
  352. map.put("enddate", GlobalData.scheduledDataList.get(0).getEnddate());
  353. map.put("starttime", GlobalData.scheduledDataList.get(0).getStarttime());
  354. map.put("endtime", GlobalData.scheduledDataList.get(0).getEndtime());
  355. map.put("venue_am", GlobalData.scheduledDataList.get(0).getVenueAm());
  356. map.put("schedule_id", GlobalData.scheduledDataList.get(0).getScheduleId());
  357. map.put("is_feedback", GlobalData.scheduledDataList.get(0).getIsFeedback());
  358. map.put("venue_type", GlobalData.scheduledDataList.get(0).getVenueType());
  359. map.put("venue_address", GlobalData.scheduledDataList.get(0).getVenueAddress());
  360. map.put("venue_dealer", GlobalData.scheduledDataList.get(0).getVenueDealer());
  361. map.put("assessments", jsonArray.toString());
  362. map.put("dse", dseJsonElement.toString());
  363. map.put("adhoc_training", GlobalData.scheduledDataList.get(0).getAdhocTraining());
  364. map.put("business_segment", GlobalData.scheduledDataList.get(0).getBusinessSegment());
  365. map.put("training_other_title", GlobalData.scheduledDataList.get(0).getTrainingOtherTitle());
  366. map.put("date_restriction", GlobalData.scheduledDataList.get(0).getDateRestriction());
  367. map.put("status", s);
  368. Log.e("MapValue", map.toString());
  369. restService.sendAllUpdateTrainingToServer(map).enqueue(new Callback<CommonResponse>() {
  370. @Override
  371. public void onResponse(Call<CommonResponse> call, Response<CommonResponse> response) {
  372. if (response.body() != null) {
  373. if (response.body().getResponse().equalsIgnoreCase("Success")) {
  374. GlobalData.toast(ViewScheduleActivity.this, "Published Successfully");
  375. startActivity(new Intent(ViewScheduleActivity.this, ClassRoomTrainerTainingActivity.class));
  376. finish();
  377. } else {
  378. GlobalData.toast(ViewScheduleActivity.this, response.body().getResponseText());
  379. }
  380. } else if (response.body() != null && response.body().getStatus() == 401) {
  381. GlobalData.canLogout = true;
  382. finish();
  383. } else if (response.errorBody() != null) {
  384. Gson gson = new Gson();
  385. ErrorResponse message = gson.fromJson(response.errorBody().charStream(), ErrorResponse.class);
  386. GlobalData.showToast(getBaseContext(), message.getMessage(), Toast.LENGTH_SHORT).show();
  387. if (message.getStatus() == 401) {
  388. GlobalData.canLogout = true;
  389. finish();
  390. }
  391. }
  392. }
  393. @Override
  394. public void onFailure(Call<CommonResponse> call, Throwable t) {
  395. }
  396. });
  397. }
  398. @Override
  399. public void onBackPressed() {
  400. super.onBackPressed();
  401. startActivity(new Intent(ViewScheduleActivity.this, ClassRoomTrainerTainingActivity.class));
  402. finish();
  403. this.overridePendingTransition(R.anim.animation_f_enter,
  404. R.anim.animation_f_leave);
  405. }
  406. @Override
  407. public boolean onOptionsItemSelected(MenuItem item) {
  408. if (item.getItemId() == android.R.id.home) {
  409. finish();
  410. onBackPressed();
  411. }
  412. return super.onOptionsItemSelected(item);
  413. }
  414. private static class ParticipantViewHolder extends RecyclerView.ViewHolder {
  415. TextView txtName, txtStatus;
  416. CircularImageView imgPic;
  417. ImageView info;
  418. public ParticipantViewHolder(@NonNull View itemView) {
  419. super(itemView);
  420. txtName = itemView.findViewById(R.id.txt_Name);
  421. txtStatus = itemView.findViewById(R.id.txtStatus);
  422. imgPic = itemView.findViewById(R.id.imgPic);
  423. info = itemView.findViewById(R.id.info);
  424. }
  425. }
  426. private class ParticipantListAdapter extends RecyclerView.Adapter<ParticipantViewHolder> {
  427. @NonNull
  428. @Override
  429. public ParticipantViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
  430. View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.participant_view_holder, parent, false);
  431. return new ParticipantViewHolder(v);
  432. }
  433. @Override
  434. public void onBindViewHolder(@NonNull ParticipantViewHolder holder, int position) {
  435. if (GlobalData.scheduledDataList.get(0).getParticipant().get(position).getName() == null || GlobalData.scheduledDataList.get(0).getParticipant().get(position).getName().isEmpty()) {
  436. holder.txtName.setText("No Name");
  437. } else {
  438. holder.txtName.setText(GlobalData.scheduledDataList.get(0).getParticipant().get(position).getSmpin() + " " +
  439. GlobalData.scheduledDataList.get(0).getParticipant().get(position).getName());
  440. }
  441. if (GlobalData.scheduledDataList.get(0).getParticipant().get(position).getStatus().equalsIgnoreCase("0")) {
  442. holder.txtStatus.setText("Waiting for response");
  443. holder.txtStatus.setTextColor(Color.parseColor("#808080"));
  444. } else if (GlobalData.scheduledDataList.get(0).getParticipant().get(position).getStatus().equalsIgnoreCase("1")) {
  445. holder.txtStatus.setText("Acknowledged");
  446. holder.txtStatus.setTextColor(Color.parseColor("#348E00"));
  447. } else if (GlobalData.scheduledDataList.get(0).getParticipant().get(position).getStatus().equalsIgnoreCase("2")) {
  448. holder.txtStatus.setText("Declined");
  449. holder.info.setVisibility(View.VISIBLE);
  450. holder.txtStatus.setTextColor(Color.parseColor("#F90303"));
  451. }
  452. holder.info.setOnClickListener(new View.OnClickListener() {
  453. @Override
  454. public void onClick(View view) {
  455. String header = GlobalData.scheduledDataList.get(0).getParticipant().get(position).getDeclineReasonName() + "/" + GlobalData.scheduledDataList.get(0).getParticipant().get(position).getDeclineReasonDesc();
  456. View mView = LayoutInflater.from(ViewScheduleActivity.this).inflate(R.layout.tooltip_layout, null);
  457. TextView text = mView.findViewById(R.id.text11);
  458. TextView txtReasonTitle = mView.findViewById(R.id.txtReasonTitle);
  459. txtReasonTitle.setText(GlobalData.scheduledDataList.get(0).getParticipant().get(position).getDeclineReasonName());
  460. text.setText(header);
  461. Tooltip.TooltipView tooltip = Tooltip.make(ViewScheduleActivity.this,
  462. new Tooltip.Builder(101)
  463. .anchor(view, Tooltip.Gravity.TOP)
  464. .closePolicy(new Tooltip.ClosePolicy()
  465. .insidePolicy(true, false)
  466. .outsidePolicy(true, false), 0)
  467. .activateDelay(300)
  468. .withStyleId(R.style.ToolTipLayoutCustomStyle)
  469. .showDelay(300)
  470. .text("")
  471. .setBgColor(getResources().getColor(R.color.bg_color))
  472. .view(mView)
  473. .maxWidth(300)
  474. .withArrow(true)
  475. .build()
  476. );
  477. tooltip.setTextColor(Color.WHITE);
  478. tooltip.show();
  479. }
  480. });
  481. if (GlobalData.scheduledDataList.get(0).getParticipant().get(position).getProfilePhoto() != null || !GlobalData.scheduledDataList.get(0).getParticipant().get(position).getProfilePhoto().isEmpty()) {
  482. Glide.with(ViewScheduleActivity.this).load(GlobalData.scheduledDataList.get(0).getParticipant().get(position).getProfilePhoto())
  483. .thumbnail(Glide.with(ViewScheduleActivity.this).load(R.drawable.gif_loader))
  484. .apply(new RequestOptions().fitCenter().diskCacheStrategy(DiskCacheStrategy.ALL)
  485. .placeholder(R.drawable.placeholder)).into(holder.imgPic);
  486. } else {
  487. Glide.with(ViewScheduleActivity.this).load(R.drawable.placeholder)
  488. .thumbnail(Glide.with(ViewScheduleActivity.this).load(R.drawable.gif_loader))
  489. .apply(new RequestOptions().fitCenter().diskCacheStrategy(DiskCacheStrategy.ALL)
  490. .placeholder(R.drawable.placeholder)).into(holder.imgPic);
  491. }
  492. }
  493. @Override
  494. public int getItemCount() {
  495. return GlobalData.scheduledDataList.get(0).getParticipant().size();
  496. }
  497. }
  498. }