// Path: app/src/main/java/discovery/contentful/ui/FieldViewHolder.java
// public class FieldViewHolder {
//   public @Bind(R.id.tv_title) CFTextView tvTitle;
//   public @Bind(R.id.tv_value) CFTextView tvValue;
//   public @Bind(R.id.iv_arrow) ImageView ivArrow;
// 
//   public FieldViewHolder(View v) {
//     ButterKnife.bind(this, v);
//   }
// }
// 
// Path: app/src/main/java/discovery/contentful/utils/ViewHelper.java
// public class ViewHelper {
//   private ViewHelper() {
//   }
// 
//   /**
//    * Register a callback to be invoked when the global layout state or the visibility of views
//    * within the view tree changes.
//    *
//    * @param v The View.
//    * @param listener The callback to add.
//    * @see #removeGlobalLayoutListener(View, ViewTreeObserver.OnGlobalLayoutListener).
//    */
//   public static void addGlobalLayoutListener(View v,
//       ViewTreeObserver.OnGlobalLayoutListener listener) {
//     ViewTreeObserver observer = v.getViewTreeObserver();
// 
//     if (observer == null || !observer.isAlive()) {
//       return;
//     }
// 
//     observer.addOnGlobalLayoutListener(listener);
//   }
// 
//   /**
//    * Remove a previously installed global layout callback.
//    *
//    * @param v The View.
//    * @param listener The callback to remove.
//    * @see #addGlobalLayoutListener(View, ViewTreeObserver.OnGlobalLayoutListener).
//    */
//   @SuppressWarnings("deprecation")
//   @SuppressLint("NewApi")
//   public static void removeGlobalLayoutListener(View v,
//       ViewTreeObserver.OnGlobalLayoutListener listener) {
//     ViewTreeObserver observer = v.getViewTreeObserver();
//     if (observer == null || !observer.isAlive()) {
//       return;
//     }
// 
//     if (Build.VERSION.SDK_INT < 16) {
//       observer.removeGlobalOnLayoutListener(listener);
//     } else {
//       observer.removeOnGlobalLayoutListener(listener);
//     }
//   }
// 
//   public static void setVisibility(View v, boolean show) {
//     if (show) {
//       v.setVisibility(View.VISIBLE);
//     } else {
//       v.setVisibility(View.GONE);
//     }
//   }
// }


import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import discovery.contentful.R;
import discovery.contentful.ui.FieldViewHolder;
import discovery.contentful.utils.ViewHelper;
import com.contentful.java.cda.CDAContentType;
import com.contentful.java.cda.CDAEntry;
import com.contentful.java.cda.CDAField;
import java.util.List;
import java.util.Locale;
import java.util.Map;
  @Override public long getItemId(int position) {
    return 0;
  }

  @Override public View getView(int position, View convertView, ViewGroup parent) {
    FieldViewHolder vh;

    if (convertView == null) {
      convertView = View.inflate(context, R.layout.view_field, null);
      convertView.setTag(vh = new FieldViewHolder(convertView));
    } else {
      vh = (FieldViewHolder) convertView.getTag();
    }

    CDAField item = getItem(position);
    Object value = entry.getField(item.id());
    String fieldType = item.type();

    // Title
    vh.tvTitle.setText(item.name());

    // Value
    if (value != null && isDisplayableFieldType(fieldType)) {
      vh.tvValue.setText(normalizeDisplayValue(fieldType, value));
      vh.tvValue.setVisibility(View.VISIBLE);
    } else {
      vh.tvValue.setVisibility(View.GONE);
    }

    // Arrow
// Path: app/src/main/java/discovery/contentful/ui/FieldViewHolder.java
// public class FieldViewHolder {
//   public @Bind(R.id.tv_title) CFTextView tvTitle;
//   public @Bind(R.id.tv_value) CFTextView tvValue;
//   public @Bind(R.id.iv_arrow) ImageView ivArrow;
// 
//   public FieldViewHolder(View v) {
//     ButterKnife.bind(this, v);
//   }
// }
// 
// Path: app/src/main/java/discovery/contentful/utils/ViewHelper.java
// public class ViewHelper {
//   private ViewHelper() {
//   }
// 
//   /**
//    * Register a callback to be invoked when the global layout state or the visibility of views
//    * within the view tree changes.
//    *
//    * @param v The View.
//    * @param listener The callback to add.
//    * @see #removeGlobalLayoutListener(View, ViewTreeObserver.OnGlobalLayoutListener).
//    */
//   public static void addGlobalLayoutListener(View v,
//       ViewTreeObserver.OnGlobalLayoutListener listener) {
//     ViewTreeObserver observer = v.getViewTreeObserver();
// 
//     if (observer == null || !observer.isAlive()) {
//       return;
//     }
// 
//     observer.addOnGlobalLayoutListener(listener);
//   }
// 
//   /**
//    * Remove a previously installed global layout callback.
//    *
//    * @param v The View.
//    * @param listener The callback to remove.
//    * @see #addGlobalLayoutListener(View, ViewTreeObserver.OnGlobalLayoutListener).
//    */
//   @SuppressWarnings("deprecation")
//   @SuppressLint("NewApi")
//   public static void removeGlobalLayoutListener(View v,
//       ViewTreeObserver.OnGlobalLayoutListener listener) {
//     ViewTreeObserver observer = v.getViewTreeObserver();
//     if (observer == null || !observer.isAlive()) {
//       return;
//     }
// 
//     if (Build.VERSION.SDK_INT < 16) {
//       observer.removeGlobalOnLayoutListener(listener);
//     } else {
//       observer.removeOnGlobalLayoutListener(listener);
//     }
//   }
// 
//   public static void setVisibility(View v, boolean show) {
//     if (show) {
//       v.setVisibility(View.VISIBLE);
//     } else {
//       v.setVisibility(View.GONE);
//     }
//   }
// }


// Path: app/src/main/java/discovery/contentful/preview/EntryListAdapter.java
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import discovery.contentful.R;
import discovery.contentful.ui.FieldViewHolder;
import discovery.contentful.utils.ViewHelper;
import com.contentful.java.cda.CDAContentType;
import com.contentful.java.cda.CDAEntry;
import com.contentful.java.cda.CDAField;
import java.util.List;
import java.util.Locale;
import java.util.Map;

  @Override public long getItemId(int position) {
    return 0;
  }

  @Override public View getView(int position, View convertView, ViewGroup parent) {
    FieldViewHolder vh;

    if (convertView == null) {
      convertView = View.inflate(context, R.layout.view_field, null);
      convertView.setTag(vh = new FieldViewHolder(convertView));
    } else {
      vh = (FieldViewHolder) convertView.getTag();
    }

    CDAField item = getItem(position);
    Object value = entry.getField(item.id());
    String fieldType = item.type();

    // Title
    vh.tvTitle.setText(item.name());

    // Value
    if (value != null && isDisplayableFieldType(fieldType)) {
      vh.tvValue.setText(normalizeDisplayValue(fieldType, value));
      vh.tvValue.setVisibility(View.VISIBLE);
    } else {
      vh.tvValue.setVisibility(View.GONE);
    }

    // Arrow
    ViewHelper.setVisibility(vh.ivArrow, value != null && isClickableFieldType(fieldType));