package com.quickblox.qmunicate.ui.utils;

import com.quickblox.qmunicate.App;
import com.quickblox.qmunicate.R;

import java.util.Date;
import java.util.concurrent.TimeUnit;

public class OnlineStatusHelper {

    private static final int ONLINE_TIMEOUT = 15;

    public static boolean isOnline(Date lastRequestAt) {
        long timeout = new Date().getTime() - lastRequestAt.getTime();
        return TimeUnit.MILLISECONDS.toMinutes(timeout) < ONLINE_TIMEOUT;
    }

    public static String getOnlineStatus(Date lastRequestAt) {
        if (isOnline(lastRequestAt)) {
            return App.getInstance().getString(R.string.frl_online);
        } else {
            return App.getInstance().getString(R.string.frl_offline);
        }
    }
}

@@ -304,32 +304,73 @@
 astRequestAt) %7B%0A
+        if (lastRequestAt != null) %7B%0A    
         long tim
@@ -424,16 +424,20 @@
 Time();%0A
+    
         
@@ -502,16 +502,48 @@
 IMEOUT;%0A
+        %7D%0A        return false;%0A
     %7D%0A%0A 

fix nullpointer with online status if user never entered qb