package com.codetroopers.betterpickers.sample.activity.radialtimepicker;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.codetroopers.betterpickers.radialtimepicker.RadialTimePickerDialogFragment;
import com.codetroopers.betterpickers.sample.R;
import com.codetroopers.betterpickers.sample.activity.BaseSampleActivity;
public class SampleRadialTimeForced24hFormat extends BaseSampleActivity
implements RadialTimePickerDialogFragment.OnTimeSetListener {
private static final String FRAG_TAG_TIME_PICKER = "timePickerDialogFragment";
private TextView mResultTextView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.text_and_button);
mResultTextView = (TextView) findViewById(R.id.text);
Button button = (Button) findViewById(R.id.button);
mResultTextView.setText(R.string.no_value);
button.setText(R.string.radial_time_picker);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
RadialTimePickerDialogFragment rtpd = new RadialTimePickerDialogFragment()
.setOnTimeSetListener(SampleRadialTimeForced24hFormat.this)
.setForced24hFormat();
rtpd.show(getSupportFragmentManager(), FRAG_TAG_TIME_PICKER);
}
});
}
@Override
public void onTimeSet(RadialTimePickerDialogFragment dialog, int hourOfDay, int minute) {
mResultTextView.setText(getString(R.string.radial_time_picker_result_value, hourOfDay, minute));
}
@Override
public void onResume() {
// Example of reattaching to the fragment
super.onResume();
RadialTimePickerDialogFragment rtpd = (RadialTimePickerDialogFragment) getSupportFragmentManager().findFragmentByTag(FRAG_TAG_TIME_PICKER);
if (rtpd != null) {
rtpd.setOnTimeSetListener(this);
}
}
}