title: Changing color with calendar according to half day and full day using android-times-square api in android
body: <p>I am developing an android app with android-times-square API. for this i am using <a href="https://github.com/square/android-times-square" rel="nofollow noreferrer">https://github.com/square/android-times-square</a> url to developed custom calendar into my app. </p>
  
  <p>I have successful integrated that API. but i want some changes using this API.</p>
  
  <p>I want changing color according to half day and full day selection.</p>
  
  <p><strong>below is my screen:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/hFHOD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hFHOD.png" alt="enter image description here"></a></p>
  
  <p>I have used following manner for solved this issue. I have resolve this issue but for this steps my app is going to hang.</p>
  
  <p>There are following steps:</p>
  
  <p>1: (Replace default line to my modified line)</p>
  
  <p><strong>Default:</strong></p>
  
  <pre><code>  calendar.setDecorators(Collections.&lt;CalendarCellDecorator&gt;emptyList());
  </code></pre>
  
  <p><strong>Replaced</strong></p>
  
  <pre><code>  List&lt;CalendarCellDecorator&gt; decoratorList = new ArrayList&lt;&gt;();
    decoratorList.add(new MonthDecorator());
    calendar.setDecorators(decoratorList);
  </code></pre>
  
  <p>2. MonthDecorator.java</p>
  
  <pre><code>public class MonthDecorator implements CalendarCellDecorator {
  
      @Override
      public void decorate(CalendarCellView calendarCellView, Date date) {
  
             /**
       * getting value from tag
       */
      String mDate = calendarCellView.getTag().toString().split("\\{")[1].split(",")[0].split("=")[1];
  
      /**
       * getting value from shared preference
       */
      HashMap&lt;Date, String&gt; mList = GeneralUtil.GetCalenderView(calendarCellView.getContext());
  
  
      if(mList != null){
  
          if(mList.size()&gt;0){
              for(int y=0 ; y&lt;mList.size();y++){
                  /**
                   * getting keys from hashmap
                   */
                  String Format = "",mValue="";
                  Format = mList.keySet().toArray()[y].toString();
                  /////////////////
  
                  /**
                   * getting value from hashmap
                   */
                  mValue = mList.entrySet().toArray()[y].toString();
                  //////////////////
  
                  /**
                   * compare value from saved half day and retrive date
                   */
                  if(Format.equals(mDate)){
  
                      if(mValue.split("=")[1].equals("0")){
                          calendarCellView.setBackgroundResource(R.drawable.calendar_bg_selector_green);
                          mTempCheckDate.add(""+Format);
                      }
  
                  }
                  else{
                      if(!mTempCheckDate.contains(Format)){
                          calendarCellView.setBackgroundResource(R.drawable.calendar_bg_selector);
                      }
  
                  }
                  ////////////////////////
  
              }
          }
          else{
              calendarCellView.setBackgroundResource(R.drawable.calendar_bg_selector);
          }
  
  
      }
      else{
          calendarCellView.setBackgroundResource(R.drawable.calendar_bg_selector);
      }
  
      }
  }
  </code></pre>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I have solved this issue to some extent. but My custom calendar not scroll smoothly.</p>
  
  <p>I am using following code in MonthDecoder.java file:</p>
  
  <pre><code> public class MonthDecorator implements CalendarCellDecorator {
  
      @Override
      public void decorate(final CalendarCellView calendarCellView, Date date) {
  
          final Handler handler = new Handler();
  
          handler.postDelayed(new Runnable() {
              @Override
              public void run() {
                  callFxnForChangeColor(calendarCellView);
                  }
          },0);
  
      }
  
      private void callFxnForChangeColor(CalendarCellView calendarCellView) {
          /**
           * getting value from tag
           */
          String mDate = calendarCellView.getTag().toString().split("\\{")[1].split(",")[0].split("=")[1];
  
          /**
           *  convert date from one formatg to another format
           */
          mDate = Utils.callFxnForConvertDateToString(new Date(mDate));
  
          /**
           * getting value from shared preference
           */
          HashMap&lt;String, String&gt; mList = GeneralUtil.GetCalenderView(calendarCellView.getContext());
  
          if(mList != null &amp;&amp; mList.size()&gt;0){
  
              if (mList.containsKey(mDate)){
                  calendarCellView.setBackgroundResource(R.drawable.calendar_bg_selector_green);
  
              }
              else{
                  calendarCellView.setBackgroundResource(R.drawable.calendar_bg_selector);
  
              }
          }
          else{
              calendarCellView.setBackgroundResource(R.drawable.calendar_bg_selector);
          }
      }
  }
  </code></pre>
  
  <p>So, Can anyone suggest me for resolve this problem.</p>
  
  <p>Sorry for my poor English.</p>
  
  <p>Thanks in Advance</p>