Skip to content

Instantly share code, notes, and snippets.

public class OnlineStatus {
public enum States {Unknown, Online}
private int onlineThresholdHrs;
public void setOnlineThresholdHrs(int hours) {
this.onlineThresholdHrs = hours;
}
public States getStatus(Date lastOnline, Calendar calendar) {
public class Profile {
Date lastOnline;
public Date getLastOnline() {
return lastOnline;
}
public void setLastOnline(Date lastOnline) {
this.lastOnline = lastOnline;
}
Calendar rightNow = Calendar.getInstance();
@Test
public void onlineTest() throws Exception {
Profile profile = new Profile();
//sets instance to right now
Calendar calendar = Calendar.getInstance();
//get time of right now and set users online status with it
profile.setLastOnline(calendar.getTime());
//create and configure
public class OnlineStatus {
public enum States {Unknown, Online}
private int onlineThresholdHrs;
public void setOnlineThresholdHrs(int hours) {
this.onlineThresholdHrs = hours;
}
public States getStatus(Date lastOnline, Calendar calendar) {
public class ProfileOnlineStatusTest {
@Test
public void this_week() throws Exception {
Profile profile = new Profile();
//sets instance to right now
Calendar calendar = Calendar.getInstance();
// 6 days is less than a week
calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 6);
//get time of right now and set users online status with it
public class OnlineStatus {
private int recentOnlineThresholdDays;
private int onlineThresholdHrs;
public enum States {Unknown, Online, Recent}
public void setOnlineThresholdHrs(int hours) {
this.onlineThresholdHrs = hours;
}
public class OnlineStatus {
private int recentOnlineThresholdDays;
private int onlineThresholdHrs;
public enum States {Unknown, Online, Recent}
public void setOnlineThresholdHrs(int hours) {
this.onlineThresholdHrs = hours;
}
package com.dkary.portj.danichat.fragments.profile;
import java.util.Calendar;
import java.util.Date;
public class OnlineStatus {
public enum States {Unknown, Online, Distant, Recent, Offline;}
private int recentOnlineThresholdDays;
private int onlineThresholdHrs;
package com.dkary.portj.danichat;
import com.dkary.portj.danichat.fragments.profile.OnlineStatus;
import com.dkary.portj.danichat.models.Profile;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import java.util.Calendar;