Guest User

Untitled

a guest
Aug 19th, 2019
73
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public void onBindViewHolder(@NonNull MyViewHolder holders, int position) {
  2. final MyViewHolder holder = holders;
  3. final DishesObject dishesObject = dishes.get(position);
  4. Log.d(TAG, "onBindViewHolder: " + position);
  5. holder.dishName.setText(dishesObject.getDishName());
  6. holder.dishNumber.setText(dishesObject.getMenuitemArticle());
  7.  
  8. if (dishesStopList.contains(dishesObject.getDishUuid())) {
  9. Log.d(TAG, "dishesStopList: " + dishesStopList.toString());
  10. Log.d(TAG, "dishesObject.getDishUuid(): " + dishesObject.getDishUuid() + " " + dishesObject.getDishName());
  11. holder.cdView.setCardBackgroundColor(Color.parseColor("#7f7f7f"));
  12. holder.dishName.setTextColor(Color.parseColor("#d3d3d3"));
  13. holder.dishNumber.setTextColor(Color.parseColor("#d3d3d3"));
  14. } else {
  15. holder.cdView.setCardBackgroundColor(Color.parseColor("#FFFFFF"));
  16. holder.dishName.setTextColor(Color.parseColor("#FF757575"));
  17. holder.dishNumber.setTextColor(Color.parseColor("#FF757575"));
  18. }
  19.  
  20. if (dishesLimitList.has(dishesObject.getDishUuid())) {
  21. JsonObject limit = dishesLimitList.getAsJsonObject(dishesObject.getDishUuid());
  22. Log.d(TAG, "onBindViewHolder: " + limit.toString());
  23. Double balance = 0.00;
  24. if (!limit.get("limit_rate").isJsonNull() && !limit.get("limit_share").isJsonNull()) {
  25. balance = (Double.valueOf(limit.get("limit_rate").getAsString()) - Double.valueOf(limit.get("limit_share").getAsString()));
  26. } else if (limit.get("limit_share").isJsonNull()) {
  27. balance = (Double.valueOf(limit.get("limit_rate").getAsString()));
  28. }
  29. holder.dishName.setText(dishesObject.getDishName() + " (" + balance + ")");
  30. if (balance == 0.00) {
  31. holder.cdView.setCardBackgroundColor(Color.parseColor("#7f7f7f"));
  32. holder.dishName.setTextColor(Color.parseColor("#d3d3d3"));
  33. holder.dishNumber.setTextColor(Color.parseColor("#d3d3d3"));
  34. } else {
  35. holder.cdView.setCardBackgroundColor(Color.parseColor("#FFACAA"));
  36. }
  37. } else {
  38. holder.dishName.setText(dishesObject.getDishName());
  39. holder.cdView.setCardBackgroundColor(Color.parseColor("#FFFFFF"));
  40. holder.dishName.setTextColor(Color.parseColor("#FF757575"));
  41. holder.dishNumber.setTextColor(Color.parseColor("#FF757575"));
  42. }
  43. }
RAW Paste Data