Esempio n. 1
0
  // Replace the contents of a view (invoked by the layout manager)
  @Override
  public void onBindViewHolder(final SpeakersAdapter.ViewHolder holder, final int position) {
    final Speaker speaker = mSpeakerList.get(position);
    holder.speakerImage.setImageDrawable(null);

    holder.titleTextView.setText(speaker.title);
    holder.nameTextView.setText(speaker.name);
    holder.bioTextView.setText(speaker.bio);
    holder.countryCompanyTextView.setText(speaker.company + ", " + speaker.country);

    Log.e("URL", speaker.photoUrl);
    if (speaker.photoUrl.startsWith("http")) {
      url = speaker.photoUrl;
      Log.e("URL", url);
      Glide.with(mContext)
          .load(url)
          .diskCacheStrategy(DiskCacheStrategy.ALL)
          .crossFade()
          .into(holder.speakerImage);
    } else {
      Log.e("URL", fb.getImageRoot().toString());
      fb.getImageRoot()
          .child(speaker.photoUrl)
          .getDownloadUrl()
          .addOnSuccessListener(
              new OnSuccessListener<Uri>() {
                @Override
                public void onSuccess(Uri uri) {
                  speaker.photoUrl = uri.toString();
                  url = uri.toString();
                  Log.e("URL", url);
                  Glide.with(mContext)
                      .load(speaker.photoUrl)
                      .diskCacheStrategy(DiskCacheStrategy.ALL)
                      .crossFade()
                      .into(holder.speakerImage);
                }
              })
          .addOnFailureListener(
              new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception exception) {
                  // Handle any errors
                }
              });
    }

    holder.speakerImage.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            if (mOnSpeakerClickListener != null) {
              mOnSpeakerClickListener.onSpeakerClick(holder.speakerImage, speaker, position);
            }
          }
        });
  }
Esempio n. 2
0
 public SpeakersAdapter(
     ArrayList<Speaker> data, BaseActivity context, OnSpeakerClickListener listener) {
   mSpeakerList = data;
   mContext = context;
   mOnSpeakerClickListener = listener;
   fb = FB.getInstance();
 }