package io.github.droidkaigi.confsched2017.view.customview;

import android.content.Context;
import android.content.res.TypedArray;
import android.databinding.DataBindingUtil;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.RelativeLayout;

import io.github.droidkaigi.confsched2017.R;
import io.github.droidkaigi.confsched2017.databinding.ViewInfoRowBinding;
import io.github.droidkaigi.confsched2017.view.helper.DataBindingHelper;

public class InfoRowView extends RelativeLayout {

    private static final String TAG = InfoRowView.class.getSimpleName();

    private ViewInfoRowBinding binding;

    public InfoRowView(Context context) {
        this(context, null);
    }

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

    public InfoRowView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        binding = DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.view_info_row, this, true);

        if (!isInEditMode()) {
            TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.InfoRow);

            String title = a.getString(R.styleable.InfoRow_infoTitle);
            String description = a.getString(R.styleable.InfoRow_infoDescription);

            binding.txtInfoTitle.setText(title);
            binding.txtInfoDescription.setText(description);
            DataBindingHelper.setTextLinkify(binding.txtInfoDescription, true);

            a.recycle();
        }
    }

    public void setTitle(String title) {
        binding.txtInfoTitle.setText(title);
    }

    public void setDescription(String description) {
        binding.txtInfoDescription.setText(description);
    }

}

@@ -942,16 +942,137 @@
 eAttr);%0A
+        if (isInEditMode()) %7B%0A            inflate(context, R.layout.view_info_row, this);%0A            return;%0A        %7D%0A%0A
         
@@ -1176,44 +1176,8 @@
 e);%0A
-%0A        if (!isInEditMode()) %7B%0A    
     
@@ -1260,28 +1260,24 @@
 );%0A%0A        
-    
 String title
@@ -1327,28 +1327,24 @@
 e);%0A        
- 
-   
 String descr
@@ -1403,36 +1403,32 @@
 tion);%0A%0A        
-   
- 
 binding.txtInfoT
@@ -1444,28 +1444,24 @@
 ext(title);%0A
-    
         bind
@@ -1513,20 +1513,16 @@
         
- 
-   
 DataBind
@@ -1590,20 +1590,16 @@
         
-   
- 
 a.recycl
@@ -1603,26 +1603,16 @@
 ycle();%0A
-        %7D%0A
     %7D%0A%0A 

Fix layout preview of InfoRowView on Android Studio