// Path: app/src/main/java/discovery/contentful/CFApp.java
// public class CFApp extends Application {
//   public static CFApp sInstance;
// 
//   @Override
//   public void onCreate() {
//     super.onCreate();
// 
//     sInstance = this;
//   }
// 
//   public static CFApp getInstance() {
//     return sInstance;
//   }
// }
// 
// Path: app/src/main/java/discovery/contentful/activities/TextPreviewActivity.java
// public class TextPreviewActivity extends CFFragmentActivity
//     implements LoaderManager.LoaderCallbacks<String> {
// 
//   public static final String MIME_TYPE_TEXT_HTML = "text/html";
// 
//   // Views
//   @Bind(R.id.web_view) WebView webView;
// 
//   @Override protected void onCreate(Bundle savedInstanceState) {
//     super.onCreate(savedInstanceState);
// 
//     setContentView(R.layout.activity_text_preview);
// 
//     // Inject views
//     ButterKnife.bind(this);
// 
//     // Setup WebView
//     if (!getIntent().getBooleanExtra(IntentConsts.EXTRA_ALLOW_LINKS, false)) {
//       webView.setWebViewClient(new WebViewClient() {
//         @Override
//         public boolean shouldOverrideUrlLoading(WebView view, String url) {
//           return true;
//         }
//       });
//     }
// 
//     // Title
//     Utils.setTitleFromIntent(this);
// 
//     // Init Loader
//     getSupportLoaderManager().initLoader(Utils.getLoaderId(this), null, this);
//   }
// 
//   @Override protected void onDestroy() {
//     webView.loadUrl("about:blank");
// 
//     super.onDestroy();
//   }
// 
//   @Override public Loader<String> onCreateLoader(int id, Bundle args) {
//     return new TextProcessorLoader(getIntent().getStringExtra(IntentConsts.EXTRA_TEXT));
//   }
// 
//   @Override public void onLoadFinished(Loader<String> loader, String data) {
//     webView.loadDataWithBaseURL(getString(R.string.url_contentful), data, MIME_TYPE_TEXT_HTML,
//         CharEncoding.UTF_8, null);
// 
//     webView.setBackgroundColor(0);
//   }
// 
//   @Override public void onLoaderReset(Loader<String> loader) {
//   }
// }
// 
// Path: app/src/main/java/discovery/contentful/ui/DisplayItem.java
// public class DisplayItem {
//   public String key;
//   public String displayValue;
//   public String fieldType;
//   public CDAResource resource;
//   public String imageURI;
//   public LatLng location;
// 
//   // Array
//   public List<Object> array;
//   public String arrayItemType;
//   public String arrayLinkType;
// }


import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import discovery.contentful.CFApp;
import discovery.contentful.R;
import discovery.contentful.activities.TextPreviewActivity;
import discovery.contentful.ui.DisplayItem;
import org.apache.commons.lang3.CharEncoding;
package discovery.contentful.preview;


public class RTFViewFactory extends PreviewViewFactory<RTFViewHolder> {
  @Override protected int getLayoutResId() {
    return R.layout.view_preview_rtf;
  }

  @Override protected int getItemViewType() {
    return EntryPreviewAdapter.VIEW_TYPE_RTF;
  }

  @Override protected RTFViewHolder createViewHolder(Object factoryKey, View v) {
    RTFViewHolder vh = new RTFViewHolder(factoryKey, v);

    vh.webView.setWebViewClient(new WebViewClient() {
      @Override
      public boolean shouldOverrideUrlLoading(WebView view, String url) {
        return true;
      }
    });

    return vh;
  }

  @Override protected void setViewData(RTFViewHolder viewHolder, DisplayItem displayItem) {
    viewHolder.webView.loadDataWithBaseURL(CFApp.getInstance().getString(R.string.url_contentful),
// Path: app/src/main/java/discovery/contentful/CFApp.java
// public class CFApp extends Application {
//   public static CFApp sInstance;
// 
//   @Override
//   public void onCreate() {
//     super.onCreate();
// 
//     sInstance = this;
//   }
// 
//   public static CFApp getInstance() {
//     return sInstance;
//   }
// }
// 
// Path: app/src/main/java/discovery/contentful/activities/TextPreviewActivity.java
// public class TextPreviewActivity extends CFFragmentActivity
//     implements LoaderManager.LoaderCallbacks<String> {
// 
//   public static final String MIME_TYPE_TEXT_HTML = "text/html";
// 
//   // Views
//   @Bind(R.id.web_view) WebView webView;
// 
//   @Override protected void onCreate(Bundle savedInstanceState) {
//     super.onCreate(savedInstanceState);
// 
//     setContentView(R.layout.activity_text_preview);
// 
//     // Inject views
//     ButterKnife.bind(this);
// 
//     // Setup WebView
//     if (!getIntent().getBooleanExtra(IntentConsts.EXTRA_ALLOW_LINKS, false)) {
//       webView.setWebViewClient(new WebViewClient() {
//         @Override
//         public boolean shouldOverrideUrlLoading(WebView view, String url) {
//           return true;
//         }
//       });
//     }
// 
//     // Title
//     Utils.setTitleFromIntent(this);
// 
//     // Init Loader
//     getSupportLoaderManager().initLoader(Utils.getLoaderId(this), null, this);
//   }
// 
//   @Override protected void onDestroy() {
//     webView.loadUrl("about:blank");
// 
//     super.onDestroy();
//   }
// 
//   @Override public Loader<String> onCreateLoader(int id, Bundle args) {
//     return new TextProcessorLoader(getIntent().getStringExtra(IntentConsts.EXTRA_TEXT));
//   }
// 
//   @Override public void onLoadFinished(Loader<String> loader, String data) {
//     webView.loadDataWithBaseURL(getString(R.string.url_contentful), data, MIME_TYPE_TEXT_HTML,
//         CharEncoding.UTF_8, null);
// 
//     webView.setBackgroundColor(0);
//   }
// 
//   @Override public void onLoaderReset(Loader<String> loader) {
//   }
// }
// 
// Path: app/src/main/java/discovery/contentful/ui/DisplayItem.java
// public class DisplayItem {
//   public String key;
//   public String displayValue;
//   public String fieldType;
//   public CDAResource resource;
//   public String imageURI;
//   public LatLng location;
// 
//   // Array
//   public List<Object> array;
//   public String arrayItemType;
//   public String arrayLinkType;
// }


// Path: app/src/main/java/discovery/contentful/preview/RTFViewFactory.java
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import discovery.contentful.CFApp;
import discovery.contentful.R;
import discovery.contentful.activities.TextPreviewActivity;
import discovery.contentful.ui.DisplayItem;
import org.apache.commons.lang3.CharEncoding;

package discovery.contentful.preview;


public class RTFViewFactory extends PreviewViewFactory<RTFViewHolder> {
  @Override protected int getLayoutResId() {
    return R.layout.view_preview_rtf;
  }

  @Override protected int getItemViewType() {
    return EntryPreviewAdapter.VIEW_TYPE_RTF;
  }

  @Override protected RTFViewHolder createViewHolder(Object factoryKey, View v) {
    RTFViewHolder vh = new RTFViewHolder(factoryKey, v);

    vh.webView.setWebViewClient(new WebViewClient() {
      @Override
      public boolean shouldOverrideUrlLoading(WebView view, String url) {
        return true;
      }
    });

    return vh;
  }

  @Override protected void setViewData(RTFViewHolder viewHolder, DisplayItem displayItem) {
    viewHolder.webView.loadDataWithBaseURL(CFApp.getInstance().getString(R.string.url_contentful),
        displayItem.displayValue, TextPreviewActivity.MIME_TYPE_TEXT_HTML, CharEncoding.UTF_8,