Coder Social home page Coder Social logo

in 0 mins about android-ago HOT 14 CLOSED

curioustechizen avatar curioustechizen commented on June 4, 2024
in 0 mins

from android-ago.

Comments (14)

broakenmedia avatar broakenmedia commented on June 4, 2024 2

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();
}

from android-ago.

Mpendxlo avatar Mpendxlo commented on June 4, 2024 2

@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.

from android-ago.

khdkls avatar khdkls commented on June 4, 2024 1

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

from android-ago.

curioustechizen avatar curioustechizen commented on June 4, 2024 1

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

from android-ago.

janakagamini avatar janakagamini commented on June 4, 2024

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

from android-ago.

broakenmedia avatar broakenmedia commented on June 4, 2024

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

from android-ago.

janakagamini avatar janakagamini commented on June 4, 2024

@xbroak Thanks, will try it out!

from android-ago.

Mpendxlo avatar Mpendxlo commented on June 4, 2024

Great solution @xbroak , works like a bomb.

from android-ago.

khdkls avatar khdkls commented on June 4, 2024

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();
}

from android-ago.

ovitrif avatar ovitrif commented on June 4, 2024

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

from android-ago.

curioustechizen avatar curioustechizen commented on June 4, 2024

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").

from android-ago.

Redman1037 avatar Redman1037 commented on June 4, 2024

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

from android-ago.

Redman1037 avatar Redman1037 commented on June 4, 2024

As a work around i kept

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

from android-ago.

curioustechizen avatar curioustechizen commented on June 4, 2024

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.

from android-ago.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.