Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

added setTitleTypeface #317

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import java.util.concurrent.TimeUnit;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.res.ResourcesCompat;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
Expand Down Expand Up @@ -214,8 +216,8 @@ public void onClosed(SingleDateAndTimePicker picker) {
Log.d(TAG, "Dialog closed");
}
})

.title("Simple")
.titleTypeFace(ResourcesCompat.getFont(getBaseContext(), R.font.dinot_bold))
.listener(new SingleDateAndTimePickerDialog.Listener() {
@Override
public void onDateSelected(Date date) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.florent37.singledateandtimepicker.dialog;

import android.content.Context;
import android.graphics.Typeface;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
Expand Down Expand Up @@ -33,6 +34,8 @@ public class SingleDateAndTimePickerDialog extends BaseDialog {
@Nullable
private Integer titleTextSize;
@Nullable
private Typeface titleTypeFace;
@Nullable
private Integer bottomSheetHeight;
@Nullable
private String todayText;
Expand Down Expand Up @@ -128,6 +131,10 @@ public void onClick(View v) {
if (titleTextSize != null) {
titleTextView.setTextSize(titleTextSize);
}

if (titleTypeFace != null) {
titleTextView.setTypeface(titleTypeFace);
}
}

picker.setTodayText(new DateWithLabel(todayText, new Date()));
Expand Down Expand Up @@ -215,6 +222,11 @@ public SingleDateAndTimePickerDialog setTitleTextSize(@Nullable Integer titleTex
return this;
}

public SingleDateAndTimePickerDialog setTitleTypeFace(@Nullable Typeface titleTypeFace) {
this.titleTypeFace = titleTypeFace;
return this;
}

public SingleDateAndTimePickerDialog setBottomSheetHeight(@Nullable Integer bottomSheetHeight) {
this.bottomSheetHeight = bottomSheetHeight;
return this;
Expand Down Expand Up @@ -352,6 +364,9 @@ public static class Builder {
@Nullable
private Integer titleTextSize;

@Nullable
private Typeface titleTypeFace;

@Nullable
private Integer bottomSheetHeight;

Expand Down Expand Up @@ -416,6 +431,11 @@ public Builder titleTextSize(@Nullable Integer titleTextSize) {
return this;
}

public Builder titleTypeFace(@Nullable Typeface titleTypeface) {
this.titleTypeFace = titleTypeface;
return this;
}

public Builder bottomSheetHeight(@Nullable Integer bottomSheetHeight) {
this.bottomSheetHeight = bottomSheetHeight;
return this;
Expand Down Expand Up @@ -549,6 +569,7 @@ public Builder focusable() {
public SingleDateAndTimePickerDialog build() {
final SingleDateAndTimePickerDialog dialog = new SingleDateAndTimePickerDialog(context, bottomSheet)
.setTitle(title)
.setTitleTypeFace(titleTypeFace)
.setTitleTextSize(titleTextSize)
.setBottomSheetHeight(bottomSheetHeight)
.setTodayText(todayText)
Expand Down