This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Profile { | |
| Date lastOnline; | |
| public Date getLastOnline() { | |
| return lastOnline; | |
| } | |
| public void setLastOnline(Date lastOnline) { | |
| this.lastOnline = lastOnline; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Calendar rightNow = Calendar.getInstance(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class OnlineStatus { | |
| private int recentOnlineThresholdDays; | |
| private int onlineThresholdHrs; | |
| public enum States {Unknown, Online, Recent} | |
| public void setOnlineThresholdHrs(int hours) { | |
| this.onlineThresholdHrs = hours; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class OnlineStatus { | |
| private int recentOnlineThresholdDays; | |
| private int onlineThresholdHrs; | |
| public enum States {Unknown, Online, Recent} | |
| public void setOnlineThresholdHrs(int hours) { | |
| this.onlineThresholdHrs = hours; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
OlderNewer