content: package com.alirezaafkar.sundatepicker.components;
  
  import android.content.Context;
  import android.support.v7.widget.AppCompatTextView;
  import android.util.AttributeSet;
  import android.widget.Checkable;
  
  /**
   * Created by Alireza Afkar on 2/11/16 AD.
   */
  public class SquareTextView extends AppCompatTextView implements Checkable {
      private static final int[] CheckedStateSet = {android.R.attr.state_checked};
  
      private boolean mChecked = false;
  
      public SquareTextView(Context context) {
          super(context);
      }
  
      public SquareTextView(Context context, AttributeSet attrs) {
          super(context, attrs);
      }
  
      public SquareTextView(Context context, AttributeSet attrs, int defStyle) {
          super(context, attrs, defStyle);
      }
  
      @Override
      public boolean isChecked() {
          return mChecked;
      }
  
      @Override
      public void setChecked(boolean checked) {
          mChecked = checked;
          refreshDrawableState();
      }
  
      @Override
      public void toggle() {
          mChecked = !mChecked;
          refreshDrawableState();
      }
  
      @Override
      protected int[] onCreateDrawableState(int extraSpace) {
          final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
          if (isChecked()) {
              mergeDrawableStates(drawableState, CheckedStateSet);
          }
          return drawableState;
      }
  
      @Override
      protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
          super.onMeasure(widthMeasureSpec, widthMeasureSpec);
      }
  }
  