// Path: app/src/main/java/com/cxsj/runhdu/constant/Types.java
// public class Types {
//     public final static int TYPE_YEAR = 1000;
//     public final static int TYPE_MONTH = 1001;
//     public final static int TYPE_DATE = 1002;
//     public final static int TYPE_HOUR = 1003;
//     public final static int TYPE_MINUTE = 1004;
//     public final static int TYPE_SECOND = 1005;
//     public final static int TYPE_MONTH_DATE = 1006;
//     public final static int TYPE_CURRENT_TIME = 1007;
//     public final static int TYPE_AM_PM = 1008;
//     public final static int TYPE_CHANGE_PROFILE = 1009;
//     public final static int TYPE_CHANGE_MENU_BG = 1010;
//     public final static int MANUAL_UPDATE = 1011;
//     public final static int AUTO_UPDATE = 1012;
//     public final static int TYPE_SAVE_PROFILE = 1013;
//     public final static int TYPE_STRING_FORM=1014;
// }
// 
// Path: app/src/main/java/com/cxsj/runhdu/constant/URLs.java
// public class URLs {
//     public static final String DOWNLOAD = "http://d1.51gugu.com/170258/RunHDU";
//     public static final String LOGIN = "http://112.74.115.231:8080/CXSJ/Login";
//     public static final String REGISTER="http://112.74.115.231:8080/CXSJ/Register";
//     public static final String GET_RUN_INFO = "http://112.74.115.231:8080/chuangxinshijian/ReadAll";
//     public static final String UPLOAD_RUN_INFO = "http://112.74.115.231:8080/chuangxinshijian/Write";
//     public static final String CLEAR_DATA = "http://112.74.115.231:8080/chuangxinshijian/ClearTheTable";
//     public static final String UPDATE_URL = "http://112.74.115.231:8080/chuangxinshijian/VersionCompare";
//     public static final String GET_RUN_TIMES = "http://112.74.115.231:8080/chuangxinshijian/ReadUserNameAndTimesOnly";
//     public static final String UPLOAD_ALL_INFO = "http://112.74.115.231:8080/chuangxinshijian/WriteByJson";
//     public static final String UPLOAD_PROFILE = "http://112.74.115.231:8080/CXSJ/UploadHead";
//     public static final String PROFILE_URL = "http://112.74.115.231:8080/CXSJ/Image/";
//     public static final String FEEDBACK_URL = "http://112.74.115.231:8080/chuangxinshijian/WriteFeedback";
//     public static final String SUNNY_RUN_QUERY_API = "http://hdu.sunnysport.org.cn/api/student/achievements/";
//     public static final String SUNNY_RUN_INFO_API = "http://hdu.sunnysport.org.cn/api/student/info/";
//     public static final String DELETE_ITEM = "http://112.74.115.231:8080/chuangxinshijian/ClearByUserNameAndRunId";
//     public static final String APPLY_FRIEND = "http://112.74.115.231:8080/CXSJ/Apply";
//     public static final String REPLY_FRIEND = "http://112.74.115.231:8080/CXSJ/BeFriend";
//     public static final String GET_FRIEND = "http://112.74.115.231:8080/CXSJ/MyFriends";
//     public static final String DELETE_FRIEND = "http://112.74.115.231:8080/CXSJ/DeleteFriend";
//     public static final String OFF_LINE = "http://112.74.115.231:8080/CXSJ/Xiaxian";
// }


import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Environment;
import android.test.ActivityTestCase;
import android.util.Base64;
import android.view.View;
import com.baidu.mapapi.map.BitmapDescriptor;
import com.cxsj.runhdu.constant.Types;
import com.cxsj.runhdu.constant.URLs;
import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;
package com.cxsj.runhdu.utils;





/**
 * Created by Sail on 2017/5/21 0021.
 * 图片处理工具
 */

public class ImageUtil {
    /**
     * 保存图片到相册。
     *
     * @param context  上下文
     * @param bitmap
     * @param fileName 保存的路径
     */
    public static String saveToSDCard(Context context, Bitmap bitmap, String fileName) {
        FileOutputStream fos;
        String saveDir = context.getExternalFilesDir(Environment.DIRECTORY_PICTURES)
                + fileName;
        try {
            fos = new FileOutputStream(saveDir);
            if (null != fos) {
                bitmap.compress(Bitmap.CompressFormat.JPEG, 90, fos);
                fos.flush();
                fos.close();
                return saveDir;
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
// Path: app/src/main/java/com/cxsj/runhdu/constant/Types.java
// public class Types {
//     public final static int TYPE_YEAR = 1000;
//     public final static int TYPE_MONTH = 1001;
//     public final static int TYPE_DATE = 1002;
//     public final static int TYPE_HOUR = 1003;
//     public final static int TYPE_MINUTE = 1004;
//     public final static int TYPE_SECOND = 1005;
//     public final static int TYPE_MONTH_DATE = 1006;
//     public final static int TYPE_CURRENT_TIME = 1007;
//     public final static int TYPE_AM_PM = 1008;
//     public final static int TYPE_CHANGE_PROFILE = 1009;
//     public final static int TYPE_CHANGE_MENU_BG = 1010;
//     public final static int MANUAL_UPDATE = 1011;
//     public final static int AUTO_UPDATE = 1012;
//     public final static int TYPE_SAVE_PROFILE = 1013;
//     public final static int TYPE_STRING_FORM=1014;
// }
// 
// Path: app/src/main/java/com/cxsj/runhdu/constant/URLs.java
// public class URLs {
//     public static final String DOWNLOAD = "http://d1.51gugu.com/170258/RunHDU";
//     public static final String LOGIN = "http://112.74.115.231:8080/CXSJ/Login";
//     public static final String REGISTER="http://112.74.115.231:8080/CXSJ/Register";
//     public static final String GET_RUN_INFO = "http://112.74.115.231:8080/chuangxinshijian/ReadAll";
//     public static final String UPLOAD_RUN_INFO = "http://112.74.115.231:8080/chuangxinshijian/Write";
//     public static final String CLEAR_DATA = "http://112.74.115.231:8080/chuangxinshijian/ClearTheTable";
//     public static final String UPDATE_URL = "http://112.74.115.231:8080/chuangxinshijian/VersionCompare";
//     public static final String GET_RUN_TIMES = "http://112.74.115.231:8080/chuangxinshijian/ReadUserNameAndTimesOnly";
//     public static final String UPLOAD_ALL_INFO = "http://112.74.115.231:8080/chuangxinshijian/WriteByJson";
//     public static final String UPLOAD_PROFILE = "http://112.74.115.231:8080/CXSJ/UploadHead";
//     public static final String PROFILE_URL = "http://112.74.115.231:8080/CXSJ/Image/";
//     public static final String FEEDBACK_URL = "http://112.74.115.231:8080/chuangxinshijian/WriteFeedback";
//     public static final String SUNNY_RUN_QUERY_API = "http://hdu.sunnysport.org.cn/api/student/achievements/";
//     public static final String SUNNY_RUN_INFO_API = "http://hdu.sunnysport.org.cn/api/student/info/";
//     public static final String DELETE_ITEM = "http://112.74.115.231:8080/chuangxinshijian/ClearByUserNameAndRunId";
//     public static final String APPLY_FRIEND = "http://112.74.115.231:8080/CXSJ/Apply";
//     public static final String REPLY_FRIEND = "http://112.74.115.231:8080/CXSJ/BeFriend";
//     public static final String GET_FRIEND = "http://112.74.115.231:8080/CXSJ/MyFriends";
//     public static final String DELETE_FRIEND = "http://112.74.115.231:8080/CXSJ/DeleteFriend";
//     public static final String OFF_LINE = "http://112.74.115.231:8080/CXSJ/Xiaxian";
// }


// Path: app/src/main/java/com/cxsj/runhdu/utils/ImageUtil.java
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Environment;
import android.test.ActivityTestCase;
import android.util.Base64;
import android.view.View;
import com.baidu.mapapi.map.BitmapDescriptor;
import com.cxsj.runhdu.constant.Types;
import com.cxsj.runhdu.constant.URLs;
import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;

package com.cxsj.runhdu.utils;





/**
 * Created by Sail on 2017/5/21 0021.
 * 图片处理工具
 */

public class ImageUtil {
    /**
     * 保存图片到相册。
     *
     * @param context  上下文
     * @param bitmap
     * @param fileName 保存的路径
     */
    public static String saveToSDCard(Context context, Bitmap bitmap, String fileName) {
        FileOutputStream fos;
        String saveDir = context.getExternalFilesDir(Environment.DIRECTORY_PICTURES)
                + fileName;
        try {
            fos = new FileOutputStream(saveDir);
            if (null != fos) {
                bitmap.compress(Bitmap.CompressFormat.JPEG, 90, fos);
                fos.flush();
                fos.close();
                return saveDir;
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();