Advertisement
Guest User

Untitled

a guest
Dec 13th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.76 KB | None | 0 0
  1.  @Override
  2.     public String getPrimaryLiveTimeText(Context context) {
  3.         if (matchMataData != null) {
  4.             if (sport != null && sport.getPeriodCalculationType() != null) {
  5.                 switch (sport.getPeriodCalculationType()) {
  6.                     case HALF_TIME:
  7.                         return getPrimaryLiveTextForHalfTime(context);
  8.                     case SETS:
  9.                         return getPrimaryLiveTextForSets(context);
  10.                     case PERIOD:
  11.                         return getPrimaryLiveTextForPeriods(context);
  12.                     case QUARTERS:
  13.                         return getPrimaryLiveTextForQuarters(context);
  14.                 }
  15.             }
  16.         }
  17.         return defaultPrimaryLiveText(context);
  18.     }
  19.  
  20.     private String getPrimaryLiveTextForQuarters(Context context) {
  21.         Integer currentPeriod = matchMataData.getCurrentPeriod();
  22.         if (matchMataData.isOverTime()) {
  23.             return context.getString(R.string.label_overtime_short);
  24.         } else if (currentPeriod != null) {
  25.             return context.getString(R.string.status_quarter_prefix) + currentPeriod;
  26.         }
  27.         return "";
  28.     }
  29.  
  30.     private String getPrimaryLiveTextForPeriods(Context context) {
  31.         Integer currentPeriod = matchMataData.getCurrentPeriod();
  32.         if (matchMataData.isOverTime()) {
  33.             return context.getString(R.string.label_overtime_short);
  34.         } else if (currentPeriod != null) {
  35.             return context.getString(R.string.status_period_prefix) + currentPeriod;
  36.         }
  37.         return "";
  38.     }
  39.  
  40.     private String getPrimaryLiveTextForSets(Context context) {
  41.         Integer currentPeriod = matchMataData.getCurrentPeriod();
  42.         if (currentPeriod != null) {
  43.             return context.getString(R.string.status_set_prefix) + currentPeriod;
  44.         }
  45.         return "";
  46.     }
  47.  
  48.     private String getPrimaryLiveTextForHalfTime(Context context) {
  49.         if (matchMataData.arePenalties()) {
  50.             return context.getString(R.string.label_penalties_short);
  51.         } else if (matchMataData.isOverTime()) {
  52.             return context.getString(R.string.label_overtime_short);
  53.         } else if (matchMataData.hasMinuteInfo()) {
  54.             return matchMataData.getMinute() + "'";
  55.         } else if (matchMataData.isFinished()) {
  56.             return context.getString(R.string.result_ended);
  57.         } else {
  58.             return context.getString(R.string.halfTime);
  59.         }
  60.     }
  61.  
  62.     private String defaultPrimaryLiveText(Context context) {
  63.         if (matchMataData != null) {
  64.             if (matchMataData.hasMinuteInfo()) {
  65.                 return matchMataData.getMinute() + "'";
  66.             } else if (matchMataData.getStatus() != null) {
  67.                 return context.getString(matchMataData.getStatus().getResId());
  68.             }
  69.         }
  70.         return "";
  71.     }
  72.  
  73.     @Override
  74.     public String getSecondaryLiveTimeText(Context context) {
  75.         if (matchMataData != null) {
  76.             if (sport != null && sport.getPeriodCalculationType() != null) {
  77.                 switch (sport.getPeriodCalculationType()) {
  78.                     case HALF_TIME:
  79.                         return getSecondaryLiveTimeTextForHalfTime(context);
  80.                     case PERIOD:
  81.                     case QUARTERS:
  82.                         if (matchMataData.hasMinuteInfo()) {
  83.                             return matchMataData.getMinute() + "'";
  84.                         }
  85.                 }
  86.             }
  87.         }
  88.         return null;
  89.     }
  90.  
  91.     private String getSecondaryLiveTimeTextForHalfTime(Context context) {
  92.         if (matchMataData.isOverTime() && matchMataData.hasMinuteInfo()) {
  93.             return matchMataData.getMinute() + "'";
  94.         }
  95.         return null;
  96.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement