RocketChatAvatar.java 1.35 KB
Newer Older
Tiago Cunha's avatar
Tiago Cunha committed
1
package chat.rocket.android.widget;
2 3 4 5 6 7 8

import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
9
import chat.rocket.android.widget.helper.FrescoHelper;
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
import com.facebook.drawee.view.SimpleDraweeView;

public class RocketChatAvatar extends FrameLayout {

  private SimpleDraweeView draweeView;

  public RocketChatAvatar(Context context) {
    super(context);
    initialize(context, null);
  }

  public RocketChatAvatar(Context context, AttributeSet attrs) {
    super(context, attrs);
    initialize(context, attrs);
  }

  public RocketChatAvatar(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    initialize(context, attrs);
  }

  @TargetApi(Build.VERSION_CODES.LOLLIPOP)
  public RocketChatAvatar(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    initialize(context, attrs);
  }

  private void initialize(Context context, AttributeSet attrs) {
38 39
    LayoutInflater
        .from(context)
40
        .inflate(R.layout.message_avatar, this, true);
41
    draweeView = findViewById(R.id.drawee_avatar);
42 43
  }

44 45 46
  public void loadImage(String imageUri) {
    FrescoHelper
        .loadImage(draweeView, imageUri);
47
  }
48
}