public AchievementFeedlette(JSONObject jobj) {
    super(Rzap.layout("achievement_feedlette"));

    if (jobj != null) {
      try {
        this.achievement = new Achievement(jobj);
      } catch (JSONException e) {
        e.printStackTrace();
      }
    }
  }
Esempio n. 2
0
  protected View buildDialogView() {

    FrameLayout dialogLayout = new FrameLayout(getContext());

    View dialogContents = buildDialogContentView();
    dialogContents.setPadding(1, 1, 1, 1);

    dialogLayout.addView(dialogContents);

    FrameLayout.LayoutParams imageViewLayout =
        new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.FILL_PARENT);
    ImageView borderImage = new ImageView(getContext());
    borderImage.setAdjustViewBounds(true);
    borderImage.setBackgroundResource(Rzap.drawable("dialog_border"));
    dialogLayout.addView(borderImage, imageViewLayout);

    return dialogLayout;
  }
  public View render(View convertView, final Context context, FeedView feedView) {
    // Set up the view holder
    if (convertView == null) {
      convertView = super.render(convertView, context, feedView);

      holder = new ViewHolder();
      holder.achievementIconView =
          (ImageView) convertView.findViewById(Rzap.id("achievement_icon"));
      holder.achievementNameView = (TextView) convertView.findViewById(Rzap.id("achievement_name"));
      holder.achievementDescriptionView =
          (TextView) convertView.findViewById(Rzap.id("achievement_description"));
      holder.achievementNewBadgeView =
          (ImageView) convertView.findViewById(Rzap.id("new_badge_icon"));
      ;

      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    holder.feedlette = this;
    holder.achievementIconView.setImageResource(Rzap.drawable("icon_default_badge"));

    // Fill in the views
    String iconUrl = achievement.getIconUrl();
    if (iconUrl != null && !iconUrl.equals("") && !iconUrl.equals("null")) {
      if (!downloadingAchievementImage) {
        downloadingAchievementImage = true;
        new DownloadImageTask(
                new DownloadImageListener() {

                  @Override
                  public void onImageDownloaded(Bitmap bitmap) {
                    downloadedAchievementImage = bitmap;
                    if (holder.feedlette == AchievementFeedlette.this) {
                      holder.achievementIconView.setImageBitmap(downloadedAchievementImage);
                    }
                  }
                })
            .execute(iconUrl);
      }
      if (downloadedAchievementImage != null) {
        holder.achievementIconView.setImageBitmap(downloadedAchievementImage);
      } else {
        holder.achievementIconView.setImageDrawable(null);
      }
    } else {
      holder.achievementIconView.setImageDrawable(null);
    }

    if (achievement.hasJustUnlocked()) {
      holder.achievementNewBadgeView.setVisibility(View.VISIBLE);
    } else {
      holder.achievementNewBadgeView.setVisibility(View.GONE);
    }

    if (achievement.hasUnlocked()) {
      holder.achievementNameView.setTextColor(0xff000000);
    } else {
      holder.achievementNameView.setTextColor(0xff999999);
    }

    holder.achievementNameView.setText(achievement.getName());
    holder.achievementDescriptionView.setText(achievement.getDescription());

    return convertView;
  }
 public AchievementFeedlette(Achievement achievement) {
   super(Rzap.id("achievement_feedlette"));
   this.achievement = achievement;
 }