// Path: AndroidClient/app/src/main/java/com/hufeiya/SignIn/helper/ApiLevelHelper.java
// public class ApiLevelHelper {
// 
//     private ApiLevelHelper() {
//         //no instance
//     }
// 
//     /**
//      * Checks if the current api level is at least the provided value.
//      *
//      * @param apiLevel One of the values within {@link Build.VERSION_CODES}.
//      * @return <code>true</code> if the calling version is at least <code>apiLevel</code>.
//      * Else <code>false</code> is returned.
//      */
//     public static boolean isAtLeast(int apiLevel) {
//         return Build.VERSION.SDK_INT >= apiLevel;
//     }
// 
//     /**
//      * Checks if the current api level is at lower than the provided value.
//      *
//      * @param apiLevel One of the values within {@link Build.VERSION_CODES}.
//      * @return <code>true</code> if the calling version is lower than <code>apiLevel</code>.
//      * Else <code>false</code> is returned.
//      */
//     public static boolean isLowerThan(int apiLevel) {
//         return Build.VERSION.SDK_INT < apiLevel;
//     }
// }
// 
// Path: AndroidClient/app/src/main/java/com/hufeiya/SignIn/widget/outlineprovider/RoundOutlineProvider.java
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// public class RoundOutlineProvider extends ViewOutlineProvider {
// 
//     private final int mSize;
// 
//     public RoundOutlineProvider(int size) {
//         if (0 > size) {
//             throw new IllegalArgumentException("size needs to be > 0. Actually was " + size);
//         }
//         mSize = size;
//     }
// 
//     @Override
//     public final void getOutline(View view, Outline outline) {
//         outline.setOval(0, 0, mSize, mSize);
//     }
// 
// }


import android.widget.ImageView;
import com.hufeiya.SignIn.R;
import com.hufeiya.SignIn.helper.ApiLevelHelper;
import com.hufeiya.SignIn.widget.outlineprovider.RoundOutlineProvider;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
import android.util.AttributeSet;
import android.widget.Checkable;
/*
 * 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.widget;



/**
 * A simple view that wraps an avatar.
 */
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) {
// Path: AndroidClient/app/src/main/java/com/hufeiya/SignIn/helper/ApiLevelHelper.java
// public class ApiLevelHelper {
// 
//     private ApiLevelHelper() {
//         //no instance
//     }
// 
//     /**
//      * Checks if the current api level is at least the provided value.
//      *
//      * @param apiLevel One of the values within {@link Build.VERSION_CODES}.
//      * @return <code>true</code> if the calling version is at least <code>apiLevel</code>.
//      * Else <code>false</code> is returned.
//      */
//     public static boolean isAtLeast(int apiLevel) {
//         return Build.VERSION.SDK_INT >= apiLevel;
//     }
// 
//     /**
//      * Checks if the current api level is at lower than the provided value.
//      *
//      * @param apiLevel One of the values within {@link Build.VERSION_CODES}.
//      * @return <code>true</code> if the calling version is lower than <code>apiLevel</code>.
//      * Else <code>false</code> is returned.
//      */
//     public static boolean isLowerThan(int apiLevel) {
//         return Build.VERSION.SDK_INT < apiLevel;
//     }
// }
// 
// Path: AndroidClient/app/src/main/java/com/hufeiya/SignIn/widget/outlineprovider/RoundOutlineProvider.java
// @TargetApi(Build.VERSION_CODES.LOLLIPOP)
// public class RoundOutlineProvider extends ViewOutlineProvider {
// 
//     private final int mSize;
// 
//     public RoundOutlineProvider(int size) {
//         if (0 > size) {
//             throw new IllegalArgumentException("size needs to be > 0. Actually was " + size);
//         }
//         mSize = size;
//     }
// 
//     @Override
//     public final void getOutline(View view, Outline outline) {
//         outline.setOval(0, 0, mSize, mSize);
//     }
// 
// }


// Path: AndroidClient/app/src/main/java/com/hufeiya/SignIn/widget/AvatarView.java
import android.widget.ImageView;
import com.hufeiya.SignIn.R;
import com.hufeiya.SignIn.helper.ApiLevelHelper;
import com.hufeiya.SignIn.widget.outlineprovider.RoundOutlineProvider;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
import android.util.AttributeSet;
import android.widget.Checkable;

/*
 * 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.widget;



/**
 * A simple view that wraps an avatar.
 */
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)) {