Commit 89172b6f authored by Matyáš Latner's avatar Matyáš Latner

Oprava leakování paměti u GameMenu

parent 93bd63dc
......@@ -102,6 +102,16 @@ public class GameMenu extends AbstractMenuFragment implements OnPageChangeListen
ambientStopped = true;
}
};
SightSeeingBroadcastReceiver receiver = new SightSeeingBroadcastReceiver() {
@Override
protected void onNewUserBroadcastReceivedAction() {
if (gamesPager != null) {
gamesPager.setCurrentItem(gamesPager.getAdapter().getCount() - 1, false);
}
}
};
/* //////////////////////////////////////////// TABLEXIA FRAGMENT LIFECYCLE */
......@@ -121,14 +131,7 @@ public class GameMenu extends AbstractMenuFragment implements OnPageChangeListen
if ((u == null) || !u.isSightseeingShown()) {
gamesPager.setCurrentItem(gamesPager.getAdapter().getCount() - 1, false);
}
SightSeeingBroadcastReceiver receiver = new SightSeeingBroadcastReceiver() {
@Override
protected void onNewUserBroadcastReceivedAction() {
gamesPager.setCurrentItem(gamesPager.getAdapter().getCount() - 1, false);
}
};
IntentFilter filter = new IntentFilter("cz.nic.tablexia.action.NEW_USER_CREATED");
LocalBroadcastManager.getInstance(getActivity()).registerReceiver(receiver, filter);
......@@ -180,6 +183,8 @@ public class GameMenu extends AbstractMenuFragment implements OnPageChangeListen
gamesPager.setOnPageChangeListener(this);
goToPage(selectedPageNumber, false);
}
/* //////////////////////////////////////////// ANDROID FRAGMENT LIFECYCLE */
@Override
public void onBackPressed() {
......@@ -190,6 +195,13 @@ public class GameMenu extends AbstractMenuFragment implements OnPageChangeListen
}
}
}
@Override
public void onDestroy() {
LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(receiver);
LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(receiverAmbient);
super.onDestroy();
}
/* //////////////////////////////////////////// INTRO ANIMATION */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment