Android

Don't say hi. Don't ask questions. Don't have fun. Don't do an...
Mar 14 12:35
no point in remembering anything google related, it gets changed almost every week
Mar 14 12:35
I just go search these
Feb 4 12:09
starting this succession series instead
Feb 4 12:09
somehow i'd already seen norsemen, and didn't remember it :/
Feb 2 12:58
I was searching for something to watch this weekend already, think I can start this one.
Feb 2 12:58
Starting.
Feb 2 12:32
I should too, this weekend
Jan 2, 2023 11:46
Meanwhile, you can create a minimal reproducible project to test?
Jan 2, 2023 11:44
@MARSH perhaps in 3 hours
Aug 10, 2021 06:47
Maybe RecyclerView#findViewHolderForAdapterPosition()
Feb 6, 2020 08:15
About coroutines
Feb 6, 2020 08:15
Jan 6, 2020 04:50
Hi, does someone have a clue about this? stackoverflow.com/questions/59589306
Oct 30, 2019 11:04
these things are weird to me. I read something else, and when it comes to implementation, I have to do something else.
Oct 30, 2019 11:03
And, I was thinking why wouldn't they suggest trycatch as their primary excpetion handling method in a doc about exception-handling.
 
May 15, 2020 05:49
@VivekYadav Please do this.
May 15, 2020 05:48
I will read up on this in free time.
May 15, 2020 05:48
Thank you.
May 15, 2020 05:48
You can proceed to re-suggest these changes stackoverflow.com/review/suggested-edits/26122165
May 14, 2020 13:15
I will surely come back to this, and add your edit if I am wrong.
May 14, 2020 13:14
@VivekYadav perhaps I am not understanding this.
May 14, 2020 13:14
Can you show me a demo of "composition instead of inheritance (implementing onDatePick and onTimePick)"?
May 14, 2020 10:03
Hi, I see that you suggested an edit to the answer. Your edit is good in terms of conciseness. But for anyone, who comes looking for information, this edit is not readable.

I kept the answer minimal so that it is readable and understandable easily. You can create a gist of your improved edit and post it as a comment to the answer.
Apr 30, 2020 15:15
bye.
Apr 30, 2020 15:15
Thank you too
Apr 30, 2020 15:10
added explanation
Apr 30, 2020 15:05
Added an answer
Apr 30, 2020 14:51
I am writing a snippet.
Apr 30, 2020 14:50
Do not send project code.
Apr 30, 2020 14:27
lemme try
Apr 30, 2020 14:24
Do this

itemView.txtGreetingTime.text = if (...

inside TimeSet listener
Apr 30, 2020 14:24
Wait
Apr 30, 2020 14:23
Well done
Apr 30, 2020 14:23
This will work for your code
Apr 30, 2020 14:23
Ok yes.
Apr 30, 2020 14:23
Even then it wouldn't work I think, you might need a Callback interface and pass it to your dateToString method.
Apr 30, 2020 14:21
return if (DateFormat.is24HourFormat(context)){
Toast.makeText(context, "Chose 24-hour clause", Toast.LENGTH_SHORT).show()
SimpleDateFormat("dd mmm, yyyy 'at' HH:mm", Locale.getDefault()).format(c.time)}
else{
Toast.makeText(context, "Chose 12-hour clause", Toast.LENGTH_SHORT).show()
SimpleDateFormat("dd mmm, yyyy 'at' hh:mm aa", Locale.getDefault()).format(c.time)}
Apr 30, 2020 14:21
Also, I think following code returns before selecting time.
Apr 30, 2020 14:21
This is synchronised now.
Apr 30, 2020 14:16
Into DateSet Listener.
Apr 30, 2020 14:16
Move this code:

val timePicker = createTimePicker{
_, hour, minute ->
c[Calendar.HOUR] = hour
c[Calendar.MINUTE] = minute
}
// Do time picking stuff
timePicker.show()

return if (DateFormat.is24HourFormat(context)){
Toast.makeText(context, "Chose 24-hour clause", Toast.LENGTH_SHORT).show()
SimpleDateFormat("dd mmm, yyyy 'at' HH:mm", Locale.getDefault()).format(c.time)}
else{
Toast.makeText(context, "Chose 12-hour clause", Toast.LENGTH_SHORT).show()
SimpleDateFormat("dd mmm, yyyy 'at' hh:mm aa", Locale.getDefault()).format(c.time)}
Apr 30, 2020 14:16
Hello
Apr 30, 2020 13:38
Also, this is going to be faulty code in long run. Basically, you'd create both pickers globally. Implement listeners on your adapter. And, set values(date, time) on global pickers before calling them.
Apr 30, 2020 13:36
Remember TimePicker must be created after onDateSet for it to work with your existing code.
Apr 30, 2020 13:34
Or do this/

fun onDateSet() {
// apply selection to calendar

val timePicker = createTimePicker(onTimeSetListener)
timePicker.show()
}
Apr 30, 2020 13:32
Or create a method that returns TimePicker.
Apr 30, 2020 13:31
That is a problem. Declare your pickers globally.
Apr 30, 2020 13:31
Also, In your posted code, TimePicker is being created with old date because you create TimePicker before creating DatePicker. By the time a date is selected, and you change the Calendar, TimePicker is already created. So, newly selected date is not given to already created TimePicker.
Apr 30, 2020 13:31
Can you check by formatting with "AM / PM" if 02:30 is from morning.
Apr 30, 2020 13:31
You changed the date in your second try. Did you assign picked date from DatePicker to Calendar.getInstance() you're using before opening TimePicker. Can you check this?