| @ -0,0 +1,87 @@ | |||
| package com.qhclh.ytzh.bean; | |||
| import com.google.gson.annotations.SerializedName; | |||
| /** | |||
| * Created by 青花瓷 on 2017/9/5. | |||
| */ | |||
| public class DownLoadBean { | |||
| /** | |||
| * name : MarketPlaceMerchantApp | |||
| * version : 0.1 | |||
| * filename : release.apk | |||
| * versions : {"0.1":"http://bwp.oss-cn-beijing.aliyuncs.com/publish/MarketPlaceMerchantApp/0.1/release.apk"} | |||
| * download : http://bwp.oss-cn-beijing.aliyuncs.com/publish/MarketPlaceMerchantApp/release.apk | |||
| * qrcode : http://bwp.oss-cn-beijing.aliyuncs.com/publish/MarketPlaceMerchantApp/qrcode.png | |||
| */ | |||
| private String name; | |||
| private String version; | |||
| private String filename; | |||
| private VersionsBean versions; | |||
| private String download; | |||
| private String qrcode; | |||
| public String getName() { | |||
| return name; | |||
| } | |||
| public void setName(String name) { | |||
| this.name = name; | |||
| } | |||
| public String getVersion() { | |||
| return version; | |||
| } | |||
| public void setVersion(String version) { | |||
| this.version = version; | |||
| } | |||
| public String getFilename() { | |||
| return filename; | |||
| } | |||
| public void setFilename(String filename) { | |||
| this.filename = filename; | |||
| } | |||
| public VersionsBean getVersions() { | |||
| return versions; | |||
| } | |||
| public void setVersions(VersionsBean versions) { | |||
| this.versions = versions; | |||
| } | |||
| public String getDownload() { | |||
| return download; | |||
| } | |||
| public void setDownload(String download) { | |||
| this.download = download; | |||
| } | |||
| public String getQrcode() { | |||
| return qrcode; | |||
| } | |||
| public void setQrcode(String qrcode) { | |||
| this.qrcode = qrcode; | |||
| } | |||
| public static class VersionsBean { | |||
| @SerializedName("0.1") | |||
| private String _$_01260; // FIXME check this code | |||
| public String get_$_01260() { | |||
| return _$_01260; | |||
| } | |||
| public void set_$_01260(String _$_01260) { | |||
| this._$_01260 = _$_01260; | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,62 @@ | |||
| package com.qhclh.ytzh.utils; | |||
| import android.content.Context; | |||
| import android.content.pm.PackageInfo; | |||
| import android.content.pm.PackageManager; | |||
| import android.util.Log; | |||
| public class ApkUtils { | |||
| /** | |||
| * This method provide the package's name. | |||
| * | |||
| * @param context | |||
| * @return String name | |||
| */ | |||
| public static String getPackageName(Context context) { | |||
| PackageManager manager = context.getPackageManager(); | |||
| String packageName = "0"; | |||
| try { | |||
| PackageInfo info = manager.getPackageInfo(context.getPackageName(),0); | |||
| packageName = info.packageName; | |||
| } catch (Exception e) { | |||
| Log.e("ApkInfo", e.getMessage()); | |||
| } | |||
| return packageName; | |||
| } | |||
| /** | |||
| * This method provide the package's version name. | |||
| * | |||
| * @param context | |||
| * @return String name | |||
| */ | |||
| public static String getVersionName(Context context) { | |||
| PackageManager manager = context.getPackageManager(); | |||
| String versionName = "0"; | |||
| try { | |||
| PackageInfo info = manager.getPackageInfo(context.getPackageName(),0); | |||
| versionName = info.versionName; | |||
| } catch (Exception e) { | |||
| Log.e("ApkInfo", e.getMessage()); | |||
| } | |||
| return versionName; | |||
| } | |||
| /** | |||
| * This method provide the package's version code | |||
| * | |||
| * @param context | |||
| * @return int code | |||
| */ | |||
| public static int getVersionCode(Context context) { | |||
| PackageManager manager = context.getPackageManager(); | |||
| int versionCode = 0; | |||
| try { | |||
| PackageInfo info = manager.getPackageInfo(context.getPackageName(),0); | |||
| versionCode = info.versionCode; | |||
| } catch (Exception e) { | |||
| Log.e("ApkInfo", e.getMessage()); | |||
| } | |||
| return versionCode; | |||
| } | |||
| } | |||
| @ -0,0 +1,89 @@ | |||
| package com.qhclh.ytzh.utils; | |||
| import java.io.ByteArrayOutputStream; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.io.UnsupportedEncodingException; | |||
| import java.net.HttpURLConnection; | |||
| import java.net.URL; | |||
| import java.net.URLDecoder; | |||
| import java.util.HashMap; | |||
| import java.util.Map; | |||
| /** | |||
| * Created by 青花瓷 on 2017/8/18. | |||
| */ | |||
| public class Urltool { | |||
| ///< 获取url的键值 | |||
| public static Map<String, String> getParameters(String url) { | |||
| Map<String, String> params=new HashMap<String, String>(); | |||
| if(url==null || "".equals(url.trim())){ | |||
| return params; | |||
| } | |||
| try { | |||
| url = URLDecoder.decode(url, "UTF-8"); | |||
| } catch (UnsupportedEncodingException e1) { | |||
| e1.printStackTrace(); | |||
| } | |||
| String[] split = url.split("[?]"); | |||
| if (split.length == 2 && !"".equals(split[1].trim())) { | |||
| String[] parameters = split[1].split("&"); | |||
| if (parameters != null && parameters.length != 0) { | |||
| for (int i = 0; i < parameters.length; i++) { | |||
| if (parameters[i] != null | |||
| && parameters[i].trim().contains("=")) { | |||
| String[] split2 = parameters[i].split("="); | |||
| //split2可能为1,可能为2 | |||
| if(split2.length==1){ | |||
| //有这个参数但是是空的 | |||
| params.put(split2[0], ""); | |||
| }else if(split2.length==2){ | |||
| if(!"".equals(split2[0].trim())){ | |||
| params.put(split2[0], split2[1]); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| return params; | |||
| } | |||
| /** | |||
| * 从网络获取json数据,(String byte[}) | |||
| * @param path | |||
| * @return | |||
| */ | |||
| public static String getJsonByInternet(String path){ | |||
| try { | |||
| URL url = new URL(path.trim()); | |||
| //打开连接 | |||
| HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); | |||
| urlConnection.setConnectTimeout(3000); | |||
| urlConnection.setRequestMethod("GET"); | |||
| if(200 == urlConnection.getResponseCode()){ | |||
| //得到输入流 | |||
| InputStream is =urlConnection.getInputStream(); | |||
| ByteArrayOutputStream baos = new ByteArrayOutputStream(); | |||
| byte[] buffer = new byte[1024]; | |||
| int len = 0; | |||
| while(-1 != (len = is.read(buffer))){ | |||
| baos.write(buffer,0,len); | |||
| baos.flush(); | |||
| } | |||
| is.close(); | |||
| baos.close(); | |||
| return baos.toString("utf-8"); | |||
| } | |||
| } catch (IOException e) { | |||
| e.printStackTrace(); | |||
| } | |||
| return null; | |||
| } | |||
| } | |||