Skip to content

Commit

Permalink
[TimePicker] Change text input view to a view stub
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 347387465
(cherry picked from commit cbef0d3)
  • Loading branch information
ymarian authored and dsn5ft committed Dec 15, 2020
1 parent 77cf940 commit 3a00d7a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.view.Window;
import android.widget.Button;
import android.widget.LinearLayout;
Expand Down Expand Up @@ -63,6 +64,7 @@ public final class MaterialTimePicker extends DialogFragment {

private TimePickerView timePickerView;
private LinearLayout textInputView;
private ViewStub textInputStub;

@Nullable private TimePickerClockPresenter timePickerClockPresenter;
@Nullable private TimePickerTextInputPresenter timePickerTextInputPresenter;
Expand Down Expand Up @@ -211,7 +213,7 @@ public void onDoubleTap() {
timePickerTextInputPresenter.resetChecked();
}
});
textInputView = root.findViewById(R.id.material_textinput_timepicker);
textInputStub = root.findViewById(R.id.material_textinput_timepicker);
modeButton = root.findViewById(R.id.material_timepicker_mode_button);
TextView headerTitle = root.findViewById(R.id.header_title);

Expand Down Expand Up @@ -294,6 +296,7 @@ private void updateInputMode(MaterialButton modeButton) {
}

private TimePickerPresenter initializeOrRetrieveActivePresenterForMode(int mode) {

if (mode == INPUT_MODE_CLOCK) {
timePickerClockPresenter =
timePickerClockPresenter == null
Expand All @@ -304,6 +307,7 @@ private TimePickerPresenter initializeOrRetrieveActivePresenterForMode(int mode)
}

if (timePickerTextInputPresenter == null) {
textInputView = (LinearLayout) textInputStub.inflate();
timePickerTextInputPresenter = new TimePickerTextInputPresenter(textInputView, time);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<include
<ViewStub
android:id="@+id/material_textinput_timepicker"
layout="@layout/material_textinput_timepicker"
android:inflatedId="@+id/material_textinput_timepicker"
android:layout="@layout/material_textinput_timepicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="44dp"
android:layout_marginBottom="24dp"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Expand Down

0 comments on commit 3a00d7a

Please sign in to comment.