package com.xamoom.android.xamoomcontentblocks.ViewHolders;

import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.xamoom.android.xamoomsdk.R;
import com.xamoom.android.xamoomsdk.Resource.ContentBlock;
import com.xamoom.android.xamoomsdk.Resource.Style;

/**
 * Displays the text ContentBlock.
 */
public class ContentBlock0ViewHolder extends RecyclerView.ViewHolder {
  private static final String FALLBACK_LINK_COLOR = "00F";

  private TextView mTitleTextView;
  private WebView mWebView;
  private Style mStyle;

  public ContentBlock0ViewHolder(View itemView) {
    super(itemView);
    mTitleTextView = (TextView) itemView.findViewById(R.id.titleTextView);
    mWebView = (WebView) itemView.findViewById(R.id.webView);
    mWebView.setBackgroundColor(Color.TRANSPARENT);

    if (Build.VERSION.SDK_INT >= 19) {
      mWebView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
    }
    else {
      mWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }

    //override to open links in Webbrowser
    mWebView.setWebViewClient(new WebViewClient() {
      public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.getContext().startActivity(
            new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
        return true;
      }
    });
  }

  public void setupContentBlock(ContentBlock contentBlock){
    mTitleTextView.setVisibility(View.VISIBLE);
    mWebView.setVisibility(View.VISIBLE);

    if(contentBlock.getTitle() != null) {
      mTitleTextView.setText(contentBlock.getTitle());
    } else {
      mTitleTextView.setVisibility(View.GONE);
      LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mWebView.getLayoutParams();
      params.setMargins(0,0,0,0);
      mWebView.setLayoutParams(params);
    }

    String linkColor = FALLBACK_LINK_COLOR;
    if (mStyle != null && mStyle.getHighlightFontColor() != null) {
      linkColor = mStyle.getHighlightFontColor();
    }

    if((contentBlock.getText() != null) && !(contentBlock.getText().equalsIgnoreCase("<p><br></p>"))) {
      String style = "<style type=\"text/css\">html, body {margin: 0; padding: 0dp;} a {color: #"+linkColor+"}</style>";
      String htmlAsString = String.format("%s%s", style, contentBlock.getText());
      mWebView.loadDataWithBaseURL(null, htmlAsString, "text/html", "UTF-8", null);
    } else {
      mWebView.setVisibility(View.GONE);
    }
  }

  public void setStyle(Style style) {
    mStyle = style;
  }
}

@@ -1728,32 +1728,81 @@
 tTitle() != null
+ && !contentBlock.getTitle().equalsIgnoreCase(%22%22)
 ) %7B%0A      mTitle
@@ -2533,16 +2533,26 @@
  style, 
+cleanHtml(
 contentB
@@ -2566,16 +2566,17 @@
 tText())
+)
 ;%0A      
@@ -2703,24 +2703,24 @@
 View.GONE);%0A
-
     %7D%0A  %7D%0A%0A 
@@ -2714,24 +2714,156 @@
 %0A    %7D%0A  %7D%0A%0A
+  private String cleanHtml(String text) %7B%0A    text = text.replace(%22%3Cbr%3E%3C/p%3E%22, %22%3C/p%3E%22);%0A    return text.replace(%22%3Cp%3E%3C/p%3E%22, %22%22);%0A  %7D%0A%0A
   public voi

Check for "" string and null