// Path: app/src/main/java/com/calgen/prodek/fadflicks/Adapter/ReviewAdapter.java
// public class ReviewAdapter extends ArrayAdapter<Review> {
//     private Context context;
//     private List<Review> reviewList;
//     private boolean glimpse;
// 
//     public ReviewAdapter(Context context, ArrayList<Review> reviewList, boolean glimpse) {
//         super(context, 0, reviewList);
//         this.context = context;
//         this.reviewList = reviewList;
//         this.glimpse = glimpse;
//     }
// 
//     @Override
//     public int getCount() {
//         int size = reviewList.size();
//         int reviewLimit = 3;
//         if (glimpse)
//             return (size > 2) ? reviewLimit : size;
//         else
//             return size;
//     }
// 
//     @NonNull
//     @Override
//     public View getView(int position, View convertView, @NonNull ViewGroup parent) {
// 
//         Review review = reviewList.get(position);
//         ViewHolder viewHolder;
// 
//         if (convertView == null) {
//             LayoutInflater layoutInflater = LayoutInflater.from(context);
//             convertView = layoutInflater.inflate(R.layout.list_item_review, parent, false);
//             viewHolder = new ViewHolder(convertView);
// 
//             convertView.setTag(viewHolder);
//         } else {
//             viewHolder = (ViewHolder) convertView.getTag();
//         }
// 
//         if (glimpse) {
//             viewHolder.reviewText.setMaxLines(3);
//             viewHolder.reviewText.setEllipsize(TextUtils.TruncateAt.END);
//             viewHolder.listItemLayout.setEnabled(false);
//             viewHolder.listItemLayout.setLongClickable(false);
//         }
// 
//         viewHolder.author.setText(review.getAuthor());
//         viewHolder.reviewText.setText(review.getContent());
//         viewHolder.author.setTag(position);
//         viewHolder.reviewText.setTag(position);
//         return convertView;
//     }
// 
//     class ViewHolder {
// 
//         //@formatter:off
//         @BindView(R.id.review_author) public TextView author;
//         @BindView(R.id.review_text) public TextView reviewText;
//         @BindView(R.id.list_item_layout) public LinearLayout listItemLayout;
//         //@formatter:on
// 
//         ViewHolder(View view) {
//             ButterKnife.bind(this, view);
//         }
//     }
// }


import android.content.Context;
import android.content.res.Resources;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.ListView;
import com.calgen.prodek.fadflicks.adapter.ReviewAdapter;
/*
 *    Copyright 2016 Gurupad Mamadapur
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package com.calgen.prodek.fadflicks.utils;



/**
 * Created by Gurupad Mamadapur on 10/30/2016.
 */

public class UI {
    /**
     * @param dp dp value
     * @return converted px value
     */
    public static int dpToPx(int dp) {
        DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics();
        return Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT));
    }

    /**
     * @param px dp value
     * @return converted dp value
     */

    public static int pxToDp(int px) {
        DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics();
        return Math.round(px / (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT));
    }

    /**
     * Change the height of the listView embedded in scrollview based on its children so that
     *
     * @param listView ListView whose height needs modification
     */
    public static void setListViewHeightBasedOnChildren(ListView listView) {
// Path: app/src/main/java/com/calgen/prodek/fadflicks/Adapter/ReviewAdapter.java
// public class ReviewAdapter extends ArrayAdapter<Review> {
//     private Context context;
//     private List<Review> reviewList;
//     private boolean glimpse;
// 
//     public ReviewAdapter(Context context, ArrayList<Review> reviewList, boolean glimpse) {
//         super(context, 0, reviewList);
//         this.context = context;
//         this.reviewList = reviewList;
//         this.glimpse = glimpse;
//     }
// 
//     @Override
//     public int getCount() {
//         int size = reviewList.size();
//         int reviewLimit = 3;
//         if (glimpse)
//             return (size > 2) ? reviewLimit : size;
//         else
//             return size;
//     }
// 
//     @NonNull
//     @Override
//     public View getView(int position, View convertView, @NonNull ViewGroup parent) {
// 
//         Review review = reviewList.get(position);
//         ViewHolder viewHolder;
// 
//         if (convertView == null) {
//             LayoutInflater layoutInflater = LayoutInflater.from(context);
//             convertView = layoutInflater.inflate(R.layout.list_item_review, parent, false);
//             viewHolder = new ViewHolder(convertView);
// 
//             convertView.setTag(viewHolder);
//         } else {
//             viewHolder = (ViewHolder) convertView.getTag();
//         }
// 
//         if (glimpse) {
//             viewHolder.reviewText.setMaxLines(3);
//             viewHolder.reviewText.setEllipsize(TextUtils.TruncateAt.END);
//             viewHolder.listItemLayout.setEnabled(false);
//             viewHolder.listItemLayout.setLongClickable(false);
//         }
// 
//         viewHolder.author.setText(review.getAuthor());
//         viewHolder.reviewText.setText(review.getContent());
//         viewHolder.author.setTag(position);
//         viewHolder.reviewText.setTag(position);
//         return convertView;
//     }
// 
//     class ViewHolder {
// 
//         //@formatter:off
//         @BindView(R.id.review_author) public TextView author;
//         @BindView(R.id.review_text) public TextView reviewText;
//         @BindView(R.id.list_item_layout) public LinearLayout listItemLayout;
//         //@formatter:on
// 
//         ViewHolder(View view) {
//             ButterKnife.bind(this, view);
//         }
//     }
// }


// Path: app/src/main/java/com/calgen/prodek/fadflicks/utils/UI.java
import android.content.Context;
import android.content.res.Resources;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.ListView;
import com.calgen.prodek.fadflicks.adapter.ReviewAdapter;

/*
 *    Copyright 2016 Gurupad Mamadapur
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package com.calgen.prodek.fadflicks.utils;



/**
 * Created by Gurupad Mamadapur on 10/30/2016.
 */

public class UI {
    /**
     * @param dp dp value
     * @return converted px value
     */
    public static int dpToPx(int dp) {
        DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics();
        return Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT));
    }

    /**
     * @param px dp value
     * @return converted dp value
     */

    public static int pxToDp(int px) {
        DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics();
        return Math.round(px / (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT));
    }

    /**
     * Change the height of the listView embedded in scrollview based on its children so that
     *
     * @param listView ListView whose height needs modification
     */
    public static void setListViewHeightBasedOnChildren(ListView listView) {
        ReviewAdapter listAdapter = (ReviewAdapter) listView.getAdapter();