Widget for selecting the Bangla weekdays
Add the JitPack repository to your root build.gradle file
allprojects {
repositories {
// ...
maven { url 'https://jitpack.io' }
}
}
Add the dependency
dependencies {
implementation 'com.github.Gkemon:Android-Bangla-Day-Picker:1.0.2'
}
Add the JitPack repository to your build file
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add the dependency
<dependency>
<groupId>com.github.Gkemon</groupId>
<artifactId>Android-Bangla-Day-Picker</artifactId>
<version>1.0.0</version>
</dependency>
<com.gk.emon.android.BanglaDaysPicker
android:id="@+id/weekdays"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:friday_first_day="true" //If true the shows Islamic weekend
app:is_all_days_selected="false" //If true then selects all days
app:is_bangla="true" //If true then shows bangla days otherwise shows english
app:full_size="true"/>
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// ...
BanglaDaysPicker widget = (BanglaDaysPicker) findViewById(R.id.weekdays);
widget.setOnWeekdaysChangeListener(new OnWeekdaysChangeListener() {
@Override
public void onChange(View view, int clickedDayOfWeek, List<Integer> selectedDays) {
// Do Something
}
});
// ...
}
// ...
}
enabled
: If user is allowed to select weekdays (default=true)highlight_color
: Color of selected days and unselected Text (default=Color.RED)background_color
: Background-Color of unselected days (default=Color.LTGRAY)text_color
: Color of selected days text (default=Color.WHITE)sunday_first_day
: Starting with Sunday or Monday (default=true)show_weekend
: Display weekend (Satuarday and Sunday) (default=true)weekenddarker
: Allows that weekend has another color (default=false)weekend_color
: Background-Color from unselected Weekend (default=Color.GRAY)weekend_text_color
: Set the unselected text color from the weekend (default=highlight_color)full_size
: Shows the days with the dayname (f.e. Mo.) and in a rectangle form (default=false)recurrence
: Shows a spinner to select the week recurrence (default=false)border_color
: Set the Border-Color from unselected days (default=-1 no border)border_thickness
: Set the Border-Thickness from unselected days (default=4)border_highlight_color
: Set the Border-Color from selected days (default=-1 no border)border_highlight_thickness
: Set the Border-Thickness from selected days (default=4)
Assuming widget
is an WeekdaysPicker
object
WeekdaysPicker widget = (WeekdaysPicker) findViewById(R.id.weekdays);
widget.setOnWeekdaysChangeListener(new OnWeekdaysChangeListener() {
@Override
public void onChange(View view, int clickedDayOfWeek, List<Integer> selectedDays) {
// Do Something
}
});
widget.setOnWeekRecurrenceChangeListener(new OnWeekRecurrenceChangeListener() {
@Override
public void onWeekChange(View view, List<Integer> selectedDays, int even_week) {
// Do something else
switch (even_week) {
case WeekdaysPicker.ALL:
// if all weeks selected
break;
case WeekdaysPicker.ODD:
// if odd weeks selected
break;
case WeekdaysPicker.EVEN:
// if even weeks selected
break;
}
}
});
Returns selected Days as Integer-List according to Calendar.MONDAY
, Calendar.TUESDAY
and so on
List<Integer> selectedDays = widget.getSelectedDays();
Returns selected Days as Text Optional: Set locale
List<String> selectedDays = widget.getSelectedDaysText();
Accept Integer-List of days you would like to select
List<Integer> days = Arrays.asList(Calendar.MONDAY, Calendar.WEDNESDAY, Calendar.FRIDAY, Calendar.SUNDAY);
widget.setSelectedDays(days);
Select day by Integer of Day (eg. Calendar.SUNDAY
)
widget.selectDay(Calendar.SUNDAY);
if (widget.allDaysSelected()){
// Do Something
}
widget.setOnWeekdaysChangeListener(new OnWeekdaysChangeListener() {
@Override
public void onChange(View view, int clickedDayOfWeek, List<Integer> selectedDays) {
if (selectedDays.size() == 7){
// Do Something
}
}
});
if (widget.noDaySelected()){
// Do Something
}
widget.setOnWeekdaysChangeListener(new OnWeekdaysChangeListener() {
@Override
public void onChange(View view, int clickedDayOfWeek, List<Integer> selectedDays) {
if (selectedDays.size() == 0){
// Do Something
}
}
});
if (widget.isInEditMode()){
// Do Something
}
// Enable the widget
widget.setEditable(true);
// Disable the widget
widget.setEditable(false);
// Integer = CalendarDay, Boolean = selected
LinkedHashMap<Integer, Boolean> map = new LinkedHashMap<>();
mp.put(SUNDAY, true);
mp.put(SATURDAY, true); //counting
mp.put(THURSDAY, false);
mp.put(FRIDAY, true);
mp.put(TUESDAY, true);
mp.put(SATURDAY, false); //For duplicated values, the first one is counting, but the last one is updating the selected value
//Add the custom map
widget.setCustomDays(map);
// To disable the custom days:
widget.setCustomDays(null);
widget.setHighlightColor(Color.RED);
widget.setBackgroundColor(Color.LTGRAY);
widget.setWeekendColor(Color.GRAY);
widget.setTextColor(Color.WHITE);
widget.setSundayFirstDay(true);
widget.setShowWeekend(true);
widget.setRecurrence(true);
widget.setWeekendDarker(true);
widget.setWeekendTextColor(Color.WHITE);
widget.setBorderColor(Color.BLUE);
widget.setBorderThickness(3);
widget.setBorderHighlightColor(Color.MAGENTA);
widget.setBorderHighlightThickness(10);
widget.setFullSize(true);
widget.setSelectOnlyOne(true);