// Path: AndroidClient/app/src/main/java/com/hufeiya/SignIn/model/Avatar.java
// public enum Avatar {
// 
//     ONE(R.drawable.avatar_1),
//     TWO(R.drawable.avatar_2),
//     THREE(R.drawable.avatar_3),
//     FOUR(R.drawable.avatar_4),
//     FIVE(R.drawable.avatar_5),
//     SIX(R.drawable.avatar_6),
//     SEVEN(R.drawable.avatar_7),
//     EIGHT(R.drawable.avatar_8),
//     NINE(R.drawable.avatar_9),
//     TEN(R.drawable.avatar_10),
//     ELEVEN(R.drawable.avatar_11),
//     TWELVE(R.drawable.avatar_12),
//     THIRTEEN(R.drawable.avatar_13),
//     FOURTEEN(R.drawable.avatar_14),
//     FIFTEEN(R.drawable.avatar_15),
//     SIXTEEN(R.drawable.avatar_16);
// 
//     private static final String TAG = "Avatar";
// 
//     private final int mResId;
// 
//     Avatar(@DrawableRes final int resId) {
//         mResId = resId;
//     }
// 
//     @DrawableRes
//     public int getDrawableId() {
//         return mResId;
//     }
// 
//     public String getNameForAccessibility() {
//         return TAG + " " + ordinal() + 1;
//     }
// }
// 
// Path: AndroidClient/app/src/main/java/com/hufeiya/SignIn/widget/AvatarView.java
// public class AvatarView extends ImageView implements Checkable {
// 
//     private boolean mChecked;
// 
//     public AvatarView(Context context) {
//         this(context, null);
//     }
// 
//     public AvatarView(Context context, AttributeSet attrs) {
//         this(context, attrs, 0);
//     }
// 
//     public AvatarView(Context context, AttributeSet attrs, int defStyle) {
//         super(context, attrs, defStyle);
//     }
// 
//     @Override
//     public boolean isChecked() {
//         return mChecked;
//     }
// 
//     @Override
//     public void setChecked(boolean b) {
//         mChecked = b;
//         invalidate();
//     }
// 
//     @Override
//     public void toggle() {
//         setChecked(!mChecked);
//     }
// 
//     /**
//      * Set the image for this avatar. Will be used to create a round version of this avatar.
//      *
//      * @param resId The image's resource id.
//      */
//     @SuppressLint("NewApi")
//     public void setAvatar(@DrawableRes int resId) {
//         if (ApiLevelHelper.isAtLeast(Build.VERSION_CODES.LOLLIPOP)) {
//             setClipToOutline(true);
//             setImageResource(resId);
//         } else {
//             setAvatarPreLollipop(resId);
//         }
//     }
// 
//     private void setAvatarPreLollipop(@DrawableRes int resId) {
//         Drawable drawable = ResourcesCompat.getDrawable(getResources(), resId,
//                 getContext().getTheme());
//         BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
//         @SuppressWarnings("ConstantConditions")
//         RoundedBitmapDrawable roundedDrawable = RoundedBitmapDrawableFactory.create(getResources(),
//                 bitmapDrawable.getBitmap());
//         roundedDrawable.setCircular(true);
//         setImageDrawable(roundedDrawable);
//     }
// 
//     @Override
//     protected void onDraw(@NonNull Canvas canvas) {
//         super.onDraw(canvas);
//         if (mChecked) {
//             Drawable border = ContextCompat.getDrawable(getContext(), R.drawable.selector_avatar);
//             border.setBounds(0, 0, getWidth(), getHeight());
//             border.draw(canvas);
//         }
//     }
// 
//     @Override
//     @SuppressLint("NewApi")
//     protected void onSizeChanged(int w, int h, int oldw, int oldh) {
//         super.onSizeChanged(w, h, oldw, oldh);
//         if (ApiLevelHelper.isLowerThan(Build.VERSION_CODES.LOLLIPOP)) {
//             return;
//         }
//         if (w > 0 && h > 0) {
//             setOutlineProvider(new RoundOutlineProvider(Math.min(w, h)));
//         }
//     }
// }


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.hufeiya.SignIn.R;
import com.hufeiya.SignIn.model.Avatar;
import com.hufeiya.SignIn.widget.AvatarView;
/*
 * Copyright 2015 Google Inc.
 *
 * 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.hufeiya.SignIn.adapter;



/**
 * Adapter to display {@link Avatar} icons.
 */
public class AvatarAdapter extends BaseAdapter {

    private static final Avatar[] mAvatars = Avatar.values();

    private final LayoutInflater mLayoutInflater;

    public AvatarAdapter(Context context) {
        mLayoutInflater = LayoutInflater.from(context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (null == convertView) {
            convertView = mLayoutInflater.inflate(R.layout.item_avatar, parent, false);
        }
// Path: AndroidClient/app/src/main/java/com/hufeiya/SignIn/model/Avatar.java
// public enum Avatar {
// 
//     ONE(R.drawable.avatar_1),
//     TWO(R.drawable.avatar_2),
//     THREE(R.drawable.avatar_3),
//     FOUR(R.drawable.avatar_4),
//     FIVE(R.drawable.avatar_5),
//     SIX(R.drawable.avatar_6),
//     SEVEN(R.drawable.avatar_7),
//     EIGHT(R.drawable.avatar_8),
//     NINE(R.drawable.avatar_9),
//     TEN(R.drawable.avatar_10),
//     ELEVEN(R.drawable.avatar_11),
//     TWELVE(R.drawable.avatar_12),
//     THIRTEEN(R.drawable.avatar_13),
//     FOURTEEN(R.drawable.avatar_14),
//     FIFTEEN(R.drawable.avatar_15),
//     SIXTEEN(R.drawable.avatar_16);
// 
//     private static final String TAG = "Avatar";
// 
//     private final int mResId;
// 
//     Avatar(@DrawableRes final int resId) {
//         mResId = resId;
//     }
// 
//     @DrawableRes
//     public int getDrawableId() {
//         return mResId;
//     }
// 
//     public String getNameForAccessibility() {
//         return TAG + " " + ordinal() + 1;
//     }
// }
// 
// Path: AndroidClient/app/src/main/java/com/hufeiya/SignIn/widget/AvatarView.java
// public class AvatarView extends ImageView implements Checkable {
// 
//     private boolean mChecked;
// 
//     public AvatarView(Context context) {
//         this(context, null);
//     }
// 
//     public AvatarView(Context context, AttributeSet attrs) {
//         this(context, attrs, 0);
//     }
// 
//     public AvatarView(Context context, AttributeSet attrs, int defStyle) {
//         super(context, attrs, defStyle);
//     }
// 
//     @Override
//     public boolean isChecked() {
//         return mChecked;
//     }
// 
//     @Override
//     public void setChecked(boolean b) {
//         mChecked = b;
//         invalidate();
//     }
// 
//     @Override
//     public void toggle() {
//         setChecked(!mChecked);
//     }
// 
//     /**
//      * Set the image for this avatar. Will be used to create a round version of this avatar.
//      *
//      * @param resId The image's resource id.
//      */
//     @SuppressLint("NewApi")
//     public void setAvatar(@DrawableRes int resId) {
//         if (ApiLevelHelper.isAtLeast(Build.VERSION_CODES.LOLLIPOP)) {
//             setClipToOutline(true);
//             setImageResource(resId);
//         } else {
//             setAvatarPreLollipop(resId);
//         }
//     }
// 
//     private void setAvatarPreLollipop(@DrawableRes int resId) {
//         Drawable drawable = ResourcesCompat.getDrawable(getResources(), resId,
//                 getContext().getTheme());
//         BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
//         @SuppressWarnings("ConstantConditions")
//         RoundedBitmapDrawable roundedDrawable = RoundedBitmapDrawableFactory.create(getResources(),
//                 bitmapDrawable.getBitmap());
//         roundedDrawable.setCircular(true);
//         setImageDrawable(roundedDrawable);
//     }
// 
//     @Override
//     protected void onDraw(@NonNull Canvas canvas) {
//         super.onDraw(canvas);
//         if (mChecked) {
//             Drawable border = ContextCompat.getDrawable(getContext(), R.drawable.selector_avatar);
//             border.setBounds(0, 0, getWidth(), getHeight());
//             border.draw(canvas);
//         }
//     }
// 
//     @Override
//     @SuppressLint("NewApi")
//     protected void onSizeChanged(int w, int h, int oldw, int oldh) {
//         super.onSizeChanged(w, h, oldw, oldh);
//         if (ApiLevelHelper.isLowerThan(Build.VERSION_CODES.LOLLIPOP)) {
//             return;
//         }
//         if (w > 0 && h > 0) {
//             setOutlineProvider(new RoundOutlineProvider(Math.min(w, h)));
//         }
//     }
// }


// Path: AndroidClient/app/src/main/java/com/hufeiya/SignIn/adapter/AvatarAdapter.java
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.hufeiya.SignIn.R;
import com.hufeiya.SignIn.model.Avatar;
import com.hufeiya.SignIn.widget.AvatarView;

/*
 * Copyright 2015 Google Inc.
 *
 * 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.hufeiya.SignIn.adapter;



/**
 * Adapter to display {@link Avatar} icons.
 */
public class AvatarAdapter extends BaseAdapter {

    private static final Avatar[] mAvatars = Avatar.values();

    private final LayoutInflater mLayoutInflater;

    public AvatarAdapter(Context context) {
        mLayoutInflater = LayoutInflater.from(context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (null == convertView) {
            convertView = mLayoutInflater.inflate(R.layout.item_avatar, parent, false);
        }
        setAvatar((AvatarView) convertView, mAvatars[position]);