@Override public void onRefresh(final int flags) { final Button controlButton = (Button) findViewById(R.id.sl_control_button); final Game game = getGame(); ImageDownloader.downloadImage( game.getImageUrl(), getResources().getDrawable(R.drawable.sl_icon_games_loading), getImageView(), null); setTitle(game.getName()); setSubTitle(game.getPublisherName()); if (game.getPackageNames() != null) { if (PackageManager.isGameInstalled(this, game)) { controlButton.setText(getString(R.string.sl_launch)); controlButton.setOnClickListener( new OnClickListener() { @Override public void onClick(final View v) { getTracker() .trackEvent( TrackerEvents.CAT_NAVI, TrackerEvents.NAVI_HEADER_GAME_LAUNCH, game.getName(), 0); PackageManager.launchGame(GameDetailHeaderActivity.this, game); } }); } else { controlButton.setText(getString(R.string.sl_get)); controlButton.setOnClickListener( new OnClickListener() { @Override public void onClick(final View v) { getTracker() .trackEvent( TrackerEvents.CAT_NAVI, TrackerEvents.NAVI_HEADER_GAME_GET, game.getName(), 0); PackageManager.installGame(GameDetailHeaderActivity.this, game); } }); } controlButton.setVisibility(View.VISIBLE); } else { controlButton.setVisibility(View.GONE); } }
@Override public void onValueChanged( final ValueStore valueStore, final String key, final Object oldValue, final Object newValue) { if (oldValue != newValue) { if (key.equals(Constant.FEATURED_GAME_IMAGE_URL)) { ImageDownloader.downloadImage( (String) newValue, getResources().getDrawable(R.drawable.sl_header_icon_market), getImageView(), null); } else if (key.equals(Constant.FEATURED_GAME_NAME)) { setTitle((String) newValue); } else if (key.equals(Constant.FEATURED_GAME_PUBLISHER)) { setSubTitle((String) newValue); } } }
@Override public View getView(View view, final ViewGroup parent) { if (view == null) { view = getLayoutInflater().inflate(R.layout.sl_grid_item_game_item, null); } final String imageUrl = getImageUrl(); final ImageView icon = (ImageView) view.findViewById(R.id.sl_icon); if (imageUrl != null) { final Drawable drawable = getDrawableLoading(); ImageDownloader.downloadImage(imageUrl, drawable, icon, getDrawableLoadingError()); } else { final Drawable drawable = getDrawable(); if (drawable != null) { icon.setImageDrawable(drawable); } } ((TextView) view.findViewById(R.id.sl_title)).setText(getTitle()); final TextView subTitle = (TextView) view.findViewById(R.id.sl_subtitle); if (subTitle != null) { subTitle.setText(getSubTitle()); } final TextView priceText = (TextView) view.findViewById(R.id.sl_price); if (priceText != null) { priceText.setVisibility(getPriceText().length() > 0 ? View.VISIBLE : View.GONE); priceText.setText(getPriceText()); } final TextView priceTextSmall = (TextView) view.findViewById(R.id.sl_price_header); if (priceTextSmall != null) { priceTextSmall.setVisibility(getPriceTextSmall().length() > 0 ? View.VISIBLE : View.GONE); priceTextSmall.setText(getPriceTextSmall()); } view.findViewById(R.id.sl_buy_button).setBackgroundDrawable(buttonDrawable); return view; }