Android Open Source - calendar Text View With Circular Indicator






From Project

Back to project page calendar.

License

The source code is released under:

GNU General Public License

If you think the Android project calendar listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.fourmob.datetimepicker.date;
/*from w w w. j  a v  a2s.  co  m*/
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.widget.TextView;

import com.fourmob.datetimepicker.R;

public class TextViewWithCircularIndicator extends TextView {
    
  private final int mCircleColor;
    private Paint mCirclePaint = new Paint();
  private boolean mDrawCircle;
  private final String mItemIsSelectedText;
  private final int mRadius;

  public TextViewWithCircularIndicator(Context context, AttributeSet attributeSet) {
    super(context, attributeSet);
        
    Resources res = context.getResources();
    mCircleColor = res.getColor(R.color.blue);
    mRadius = res.getDimensionPixelOffset(R.dimen.month_select_circle_radius);
    mItemIsSelectedText = context.getResources().getString(R.string.item_is_selected);
        
    init();
  }

  private void init() {
    mCirclePaint.setFakeBoldText(true);
    mCirclePaint.setAntiAlias(true);
    mCirclePaint.setColor(mCircleColor);
    mCirclePaint.setTextAlign(Paint.Align.CENTER);
    mCirclePaint.setStyle(Paint.Style.FILL);
    mCirclePaint.setAlpha(60);
  }

  public void drawIndicator(boolean drawIndicator) {
    mDrawCircle = drawIndicator;
  }

  public CharSequence getContentDescription() {
    CharSequence text = getText();
    if (mDrawCircle) {
      text = String.format(mItemIsSelectedText, text);
        }
    return text;
  }

  public void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    if (mDrawCircle) {
      int width = getWidth();
      int heigth = getHeight();
      int radius = Math.min(width, heigth) / 2;
      canvas.drawCircle(width / 2, heigth / 2, radius, mCirclePaint);
    }
  }
}




Java Source Code List

com.dorosh.calendar.creator.ideacalendar.app.AddActivity.java
com.dorosh.calendar.creator.ideacalendar.app.ArchiveListFragment.java
com.dorosh.calendar.creator.ideacalendar.app.DatabaseHelper.java
com.dorosh.calendar.creator.ideacalendar.app.MainActivity.java
com.dorosh.calendar.creator.ideacalendar.app.SettingsActivity.java
com.dorosh.calendar.creator.ideacalendar.app.SetupActivity.java
com.dorosh.calendar.creator.ideacalendar.app.StartAcitivity.java
com.dorosh.calendar.creator.ideacalendar.app.TODOListFragment.java
com.dorosh.calendar.creator.ideacalendar.app.Cursors.TODOCursorAdapter.java
com.fourmob.datetimepicker.BuildConfig.java
com.fourmob.datetimepicker.BuildConfig.java
com.fourmob.datetimepicker.Utils.java
com.fourmob.datetimepicker.date.AccessibleDateAnimator.java
com.fourmob.datetimepicker.date.DatePickerController.java
com.fourmob.datetimepicker.date.DatePickerDialog.java
com.fourmob.datetimepicker.date.DayPickerView.java
com.fourmob.datetimepicker.date.SimpleMonthAdapter.java
com.fourmob.datetimepicker.date.SimpleMonthView.java
com.fourmob.datetimepicker.date.TextViewWithCircularIndicator.java
com.fourmob.datetimepicker.date.YearPickerView.java
com.sleepbot.datetimepicker.AccessibleTextView.java
com.sleepbot.datetimepicker.time.AmPmCirclesView.java
com.sleepbot.datetimepicker.time.CircleView.java
com.sleepbot.datetimepicker.time.RadialPickerLayout.java
com.sleepbot.datetimepicker.time.RadialSelectorView.java
com.sleepbot.datetimepicker.time.RadialTextsView.java
com.sleepbot.datetimepicker.time.TimePickerDialog.java