@Override public void onCreate(final Bundle savedInstanceState) { // used in prepare dialog (must be restored before super.onCreate() _navigationIntent = getActivityArguments() .<NavigationIntent>getValue(Constant.NAVIGATION_INTENT, _navigationIntent); _navigationDialogContinuation = getActivityArguments().<Runnable>getValue(Constant.NAVIGATION_DIALOG_CONTINUATION); final Boolean navigationAllowed = getActivityArguments().<Boolean>getValue(Constant.NAVIGATION_ALLOWED, Boolean.TRUE); if (navigationAllowed != null) { _isNavigationAllowed = navigationAllowed; } super.onCreate(savedInstanceState); addObservedKeys( ValueStore.concatenateKeys(Constant.USER_VALUES, Constant.NUMBER_CHALLENGES_WON)); _challenge = getActivityArguments().getValue(Constant.CHALLENGE, null); // assert challenge != null _opponentValueStore = new ValueStore(); _opponentValueStore.putValue(Constant.USER, _challenge.getContender()); _opponentValueStore.addObserver(Constant.NUMBER_CHALLENGES_WON, this); _opponentValueStore.addValueSources(new UserDetailsAgent(this)); setNeedsRefresh(); initAdapter(); }
@Override public void requestControllerDidReceiveResponseSafe(final RequestController aRequestController) { final List<Game> featuredGames = _gamesController.getGames(); if (featuredGames.size() > 0) { final ValueStore store = getScreenValues(); final Game game = featuredGames.get(0); store.putValue(Constant.FEATURED_GAME, game); store.putValue(Constant.FEATURED_GAME_NAME, game.getName()); store.putValue(Constant.FEATURED_GAME_PUBLISHER, game.getPublisherName()); store.putValue(Constant.FEATURED_GAME_IMAGE_URL, game.getImageUrl()); showControlIcon(R.drawable.sl_button_arrow); } }
@Override public void onValueSetDirty(final ValueStore valueStore, final String key) { if (valueStore == _opponentValueStore) { _opponentValueStore.retrieveValue( Constant.NUMBER_CHALLENGES_WON, ValueStore.RetrievalMode.NOT_DIRTY, null); } else if (Constant.NUMBER_CHALLENGES_WON.equals(key)) { getUserValues().retrieveValue(key, ValueStore.RetrievalMode.NOT_DIRTY, null); } }
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState, R.layout.sl_header_default); setCaption(getGame().getName()); final Integer mode = getActivityArguments().getValue(PaymentConstant.GAME_ITEMS_MODE); if (mode == PaymentConstant.GAME_ITEMS_MODE_GAME_ITEM) { getImageView().setImageDrawable(getResources().getDrawable(R.drawable.sl_header_icon_shop)); setTitle(getResources().getString(R.string.sl_shop)); if (ScoreloopManagerSingleton.get() .getSupportedPaymentProviderKinds() .contains("game_currency")) { final ImageView icon = (ImageView) findViewById(R.id.sl_control_icon); icon.setImageResource(R.drawable.sl_button_add_coins); icon.setEnabled(true); icon.setOnClickListener( new View.OnClickListener() { @Override public void onClick(final View view) { if (getSession().isAuthenticated()) { display(getFactory().createChallengePaymentScreenDescription()); } } }); displayBalance = true; } } else if (mode == PaymentConstant.GAME_ITEMS_MODE_COIN_PACK) { getImageView().setImageDrawable(getResources().getDrawable(R.drawable.sl_button_add_coins)); setTitle(getResources().getString(R.string.sl_add_coins)); displayBalance = true; } if (displayBalance) { addObservedKeys(ValueStore.concatenateKeys(Constant.USER_VALUES, Constant.USER_BALANCE)); } }
@Override public void onRefresh(final int flags) { _opponentValueStore.retrieveValue( Constant.NUMBER_CHALLENGES_WON, ValueStore.RetrievalMode.NOT_DIRTY, null); }