package com.vaguehope.onosendai.model;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.vaguehope.onosendai.R;
import com.vaguehope.onosendai.images.ImageLoadRequest;
import com.vaguehope.onosendai.images.ImageLoader;
import com.vaguehope.onosendai.widget.PendingImage;

public enum TweetLayout {

	MAIN(0, R.layout.tweetlistrow) {
		@Override
		public TweetRowView makeRowView (final View view) {
			return new TweetRowView(
					(ImageView) view.findViewById(R.id.imgMain),
					(TextView) view.findViewById(R.id.txtTweet),
					(TextView) view.findViewById(R.id.txtName)
			);
		}

		@Override
		public void applyTweetTo (final Tweet item, final TweetRowView rowView, final ImageLoader imageLoader) {
			rowView.getTweet().setText(item.getBody());
			rowView.getName().setText(item.getUsername() != null ? item.getUsername() : item.getFullname());

			final String avatarUrl = item.getAvatarUrl();
			if (avatarUrl != null) {
				imageLoader.loadImage(new ImageLoadRequest(avatarUrl, rowView.getAvatar()));
			}
			else {
				rowView.getAvatar().setImageResource(R.drawable.question_blue);
			}
		}
	},
	INLINE_MEDIA(1, R.layout.tweetlistinlinemediarow) {
		@Override
		public TweetRowView makeRowView (final View view) {
			return new TweetRowView(
					(ImageView) view.findViewById(R.id.imgMain),
					(TextView) view.findViewById(R.id.txtTweet),
					(TextView) view.findViewById(R.id.txtName),
					(PendingImage) view.findViewById(R.id.imgMedia)
			);
		}

		@Override
		public void applyTweetTo (final Tweet item, final TweetRowView rowView, final ImageLoader imageLoader) {
			MAIN.applyTweetTo(item, rowView, imageLoader);
			final String InlineMediaUrl = item.getInlineMediaUrl();
			if (InlineMediaUrl != null) {
				imageLoader.loadImage(new ImageLoadRequest(InlineMediaUrl, rowView.getInlineMedia()));
			}
			else {
				rowView.getInlineMedia().setImageResource(R.drawable.question_blue);
			}
		}
	};

	private final int index;
	private final int layout;

	private TweetLayout (final int index, final int layout) {
		this.index = index;
		this.layout = layout;
	}

	public int getIndex () {
		return this.index;
	}

	public int getLayout () {
		return this.layout;
	}

	public abstract TweetRowView makeRowView (final View view);

	public abstract void applyTweetTo (Tweet item, TweetRowView rowView, ImageLoader imageLoader);

}

@@ -1699,17 +1699,17 @@
  String 
-I
+i
 nlineMed
@@ -1749,17 +1749,17 @@
 %0A%09%09%09if (
-I
+i
 nlineMed
@@ -1822,17 +1822,17 @@
 Request(
-I
+i
 nlineMed

Fix var name. [sonar]