Hey there.
Well let's implement the on shirt preferences change listener interface in our main activity.
All right here implements on shared preference.
Change up
and implement implement the method on shared preference.
Changed and here we are right.
Eve key Lisa's input parameter equals
value of our key default interval
but only we need to coat it
and then in this case we run said interval from shared preference method and let's again specify shared
preferences so as not to go to the preference manager solved and let's create an on shared preferences
field
more precisely shared preferences and initialize it once in our own great method a son immediately the
value should preferences per hour sorry preference manager get the full shared preferences D and then
here we can simply indicate this field shared preferences
and also
in the recess time a method
and in the shirt preference changed method as well also as I recall in settings fragment where exists
and our guests of all listen the same thing needs to be done in main activity we are against the great
method our main activity as on shared preferences change releasing
let's do this then on don't create method.
And here we can specify shared preferences or against the shared preferences change listener and or
against our activity these and also override the on destroy method control all on destroy select.
And here we arrive shared preferences on guest.
Listen to this.
Let's try to run
and let's change the setting
25 for example.
And immediately everything he is displayed if we specify
some other value for example one hundred twenty five gay
then specified in these format displayed in these format.
The only thing we can do we still have to set some or it is again here we do not see the default interval.
Let's do this in our settings fragment as you remember we did this set preference label was created
method and here we check whether the preference setting is the type of least preference add another
branch the right.
Else if preference instance all edit takes preference and preference.
So in summary
and value this that all it's around again
how is this incorrectly displayed.
Immediately start up.
Let's see the old method.
Here in our method set interval from shared preferences we don't do a check here like in the time a
method that is instead of just sex use a text.
Let's call this method in our certain interval method here.
Call the method of the timer and poise the default interval in it.
Remove these line let's check how it works
we get zeros why.
Well of course because the default interval is in seconds and we need in the daytime a method in milliseconds.
Therefore here we create another variable of type long.
Call it default interval in Mehlis
and assign the value default interval multiply by 1000
and here we specify its default interval in minutes
relaunch that
and everything is displayed correctly.
Let's check
here.
Display summary in seconds let's specify 115.
Okay.
The summary is updated immediately.
And here it turns out one hundred fifteen seconds.
It is one minute and fifty five seconds.
Everything turns out.
Correct.