Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set title after onCreateView #164

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -104,6 +104,7 @@ public class TimePickerDialog extends DialogFragment implements
private TextView mSecondView;
private TextView mSecondSpaceView;
private TextView mAmPmTextView;
private TextView mTimePickerHeader;
private View mAmPmHitspace;
private RadialPickerLayout mTimePicker;

Expand Down Expand Up @@ -198,10 +199,18 @@ public void initialize(OnTimeSetListener callback,
}

/**
* Set a title. NOTE: this will only take effect with the next onCreateView
* Set a title.
*/
public void setTitle(String title) {
mTitle = title;
mTitle = title == null ? "" : title;
if (mTimePickerHeader != null) {
if (!mTitle.isEmpty()) {
mTimePickerHeader.setVisibility(TextView.VISIBLE);
mTimePickerHeader.setText(mTitle.toUpperCase(Locale.getDefault()));
} else {
mTimePickerHeader.setText(mTitle);
}
}
}

public String getTitle() {
Expand Down Expand Up @@ -621,16 +630,13 @@ public void onClick(View v) {
}

// Set the title (if any)
TextView timePickerHeader = (TextView) view.findViewById(R.id.time_picker_header);
if (!mTitle.isEmpty()) {
timePickerHeader.setVisibility(TextView.VISIBLE);
timePickerHeader.setText(mTitle.toUpperCase(Locale.getDefault()));
}
mTimePickerHeader = (TextView) view.findViewById(R.id.time_picker_header);
setTitle(mTitle);

// Set the theme at the end so that the initialize()s above don't counteract the theme.
mOkButton.setTextColor(mAccentColor);
mCancelButton.setTextColor(mAccentColor);
timePickerHeader.setBackgroundColor(Utils.darkenColor(mAccentColor));
mTimePickerHeader.setBackgroundColor(Utils.darkenColor(mAccentColor));
view.findViewById(R.id.time_display_background).setBackgroundColor(mAccentColor);
view.findViewById(R.id.time_display).setBackgroundColor(mAccentColor);

Expand Down