package cl.monsoon.s1next.view.adapter;

import android.app.Activity;
import android.support.annotation.LayoutRes;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.List;

import cl.monsoon.s1next.App;
import cl.monsoon.s1next.data.api.model.Forum;
import cl.monsoon.s1next.util.ViewUtil;

public final class SubForumArrayAdapter extends ArrayAdapter<Forum> {

    private final LayoutInflater mLayoutInflater;
    @LayoutRes
    private final int mResource;

    private final int mGentleAccentColor;

    public SubForumArrayAdapter(Activity activity, @LayoutRes int resource, List<Forum> objects) {
        super(activity, resource, objects);

        mLayoutInflater = activity.getLayoutInflater();
        this.mResource = resource;
        mGentleAccentColor = App.getAppComponent(activity).getThemeManager().getGentleAccentColor();
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            convertView = mLayoutInflater.inflate(mResource, parent, false);

            viewHolder = new ViewHolder();
            viewHolder.textView = (TextView) convertView;
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        Forum forum = getItem(position);

        TextView textView = viewHolder.textView;
        textView.setText(forum.getName());
        // add today's posts count to each forum
        if (forum.getTodayPosts() != 0) {
            ViewUtil.concatWithTwoSpacesForRtlSupport(textView, String.valueOf(forum.getTodayPosts()),
                    mGentleAccentColor);
        }

        return convertView;
    }

    @Override
    public boolean hasStableIds() {
        return true;
    }

    @Override
    public long getItemId(int position) {
        return Long.parseLong(getItem(position).getId());
    }

    private static class ViewHolder {

        private TextView textView;
    }
}

@@ -353,28 +353,38 @@
 ext.
-data.api.model.Forum
+binding.TextViewBindingAdapter
 ;%0Aim
@@ -410,21 +410,28 @@
 ext.
-util.ViewUtil
+data.api.model.Forum
 ;%0A%0Ap
@@ -1464,347 +1464,80 @@
     
-Forum forum = getItem(position);%0A%0A        TextView textView = viewHolder.textView;%0A        textView.setText(forum.getName());%0A        // add today's posts count to each forum%0A        if (forum.getTodayPosts() != 0) %7B%0A            ViewUtil.concatWithTwoSpacesForRtlSupport(textView, String.valueOf(forum.getTodayPosts()),%0A                   
+TextViewBindingAdapter.showForum(viewHolder.textView, getItem(position),
  mGe
@@ -1553,26 +1553,16 @@
 tColor);
-%0A        %7D
 %0A%0A      

Simplify `SubForumArrayAdapter`