svenwiegand / time-duration-picker Goto Github PK
View Code? Open in Web Editor NEWAn android time duration input control and picker dialog as known from Lollipop's stock timer app.
License: MIT License
An android time duration input control and picker dialog as known from Lollipop's stock timer app.
License: MIT License
Because of this the view restore procedure can crash (for me it started crashing after switching to the android support libraries' Fragments.
For reference, this is the weird Exception that is produced: "java.lang.RuntimeException: Parcel android.os.Parcel@33bc0fc: Unmarshalling unknown type code 3145776 at offset 1340"
Of course the code and the offset may vary depending on your view hierarchy.
This is the correct implementation:
`public static class SavedState extends BaseSavedState {
final String durationInput;
public SavedState(Parcelable superState, String durationInput) {
super(superState);
this.durationInput = durationInput;
}
@SuppressWarnings("unused")
public SavedState(Parcel source) {
super(source);
durationInput = source.readString();
}
@Override
public void writeToParcel(Parcel out, int flags) {
super.writeToParcel(out, flags);
out.writeString(durationInput);
}
public static final Parcelable.Creator<SavedState> CREATOR
= new Parcelable.Creator<SavedState>() {
public SavedState createFromParcel(Parcel in) {
return new SavedState(in);
}
public SavedState[] newArray(int size) {
return new SavedState[size];
}
};
}
The only thing that is changed is the added CREATOR field.
It's impossible to use this library in recent IDE versions... Can something be done about it ?
I just released my app in the Play Store and it uses this library! It's not available in Germany yet -- I'm waiting on some string translations that should be ready in the next few days.
Thanks for the free code :)
https://play.google.com/store/apps/details?id=co.apexpark.sessions
what can it be?
thanks for the awesome library!
creating a new instance should use getSupportFragmentManager()
new PickerDialogFragment().show(getFragmentManager(), "dialog");
any work arounds available?
Apparently when I use the time-duration picker widget as a fragment, it doesn't automatically
use the right textColor. So it's not possible to see the values entered into the dialog as the text color and the background are both white. Is there any way to change the durationDisplayBackground from the java code in my own extension of the TimeDurationPickerDialogFragment? I've already tried to change the style using myFragement.setStyle() but it doesn't seem to work. What am I missing? Thanks a lot!
I tried to implement the TimeDurationPickerDialog based on the AlertDialog, but when I click the button, the screen is just faded out without showing the TimeDurationPickerDialog. Here is my example code:
durationPicker.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { TimeDurationPickerDialog.Builder durationDialog = new TimeDurationPickerDialog.Builder(CreateEventActivity.this,R.style.AlertDialog); durationDialog.show(); } });
Rationale: https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/
Quote (from a link above):
May 1st | Bintray, JCenter, GoCenter, and ChartCenter services will no longer be available
@svenwiegand let me know if I can help you with this.
Hi,
Is there a way to show only hours and minutes? In fact could it be possible to switch units, from hours to minutes or something like that?
Thanks
Thanks for this library. It is really cool. Only issue am facing is to enter time since it starts from seconds. even for setting one hour , i have to press 1 and five 0s.
I'm new to Android dev so this is probably a really easy question, but how does one get the duration from the TimePicker fragment?
I've got the TimePicker.java fragment in the directory with my activity. The activity successfully opens the fragment when the user long clicks on some text, but I can't figure out how to return the duration value from the fragment back to the activity. I spent a few hours yesterday messing around with interfaces but never got it to work.
TimeDurationPicker.onMeasure doesn't properly set the size of the numPad.
// measure the numPad
// if we have more space available, we can try to grow the num pad
final int numPadWidth = Math.max(minNumPadHeight, displayRowWidth);
final int numPadHeight = Math.max(minNumPadHeight, preferredHeight - displayRowHeight);
numPad.measure(MeasureSpec.makeMeasureSpec(numPadWidth, MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(numPadHeight, MeasureSpec.EXACTLY));
For the numPadWidth, I think you want minNumPadWidth instead of minNumPadHeight.
However, using Math.max doesn't work properly on smaller screens. If the available screen height is smaller than the minNumPadHeight, the height you set will be too large (similar for width), and the keyboard gets cut of. For example:
killing the zeroes.
I'd put in a pull request, but I don't know if this would kill the expected behavior from other users...
Is it possible to set the title and prompt text of the TimePickerDialog? I'm sorry if this is a trivial question but I'm new to android development.
The TimeDurationPicker
itself is customizable using XML attributes. The TimeDurationPickerPreference
opens a dialog that contains a TimeDurationPicker
which could in turn be customized using XML attributes.
As a use case, I have some durations in my preferences.xml
that need different appearance (in my case the timeUnits
attribute needs to be customized for some of them). I think it would make sense to support most of the styleable attributes from TimeDurationPicker
in the TimeDurationPickerPreference
.
when i open the same instance of TimePickerFragment i created, it always opens with defualt duration and dosn't save my last set duration
Hi,
At first, thank you for uploading it, it is a nice component, it saved a lot of time for me. However in my app I'm using supportDialogs and fragments, and I would be good if I can avoid to rewrite my whole application.
Do you have any objections to use support.v4.app.DialogFragment instead of app.DialogFragment?
If there's no any, could you please change your part in here?
Thank you in advance,
Tamás Oarga
Hi.
I'm using dialog with minutes and seconds
protected int setTimeUnits() { return TimeDurationPicker.MM_SS; }
protected long getInitialDuration() { return 30000 } //30 seconds
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.