67 lines
2.1 KiB
Java
67 lines
2.1 KiB
Java
|
package com.prolificinteractive.materialcalendarview;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.content.res.TypedArray;
|
||
|
import android.graphics.Typeface;
|
||
|
import android.text.TextUtils;
|
||
|
import android.widget.TextView;
|
||
|
import com.prolificinteractive.materialcalendarview.format.WeekDayFormatter;
|
||
|
import java.util.Calendar;
|
||
|
|
||
|
/* loaded from: classes3.dex */
|
||
|
class WeekDayView extends TextView {
|
||
|
private int dayOfWeek;
|
||
|
private WeekDayFormatter formatter;
|
||
|
|
||
|
public WeekDayView(Context context, int i) {
|
||
|
super(context);
|
||
|
this.formatter = WeekDayFormatter.DEFAULT;
|
||
|
setGravity(17);
|
||
|
setTextAlignment(4);
|
||
|
setDayOfWeek(i);
|
||
|
}
|
||
|
|
||
|
public void setWeekDayFormatter(WeekDayFormatter weekDayFormatter) {
|
||
|
if (weekDayFormatter == null) {
|
||
|
weekDayFormatter = WeekDayFormatter.DEFAULT;
|
||
|
}
|
||
|
this.formatter = weekDayFormatter;
|
||
|
setDayOfWeek(this.dayOfWeek);
|
||
|
}
|
||
|
|
||
|
public void setDayOfWeek(int i) {
|
||
|
this.dayOfWeek = i;
|
||
|
setText(this.formatter.format(i));
|
||
|
}
|
||
|
|
||
|
public void setDayOfWeek(Calendar calendar) {
|
||
|
setDayOfWeek(CalendarUtils.getDayOfWeek(calendar));
|
||
|
}
|
||
|
|
||
|
@Override // android.widget.TextView
|
||
|
public void setTextAppearance(int i) {
|
||
|
super.setTextAppearance(i);
|
||
|
applyCustomTypeface(i);
|
||
|
}
|
||
|
|
||
|
@Override // android.widget.TextView
|
||
|
public void setTextAppearance(Context context, int i) {
|
||
|
super.setTextAppearance(context, i);
|
||
|
applyCustomTypeface(i);
|
||
|
}
|
||
|
|
||
|
private void applyCustomTypeface(int i) {
|
||
|
TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(i, R.styleable.MaterialCalendarView);
|
||
|
if (obtainStyledAttributes != null) {
|
||
|
String string = obtainStyledAttributes.getString(R.styleable.MaterialCalendarView_mcv_textAppearanceFontPath);
|
||
|
if (TextUtils.isEmpty(string)) {
|
||
|
return;
|
||
|
}
|
||
|
try {
|
||
|
setTypeface(Typeface.createFromAsset(getResources().getAssets(), string));
|
||
|
} catch (Exception unused) {
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|