Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in 0 mins #37

Closed
broakenmedia opened this issue Jul 18, 2016 · 14 comments
Closed

in 0 mins #37

broakenmedia opened this issue Jul 18, 2016 · 14 comments

Comments

@broakenmedia
Copy link

Seems to happen basically the moment a new item is added with timestamp = now, shortly after that, the value changes to "Just now" as expected

@janakagamini
Copy link

As a temporary solution I find that if I offset now by about -300ms it behaves as expected.

@broakenmedia
Copy link
Author

@janakagamini No such luck here! I've gone up to 3 seconds so far from the reference time and it's still happening

@broakenmedia
Copy link
Author

broakenmedia commented Dec 7, 2016

OK, just found a way to sort thing, well, at least to make sure it's Just Now instead of 0 minutes.

My app is a client/server of sorts, with the client sending it's timestamp to the server, thus showing how long ago the last "ping" was sent thus:

The issue seems to happen when there are discrepancies between the two devices and the currentTimeMillis being reported. To be expected, to that end, all i need to do is:

long reportedTimeStamp = getDevice_status_timestamp();
long difBetween = System.currentTimeMillis() - reportedTimeStamp;
if(difBetween < 0){ 
        i.e. If NOW is somehow less than the one being reported, just make it NOW
        reportedTimeStamp = System.currentTimeMillis();
}

@janakagamini
Copy link

@xbroak Thanks, will try it out!

@Mpendxlo
Copy link

Great solution @xbroak , works like a bomb.

@khdkls
Copy link

khdkls commented May 25, 2017

Where to place this code ?

long reportedTimeStamp = getDevice_status_timestamp();
long difBetween = System.currentTimeMillis() - reportedTimeStamp;
if(difBetween < 0){
i.e. If NOW is somehow less than the one being reported, just make it NOW
reportedTimeStamp = System.currentTimeMillis();
}

@Mpendxlo
Copy link

Mpendxlo commented May 29, 2017

@khitdhikhun you can apply this code like so...

private void setTime(final long timeStamp){
try{

            long reportedTimeStamp = timeStamp;
            long difBetween = System.currentTimeMillis() - reportedTimeStamp;
            if(difBetween < 0){
                reportedTimeStamp = System.currentTimeMillis();
            }
            //RelativeTimeTextView timestamp
            timestamp.setReferenceTime(reportedTimeStamp);

        } catch (Exception e){
        }
    }

Here is a method to read time that the post was posted from firebase, i pass the time stamp and apply the piece of code by @xbroak. the results are good.

@khdkls
Copy link

khdkls commented May 30, 2017

@Mpendxlo Thanks, I think they just fixed it. It always show"Just now" instead of In 0 min.
Sorry for bad english.

@ovitrif
Copy link
Contributor

ovitrif commented Jun 23, 2017

One of our testers was still encountering this on the latest version, I don't think it's fixed.

@curioustechizen
Copy link
Owner

@ovitrif Any repro steps would be helpful. And of course I'm accepting PRs for this one.

@curioustechizen
Copy link
Owner

The current logic for displaying the "Just now" string is as follows. Both the following conditions have to be satisfied

  • The current time is later than reference time
  • The difference between current time and reference time is one minute or less.

It is possible that you see the "In 0 mins" text if your reference time is in the future, and less than a minute into the future.

Note that the "In 0 mins" text comes directly from Android'sDateUtils class, and not from android-ago.
Also note that this is not necessarily a bug - if your reference time is in the very near future, you probably want to show it as "In 0 mins" (although a nicer string would be good - like "Soon").

@Redman1037
Copy link

tried @Mpendxlo solution , but still facing this issue , please fix it

@Redman1037
Copy link

As a work around i kept

          if (difBetween < 0) {
                refDate = System.currentTimeMillis() - 3000;
            }

@curioustechizen
Copy link
Owner

v1.4.0 of this library has been released. It allows you to customize the display text before it is displayed. You can use it if you want to prevent in 0 mins. I'm closing this issue for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants