merge
This commit is contained in:
commit
a4637f2ca3
|
@ -17,11 +17,9 @@ public class Good extends BmobObject implements Serializable{
|
||||||
//private String id; 商品ID, 默认
|
//private String id; 商品ID, 默认
|
||||||
|
|
||||||
private String shopID = ""; // 商店ID
|
private String shopID = ""; // 商店ID
|
||||||
private String shopName = ""; //商店名称
|
|
||||||
private String type = ""; // 类型
|
private String type = ""; // 类型
|
||||||
private String name = ""; // 名称
|
private String name = ""; // 名称
|
||||||
private String price = ""; // 价格
|
private String price = ""; // 价格
|
||||||
private BmobFile picGood = null; // 商品主图
|
|
||||||
|
|
||||||
public Good(String name, String price) {
|
public Good(String name, String price) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
|
@ -21,8 +21,6 @@ public class Shop extends BmobObject implements Serializable{
|
||||||
private String phone; // 联系电话
|
private String phone; // 联系电话
|
||||||
private String info; // 简介
|
private String info; // 简介
|
||||||
private String sale; // 促销信息
|
private String sale; // 促销信息
|
||||||
private BmobFile picShop; // 商店主图
|
|
||||||
|
|
||||||
public String getUserID() {
|
public String getUserID() {
|
||||||
return userID;
|
return userID;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,6 @@ import cn.bmob.v3.BmobObject;
|
||||||
*/
|
*/
|
||||||
public class BXTNews extends BmobObject{
|
public class BXTNews extends BmobObject{
|
||||||
|
|
||||||
//private String id;
|
|
||||||
|
|
||||||
private String title; //标题
|
private String title; //标题
|
||||||
private String topic; //讲座主题
|
private String topic; //讲座主题
|
||||||
private String speaker; //主 讲 人
|
private String speaker; //主 讲 人
|
||||||
|
|
|
@ -9,9 +9,6 @@ import cn.bmob.v3.BmobObject;
|
||||||
*/
|
*/
|
||||||
public class SComment extends BmobObject {
|
public class SComment extends BmobObject {
|
||||||
|
|
||||||
// private String id;
|
|
||||||
// private String time;
|
|
||||||
|
|
||||||
private String shopID;
|
private String shopID;
|
||||||
private String shopName;
|
private String shopName;
|
||||||
private String userID;
|
private String userID;
|
||||||
|
|
|
@ -12,6 +12,8 @@ import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -44,6 +46,7 @@ import junit.framework.Assert;
|
||||||
* @date 2014-5-9
|
* @date 2014-5-9
|
||||||
* @author Stone
|
* @author Stone
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Util {
|
public class Util {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,6 +55,7 @@ public class Util {
|
||||||
* @param phoneNumber
|
* @param phoneNumber
|
||||||
* @return true 有效 / false 无效
|
* @return true 有效 / false 无效
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static boolean isPhoneNumberValid(String phoneNumber) {
|
public static boolean isPhoneNumberValid(String phoneNumber) {
|
||||||
|
|
||||||
boolean isValid = false;
|
boolean isValid = false;
|
||||||
|
@ -93,8 +97,9 @@ private static final String TAG = "SDK_Sample.Util";
|
||||||
*/
|
*/
|
||||||
public static String bytesToHexString(byte[] src){
|
public static String bytesToHexString(byte[] src){
|
||||||
StringBuilder stringBuilder = new StringBuilder("");
|
StringBuilder stringBuilder = new StringBuilder("");
|
||||||
|
String nullreplace="";
|
||||||
if (src == null || src.length <= 0) {
|
if (src == null || src.length <= 0) {
|
||||||
return null;
|
return nullreplace;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < src.length; i++) {
|
for (int i = 0; i < src.length; i++) {
|
||||||
int v = src[i] & 0xFF;
|
int v = src[i] & 0xFF;
|
||||||
|
@ -112,8 +117,9 @@ private static final String TAG = "SDK_Sample.Util";
|
||||||
* @return byte[]
|
* @return byte[]
|
||||||
*/
|
*/
|
||||||
public static byte[] hexStringToBytes(String hexString) {
|
public static byte[] hexStringToBytes(String hexString) {
|
||||||
if (hexString == null || hexString.equals("")) {
|
byte[] nullreplace=null;
|
||||||
return null;
|
if (hexString == null || "".equals(hexString)) {
|
||||||
|
return nullreplace;
|
||||||
}
|
}
|
||||||
hexString = hexString.toUpperCase();
|
hexString = hexString.toUpperCase();
|
||||||
int length = hexString.length() / 2;
|
int length = hexString.length() / 2;
|
||||||
|
@ -148,15 +154,17 @@ private static final String TAG = "SDK_Sample.Util";
|
||||||
try {
|
try {
|
||||||
bytes = str.getBytes("UTF-8");
|
bytes = str.getBytes("UTF-8");
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
e.printStackTrace();
|
Logger logger = Logger.getLogger("lavasoft");
|
||||||
|
logger.log(Level.SEVERE, "sthwrong", e);
|
||||||
}
|
}
|
||||||
if (bytes == null) return null;
|
if (bytes == null)
|
||||||
|
return null;
|
||||||
StringBuilder sb=new StringBuilder(bytes.length*2);
|
StringBuilder sb=new StringBuilder(bytes.length*2);
|
||||||
//将字节数组中每个字节拆解成2位16进制整数
|
//将字节数组中每个字节拆解成2位16进制整数
|
||||||
for(int i=0;i<bytes.length;i++)
|
for(int i=0;i<bytes.length;i++)
|
||||||
{
|
{
|
||||||
sb.append(hexString.charAt((bytes[i]&0xf0)>>4));
|
sb.append(hexString.charAt((bytes[i]&0xf0)>>4));
|
||||||
sb.append(hexString.charAt((bytes[i]&0x0f)>>0));
|
sb.append(hexString.charAt(bytes[i]&0x0f));
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
@ -177,7 +185,8 @@ private static final String TAG = "SDK_Sample.Util";
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
Logger logger = Logger.getLogger("lavasoft");
|
||||||
|
logger.log(Level.SEVERE, "sthwrong", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +196,8 @@ private static final String TAG = "SDK_Sample.Util";
|
||||||
}
|
}
|
||||||
catch (Exception e1)
|
catch (Exception e1)
|
||||||
{
|
{
|
||||||
e1.printStackTrace();
|
Logger logger = Logger.getLogger("lavasoft");
|
||||||
|
logger.log(Level.SEVERE, "sthwrong", e1);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -203,7 +213,8 @@ private static final String TAG = "SDK_Sample.Util";
|
||||||
try {
|
try {
|
||||||
output.close();
|
output.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
Logger logger = Logger.getLogger("lavasoft");
|
||||||
|
logger.log(Level.SEVERE, "sthwrong", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -221,12 +232,13 @@ private static final String TAG = "SDK_Sample.Util";
|
||||||
inStream = httpConnection.getInputStream();
|
inStream = httpConnection.getInputStream();
|
||||||
}
|
}
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
e.printStackTrace();
|
Logger logger = Logger.getLogger("lavasoft");
|
||||||
|
logger.log(Level.SEVERE, "sthwrong", e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
Logger logger = Logger.getLogger("lavasoft");
|
||||||
|
logger.log(Level.SEVERE, "sthwrong", e);
|
||||||
}
|
}
|
||||||
byte[] data = inputStreamToByte(inStream);
|
byte[] data = inputStreamToByte(inStream);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,21 +253,23 @@ private static final String TAG = "SDK_Sample.Util";
|
||||||
bytestream.close();
|
bytestream.close();
|
||||||
return imgdata;
|
return imgdata;
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
e.printStackTrace();
|
Logger logger = Logger.getLogger("lavasoft");
|
||||||
|
logger.log(Level.SEVERE, "sthwrong", e);
|
||||||
}
|
}
|
||||||
|
byte[] nullreplace=new byte[0];
|
||||||
return null;
|
return nullreplace;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] readFromFile(String fileName, int offset, int len) {
|
public static byte[] readFromFile(String fileName, int offset, int len) {
|
||||||
|
byte[] nullreplace=new byte[0];
|
||||||
if (fileName == null) {
|
if (fileName == null) {
|
||||||
return null;
|
return nullreplace;
|
||||||
}
|
}
|
||||||
|
|
||||||
File file = new File(fileName);
|
File file = new File(fileName);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
Log.i(TAG, "readFromFile: file not found");
|
Log.i(TAG, "readFromFile: file not found");
|
||||||
return null;
|
return nullreplace;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len == -1) {
|
if (len == -1) {
|
||||||
|
@ -266,15 +280,15 @@ private static final String TAG = "SDK_Sample.Util";
|
||||||
|
|
||||||
if(offset <0){
|
if(offset <0){
|
||||||
Log.e(TAG, "readFromFile invalid offset:" + offset);
|
Log.e(TAG, "readFromFile invalid offset:" + offset);
|
||||||
return null;
|
return nullreplace;
|
||||||
}
|
}
|
||||||
if(len <=0 ){
|
if(len <=0 ){
|
||||||
Log.e(TAG, "readFromFile invalid len:" + len);
|
Log.e(TAG, "readFromFile invalid len:" + len);
|
||||||
return null;
|
return nullreplace;
|
||||||
}
|
}
|
||||||
if(offset + len > (int) file.length()){
|
if(offset + len > (int) file.length()){
|
||||||
Log.e(TAG, "readFromFile invalid file len:" + file.length());
|
Log.e(TAG, "readFromFile invalid file len:" + file.length());
|
||||||
return null;
|
return nullreplace;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] b = null;
|
byte[] b = null;
|
||||||
|
@ -287,7 +301,8 @@ private static final String TAG = "SDK_Sample.Util";
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "readFromFile : errMsg = " + e.getMessage());
|
Log.e(TAG, "readFromFile : errMsg = " + e.getMessage());
|
||||||
e.printStackTrace();
|
Logger logger = Logger.getLogger("lavasoft");
|
||||||
|
logger.log(Level.SEVERE, "sthwrong", e);
|
||||||
}
|
}
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
@ -321,35 +336,17 @@ private static final String TAG = "SDK_Sample.Util";
|
||||||
return roundedSize;
|
return roundedSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int computeInitialSampleSize(BitmapFactory.Options options,
|
private static int computeInitialSampleSize(BitmapFactory.Options options,int minSideLength, int maxNumOfPixels)
|
||||||
|
{
|
||||||
int minSideLength, int maxNumOfPixels) {
|
|
||||||
|
|
||||||
double w = options.outWidth;
|
double w = options.outWidth;
|
||||||
|
|
||||||
double h = options.outHeight;
|
double h = options.outHeight;
|
||||||
|
int lowerBound = (maxNumOfPixels == -1) ? 1 :(int) Math.ceil(Math.sqrt(w * h / maxNumOfPixels));
|
||||||
int lowerBound = (maxNumOfPixels == -1) ? 1 :
|
int upperBound = (minSideLength == -1) ? 128 :(int) Math.min(Math.floor(w / minSideLength),Math.floor(h / minSideLength));
|
||||||
|
|
||||||
(int) Math.ceil(Math.sqrt(w * h / maxNumOfPixels));
|
|
||||||
|
|
||||||
int upperBound = (minSideLength == -1) ? 128 :
|
|
||||||
|
|
||||||
(int) Math.min(Math.floor(w / minSideLength),
|
|
||||||
|
|
||||||
Math.floor(h / minSideLength));
|
|
||||||
|
|
||||||
if (upperBound < lowerBound) {
|
if (upperBound < lowerBound) {
|
||||||
|
|
||||||
// return the larger one when there is no overlapping zone.
|
// return the larger one when there is no overlapping zone.
|
||||||
|
|
||||||
return lowerBound;
|
return lowerBound;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if ((maxNumOfPixels == -1) &&(minSideLength == -1)) {
|
||||||
if ((maxNumOfPixels == -1) &&
|
|
||||||
|
|
||||||
(minSideLength == -1)) {
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
@ -377,15 +374,19 @@ private static final String TAG = "SDK_Sample.Util";
|
||||||
Bitmap bitmap = BitmapFactory.decodeStream(stream , null, opts);
|
Bitmap bitmap = BitmapFactory.decodeStream(stream , null, opts);
|
||||||
return bitmap;
|
return bitmap;
|
||||||
} catch (OutOfMemoryError e) {
|
} catch (OutOfMemoryError e) {
|
||||||
|
Logger logger = Logger.getLogger("lavasoft");
|
||||||
|
logger.log(Level.SEVERE, "sthwrong", e);
|
||||||
return null;
|
return null;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
Logger logger = Logger.getLogger("lavasoft");
|
||||||
|
logger.log(Level.SEVERE, "sthwrong", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int MAX_DECODE_PICTURE_SIZE = 1920 * 1440;
|
private static final int MAX_DECODE_PICTURE_SIZE = 1920 * 1440;
|
||||||
public static Bitmap extractThumbNail(final String path, final int height, final int width, final boolean crop) {
|
public static Bitmap extractThumbNail(final String path, final int height, final int width, final boolean crop) {
|
||||||
Assert.assertTrue(path != null && !path.equals("") && height > 0 && width > 0);
|
Assert.assertTrue(path != null && !"".equals(path) && height > 0 && width > 0);
|
||||||
|
|
||||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||||
|
|
||||||
|
@ -396,7 +397,6 @@ private static final String TAG = "SDK_Sample.Util";
|
||||||
tmp.recycle();
|
tmp.recycle();
|
||||||
tmp = null;
|
tmp = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d(TAG, "extractThumbNail: round=" + width + "x" + height + ", crop=" + crop);
|
Log.d(TAG, "extractThumbNail: round=" + width + "x" + height + ", crop=" + crop);
|
||||||
final double beY = options.outHeight * 1.0 / height;
|
final double beY = options.outHeight * 1.0 / height;
|
||||||
final double beX = options.outWidth * 1.0 / width;
|
final double beX = options.outWidth * 1.0 / width;
|
||||||
|
@ -457,6 +457,8 @@ private static final String TAG = "SDK_Sample.Util";
|
||||||
|
|
||||||
} catch (final OutOfMemoryError e) {
|
} catch (final OutOfMemoryError e) {
|
||||||
Log.e(TAG, "decode bitmap failed: " + e.getMessage());
|
Log.e(TAG, "decode bitmap failed: " + e.getMessage());
|
||||||
|
Logger logger = Logger.getLogger("lavasoft");
|
||||||
|
logger.log(Level.SEVERE, "sthwrong", e);
|
||||||
options = null;
|
options = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,7 +467,8 @@ private static final String TAG = "SDK_Sample.Util";
|
||||||
|
|
||||||
public static final void showResultDialog(Context context, String msg,
|
public static final void showResultDialog(Context context, String msg,
|
||||||
String title) {
|
String title) {
|
||||||
if(msg == null) return;
|
if(msg == null)
|
||||||
|
return;
|
||||||
String rmsg = msg.replace(",", "\n");
|
String rmsg = msg.replace(",", "\n");
|
||||||
Log.d("Util", rmsg);
|
Log.d("Util", rmsg);
|
||||||
new AlertDialog.Builder(context).setTitle(title).setMessage(rmsg)
|
new AlertDialog.Builder(context).setTitle(title).setMessage(rmsg)
|
||||||
|
@ -484,17 +487,13 @@ private static final String TAG = "SDK_Sample.Util";
|
||||||
mProgressDialog = ProgressDialog.show(context, title, message);
|
mProgressDialog = ProgressDialog.show(context, title, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AlertDialog showConfirmCancelDialog(Context context,
|
public static AlertDialog showConfirmCancelDialog(Context context,String message,DialogInterface.OnClickListener posListener)
|
||||||
String title, String message,
|
{
|
||||||
DialogInterface.OnClickListener posListener) {
|
AlertDialog dlg = new AlertDialog.Builder(context).setMessage(message).setPositiveButton("确认", posListener).setNegativeButton("取消", null).create();
|
||||||
AlertDialog dlg = new AlertDialog.Builder(context).setMessage(message)
|
|
||||||
.setPositiveButton("确认", posListener)
|
|
||||||
.setNegativeButton("取消", null).create();
|
|
||||||
dlg.setCanceledOnTouchOutside(false);
|
dlg.setCanceledOnTouchOutside(false);
|
||||||
dlg.show();
|
dlg.show();
|
||||||
return dlg;
|
return dlg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final void dismissDialog() {
|
public static final void dismissDialog() {
|
||||||
if (mProgressDialog != null) {
|
if (mProgressDialog != null) {
|
||||||
mProgressDialog.dismiss();
|
mProgressDialog.dismiss();
|
||||||
|
@ -522,7 +521,6 @@ private static final String TAG = "SDK_Sample.Util";
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
if (mToast != null) {
|
if (mToast != null) {
|
||||||
mToast.cancel();
|
mToast.cancel();
|
||||||
mToast = null;
|
mToast = null;
|
||||||
|
@ -569,10 +567,12 @@ private static final String TAG = "SDK_Sample.Util";
|
||||||
|
|
||||||
Log.v(TAG, "image download finished." + imageUri);
|
Log.v(TAG, "image download finished." + imageUri);
|
||||||
} catch (OutOfMemoryError e) {
|
} catch (OutOfMemoryError e) {
|
||||||
e.printStackTrace();
|
Logger logger = Logger.getLogger("lavasoft");
|
||||||
|
logger.log(Level.SEVERE, "sthwrong", e);
|
||||||
bitmap = null;
|
bitmap = null;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
Logger logger = Logger.getLogger("lavasoft");
|
||||||
|
logger.log(Level.SEVERE, "sthwrong", e);
|
||||||
Log.v(TAG, "getbitmap bmp fail---");
|
Log.v(TAG, "getbitmap bmp fail---");
|
||||||
bitmap = null;
|
bitmap = null;
|
||||||
}
|
}
|
||||||
|
@ -589,8 +589,8 @@ private static final String TAG = "SDK_Sample.Util";
|
||||||
// =兼容android 5.0
|
// =兼容android 5.0
|
||||||
// ==========
|
// ==========
|
||||||
|
|
||||||
public static String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
|
public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
|
||||||
public static int Build_VERSION_KITKAT = 19;
|
public static final int Build_VERSION_KITKAT = 19;
|
||||||
public static String getPath(final Context context, final Uri uri) {
|
public static String getPath(final Context context, final Uri uri) {
|
||||||
|
|
||||||
final boolean isKitKat = Build.VERSION.SDK_INT >= 19;
|
final boolean isKitKat = Build.VERSION.SDK_INT >= 19;
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue