// Path: app/src/main/java/me/yifeiyuan/climb/data/entity/GankEntity.java
// public class GankEntity {
//     public String _id;
//     public String createdAt;
//     public String desc;
//     public String publishedAt;
//     public String source;
//     public String type;
//     public String url;
//     public boolean used;
//     public String who;
// }
// 
// Path: app/src/main/java/me/yifeiyuan/climb/tools/Navigator.java
// public class Navigator {
// 
// 
//     public static void go2PhotoActivity(Context cxt, String url){
//         Intent intent = new Intent(Intent.ACTION_VIEW);
//         intent.setData(Uri.parse("climb://photo/url=" + url));
//         cxt.startActivity(intent);
//     }
// }
// 
// Path: app/src/main/java/me/yifeiyuan/climb/ui/view/RatioImageView.java
// public class RatioImageView extends ImageView {
// 
//     private float mRatio = 1.0f;
// 
//     public RatioImageView(Context context) {
//         this(context,null,0);
//     }
// 
//     public RatioImageView(Context context, AttributeSet attrs) {
//         this(context, attrs,0);
//     }
// 
//     public RatioImageView(Context context, AttributeSet attrs, int defStyleAttr) {
//         super(context, attrs, defStyleAttr);
//         TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.RatioImageView);
//         if (null != ta) {
//             mRatio = ta.getFloat(R.styleable.RatioImageView_ratio, 1.0f);
//         }
//         ta.recycle();
//     }
// 
//     public float getRatio() {
//         return mRatio;
//     }
// 
//     public void setRatio(float ratio) {
//         mRatio = ratio;
//     }
// 
//     @Override
//     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
//         super.onMeasure(widthMeasureSpec, heightMeasureSpec);
//         int width = getMeasuredWidth();
//         int height = (int) (width*mRatio);
//         setMeasuredDimension(width, height);
//     }
// }


import me.yifeiyuan.climb.tools.Navigator;
import me.yifeiyuan.climb.ui.view.RatioImageView;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.bumptech.glide.Glide;
import java.util.List;
import butterknife.Bind;
import butterknife.ButterKnife;
import me.yifeiyuan.climb.R;
import me.yifeiyuan.climb.data.entity.GankEntity;
/*
 * Copyright (C) 2016, 程序亦非猿
 *
 * 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 me.yifeiyuan.climb.module.gank;





/**
 * Created by 程序亦非猿 on 16/7/28.
 */
public class GankMeiziAdapter extends RecyclerView.Adapter<GankMeiziAdapter.GankViewHolder>{

    private List<GankEntity> mDatas;
    private Context mContext;

    public GankMeiziAdapter(Context context, List<GankEntity> mDatas) {
        this.mContext = context;
        this.mDatas = mDatas;
    }

    @Override
    public GankViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View view = LayoutInflater.from(mContext).inflate(R.layout.gank_item_meizi, parent, false);

        return new GankViewHolder(view);
    }

    @Override
    public void onBindViewHolder(final GankViewHolder holder, int position) {

        final GankEntity entity = mDatas.get(position);

        Glide.with(mContext)
                .load(entity.url)
//                .placeholder(R.mipmap.ic_launcher)
//                .error(R.mipmap.ic_launcher)
//                .override(300,400)
//                .crossFade(R.anim.fade_in)
                .centerCrop()
                .into(holder.ivMeizi);

        holder.itemView.setOnClickListener(v -> {
// Path: app/src/main/java/me/yifeiyuan/climb/data/entity/GankEntity.java
// public class GankEntity {
//     public String _id;
//     public String createdAt;
//     public String desc;
//     public String publishedAt;
//     public String source;
//     public String type;
//     public String url;
//     public boolean used;
//     public String who;
// }
// 
// Path: app/src/main/java/me/yifeiyuan/climb/tools/Navigator.java
// public class Navigator {
// 
// 
//     public static void go2PhotoActivity(Context cxt, String url){
//         Intent intent = new Intent(Intent.ACTION_VIEW);
//         intent.setData(Uri.parse("climb://photo/url=" + url));
//         cxt.startActivity(intent);
//     }
// }
// 
// Path: app/src/main/java/me/yifeiyuan/climb/ui/view/RatioImageView.java
// public class RatioImageView extends ImageView {
// 
//     private float mRatio = 1.0f;
// 
//     public RatioImageView(Context context) {
//         this(context,null,0);
//     }
// 
//     public RatioImageView(Context context, AttributeSet attrs) {
//         this(context, attrs,0);
//     }
// 
//     public RatioImageView(Context context, AttributeSet attrs, int defStyleAttr) {
//         super(context, attrs, defStyleAttr);
//         TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.RatioImageView);
//         if (null != ta) {
//             mRatio = ta.getFloat(R.styleable.RatioImageView_ratio, 1.0f);
//         }
//         ta.recycle();
//     }
// 
//     public float getRatio() {
//         return mRatio;
//     }
// 
//     public void setRatio(float ratio) {
//         mRatio = ratio;
//     }
// 
//     @Override
//     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
//         super.onMeasure(widthMeasureSpec, heightMeasureSpec);
//         int width = getMeasuredWidth();
//         int height = (int) (width*mRatio);
//         setMeasuredDimension(width, height);
//     }
// }


// Path: app/src/main/java/me/yifeiyuan/climb/module/gank/GankMeiziAdapter.java
import me.yifeiyuan.climb.tools.Navigator;
import me.yifeiyuan.climb.ui.view.RatioImageView;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.bumptech.glide.Glide;
import java.util.List;
import butterknife.Bind;
import butterknife.ButterKnife;
import me.yifeiyuan.climb.R;
import me.yifeiyuan.climb.data.entity.GankEntity;

/*
 * Copyright (C) 2016, 程序亦非猿
 *
 * 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 me.yifeiyuan.climb.module.gank;





/**
 * Created by 程序亦非猿 on 16/7/28.
 */
public class GankMeiziAdapter extends RecyclerView.Adapter<GankMeiziAdapter.GankViewHolder>{

    private List<GankEntity> mDatas;
    private Context mContext;

    public GankMeiziAdapter(Context context, List<GankEntity> mDatas) {
        this.mContext = context;
        this.mDatas = mDatas;
    }

    @Override
    public GankViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View view = LayoutInflater.from(mContext).inflate(R.layout.gank_item_meizi, parent, false);

        return new GankViewHolder(view);
    }

    @Override
    public void onBindViewHolder(final GankViewHolder holder, int position) {

        final GankEntity entity = mDatas.get(position);

        Glide.with(mContext)
                .load(entity.url)
//                .placeholder(R.mipmap.ic_launcher)
//                .error(R.mipmap.ic_launcher)
//                .override(300,400)
//                .crossFade(R.anim.fade_in)
                .centerCrop()
                .into(holder.ivMeizi);

        holder.itemView.setOnClickListener(v -> {
            Navigator.go2PhotoActivity(mContext,entity.url);