package net.squanchy.schedule.view;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import net.squanchy.R;

public class SpeakerView extends LinearLayout {

    private ImageView speakerPhotoView;
    private TextView speakerNameView;

    public SpeakerView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public SpeakerView(Context context, AttributeSet attrs, int defStyleAttr) {
        this(context, attrs, defStyleAttr, 0);
    }

    public SpeakerView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);

        super.setOrientation(HORIZONTAL);
    }

    @Override
    public void setOrientation(int orientation) {
        throw new UnsupportedOperationException("SpeakerView doesn't support changing orientation");
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();

        speakerPhotoView = (ImageView) findViewById(R.id.speaker_photo);
        speakerNameView = (TextView) findViewById(R.id.speaker_name);
    }

    public void updateWith(String speakersNames) {
        speakerNameView.setText(speakersNames);
        speakerPhotoView.setImageDrawable(new ColorDrawable(0xFF67B6E2)); // TODO bind photo too
    }
}

@@ -66,56 +66,8 @@
 xt;%0A
-import android.graphics.drawable.ColorDrawable;%0A
 impo
@@ -209,73 +209,429 @@
 ort 
-net.squanchy.R;%0A%0Apublic class SpeakerView extends LinearLayout %7B%0A
+com.google.firebase.storage.FirebaseStorage;%0Aimport com.google.firebase.storage.StorageReference;%0A%0Aimport java.util.Locale;%0A%0Aimport net.squanchy.R;%0Aimport net.squanchy.imageloader.ImageLoader;%0Aimport net.squanchy.imageloader.ImageLoaderInjector;%0A%0Apublic class SpeakerView extends LinearLayout %7B%0A%0A    private static final String SPEAKER_PHOTO_PATH_TEMPLATE = %22speakers/%25s%22;%0A%0A    private final ImageLoader imageLoader;%0A    
 %0A   
@@ -1094,24 +1094,97 @@
 StyleRes);%0A%0A
+        imageLoader = ImageLoaderInjector.obtain(context).imageLoader();%0A
         supe
@@ -1740,96 +1740,282 @@
     
-speakerPhotoView.setImageDrawable(new ColorDrawable(0xFF67B6E2)); // TODO bind photo too
+String path = String.format(Locale.US, SPEAKER_PHOTO_PATH_TEMPLATE, %22squanchy.webp%22);   // TODO use actual speaker ID%0A        StorageReference photoReference = FirebaseStorage.getInstance().getReference(path);%0A        imageLoader.load(photoReference).into(speakerPhotoView);
 %0A   

Load speaker images in schedule