From 13720e52d47ab1237f795218abfb5f96c3a7ad3b Mon Sep 17 00:00:00 2001 From: willlyprkl Date: Wed, 10 May 2017 21:27:49 +0300 Subject: [PATCH] HOTFIX for the nullpointer exception in getFiveProfiles --- .../handlers/profiles/ProfilesHandler.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gameder/app/handlers/profiles/ProfilesHandler.java b/src/main/java/com/gameder/app/handlers/profiles/ProfilesHandler.java index 4873a8b..0dabdbf 100755 --- a/src/main/java/com/gameder/app/handlers/profiles/ProfilesHandler.java +++ b/src/main/java/com/gameder/app/handlers/profiles/ProfilesHandler.java @@ -177,6 +177,17 @@ public ArrayList getFiveProfiles() { * If either end is reached, it will skip that side * The algorithm can be easily limited if the profile pool is huge * */ + + /** + * If both ends have been reached, the roots will be reset + */ + if(maxRoot == null && minRoot == null) { + minnull = false; + maxnull = false; + maxRoot = profileTreeSet.higher(rootPreference); + minRoot = profileTreeSet.lower(rootPreference); + } + if(!minnull && !maxnull) { /** * Minroot is closer @@ -212,15 +223,6 @@ public ArrayList getFiveProfiles() { minRoot = profileTreeSet.lower(minRoot); } - /** - * If both ends have been reached, the roots will be reset - */ - if(maxRoot == null && minRoot == null) { - minnull = false; - maxnull = false; - maxRoot = profileTreeSet.higher(rootPreference); - minRoot = profileTreeSet.lower(rootPreference); - } } return profiles; } else {