Good day.
There is a class MotiveCalendar inherited from CalendarView , I have redefined all three constructors of the class CalendarView . So far, only one constructor is used, but not the essence. In the three constructors, code duplication is obvious. Here they are:
private boolean showWeekNumber = false; private int firstDayOfWeek = 2; public MotiveCalendar(Context context) { super(context); setShowWeekNumber(showWeekNumber); setFirstDayOfWeek(firstDayOfWeek); Log.d( TAG , "MotiveCalendar: Constructor 1 called"); } public MotiveCalendar(Context context, AttributeSet attrs) { super(context, attrs); setShowWeekNumber(showWeekNumber); setFirstDayOfWeek(firstDayOfWeek); Log.d( TAG , "MotiveCalendar: Constructor 2 called"); } public MotiveCalendar(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); setShowWeekNumber(showWeekNumber); setFirstDayOfWeek(firstDayOfWeek); Log.d( TAG , "MotiveCalendar: Constructor 3 called"); } Calendar options will definitely be added and changed. I think you can make the parameters setShowWeekNumber(showWeekNumber); , setFirstDayOfWeek(firstDayOfWeek); and the rest, when they appear, in a separate class of MotiveCalendarParams , but I can not understand how I apply these parameters to the calendar then do not produce a bunch of getters in the constructor.
Question: How can I make parameters in a separate class, or how can code duplication be avoided in another way?
init()) and call this method in each constructor. - pavlofff 2:42 pmthis(args)another. - Roxio0