merge
This commit is contained in:
commit
fee6c38a85
|
@ -0,0 +1,63 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
import cn.bmob.v3.datatype.BmobFile;
|
||||
|
||||
/**
|
||||
* 商品实体类
|
||||
* @date 2014-4-24
|
||||
* @author Stone
|
||||
*/
|
||||
public class Good extends BmobObject implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = -3248168273019127389L;
|
||||
|
||||
//private String id; 商品ID, 默认
|
||||
|
||||
private String shopID = ""; // 商店ID
|
||||
private String shopName = ""; //商店名称
|
||||
private String type = ""; // 类型
|
||||
private String name = ""; // 名称
|
||||
private String price = ""; // 价格
|
||||
private BmobFile picGood = null; // 商品主图
|
||||
|
||||
public Good(String name, String price) {
|
||||
this.name = name;
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public String getShopID() {
|
||||
return shopID;
|
||||
}
|
||||
|
||||
public void setShopID(String shopID) {
|
||||
this.shopID = shopID;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(String price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
import cn.bmob.v3.datatype.BmobFile;
|
||||
|
||||
/**
|
||||
* 店铺实体类, 实现序列化, Activity之间实现传递
|
||||
* @date 2014-4-24
|
||||
* @author Stone
|
||||
*/
|
||||
public class Shop extends BmobObject implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = -8796635595320697255L;
|
||||
|
||||
private String userID; // 主人
|
||||
private String type; // 类型(11代表第一个GridView中的第一个)
|
||||
private String name; // 店名
|
||||
private String location; // 地理位置
|
||||
private String phone; // 联系电话
|
||||
private String info; // 简介
|
||||
private String sale; // 促销信息
|
||||
private BmobFile picShop; // 商店主图
|
||||
|
||||
public String getUserID() {
|
||||
return userID;
|
||||
}
|
||||
|
||||
public void setUserID(String userID) {
|
||||
this.userID = userID;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public void setInfo(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public String getSale() {
|
||||
return sale;
|
||||
}
|
||||
|
||||
public void setSale(String sale) {
|
||||
this.sale = sale;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
|
||||
/**
|
||||
* 博学堂讲座实体类
|
||||
* @date 2014-5-10
|
||||
* @author Stone
|
||||
*/
|
||||
public class BXTNews extends BmobObject{
|
||||
|
||||
//private String id;
|
||||
|
||||
private String title; //标题
|
||||
private String topic; //讲座主题
|
||||
private String speaker; //主 讲 人
|
||||
private String time; //讲座时间
|
||||
private String location; //讲座地点
|
||||
private String holder1; //主办单位
|
||||
private String holder2; //承办单位
|
||||
private String points; //主讲内容提要
|
||||
private String speakerinfo; //主讲人简介
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public String getTopic() {
|
||||
return topic;
|
||||
}
|
||||
public String getSpeaker() {
|
||||
return speaker;
|
||||
}
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
public String getHolder1() {
|
||||
return holder1;
|
||||
}
|
||||
public String getHolder2() {
|
||||
return holder2;
|
||||
}
|
||||
public String getPoints() {
|
||||
return points;
|
||||
}
|
||||
public String getSpeakerinfo() {
|
||||
return speakerinfo;
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
public void setTopic(String topic) {
|
||||
this.topic = topic;
|
||||
}
|
||||
public void setSpeaker(String speaker) {
|
||||
this.speaker = speaker;
|
||||
}
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
public void setHolder1(String holder1) {
|
||||
this.holder1 = holder1;
|
||||
}
|
||||
public void setHolder2(String holder2) {
|
||||
this.holder2 = holder2;
|
||||
}
|
||||
public void setPoints(String points) {
|
||||
this.points = points;
|
||||
}
|
||||
public void setSpeakerinfo(String speakerinfo) {
|
||||
this.speakerinfo = speakerinfo;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import cn.bmob.v3.BmobUser;
|
||||
|
||||
/**
|
||||
* 用户实体类
|
||||
* @date 2014-4-24
|
||||
* @author Stone
|
||||
*/
|
||||
public class User extends BmobUser {
|
||||
|
||||
public static String userId;
|
||||
|
||||
|
||||
|
||||
private String sex; // 性别
|
||||
private String phone; // 电话
|
||||
private String qq; // QQ
|
||||
private String school = "湖北工业大学"; // 学校
|
||||
private String cademy; // 学院
|
||||
private String dorPart; // 校区
|
||||
private String dorNum; // 寝室号
|
||||
private String state = "未登陆"; // 登录状态
|
||||
private String type = "普通用户"; // 用户类型(普通用户、黑名单、中奖者)
|
||||
//private BmobFile picUser; // 头像
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(String sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getQQ() {
|
||||
return qq;
|
||||
}
|
||||
|
||||
public void setQQ(String qq) {
|
||||
this.qq = qq;
|
||||
}
|
||||
|
||||
public String getSchool() {
|
||||
return school;
|
||||
}
|
||||
|
||||
public void setSchool(String school) {
|
||||
this.school = school;
|
||||
}
|
||||
|
||||
public String getCademy() {
|
||||
return cademy;
|
||||
}
|
||||
|
||||
public void setCademy(String cademy) {
|
||||
this.cademy = cademy;
|
||||
}
|
||||
|
||||
public String getDorPart() {
|
||||
return dorPart;
|
||||
}
|
||||
|
||||
public void setDorPart(String dorPart) {
|
||||
this.dorPart = dorPart;
|
||||
}
|
||||
|
||||
public String getDorNum() {
|
||||
return dorNum;
|
||||
}
|
||||
|
||||
public void setDorNum(String dorNum) {
|
||||
this.dorNum = dorNum;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
|
||||
/**
|
||||
* 店铺评论实体类
|
||||
* @date 2014-5-3
|
||||
* @author Stone
|
||||
*/
|
||||
public class SComment extends BmobObject {
|
||||
|
||||
// private String id;
|
||||
// private String time;
|
||||
|
||||
private String shopID;
|
||||
private String shopName;
|
||||
private String userID;
|
||||
private String userName;
|
||||
private String content;
|
||||
|
||||
public String getShopID() {
|
||||
return shopID;
|
||||
}
|
||||
|
||||
public void setShopID(String shopID) {
|
||||
this.shopID = shopID;
|
||||
}
|
||||
|
||||
public String getShopName() {
|
||||
return shopName;
|
||||
}
|
||||
|
||||
public void setShopName(String shopName) {
|
||||
this.shopName = shopName;
|
||||
}
|
||||
|
||||
public String getUserID() {
|
||||
return userID;
|
||||
}
|
||||
|
||||
public void setUserID(String userID) {
|
||||
this.userID = userID;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
|
||||
/**
|
||||
* 博学堂讲座实体类
|
||||
* @date 2014-5-10
|
||||
* @author Stone
|
||||
*/
|
||||
public class BXTNews extends BmobObject{
|
||||
|
||||
//private String id;
|
||||
|
||||
private String title; //标题
|
||||
private String topic; //讲座主题
|
||||
private String speaker; //主 讲 人
|
||||
private String time; //讲座时间
|
||||
private String location; //讲座地点
|
||||
private String holder1; //主办单位
|
||||
private String holder2; //承办单位
|
||||
private String points; //主讲内容提要
|
||||
private String speakerinfo; //主讲人简介
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public String getTopic() {
|
||||
return topic;
|
||||
}
|
||||
public String getSpeaker() {
|
||||
return speaker;
|
||||
}
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
public String getHolder1() {
|
||||
return holder1;
|
||||
}
|
||||
public String getHolder2() {
|
||||
return holder2;
|
||||
}
|
||||
public String getPoints() {
|
||||
return points;
|
||||
}
|
||||
public String getSpeakerinfo() {
|
||||
return speakerinfo;
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
public void setTopic(String topic) {
|
||||
this.topic = topic;
|
||||
}
|
||||
public void setSpeaker(String speaker) {
|
||||
this.speaker = speaker;
|
||||
}
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
public void setHolder1(String holder1) {
|
||||
this.holder1 = holder1;
|
||||
}
|
||||
public void setHolder2(String holder2) {
|
||||
this.holder2 = holder2;
|
||||
}
|
||||
public void setPoints(String points) {
|
||||
this.points = points;
|
||||
}
|
||||
public void setSpeakerinfo(String speakerinfo) {
|
||||
this.speakerinfo = speakerinfo;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,756 @@
|
|||
package com.stone.util;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.ContentUris;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Bitmap.CompressFormat;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
import junit.framework.Assert;
|
||||
|
||||
/**
|
||||
* 工具类
|
||||
*
|
||||
* @date 2014-5-9
|
||||
* @author Stone
|
||||
*/
|
||||
public class Util {
|
||||
|
||||
/**
|
||||
* 判断电话号码是否有效
|
||||
*
|
||||
* @param phoneNumber
|
||||
* @return true 有效 / false 无效
|
||||
*/
|
||||
public static boolean isPhoneNumberValid(String phoneNumber) {
|
||||
|
||||
boolean isValid = false;
|
||||
|
||||
String expression = "((^(13|15|18)[0-9]{9}$)|(^0[1,2]{1}\\d{1}-?\\d{8}$)|(^0[3-9] {1}\\d{2}-?\\d{7,8}$)|(^0[1,2]{1}\\d{1}-?\\d{8}-(\\d{1,4})$)|(^0[3-9]{1}\\d{2}-? \\d{7,8}-(\\d{1,4})$))";
|
||||
CharSequence inputStr = phoneNumber;
|
||||
|
||||
Pattern pattern = Pattern.compile(expression);
|
||||
Matcher matcher = pattern.matcher(inputStr);
|
||||
|
||||
if (matcher.matches()) {
|
||||
isValid = true;
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
|
||||
// 判断网络是否连接
|
||||
public static boolean isNetworkConnected(Context context) {
|
||||
if (context != null) {
|
||||
ConnectivityManager mConnectivityManager = (ConnectivityManager) context
|
||||
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo mNetworkInfo = mConnectivityManager
|
||||
.getActiveNetworkInfo();
|
||||
if (mNetworkInfo != null) {
|
||||
return mNetworkInfo.isAvailable();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final String TAG = "SDK_Sample.Util";
|
||||
|
||||
private static Dialog mProgressDialog;
|
||||
private static Toast mToast;
|
||||
|
||||
/* Convert byte[] to hex string.这里我们可以将byte转换成int,然后利用Integer.toHexString(int)来转换成16进制字符串。
|
||||
* @param src byte[] data
|
||||
* @return hex string
|
||||
*/
|
||||
public static String bytesToHexString(byte[] src){
|
||||
StringBuilder stringBuilder = new StringBuilder("");
|
||||
if (src == null || src.length <= 0) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < src.length; i++) {
|
||||
int v = src[i] & 0xFF;
|
||||
String hv = Integer.toHexString(v);
|
||||
if (hv.length() < 2) {
|
||||
stringBuilder.append(0);
|
||||
}
|
||||
stringBuilder.append(hv);
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
/**
|
||||
* Convert hex string to byte[]
|
||||
* @param hexString the hex string
|
||||
* @return byte[]
|
||||
*/
|
||||
public static byte[] hexStringToBytes(String hexString) {
|
||||
if (hexString == null || hexString.equals("")) {
|
||||
return null;
|
||||
}
|
||||
hexString = hexString.toUpperCase();
|
||||
int length = hexString.length() / 2;
|
||||
char[] hexChars = hexString.toCharArray();
|
||||
byte[] d = new byte[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
int pos = i * 2;
|
||||
d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
|
||||
}
|
||||
return d;
|
||||
}
|
||||
/**
|
||||
* Convert char to byte
|
||||
* @param c char
|
||||
* @return byte
|
||||
*/
|
||||
private static byte charToByte(char c) {
|
||||
return (byte) "0123456789ABCDEF".indexOf(c);
|
||||
}
|
||||
|
||||
/*
|
||||
* 16进制数字字符集
|
||||
*/
|
||||
private static String hexString="0123456789ABCDEF";
|
||||
/*
|
||||
* 将字符串编码成16进制数字,适用于所有字符(包括中文)
|
||||
*/
|
||||
public static String toHexString(String str)
|
||||
{
|
||||
//根据默认编码获取字节数组
|
||||
byte[] bytes = null;
|
||||
try {
|
||||
bytes = str.getBytes("UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (bytes == null) return null;
|
||||
StringBuilder sb=new StringBuilder(bytes.length*2);
|
||||
//将字节数组中每个字节拆解成2位16进制整数
|
||||
for(int i=0;i<bytes.length;i++)
|
||||
{
|
||||
sb.append(hexString.charAt((bytes[i]&0xf0)>>4));
|
||||
sb.append(hexString.charAt((bytes[i]&0x0f)>>0));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
//转换十六进制编码为字符串
|
||||
public static String hexToString(String s)
|
||||
{
|
||||
if("0x".equals(s.substring(0, 2)))
|
||||
{
|
||||
s =s.substring(2);
|
||||
}
|
||||
byte[] baKeyword = new byte[s.length()/2];
|
||||
for(int i = 0; i < baKeyword.length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
baKeyword[i] = (byte)(0xff & Integer.parseInt(s.substring(i*2, i*2+2),16));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
s = new String(baKeyword, "utf-8");//UTF-16le:Not
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
e1.printStackTrace();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public static byte[] bmpToByteArray(final Bitmap bmp, final boolean needRecycle) {
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
bmp.compress(CompressFormat.PNG, 100, output);
|
||||
if (needRecycle) {
|
||||
bmp.recycle();
|
||||
}
|
||||
|
||||
byte[] result = output.toByteArray();
|
||||
try {
|
||||
output.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static byte[] getHtmlByteArray(final String url) {
|
||||
URL htmlUrl = null;
|
||||
InputStream inStream = null;
|
||||
try {
|
||||
htmlUrl = new URL(url);
|
||||
URLConnection connection = htmlUrl.openConnection();
|
||||
HttpURLConnection httpConnection = (HttpURLConnection)connection;
|
||||
int responseCode = httpConnection.getResponseCode();
|
||||
if(responseCode == HttpURLConnection.HTTP_OK){
|
||||
inStream = httpConnection.getInputStream();
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
byte[] data = inputStreamToByte(inStream);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public static byte[] inputStreamToByte(InputStream is) {
|
||||
try{
|
||||
ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
|
||||
int ch;
|
||||
while ((ch = is.read()) != -1) {
|
||||
bytestream.write(ch);
|
||||
}
|
||||
byte imgdata[] = bytestream.toByteArray();
|
||||
bytestream.close();
|
||||
return imgdata;
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static byte[] readFromFile(String fileName, int offset, int len) {
|
||||
if (fileName == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
File file = new File(fileName);
|
||||
if (!file.exists()) {
|
||||
Log.i(TAG, "readFromFile: file not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (len == -1) {
|
||||
len = (int) file.length();
|
||||
}
|
||||
|
||||
Log.d(TAG, "readFromFile : offset = " + offset + " len = " + len + " offset + len = " + (offset + len));
|
||||
|
||||
if(offset <0){
|
||||
Log.e(TAG, "readFromFile invalid offset:" + offset);
|
||||
return null;
|
||||
}
|
||||
if(len <=0 ){
|
||||
Log.e(TAG, "readFromFile invalid len:" + len);
|
||||
return null;
|
||||
}
|
||||
if(offset + len > (int) file.length()){
|
||||
Log.e(TAG, "readFromFile invalid file len:" + file.length());
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] b = null;
|
||||
try {
|
||||
RandomAccessFile in = new RandomAccessFile(fileName, "r");
|
||||
b = new byte[len];
|
||||
in.seek(offset);
|
||||
in.readFully(b);
|
||||
in.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "readFromFile : errMsg = " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
public static int computeSampleSize(BitmapFactory.Options options,
|
||||
|
||||
int minSideLength, int maxNumOfPixels) {
|
||||
|
||||
int initialSize = computeInitialSampleSize(options, minSideLength,
|
||||
|
||||
maxNumOfPixels);
|
||||
|
||||
int roundedSize;
|
||||
|
||||
if (initialSize <= 8) {
|
||||
|
||||
roundedSize = 1;
|
||||
|
||||
while (roundedSize < initialSize) {
|
||||
|
||||
roundedSize <<= 1;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
roundedSize = (initialSize + 7) / 8 * 8;
|
||||
|
||||
}
|
||||
|
||||
return roundedSize;
|
||||
}
|
||||
|
||||
private static int computeInitialSampleSize(BitmapFactory.Options options,
|
||||
|
||||
int minSideLength, int maxNumOfPixels) {
|
||||
|
||||
double w = options.outWidth;
|
||||
|
||||
double h = options.outHeight;
|
||||
|
||||
int lowerBound = (maxNumOfPixels == -1) ? 1 :
|
||||
|
||||
(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) {
|
||||
|
||||
// return the larger one when there is no overlapping zone.
|
||||
|
||||
return lowerBound;
|
||||
|
||||
}
|
||||
|
||||
if ((maxNumOfPixels == -1) &&
|
||||
|
||||
(minSideLength == -1)) {
|
||||
|
||||
return 1;
|
||||
|
||||
} else if (minSideLength == -1) {
|
||||
|
||||
return lowerBound;
|
||||
|
||||
} else {
|
||||
|
||||
return upperBound;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 以最省内存的方式读取图片
|
||||
*/
|
||||
public static Bitmap readBitmap(final String path){
|
||||
try{
|
||||
FileInputStream stream = new FileInputStream(new File(path+"test.jpg"));
|
||||
BitmapFactory.Options opts = new BitmapFactory.Options();
|
||||
opts.inSampleSize = 8;
|
||||
opts.inPurgeable=true;
|
||||
opts.inInputShareable=true;
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(stream , null, opts);
|
||||
return bitmap;
|
||||
} catch (OutOfMemoryError e) {
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
Assert.assertTrue(path != null && !path.equals("") && height > 0 && width > 0);
|
||||
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
|
||||
try {
|
||||
options.inJustDecodeBounds = true;
|
||||
Bitmap tmp = BitmapFactory.decodeFile(path, options);
|
||||
if (tmp != null) {
|
||||
tmp.recycle();
|
||||
tmp = null;
|
||||
}
|
||||
|
||||
Log.d(TAG, "extractThumbNail: round=" + width + "x" + height + ", crop=" + crop);
|
||||
final double beY = options.outHeight * 1.0 / height;
|
||||
final double beX = options.outWidth * 1.0 / width;
|
||||
Log.d(TAG, "extractThumbNail: extract beX = " + beX + ", beY = " + beY);
|
||||
options.inSampleSize = (int) (crop ? (beY > beX ? beX : beY) : (beY < beX ? beX : beY));
|
||||
if (options.inSampleSize <= 1) {
|
||||
options.inSampleSize = 1;
|
||||
}
|
||||
|
||||
// NOTE: out of memory error
|
||||
while (options.outHeight * options.outWidth / options.inSampleSize > MAX_DECODE_PICTURE_SIZE) {
|
||||
options.inSampleSize++;
|
||||
}
|
||||
|
||||
int newHeight = height;
|
||||
int newWidth = width;
|
||||
if (crop) {
|
||||
if (beY > beX) {
|
||||
newHeight = (int) (newWidth * 1.0 * options.outHeight / options.outWidth);
|
||||
} else {
|
||||
newWidth = (int) (newHeight * 1.0 * options.outWidth / options.outHeight);
|
||||
}
|
||||
} else {
|
||||
if (beY < beX) {
|
||||
newHeight = (int) (newWidth * 1.0 * options.outHeight / options.outWidth);
|
||||
} else {
|
||||
newWidth = (int) (newHeight * 1.0 * options.outWidth / options.outHeight);
|
||||
}
|
||||
}
|
||||
|
||||
options.inJustDecodeBounds = false;
|
||||
|
||||
Log.i(TAG, "bitmap required size=" + newWidth + "x" + newHeight + ", orig=" + options.outWidth + "x" + options.outHeight + ", sample=" + options.inSampleSize);
|
||||
Bitmap bm = BitmapFactory.decodeFile(path, options);
|
||||
if (bm == null) {
|
||||
Log.e(TAG, "bitmap decode failed");
|
||||
return null;
|
||||
}
|
||||
|
||||
Log.i(TAG, "bitmap decoded size=" + bm.getWidth() + "x" + bm.getHeight());
|
||||
final Bitmap scale = Bitmap.createScaledBitmap(bm, newWidth, newHeight, true);
|
||||
if (scale != null) {
|
||||
bm.recycle();
|
||||
bm = scale;
|
||||
}
|
||||
|
||||
if (crop) {
|
||||
final Bitmap cropped = Bitmap.createBitmap(bm, (bm.getWidth() - width) >> 1, (bm.getHeight() - height) >> 1, width, height);
|
||||
if (cropped == null) {
|
||||
return bm;
|
||||
}
|
||||
|
||||
bm.recycle();
|
||||
bm = cropped;
|
||||
Log.i(TAG, "bitmap croped size=" + bm.getWidth() + "x" + bm.getHeight());
|
||||
}
|
||||
return bm;
|
||||
|
||||
} catch (final OutOfMemoryError e) {
|
||||
Log.e(TAG, "decode bitmap failed: " + e.getMessage());
|
||||
options = null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final void showResultDialog(Context context, String msg,
|
||||
String title) {
|
||||
if(msg == null) return;
|
||||
String rmsg = msg.replace(",", "\n");
|
||||
Log.d("Util", rmsg);
|
||||
new AlertDialog.Builder(context).setTitle(title).setMessage(rmsg)
|
||||
.setNegativeButton("知道了", null).create().show();
|
||||
}
|
||||
|
||||
public static final void showProgressDialog(Context context, String title,
|
||||
String message) {
|
||||
dismissDialog();
|
||||
if (TextUtils.isEmpty(title)) {
|
||||
title = "请稍候";
|
||||
}
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "正在加载...";
|
||||
}
|
||||
mProgressDialog = ProgressDialog.show(context, title, message);
|
||||
}
|
||||
|
||||
public static AlertDialog showConfirmCancelDialog(Context context,
|
||||
String title, String message,
|
||||
DialogInterface.OnClickListener posListener) {
|
||||
AlertDialog dlg = new AlertDialog.Builder(context).setMessage(message)
|
||||
.setPositiveButton("确认", posListener)
|
||||
.setNegativeButton("取消", null).create();
|
||||
dlg.setCanceledOnTouchOutside(false);
|
||||
dlg.show();
|
||||
return dlg;
|
||||
}
|
||||
|
||||
public static final void dismissDialog() {
|
||||
if (mProgressDialog != null) {
|
||||
mProgressDialog.dismiss();
|
||||
mProgressDialog = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印消息并且用Toast显示消息
|
||||
*
|
||||
* @param activity
|
||||
* @param message
|
||||
* @param logLevel
|
||||
* 填d, w, e分别代表debug, warn, error; 默认是debug
|
||||
*/
|
||||
public static final void toastMessage(final Activity activity,
|
||||
final String message, String logLevel) {
|
||||
if ("w".equals(logLevel)) {
|
||||
Log.w("sdkDemo", message);
|
||||
} else if ("e".equals(logLevel)) {
|
||||
Log.e("sdkDemo", message);
|
||||
} else {
|
||||
Log.d("sdkDemo", message);
|
||||
}
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// TODO Auto-generated method stub
|
||||
if (mToast != null) {
|
||||
mToast.cancel();
|
||||
mToast = null;
|
||||
}
|
||||
mToast = Toast.makeText(activity, message, Toast.LENGTH_SHORT);
|
||||
mToast.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印消息并且用Toast显示消息
|
||||
*
|
||||
* @param activity
|
||||
* @param message
|
||||
* @param logLevel
|
||||
* 填d, w, e分别代表debug, warn, error; 默认是debug
|
||||
*/
|
||||
public static final void toastMessage(final Activity activity,
|
||||
final String message) {
|
||||
toastMessage(activity, message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据一个网络连接(String)获取bitmap图像
|
||||
*
|
||||
* @param imageUri
|
||||
* @return
|
||||
* @throws MalformedURLException
|
||||
*/
|
||||
public static Bitmap getbitmap(String imageUri) {
|
||||
Log.v(TAG, "getbitmap:" + imageUri);
|
||||
// 显示网络上的图片
|
||||
Bitmap bitmap = null;
|
||||
try {
|
||||
URL myFileUrl = new URL(imageUri);
|
||||
HttpURLConnection conn = (HttpURLConnection) myFileUrl
|
||||
.openConnection();
|
||||
conn.setDoInput(true);
|
||||
conn.connect();
|
||||
InputStream is = conn.getInputStream();
|
||||
bitmap = BitmapFactory.decodeStream(is);
|
||||
is.close();
|
||||
|
||||
Log.v(TAG, "image download finished." + imageUri);
|
||||
} catch (OutOfMemoryError e) {
|
||||
e.printStackTrace();
|
||||
bitmap = null;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Log.v(TAG, "getbitmap bmp fail---");
|
||||
bitmap = null;
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public static void release() {
|
||||
mProgressDialog = null;
|
||||
mToast = null;
|
||||
}
|
||||
|
||||
// =========
|
||||
// =通过URI获取本地图片的path
|
||||
// =兼容android 5.0
|
||||
// ==========
|
||||
|
||||
public static String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
|
||||
public static int Build_VERSION_KITKAT = 19;
|
||||
public static String getPath(final Context context, final Uri uri) {
|
||||
|
||||
final boolean isKitKat = Build.VERSION.SDK_INT >= 19;
|
||||
|
||||
// DocumentProvider
|
||||
if (isKitKat && isDocumentUri(context, uri)) {
|
||||
// ExternalStorageProvider
|
||||
if (isExternalStorageDocument(uri)) {
|
||||
final String docId = getDocumentId(uri);
|
||||
final String[] split = docId.split(":");
|
||||
final String type = split[0];
|
||||
|
||||
if ("primary".equalsIgnoreCase(type)) {
|
||||
return Environment.getExternalStorageDirectory() + "/" + split[1];
|
||||
}
|
||||
|
||||
}
|
||||
// DownloadsProvider
|
||||
else if (isDownloadsDocument(uri)) {
|
||||
|
||||
final String id = getDocumentId(uri);
|
||||
final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"),
|
||||
Long.valueOf(id));
|
||||
|
||||
return getDataColumn(context, contentUri, null, null);
|
||||
}
|
||||
// MediaProvider
|
||||
else if (isMediaDocument(uri)) {
|
||||
final String docId = getDocumentId(uri);
|
||||
final String[] split = docId.split(":");
|
||||
final String type = split[0];
|
||||
|
||||
Uri contentUri = null;
|
||||
if ("image".equals(type)) {
|
||||
contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||
} else if ("video".equals(type)) {
|
||||
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
|
||||
} else if ("audio".equals(type)) {
|
||||
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
|
||||
}
|
||||
|
||||
final String selection = "_id=?";
|
||||
final String[] selectionArgs = new String[] { split[1] };
|
||||
|
||||
return getDataColumn(context, contentUri, selection, selectionArgs);
|
||||
}
|
||||
}
|
||||
// MediaStore (and general)
|
||||
else if ("content".equalsIgnoreCase(uri.getScheme())) {
|
||||
|
||||
// Return the remote address
|
||||
if (isGooglePhotosUri(uri))
|
||||
return uri.getLastPathSegment();
|
||||
|
||||
return getDataColumn(context, uri, null, null);
|
||||
}
|
||||
// File
|
||||
else if ("file".equalsIgnoreCase(uri.getScheme())) {
|
||||
return uri.getPath();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final String PATH_DOCUMENT = "document";
|
||||
|
||||
/**
|
||||
* Test if the given URI represents a {@link Document} backed by a
|
||||
* {@link DocumentsProvider}.
|
||||
*/
|
||||
private static boolean isDocumentUri(Context context, Uri uri) {
|
||||
final List<String> paths = uri.getPathSegments();
|
||||
if (paths.size() < 2) {
|
||||
return false;
|
||||
}
|
||||
if (!PATH_DOCUMENT.equals(paths.get(0))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static String getDocumentId(Uri documentUri) {
|
||||
final List<String> paths = documentUri.getPathSegments();
|
||||
if (paths.size() < 2) {
|
||||
throw new IllegalArgumentException("Not a document: " + documentUri);
|
||||
}
|
||||
if (!PATH_DOCUMENT.equals(paths.get(0))) {
|
||||
throw new IllegalArgumentException("Not a document: " + documentUri);
|
||||
}
|
||||
return paths.get(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of the data column for this Uri. This is useful for
|
||||
* MediaStore Uris, and other file-based ContentProviders.
|
||||
*
|
||||
* @param context
|
||||
* The context.
|
||||
* @param uri
|
||||
* The Uri to query.
|
||||
* @param selection
|
||||
* (Optional) Filter used in the query.
|
||||
* @param selectionArgs
|
||||
* (Optional) Selection arguments used in the query.
|
||||
* [url=home.php?mod=space&uid=7300]@return[/url] The value of
|
||||
* the _data column, which is typically a file path.
|
||||
*/
|
||||
public static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {
|
||||
|
||||
Cursor cursor = null;
|
||||
final String column = "_data";
|
||||
final String[] projection = { column };
|
||||
|
||||
try {
|
||||
cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
final int index = cursor.getColumnIndexOrThrow(column);
|
||||
return cursor.getString(index);
|
||||
}
|
||||
} finally {
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri
|
||||
* The Uri to check.
|
||||
* @return Whether the Uri authority is ExternalStorageProvider.
|
||||
*/
|
||||
public static boolean isExternalStorageDocument(Uri uri) {
|
||||
return "com.android.externalstorage.documents".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri
|
||||
* The Uri to check.
|
||||
* @return Whether the Uri authority is DownloadsProvider.
|
||||
*/
|
||||
public static boolean isDownloadsDocument(Uri uri) {
|
||||
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri
|
||||
* The Uri to check.
|
||||
* @return Whether the Uri authority is MediaProvider.
|
||||
*/
|
||||
public static boolean isMediaDocument(Uri uri) {
|
||||
return "com.android.providers.media.documents".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri
|
||||
* The Uri to check.
|
||||
* @return Whether the Uri authority is Google Photos.
|
||||
*/
|
||||
public static boolean isGooglePhotosUri(Uri uri) {
|
||||
return "com.google.android.apps.photos.content".equals(uri.getAuthority());
|
||||
}
|
||||
}
|
14
readme.txt
14
readme.txt
|
@ -1,14 +0,0 @@
|
|||
1. bmob_test_pull——后台更新代码测试1
|
||||
2. Shop ——小组任务代码
|
||||
3. 文档中:王尚文的project和许家铭的project
|
||||
19:41 2016/8/18
|
||||
4. bmob_test_pull——云端数据下载显示代码测试1——成功
|
||||
13:16 2016/8/19
|
||||
5. 文档更新,第三章修改,增加需求分析设计用例图
|
||||
8:38 2016/8/20
|
||||
6. Shop代码更新,增加“学校通知”功能;整合覃佳明同学
|
||||
图书馆代码,修正部分冲突;增加图书馆,学校通知,
|
||||
商店,商品的云端数据
|
||||
18:33 2016/8/22
|
||||
7. 修改需求设计用例图,软件体系结构包图,代码问题修正
|
||||
9:06 2016/8/23
|
9
test.txt
9
test.txt
|
@ -1,9 +0,0 @@
|
|||
11:17 2016/8/1711:17 2016/8/17
|
||||
11:17 2016/8/17
|
||||
11:18 2016/8/17
|
||||
|
||||
1. 在标记为“对勾”的第一个文件夹下commit
|
||||
2. commit只是提交到本地
|
||||
3. 在相同的文件夹上进行push即可
|
||||
|
||||
4.change!8:20 2016/8/18
|
Binary file not shown.
Before Width: | Height: | Size: 21 KiB |
|
@ -3,6 +3,7 @@
|
|||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,78 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
|
||||
/**
|
||||
* 博学堂讲座实体类
|
||||
* @date 2014-5-10
|
||||
* @author Stone
|
||||
*/
|
||||
public class BXTNews extends BmobObject{
|
||||
|
||||
//private String id;
|
||||
|
||||
private String title; //标题
|
||||
private String topic; //讲座主题
|
||||
private String speaker; //主 讲 人
|
||||
private String time; //讲座时间
|
||||
private String location; //讲座地点
|
||||
private String holder1; //主办单位
|
||||
private String holder2; //承办单位
|
||||
private String points; //主讲内容提要
|
||||
private String speakerinfo; //主讲人简介
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public String getTopic() {
|
||||
return topic;
|
||||
}
|
||||
public String getSpeaker() {
|
||||
return speaker;
|
||||
}
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
public String getHolder1() {
|
||||
return holder1;
|
||||
}
|
||||
public String getHolder2() {
|
||||
return holder2;
|
||||
}
|
||||
public String getPoints() {
|
||||
return points;
|
||||
}
|
||||
public String getSpeakerinfo() {
|
||||
return speakerinfo;
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
public void setTopic(String topic) {
|
||||
this.topic = topic;
|
||||
}
|
||||
public void setSpeaker(String speaker) {
|
||||
this.speaker = speaker;
|
||||
}
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
public void setHolder1(String holder1) {
|
||||
this.holder1 = holder1;
|
||||
}
|
||||
public void setHolder2(String holder2) {
|
||||
this.holder2 = holder2;
|
||||
}
|
||||
public void setPoints(String points) {
|
||||
this.points = points;
|
||||
}
|
||||
public void setSpeakerinfo(String speakerinfo) {
|
||||
this.speakerinfo = speakerinfo;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
|
||||
/**
|
||||
* 博学堂讲座实体类
|
||||
* @date 2014-5-10
|
||||
* @author Stone
|
||||
*/
|
||||
public class BXTNews extends BmobObject{
|
||||
|
||||
//private String id;
|
||||
|
||||
private String title; //标题
|
||||
private String topic; //讲座主题
|
||||
private String speaker; //主 讲 人
|
||||
private String time; //讲座时间
|
||||
private String location; //讲座地点
|
||||
private String holder1; //主办单位
|
||||
private String holder2; //承办单位
|
||||
private String points; //主讲内容提要
|
||||
private String speakerinfo; //主讲人简介
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public String getTopic() {
|
||||
return topic;
|
||||
}
|
||||
public String getSpeaker() {
|
||||
return speaker;
|
||||
}
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
public String getHolder1() {
|
||||
return holder1;
|
||||
}
|
||||
public String getHolder2() {
|
||||
return holder2;
|
||||
}
|
||||
public String getPoints() {
|
||||
return points;
|
||||
}
|
||||
public String getSpeakerinfo() {
|
||||
return speakerinfo;
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
public void setTopic(String topic) {
|
||||
this.topic = topic;
|
||||
}
|
||||
public void setSpeaker(String speaker) {
|
||||
this.speaker = speaker;
|
||||
}
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
public void setHolder1(String holder1) {
|
||||
this.holder1 = holder1;
|
||||
}
|
||||
public void setHolder2(String holder2) {
|
||||
this.holder2 = holder2;
|
||||
}
|
||||
public void setPoints(String points) {
|
||||
this.points = points;
|
||||
}
|
||||
public void setSpeakerinfo(String speakerinfo) {
|
||||
this.speakerinfo = speakerinfo;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
|
||||
/**
|
||||
* 博学堂讲座实体类
|
||||
* @date 2014-5-10
|
||||
* @author Stone
|
||||
*/
|
||||
public class BXTNews extends BmobObject{
|
||||
|
||||
//private String id;
|
||||
|
||||
private String title; //标题
|
||||
private String topic; //讲座主题
|
||||
private String speaker; //主 讲 人
|
||||
private String time; //讲座时间
|
||||
private String location; //讲座地点
|
||||
private String holder1; //主办单位
|
||||
private String holder2; //承办单位
|
||||
private String points; //主讲内容提要
|
||||
private String speakerinfo; //主讲人简介
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public String getTopic() {
|
||||
return topic;
|
||||
}
|
||||
public String getSpeaker() {
|
||||
return speaker;
|
||||
}
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
public String getHolder1() {
|
||||
return holder1;
|
||||
}
|
||||
public String getHolder2() {
|
||||
return holder2;
|
||||
}
|
||||
public String getPoints() {
|
||||
return points;
|
||||
}
|
||||
public String getSpeakerinfo() {
|
||||
return speakerinfo;
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
public void setTopic(String topic) {
|
||||
this.topic = topic;
|
||||
}
|
||||
public void setSpeaker(String speaker) {
|
||||
this.speaker = speaker;
|
||||
}
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
public void setHolder1(String holder1) {
|
||||
this.holder1 = holder1;
|
||||
}
|
||||
public void setHolder2(String holder2) {
|
||||
this.holder2 = holder2;
|
||||
}
|
||||
public void setPoints(String points) {
|
||||
this.points = points;
|
||||
}
|
||||
public void setSpeakerinfo(String speakerinfo) {
|
||||
this.speakerinfo = speakerinfo;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
import cn.bmob.v3.datatype.BmobFile;
|
||||
|
||||
/**
|
||||
* 商品实体类
|
||||
* @date 2014-4-24
|
||||
* @author Stone
|
||||
*/
|
||||
public class Good extends BmobObject implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = -3248168273019127389L;
|
||||
|
||||
//private String id; 商品ID, 默认
|
||||
|
||||
private String shopID = ""; // 商店ID
|
||||
private String shopName = ""; //商店名称
|
||||
private String type = ""; // 类型
|
||||
private String name = ""; // 名称
|
||||
private String price = ""; // 价格
|
||||
private BmobFile picGood = null; // 商品主图
|
||||
|
||||
public Good(String name, String price) {
|
||||
this.name = name;
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public String getShopID() {
|
||||
return shopID;
|
||||
}
|
||||
|
||||
public void setShopID(String shopID) {
|
||||
this.shopID = shopID;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(String price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
import cn.bmob.v3.datatype.BmobFile;
|
||||
|
||||
/**
|
||||
* 商品实体类
|
||||
* @date 2014-4-24
|
||||
* @author Stone
|
||||
*/
|
||||
public class Good extends BmobObject implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = -3248168273019127389L;
|
||||
|
||||
//private String id; 商品ID, 默认
|
||||
|
||||
private String shopID = ""; // 商店ID
|
||||
private String shopName = ""; //商店名称
|
||||
private String type = ""; // 类型
|
||||
private String name = ""; // 名称
|
||||
private String price = ""; // 价格
|
||||
private BmobFile picGood = null; // 商品主图
|
||||
|
||||
public Good(String name, String price) {
|
||||
this.name = name;
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public String getShopID() {
|
||||
return shopID;
|
||||
}
|
||||
|
||||
public void setShopID(String shopID) {
|
||||
this.shopID = shopID;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(String price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
import cn.bmob.v3.datatype.BmobFile;
|
||||
|
||||
/**
|
||||
* 商品实体类
|
||||
* @date 2014-4-24
|
||||
* @author Stone
|
||||
*/
|
||||
public class Good extends BmobObject implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = -3248168273019127389L;
|
||||
|
||||
//private String id; 商品ID, 默认
|
||||
|
||||
private String shopID = ""; // 商店ID
|
||||
private String shopName = ""; //商店名称
|
||||
private String type = ""; // 类型
|
||||
private String name = ""; // 名称
|
||||
private String price = ""; // 价格
|
||||
private BmobFile picGood = null; // 商品主图
|
||||
|
||||
public Good(String name, String price) {
|
||||
this.name = name;
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public String getShopID() {
|
||||
return shopID;
|
||||
}
|
||||
|
||||
public void setShopID(String shopID) {
|
||||
this.shopID = shopID;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(String price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
|
||||
/**
|
||||
* 首页校内新闻实体类
|
||||
*
|
||||
* @date 2014-5-3
|
||||
* @author Stone
|
||||
*/
|
||||
public class News extends BmobObject {
|
||||
|
||||
// private String id;
|
||||
// private String time;
|
||||
|
||||
private String type; // 新闻类型
|
||||
private String title; // 新闻标题
|
||||
private String author; // 新闻作者
|
||||
private String content; // 新闻内容
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
|
||||
/**
|
||||
* 首页校内新闻实体类
|
||||
*
|
||||
* @date 2014-5-3
|
||||
* @author Stone
|
||||
*/
|
||||
public class News extends BmobObject {
|
||||
|
||||
// private String id;
|
||||
// private String time;
|
||||
|
||||
private String type; // 新闻类型
|
||||
private String title; // 新闻标题
|
||||
private String author; // 新闻作者
|
||||
private String content; // 新闻内容
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
|
||||
/**
|
||||
* 首页校内新闻实体类
|
||||
*
|
||||
* @date 2014-5-3
|
||||
* @author Stone
|
||||
*/
|
||||
public class News extends BmobObject {
|
||||
|
||||
// private String id;
|
||||
// private String time;
|
||||
|
||||
private String type; // 新闻类型
|
||||
private String title; // 新闻标题
|
||||
private String author; // 新闻作者
|
||||
private String content; // 新闻内容
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
|
||||
/**
|
||||
* 店铺评论实体类
|
||||
* @date 2014-5-3
|
||||
* @author Stone
|
||||
*/
|
||||
public class SComment extends BmobObject {
|
||||
|
||||
// private String id;
|
||||
// private String time;
|
||||
|
||||
private String shopID;
|
||||
private String shopName;
|
||||
private String userID;
|
||||
private String userName;
|
||||
private String content;
|
||||
|
||||
public String getShopID() {
|
||||
return shopID;
|
||||
}
|
||||
|
||||
public void setShopID(String shopID) {
|
||||
this.shopID = shopID;
|
||||
}
|
||||
|
||||
public String getShopName() {
|
||||
return shopName;
|
||||
}
|
||||
|
||||
public void setShopName(String shopName) {
|
||||
this.shopName = shopName;
|
||||
}
|
||||
|
||||
public String getUserID() {
|
||||
return userID;
|
||||
}
|
||||
|
||||
public void setUserID(String userID) {
|
||||
this.userID = userID;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
|
||||
/**
|
||||
* 店铺评论实体类
|
||||
* @date 2014-5-3
|
||||
* @author Stone
|
||||
*/
|
||||
public class SComment extends BmobObject {
|
||||
|
||||
// private String id;
|
||||
// private String time;
|
||||
|
||||
private String shopID;
|
||||
private String shopName;
|
||||
private String userID;
|
||||
private String userName;
|
||||
private String content;
|
||||
|
||||
public String getShopID() {
|
||||
return shopID;
|
||||
}
|
||||
|
||||
public void setShopID(String shopID) {
|
||||
this.shopID = shopID;
|
||||
}
|
||||
|
||||
public String getShopName() {
|
||||
return shopName;
|
||||
}
|
||||
|
||||
public void setShopName(String shopName) {
|
||||
this.shopName = shopName;
|
||||
}
|
||||
|
||||
public String getUserID() {
|
||||
return userID;
|
||||
}
|
||||
|
||||
public void setUserID(String userID) {
|
||||
this.userID = userID;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
|
||||
/**
|
||||
* 店铺评论实体类
|
||||
* @date 2014-5-3
|
||||
* @author Stone
|
||||
*/
|
||||
public class SComment extends BmobObject {
|
||||
|
||||
// private String id;
|
||||
// private String time;
|
||||
|
||||
private String shopID;
|
||||
private String shopName;
|
||||
private String userID;
|
||||
private String userName;
|
||||
private String content;
|
||||
|
||||
public String getShopID() {
|
||||
return shopID;
|
||||
}
|
||||
|
||||
public void setShopID(String shopID) {
|
||||
this.shopID = shopID;
|
||||
}
|
||||
|
||||
public String getShopName() {
|
||||
return shopName;
|
||||
}
|
||||
|
||||
public void setShopName(String shopName) {
|
||||
this.shopName = shopName;
|
||||
}
|
||||
|
||||
public String getUserID() {
|
||||
return userID;
|
||||
}
|
||||
|
||||
public void setUserID(String userID) {
|
||||
this.userID = userID;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
import cn.bmob.v3.datatype.BmobFile;
|
||||
|
||||
/**
|
||||
* 店铺实体类, 实现序列化, Activity之间实现传递
|
||||
* @date 2014-4-24
|
||||
* @author Stone
|
||||
*/
|
||||
public class Shop extends BmobObject implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = -8796635595320697255L;
|
||||
|
||||
private String userID; // 主人
|
||||
private String type; // 类型(11代表第一个GridView中的第一个)
|
||||
private String name; // 店名
|
||||
private String location; // 地理位置
|
||||
private String phone; // 联系电话
|
||||
private String info; // 简介
|
||||
private String sale; // 促销信息
|
||||
private BmobFile picShop; // 商店主图
|
||||
|
||||
public String getUserID() {
|
||||
return userID;
|
||||
}
|
||||
|
||||
public void setUserID(String userID) {
|
||||
this.userID = userID;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public void setInfo(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public String getSale() {
|
||||
return sale;
|
||||
}
|
||||
|
||||
public void setSale(String sale) {
|
||||
this.sale = sale;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
import cn.bmob.v3.datatype.BmobFile;
|
||||
|
||||
/**
|
||||
* 店铺实体类, 实现序列化, Activity之间实现传递
|
||||
* @date 2014-4-24
|
||||
* @author Stone
|
||||
*/
|
||||
public class Shop extends BmobObject implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = -8796635595320697255L;
|
||||
|
||||
private String userID; // 主人
|
||||
private String type; // 类型(11代表第一个GridView中的第一个)
|
||||
private String name; // 店名
|
||||
private String location; // 地理位置
|
||||
private String phone; // 联系电话
|
||||
private String info; // 简介
|
||||
private String sale; // 促销信息
|
||||
private BmobFile picShop; // 商店主图
|
||||
|
||||
public String getUserID() {
|
||||
return userID;
|
||||
}
|
||||
|
||||
public void setUserID(String userID) {
|
||||
this.userID = userID;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public void setInfo(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public String getSale() {
|
||||
return sale;
|
||||
}
|
||||
|
||||
public void setSale(String sale) {
|
||||
this.sale = sale;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
import cn.bmob.v3.datatype.BmobFile;
|
||||
|
||||
/**
|
||||
* 店铺实体类, 实现序列化, Activity之间实现传递
|
||||
* @date 2014-4-24
|
||||
* @author Stone
|
||||
*/
|
||||
public class Shop extends BmobObject implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = -8796635595320697255L;
|
||||
|
||||
private String userID; // 主人
|
||||
private String type; // 类型(11代表第一个GridView中的第一个)
|
||||
private String name; // 店名
|
||||
private String location; // 地理位置
|
||||
private String phone; // 联系电话
|
||||
private String info; // 简介
|
||||
private String sale; // 促销信息
|
||||
private BmobFile picShop; // 商店主图
|
||||
|
||||
public String getUserID() {
|
||||
return userID;
|
||||
}
|
||||
|
||||
public void setUserID(String userID) {
|
||||
this.userID = userID;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public void setInfo(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public String getSale() {
|
||||
return sale;
|
||||
}
|
||||
|
||||
public void setSale(String sale) {
|
||||
this.sale = sale;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import cn.bmob.v3.BmobUser;
|
||||
import cn.bmob.v3.datatype.BmobFile;
|
||||
import cn.bmob.v3.datatype.BmobRelation;
|
||||
|
||||
/**
|
||||
* 用户实体类
|
||||
* @date 2014-4-24
|
||||
* @author Stone
|
||||
*/
|
||||
public class User extends BmobUser {
|
||||
|
||||
public static String userId;
|
||||
|
||||
// 父类中已经存在的属性
|
||||
// private String id;
|
||||
// private String username;
|
||||
// private String password;
|
||||
// private String email;
|
||||
// private String regTime;
|
||||
|
||||
private String sex; // 性别
|
||||
private String phone; // 电话
|
||||
private String qq; // QQ
|
||||
private String school = "湖北工业大学"; // 学校
|
||||
private String cademy; // 学院
|
||||
private String dorPart; // 校区
|
||||
private String dorNum; // 寝室号
|
||||
private String state = "未登陆"; // 登录状态
|
||||
private String type = "普通用户"; // 用户类型(普通用户、黑名单、中奖者)
|
||||
//private BmobFile picUser; // 头像
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(String sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getQQ() {
|
||||
return qq;
|
||||
}
|
||||
|
||||
public void setQQ(String qq) {
|
||||
this.qq = qq;
|
||||
}
|
||||
|
||||
public String getSchool() {
|
||||
return school;
|
||||
}
|
||||
|
||||
public void setSchool(String school) {
|
||||
this.school = school;
|
||||
}
|
||||
|
||||
public String getCademy() {
|
||||
return cademy;
|
||||
}
|
||||
|
||||
public void setCademy(String cademy) {
|
||||
this.cademy = cademy;
|
||||
}
|
||||
|
||||
public String getDorPart() {
|
||||
return dorPart;
|
||||
}
|
||||
|
||||
public void setDorPart(String dorPart) {
|
||||
this.dorPart = dorPart;
|
||||
}
|
||||
|
||||
public String getDorNum() {
|
||||
return dorNum;
|
||||
}
|
||||
|
||||
public void setDorNum(String dorNum) {
|
||||
this.dorNum = dorNum;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import cn.bmob.v3.BmobUser;
|
||||
import cn.bmob.v3.datatype.BmobFile;
|
||||
import cn.bmob.v3.datatype.BmobRelation;
|
||||
|
||||
/**
|
||||
* 用户实体类
|
||||
* @date 2014-4-24
|
||||
* @author Stone
|
||||
*/
|
||||
public class User extends BmobUser {
|
||||
|
||||
public static String userId;
|
||||
|
||||
// 父类中已经存在的属性
|
||||
// private String id;
|
||||
// private String username;
|
||||
// private String password;
|
||||
// private String email;
|
||||
// private String regTime;
|
||||
|
||||
private String sex; // 性别
|
||||
private String phone; // 电话
|
||||
private String qq; // QQ
|
||||
private String school = "湖北工业大学"; // 学校
|
||||
private String cademy; // 学院
|
||||
private String dorPart; // 校区
|
||||
private String dorNum; // 寝室号
|
||||
private String state = "未登陆"; // 登录状态
|
||||
private String type = "普通用户"; // 用户类型(普通用户、黑名单、中奖者)
|
||||
//private BmobFile picUser; // 头像
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(String sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getQQ() {
|
||||
return qq;
|
||||
}
|
||||
|
||||
public void setQQ(String qq) {
|
||||
this.qq = qq;
|
||||
}
|
||||
|
||||
public String getSchool() {
|
||||
return school;
|
||||
}
|
||||
|
||||
public void setSchool(String school) {
|
||||
this.school = school;
|
||||
}
|
||||
|
||||
public String getCademy() {
|
||||
return cademy;
|
||||
}
|
||||
|
||||
public void setCademy(String cademy) {
|
||||
this.cademy = cademy;
|
||||
}
|
||||
|
||||
public String getDorPart() {
|
||||
return dorPart;
|
||||
}
|
||||
|
||||
public void setDorPart(String dorPart) {
|
||||
this.dorPart = dorPart;
|
||||
}
|
||||
|
||||
public String getDorNum() {
|
||||
return dorNum;
|
||||
}
|
||||
|
||||
public void setDorNum(String dorNum) {
|
||||
this.dorNum = dorNum;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import cn.bmob.v3.BmobUser;
|
||||
import cn.bmob.v3.datatype.BmobFile;
|
||||
import cn.bmob.v3.datatype.BmobRelation;
|
||||
|
||||
/**
|
||||
* 用户实体类
|
||||
* @date 2014-4-24
|
||||
* @author Stone
|
||||
*/
|
||||
public class User extends BmobUser {
|
||||
|
||||
public static String userId;
|
||||
|
||||
// 父类中已经存在的属性
|
||||
// private String id;
|
||||
// private String username;
|
||||
// private String password;
|
||||
// private String email;
|
||||
// private String regTime;
|
||||
|
||||
private String sex; // 性别
|
||||
private String phone; // 电话
|
||||
private String qq; // QQ
|
||||
private String school = "湖北工业大学"; // 学校
|
||||
private String cademy; // 学院
|
||||
private String dorPart; // 校区
|
||||
private String dorNum; // 寝室号
|
||||
private String state = "未登陆"; // 登录状态
|
||||
private String type = "普通用户"; // 用户类型(普通用户、黑名单、中奖者)
|
||||
//private BmobFile picUser; // 头像
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(String sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getQQ() {
|
||||
return qq;
|
||||
}
|
||||
|
||||
public void setQQ(String qq) {
|
||||
this.qq = qq;
|
||||
}
|
||||
|
||||
public String getSchool() {
|
||||
return school;
|
||||
}
|
||||
|
||||
public void setSchool(String school) {
|
||||
this.school = school;
|
||||
}
|
||||
|
||||
public String getCademy() {
|
||||
return cademy;
|
||||
}
|
||||
|
||||
public void setCademy(String cademy) {
|
||||
this.cademy = cademy;
|
||||
}
|
||||
|
||||
public String getDorPart() {
|
||||
return dorPart;
|
||||
}
|
||||
|
||||
public void setDorPart(String dorPart) {
|
||||
this.dorPart = dorPart;
|
||||
}
|
||||
|
||||
public String getDorNum() {
|
||||
return dorNum;
|
||||
}
|
||||
|
||||
public void setDorNum(String dorNum) {
|
||||
this.dorNum = dorNum;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,756 @@
|
|||
package com.stone.util;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.ContentUris;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Bitmap.CompressFormat;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
import junit.framework.Assert;
|
||||
|
||||
/**
|
||||
* 工具类
|
||||
*
|
||||
* @date 2014-5-9
|
||||
* @author Stone
|
||||
*/
|
||||
public class Util {
|
||||
|
||||
/**
|
||||
* 判断电话号码是否有效
|
||||
*
|
||||
* @param phoneNumber
|
||||
* @return true 有效 / false 无效
|
||||
*/
|
||||
public static boolean isPhoneNumberValid(String phoneNumber) {
|
||||
|
||||
boolean isValid = false;
|
||||
|
||||
String expression = "((^(13|15|18)[0-9]{9}$)|(^0[1,2]{1}\\d{1}-?\\d{8}$)|(^0[3-9] {1}\\d{2}-?\\d{7,8}$)|(^0[1,2]{1}\\d{1}-?\\d{8}-(\\d{1,4})$)|(^0[3-9]{1}\\d{2}-? \\d{7,8}-(\\d{1,4})$))";
|
||||
CharSequence inputStr = phoneNumber;
|
||||
|
||||
Pattern pattern = Pattern.compile(expression);
|
||||
Matcher matcher = pattern.matcher(inputStr);
|
||||
|
||||
if (matcher.matches()) {
|
||||
isValid = true;
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
|
||||
// 判断网络是否连接
|
||||
public static boolean isNetworkConnected(Context context) {
|
||||
if (context != null) {
|
||||
ConnectivityManager mConnectivityManager = (ConnectivityManager) context
|
||||
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo mNetworkInfo = mConnectivityManager
|
||||
.getActiveNetworkInfo();
|
||||
if (mNetworkInfo != null) {
|
||||
return mNetworkInfo.isAvailable();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final String TAG = "SDK_Sample.Util";
|
||||
|
||||
private static Dialog mProgressDialog;
|
||||
private static Toast mToast;
|
||||
|
||||
/* Convert byte[] to hex string.这里我们可以将byte转换成int,然后利用Integer.toHexString(int)来转换成16进制字符串。
|
||||
* @param src byte[] data
|
||||
* @return hex string
|
||||
*/
|
||||
public static String bytesToHexString(byte[] src){
|
||||
StringBuilder stringBuilder = new StringBuilder("");
|
||||
if (src == null || src.length <= 0) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < src.length; i++) {
|
||||
int v = src[i] & 0xFF;
|
||||
String hv = Integer.toHexString(v);
|
||||
if (hv.length() < 2) {
|
||||
stringBuilder.append(0);
|
||||
}
|
||||
stringBuilder.append(hv);
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
/**
|
||||
* Convert hex string to byte[]
|
||||
* @param hexString the hex string
|
||||
* @return byte[]
|
||||
*/
|
||||
public static byte[] hexStringToBytes(String hexString) {
|
||||
if (hexString == null || hexString.equals("")) {
|
||||
return null;
|
||||
}
|
||||
hexString = hexString.toUpperCase();
|
||||
int length = hexString.length() / 2;
|
||||
char[] hexChars = hexString.toCharArray();
|
||||
byte[] d = new byte[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
int pos = i * 2;
|
||||
d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
|
||||
}
|
||||
return d;
|
||||
}
|
||||
/**
|
||||
* Convert char to byte
|
||||
* @param c char
|
||||
* @return byte
|
||||
*/
|
||||
private static byte charToByte(char c) {
|
||||
return (byte) "0123456789ABCDEF".indexOf(c);
|
||||
}
|
||||
|
||||
/*
|
||||
* 16进制数字字符集
|
||||
*/
|
||||
private static String hexString="0123456789ABCDEF";
|
||||
/*
|
||||
* 将字符串编码成16进制数字,适用于所有字符(包括中文)
|
||||
*/
|
||||
public static String toHexString(String str)
|
||||
{
|
||||
//根据默认编码获取字节数组
|
||||
byte[] bytes = null;
|
||||
try {
|
||||
bytes = str.getBytes("UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (bytes == null) return null;
|
||||
StringBuilder sb=new StringBuilder(bytes.length*2);
|
||||
//将字节数组中每个字节拆解成2位16进制整数
|
||||
for(int i=0;i<bytes.length;i++)
|
||||
{
|
||||
sb.append(hexString.charAt((bytes[i]&0xf0)>>4));
|
||||
sb.append(hexString.charAt((bytes[i]&0x0f)>>0));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
//转换十六进制编码为字符串
|
||||
public static String hexToString(String s)
|
||||
{
|
||||
if("0x".equals(s.substring(0, 2)))
|
||||
{
|
||||
s =s.substring(2);
|
||||
}
|
||||
byte[] baKeyword = new byte[s.length()/2];
|
||||
for(int i = 0; i < baKeyword.length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
baKeyword[i] = (byte)(0xff & Integer.parseInt(s.substring(i*2, i*2+2),16));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
s = new String(baKeyword, "utf-8");//UTF-16le:Not
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
e1.printStackTrace();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public static byte[] bmpToByteArray(final Bitmap bmp, final boolean needRecycle) {
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
bmp.compress(CompressFormat.PNG, 100, output);
|
||||
if (needRecycle) {
|
||||
bmp.recycle();
|
||||
}
|
||||
|
||||
byte[] result = output.toByteArray();
|
||||
try {
|
||||
output.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static byte[] getHtmlByteArray(final String url) {
|
||||
URL htmlUrl = null;
|
||||
InputStream inStream = null;
|
||||
try {
|
||||
htmlUrl = new URL(url);
|
||||
URLConnection connection = htmlUrl.openConnection();
|
||||
HttpURLConnection httpConnection = (HttpURLConnection)connection;
|
||||
int responseCode = httpConnection.getResponseCode();
|
||||
if(responseCode == HttpURLConnection.HTTP_OK){
|
||||
inStream = httpConnection.getInputStream();
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
byte[] data = inputStreamToByte(inStream);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public static byte[] inputStreamToByte(InputStream is) {
|
||||
try{
|
||||
ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
|
||||
int ch;
|
||||
while ((ch = is.read()) != -1) {
|
||||
bytestream.write(ch);
|
||||
}
|
||||
byte imgdata[] = bytestream.toByteArray();
|
||||
bytestream.close();
|
||||
return imgdata;
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static byte[] readFromFile(String fileName, int offset, int len) {
|
||||
if (fileName == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
File file = new File(fileName);
|
||||
if (!file.exists()) {
|
||||
Log.i(TAG, "readFromFile: file not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (len == -1) {
|
||||
len = (int) file.length();
|
||||
}
|
||||
|
||||
Log.d(TAG, "readFromFile : offset = " + offset + " len = " + len + " offset + len = " + (offset + len));
|
||||
|
||||
if(offset <0){
|
||||
Log.e(TAG, "readFromFile invalid offset:" + offset);
|
||||
return null;
|
||||
}
|
||||
if(len <=0 ){
|
||||
Log.e(TAG, "readFromFile invalid len:" + len);
|
||||
return null;
|
||||
}
|
||||
if(offset + len > (int) file.length()){
|
||||
Log.e(TAG, "readFromFile invalid file len:" + file.length());
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] b = null;
|
||||
try {
|
||||
RandomAccessFile in = new RandomAccessFile(fileName, "r");
|
||||
b = new byte[len];
|
||||
in.seek(offset);
|
||||
in.readFully(b);
|
||||
in.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "readFromFile : errMsg = " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
public static int computeSampleSize(BitmapFactory.Options options,
|
||||
|
||||
int minSideLength, int maxNumOfPixels) {
|
||||
|
||||
int initialSize = computeInitialSampleSize(options, minSideLength,
|
||||
|
||||
maxNumOfPixels);
|
||||
|
||||
int roundedSize;
|
||||
|
||||
if (initialSize <= 8) {
|
||||
|
||||
roundedSize = 1;
|
||||
|
||||
while (roundedSize < initialSize) {
|
||||
|
||||
roundedSize <<= 1;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
roundedSize = (initialSize + 7) / 8 * 8;
|
||||
|
||||
}
|
||||
|
||||
return roundedSize;
|
||||
}
|
||||
|
||||
private static int computeInitialSampleSize(BitmapFactory.Options options,
|
||||
|
||||
int minSideLength, int maxNumOfPixels) {
|
||||
|
||||
double w = options.outWidth;
|
||||
|
||||
double h = options.outHeight;
|
||||
|
||||
int lowerBound = (maxNumOfPixels == -1) ? 1 :
|
||||
|
||||
(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) {
|
||||
|
||||
// return the larger one when there is no overlapping zone.
|
||||
|
||||
return lowerBound;
|
||||
|
||||
}
|
||||
|
||||
if ((maxNumOfPixels == -1) &&
|
||||
|
||||
(minSideLength == -1)) {
|
||||
|
||||
return 1;
|
||||
|
||||
} else if (minSideLength == -1) {
|
||||
|
||||
return lowerBound;
|
||||
|
||||
} else {
|
||||
|
||||
return upperBound;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 以最省内存的方式读取图片
|
||||
*/
|
||||
public static Bitmap readBitmap(final String path){
|
||||
try{
|
||||
FileInputStream stream = new FileInputStream(new File(path+"test.jpg"));
|
||||
BitmapFactory.Options opts = new BitmapFactory.Options();
|
||||
opts.inSampleSize = 8;
|
||||
opts.inPurgeable=true;
|
||||
opts.inInputShareable=true;
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(stream , null, opts);
|
||||
return bitmap;
|
||||
} catch (OutOfMemoryError e) {
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
Assert.assertTrue(path != null && !path.equals("") && height > 0 && width > 0);
|
||||
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
|
||||
try {
|
||||
options.inJustDecodeBounds = true;
|
||||
Bitmap tmp = BitmapFactory.decodeFile(path, options);
|
||||
if (tmp != null) {
|
||||
tmp.recycle();
|
||||
tmp = null;
|
||||
}
|
||||
|
||||
Log.d(TAG, "extractThumbNail: round=" + width + "x" + height + ", crop=" + crop);
|
||||
final double beY = options.outHeight * 1.0 / height;
|
||||
final double beX = options.outWidth * 1.0 / width;
|
||||
Log.d(TAG, "extractThumbNail: extract beX = " + beX + ", beY = " + beY);
|
||||
options.inSampleSize = (int) (crop ? (beY > beX ? beX : beY) : (beY < beX ? beX : beY));
|
||||
if (options.inSampleSize <= 1) {
|
||||
options.inSampleSize = 1;
|
||||
}
|
||||
|
||||
// NOTE: out of memory error
|
||||
while (options.outHeight * options.outWidth / options.inSampleSize > MAX_DECODE_PICTURE_SIZE) {
|
||||
options.inSampleSize++;
|
||||
}
|
||||
|
||||
int newHeight = height;
|
||||
int newWidth = width;
|
||||
if (crop) {
|
||||
if (beY > beX) {
|
||||
newHeight = (int) (newWidth * 1.0 * options.outHeight / options.outWidth);
|
||||
} else {
|
||||
newWidth = (int) (newHeight * 1.0 * options.outWidth / options.outHeight);
|
||||
}
|
||||
} else {
|
||||
if (beY < beX) {
|
||||
newHeight = (int) (newWidth * 1.0 * options.outHeight / options.outWidth);
|
||||
} else {
|
||||
newWidth = (int) (newHeight * 1.0 * options.outWidth / options.outHeight);
|
||||
}
|
||||
}
|
||||
|
||||
options.inJustDecodeBounds = false;
|
||||
|
||||
Log.i(TAG, "bitmap required size=" + newWidth + "x" + newHeight + ", orig=" + options.outWidth + "x" + options.outHeight + ", sample=" + options.inSampleSize);
|
||||
Bitmap bm = BitmapFactory.decodeFile(path, options);
|
||||
if (bm == null) {
|
||||
Log.e(TAG, "bitmap decode failed");
|
||||
return null;
|
||||
}
|
||||
|
||||
Log.i(TAG, "bitmap decoded size=" + bm.getWidth() + "x" + bm.getHeight());
|
||||
final Bitmap scale = Bitmap.createScaledBitmap(bm, newWidth, newHeight, true);
|
||||
if (scale != null) {
|
||||
bm.recycle();
|
||||
bm = scale;
|
||||
}
|
||||
|
||||
if (crop) {
|
||||
final Bitmap cropped = Bitmap.createBitmap(bm, (bm.getWidth() - width) >> 1, (bm.getHeight() - height) >> 1, width, height);
|
||||
if (cropped == null) {
|
||||
return bm;
|
||||
}
|
||||
|
||||
bm.recycle();
|
||||
bm = cropped;
|
||||
Log.i(TAG, "bitmap croped size=" + bm.getWidth() + "x" + bm.getHeight());
|
||||
}
|
||||
return bm;
|
||||
|
||||
} catch (final OutOfMemoryError e) {
|
||||
Log.e(TAG, "decode bitmap failed: " + e.getMessage());
|
||||
options = null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final void showResultDialog(Context context, String msg,
|
||||
String title) {
|
||||
if(msg == null) return;
|
||||
String rmsg = msg.replace(",", "\n");
|
||||
Log.d("Util", rmsg);
|
||||
new AlertDialog.Builder(context).setTitle(title).setMessage(rmsg)
|
||||
.setNegativeButton("知道了", null).create().show();
|
||||
}
|
||||
|
||||
public static final void showProgressDialog(Context context, String title,
|
||||
String message) {
|
||||
dismissDialog();
|
||||
if (TextUtils.isEmpty(title)) {
|
||||
title = "请稍候";
|
||||
}
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "正在加载...";
|
||||
}
|
||||
mProgressDialog = ProgressDialog.show(context, title, message);
|
||||
}
|
||||
|
||||
public static AlertDialog showConfirmCancelDialog(Context context,
|
||||
String title, String message,
|
||||
DialogInterface.OnClickListener posListener) {
|
||||
AlertDialog dlg = new AlertDialog.Builder(context).setMessage(message)
|
||||
.setPositiveButton("确认", posListener)
|
||||
.setNegativeButton("取消", null).create();
|
||||
dlg.setCanceledOnTouchOutside(false);
|
||||
dlg.show();
|
||||
return dlg;
|
||||
}
|
||||
|
||||
public static final void dismissDialog() {
|
||||
if (mProgressDialog != null) {
|
||||
mProgressDialog.dismiss();
|
||||
mProgressDialog = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印消息并且用Toast显示消息
|
||||
*
|
||||
* @param activity
|
||||
* @param message
|
||||
* @param logLevel
|
||||
* 填d, w, e分别代表debug, warn, error; 默认是debug
|
||||
*/
|
||||
public static final void toastMessage(final Activity activity,
|
||||
final String message, String logLevel) {
|
||||
if ("w".equals(logLevel)) {
|
||||
Log.w("sdkDemo", message);
|
||||
} else if ("e".equals(logLevel)) {
|
||||
Log.e("sdkDemo", message);
|
||||
} else {
|
||||
Log.d("sdkDemo", message);
|
||||
}
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// TODO Auto-generated method stub
|
||||
if (mToast != null) {
|
||||
mToast.cancel();
|
||||
mToast = null;
|
||||
}
|
||||
mToast = Toast.makeText(activity, message, Toast.LENGTH_SHORT);
|
||||
mToast.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印消息并且用Toast显示消息
|
||||
*
|
||||
* @param activity
|
||||
* @param message
|
||||
* @param logLevel
|
||||
* 填d, w, e分别代表debug, warn, error; 默认是debug
|
||||
*/
|
||||
public static final void toastMessage(final Activity activity,
|
||||
final String message) {
|
||||
toastMessage(activity, message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据一个网络连接(String)获取bitmap图像
|
||||
*
|
||||
* @param imageUri
|
||||
* @return
|
||||
* @throws MalformedURLException
|
||||
*/
|
||||
public static Bitmap getbitmap(String imageUri) {
|
||||
Log.v(TAG, "getbitmap:" + imageUri);
|
||||
// 显示网络上的图片
|
||||
Bitmap bitmap = null;
|
||||
try {
|
||||
URL myFileUrl = new URL(imageUri);
|
||||
HttpURLConnection conn = (HttpURLConnection) myFileUrl
|
||||
.openConnection();
|
||||
conn.setDoInput(true);
|
||||
conn.connect();
|
||||
InputStream is = conn.getInputStream();
|
||||
bitmap = BitmapFactory.decodeStream(is);
|
||||
is.close();
|
||||
|
||||
Log.v(TAG, "image download finished." + imageUri);
|
||||
} catch (OutOfMemoryError e) {
|
||||
e.printStackTrace();
|
||||
bitmap = null;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Log.v(TAG, "getbitmap bmp fail---");
|
||||
bitmap = null;
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public static void release() {
|
||||
mProgressDialog = null;
|
||||
mToast = null;
|
||||
}
|
||||
|
||||
// =========
|
||||
// =通过URI获取本地图片的path
|
||||
// =兼容android 5.0
|
||||
// ==========
|
||||
|
||||
public static String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
|
||||
public static int Build_VERSION_KITKAT = 19;
|
||||
public static String getPath(final Context context, final Uri uri) {
|
||||
|
||||
final boolean isKitKat = Build.VERSION.SDK_INT >= 19;
|
||||
|
||||
// DocumentProvider
|
||||
if (isKitKat && isDocumentUri(context, uri)) {
|
||||
// ExternalStorageProvider
|
||||
if (isExternalStorageDocument(uri)) {
|
||||
final String docId = getDocumentId(uri);
|
||||
final String[] split = docId.split(":");
|
||||
final String type = split[0];
|
||||
|
||||
if ("primary".equalsIgnoreCase(type)) {
|
||||
return Environment.getExternalStorageDirectory() + "/" + split[1];
|
||||
}
|
||||
|
||||
}
|
||||
// DownloadsProvider
|
||||
else if (isDownloadsDocument(uri)) {
|
||||
|
||||
final String id = getDocumentId(uri);
|
||||
final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"),
|
||||
Long.valueOf(id));
|
||||
|
||||
return getDataColumn(context, contentUri, null, null);
|
||||
}
|
||||
// MediaProvider
|
||||
else if (isMediaDocument(uri)) {
|
||||
final String docId = getDocumentId(uri);
|
||||
final String[] split = docId.split(":");
|
||||
final String type = split[0];
|
||||
|
||||
Uri contentUri = null;
|
||||
if ("image".equals(type)) {
|
||||
contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||
} else if ("video".equals(type)) {
|
||||
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
|
||||
} else if ("audio".equals(type)) {
|
||||
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
|
||||
}
|
||||
|
||||
final String selection = "_id=?";
|
||||
final String[] selectionArgs = new String[] { split[1] };
|
||||
|
||||
return getDataColumn(context, contentUri, selection, selectionArgs);
|
||||
}
|
||||
}
|
||||
// MediaStore (and general)
|
||||
else if ("content".equalsIgnoreCase(uri.getScheme())) {
|
||||
|
||||
// Return the remote address
|
||||
if (isGooglePhotosUri(uri))
|
||||
return uri.getLastPathSegment();
|
||||
|
||||
return getDataColumn(context, uri, null, null);
|
||||
}
|
||||
// File
|
||||
else if ("file".equalsIgnoreCase(uri.getScheme())) {
|
||||
return uri.getPath();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final String PATH_DOCUMENT = "document";
|
||||
|
||||
/**
|
||||
* Test if the given URI represents a {@link Document} backed by a
|
||||
* {@link DocumentsProvider}.
|
||||
*/
|
||||
private static boolean isDocumentUri(Context context, Uri uri) {
|
||||
final List<String> paths = uri.getPathSegments();
|
||||
if (paths.size() < 2) {
|
||||
return false;
|
||||
}
|
||||
if (!PATH_DOCUMENT.equals(paths.get(0))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static String getDocumentId(Uri documentUri) {
|
||||
final List<String> paths = documentUri.getPathSegments();
|
||||
if (paths.size() < 2) {
|
||||
throw new IllegalArgumentException("Not a document: " + documentUri);
|
||||
}
|
||||
if (!PATH_DOCUMENT.equals(paths.get(0))) {
|
||||
throw new IllegalArgumentException("Not a document: " + documentUri);
|
||||
}
|
||||
return paths.get(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of the data column for this Uri. This is useful for
|
||||
* MediaStore Uris, and other file-based ContentProviders.
|
||||
*
|
||||
* @param context
|
||||
* The context.
|
||||
* @param uri
|
||||
* The Uri to query.
|
||||
* @param selection
|
||||
* (Optional) Filter used in the query.
|
||||
* @param selectionArgs
|
||||
* (Optional) Selection arguments used in the query.
|
||||
* [url=home.php?mod=space&uid=7300]@return[/url] The value of
|
||||
* the _data column, which is typically a file path.
|
||||
*/
|
||||
public static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {
|
||||
|
||||
Cursor cursor = null;
|
||||
final String column = "_data";
|
||||
final String[] projection = { column };
|
||||
|
||||
try {
|
||||
cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
final int index = cursor.getColumnIndexOrThrow(column);
|
||||
return cursor.getString(index);
|
||||
}
|
||||
} finally {
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri
|
||||
* The Uri to check.
|
||||
* @return Whether the Uri authority is ExternalStorageProvider.
|
||||
*/
|
||||
public static boolean isExternalStorageDocument(Uri uri) {
|
||||
return "com.android.externalstorage.documents".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri
|
||||
* The Uri to check.
|
||||
* @return Whether the Uri authority is DownloadsProvider.
|
||||
*/
|
||||
public static boolean isDownloadsDocument(Uri uri) {
|
||||
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri
|
||||
* The Uri to check.
|
||||
* @return Whether the Uri authority is MediaProvider.
|
||||
*/
|
||||
public static boolean isMediaDocument(Uri uri) {
|
||||
return "com.android.providers.media.documents".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri
|
||||
* The Uri to check.
|
||||
* @return Whether the Uri authority is Google Photos.
|
||||
*/
|
||||
public static boolean isGooglePhotosUri(Uri uri) {
|
||||
return "com.google.android.apps.photos.content".equals(uri.getAuthority());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,756 @@
|
|||
package com.stone.util;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.ContentUris;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Bitmap.CompressFormat;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
import junit.framework.Assert;
|
||||
|
||||
/**
|
||||
* 工具类
|
||||
*
|
||||
* @date 2014-5-9
|
||||
* @author Stone
|
||||
*/
|
||||
public class Util {
|
||||
|
||||
/**
|
||||
* 判断电话号码是否有效
|
||||
*
|
||||
* @param phoneNumber
|
||||
* @return true 有效 / false 无效
|
||||
*/
|
||||
public static boolean isPhoneNumberValid(String phoneNumber) {
|
||||
|
||||
boolean isValid = false;
|
||||
|
||||
String expression = "((^(13|15|18)[0-9]{9}$)|(^0[1,2]{1}\\d{1}-?\\d{8}$)|(^0[3-9] {1}\\d{2}-?\\d{7,8}$)|(^0[1,2]{1}\\d{1}-?\\d{8}-(\\d{1,4})$)|(^0[3-9]{1}\\d{2}-? \\d{7,8}-(\\d{1,4})$))";
|
||||
CharSequence inputStr = phoneNumber;
|
||||
|
||||
Pattern pattern = Pattern.compile(expression);
|
||||
Matcher matcher = pattern.matcher(inputStr);
|
||||
|
||||
if (matcher.matches()) {
|
||||
isValid = true;
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
|
||||
// 判断网络是否连接
|
||||
public static boolean isNetworkConnected(Context context) {
|
||||
if (context != null) {
|
||||
ConnectivityManager mConnectivityManager = (ConnectivityManager) context
|
||||
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo mNetworkInfo = mConnectivityManager
|
||||
.getActiveNetworkInfo();
|
||||
if (mNetworkInfo != null) {
|
||||
return mNetworkInfo.isAvailable();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final String TAG = "SDK_Sample.Util";
|
||||
|
||||
private static Dialog mProgressDialog;
|
||||
private static Toast mToast;
|
||||
|
||||
/* Convert byte[] to hex string.这里我们可以将byte转换成int,然后利用Integer.toHexString(int)来转换成16进制字符串。
|
||||
* @param src byte[] data
|
||||
* @return hex string
|
||||
*/
|
||||
public static String bytesToHexString(byte[] src){
|
||||
StringBuilder stringBuilder = new StringBuilder("");
|
||||
if (src == null || src.length <= 0) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < src.length; i++) {
|
||||
int v = src[i] & 0xFF;
|
||||
String hv = Integer.toHexString(v);
|
||||
if (hv.length() < 2) {
|
||||
stringBuilder.append(0);
|
||||
}
|
||||
stringBuilder.append(hv);
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
/**
|
||||
* Convert hex string to byte[]
|
||||
* @param hexString the hex string
|
||||
* @return byte[]
|
||||
*/
|
||||
public static byte[] hexStringToBytes(String hexString) {
|
||||
if (hexString == null || hexString.equals("")) {
|
||||
return null;
|
||||
}
|
||||
hexString = hexString.toUpperCase();
|
||||
int length = hexString.length() / 2;
|
||||
char[] hexChars = hexString.toCharArray();
|
||||
byte[] d = new byte[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
int pos = i * 2;
|
||||
d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
|
||||
}
|
||||
return d;
|
||||
}
|
||||
/**
|
||||
* Convert char to byte
|
||||
* @param c char
|
||||
* @return byte
|
||||
*/
|
||||
private static byte charToByte(char c) {
|
||||
return (byte) "0123456789ABCDEF".indexOf(c);
|
||||
}
|
||||
|
||||
/*
|
||||
* 16进制数字字符集
|
||||
*/
|
||||
private static String hexString="0123456789ABCDEF";
|
||||
/*
|
||||
* 将字符串编码成16进制数字,适用于所有字符(包括中文)
|
||||
*/
|
||||
public static String toHexString(String str)
|
||||
{
|
||||
//根据默认编码获取字节数组
|
||||
byte[] bytes = null;
|
||||
try {
|
||||
bytes = str.getBytes("UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (bytes == null) return null;
|
||||
StringBuilder sb=new StringBuilder(bytes.length*2);
|
||||
//将字节数组中每个字节拆解成2位16进制整数
|
||||
for(int i=0;i<bytes.length;i++)
|
||||
{
|
||||
sb.append(hexString.charAt((bytes[i]&0xf0)>>4));
|
||||
sb.append(hexString.charAt((bytes[i]&0x0f)>>0));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
//转换十六进制编码为字符串
|
||||
public static String hexToString(String s)
|
||||
{
|
||||
if("0x".equals(s.substring(0, 2)))
|
||||
{
|
||||
s =s.substring(2);
|
||||
}
|
||||
byte[] baKeyword = new byte[s.length()/2];
|
||||
for(int i = 0; i < baKeyword.length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
baKeyword[i] = (byte)(0xff & Integer.parseInt(s.substring(i*2, i*2+2),16));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
s = new String(baKeyword, "utf-8");//UTF-16le:Not
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
e1.printStackTrace();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public static byte[] bmpToByteArray(final Bitmap bmp, final boolean needRecycle) {
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
bmp.compress(CompressFormat.PNG, 100, output);
|
||||
if (needRecycle) {
|
||||
bmp.recycle();
|
||||
}
|
||||
|
||||
byte[] result = output.toByteArray();
|
||||
try {
|
||||
output.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static byte[] getHtmlByteArray(final String url) {
|
||||
URL htmlUrl = null;
|
||||
InputStream inStream = null;
|
||||
try {
|
||||
htmlUrl = new URL(url);
|
||||
URLConnection connection = htmlUrl.openConnection();
|
||||
HttpURLConnection httpConnection = (HttpURLConnection)connection;
|
||||
int responseCode = httpConnection.getResponseCode();
|
||||
if(responseCode == HttpURLConnection.HTTP_OK){
|
||||
inStream = httpConnection.getInputStream();
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
byte[] data = inputStreamToByte(inStream);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public static byte[] inputStreamToByte(InputStream is) {
|
||||
try{
|
||||
ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
|
||||
int ch;
|
||||
while ((ch = is.read()) != -1) {
|
||||
bytestream.write(ch);
|
||||
}
|
||||
byte imgdata[] = bytestream.toByteArray();
|
||||
bytestream.close();
|
||||
return imgdata;
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static byte[] readFromFile(String fileName, int offset, int len) {
|
||||
if (fileName == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
File file = new File(fileName);
|
||||
if (!file.exists()) {
|
||||
Log.i(TAG, "readFromFile: file not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (len == -1) {
|
||||
len = (int) file.length();
|
||||
}
|
||||
|
||||
Log.d(TAG, "readFromFile : offset = " + offset + " len = " + len + " offset + len = " + (offset + len));
|
||||
|
||||
if(offset <0){
|
||||
Log.e(TAG, "readFromFile invalid offset:" + offset);
|
||||
return null;
|
||||
}
|
||||
if(len <=0 ){
|
||||
Log.e(TAG, "readFromFile invalid len:" + len);
|
||||
return null;
|
||||
}
|
||||
if(offset + len > (int) file.length()){
|
||||
Log.e(TAG, "readFromFile invalid file len:" + file.length());
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] b = null;
|
||||
try {
|
||||
RandomAccessFile in = new RandomAccessFile(fileName, "r");
|
||||
b = new byte[len];
|
||||
in.seek(offset);
|
||||
in.readFully(b);
|
||||
in.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "readFromFile : errMsg = " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
public static int computeSampleSize(BitmapFactory.Options options,
|
||||
|
||||
int minSideLength, int maxNumOfPixels) {
|
||||
|
||||
int initialSize = computeInitialSampleSize(options, minSideLength,
|
||||
|
||||
maxNumOfPixels);
|
||||
|
||||
int roundedSize;
|
||||
|
||||
if (initialSize <= 8) {
|
||||
|
||||
roundedSize = 1;
|
||||
|
||||
while (roundedSize < initialSize) {
|
||||
|
||||
roundedSize <<= 1;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
roundedSize = (initialSize + 7) / 8 * 8;
|
||||
|
||||
}
|
||||
|
||||
return roundedSize;
|
||||
}
|
||||
|
||||
private static int computeInitialSampleSize(BitmapFactory.Options options,
|
||||
|
||||
int minSideLength, int maxNumOfPixels) {
|
||||
|
||||
double w = options.outWidth;
|
||||
|
||||
double h = options.outHeight;
|
||||
|
||||
int lowerBound = (maxNumOfPixels == -1) ? 1 :
|
||||
|
||||
(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) {
|
||||
|
||||
// return the larger one when there is no overlapping zone.
|
||||
|
||||
return lowerBound;
|
||||
|
||||
}
|
||||
|
||||
if ((maxNumOfPixels == -1) &&
|
||||
|
||||
(minSideLength == -1)) {
|
||||
|
||||
return 1;
|
||||
|
||||
} else if (minSideLength == -1) {
|
||||
|
||||
return lowerBound;
|
||||
|
||||
} else {
|
||||
|
||||
return upperBound;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 以最省内存的方式读取图片
|
||||
*/
|
||||
public static Bitmap readBitmap(final String path){
|
||||
try{
|
||||
FileInputStream stream = new FileInputStream(new File(path+"test.jpg"));
|
||||
BitmapFactory.Options opts = new BitmapFactory.Options();
|
||||
opts.inSampleSize = 8;
|
||||
opts.inPurgeable=true;
|
||||
opts.inInputShareable=true;
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(stream , null, opts);
|
||||
return bitmap;
|
||||
} catch (OutOfMemoryError e) {
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
Assert.assertTrue(path != null && !path.equals("") && height > 0 && width > 0);
|
||||
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
|
||||
try {
|
||||
options.inJustDecodeBounds = true;
|
||||
Bitmap tmp = BitmapFactory.decodeFile(path, options);
|
||||
if (tmp != null) {
|
||||
tmp.recycle();
|
||||
tmp = null;
|
||||
}
|
||||
|
||||
Log.d(TAG, "extractThumbNail: round=" + width + "x" + height + ", crop=" + crop);
|
||||
final double beY = options.outHeight * 1.0 / height;
|
||||
final double beX = options.outWidth * 1.0 / width;
|
||||
Log.d(TAG, "extractThumbNail: extract beX = " + beX + ", beY = " + beY);
|
||||
options.inSampleSize = (int) (crop ? (beY > beX ? beX : beY) : (beY < beX ? beX : beY));
|
||||
if (options.inSampleSize <= 1) {
|
||||
options.inSampleSize = 1;
|
||||
}
|
||||
|
||||
// NOTE: out of memory error
|
||||
while (options.outHeight * options.outWidth / options.inSampleSize > MAX_DECODE_PICTURE_SIZE) {
|
||||
options.inSampleSize++;
|
||||
}
|
||||
|
||||
int newHeight = height;
|
||||
int newWidth = width;
|
||||
if (crop) {
|
||||
if (beY > beX) {
|
||||
newHeight = (int) (newWidth * 1.0 * options.outHeight / options.outWidth);
|
||||
} else {
|
||||
newWidth = (int) (newHeight * 1.0 * options.outWidth / options.outHeight);
|
||||
}
|
||||
} else {
|
||||
if (beY < beX) {
|
||||
newHeight = (int) (newWidth * 1.0 * options.outHeight / options.outWidth);
|
||||
} else {
|
||||
newWidth = (int) (newHeight * 1.0 * options.outWidth / options.outHeight);
|
||||
}
|
||||
}
|
||||
|
||||
options.inJustDecodeBounds = false;
|
||||
|
||||
Log.i(TAG, "bitmap required size=" + newWidth + "x" + newHeight + ", orig=" + options.outWidth + "x" + options.outHeight + ", sample=" + options.inSampleSize);
|
||||
Bitmap bm = BitmapFactory.decodeFile(path, options);
|
||||
if (bm == null) {
|
||||
Log.e(TAG, "bitmap decode failed");
|
||||
return null;
|
||||
}
|
||||
|
||||
Log.i(TAG, "bitmap decoded size=" + bm.getWidth() + "x" + bm.getHeight());
|
||||
final Bitmap scale = Bitmap.createScaledBitmap(bm, newWidth, newHeight, true);
|
||||
if (scale != null) {
|
||||
bm.recycle();
|
||||
bm = scale;
|
||||
}
|
||||
|
||||
if (crop) {
|
||||
final Bitmap cropped = Bitmap.createBitmap(bm, (bm.getWidth() - width) >> 1, (bm.getHeight() - height) >> 1, width, height);
|
||||
if (cropped == null) {
|
||||
return bm;
|
||||
}
|
||||
|
||||
bm.recycle();
|
||||
bm = cropped;
|
||||
Log.i(TAG, "bitmap croped size=" + bm.getWidth() + "x" + bm.getHeight());
|
||||
}
|
||||
return bm;
|
||||
|
||||
} catch (final OutOfMemoryError e) {
|
||||
Log.e(TAG, "decode bitmap failed: " + e.getMessage());
|
||||
options = null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final void showResultDialog(Context context, String msg,
|
||||
String title) {
|
||||
if(msg == null) return;
|
||||
String rmsg = msg.replace(",", "\n");
|
||||
Log.d("Util", rmsg);
|
||||
new AlertDialog.Builder(context).setTitle(title).setMessage(rmsg)
|
||||
.setNegativeButton("知道了", null).create().show();
|
||||
}
|
||||
|
||||
public static final void showProgressDialog(Context context, String title,
|
||||
String message) {
|
||||
dismissDialog();
|
||||
if (TextUtils.isEmpty(title)) {
|
||||
title = "请稍候";
|
||||
}
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "正在加载...";
|
||||
}
|
||||
mProgressDialog = ProgressDialog.show(context, title, message);
|
||||
}
|
||||
|
||||
public static AlertDialog showConfirmCancelDialog(Context context,
|
||||
String title, String message,
|
||||
DialogInterface.OnClickListener posListener) {
|
||||
AlertDialog dlg = new AlertDialog.Builder(context).setMessage(message)
|
||||
.setPositiveButton("确认", posListener)
|
||||
.setNegativeButton("取消", null).create();
|
||||
dlg.setCanceledOnTouchOutside(false);
|
||||
dlg.show();
|
||||
return dlg;
|
||||
}
|
||||
|
||||
public static final void dismissDialog() {
|
||||
if (mProgressDialog != null) {
|
||||
mProgressDialog.dismiss();
|
||||
mProgressDialog = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印消息并且用Toast显示消息
|
||||
*
|
||||
* @param activity
|
||||
* @param message
|
||||
* @param logLevel
|
||||
* 填d, w, e分别代表debug, warn, error; 默认是debug
|
||||
*/
|
||||
public static final void toastMessage(final Activity activity,
|
||||
final String message, String logLevel) {
|
||||
if ("w".equals(logLevel)) {
|
||||
Log.w("sdkDemo", message);
|
||||
} else if ("e".equals(logLevel)) {
|
||||
Log.e("sdkDemo", message);
|
||||
} else {
|
||||
Log.d("sdkDemo", message);
|
||||
}
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// TODO Auto-generated method stub
|
||||
if (mToast != null) {
|
||||
mToast.cancel();
|
||||
mToast = null;
|
||||
}
|
||||
mToast = Toast.makeText(activity, message, Toast.LENGTH_SHORT);
|
||||
mToast.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印消息并且用Toast显示消息
|
||||
*
|
||||
* @param activity
|
||||
* @param message
|
||||
* @param logLevel
|
||||
* 填d, w, e分别代表debug, warn, error; 默认是debug
|
||||
*/
|
||||
public static final void toastMessage(final Activity activity,
|
||||
final String message) {
|
||||
toastMessage(activity, message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据一个网络连接(String)获取bitmap图像
|
||||
*
|
||||
* @param imageUri
|
||||
* @return
|
||||
* @throws MalformedURLException
|
||||
*/
|
||||
public static Bitmap getbitmap(String imageUri) {
|
||||
Log.v(TAG, "getbitmap:" + imageUri);
|
||||
// 显示网络上的图片
|
||||
Bitmap bitmap = null;
|
||||
try {
|
||||
URL myFileUrl = new URL(imageUri);
|
||||
HttpURLConnection conn = (HttpURLConnection) myFileUrl
|
||||
.openConnection();
|
||||
conn.setDoInput(true);
|
||||
conn.connect();
|
||||
InputStream is = conn.getInputStream();
|
||||
bitmap = BitmapFactory.decodeStream(is);
|
||||
is.close();
|
||||
|
||||
Log.v(TAG, "image download finished." + imageUri);
|
||||
} catch (OutOfMemoryError e) {
|
||||
e.printStackTrace();
|
||||
bitmap = null;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Log.v(TAG, "getbitmap bmp fail---");
|
||||
bitmap = null;
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public static void release() {
|
||||
mProgressDialog = null;
|
||||
mToast = null;
|
||||
}
|
||||
|
||||
// =========
|
||||
// =通过URI获取本地图片的path
|
||||
// =兼容android 5.0
|
||||
// ==========
|
||||
|
||||
public static String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
|
||||
public static int Build_VERSION_KITKAT = 19;
|
||||
public static String getPath(final Context context, final Uri uri) {
|
||||
|
||||
final boolean isKitKat = Build.VERSION.SDK_INT >= 19;
|
||||
|
||||
// DocumentProvider
|
||||
if (isKitKat && isDocumentUri(context, uri)) {
|
||||
// ExternalStorageProvider
|
||||
if (isExternalStorageDocument(uri)) {
|
||||
final String docId = getDocumentId(uri);
|
||||
final String[] split = docId.split(":");
|
||||
final String type = split[0];
|
||||
|
||||
if ("primary".equalsIgnoreCase(type)) {
|
||||
return Environment.getExternalStorageDirectory() + "/" + split[1];
|
||||
}
|
||||
|
||||
}
|
||||
// DownloadsProvider
|
||||
else if (isDownloadsDocument(uri)) {
|
||||
|
||||
final String id = getDocumentId(uri);
|
||||
final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"),
|
||||
Long.valueOf(id));
|
||||
|
||||
return getDataColumn(context, contentUri, null, null);
|
||||
}
|
||||
// MediaProvider
|
||||
else if (isMediaDocument(uri)) {
|
||||
final String docId = getDocumentId(uri);
|
||||
final String[] split = docId.split(":");
|
||||
final String type = split[0];
|
||||
|
||||
Uri contentUri = null;
|
||||
if ("image".equals(type)) {
|
||||
contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||
} else if ("video".equals(type)) {
|
||||
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
|
||||
} else if ("audio".equals(type)) {
|
||||
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
|
||||
}
|
||||
|
||||
final String selection = "_id=?";
|
||||
final String[] selectionArgs = new String[] { split[1] };
|
||||
|
||||
return getDataColumn(context, contentUri, selection, selectionArgs);
|
||||
}
|
||||
}
|
||||
// MediaStore (and general)
|
||||
else if ("content".equalsIgnoreCase(uri.getScheme())) {
|
||||
|
||||
// Return the remote address
|
||||
if (isGooglePhotosUri(uri))
|
||||
return uri.getLastPathSegment();
|
||||
|
||||
return getDataColumn(context, uri, null, null);
|
||||
}
|
||||
// File
|
||||
else if ("file".equalsIgnoreCase(uri.getScheme())) {
|
||||
return uri.getPath();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final String PATH_DOCUMENT = "document";
|
||||
|
||||
/**
|
||||
* Test if the given URI represents a {@link Document} backed by a
|
||||
* {@link DocumentsProvider}.
|
||||
*/
|
||||
private static boolean isDocumentUri(Context context, Uri uri) {
|
||||
final List<String> paths = uri.getPathSegments();
|
||||
if (paths.size() < 2) {
|
||||
return false;
|
||||
}
|
||||
if (!PATH_DOCUMENT.equals(paths.get(0))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static String getDocumentId(Uri documentUri) {
|
||||
final List<String> paths = documentUri.getPathSegments();
|
||||
if (paths.size() < 2) {
|
||||
throw new IllegalArgumentException("Not a document: " + documentUri);
|
||||
}
|
||||
if (!PATH_DOCUMENT.equals(paths.get(0))) {
|
||||
throw new IllegalArgumentException("Not a document: " + documentUri);
|
||||
}
|
||||
return paths.get(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of the data column for this Uri. This is useful for
|
||||
* MediaStore Uris, and other file-based ContentProviders.
|
||||
*
|
||||
* @param context
|
||||
* The context.
|
||||
* @param uri
|
||||
* The Uri to query.
|
||||
* @param selection
|
||||
* (Optional) Filter used in the query.
|
||||
* @param selectionArgs
|
||||
* (Optional) Selection arguments used in the query.
|
||||
* [url=home.php?mod=space&uid=7300]@return[/url] The value of
|
||||
* the _data column, which is typically a file path.
|
||||
*/
|
||||
public static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {
|
||||
|
||||
Cursor cursor = null;
|
||||
final String column = "_data";
|
||||
final String[] projection = { column };
|
||||
|
||||
try {
|
||||
cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
final int index = cursor.getColumnIndexOrThrow(column);
|
||||
return cursor.getString(index);
|
||||
}
|
||||
} finally {
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri
|
||||
* The Uri to check.
|
||||
* @return Whether the Uri authority is ExternalStorageProvider.
|
||||
*/
|
||||
public static boolean isExternalStorageDocument(Uri uri) {
|
||||
return "com.android.externalstorage.documents".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri
|
||||
* The Uri to check.
|
||||
* @return Whether the Uri authority is DownloadsProvider.
|
||||
*/
|
||||
public static boolean isDownloadsDocument(Uri uri) {
|
||||
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri
|
||||
* The Uri to check.
|
||||
* @return Whether the Uri authority is MediaProvider.
|
||||
*/
|
||||
public static boolean isMediaDocument(Uri uri) {
|
||||
return "com.android.providers.media.documents".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri
|
||||
* The Uri to check.
|
||||
* @return Whether the Uri authority is Google Photos.
|
||||
*/
|
||||
public static boolean isGooglePhotosUri(Uri uri) {
|
||||
return "com.google.android.apps.photos.content".equals(uri.getAuthority());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,756 @@
|
|||
package com.stone.util;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.ContentUris;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Bitmap.CompressFormat;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
import junit.framework.Assert;
|
||||
|
||||
/**
|
||||
* 工具类
|
||||
*
|
||||
* @date 2014-5-9
|
||||
* @author Stone
|
||||
*/
|
||||
public class Util {
|
||||
|
||||
/**
|
||||
* 判断电话号码是否有效
|
||||
*
|
||||
* @param phoneNumber
|
||||
* @return true 有效 / false 无效
|
||||
*/
|
||||
public static boolean isPhoneNumberValid(String phoneNumber) {
|
||||
|
||||
boolean isValid = false;
|
||||
|
||||
String expression = "((^(13|15|18)[0-9]{9}$)|(^0[1,2]{1}\\d{1}-?\\d{8}$)|(^0[3-9] {1}\\d{2}-?\\d{7,8}$)|(^0[1,2]{1}\\d{1}-?\\d{8}-(\\d{1,4})$)|(^0[3-9]{1}\\d{2}-? \\d{7,8}-(\\d{1,4})$))";
|
||||
CharSequence inputStr = phoneNumber;
|
||||
|
||||
Pattern pattern = Pattern.compile(expression);
|
||||
Matcher matcher = pattern.matcher(inputStr);
|
||||
|
||||
if (matcher.matches()) {
|
||||
isValid = true;
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
|
||||
// 判断网络是否连接
|
||||
public static boolean isNetworkConnected(Context context) {
|
||||
if (context != null) {
|
||||
ConnectivityManager mConnectivityManager = (ConnectivityManager) context
|
||||
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo mNetworkInfo = mConnectivityManager
|
||||
.getActiveNetworkInfo();
|
||||
if (mNetworkInfo != null) {
|
||||
return mNetworkInfo.isAvailable();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final String TAG = "SDK_Sample.Util";
|
||||
|
||||
private static Dialog mProgressDialog;
|
||||
private static Toast mToast;
|
||||
|
||||
/* Convert byte[] to hex string.这里我们可以将byte转换成int,然后利用Integer.toHexString(int)来转换成16进制字符串。
|
||||
* @param src byte[] data
|
||||
* @return hex string
|
||||
*/
|
||||
public static String bytesToHexString(byte[] src){
|
||||
StringBuilder stringBuilder = new StringBuilder("");
|
||||
if (src == null || src.length <= 0) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < src.length; i++) {
|
||||
int v = src[i] & 0xFF;
|
||||
String hv = Integer.toHexString(v);
|
||||
if (hv.length() < 2) {
|
||||
stringBuilder.append(0);
|
||||
}
|
||||
stringBuilder.append(hv);
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
/**
|
||||
* Convert hex string to byte[]
|
||||
* @param hexString the hex string
|
||||
* @return byte[]
|
||||
*/
|
||||
public static byte[] hexStringToBytes(String hexString) {
|
||||
if (hexString == null || hexString.equals("")) {
|
||||
return null;
|
||||
}
|
||||
hexString = hexString.toUpperCase();
|
||||
int length = hexString.length() / 2;
|
||||
char[] hexChars = hexString.toCharArray();
|
||||
byte[] d = new byte[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
int pos = i * 2;
|
||||
d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
|
||||
}
|
||||
return d;
|
||||
}
|
||||
/**
|
||||
* Convert char to byte
|
||||
* @param c char
|
||||
* @return byte
|
||||
*/
|
||||
private static byte charToByte(char c) {
|
||||
return (byte) "0123456789ABCDEF".indexOf(c);
|
||||
}
|
||||
|
||||
/*
|
||||
* 16进制数字字符集
|
||||
*/
|
||||
private static String hexString="0123456789ABCDEF";
|
||||
/*
|
||||
* 将字符串编码成16进制数字,适用于所有字符(包括中文)
|
||||
*/
|
||||
public static String toHexString(String str)
|
||||
{
|
||||
//根据默认编码获取字节数组
|
||||
byte[] bytes = null;
|
||||
try {
|
||||
bytes = str.getBytes("UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (bytes == null) return null;
|
||||
StringBuilder sb=new StringBuilder(bytes.length*2);
|
||||
//将字节数组中每个字节拆解成2位16进制整数
|
||||
for(int i=0;i<bytes.length;i++)
|
||||
{
|
||||
sb.append(hexString.charAt((bytes[i]&0xf0)>>4));
|
||||
sb.append(hexString.charAt((bytes[i]&0x0f)>>0));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
//转换十六进制编码为字符串
|
||||
public static String hexToString(String s)
|
||||
{
|
||||
if("0x".equals(s.substring(0, 2)))
|
||||
{
|
||||
s =s.substring(2);
|
||||
}
|
||||
byte[] baKeyword = new byte[s.length()/2];
|
||||
for(int i = 0; i < baKeyword.length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
baKeyword[i] = (byte)(0xff & Integer.parseInt(s.substring(i*2, i*2+2),16));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
s = new String(baKeyword, "utf-8");//UTF-16le:Not
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
e1.printStackTrace();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public static byte[] bmpToByteArray(final Bitmap bmp, final boolean needRecycle) {
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
bmp.compress(CompressFormat.PNG, 100, output);
|
||||
if (needRecycle) {
|
||||
bmp.recycle();
|
||||
}
|
||||
|
||||
byte[] result = output.toByteArray();
|
||||
try {
|
||||
output.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static byte[] getHtmlByteArray(final String url) {
|
||||
URL htmlUrl = null;
|
||||
InputStream inStream = null;
|
||||
try {
|
||||
htmlUrl = new URL(url);
|
||||
URLConnection connection = htmlUrl.openConnection();
|
||||
HttpURLConnection httpConnection = (HttpURLConnection)connection;
|
||||
int responseCode = httpConnection.getResponseCode();
|
||||
if(responseCode == HttpURLConnection.HTTP_OK){
|
||||
inStream = httpConnection.getInputStream();
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
byte[] data = inputStreamToByte(inStream);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public static byte[] inputStreamToByte(InputStream is) {
|
||||
try{
|
||||
ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
|
||||
int ch;
|
||||
while ((ch = is.read()) != -1) {
|
||||
bytestream.write(ch);
|
||||
}
|
||||
byte imgdata[] = bytestream.toByteArray();
|
||||
bytestream.close();
|
||||
return imgdata;
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static byte[] readFromFile(String fileName, int offset, int len) {
|
||||
if (fileName == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
File file = new File(fileName);
|
||||
if (!file.exists()) {
|
||||
Log.i(TAG, "readFromFile: file not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (len == -1) {
|
||||
len = (int) file.length();
|
||||
}
|
||||
|
||||
Log.d(TAG, "readFromFile : offset = " + offset + " len = " + len + " offset + len = " + (offset + len));
|
||||
|
||||
if(offset <0){
|
||||
Log.e(TAG, "readFromFile invalid offset:" + offset);
|
||||
return null;
|
||||
}
|
||||
if(len <=0 ){
|
||||
Log.e(TAG, "readFromFile invalid len:" + len);
|
||||
return null;
|
||||
}
|
||||
if(offset + len > (int) file.length()){
|
||||
Log.e(TAG, "readFromFile invalid file len:" + file.length());
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] b = null;
|
||||
try {
|
||||
RandomAccessFile in = new RandomAccessFile(fileName, "r");
|
||||
b = new byte[len];
|
||||
in.seek(offset);
|
||||
in.readFully(b);
|
||||
in.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "readFromFile : errMsg = " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
public static int computeSampleSize(BitmapFactory.Options options,
|
||||
|
||||
int minSideLength, int maxNumOfPixels) {
|
||||
|
||||
int initialSize = computeInitialSampleSize(options, minSideLength,
|
||||
|
||||
maxNumOfPixels);
|
||||
|
||||
int roundedSize;
|
||||
|
||||
if (initialSize <= 8) {
|
||||
|
||||
roundedSize = 1;
|
||||
|
||||
while (roundedSize < initialSize) {
|
||||
|
||||
roundedSize <<= 1;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
roundedSize = (initialSize + 7) / 8 * 8;
|
||||
|
||||
}
|
||||
|
||||
return roundedSize;
|
||||
}
|
||||
|
||||
private static int computeInitialSampleSize(BitmapFactory.Options options,
|
||||
|
||||
int minSideLength, int maxNumOfPixels) {
|
||||
|
||||
double w = options.outWidth;
|
||||
|
||||
double h = options.outHeight;
|
||||
|
||||
int lowerBound = (maxNumOfPixels == -1) ? 1 :
|
||||
|
||||
(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) {
|
||||
|
||||
// return the larger one when there is no overlapping zone.
|
||||
|
||||
return lowerBound;
|
||||
|
||||
}
|
||||
|
||||
if ((maxNumOfPixels == -1) &&
|
||||
|
||||
(minSideLength == -1)) {
|
||||
|
||||
return 1;
|
||||
|
||||
} else if (minSideLength == -1) {
|
||||
|
||||
return lowerBound;
|
||||
|
||||
} else {
|
||||
|
||||
return upperBound;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 以最省内存的方式读取图片
|
||||
*/
|
||||
public static Bitmap readBitmap(final String path){
|
||||
try{
|
||||
FileInputStream stream = new FileInputStream(new File(path+"test.jpg"));
|
||||
BitmapFactory.Options opts = new BitmapFactory.Options();
|
||||
opts.inSampleSize = 8;
|
||||
opts.inPurgeable=true;
|
||||
opts.inInputShareable=true;
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(stream , null, opts);
|
||||
return bitmap;
|
||||
} catch (OutOfMemoryError e) {
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
Assert.assertTrue(path != null && !path.equals("") && height > 0 && width > 0);
|
||||
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
|
||||
try {
|
||||
options.inJustDecodeBounds = true;
|
||||
Bitmap tmp = BitmapFactory.decodeFile(path, options);
|
||||
if (tmp != null) {
|
||||
tmp.recycle();
|
||||
tmp = null;
|
||||
}
|
||||
|
||||
Log.d(TAG, "extractThumbNail: round=" + width + "x" + height + ", crop=" + crop);
|
||||
final double beY = options.outHeight * 1.0 / height;
|
||||
final double beX = options.outWidth * 1.0 / width;
|
||||
Log.d(TAG, "extractThumbNail: extract beX = " + beX + ", beY = " + beY);
|
||||
options.inSampleSize = (int) (crop ? (beY > beX ? beX : beY) : (beY < beX ? beX : beY));
|
||||
if (options.inSampleSize <= 1) {
|
||||
options.inSampleSize = 1;
|
||||
}
|
||||
|
||||
// NOTE: out of memory error
|
||||
while (options.outHeight * options.outWidth / options.inSampleSize > MAX_DECODE_PICTURE_SIZE) {
|
||||
options.inSampleSize++;
|
||||
}
|
||||
|
||||
int newHeight = height;
|
||||
int newWidth = width;
|
||||
if (crop) {
|
||||
if (beY > beX) {
|
||||
newHeight = (int) (newWidth * 1.0 * options.outHeight / options.outWidth);
|
||||
} else {
|
||||
newWidth = (int) (newHeight * 1.0 * options.outWidth / options.outHeight);
|
||||
}
|
||||
} else {
|
||||
if (beY < beX) {
|
||||
newHeight = (int) (newWidth * 1.0 * options.outHeight / options.outWidth);
|
||||
} else {
|
||||
newWidth = (int) (newHeight * 1.0 * options.outWidth / options.outHeight);
|
||||
}
|
||||
}
|
||||
|
||||
options.inJustDecodeBounds = false;
|
||||
|
||||
Log.i(TAG, "bitmap required size=" + newWidth + "x" + newHeight + ", orig=" + options.outWidth + "x" + options.outHeight + ", sample=" + options.inSampleSize);
|
||||
Bitmap bm = BitmapFactory.decodeFile(path, options);
|
||||
if (bm == null) {
|
||||
Log.e(TAG, "bitmap decode failed");
|
||||
return null;
|
||||
}
|
||||
|
||||
Log.i(TAG, "bitmap decoded size=" + bm.getWidth() + "x" + bm.getHeight());
|
||||
final Bitmap scale = Bitmap.createScaledBitmap(bm, newWidth, newHeight, true);
|
||||
if (scale != null) {
|
||||
bm.recycle();
|
||||
bm = scale;
|
||||
}
|
||||
|
||||
if (crop) {
|
||||
final Bitmap cropped = Bitmap.createBitmap(bm, (bm.getWidth() - width) >> 1, (bm.getHeight() - height) >> 1, width, height);
|
||||
if (cropped == null) {
|
||||
return bm;
|
||||
}
|
||||
|
||||
bm.recycle();
|
||||
bm = cropped;
|
||||
Log.i(TAG, "bitmap croped size=" + bm.getWidth() + "x" + bm.getHeight());
|
||||
}
|
||||
return bm;
|
||||
|
||||
} catch (final OutOfMemoryError e) {
|
||||
Log.e(TAG, "decode bitmap failed: " + e.getMessage());
|
||||
options = null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final void showResultDialog(Context context, String msg,
|
||||
String title) {
|
||||
if(msg == null) return;
|
||||
String rmsg = msg.replace(",", "\n");
|
||||
Log.d("Util", rmsg);
|
||||
new AlertDialog.Builder(context).setTitle(title).setMessage(rmsg)
|
||||
.setNegativeButton("知道了", null).create().show();
|
||||
}
|
||||
|
||||
public static final void showProgressDialog(Context context, String title,
|
||||
String message) {
|
||||
dismissDialog();
|
||||
if (TextUtils.isEmpty(title)) {
|
||||
title = "请稍候";
|
||||
}
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "正在加载...";
|
||||
}
|
||||
mProgressDialog = ProgressDialog.show(context, title, message);
|
||||
}
|
||||
|
||||
public static AlertDialog showConfirmCancelDialog(Context context,
|
||||
String title, String message,
|
||||
DialogInterface.OnClickListener posListener) {
|
||||
AlertDialog dlg = new AlertDialog.Builder(context).setMessage(message)
|
||||
.setPositiveButton("确认", posListener)
|
||||
.setNegativeButton("取消", null).create();
|
||||
dlg.setCanceledOnTouchOutside(false);
|
||||
dlg.show();
|
||||
return dlg;
|
||||
}
|
||||
|
||||
public static final void dismissDialog() {
|
||||
if (mProgressDialog != null) {
|
||||
mProgressDialog.dismiss();
|
||||
mProgressDialog = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印消息并且用Toast显示消息
|
||||
*
|
||||
* @param activity
|
||||
* @param message
|
||||
* @param logLevel
|
||||
* 填d, w, e分别代表debug, warn, error; 默认是debug
|
||||
*/
|
||||
public static final void toastMessage(final Activity activity,
|
||||
final String message, String logLevel) {
|
||||
if ("w".equals(logLevel)) {
|
||||
Log.w("sdkDemo", message);
|
||||
} else if ("e".equals(logLevel)) {
|
||||
Log.e("sdkDemo", message);
|
||||
} else {
|
||||
Log.d("sdkDemo", message);
|
||||
}
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// TODO Auto-generated method stub
|
||||
if (mToast != null) {
|
||||
mToast.cancel();
|
||||
mToast = null;
|
||||
}
|
||||
mToast = Toast.makeText(activity, message, Toast.LENGTH_SHORT);
|
||||
mToast.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印消息并且用Toast显示消息
|
||||
*
|
||||
* @param activity
|
||||
* @param message
|
||||
* @param logLevel
|
||||
* 填d, w, e分别代表debug, warn, error; 默认是debug
|
||||
*/
|
||||
public static final void toastMessage(final Activity activity,
|
||||
final String message) {
|
||||
toastMessage(activity, message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据一个网络连接(String)获取bitmap图像
|
||||
*
|
||||
* @param imageUri
|
||||
* @return
|
||||
* @throws MalformedURLException
|
||||
*/
|
||||
public static Bitmap getbitmap(String imageUri) {
|
||||
Log.v(TAG, "getbitmap:" + imageUri);
|
||||
// 显示网络上的图片
|
||||
Bitmap bitmap = null;
|
||||
try {
|
||||
URL myFileUrl = new URL(imageUri);
|
||||
HttpURLConnection conn = (HttpURLConnection) myFileUrl
|
||||
.openConnection();
|
||||
conn.setDoInput(true);
|
||||
conn.connect();
|
||||
InputStream is = conn.getInputStream();
|
||||
bitmap = BitmapFactory.decodeStream(is);
|
||||
is.close();
|
||||
|
||||
Log.v(TAG, "image download finished." + imageUri);
|
||||
} catch (OutOfMemoryError e) {
|
||||
e.printStackTrace();
|
||||
bitmap = null;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Log.v(TAG, "getbitmap bmp fail---");
|
||||
bitmap = null;
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public static void release() {
|
||||
mProgressDialog = null;
|
||||
mToast = null;
|
||||
}
|
||||
|
||||
// =========
|
||||
// =通过URI获取本地图片的path
|
||||
// =兼容android 5.0
|
||||
// ==========
|
||||
|
||||
public static String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
|
||||
public static int Build_VERSION_KITKAT = 19;
|
||||
public static String getPath(final Context context, final Uri uri) {
|
||||
|
||||
final boolean isKitKat = Build.VERSION.SDK_INT >= 19;
|
||||
|
||||
// DocumentProvider
|
||||
if (isKitKat && isDocumentUri(context, uri)) {
|
||||
// ExternalStorageProvider
|
||||
if (isExternalStorageDocument(uri)) {
|
||||
final String docId = getDocumentId(uri);
|
||||
final String[] split = docId.split(":");
|
||||
final String type = split[0];
|
||||
|
||||
if ("primary".equalsIgnoreCase(type)) {
|
||||
return Environment.getExternalStorageDirectory() + "/" + split[1];
|
||||
}
|
||||
|
||||
}
|
||||
// DownloadsProvider
|
||||
else if (isDownloadsDocument(uri)) {
|
||||
|
||||
final String id = getDocumentId(uri);
|
||||
final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"),
|
||||
Long.valueOf(id));
|
||||
|
||||
return getDataColumn(context, contentUri, null, null);
|
||||
}
|
||||
// MediaProvider
|
||||
else if (isMediaDocument(uri)) {
|
||||
final String docId = getDocumentId(uri);
|
||||
final String[] split = docId.split(":");
|
||||
final String type = split[0];
|
||||
|
||||
Uri contentUri = null;
|
||||
if ("image".equals(type)) {
|
||||
contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||
} else if ("video".equals(type)) {
|
||||
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
|
||||
} else if ("audio".equals(type)) {
|
||||
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
|
||||
}
|
||||
|
||||
final String selection = "_id=?";
|
||||
final String[] selectionArgs = new String[] { split[1] };
|
||||
|
||||
return getDataColumn(context, contentUri, selection, selectionArgs);
|
||||
}
|
||||
}
|
||||
// MediaStore (and general)
|
||||
else if ("content".equalsIgnoreCase(uri.getScheme())) {
|
||||
|
||||
// Return the remote address
|
||||
if (isGooglePhotosUri(uri))
|
||||
return uri.getLastPathSegment();
|
||||
|
||||
return getDataColumn(context, uri, null, null);
|
||||
}
|
||||
// File
|
||||
else if ("file".equalsIgnoreCase(uri.getScheme())) {
|
||||
return uri.getPath();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final String PATH_DOCUMENT = "document";
|
||||
|
||||
/**
|
||||
* Test if the given URI represents a {@link Document} backed by a
|
||||
* {@link DocumentsProvider}.
|
||||
*/
|
||||
private static boolean isDocumentUri(Context context, Uri uri) {
|
||||
final List<String> paths = uri.getPathSegments();
|
||||
if (paths.size() < 2) {
|
||||
return false;
|
||||
}
|
||||
if (!PATH_DOCUMENT.equals(paths.get(0))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static String getDocumentId(Uri documentUri) {
|
||||
final List<String> paths = documentUri.getPathSegments();
|
||||
if (paths.size() < 2) {
|
||||
throw new IllegalArgumentException("Not a document: " + documentUri);
|
||||
}
|
||||
if (!PATH_DOCUMENT.equals(paths.get(0))) {
|
||||
throw new IllegalArgumentException("Not a document: " + documentUri);
|
||||
}
|
||||
return paths.get(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of the data column for this Uri. This is useful for
|
||||
* MediaStore Uris, and other file-based ContentProviders.
|
||||
*
|
||||
* @param context
|
||||
* The context.
|
||||
* @param uri
|
||||
* The Uri to query.
|
||||
* @param selection
|
||||
* (Optional) Filter used in the query.
|
||||
* @param selectionArgs
|
||||
* (Optional) Selection arguments used in the query.
|
||||
* [url=home.php?mod=space&uid=7300]@return[/url] The value of
|
||||
* the _data column, which is typically a file path.
|
||||
*/
|
||||
public static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {
|
||||
|
||||
Cursor cursor = null;
|
||||
final String column = "_data";
|
||||
final String[] projection = { column };
|
||||
|
||||
try {
|
||||
cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
final int index = cursor.getColumnIndexOrThrow(column);
|
||||
return cursor.getString(index);
|
||||
}
|
||||
} finally {
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri
|
||||
* The Uri to check.
|
||||
* @return Whether the Uri authority is ExternalStorageProvider.
|
||||
*/
|
||||
public static boolean isExternalStorageDocument(Uri uri) {
|
||||
return "com.android.externalstorage.documents".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri
|
||||
* The Uri to check.
|
||||
* @return Whether the Uri authority is DownloadsProvider.
|
||||
*/
|
||||
public static boolean isDownloadsDocument(Uri uri) {
|
||||
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri
|
||||
* The Uri to check.
|
||||
* @return Whether the Uri authority is MediaProvider.
|
||||
*/
|
||||
public static boolean isMediaDocument(Uri uri) {
|
||||
return "com.android.providers.media.documents".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri
|
||||
* The Uri to check.
|
||||
* @return Whether the Uri authority is Google Photos.
|
||||
*/
|
||||
public static boolean isGooglePhotosUri(Uri uri) {
|
||||
return "com.google.android.apps.photos.content".equals(uri.getAuthority());
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
|
@ -150,146 +150,147 @@ public final class R {
|
|||
public static final int selector_load_more=0x7f02006e;
|
||||
public static final int selector_logout=0x7f02006f;
|
||||
public static final int sgbf=0x7f020070;
|
||||
public static final int shap_divider=0x7f020071;
|
||||
public static final int shape_color_frame=0x7f020072;
|
||||
public static final int shape_grid_item=0x7f020073;
|
||||
public static final int shape_left_radius_color_square=0x7f020074;
|
||||
public static final int shape_radius=0x7f020075;
|
||||
public static final int shape_radius_color_square=0x7f020076;
|
||||
public static final int shape_radius_square=0x7f020077;
|
||||
public static final int splash=0x7f020078;
|
||||
public static final int tab_bg_selector=0x7f020079;
|
||||
public static final int user_icon_default=0x7f02007a;
|
||||
public static final int user_icon_default_main=0x7f02007b;
|
||||
public static final int w01=0x7f02007c;
|
||||
public static final int w02=0x7f02007d;
|
||||
public static final int w03=0x7f02007e;
|
||||
public static final int w04=0x7f02007f;
|
||||
public static final int w05=0x7f020080;
|
||||
public static final int welcome_background=0x7f020081;
|
||||
public static final int shap_circle=0x7f020071;
|
||||
public static final int shap_divider=0x7f020072;
|
||||
public static final int shape_color_frame=0x7f020073;
|
||||
public static final int shape_grid_item=0x7f020074;
|
||||
public static final int shape_left_radius_color_square=0x7f020075;
|
||||
public static final int shape_radius=0x7f020076;
|
||||
public static final int shape_radius_color_square=0x7f020077;
|
||||
public static final int shape_radius_square=0x7f020078;
|
||||
public static final int splash=0x7f020079;
|
||||
public static final int tab_bg_selector=0x7f02007a;
|
||||
public static final int user_icon_default=0x7f02007b;
|
||||
public static final int user_icon_default_main=0x7f02007c;
|
||||
public static final int w01=0x7f02007d;
|
||||
public static final int w02=0x7f02007e;
|
||||
public static final int w03=0x7f02007f;
|
||||
public static final int w04=0x7f020080;
|
||||
public static final int w05=0x7f020081;
|
||||
public static final int welcome_background=0x7f020082;
|
||||
}
|
||||
public static final class id {
|
||||
public static final int action_settings=0x7f0a00c6;
|
||||
public static final int action_settings=0x7f0a00c9;
|
||||
public static final int actionbar_comment=0x7f0a000f;
|
||||
public static final int area_commit=0x7f0a0014;
|
||||
public static final int bt_scrollLeft=0x7f0a00a4;
|
||||
public static final int bt_scrollRight=0x7f0a00a5;
|
||||
public static final int btn_about=0x7f0a0056;
|
||||
public static final int btn_add=0x7f0a009b;
|
||||
public static final int btn_add_good=0x7f0a007d;
|
||||
public static final int btn_add_news=0x7f0a007e;
|
||||
public static final int btn_add_shop=0x7f0a007c;
|
||||
public static final int btn_buy_good=0x7f0a0098;
|
||||
public static final int btn_commit=0x7f0a00c5;
|
||||
public static final int btn_contact=0x7f0a0057;
|
||||
public static final int btn_dlg_ok=0x7f0a0094;
|
||||
public static final int bt_scrollLeft=0x7f0a00a7;
|
||||
public static final int bt_scrollRight=0x7f0a00a8;
|
||||
public static final int btn_about=0x7f0a0057;
|
||||
public static final int btn_add=0x7f0a009e;
|
||||
public static final int btn_add_good=0x7f0a0080;
|
||||
public static final int btn_add_news=0x7f0a0081;
|
||||
public static final int btn_add_shop=0x7f0a007f;
|
||||
public static final int btn_buy_good=0x7f0a009b;
|
||||
public static final int btn_commit=0x7f0a00c8;
|
||||
public static final int btn_contact=0x7f0a0058;
|
||||
public static final int btn_dlg_ok=0x7f0a0097;
|
||||
public static final int btn_feedback_submit=0x7f0a001b;
|
||||
public static final int btn_hide_ads=0x7f0a0022;
|
||||
public static final int btn_login=0x7f0a003c;
|
||||
public static final int btn_look_goods=0x7f0a007a;
|
||||
public static final int btn_look_news=0x7f0a007b;
|
||||
public static final int btn_look_shops=0x7f0a0079;
|
||||
public static final int btn_look_users=0x7f0a0078;
|
||||
public static final int btn_order_count_less=0x7f0a005f;
|
||||
public static final int btn_order_count_more=0x7f0a0061;
|
||||
public static final int btn_order_submit=0x7f0a0066;
|
||||
public static final int btn_login=0x7f0a0036;
|
||||
public static final int btn_look_goods=0x7f0a007d;
|
||||
public static final int btn_look_news=0x7f0a007e;
|
||||
public static final int btn_look_shops=0x7f0a007c;
|
||||
public static final int btn_look_users=0x7f0a007b;
|
||||
public static final int btn_order_count_less=0x7f0a0060;
|
||||
public static final int btn_order_count_more=0x7f0a0062;
|
||||
public static final int btn_order_submit=0x7f0a0067;
|
||||
public static final int btn_publish=0x7f0a0017;
|
||||
public static final int btn_qq=0x7f0a0035;
|
||||
public static final int btn_reg_now=0x7f0a006d;
|
||||
public static final int btn_register=0x7f0a0033;
|
||||
public static final int btn_set_time=0x7f0a0063;
|
||||
public static final int btn_share=0x7f0a0058;
|
||||
public static final int cancel=0x7f0a00c8;
|
||||
public static final int cb_rem_psd=0x7f0a0034;
|
||||
public static final int btn_qq=0x7f0a003a;
|
||||
public static final int btn_reg_now=0x7f0a0070;
|
||||
public static final int btn_register=0x7f0a0039;
|
||||
public static final int btn_set_time=0x7f0a0064;
|
||||
public static final int btn_share=0x7f0a0059;
|
||||
public static final int cancel=0x7f0a00cb;
|
||||
public static final int cb_rem_psd=0x7f0a0038;
|
||||
public static final int comment_commit=0x7f0a0016;
|
||||
public static final int comment_content=0x7f0a0015;
|
||||
public static final int comment_item=0x7f0a0011;
|
||||
public static final int comment_list=0x7f0a0012;
|
||||
public static final int commit_scroll=0x7f0a0010;
|
||||
public static final int content_comment=0x7f0a008d;
|
||||
public static final int content_image=0x7f0a0085;
|
||||
public static final int content_text=0x7f0a0084;
|
||||
public static final int datepicker=0x7f0a0092;
|
||||
public static final int content_comment=0x7f0a0090;
|
||||
public static final int content_image=0x7f0a0088;
|
||||
public static final int content_text=0x7f0a0087;
|
||||
public static final int datepicker=0x7f0a0095;
|
||||
public static final int edit_content=0x7f0a0019;
|
||||
public static final int edit_title=0x7f0a0018;
|
||||
public static final int et_comfirm_psd=0x7f0a0069;
|
||||
public static final int et_commit=0x7f0a00c4;
|
||||
public static final int et_comfirm_psd=0x7f0a006b;
|
||||
public static final int et_commit=0x7f0a00c7;
|
||||
public static final int et_feedback_content=0x7f0a001a;
|
||||
public static final int et_mineinfo_cademy=0x7f0a0049;
|
||||
public static final int et_mineinfo_dornum=0x7f0a004b;
|
||||
public static final int et_mineinfo_dorpart=0x7f0a004a;
|
||||
public static final int et_mineinfo_phone=0x7f0a004c;
|
||||
public static final int et_mineinfo_qq=0x7f0a004d;
|
||||
public static final int et_mineinfo_school=0x7f0a0048;
|
||||
public static final int et_mineinfo_username=0x7f0a0047;
|
||||
public static final int et_order_phone=0x7f0a0064;
|
||||
public static final int et_order_words=0x7f0a0065;
|
||||
public static final int et_password=0x7f0a003b;
|
||||
public static final int et_phone=0x7f0a006b;
|
||||
public static final int et_username=0x7f0a003a;
|
||||
public static final int et_mineinfo_cademy=0x7f0a004b;
|
||||
public static final int et_mineinfo_dornum=0x7f0a004d;
|
||||
public static final int et_mineinfo_dorpart=0x7f0a004c;
|
||||
public static final int et_mineinfo_phone=0x7f0a004e;
|
||||
public static final int et_mineinfo_qq=0x7f0a004f;
|
||||
public static final int et_mineinfo_school=0x7f0a004a;
|
||||
public static final int et_mineinfo_username=0x7f0a0049;
|
||||
public static final int et_order_phone=0x7f0a0065;
|
||||
public static final int et_order_words=0x7f0a0066;
|
||||
public static final int et_password=0x7f0a0034;
|
||||
public static final int et_phone=0x7f0a006e;
|
||||
public static final int et_username=0x7f0a0031;
|
||||
public static final int fl_image_ads=0x7f0a0020;
|
||||
public static final int gv_classroom=0x7f0a000e;
|
||||
public static final int gv_food_class=0x7f0a0070;
|
||||
public static final int gv_gift_class=0x7f0a006f;
|
||||
public static final int gv_food_class=0x7f0a0073;
|
||||
public static final int gv_gift_class=0x7f0a0072;
|
||||
public static final int gv_library=0x7f0a002e;
|
||||
public static final int gv_out_class=0x7f0a0071;
|
||||
public static final int gv_school_class=0x7f0a006e;
|
||||
public static final int header_shop_all=0x7f0a0072;
|
||||
public static final int imageview=0x7f0a00b8;
|
||||
public static final int img_call=0x7f0a00bf;
|
||||
public static final int img_chooseImage=0x7f0a00b7;
|
||||
public static final int gv_out_class=0x7f0a0074;
|
||||
public static final int gv_school_class=0x7f0a0071;
|
||||
public static final int header_shop_all=0x7f0a0075;
|
||||
public static final int imageview=0x7f0a00bb;
|
||||
public static final int img_call=0x7f0a00c2;
|
||||
public static final int img_chooseImage=0x7f0a00ba;
|
||||
public static final int img_date=0x7f0a001d;
|
||||
public static final int img_item=0x7f0a00a6;
|
||||
public static final int img_search=0x7f0a009f;
|
||||
public static final int img_shop=0x7f0a00b0;
|
||||
public static final int img_item=0x7f0a00a9;
|
||||
public static final int img_search=0x7f0a00a2;
|
||||
public static final int img_shop=0x7f0a00b3;
|
||||
public static final int img_welcome=0x7f0a0001;
|
||||
public static final int index_comment=0x7f0a008c;
|
||||
public static final int item_action_comment=0x7f0a0086;
|
||||
public static final int item_action_hate=0x7f0a0088;
|
||||
public static final int item_action_love=0x7f0a0089;
|
||||
public static final int item_action_share=0x7f0a0087;
|
||||
public static final int index_comment=0x7f0a008f;
|
||||
public static final int item_action_comment=0x7f0a0089;
|
||||
public static final int item_action_hate=0x7f0a008b;
|
||||
public static final int item_action_love=0x7f0a008c;
|
||||
public static final int item_action_share=0x7f0a008a;
|
||||
public static final int listScrollView=0x7f0a001c;
|
||||
public static final int ll_commit_parent_view=0x7f0a00c3;
|
||||
public static final int ll_commit_son_view=0x7f0a008f;
|
||||
public static final int ll_commit_parent_view=0x7f0a00c6;
|
||||
public static final int ll_commit_son_view=0x7f0a0092;
|
||||
public static final int ll_row1=0x7f0a002f;
|
||||
public static final int ll_row2=0x7f0a0030;
|
||||
public static final int ll_row3=0x7f0a0031;
|
||||
public static final int ll_row4=0x7f0a006a;
|
||||
public static final int ll_row6=0x7f0a006c;
|
||||
public static final int ll_row2=0x7f0a0032;
|
||||
public static final int ll_row3=0x7f0a0035;
|
||||
public static final int ll_row4=0x7f0a006c;
|
||||
public static final int ll_row6=0x7f0a006f;
|
||||
public static final int loadmore=0x7f0a0013;
|
||||
public static final int lv_bxt_news=0x7f0a0003;
|
||||
public static final int lv_goods_list=0x7f0a00ba;
|
||||
public static final int lv_goods_list=0x7f0a00bd;
|
||||
public static final int lv_information=0x7f0a002d;
|
||||
public static final int lv_mine_about=0x7f0a003f;
|
||||
public static final int lv_mine_order=0x7f0a003e;
|
||||
public static final int lv_mine_soft=0x7f0a0076;
|
||||
public static final int lv_mine_user=0x7f0a003d;
|
||||
public static final int lv_mine_about=0x7f0a0041;
|
||||
public static final int lv_mine_order=0x7f0a0040;
|
||||
public static final int lv_mine_soft=0x7f0a0079;
|
||||
public static final int lv_mine_user=0x7f0a003f;
|
||||
public static final int lv_news=0x7f0a0023;
|
||||
public static final int lv_order_info=0x7f0a0067;
|
||||
public static final int lv_shop_all=0x7f0a0073;
|
||||
public static final int modify=0x7f0a00c7;
|
||||
public static final int mymultiViewGroup=0x7f0a00a9;
|
||||
public static final int new_login_btn=0x7f0a0036;
|
||||
public static final int pagertab=0x7f0a0075;
|
||||
public static final int lv_order_info=0x7f0a0068;
|
||||
public static final int lv_shop_all=0x7f0a0076;
|
||||
public static final int modify=0x7f0a00ca;
|
||||
public static final int mymultiViewGroup=0x7f0a00ac;
|
||||
public static final int new_login_btn=0x7f0a003b;
|
||||
public static final int pagertab=0x7f0a0078;
|
||||
public static final int pull_refresh_list=0x7f0a0002;
|
||||
public static final int ratingBar1=0x7f0a00bc;
|
||||
public static final int rb_rate=0x7f0a00b6;
|
||||
public static final int relaGrid=0x7f0a0099;
|
||||
public static final int rl_last=0x7f0a0032;
|
||||
public static final int rl_splash=0x7f0a0077;
|
||||
public static final int ratingBar1=0x7f0a00bf;
|
||||
public static final int rb_rate=0x7f0a00b9;
|
||||
public static final int relaGrid=0x7f0a009c;
|
||||
public static final int rl_last=0x7f0a0037;
|
||||
public static final int rl_splash=0x7f0a007a;
|
||||
public static final int rl_welcome=0x7f0a0000;
|
||||
public static final int sp_bxt_header=0x7f0a009c;
|
||||
public static final int textView1=0x7f0a00a0;
|
||||
public static final int textview=0x7f0a00b9;
|
||||
public static final int time_comment=0x7f0a008e;
|
||||
public static final int time_text=0x7f0a0082;
|
||||
public static final int timepicker=0x7f0a0093;
|
||||
public static final int title_text=0x7f0a0083;
|
||||
public static final int tp_dlg_time=0x7f0a0095;
|
||||
public static final int tv_bowl=0x7f0a0050;
|
||||
public static final int sp_bxt_header=0x7f0a009f;
|
||||
public static final int textView1=0x7f0a00a3;
|
||||
public static final int textview=0x7f0a00bc;
|
||||
public static final int time_comment=0x7f0a0091;
|
||||
public static final int time_text=0x7f0a0085;
|
||||
public static final int timepicker=0x7f0a0096;
|
||||
public static final int title_text=0x7f0a0086;
|
||||
public static final int tp_dlg_time=0x7f0a0098;
|
||||
public static final int tv_bowl=0x7f0a0051;
|
||||
public static final int tv_bxt_news_holder1=0x7f0a0009;
|
||||
public static final int tv_bxt_news_holder2=0x7f0a000a;
|
||||
public static final int tv_bxt_news_item_title=0x7f0a008a;
|
||||
public static final int tv_bxt_news_item_title=0x7f0a008d;
|
||||
public static final int tv_bxt_news_loc=0x7f0a0008;
|
||||
public static final int tv_bxt_news_point=0x7f0a000b;
|
||||
public static final int tv_bxt_news_speaker=0x7f0a0006;
|
||||
|
@ -297,18 +298,19 @@ public final class R {
|
|||
public static final int tv_bxt_news_time=0x7f0a0007;
|
||||
public static final int tv_bxt_news_title=0x7f0a0004;
|
||||
public static final int tv_bxt_news_topic=0x7f0a0005;
|
||||
public static final int tv_cademy=0x7f0a0053;
|
||||
public static final int tv_chooseText=0x7f0a009a;
|
||||
public static final int tv_commit_content=0x7f0a0091;
|
||||
public static final int tv_commit_title=0x7f0a00c2;
|
||||
public static final int tv_commit_user=0x7f0a0090;
|
||||
public static final int tv_cademy=0x7f0a0054;
|
||||
public static final int tv_chooseText=0x7f0a009d;
|
||||
public static final int tv_comfirm_psd=0x7f0a006a;
|
||||
public static final int tv_commit_content=0x7f0a0094;
|
||||
public static final int tv_commit_title=0x7f0a00c5;
|
||||
public static final int tv_commit_user=0x7f0a0093;
|
||||
public static final int tv_day=0x7f0a001f;
|
||||
public static final int tv_dorNum=0x7f0a0055;
|
||||
public static final int tv_dorPart=0x7f0a0054;
|
||||
public static final int tv_edit=0x7f0a009e;
|
||||
public static final int tv_good_name=0x7f0a0096;
|
||||
public static final int tv_good_price=0x7f0a0097;
|
||||
public static final int tv_hello_world=0x7f0a00a2;
|
||||
public static final int tv_dorNum=0x7f0a0056;
|
||||
public static final int tv_dorPart=0x7f0a0055;
|
||||
public static final int tv_edit=0x7f0a00a1;
|
||||
public static final int tv_good_name=0x7f0a0099;
|
||||
public static final int tv_good_price=0x7f0a009a;
|
||||
public static final int tv_hello_world=0x7f0a00a5;
|
||||
public static final int tv_info_item_content=0x7f0a002c;
|
||||
public static final int tv_info_item_holder=0x7f0a0029;
|
||||
public static final int tv_info_item_holder2=0x7f0a002a;
|
||||
|
@ -318,57 +320,59 @@ public final class R {
|
|||
public static final int tv_info_item_time=0x7f0a0027;
|
||||
public static final int tv_info_item_title=0x7f0a0024;
|
||||
public static final int tv_info_item_topic=0x7f0a0025;
|
||||
public static final int tv_info_title=0x7f0a009d;
|
||||
public static final int tv_item_content=0x7f0a00a8;
|
||||
public static final int tv_item_name=0x7f0a00a7;
|
||||
public static final int tv_me=0x7f0a004f;
|
||||
public static final int tv_mineinfo_cademy=0x7f0a0042;
|
||||
public static final int tv_mineinfo_dornum=0x7f0a0044;
|
||||
public static final int tv_mineinfo_dorpart=0x7f0a0043;
|
||||
public static final int tv_mineinfo_phone=0x7f0a0045;
|
||||
public static final int tv_mineinfo_qq=0x7f0a0046;
|
||||
public static final int tv_mineinfo_school=0x7f0a0041;
|
||||
public static final int tv_mineinfo_username=0x7f0a0040;
|
||||
public static final int tv_news_author=0x7f0a005a;
|
||||
public static final int tv_news_content=0x7f0a005c;
|
||||
public static final int tv_news_date=0x7f0a00ab;
|
||||
public static final int tv_news_time=0x7f0a005b;
|
||||
public static final int tv_news_title=0x7f0a0059;
|
||||
public static final int tv_news_type=0x7f0a00aa;
|
||||
public static final int tv_order_count=0x7f0a0060;
|
||||
public static final int tv_order_good=0x7f0a005e;
|
||||
public static final int tv_order_info_good_name=0x7f0a00ac;
|
||||
public static final int tv_order_info_price=0x7f0a00ae;
|
||||
public static final int tv_order_info_shop_name=0x7f0a00ad;
|
||||
public static final int tv_order_info_state=0x7f0a00af;
|
||||
public static final int tv_order_shop=0x7f0a005d;
|
||||
public static final int tv_order_time=0x7f0a0062;
|
||||
public static final int tv_reg_title=0x7f0a0068;
|
||||
public static final int tv_res=0x7f0a0080;
|
||||
public static final int tv_room=0x7f0a00a1;
|
||||
public static final int tv_school=0x7f0a0052;
|
||||
public static final int tv_scroll=0x7f0a00a3;
|
||||
public static final int tv_shop_discount=0x7f0a00b3;
|
||||
public static final int tv_shop_introduce=0x7f0a00c0;
|
||||
public static final int tv_shop_loc=0x7f0a00b5;
|
||||
public static final int tv_shop_location=0x7f0a00bd;
|
||||
public static final int tv_shop_name=0x7f0a00b1;
|
||||
public static final int tv_shop_paper=0x7f0a00b2;
|
||||
public static final int tv_shop_phone=0x7f0a00be;
|
||||
public static final int tv_shop_promotion=0x7f0a00c1;
|
||||
public static final int tv_shop_title=0x7f0a00bb;
|
||||
public static final int tv_shop_type=0x7f0a00b4;
|
||||
public static final int tv_title=0x7f0a007f;
|
||||
public static final int tv_username=0x7f0a004e;
|
||||
public static final int tv_info_title=0x7f0a00a0;
|
||||
public static final int tv_item_content=0x7f0a00ab;
|
||||
public static final int tv_item_name=0x7f0a00aa;
|
||||
public static final int tv_me=0x7f0a0050;
|
||||
public static final int tv_mineinfo_cademy=0x7f0a0044;
|
||||
public static final int tv_mineinfo_dornum=0x7f0a0046;
|
||||
public static final int tv_mineinfo_dorpart=0x7f0a0045;
|
||||
public static final int tv_mineinfo_phone=0x7f0a0047;
|
||||
public static final int tv_mineinfo_qq=0x7f0a0048;
|
||||
public static final int tv_mineinfo_school=0x7f0a0043;
|
||||
public static final int tv_mineinfo_username=0x7f0a0042;
|
||||
public static final int tv_news_author=0x7f0a005b;
|
||||
public static final int tv_news_content=0x7f0a005d;
|
||||
public static final int tv_news_date=0x7f0a00ae;
|
||||
public static final int tv_news_time=0x7f0a005c;
|
||||
public static final int tv_news_title=0x7f0a005a;
|
||||
public static final int tv_news_type=0x7f0a00ad;
|
||||
public static final int tv_order_count=0x7f0a0061;
|
||||
public static final int tv_order_good=0x7f0a005f;
|
||||
public static final int tv_order_info_good_name=0x7f0a00af;
|
||||
public static final int tv_order_info_price=0x7f0a00b1;
|
||||
public static final int tv_order_info_shop_name=0x7f0a00b0;
|
||||
public static final int tv_order_info_state=0x7f0a00b2;
|
||||
public static final int tv_order_shop=0x7f0a005e;
|
||||
public static final int tv_order_time=0x7f0a0063;
|
||||
public static final int tv_password=0x7f0a0033;
|
||||
public static final int tv_phone=0x7f0a006d;
|
||||
public static final int tv_reg_title=0x7f0a0069;
|
||||
public static final int tv_res=0x7f0a0083;
|
||||
public static final int tv_room=0x7f0a00a4;
|
||||
public static final int tv_school=0x7f0a0053;
|
||||
public static final int tv_scroll=0x7f0a00a6;
|
||||
public static final int tv_shop_discount=0x7f0a00b6;
|
||||
public static final int tv_shop_introduce=0x7f0a00c3;
|
||||
public static final int tv_shop_loc=0x7f0a00b8;
|
||||
public static final int tv_shop_location=0x7f0a00c0;
|
||||
public static final int tv_shop_name=0x7f0a00b4;
|
||||
public static final int tv_shop_paper=0x7f0a00b5;
|
||||
public static final int tv_shop_phone=0x7f0a00c1;
|
||||
public static final int tv_shop_promotion=0x7f0a00c4;
|
||||
public static final int tv_shop_title=0x7f0a00be;
|
||||
public static final int tv_shop_type=0x7f0a00b7;
|
||||
public static final int tv_title=0x7f0a0082;
|
||||
public static final int tv_username=0x7f0a0030;
|
||||
public static final int tv_week=0x7f0a001e;
|
||||
public static final int tv_xiaocai=0x7f0a0051;
|
||||
public static final int userName_comment=0x7f0a008b;
|
||||
public static final int user_callback=0x7f0a0039;
|
||||
public static final int user_logo=0x7f0a0038;
|
||||
public static final int user_name=0x7f0a0081;
|
||||
public static final int user_nickname=0x7f0a0037;
|
||||
public static final int tv_xiaocai=0x7f0a0052;
|
||||
public static final int userName_comment=0x7f0a008e;
|
||||
public static final int user_callback=0x7f0a003e;
|
||||
public static final int user_logo=0x7f0a003d;
|
||||
public static final int user_name=0x7f0a0084;
|
||||
public static final int user_nickname=0x7f0a003c;
|
||||
public static final int view_pager=0x7f0a0021;
|
||||
public static final int viewpager=0x7f0a0074;
|
||||
public static final int viewpager=0x7f0a0077;
|
||||
public static final int wv_wsq=0x7f0a000d;
|
||||
}
|
||||
public static final class layout {
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:background="@drawable/actionbar_background"
|
||||
android:padding="3dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_edit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:padding="5dp"
|
||||
android:onClick="clickBack"
|
||||
android:clickable="true"
|
||||
android:text="返回"
|
||||
android:textSize="18sp"
|
||||
android:textColor="#ffffff"
|
||||
android:typeface="monospace"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:text="个人资料"
|
||||
android:textSize="20sp"
|
||||
android:textColor="#ffffff"
|
||||
android:typeface="monospace"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_edit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:padding="5dp"
|
||||
android:onClick="clickEdit"
|
||||
android:clickable="true"
|
||||
android:text="编辑"
|
||||
android:textSize="18sp"
|
||||
android:textColor="#ffffff"
|
||||
android:typeface="monospace"/>
|
||||
|
||||
</RelativeLayout>
|
|
@ -1,46 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:background="@drawable/actionbar_background"
|
||||
android:padding="3dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_edit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:padding="5dp"
|
||||
android:text="取消"
|
||||
android:onClick="clickCancel"
|
||||
android:clickable="true"
|
||||
android:textSize="18sp"
|
||||
android:textColor="#ffffff"
|
||||
android:typeface="monospace"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:text="修改资料"
|
||||
android:textSize="20sp"
|
||||
android:textColor="#ffffff"
|
||||
android:typeface="monospace"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_edit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:padding="5dp"
|
||||
android:onClick="clickSave"
|
||||
android:clickable="true"
|
||||
android:text="保存"
|
||||
android:textSize="18sp"
|
||||
android:textColor="#ffffff"
|
||||
android:typeface="monospace"/>
|
||||
|
||||
</RelativeLayout>
|
|
@ -1,19 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:background="@drawable/actionbar_background"
|
||||
android:padding="3dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:text="校内新闻"
|
||||
android:textSize="20sp"
|
||||
android:textColor="#ffffff"
|
||||
android:typeface="monospace"/>
|
||||
|
||||
</RelativeLayout>
|
|
@ -1,19 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:background="@drawable/actionbar_background"
|
||||
android:padding="3dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:text="订单"
|
||||
android:textSize="20sp"
|
||||
android:textColor="#ffffff"
|
||||
android:typeface="monospace"/>
|
||||
|
||||
</RelativeLayout>
|
|
@ -1,19 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:background="@drawable/actionbar_background"
|
||||
android:padding="3dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:text="当前订单"
|
||||
android:textSize="20sp"
|
||||
android:textColor="#ffffff"
|
||||
android:typeface="monospace"/>
|
||||
|
||||
</RelativeLayout>
|
|
@ -1,29 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:background="@drawable/actionbar_background"
|
||||
android:padding="3dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:text="过桥米线"
|
||||
android:textSize="20sp"
|
||||
android:textColor="#ffffff"
|
||||
android:typeface="monospace"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/img_search"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/ic_search"/>
|
||||
|
||||
|
||||
|
||||
</RelativeLayout>
|
|
@ -1,31 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:background="@drawable/actionbar_background"
|
||||
android:padding="3dp" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:padding="5dp"
|
||||
android:onClick="clickSoftBack"
|
||||
android:clickable="true"
|
||||
android:text="返回"
|
||||
android:textSize="18sp"
|
||||
android:textColor="#ffffff"
|
||||
android:typeface="monospace"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:text="软件相关"
|
||||
android:textSize="20sp"
|
||||
android:textColor="#ffffff"
|
||||
android:typeface="monospace"/>
|
||||
|
||||
</RelativeLayout>
|
|
@ -1,28 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<include layout="@layout/header_bxt" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_room"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="15dp"
|
||||
android:text="教室:"
|
||||
android:textColor="#20B2AA"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_login"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="20dp"
|
||||
android:background="@drawable/actionbar_background"
|
||||
android:text="预定教室"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="18sp" />
|
||||
|
||||
</LinearLayout>
|
|
@ -1,48 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="2dp"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="90dp"
|
||||
android:background="#F5F5F5"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:padding="5dp" >
|
||||
|
||||
<!-- 新闻标题15字以内 -->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_news_type"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical|left"
|
||||
android:layout_weight="3"
|
||||
android:text="【博学堂】"
|
||||
android:textSize="18sp"
|
||||
android:textColor="#FF0000"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_news_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="2"
|
||||
android:text="大礼堂电影预告大礼堂电影预告"
|
||||
android:textColor="#696969"
|
||||
android:textSize="15sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_news_date"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="3"
|
||||
android:gravity="center"
|
||||
android:text="2014-4-28"
|
||||
android:textSize="13sp"
|
||||
android:typeface="monospace" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -1,80 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dp" >
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="96dp"
|
||||
android:layout_weight="2"
|
||||
android:background="#fffaf0"
|
||||
android:padding="5dp" >
|
||||
|
||||
<!-- 店铺名 -->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_order_info_good_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="10dp"
|
||||
android:text="韩式石锅拌饭"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<!-- 店铺类型 -->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_order_info_shop_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@id/tv_good_name"
|
||||
android:layout_centerVertical="true"
|
||||
android:text="xx店"
|
||||
android:textColor="#808080"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<!-- 店铺地点 -->
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@id/tv_good_name"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:text="二食堂三楼"
|
||||
android:textColor="#ff0000"
|
||||
android:textSize="12sp" />
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="96dp"
|
||||
android:layout_weight="5"
|
||||
android:background="#ff0000"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_order_info_price"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="72dp"
|
||||
android:gravity="center"
|
||||
android:text="¥ 9.0"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.3dp"
|
||||
android:background="#FFFFFF" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_order_info_state"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="24dp"
|
||||
android:gravity="center"
|
||||
android:text="未取餐"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -1,104 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dp" >
|
||||
|
||||
<!-- 商铺展示主图 96x96 -->
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/img_shop"
|
||||
android:layout_width="96dp"
|
||||
android:layout_height="96dp"
|
||||
android:background="@drawable/sgbf"
|
||||
android:contentDescription="商店展示主图" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="96dp"
|
||||
android:layout_alignBaseline="@id/img_shop"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_toRightOf="@id/img_shop"
|
||||
android:background="#fffaf0"
|
||||
android:padding="5dp" >
|
||||
|
||||
<!-- 店铺名 -->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_shop_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="10dp"
|
||||
android:text="韩式石锅拌饭"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<!-- 活动标志/劵 -->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_shop_paper"
|
||||
android:layout_width="15dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_alignBaseline="@id/tv_shop_name"
|
||||
android:layout_margin="2dp"
|
||||
android:layout_toRightOf="@id/tv_shop_name"
|
||||
android:background="#008000"
|
||||
android:gravity="center_vertical"
|
||||
android:visibility="gone"
|
||||
android:text="劵"
|
||||
android:textColor="#F8F8FF"
|
||||
android:textSize="12sp"
|
||||
android:typeface="monospace" />
|
||||
|
||||
<!-- 活动标志/折 -->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_shop_discount"
|
||||
android:layout_width="15dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_alignBaseline="@id/tv_shop_name"
|
||||
android:layout_margin="2dp"
|
||||
android:layout_toRightOf="@id/tv_shop_paper"
|
||||
android:background="#FF0000"
|
||||
android:gravity="center"
|
||||
android:text="新"
|
||||
android:textColor="#FfFfFF"
|
||||
android:textSize="12sp"
|
||||
android:typeface="monospace" />
|
||||
|
||||
<!-- 店铺类型 -->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_shop_type"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@id/tv_shop_name"
|
||||
android:layout_centerVertical="true"
|
||||
android:text="美食/中餐"
|
||||
android:textColor="#808080"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<!-- 店铺地点 -->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_shop_loc"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@id/tv_shop_name"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:text="二食堂三楼"
|
||||
android:textColor="#ff0000"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<!-- 评分 #F8F8FF -->
|
||||
|
||||
<RatingBar
|
||||
android:id="@+id/rb_rate"
|
||||
style="?android:attr/ratingBarStyleSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:rating="2.5" />
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
|
@ -1,24 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:padding="3dp"
|
||||
android:background="@drawable/tab_bg_selector">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageview"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_gravity="center_horizontal|top" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textview"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal|bottom"
|
||||
android:textSize="12sp"
|
||||
android:textColor="#ffffff"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -1,292 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<!-- 店铺展示背景图 -->
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="100dp"
|
||||
android:background="@drawable/actionbar_background"
|
||||
android:contentDescription="商店信息背景图"
|
||||
android:fitsSystemWindows="true" />
|
||||
|
||||
<!-- 店名 -->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_shop_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:gravity="center"
|
||||
android:text="过桥米线"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="26sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<RatingBar
|
||||
android:id="@+id/ratingBar1"
|
||||
style="?android:attr/ratingBarStyleSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:rating="1.5" />
|
||||
</FrameLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1.2dp"
|
||||
android:background="#bb000000" />
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="20dp" >
|
||||
|
||||
<!-- 店铺信息 -->
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:background="#F5F5F5"
|
||||
android:padding="10dp" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_shop_location"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="位置:二食堂二楼"
|
||||
android:textColor="#808080"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_shop_phone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="电话:13308647200"
|
||||
android:textColor="#808080"
|
||||
android:textSize="12sp"
|
||||
android:typeface="monospace" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/img_call"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/ic_phone3" />
|
||||
</RelativeLayout>
|
||||
|
||||
<!-- 店铺简介 -->
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:text="店铺简介"
|
||||
android:textColor="#2F4F4F"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:gravity="center"
|
||||
android:background="#F5F5F5"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_shop_introduce"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:lineSpacingMultiplier="1.5"
|
||||
android:padding="10dp"
|
||||
android:text="暂无"
|
||||
android:textColor="#696969"
|
||||
android:textSize="14sp"
|
||||
android:typeface="monospace" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<!-- 促销信息 -->
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:text="最新公告"
|
||||
android:textColor="#2F4F4F"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:background="#F5F5F5"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_shop_promotion"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:lineSpacingMultiplier="1.5"
|
||||
android:padding="10dp"
|
||||
android:text=" 本店最近新推出多种美食,米线A情侣版--¥10,欢迎大家一起来品尝。有免费免单的机会哦"
|
||||
android:textColor="#696969"
|
||||
android:textSize="14sp"
|
||||
android:typeface="monospace" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 历史评价记录 -->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_commit_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:text="历史评价 (2)"
|
||||
android:textColor="#2F4F4F"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_commit_parent_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:background="#F5F5F5"
|
||||
android:orientation="vertical"
|
||||
android:padding="2dp" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_commit_son_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="3dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_commit_user"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="2"
|
||||
android:text="stonekity:"
|
||||
android:textColor="#2F4F4F"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_commit_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:text="米线很不错,味道真棒。价格还比较实惠,这个学期我几乎天天吃米线,真心觉得是美好的回忆"
|
||||
android:textColor="#696969"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="3dp" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="2"
|
||||
android:text="猫猫:"
|
||||
android:textColor="#2F4F4F"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:text="很好吃的哦, 希望推出更多的新品"
|
||||
android:textColor="#696969"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="3dp" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="2"
|
||||
android:text="丫丫:"
|
||||
android:textColor="#2F4F4F"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:text="天天吃米线, 相信自己总有一天也会变成米线, (*^__^*) 嘻嘻……"
|
||||
android:textColor="#696969"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 发表评论 -->
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<EditText
|
||||
android:id="@+id/et_commit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_weight="1"
|
||||
android:background="#F5F5F5"
|
||||
android:hint="亲,(*^__^*)"
|
||||
android:padding="8dp"
|
||||
android:textColor="#2F4F4F" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_commit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_weight="3"
|
||||
android:background="@drawable/actionbar_background"
|
||||
android:text="评论"
|
||||
android:textColor="#FFFFFF"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
|
@ -1,75 +0,0 @@
|
|||
package com.stone.shop.adapter;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import com.stone.shop.R;
|
||||
import com.stone.shop.model.BXTNews;
|
||||
import com.stone.shop.model.Good;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* 教学类-博学堂-讲座列表适配器
|
||||
*
|
||||
* @date 2014-5-10
|
||||
* @author Stone
|
||||
*/
|
||||
public class BXTListAdapter extends BaseAdapter {
|
||||
|
||||
private Context mContext;
|
||||
private List<BXTNews> mNewsList; // 商品列表信息
|
||||
private LayoutInflater mInflater = null;
|
||||
|
||||
public BXTListAdapter(Context context, List<BXTNews> newsList) {
|
||||
mContext = context;
|
||||
mNewsList = newsList;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mNewsList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return mNewsList.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
// 刷新列表中的数据
|
||||
public void refresh(List<BXTNews> list) {
|
||||
Log.i("BXTNewsAdapter", "Adapter刷新数据");
|
||||
mNewsList = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
BXTNewsHolder newsHolder;
|
||||
if (convertView == null) {
|
||||
convertView = mInflater.inflate(R.layout.bxt_list_item, null);
|
||||
newsHolder = new BXTNewsHolder();
|
||||
newsHolder.tvBXTNewsTitle = (TextView) convertView
|
||||
.findViewById(R.id.tv_bxt_news_item_title);
|
||||
convertView.setTag(newsHolder);
|
||||
} else {
|
||||
newsHolder = (BXTNewsHolder) convertView.getTag();
|
||||
}
|
||||
newsHolder.tvBXTNewsTitle.setText(mNewsList.get(position).getTitle());
|
||||
return convertView;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
package com.stone.shop.adapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.stone.shop.R;
|
||||
import com.stone.shop.model.Classroom;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class ClassroomAdapter extends BaseAdapter {
|
||||
|
||||
private Context mContext;
|
||||
private List<Classroom> mNewsList; // 商品列表信息
|
||||
private LayoutInflater mInflater = null;
|
||||
|
||||
public ClassroomAdapter(Context context, List<Classroom> newsList) {
|
||||
mContext = context;
|
||||
mNewsList = newsList;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mNewsList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return mNewsList.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
// 刷新列表中的数据
|
||||
public void refresh(List<Classroom> list) {
|
||||
mNewsList = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
ViewHolder viewHolder;
|
||||
if (convertView == null) {
|
||||
convertView = mInflater.inflate(R.layout.gv_item_classroom, null);
|
||||
viewHolder = new ViewHolder();
|
||||
viewHolder.tv_chooseText = (TextView) convertView.findViewById(R.id.tv_chooseText);
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
viewHolder.tv_chooseText.setText(mNewsList.get(position).getName());
|
||||
return convertView;
|
||||
}
|
||||
|
||||
class ViewHolder {
|
||||
|
||||
public TextView tv_chooseText; // 博学堂讲座标题
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
package com.stone.shop.adapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.stone.shop.R;
|
||||
import com.stone.shop.model.Good;
|
||||
|
||||
public class GoodsListAdapter extends BaseAdapter {
|
||||
|
||||
private Context mContext;
|
||||
private List<Good> mGoodsList; // 商品列表信息
|
||||
private LayoutInflater mInflater = null;
|
||||
|
||||
public GoodsListAdapter(Context context, List<Good> goodsList) {
|
||||
mContext = context;
|
||||
mGoodsList = goodsList;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mGoodsList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return mGoodsList.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
// 刷新列表中的数据
|
||||
public void refresh(List<Good> list) {
|
||||
mGoodsList = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
GoodsHolder goodHolder;
|
||||
if (convertView == null) {
|
||||
convertView = mInflater.inflate(R.layout.goods_list_item, null);
|
||||
goodHolder = new GoodsHolder();
|
||||
goodHolder.tvName = (TextView) convertView
|
||||
.findViewById(R.id.tv_good_name);
|
||||
goodHolder.tvPrice = (TextView) convertView
|
||||
.findViewById(R.id.tv_good_price);
|
||||
goodHolder.btnBuyGood = (TextView) convertView
|
||||
.findViewById(R.id.btn_buy_good);
|
||||
convertView.setTag(goodHolder);
|
||||
} else {
|
||||
goodHolder = (GoodsHolder) convertView.getTag();
|
||||
}
|
||||
goodHolder.tvName.setText(mGoodsList.get(position).getName());
|
||||
goodHolder.tvPrice.setText("¥"+mGoodsList.get(position).getPrice());
|
||||
return convertView;
|
||||
}
|
||||
|
||||
}
|
|
@ -23,7 +23,7 @@ public class GridAdapter extends BaseAdapter {
|
|||
|
||||
//学习小菜
|
||||
public static final String[] mSchoolTexts = TypeDef.typeSonList1;
|
||||
private int[] mSchoolImages = { R.drawable.ic_8, R.drawable.ic_8, R.drawable.ic_8 };
|
||||
private int[] mSchoolImages = { R.drawable.ic_81, R.drawable.ic_82, R.drawable.ic_8 };
|
||||
|
||||
//吃饭小菜
|
||||
public static final String[] mFoodTexts = TypeDef.typeSonList2;
|
||||
|
@ -31,9 +31,9 @@ public class GridAdapter extends BaseAdapter {
|
|||
|
||||
//购物小菜
|
||||
public static final String[] mGiftTexts = TypeDef.typeSonList3;
|
||||
private int[] mGiftImages = { R.drawable.ic_7, R.drawable.ic_7,
|
||||
R.drawable.ic_7, R.drawable.ic_7, R.drawable.ic_7,
|
||||
R.drawable.ic_7, R.drawable.ic_7};
|
||||
private int[] mGiftImages = { R.drawable.ic_71, R.drawable.ic_72,
|
||||
R.drawable.ic_73, R.drawable.ic_74, R.drawable.ic_75,
|
||||
R.drawable.ic_76, R.drawable.ic_77};
|
||||
|
||||
//疯狂小菜
|
||||
public static final String[] mOutTexts = TypeDef.typeSonList4;
|
||||
|
|
|
@ -1,114 +0,0 @@
|
|||
package com.stone.shop.adapter;
|
||||
|
||||
import android.R.integer;
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.stone.date.TypeDef;
|
||||
import com.stone.shop.R;
|
||||
|
||||
/**
|
||||
* 生活-- 网格布局(ImageView+TextView)适配器
|
||||
*
|
||||
* @date 2014-4-24
|
||||
* @author Stone
|
||||
*/
|
||||
public class GridAdapter extends BaseAdapter {
|
||||
|
||||
private Context mContext;
|
||||
private int mIndex = 0; // 代表当前需要适配页面中第几个GridView
|
||||
|
||||
//学习小菜
|
||||
public static String[] mSchoolTexts = TypeDef.typeSonList1;
|
||||
private int[] mSchoolImages = { R.drawable.ic_81, R.drawable.ic_82, R.drawable.ic_8 };
|
||||
|
||||
//吃饭小菜
|
||||
public static String[] mFoodTexts = TypeDef.typeSonList2;
|
||||
private int[] mFoodImages = { R.drawable.ic_41, R.drawable.ic_42};
|
||||
|
||||
//购物小菜
|
||||
public static String[] mGiftTexts = TypeDef.typeSonList3;
|
||||
private int[] mGiftImages = { R.drawable.ic_71, R.drawable.ic_72,
|
||||
R.drawable.ic_73, R.drawable.ic_74, R.drawable.ic_75,
|
||||
R.drawable.ic_76, R.drawable.ic_77};
|
||||
|
||||
//疯狂小菜
|
||||
public static String[] mOutTexts = TypeDef.typeSonList4;
|
||||
private int[] mOutImages = { R.drawable.ic_3, R.drawable.ic_3,
|
||||
R.drawable.ic_3, R.drawable.ic_3, R.drawable.ic_3,
|
||||
R.drawable.ic_3, R.drawable.ic_3 };
|
||||
|
||||
public GridAdapter(Context context, int index) {
|
||||
mContext = context;
|
||||
mIndex = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
int count = 0;
|
||||
switch (mIndex) {
|
||||
case 0:
|
||||
count = mFoodImages.length;
|
||||
break;
|
||||
case 1:
|
||||
count = mGiftImages.length;
|
||||
break;
|
||||
case 2:
|
||||
count = mOutImages.length;
|
||||
break;
|
||||
case 3:
|
||||
count = mSchoolImages.length;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View view = View.inflate(mContext, R.layout.shop_grid_item, null);
|
||||
// RelativeLayout rl = (RelativeLayout)
|
||||
// view.findViewById(R.id.relaGrid);
|
||||
|
||||
ImageView image = (ImageView) view.findViewById(R.id.img_chooseImage);
|
||||
TextView text = (TextView) view.findViewById(R.id.tv_chooseText);
|
||||
switch (mIndex) {
|
||||
case 0:
|
||||
image.setImageResource(mFoodImages[position]);
|
||||
text.setText(mFoodTexts[position]);
|
||||
break;
|
||||
case 1:
|
||||
image.setImageResource(mGiftImages[position]);
|
||||
text.setText(mGiftTexts[position]);
|
||||
break;
|
||||
case 2:
|
||||
image.setImageResource(mOutImages[position]);
|
||||
text.setText(mOutTexts[position]);
|
||||
break;
|
||||
case 3:
|
||||
image.setImageResource(mSchoolImages[position]);
|
||||
text.setText(mSchoolTexts[position]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
package com.stone.shop.adapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Parcelable;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* 首页--图片轮播AutoScrollViewPager适配器
|
||||
* @author Stone
|
||||
*/
|
||||
public class ImagePagerAdapter extends PagerAdapter {
|
||||
|
||||
private List<View> mImgViews;
|
||||
|
||||
public ImagePagerAdapter(Context context, List<View> imgViews) {
|
||||
this.mImgViews = imgViews;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
if(mImgViews != null){
|
||||
return mImgViews.size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object instantiateItem(View arg0, int arg1) {
|
||||
((ViewPager) arg0).addView(mImgViews.get(arg1));
|
||||
return mImgViews.get(arg1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyItem(View arg0, int arg1, Object arg2) {
|
||||
((ViewPager) arg0).removeView(mImgViews.get(arg1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViewFromObject(View arg0, Object arg1) {
|
||||
return arg0 == arg1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreState(Parcelable arg0, ClassLoader arg1) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Parcelable saveState() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startUpdate(View arg0) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishUpdate(View arg0) {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
package com.stone.shop.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.stone.shop.R;
|
||||
|
||||
/**
|
||||
* MineActivity 项目列表适配器
|
||||
* @date 2014-5-10
|
||||
* @author Stone
|
||||
*/
|
||||
public class MineListAdapter extends BaseAdapter {
|
||||
|
||||
private Context mContext;
|
||||
private String[] mItemNames; // 项目列表名称
|
||||
private String[] mItemContents; //项目列表的备注值
|
||||
private int[] mItemImgIds; // 项目列表Icon
|
||||
private LayoutInflater mInflater = null;
|
||||
|
||||
public MineListAdapter(Context context, String[] names, String[] contents, int[] imgIds) {
|
||||
mContext = context;
|
||||
mItemNames = names;
|
||||
mItemContents = contents;
|
||||
mItemImgIds = imgIds;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mItemNames.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return mItemNames[position];
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
MineListHolder holder;
|
||||
if (convertView == null) {
|
||||
convertView = mInflater.inflate(R.layout.mine_list_item, null);
|
||||
holder = new MineListHolder();
|
||||
holder.imgItem = (ImageView) convertView.findViewById(R.id.img_item);
|
||||
holder.tvItemName = (TextView) convertView
|
||||
.findViewById(R.id.tv_item_name);
|
||||
holder.tvItemContent = (TextView) convertView.findViewById(R.id.tv_item_content);
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (MineListHolder) convertView.getTag();
|
||||
}
|
||||
holder.imgItem.setBackgroundResource(mItemImgIds[position]);
|
||||
holder.tvItemName.setText(mItemNames[position]);
|
||||
holder.tvItemContent.setText(mItemContents[position]);
|
||||
return convertView;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
package com.stone.shop.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.stone.shop.R;
|
||||
|
||||
/**
|
||||
* MineActivity 项目列表适配器
|
||||
* @date 2014-5-10
|
||||
* @author Stone
|
||||
*/
|
||||
public class MineSoftAdapter extends BaseAdapter {
|
||||
|
||||
private Context mContext;
|
||||
private String[] mItemNames; // 项目列表名称
|
||||
private String[] mItemContents; //项目列表的备注值
|
||||
private LayoutInflater mInflater = null;
|
||||
|
||||
public MineSoftAdapter(Context context, String[] names, String[] contents) {
|
||||
mContext = context;
|
||||
mItemNames = names;
|
||||
mItemContents = contents;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mItemNames.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return mItemNames[position];
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
MineListHolder holder;
|
||||
if (convertView == null) {
|
||||
convertView = mInflater.inflate(R.layout.mine_soft_list_item, null);
|
||||
holder = new MineListHolder();
|
||||
holder.tvItemName = (TextView) convertView
|
||||
.findViewById(R.id.tv_item_name);
|
||||
holder.tvItemContent = (TextView) convertView.findViewById(R.id.tv_item_content);
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (MineListHolder) convertView.getTag();
|
||||
}
|
||||
holder.tvItemName.setText(mItemNames[position]);
|
||||
holder.tvItemContent.setText(mItemContents[position]);
|
||||
return convertView;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
package com.stone.shop.adapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.stone.shop.R;
|
||||
import com.stone.shop.model.News;
|
||||
|
||||
import android.R.integer;
|
||||
import android.content.Context;
|
||||
import android.graphics.pdf.PdfDocument.Page;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* 新闻列表适配器
|
||||
*
|
||||
* @date 2014-5-3
|
||||
* @author Stone
|
||||
*/
|
||||
public class NewsListAdapter extends BaseAdapter {
|
||||
|
||||
private Context mContext;
|
||||
private LayoutInflater mInflater = null;
|
||||
private List<News> mNewsList = null; // 所选分类下的所有店铺列表
|
||||
|
||||
public NewsListAdapter(Context context, List<News> newsList) {
|
||||
mContext = context;
|
||||
mNewsList = newsList;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mNewsList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return mNewsList.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
// 刷新列表中的数据
|
||||
public void refresh(ArrayList<News> list) {
|
||||
mNewsList = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
NewsHolder newsHolder;
|
||||
if (convertView == null) {
|
||||
convertView = mInflater.inflate(R.layout.news_list_item, null);
|
||||
newsHolder = new NewsHolder();
|
||||
newsHolder.tvNewsType = (TextView) convertView
|
||||
.findViewById(R.id.tv_news_type);
|
||||
newsHolder.tvNewsTitle = (TextView) convertView
|
||||
.findViewById(R.id.tv_news_title);
|
||||
newsHolder.tvNewsDate = (TextView) convertView
|
||||
.findViewById(R.id.tv_news_date);
|
||||
convertView.setTag(newsHolder);
|
||||
} else {
|
||||
newsHolder = (NewsHolder) convertView.getTag();
|
||||
}
|
||||
//拆分字符串,只取年月日
|
||||
String[] ss = new String[2];
|
||||
ss = mNewsList.get(position).getCreatedAt().split(" ");
|
||||
newsHolder.tvNewsType.setText(mNewsList.get(position).getType()); //新闻类型
|
||||
newsHolder.tvNewsTitle.setText(mNewsList.get(position).getTitle()); //新闻标题
|
||||
newsHolder.tvNewsDate.setText(ss[0]); //新闻发布日期
|
||||
return convertView;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
package com.stone.shop.adapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import cn.bmob.v3.BmobQuery;
|
||||
import cn.bmob.v3.listener.GetListener;
|
||||
|
||||
import com.stone.date.TypeDef;
|
||||
import com.stone.shop.R;
|
||||
import com.stone.shop.model.Good;
|
||||
import com.stone.shop.model.Order;
|
||||
import com.stone.shop.model.Shop;
|
||||
import com.stone.shop.view.OrderInfoActivity;
|
||||
|
||||
/**
|
||||
* 适配器--适配订单列表中的数据
|
||||
*
|
||||
* @date 2014-5-27
|
||||
* @author Stone
|
||||
*/
|
||||
public class OrderInfoListAdapter extends BaseAdapter {
|
||||
|
||||
private Context mContext;
|
||||
private LayoutInflater mInflater = null;
|
||||
private List<Order> mOrderList = null; // 所选分类下的所有店铺列表
|
||||
private String mType; // 商店的分类
|
||||
|
||||
public OrderInfoListAdapter(Context context, List<Order> orderList) {
|
||||
mContext = context;
|
||||
mOrderList = orderList;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mOrderList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return mOrderList.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
public void refresh(List<Order> list) {
|
||||
mOrderList = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
OrderInfoHolder orderInfoHolder;
|
||||
if (convertView == null) {
|
||||
convertView = mInflater.inflate(R.layout.order_info_list_item, null);
|
||||
orderInfoHolder = new OrderInfoHolder();
|
||||
orderInfoHolder.tvOrderInfoGoodName = (TextView) convertView
|
||||
.findViewById(R.id.tv_order_info_good_name);
|
||||
orderInfoHolder.tvOrderInfoShopName = (TextView) convertView
|
||||
.findViewById(R.id.tv_order_info_shop_name);
|
||||
orderInfoHolder.tvOrderInfoPrice = (TextView) convertView
|
||||
.findViewById(R.id.tv_order_info_price);
|
||||
orderInfoHolder.tvOrderInfoState = (TextView) convertView
|
||||
.findViewById(R.id.tv_order_info_state);
|
||||
convertView.setTag(orderInfoHolder);
|
||||
} else {
|
||||
orderInfoHolder = (OrderInfoHolder) convertView.getTag();
|
||||
}
|
||||
orderInfoHolder.tvOrderInfoGoodName.setText(mOrderList.get(position).getGoodName());
|
||||
orderInfoHolder.tvOrderInfoShopName.setText(mOrderList.get(position).getShopName());
|
||||
orderInfoHolder.tvOrderInfoPrice.setText("¥" + mOrderList.get(position).getPrice());
|
||||
orderInfoHolder.tvOrderInfoState.setText(mOrderList.get(position).getState());
|
||||
return convertView;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
package com.stone.shop.adapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.stone.shop.R;
|
||||
import com.stone.shop.model.SComment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* 店铺评论列表适配器
|
||||
* @date 2014-5-3
|
||||
* @author Stone
|
||||
*/
|
||||
public class SCommentAdapter extends BaseAdapter {
|
||||
|
||||
private Context mContext;
|
||||
private LayoutInflater mInflater = null;
|
||||
private List<SComment> mSComList = null; // 所选分类下的所有店铺列表
|
||||
|
||||
public SCommentAdapter(Context context, List<SComment> list) {
|
||||
mContext = context;
|
||||
mSComList = list;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mSComList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return mSComList.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
SComHolder scomHolder;
|
||||
if (convertView == null) {
|
||||
convertView = mInflater.inflate(R.layout.scom_list_item, null);
|
||||
scomHolder = new SComHolder();
|
||||
scomHolder.tvComUser = (TextView) convertView
|
||||
.findViewById(R.id.tv_commit_user);
|
||||
scomHolder.tvComContent = (TextView) convertView
|
||||
.findViewById(R.id.tv_commit_content);
|
||||
convertView.setTag(scomHolder);
|
||||
} else {
|
||||
scomHolder = (SComHolder) convertView.getTag();
|
||||
}
|
||||
scomHolder.tvComUser.setText(mSComList.get(position).getUserName());
|
||||
scomHolder.tvComContent.setText(mSComList.get(position).getContent());
|
||||
return convertView;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,126 +0,0 @@
|
|||
package com.stone.shop.adapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.stone.date.TypeDef;
|
||||
import com.stone.shop.R;
|
||||
import com.stone.shop.model.Shop;
|
||||
|
||||
/**
|
||||
* 适配器--适配某一分类下的店铺列表数据
|
||||
*
|
||||
* @date 2014-4-29
|
||||
* @author Stone
|
||||
*/
|
||||
public class ShopListAdapter extends BaseAdapter {
|
||||
|
||||
private Context mContext;
|
||||
private LayoutInflater mInflater = null;
|
||||
private ArrayList<Shop> mShopList = null; // 所选分类下的所有店铺列表
|
||||
private String mType; // 商店的分类
|
||||
|
||||
public ShopListAdapter(Context context, ArrayList<Shop> shopList,
|
||||
String type) {
|
||||
mContext = context;
|
||||
mShopList = shopList;
|
||||
mType = type;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mShopList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return mShopList.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
// 刷新列表中的数据
|
||||
public void refresh(ArrayList<Shop> list) {
|
||||
mShopList = list;
|
||||
//将数字的类型编号转换为文字
|
||||
exchangeType(mType);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据当前的type类型, 转换成相应的文字
|
||||
* @date 2014-4-29
|
||||
* @param typeString
|
||||
*/
|
||||
private void exchangeType(String typeString) {
|
||||
|
||||
int type = Integer.parseInt(typeString);
|
||||
int fatherType = type / 10; //父类型编号
|
||||
int sonType = type % 10; //子类型编号
|
||||
|
||||
Iterator<Shop> iterator = mShopList.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
switch (fatherType) {
|
||||
case 1:
|
||||
iterator.next().setType(
|
||||
TypeDef.typeDadList[fatherType-1] + "/"
|
||||
+ TypeDef.typeSonList1[sonType-1]);
|
||||
break;
|
||||
case 2:
|
||||
iterator.next().setType(
|
||||
TypeDef.typeDadList[fatherType-1] + "/"
|
||||
+ TypeDef.typeSonList2[sonType-1]);
|
||||
break;
|
||||
case 3:
|
||||
iterator.next().setType(
|
||||
TypeDef.typeDadList[fatherType-1] + "/"
|
||||
+ TypeDef.typeSonList3[sonType-1]);
|
||||
break;
|
||||
case 4:
|
||||
iterator.next().setType(
|
||||
TypeDef.typeDadList[fatherType-1] + "/"
|
||||
+ TypeDef.typeSonList4[sonType-1]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
ShopHolder shopHodler;
|
||||
if (convertView == null) {
|
||||
convertView = mInflater.inflate(R.layout.shop_all_list_item, null);
|
||||
shopHodler = new ShopHolder();
|
||||
shopHodler.tvShopName = (TextView) convertView
|
||||
.findViewById(R.id.tv_shop_name);
|
||||
shopHodler.tvShopType = (TextView) convertView
|
||||
.findViewById(R.id.tv_shop_type);
|
||||
shopHodler.tvShopLoc = (TextView) convertView
|
||||
.findViewById(R.id.tv_shop_loc);
|
||||
convertView.setTag(shopHodler);
|
||||
} else {
|
||||
shopHodler = (ShopHolder) convertView.getTag();
|
||||
}
|
||||
shopHodler.tvShopName.setText(mShopList.get(position).getName());
|
||||
// 商店的类型需要单独处理
|
||||
shopHodler.tvShopType.setText(mShopList.get(position).getType());
|
||||
shopHodler.tvShopLoc.setText("二食堂");
|
||||
return convertView;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
|
||||
/**
|
||||
* 博学堂讲座实体类
|
||||
* @date 2014-5-10
|
||||
* @author Stone
|
||||
*/
|
||||
public class BXTNews extends BmobObject{
|
||||
|
||||
//private String id;
|
||||
|
||||
private String title; //标题
|
||||
private String topic; //讲座主题
|
||||
private String speaker; //主 讲 人
|
||||
private String time; //讲座时间
|
||||
private String location; //讲座地点
|
||||
private String holder1; //主办单位
|
||||
private String holder2; //承办单位
|
||||
private String points; //主讲内容提要
|
||||
private String speakerinfo; //主讲人简介
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public String getTopic() {
|
||||
return topic;
|
||||
}
|
||||
public String getSpeaker() {
|
||||
return speaker;
|
||||
}
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
public String getHolder1() {
|
||||
return holder1;
|
||||
}
|
||||
public String getHolder2() {
|
||||
return holder2;
|
||||
}
|
||||
public String getPoints() {
|
||||
return points;
|
||||
}
|
||||
public String getSpeakerinfo() {
|
||||
return speakerinfo;
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
public void setTopic(String topic) {
|
||||
this.topic = topic;
|
||||
}
|
||||
public void setSpeaker(String speaker) {
|
||||
this.speaker = speaker;
|
||||
}
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
public void setHolder1(String holder1) {
|
||||
this.holder1 = holder1;
|
||||
}
|
||||
public void setHolder2(String holder2) {
|
||||
this.holder2 = holder2;
|
||||
}
|
||||
public void setPoints(String points) {
|
||||
this.points = points;
|
||||
}
|
||||
public void setSpeakerinfo(String speakerinfo) {
|
||||
this.speakerinfo = speakerinfo;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
|
||||
/**
|
||||
* 博学堂讲座实体类
|
||||
* @date 2014-5-10
|
||||
* @author Stone
|
||||
*/
|
||||
public class BXTNews extends BmobObject{
|
||||
|
||||
//private String id;
|
||||
|
||||
private String title; //标题
|
||||
private String topic; //讲座主题
|
||||
private String speaker; //主 讲 人
|
||||
private String time; //讲座时间
|
||||
private String location; //讲座地点
|
||||
private String holder1; //主办单位
|
||||
private String holder2; //承办单位
|
||||
private String points; //主讲内容提要
|
||||
private String speakerinfo; //主讲人简介
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public String getTopic() {
|
||||
return topic;
|
||||
}
|
||||
public String getSpeaker() {
|
||||
return speaker;
|
||||
}
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
public String getHolder1() {
|
||||
return holder1;
|
||||
}
|
||||
public String getHolder2() {
|
||||
return holder2;
|
||||
}
|
||||
public String getPoints() {
|
||||
return points;
|
||||
}
|
||||
public String getSpeakerinfo() {
|
||||
return speakerinfo;
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
public void setTopic(String topic) {
|
||||
this.topic = topic;
|
||||
}
|
||||
public void setSpeaker(String speaker) {
|
||||
this.speaker = speaker;
|
||||
}
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
public void setHolder1(String holder1) {
|
||||
this.holder1 = holder1;
|
||||
}
|
||||
public void setHolder2(String holder2) {
|
||||
this.holder2 = holder2;
|
||||
}
|
||||
public void setPoints(String points) {
|
||||
this.points = points;
|
||||
}
|
||||
public void setSpeakerinfo(String speakerinfo) {
|
||||
this.speakerinfo = speakerinfo;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
import cn.bmob.v3.datatype.BmobFile;
|
||||
|
||||
/**
|
||||
* 商品实体类
|
||||
* @date 2014-4-24
|
||||
* @author Stone
|
||||
*/
|
||||
public class Good extends BmobObject implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = -3248168273019127389L;
|
||||
|
||||
//private String id; 商品ID, 默认
|
||||
|
||||
private String shopID = ""; // 商店ID
|
||||
private String shopName = ""; //商店名称
|
||||
private String type = ""; // 类型
|
||||
private String name = ""; // 名称
|
||||
private String price = ""; // 价格
|
||||
private BmobFile picGood = null; // 商品主图
|
||||
|
||||
public Good(String name, String price) {
|
||||
this.name = name;
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public String getShopID() {
|
||||
return shopID;
|
||||
}
|
||||
|
||||
public void setShopID(String shopID) {
|
||||
this.shopID = shopID;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(String price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
import cn.bmob.v3.datatype.BmobFile;
|
||||
|
||||
/**
|
||||
* 商品实体类
|
||||
* @date 2014-4-24
|
||||
* @author Stone
|
||||
*/
|
||||
public class Good extends BmobObject implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = -3248168273019127389L;
|
||||
|
||||
//private String id; 商品ID, 默认
|
||||
|
||||
private String shopID = ""; // 商店ID
|
||||
private String shopName = ""; //商店名称
|
||||
private String type = ""; // 类型
|
||||
private String name = ""; // 名称
|
||||
private String price = ""; // 价格
|
||||
private BmobFile picGood = null; // 商品主图
|
||||
|
||||
public Good(String name, String price) {
|
||||
this.name = name;
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public String getShopID() {
|
||||
return shopID;
|
||||
}
|
||||
|
||||
public void setShopID(String shopID) {
|
||||
this.shopID = shopID;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(String price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
|
||||
/**
|
||||
* 首页校内新闻实体类
|
||||
*
|
||||
* @date 2014-5-3
|
||||
* @author Stone
|
||||
*/
|
||||
public class News extends BmobObject {
|
||||
|
||||
// private String id;
|
||||
// private String time;
|
||||
|
||||
private String type; // 新闻类型
|
||||
private String title; // 新闻标题
|
||||
private String author; // 新闻作者
|
||||
private String content; // 新闻内容
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
|
||||
/**
|
||||
* 首页校内新闻实体类
|
||||
*
|
||||
* @date 2014-5-3
|
||||
* @author Stone
|
||||
*/
|
||||
public class News extends BmobObject {
|
||||
|
||||
// private String id;
|
||||
// private String time;
|
||||
|
||||
private String type; // 新闻类型
|
||||
private String title; // 新闻标题
|
||||
private String author; // 新闻作者
|
||||
private String content; // 新闻内容
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
|
||||
/**
|
||||
* 店铺评论实体类
|
||||
* @date 2014-5-3
|
||||
* @author Stone
|
||||
*/
|
||||
public class SComment extends BmobObject {
|
||||
|
||||
// private String id;
|
||||
// private String time;
|
||||
|
||||
private String shopID;
|
||||
private String shopName;
|
||||
private String userID;
|
||||
private String userName;
|
||||
private String content;
|
||||
|
||||
public String getShopID() {
|
||||
return shopID;
|
||||
}
|
||||
|
||||
public void setShopID(String shopID) {
|
||||
this.shopID = shopID;
|
||||
}
|
||||
|
||||
public String getShopName() {
|
||||
return shopName;
|
||||
}
|
||||
|
||||
public void setShopName(String shopName) {
|
||||
this.shopName = shopName;
|
||||
}
|
||||
|
||||
public String getUserID() {
|
||||
return userID;
|
||||
}
|
||||
|
||||
public void setUserID(String userID) {
|
||||
this.userID = userID;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
|
||||
/**
|
||||
* 店铺评论实体类
|
||||
* @date 2014-5-3
|
||||
* @author Stone
|
||||
*/
|
||||
public class SComment extends BmobObject {
|
||||
|
||||
// private String id;
|
||||
// private String time;
|
||||
|
||||
private String shopID;
|
||||
private String shopName;
|
||||
private String userID;
|
||||
private String userName;
|
||||
private String content;
|
||||
|
||||
public String getShopID() {
|
||||
return shopID;
|
||||
}
|
||||
|
||||
public void setShopID(String shopID) {
|
||||
this.shopID = shopID;
|
||||
}
|
||||
|
||||
public String getShopName() {
|
||||
return shopName;
|
||||
}
|
||||
|
||||
public void setShopName(String shopName) {
|
||||
this.shopName = shopName;
|
||||
}
|
||||
|
||||
public String getUserID() {
|
||||
return userID;
|
||||
}
|
||||
|
||||
public void setUserID(String userID) {
|
||||
this.userID = userID;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
import cn.bmob.v3.datatype.BmobFile;
|
||||
|
||||
/**
|
||||
* 店铺实体类, 实现序列化, Activity之间实现传递
|
||||
* @date 2014-4-24
|
||||
* @author Stone
|
||||
*/
|
||||
public class Shop extends BmobObject implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = -8796635595320697255L;
|
||||
|
||||
private String userID; // 主人
|
||||
private String type; // 类型(11代表第一个GridView中的第一个)
|
||||
private String name; // 店名
|
||||
private String location; // 地理位置
|
||||
private String phone; // 联系电话
|
||||
private String info; // 简介
|
||||
private String sale; // 促销信息
|
||||
private BmobFile picShop; // 商店主图
|
||||
|
||||
public String getUserID() {
|
||||
return userID;
|
||||
}
|
||||
|
||||
public void setUserID(String userID) {
|
||||
this.userID = userID;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public void setInfo(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public String getSale() {
|
||||
return sale;
|
||||
}
|
||||
|
||||
public void setSale(String sale) {
|
||||
this.sale = sale;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import cn.bmob.v3.BmobObject;
|
||||
import cn.bmob.v3.datatype.BmobFile;
|
||||
|
||||
/**
|
||||
* 店铺实体类, 实现序列化, Activity之间实现传递
|
||||
* @date 2014-4-24
|
||||
* @author Stone
|
||||
*/
|
||||
public class Shop extends BmobObject implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = -8796635595320697255L;
|
||||
|
||||
private String userID; // 主人
|
||||
private String type; // 类型(11代表第一个GridView中的第一个)
|
||||
private String name; // 店名
|
||||
private String location; // 地理位置
|
||||
private String phone; // 联系电话
|
||||
private String info; // 简介
|
||||
private String sale; // 促销信息
|
||||
private BmobFile picShop; // 商店主图
|
||||
|
||||
public String getUserID() {
|
||||
return userID;
|
||||
}
|
||||
|
||||
public void setUserID(String userID) {
|
||||
this.userID = userID;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public void setInfo(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public String getSale() {
|
||||
return sale;
|
||||
}
|
||||
|
||||
public void setSale(String sale) {
|
||||
this.sale = sale;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import cn.bmob.v3.BmobUser;
|
||||
import cn.bmob.v3.datatype.BmobFile;
|
||||
import cn.bmob.v3.datatype.BmobRelation;
|
||||
|
||||
/**
|
||||
* 用户实体类
|
||||
* @date 2014-4-24
|
||||
* @author Stone
|
||||
*/
|
||||
public class User extends BmobUser {
|
||||
|
||||
public static String userId;
|
||||
|
||||
// 父类中已经存在的属性
|
||||
// private String id;
|
||||
// private String username;
|
||||
// private String password;
|
||||
// private String email;
|
||||
// private String regTime;
|
||||
|
||||
private String sex; // 性别
|
||||
private String phone; // 电话
|
||||
private String qq; // QQ
|
||||
private String school = "湖北工业大学"; // 学校
|
||||
private String cademy; // 学院
|
||||
private String dorPart; // 校区
|
||||
private String dorNum; // 寝室号
|
||||
private String state = "未登陆"; // 登录状态
|
||||
private String type = "普通用户"; // 用户类型(普通用户、黑名单、中奖者)
|
||||
//private BmobFile picUser; // 头像
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(String sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getQQ() {
|
||||
return qq;
|
||||
}
|
||||
|
||||
public void setQQ(String qq) {
|
||||
this.qq = qq;
|
||||
}
|
||||
|
||||
public String getSchool() {
|
||||
return school;
|
||||
}
|
||||
|
||||
public void setSchool(String school) {
|
||||
this.school = school;
|
||||
}
|
||||
|
||||
public String getCademy() {
|
||||
return cademy;
|
||||
}
|
||||
|
||||
public void setCademy(String cademy) {
|
||||
this.cademy = cademy;
|
||||
}
|
||||
|
||||
public String getDorPart() {
|
||||
return dorPart;
|
||||
}
|
||||
|
||||
public void setDorPart(String dorPart) {
|
||||
this.dorPart = dorPart;
|
||||
}
|
||||
|
||||
public String getDorNum() {
|
||||
return dorNum;
|
||||
}
|
||||
|
||||
public void setDorNum(String dorNum) {
|
||||
this.dorNum = dorNum;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
package com.stone.shop.model;
|
||||
|
||||
import cn.bmob.v3.BmobUser;
|
||||
import cn.bmob.v3.datatype.BmobFile;
|
||||
import cn.bmob.v3.datatype.BmobRelation;
|
||||
|
||||
/**
|
||||
* 用户实体类
|
||||
* @date 2014-4-24
|
||||
* @author Stone
|
||||
*/
|
||||
public class User extends BmobUser {
|
||||
|
||||
public static String userId;
|
||||
|
||||
// 父类中已经存在的属性
|
||||
// private String id;
|
||||
// private String username;
|
||||
// private String password;
|
||||
// private String email;
|
||||
// private String regTime;
|
||||
|
||||
private String sex; // 性别
|
||||
private String phone; // 电话
|
||||
private String qq; // QQ
|
||||
private String school = "湖北工业大学"; // 学校
|
||||
private String cademy; // 学院
|
||||
private String dorPart; // 校区
|
||||
private String dorNum; // 寝室号
|
||||
private String state = "未登陆"; // 登录状态
|
||||
private String type = "普通用户"; // 用户类型(普通用户、黑名单、中奖者)
|
||||
//private BmobFile picUser; // 头像
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(String sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getQQ() {
|
||||
return qq;
|
||||
}
|
||||
|
||||
public void setQQ(String qq) {
|
||||
this.qq = qq;
|
||||
}
|
||||
|
||||
public String getSchool() {
|
||||
return school;
|
||||
}
|
||||
|
||||
public void setSchool(String school) {
|
||||
this.school = school;
|
||||
}
|
||||
|
||||
public String getCademy() {
|
||||
return cademy;
|
||||
}
|
||||
|
||||
public void setCademy(String cademy) {
|
||||
this.cademy = cademy;
|
||||
}
|
||||
|
||||
public String getDorPart() {
|
||||
return dorPart;
|
||||
}
|
||||
|
||||
public void setDorPart(String dorPart) {
|
||||
this.dorPart = dorPart;
|
||||
}
|
||||
|
||||
public String getDorNum() {
|
||||
return dorNum;
|
||||
}
|
||||
|
||||
public void setDorNum(String dorNum) {
|
||||
this.dorNum = dorNum;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
package com.stone.shop.view;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cn.bmob.v3.BmobQuery;
|
||||
import cn.bmob.v3.listener.FindListener;
|
||||
|
||||
import com.stone.shop.R;
|
||||
import com.stone.shop.adapter.BXTListAdapter;
|
||||
import com.stone.shop.model.BXTNews;
|
||||
import com.stone.shop.model.Classroom;
|
||||
import com.stone.shop.model.BXTNews;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.renderscript.Element;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
/**
|
||||
* 教学类-博学堂界面
|
||||
* @date 2014-5-10
|
||||
* @author Stone
|
||||
*/
|
||||
public class BXTActivity extends Activity implements OnItemClickListener{
|
||||
|
||||
private static final String TAG = "BXTActivity";
|
||||
|
||||
private ListView lvBXTNews;
|
||||
private BXTListAdapter mBxtListAdapter;
|
||||
private List<BXTNews> mBXTNewsList;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_bxt);
|
||||
|
||||
initView();
|
||||
initData();
|
||||
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
lvBXTNews = (ListView) findViewById(R.id.lv_bxt_news);
|
||||
mBXTNewsList = new ArrayList<BXTNews>();
|
||||
mBxtListAdapter = new BXTListAdapter(this, mBXTNewsList);
|
||||
lvBXTNews.setAdapter(mBxtListAdapter);
|
||||
lvBXTNews.setOnItemClickListener(this);
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
BmobQuery<BXTNews> query = new BmobQuery<BXTNews>();
|
||||
query.findObjects(this, new FindListener<BXTNews>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<BXTNews> newsList) {
|
||||
//toast("查询商品成功, 共" + newsList.size());
|
||||
if(newsList.size()==0)
|
||||
toast("亲, 暂时还木有讲座哦");
|
||||
else {
|
||||
mBXTNewsList = newsList;
|
||||
mBxtListAdapter.refresh(newsList);
|
||||
mBxtListAdapter.notifyDataSetChanged();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int arg0, String arg1) {
|
||||
toast("查询失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void toast(String toast) {
|
||||
Toast.makeText(this, toast, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position,
|
||||
long id) {
|
||||
Intent toBXTNewsActivity = new Intent(BXTActivity.this, BXTNewsActivity.class);
|
||||
toBXTNewsActivity.putExtra("title", mBXTNewsList.get(position).getTitle());
|
||||
toBXTNewsActivity.putExtra("topic", mBXTNewsList.get(position).getTopic());
|
||||
toBXTNewsActivity.putExtra("speaker", mBXTNewsList.get(position).getSpeaker());
|
||||
toBXTNewsActivity.putExtra("time", mBXTNewsList.get(position).getTime());
|
||||
toBXTNewsActivity.putExtra("location", mBXTNewsList.get(position).getLocation());
|
||||
toBXTNewsActivity.putExtra("holder1", mBXTNewsList.get(position).getHolder1());
|
||||
toBXTNewsActivity.putExtra("holder2", mBXTNewsList.get(position).getHolder2());
|
||||
toBXTNewsActivity.putExtra("points", mBXTNewsList.get(position).getPoints());
|
||||
toBXTNewsActivity.putExtra("speakerinfo", mBXTNewsList.get(position).getSpeakerinfo());
|
||||
startActivity(toBXTNewsActivity);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
package com.stone.shop.view;
|
||||
|
||||
import com.stone.shop.R;
|
||||
import com.stone.shop.model.BXTNews;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* 教学类-博学堂-讲座详情界面
|
||||
* @date 2014-5-10
|
||||
* @author Stone
|
||||
*/
|
||||
public class BXTNewsActivity extends Activity {
|
||||
|
||||
private static final String TAG = "BXTNewsActivity";
|
||||
|
||||
private BXTNews news;
|
||||
private TextView tvBXTNewsTitle;
|
||||
private TextView tvBXTNewsTopic;
|
||||
private TextView tvBXTNewsSpeaker;
|
||||
private TextView tvBXTNewsTime;
|
||||
private TextView tvBXTNewsLoc;
|
||||
private TextView tvBXTNewsHolder1;
|
||||
private TextView tvBXTNewsHolder2;
|
||||
private TextView tvBXTNewsPoints;
|
||||
private TextView tvBXTNewsSpeakerInfo;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_bxt_news);
|
||||
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
|
||||
tvBXTNewsTitle = (TextView) findViewById(R.id.tv_bxt_news_title);
|
||||
tvBXTNewsTopic = (TextView) findViewById(R.id.tv_bxt_news_topic);
|
||||
tvBXTNewsSpeaker = (TextView) findViewById(R.id.tv_bxt_news_speaker);
|
||||
tvBXTNewsTime = (TextView) findViewById(R.id.tv_bxt_news_time);
|
||||
tvBXTNewsLoc = (TextView) findViewById(R.id.tv_bxt_news_loc);
|
||||
tvBXTNewsHolder1 = (TextView) findViewById(R.id.tv_bxt_news_holder1);
|
||||
tvBXTNewsHolder2 = (TextView) findViewById(R.id.tv_bxt_news_holder2);
|
||||
tvBXTNewsPoints = (TextView) findViewById(R.id.tv_bxt_news_point);
|
||||
tvBXTNewsSpeakerInfo = (TextView) findViewById(R.id.tv_bxt_news_speaker_info);
|
||||
|
||||
tvBXTNewsTitle.setText(getIntent().getStringExtra("title"));
|
||||
tvBXTNewsTopic.setText(getIntent().getStringExtra("topic"));
|
||||
tvBXTNewsSpeaker.setText(getIntent().getStringExtra("speaker"));
|
||||
tvBXTNewsTime.setText(getIntent().getStringExtra("time"));
|
||||
tvBXTNewsLoc.setText(getIntent().getStringExtra("location"));
|
||||
tvBXTNewsHolder1.setText(getIntent().getStringExtra("holder1"));
|
||||
tvBXTNewsHolder2.setText(getIntent().getStringExtra("holder2"));
|
||||
tvBXTNewsPoints.setText(getIntent().getStringExtra("points"));
|
||||
tvBXTNewsSpeakerInfo.setText(getIntent().getStringExtra("speakerinfo"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -26,8 +26,8 @@ public class BaseActivity extends TabActivity {
|
|||
|
||||
|
||||
String[] mTitle = new String[] { "周边", "讨论区", "我的"};
|
||||
int[] mIcon = new int[] { R.drawable.ic_shop, R.drawable.ic_sale,
|
||||
R.drawable.ic_car, R.drawable.ic_mine };
|
||||
int[] mIcon = new int[] { R.drawable.ic_shop2, R.drawable.ic_sale2,
|
||||
R.drawable.ic_car2, R.drawable.ic_mine };
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
|
|
@ -1,104 +0,0 @@
|
|||
package com.stone.shop.view;
|
||||
|
||||
import cn.bmob.v3.Bmob;
|
||||
|
||||
import com.stone.shop.R;
|
||||
import com.stone.shop.view.old.OldMineActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.app.TabActivity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Space;
|
||||
import android.widget.TabHost;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* 应用主界面
|
||||
* @date 2014-4-24
|
||||
* @author Stone
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BaseActivity extends TabActivity {
|
||||
|
||||
private static final String TAG = "BaseActivity";
|
||||
|
||||
private TabHost tabHost;
|
||||
private LayoutInflater layoutInflater;
|
||||
|
||||
|
||||
String[] mTitle = new String[] { "周边", "讨论区", "我的"};
|
||||
int[] mIcon = new int[] { R.drawable.ic_shop2, R.drawable.ic_sale2,
|
||||
R.drawable.ic_car2, R.drawable.ic_mine };
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_base);
|
||||
|
||||
initTabView();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public View getTabItemView(int i) {
|
||||
// TODO Auto-generated method stub
|
||||
View view = layoutInflater.inflate(R.layout.tab_widget_item, null);
|
||||
ImageView imageView = (ImageView) view.findViewById(R.id.imageview);
|
||||
imageView.setImageResource(mIcon[i]);
|
||||
TextView textView = (TextView) view.findViewById(R.id.textview);
|
||||
textView.setText(mTitle[i]);
|
||||
return view;
|
||||
}
|
||||
|
||||
public void initTabView() {
|
||||
|
||||
/**
|
||||
* tabHost.newTabSpec("artist")创建一个标签项,其中artist为它的标签标识符,相当于jsp页面标签的name属性
|
||||
* setIndicator("艺术标签",resources.getDrawable(R.drawable.ic_tab))设置标签显示文本以及标签上的图标(该图标并不是一个图片,而是一个xml文件哦)
|
||||
* setContent(intent)为当前标签指定一个意图
|
||||
* tabHost.addTab(spec); 将标签项添加到标签中
|
||||
*/
|
||||
|
||||
tabHost = getTabHost();
|
||||
layoutInflater = LayoutInflater.from(this);
|
||||
TabHost.TabSpec spec;
|
||||
|
||||
Intent intent1 = new Intent(this, ShopActivity.class);
|
||||
spec = tabHost.newTabSpec(mTitle[0]).setIndicator( getTabItemView(0) ).setContent(intent1);
|
||||
tabHost.addTab(spec);
|
||||
|
||||
Intent intent2 = new Intent(this, AwardActivity.class);
|
||||
spec = tabHost.newTabSpec(mTitle[1]).setIndicator( getTabItemView(1) ).setContent(intent2);
|
||||
tabHost.addTab(spec);
|
||||
|
||||
Intent intent3 = new Intent(this, MineActivity.class);
|
||||
spec = tabHost.newTabSpec(mTitle[2]).setIndicator( getTabItemView(2) ).setContent(intent3);
|
||||
tabHost.addTab(spec);
|
||||
|
||||
/*
|
||||
Intent intent3 = new Intent(this, WsqActivity.class);
|
||||
spec = tabHost.newTabSpec(mTitle[2]).setIndicator( getTabItemView(2) ).setContent(intent3);
|
||||
tabHost.addTab(spec);
|
||||
|
||||
Intent intent4 = new Intent(this, OldMineActivity.class);
|
||||
spec = tabHost.newTabSpec(mTitle[3]).setIndicator( getTabItemView(3) ).setContent(intent4);
|
||||
tabHost.addTab(spec); */
|
||||
|
||||
tabHost.setCurrentTab(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
Toast.makeText(this, "确定要退出在这里么?", Toast.LENGTH_LONG).show();
|
||||
//super.onBackPressed();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
package com.stone.shop.view;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cn.bmob.v3.BmobQuery;
|
||||
import cn.bmob.v3.listener.FindListener;
|
||||
|
||||
import com.stone.shop.R;
|
||||
import com.stone.shop.adapter.BXTListAdapter;
|
||||
import com.stone.shop.adapter.ClassroomAdapter;
|
||||
import com.stone.shop.model.Classroom;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.GridView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class ClassroomActivity extends Activity implements OnItemClickListener {
|
||||
|
||||
private static final String TAG = "BXTActivity";
|
||||
|
||||
private GridView lvBXTNews;
|
||||
private ClassroomAdapter mBxtListAdapter;
|
||||
private List<Classroom> mBXTNewsList;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_classroom);
|
||||
|
||||
initView();
|
||||
initData();
|
||||
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
lvBXTNews = (GridView) findViewById(R.id.gv_classroom);
|
||||
mBXTNewsList = new ArrayList<Classroom>();
|
||||
mBxtListAdapter = new ClassroomAdapter(this, mBXTNewsList);
|
||||
lvBXTNews.setAdapter(mBxtListAdapter);
|
||||
lvBXTNews.setOnItemClickListener(this);
|
||||
|
||||
TextView tv_title = (TextView) findViewById(R.id.tv_title);
|
||||
tv_title.setText("教室");
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
BmobQuery<Classroom> query = new BmobQuery<Classroom>();
|
||||
query.addWhereEqualTo("type", "教室");
|
||||
query.findObjects(this, new FindListener<Classroom>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<Classroom> newsList) {
|
||||
// toast("查询商品成功, 共" + newsList.size());
|
||||
if (newsList.size() == 0)
|
||||
toast("亲, 暂时还木有教室哦");
|
||||
else {
|
||||
mBXTNewsList = newsList;
|
||||
mBxtListAdapter.refresh(newsList);
|
||||
mBxtListAdapter.notifyDataSetChanged();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int arg0, String arg1) {
|
||||
toast("查询失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void toast(String toast) {
|
||||
Toast.makeText(this, toast, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
Intent intent = new Intent(ClassroomActivity.this, ReservationActivity.class);
|
||||
Classroom classroom = mBXTNewsList.get(position);
|
||||
intent.putExtra("roomId", classroom.getObjectId());
|
||||
intent.putExtra("roomName", classroom.getName());
|
||||
startActivity(intent);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
package com.stone.shop.view;
|
||||
|
||||
import cn.bmob.v3.BmobUser;
|
||||
import cn.bmob.v3.listener.SaveListener;
|
||||
|
||||
import com.stone.shop.R;
|
||||
import com.stone.shop.model.FeedBack;
|
||||
import com.stone.shop.model.User;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* 意见反馈界面
|
||||
*
|
||||
* @date 2014-5-27
|
||||
* @author Stone
|
||||
*/
|
||||
public class FeedBackActivity extends Activity implements OnClickListener {
|
||||
|
||||
private static final String TAG = "FeedBackActivity";
|
||||
|
||||
private EditText etContent;
|
||||
private Button btnSubmit;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_feedback);
|
||||
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
etContent = (EditText) findViewById(R.id.et_feedback_content);
|
||||
btnSubmit = (Button) findViewById(R.id.btn_feedback_submit);
|
||||
btnSubmit.setOnClickListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交用户的反馈信息
|
||||
*/
|
||||
private void submit() {
|
||||
String content = etContent.getText().toString();
|
||||
if (content.equals("")) {
|
||||
toast("亲,请先写点东西吧");
|
||||
} else {
|
||||
BmobUser user = BmobUser.getCurrentUser(this);
|
||||
FeedBack fb = new FeedBack();
|
||||
fb.setUsername(user.getUsername());
|
||||
fb.setEmail(user.getEmail());
|
||||
fb.setContent(content);
|
||||
fb.save(this, new SaveListener() {
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
// TODO Auto-generated method stub
|
||||
toast("提交成功, 在这里会尽快回复");
|
||||
back();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int arg0, String arg1) {
|
||||
// TODO Auto-generated method stub
|
||||
toast("提交失败");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.btn_feedback_submit:
|
||||
submit();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void back() {
|
||||
finish();
|
||||
}
|
||||
|
||||
public void clickFeedBack(View v) {
|
||||
finish();
|
||||
}
|
||||
|
||||
private void toast(String toast) {
|
||||
Toast.makeText(this, toast, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,195 +0,0 @@
|
|||
package com.stone.shop.view;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.opengl.Visibility;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.view.ViewPager.OnPageChangeListener;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ImageView.ScaleType;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import cn.bmob.v3.Bmob;
|
||||
import cn.bmob.v3.BmobQuery;
|
||||
import cn.bmob.v3.listener.FindListener;
|
||||
import cn.bmob.v3.listener.GetServerTimeListener;
|
||||
|
||||
import com.stone.date.TypeDef;
|
||||
import com.stone.shop.R;
|
||||
import com.stone.shop.adapter.ImagePagerAdapter;
|
||||
import com.stone.shop.adapter.NewsListAdapter;
|
||||
import com.stone.shop.model.News;
|
||||
import com.stone.shop.model.Shop;
|
||||
import com.stone.ui.AutoScrollViewPager;
|
||||
import com.stone.ui.ListScrollView;
|
||||
|
||||
/**
|
||||
* 主界面
|
||||
*
|
||||
* @date 2014-4-24
|
||||
* @author Stone
|
||||
*/
|
||||
public class HomeActivity extends Activity implements OnClickListener,
|
||||
OnItemClickListener {
|
||||
|
||||
private static final String TAG = "HomeActivity";
|
||||
|
||||
private ListScrollView listScrollView;
|
||||
|
||||
// 校历
|
||||
private TextView tvWeek; // 周次和星期
|
||||
private TextView tvDay; // 年月日
|
||||
|
||||
// 图片轮播
|
||||
private FrameLayout flImageAds;
|
||||
private AutoScrollViewPager viewPager;
|
||||
private List<View> mImgViews;
|
||||
private ImageButton btnHideAds;
|
||||
private int[] mImgResId = { R.drawable.ic_banner1, R.drawable.ic_banner1,
|
||||
R.drawable.ic_banner1, R.drawable.ic_banner1 };
|
||||
|
||||
// 校园新闻
|
||||
private ListView lvNewsList;
|
||||
private List<News> newsList = new ArrayList<News>();
|
||||
private NewsListAdapter newsListAdapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_home);
|
||||
|
||||
// 解决ScrollView和ListView之间的冲突
|
||||
listScrollView = (ListScrollView) findViewById(R.id.listScrollView);
|
||||
lvNewsList = (ListView) findViewById(R.id.lv_news);
|
||||
listScrollView.setListView(lvNewsList);
|
||||
|
||||
flImageAds = (FrameLayout) findViewById(R.id.fl_image_ads);
|
||||
viewPager = (AutoScrollViewPager) findViewById(R.id.view_pager);
|
||||
btnHideAds = (ImageButton) findViewById(R.id.btn_hide_ads);
|
||||
|
||||
mImgViews = new ArrayList<View>();
|
||||
for (int i = 0; i < mImgResId.length; i++) {
|
||||
ImageView imageView = new ImageView(this);
|
||||
imageView.setImageResource(mImgResId[i]);
|
||||
imageView.setScaleType(ScaleType.CENTER_CROP);
|
||||
mImgViews.add(imageView);
|
||||
}
|
||||
|
||||
btnHideAds.setOnClickListener(this);
|
||||
|
||||
viewPager.setAdapter(new ImagePagerAdapter(this, mImgViews));
|
||||
viewPager.setInterval(3000); // 设置自动滚动的间隔时间,单位为毫秒
|
||||
viewPager.setDirection(AutoScrollViewPager.RIGHT); // 设置自动滚动的方向,默认向右
|
||||
viewPager.setCycle(true); // 是否自动循环轮播,默认为true
|
||||
viewPager.setScrollDurationFactor(3); // 设置ViewPager滑动动画间隔时间的倍率,达到减慢动画或改变动画速度的效果
|
||||
viewPager.setStopScrollWhenTouch(true); // 当手指碰到ViewPager时是否停止自动滚动,默认为true
|
||||
viewPager.setBorderAnimation(true); // 设置循环滚动时滑动到从边缘滚动到下一个是否需要动画,默认为true
|
||||
viewPager
|
||||
.setSlideBorderMode(AutoScrollViewPager.SLIDE_BORDER_MODE_NONE);// 滑动到第一个或最后一个Item的处理方式,支持没有任何操作、轮播以及传递到父View三种模式
|
||||
|
||||
viewPager.startAutoScroll();
|
||||
|
||||
// 校历
|
||||
tvWeek = (TextView) findViewById(R.id.tv_week);
|
||||
tvDay = (TextView) findViewById(R.id.tv_day);
|
||||
setTime();
|
||||
|
||||
// 新闻
|
||||
newsListAdapter = new NewsListAdapter(this, newsList);
|
||||
lvNewsList.setAdapter(newsListAdapter);
|
||||
lvNewsList.setOnItemClickListener(this);
|
||||
|
||||
getNewsData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置校历中日期的时间
|
||||
*/
|
||||
public void setTime() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
String year = calendar.get(Calendar.YEAR)+"";
|
||||
String month = calendar.get(Calendar.MONTH)+1+"";
|
||||
String day = calendar.get(Calendar.DAY_OF_MONTH)+"";
|
||||
String week = calendar.get(Calendar.WEEK_OF_YEAR)-9+"";
|
||||
String dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK)+"";
|
||||
String chDayOfWeek = TypeDef.chDayOfWeek[Integer.parseInt(dayOfWeek)-1];
|
||||
toast(year+"-"+month+"-"+day+" "+" 第 "+week+" 周 "+" "+" 星期 "+chDayOfWeek);
|
||||
tvWeek.setText(" 第 "+week+" 周 "+" "+" 星期 "+chDayOfWeek);
|
||||
tvDay.setText(year+" 年 "+month+" 月 "+day+" 日");
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化新闻列表数据
|
||||
* @date 2014-5-3
|
||||
* @author Stone
|
||||
*/
|
||||
public void getNewsData() {
|
||||
BmobQuery<News> query = new BmobQuery<News>();
|
||||
query.order("-updatedAt");
|
||||
query.findObjects(this, new FindListener<News>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<News> object) {
|
||||
newsList = object;
|
||||
// 通知Adapter数据更新
|
||||
newsListAdapter.refresh((ArrayList<News>) newsList);
|
||||
newsListAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int arg0, String arg1) {
|
||||
toast("对不起, 获取数据失败了");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
// start auto scroll when onResume
|
||||
viewPager.startAutoScroll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.btn_hide_ads:
|
||||
flImageAds.setVisibility(View.GONE);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position,
|
||||
long id) {
|
||||
Intent toNewsDetail = new Intent(HomeActivity.this, NewsActivity.class);
|
||||
toNewsDetail.putExtra("NewsTitle", newsList.get(position).getTitle());
|
||||
toNewsDetail.putExtra("NewsAuthor", newsList.get(position).getAuthor());
|
||||
toNewsDetail.putExtra("NewsTime", newsList.get(position).getCreatedAt());
|
||||
toNewsDetail.putExtra("NewsContent", newsList.get(position).getContent());
|
||||
startActivity(toNewsDetail);
|
||||
}
|
||||
|
||||
public void toast(String toast) {
|
||||
Toast.makeText(this, toast, Toast.LENGTH_SHORT);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,346 +0,0 @@
|
|||
package com.stone.shop.view;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import cn.bmob.v3.Bmob;
|
||||
import cn.bmob.v3.listener.SaveListener;
|
||||
|
||||
import com.stone.shop.R;
|
||||
import com.stone.shop.model.User;
|
||||
import com.stone.util.Util;
|
||||
import com.tencent.connect.UserInfo;
|
||||
import com.tencent.connect.auth.QQAuth;
|
||||
import com.tencent.connect.common.Constants;
|
||||
import com.tencent.tauth.IUiListener;
|
||||
import com.tencent.tauth.Tencent;
|
||||
import com.tencent.tauth.UiError;
|
||||
|
||||
/**
|
||||
* 登陆界面
|
||||
*
|
||||
* @date 2014-4-24
|
||||
* @author Stone
|
||||
*/
|
||||
public class LoginActivity extends Activity implements OnClickListener {
|
||||
|
||||
private static final String TAG = "LoginActicity";
|
||||
|
||||
private Button btnLogin;
|
||||
private Button btnReg;
|
||||
private EditText etUsername;
|
||||
private EditText etPassword;
|
||||
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
private static final String APP_ID = "222222";
|
||||
private UserInfo mInfo;
|
||||
private TextView mUserInfo;
|
||||
private ImageView mUserLogo;
|
||||
private ImageView mNewLoginButton;
|
||||
private TextView backInfo;
|
||||
|
||||
// QQ登陆
|
||||
private static Tencent mTencent;
|
||||
// private QQAuth mQQAuth;
|
||||
|
||||
Handler mHandler = new Handler() {
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
if (msg.what == 0) {
|
||||
JSONObject response = (JSONObject) msg.obj;
|
||||
if (response.has("nickname")) {
|
||||
try {
|
||||
mUserInfo.setVisibility(android.view.View.VISIBLE);
|
||||
mUserInfo.setText(response.getString("nickname"));
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
} else if (msg.what == 1) {
|
||||
Bitmap bitmap = (Bitmap) msg.obj;
|
||||
mUserLogo.setImageBitmap(bitmap);
|
||||
mUserLogo.setVisibility(android.view.View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// 初始化 Bmob SDK
|
||||
// 使用时请将第二个参数Application ID替换成你在Bmob服务器端创建的Application ID
|
||||
Bmob.initialize(this, "252a2c58d0dc9a78a5411501c62ce0de");
|
||||
setContentView(R.layout.activity_login);
|
||||
|
||||
// QQ登陆, 获取实例
|
||||
// mQQAuth = QQAuth.createInstance(APP_ID,
|
||||
// this.getApplicationContext());
|
||||
mTencent = Tencent.createInstance(APP_ID, this.getApplicationContext());
|
||||
|
||||
btnLogin = (Button) findViewById(R.id.btn_login);
|
||||
btnReg = (Button) findViewById(R.id.btn_register);
|
||||
|
||||
etUsername = (EditText) findViewById(R.id.et_username);
|
||||
etPassword = (EditText) findViewById(R.id.et_password);
|
||||
|
||||
btnLogin.setOnClickListener(this);
|
||||
btnReg.setOnClickListener(this);
|
||||
|
||||
findViewById(R.id.btn_qq).setOnClickListener(this);
|
||||
|
||||
mUserInfo = (TextView) findViewById(R.id.user_nickname);
|
||||
mUserLogo = (ImageView) findViewById(R.id.user_logo);
|
||||
mNewLoginButton = (ImageView) findViewById(R.id.new_login_btn);
|
||||
mNewLoginButton.setOnClickListener(this);
|
||||
backInfo = (TextView) findViewById(R.id.user_callback);
|
||||
|
||||
getUserInfo();
|
||||
|
||||
}
|
||||
|
||||
private void getUserInfo() {
|
||||
SharedPreferences sp = getSharedPreferences("UserInfo", 0);
|
||||
etUsername.setText(sp.getString("username", null));
|
||||
etPassword.setText(sp.getString("password", null));
|
||||
}
|
||||
|
||||
// 保存用户的登陆记录
|
||||
private void saveUserInfo(String username, String password) {
|
||||
SharedPreferences sp = getSharedPreferences("UserInfo", 0);
|
||||
Editor editor = sp.edit();
|
||||
editor.putString("username", username);
|
||||
editor.putString("password", password);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public void onClickLogin() {
|
||||
if (!mTencent.isSessionValid()) {
|
||||
mTencent.login(this, "all", loginListener);
|
||||
Log.d("SDKQQAgentPref", "FirstLaunch_SDK:" + SystemClock.elapsedRealtime());
|
||||
} else {
|
||||
|
||||
mTencent.logout(this);
|
||||
updateUserInfo();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
// 登陆
|
||||
case R.id.btn_login:
|
||||
username = etUsername.getText().toString();
|
||||
password = etPassword.getText().toString();
|
||||
|
||||
if (!Util.isNetworkConnected(this)) {
|
||||
toast("木有网络 ( ⊙ o ⊙ ) ");
|
||||
} else if (username.equals("") || password.equals("")) {
|
||||
toast("请输入账号和密码");
|
||||
break;
|
||||
} else {
|
||||
final User bu2 = new User();
|
||||
bu2.setUsername(username);
|
||||
bu2.setPassword(password);
|
||||
bu2.login(this, new SaveListener() {
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
// TODO Auto-generated method stub
|
||||
toast("欢迎进入 在这里 服务系统");
|
||||
// 保存用户信息
|
||||
saveUserInfo(username, password);
|
||||
// 跳转到主页
|
||||
User.userId = bu2.getObjectId();
|
||||
Intent toHome = new Intent(LoginActivity.this, BaseActivity.class);
|
||||
startActivity(toHome);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int arg0, String arg1) {
|
||||
// TODO Auto-generated method stub
|
||||
toast("用户名或密码错误");
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
case R.id.btn_register:
|
||||
Intent toReg = new Intent(LoginActivity.this, RegisterActivity.class);
|
||||
startActivity(toReg);
|
||||
break;
|
||||
case R.id.btn_qq:
|
||||
|
||||
onClickLogin();
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void toast(String toast) {
|
||||
Toast.makeText(this, toast, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
IUiListener loginListener = new BaseUiListener() {
|
||||
@Override
|
||||
protected void doComplete(JSONObject values) {
|
||||
Log.d("SDKQQAgentPref", "AuthorSwitch_SDK:" + SystemClock.elapsedRealtime());
|
||||
initOpenidAndToken(values);
|
||||
updateUserInfo();
|
||||
}
|
||||
};
|
||||
|
||||
private class BaseUiListener implements IUiListener {
|
||||
|
||||
@Override
|
||||
public void onComplete(Object response) {
|
||||
if (null == response) {
|
||||
Util.showResultDialog(LoginActivity.this, "返回为空", "登录失败");
|
||||
return;
|
||||
}
|
||||
JSONObject jsonResponse = (JSONObject) response;
|
||||
if (null != jsonResponse && jsonResponse.length() == 0) {
|
||||
Util.showResultDialog(LoginActivity.this, "返回为空", "登录失败");
|
||||
return;
|
||||
}
|
||||
// Util.showResultDialog(LoginActivity.this, response.toString(),
|
||||
// "登录成功");
|
||||
doComplete((JSONObject) response);
|
||||
try {
|
||||
User.userId = jsonResponse.getString("openid");
|
||||
} catch (JSONException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Intent toHome = new Intent(LoginActivity.this, BaseActivity.class);
|
||||
startActivity(toHome);
|
||||
finish();
|
||||
}
|
||||
|
||||
protected void doComplete(JSONObject values) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(UiError e) {
|
||||
Util.toastMessage(LoginActivity.this, "onError: " + e.errorDetail);
|
||||
Util.dismissDialog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
Util.toastMessage(LoginActivity.this, "onCancel: ");
|
||||
Util.dismissDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateUserInfo() {
|
||||
if (mTencent != null && mTencent.isSessionValid()) {
|
||||
IUiListener listener = new IUiListener() {
|
||||
|
||||
@Override
|
||||
public void onError(UiError e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete(final Object response) {
|
||||
Message msg = new Message();
|
||||
msg.obj = response;
|
||||
msg.what = 0;
|
||||
mHandler.sendMessage(msg);
|
||||
new Thread() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
JSONObject json = (JSONObject) response;
|
||||
if (json.has("figureurl")) {
|
||||
Bitmap bitmap = null;
|
||||
try {
|
||||
bitmap = Util.getbitmap(json.getString("figureurl_qq_2"));
|
||||
} catch (JSONException e) {
|
||||
|
||||
}
|
||||
Message msg = new Message();
|
||||
msg.obj = bitmap;
|
||||
msg.what = 1;
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
}.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
|
||||
}
|
||||
};
|
||||
mInfo = new UserInfo(this, mTencent.getQQToken());
|
||||
mInfo.getUserInfo(listener);
|
||||
|
||||
} else {
|
||||
mUserInfo.setText("");
|
||||
mUserInfo.setVisibility(android.view.View.GONE);
|
||||
mUserLogo.setVisibility(android.view.View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public static void initOpenidAndToken(JSONObject jsonObject) {
|
||||
try {
|
||||
String token = jsonObject.getString(Constants.PARAM_ACCESS_TOKEN);
|
||||
String expires = jsonObject.getString(Constants.PARAM_EXPIRES_IN);
|
||||
String openId = jsonObject.getString(Constants.PARAM_OPEN_ID);
|
||||
if (!TextUtils.isEmpty(token) && !TextUtils.isEmpty(expires) && !TextUtils.isEmpty(openId)) {
|
||||
mTencent.setAccessToken(token, expires);
|
||||
mTencent.setOpenId(openId);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
Log.d(TAG, "-->onActivityResult " + requestCode + " resultCode=" + resultCode);
|
||||
if (requestCode == Constants.REQUEST_LOGIN || requestCode == Constants.REQUEST_APPBAR) {
|
||||
Tencent.onActivityResultData(requestCode, resultCode, data, loginListener);
|
||||
}
|
||||
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
|
@ -1,202 +0,0 @@
|
|||
package com.stone.shop.view;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
import cn.bmob.v3.BmobQuery;
|
||||
import cn.bmob.v3.BmobUser;
|
||||
import cn.bmob.v3.listener.CountListener;
|
||||
|
||||
import com.stone.date.MessageDef;
|
||||
import com.stone.shop.R;
|
||||
import com.stone.shop.adapter.MineListAdapter;
|
||||
import com.stone.shop.model.Order;
|
||||
|
||||
/**
|
||||
* 个人中心主界面
|
||||
* @date 2014-4-24
|
||||
* @author Stone
|
||||
*/
|
||||
public class MineActivity extends Activity implements OnItemClickListener{
|
||||
|
||||
private static final String TAG = "MineActivity" ;
|
||||
|
||||
private String[] userItemNames = {"stonekity"} ;
|
||||
private String[] userItemContents = {""} ;
|
||||
private String[] orderItemNames = {"当前订单", "历史订单"};
|
||||
private String[] orderItemContents = {"*", ""};
|
||||
private String[] aboutItemNames = {"通知中心", "软件相关", "推荐给朋友", "退出账号"};
|
||||
private String[] aboutItemContents = {"", "", "", ""};
|
||||
|
||||
private int[] userImgIds = {R.drawable.ic_menu_myplaces};
|
||||
private int[] orderImgIds = {R.drawable.ic_menu_find_holo_light, R.drawable.ic_menu_copy_holo_light};
|
||||
private int[] aboutImgIds = {R.drawable.ic_menu_notifications, R.drawable.ic_menu_info_details, R.drawable.ic_menu_share, R.drawable.ic_star_yes};
|
||||
|
||||
private ListView lvMineUser;
|
||||
private ListView lvMineOrder;
|
||||
private ListView lvMineAbout;
|
||||
private MineListAdapter userListAdapter;
|
||||
private MineListAdapter orderListAdapter;
|
||||
private MineListAdapter aboutListAdapter;
|
||||
|
||||
private Handler mHandler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case MessageDef.MINE_FINISH_LOAD_DATA:
|
||||
//toast("Handler 收到数据加载完成的消息");
|
||||
orderListAdapter.notifyDataSetChanged();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_mine);
|
||||
|
||||
initData("已取餐");
|
||||
initData("未取餐");
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
|
||||
lvMineUser = (ListView) findViewById(R.id.lv_mine_user);
|
||||
lvMineOrder = (ListView) findViewById(R.id.lv_mine_order);
|
||||
lvMineAbout = (ListView) findViewById(R.id.lv_mine_about);
|
||||
|
||||
userListAdapter = new MineListAdapter(this, userItemNames, userItemContents, userImgIds);
|
||||
orderListAdapter = new MineListAdapter(this, orderItemNames, orderItemContents, orderImgIds);
|
||||
aboutListAdapter = new MineListAdapter(this, aboutItemNames, aboutItemContents, aboutImgIds);
|
||||
|
||||
lvMineUser.setAdapter(userListAdapter);
|
||||
lvMineOrder.setAdapter(orderListAdapter);
|
||||
lvMineAbout.setAdapter(aboutListAdapter);
|
||||
|
||||
lvMineUser.setOnItemClickListener(this);
|
||||
lvMineOrder.setOnItemClickListener(this);
|
||||
lvMineAbout.setOnItemClickListener(this);
|
||||
|
||||
}
|
||||
|
||||
//初始化列表菜单中数据
|
||||
public void initData(final String type) {
|
||||
//获取用户
|
||||
BmobUser user = BmobUser.getCurrentUser(this);
|
||||
userItemNames[0] = user.getUsername();
|
||||
|
||||
//获取小菜订单(数量)
|
||||
BmobQuery<Order> query = new BmobQuery<Order>();
|
||||
query.order("-updatedAt");
|
||||
query.addWhereEqualTo("userName", user.getUsername());
|
||||
query.addWhereEqualTo("state", type);
|
||||
query.count(this, Order.class, new CountListener() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(int count) {
|
||||
if(type.equals("未取餐")) {
|
||||
orderItemContents[0] ="( " +count+ " )";
|
||||
}
|
||||
if(type.equals("已取餐")) {
|
||||
orderItemContents[1] ="( " +count+ " )";
|
||||
}
|
||||
Message msg = new Message();
|
||||
msg.what = MessageDef.MINE_FINISH_LOAD_DATA;
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int arg0, String arg1) {
|
||||
toast("查询失败");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position,
|
||||
long id) {
|
||||
|
||||
//个人资料
|
||||
if(parent.getId() == R.id.lv_mine_user) {
|
||||
switch (position) {
|
||||
case 0: //资料卡
|
||||
//toast("点击个人资料");
|
||||
Intent toMineInfo = new Intent(MineActivity.this, MineInfoActivity.class);
|
||||
startActivity(toMineInfo);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//小菜订单
|
||||
if(parent.getId() == R.id.lv_mine_order) {
|
||||
//toast("点击了订单区域");
|
||||
Intent toOrderInfo;
|
||||
switch (position) {
|
||||
case 0:
|
||||
toOrderInfo = new Intent(MineActivity.this, OrderInfoActivity.class);
|
||||
toOrderInfo.putExtra("type", "now");
|
||||
startActivity(toOrderInfo);
|
||||
break;
|
||||
case 1:
|
||||
toOrderInfo = new Intent(MineActivity.this, OrderInfoActivity.class);
|
||||
toOrderInfo.putExtra("type", "old");
|
||||
startActivity(toOrderInfo);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//其他
|
||||
if(parent.getId() == R.id.lv_mine_about) {
|
||||
|
||||
switch (position) {
|
||||
case 1: //软件相关
|
||||
Intent toMineSoft = new Intent(MineActivity.this, MineSoftActivity.class);
|
||||
startActivity(toMineSoft);
|
||||
break;
|
||||
case 2: //推荐给朋友
|
||||
Intent toShare = new Intent(Intent.ACTION_SEND);
|
||||
toShare.setType("text/plain");
|
||||
toShare.putExtra(Intent.EXTRA_SUBJECT, "分享");
|
||||
toShare.putExtra(Intent.EXTRA_TEXT, "校园小菜-HBUT版" +"\n" + "针对湖工大的校园小菜测试版上线了,赶紧下载体验吧"
|
||||
+ "http://xiaocai.bmob.cn");
|
||||
startActivity(Intent.createChooser(toShare, "分享到"));
|
||||
break;
|
||||
case 3: //退出当期账号
|
||||
BmobUser.logOut(this);
|
||||
Intent toLogin = new Intent(MineActivity.this, LoginActivity.class);
|
||||
startActivity(toLogin);
|
||||
finish();
|
||||
break;
|
||||
|
||||
default:
|
||||
//toast("点击了通知区域");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void toast(String toast) {
|
||||
Toast.makeText(this, toast, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,124 +0,0 @@
|
|||
package com.stone.shop.view;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cn.bmob.v3.BmobQuery;
|
||||
import cn.bmob.v3.BmobUser;
|
||||
import cn.bmob.v3.listener.FindListener;
|
||||
|
||||
import com.stone.date.MessageDef;
|
||||
import com.stone.shop.R;
|
||||
import com.stone.shop.model.User;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* 个人资料卡
|
||||
* @date 2014-5-21
|
||||
* @author Stone
|
||||
*/
|
||||
public class MineInfoActivity extends Activity {
|
||||
|
||||
private TextView tvUsername;
|
||||
private TextView tvSchool;
|
||||
private TextView tvCademy;
|
||||
private TextView tvDorPart;
|
||||
private TextView tvDorNum;
|
||||
private TextView tvPhone;
|
||||
private TextView tvQQ;
|
||||
|
||||
private User curUser = new User();
|
||||
|
||||
private Handler mHandler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case MessageDef.MINE_INFO_FINISH_FIND_USER:
|
||||
initView();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_mine_info);
|
||||
|
||||
getCurUser();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
tvUsername = (TextView) findViewById(R.id.tv_mineinfo_username);
|
||||
tvSchool = (TextView) findViewById(R.id.tv_mineinfo_school);
|
||||
tvCademy = (TextView) findViewById(R.id.tv_mineinfo_cademy);
|
||||
tvDorPart = (TextView) findViewById(R.id.tv_mineinfo_dorpart);
|
||||
tvDorNum = (TextView) findViewById(R.id.tv_mineinfo_dornum);
|
||||
tvPhone = (TextView) findViewById(R.id.tv_mineinfo_phone);
|
||||
tvQQ = (TextView) findViewById(R.id.tv_mineinfo_qq);
|
||||
|
||||
tvUsername.setText(curUser.getUsername());
|
||||
tvSchool.setText(curUser.getSchool());
|
||||
tvCademy.setText(curUser.getCademy());
|
||||
tvDorPart.setText(curUser.getDorPart());
|
||||
tvDorNum.setText(curUser.getDorNum());
|
||||
tvPhone.setText(curUser.getPhone());
|
||||
tvQQ.setText(curUser.getQQ());
|
||||
|
||||
}
|
||||
|
||||
private void getCurUser() {
|
||||
BmobUser bmobUser = BmobUser.getCurrentUser(this);
|
||||
BmobQuery<User> query = new BmobQuery<User>();
|
||||
query.addWhereEqualTo("objectId", bmobUser.getObjectId());
|
||||
query.findObjects(this, new FindListener<User>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<User> object) {
|
||||
curUser = object.get(0);
|
||||
Message msg = new Message();
|
||||
msg.what = MessageDef.MINE_INFO_FINISH_FIND_USER;
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int arg0, String arg1) {
|
||||
toast("亲, 获取当前用户失败");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void clickEdit(View v) {
|
||||
Intent toEditMineInfo = new Intent(MineInfoActivity.this, MineInfoEditActivity.class);
|
||||
// Bundle bundle = new Bundle();
|
||||
// bundle.putString("username", curUser.getUsername());
|
||||
// bundle.putString("school", curUser.getSchool());
|
||||
// bundle.putString("cademy", curUser.getCademy());
|
||||
// bundle.putString("dorpart", curUser.getDorPart());
|
||||
// bundle.putString("dornum", curUser.getDorNum());
|
||||
// bundle.putString("phone", curUser.getPhone());
|
||||
// bundle.putString("qq", curUser.getQQ());
|
||||
// toEditMineInfo.putExtras(bundle);
|
||||
startActivity(toEditMineInfo);
|
||||
}
|
||||
|
||||
public void clickBack(View v) {
|
||||
finish();
|
||||
}
|
||||
|
||||
private void toast(String toast) {
|
||||
Toast.makeText(this, toast, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,145 +0,0 @@
|
|||
package com.stone.shop.view;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cn.bmob.v3.BmobQuery;
|
||||
import cn.bmob.v3.BmobUser;
|
||||
import cn.bmob.v3.listener.FindListener;
|
||||
import cn.bmob.v3.listener.UpdateListener;
|
||||
|
||||
import com.stone.date.MessageDef;
|
||||
import com.stone.shop.R;
|
||||
import com.stone.shop.model.User;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* 修改个人资料卡
|
||||
* @date 2014-5-28
|
||||
* @author Stone
|
||||
*/
|
||||
public class MineInfoEditActivity extends Activity {
|
||||
|
||||
private EditText etUsername;
|
||||
private EditText etSchool;
|
||||
private EditText etCademy;
|
||||
private EditText etDorPart;
|
||||
private EditText etDorNum;
|
||||
private EditText etPhone;
|
||||
private EditText etQQ;
|
||||
|
||||
private User curUser;
|
||||
private Bundle bundle;
|
||||
private Handler mHandler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case MessageDef.MINE_INFO_FINISH_FIND_USER:
|
||||
initView();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_mine_info_edit);
|
||||
|
||||
setCurUser();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
etUsername = (EditText) findViewById(R.id.et_mineinfo_username);
|
||||
etSchool = (EditText) findViewById(R.id.et_mineinfo_school);
|
||||
etCademy = (EditText) findViewById(R.id.et_mineinfo_cademy);
|
||||
etDorPart = (EditText) findViewById(R.id.et_mineinfo_dorpart);
|
||||
etDorNum = (EditText) findViewById(R.id.et_mineinfo_dornum);
|
||||
etPhone = (EditText) findViewById(R.id.et_mineinfo_phone);
|
||||
etQQ = (EditText) findViewById(R.id.et_mineinfo_qq);
|
||||
|
||||
etUsername.setText(curUser.getUsername());
|
||||
etSchool.setText(curUser.getSchool());
|
||||
etCademy.setText(curUser.getCademy());
|
||||
etDorPart.setText(curUser.getDorPart());
|
||||
etDorNum.setText(curUser.getDorNum());
|
||||
etPhone.setText(curUser.getPhone());
|
||||
etQQ.setText(curUser.getQQ());
|
||||
}
|
||||
|
||||
private void setCurUser() {
|
||||
BmobUser bmobUser = BmobUser.getCurrentUser(this);
|
||||
BmobQuery<User> query = new BmobQuery<User>();
|
||||
query.addWhereEqualTo("objectId", bmobUser.getObjectId());
|
||||
query.findObjects(this, new FindListener<User>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<User> object) {
|
||||
curUser = object.get(0);
|
||||
//toast("查询到用户 " + object.size());
|
||||
Message msg = new Message();
|
||||
msg.what = MessageDef.MINE_INFO_FINISH_FIND_USER;
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int arg0, String arg1) {
|
||||
toast("获取当前用户失败");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void saveUserInfo() {
|
||||
if(curUser == null) {
|
||||
toast("curUser为空");
|
||||
} else {
|
||||
toast("当前用户为 " + curUser.getUsername());
|
||||
}
|
||||
Log.i("当前用户的ID: ", curUser.getObjectId());
|
||||
curUser.setUsername(etUsername.getText().toString());
|
||||
curUser.setSchool(etSchool.getText().toString());
|
||||
curUser.setCademy(etCademy.getText().toString());
|
||||
curUser.setDorPart(etDorPart.getText().toString());
|
||||
curUser.setDorNum(etDorNum.getText().toString());
|
||||
curUser.setPhone(etPhone.getText().toString());
|
||||
curUser.setQQ(etQQ.getText().toString());
|
||||
curUser.update(this, curUser.getObjectId(), new UpdateListener() {
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
toast("更新成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int arg0, String arg1) {
|
||||
toast("更新失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void clickSave(View v) {
|
||||
saveUserInfo();
|
||||
finish();
|
||||
}
|
||||
|
||||
public void clickCancel(View v) {
|
||||
finish();
|
||||
}
|
||||
|
||||
private void toast(String toast) {
|
||||
Toast.makeText(this, toast, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
package com.stone.shop.view;
|
||||
|
||||
import com.stone.shop.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* 新闻内容显示界面
|
||||
* @date 2014-5-8
|
||||
* @author Stone
|
||||
*/
|
||||
public class NewsActivity extends Activity {
|
||||
|
||||
private static String TAG = "NewsActivity";
|
||||
|
||||
private TextView tvNewsTitle;
|
||||
private TextView tvNewsAuthor;
|
||||
private TextView tvNewsTime;
|
||||
private TextView tvNewsContent;
|
||||
|
||||
private String newsTitle;
|
||||
private String newsAuthor;
|
||||
private String newsTime;
|
||||
private String newsContent;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_news);
|
||||
|
||||
getIntentData();
|
||||
initView();
|
||||
}
|
||||
|
||||
//获取Intent中传入的新闻数据
|
||||
private void getIntentData() {
|
||||
newsTitle = getIntent().getStringExtra("NewsTitle");
|
||||
newsAuthor = getIntent().getStringExtra("NewsAuthor");
|
||||
newsTime = getIntent().getStringExtra("NewsTime");
|
||||
newsContent = getIntent().getStringExtra("NewsContent");
|
||||
|
||||
newsTitle = splitString(newsTitle); //拆分字符串, 将新闻标题设置为 "】" 后面的内容
|
||||
}
|
||||
|
||||
private String splitString(String str) {
|
||||
String[] strs = null;
|
||||
if(str.equals("")){
|
||||
return "";
|
||||
} else if ( !(str.contains("【") || str.contains("】")) ) {
|
||||
return str;
|
||||
}
|
||||
strs = str.split("】");
|
||||
return strs[1];
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
tvNewsTitle = (TextView) findViewById(R.id.tv_news_title);
|
||||
tvNewsAuthor = (TextView) findViewById(R.id.tv_news_author);
|
||||
tvNewsTime = (TextView) findViewById(R.id.tv_news_time);
|
||||
tvNewsContent = (TextView) findViewById(R.id.tv_news_content);
|
||||
|
||||
tvNewsTitle.setText(newsTitle);
|
||||
tvNewsAuthor.setText("作者: "+newsAuthor);
|
||||
tvNewsTime.setText("发布日期 : "+newsTime);
|
||||
tvNewsContent.setText(newsContent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,218 +0,0 @@
|
|||
package com.stone.shop.view;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.TimePickerDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TimePicker;
|
||||
import android.widget.Toast;
|
||||
|
||||
import cn.bmob.v3.BmobUser;
|
||||
import cn.bmob.v3.listener.SaveListener;
|
||||
|
||||
import com.stone.shop.R;
|
||||
import com.stone.shop.model.Good;
|
||||
import com.stone.shop.model.Order;
|
||||
import com.stone.shop.model.Shop;
|
||||
import com.stone.ui.DialogOrder;
|
||||
import com.stone.util.Util;
|
||||
|
||||
/**
|
||||
* 应用主界面
|
||||
*
|
||||
* @date 2014-5-13
|
||||
* @author Stone
|
||||
*/
|
||||
public class OrderActivity extends Activity implements OnClickListener {
|
||||
|
||||
private TextView tvOrderShop; // 店名
|
||||
private TextView tvOrderGood; // 菜名
|
||||
private TextView tvOrderCount; // 数量
|
||||
private TextView tvOrderTime; // 取餐时间
|
||||
private TimePicker tpOrderTime; // 时间选择控件
|
||||
private EditText etOrderPhone; // 联系电话
|
||||
private EditText etOrderWords; // 附加留言
|
||||
private Button btnOrderCountMore; // 增加数量
|
||||
private Button btnOrderCountLess; // 减少数量
|
||||
|
||||
private Button btnOrderSetTime; // 设置时间
|
||||
private Button btnDlgOk; // 设置时间完成
|
||||
private Button btnOrderSubmit; // 提交订单
|
||||
|
||||
// private DialogOrder dlgSetOrderTime;
|
||||
// private View dlgOrderView;
|
||||
private int mHour;
|
||||
private int mMinute;
|
||||
private String time = "12 : 30";
|
||||
private TimePickerDialog dlgSetOrderTime;
|
||||
private TimePickerDialog.OnTimeSetListener mTimeSetListener = new TimePickerDialog.OnTimeSetListener() {
|
||||
|
||||
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
||||
mHour = hourOfDay;
|
||||
mMinute = minute;
|
||||
updateDisplay();
|
||||
}
|
||||
};
|
||||
|
||||
// 从上级页面中传入的数据
|
||||
private Shop shop; // 当期选择的Shop
|
||||
private Good good; // 当前选择的商品
|
||||
private String shopID; // 当前选择的Shop的ID
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_order);
|
||||
|
||||
shop = (Shop) getIntent().getSerializableExtra("shop");
|
||||
good = (Good) getIntent().getSerializableExtra("good");
|
||||
shopID = getIntent().getStringExtra("shopID");
|
||||
|
||||
initView();
|
||||
// initDlgView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
|
||||
tvOrderShop = (TextView) findViewById(R.id.tv_order_shop);
|
||||
tvOrderGood = (TextView) findViewById(R.id.tv_order_good);
|
||||
tvOrderCount = (TextView) findViewById(R.id.tv_order_count);
|
||||
tvOrderTime = (TextView) findViewById(R.id.tv_order_time);
|
||||
tvOrderShop.setText(shop.getName());
|
||||
tvOrderGood.setText(good.getName());
|
||||
|
||||
etOrderPhone = (EditText) findViewById(R.id.et_order_phone);
|
||||
etOrderWords = (EditText) findViewById(R.id.et_order_words);
|
||||
|
||||
btnOrderCountMore = (Button) findViewById(R.id.btn_order_count_more);
|
||||
btnOrderCountLess = (Button) findViewById(R.id.btn_order_count_less);
|
||||
btnOrderSetTime = (Button) findViewById(R.id.btn_set_time);
|
||||
btnOrderSubmit = (Button) findViewById(R.id.btn_order_submit);
|
||||
btnOrderCountMore.setOnClickListener(this);
|
||||
btnOrderCountLess.setOnClickListener(this);
|
||||
btnOrderSetTime.setOnClickListener(this);
|
||||
btnOrderSubmit.setOnClickListener(this);
|
||||
|
||||
}
|
||||
|
||||
// private void initDlgView() {
|
||||
// LayoutInflater inflater = LayoutInflater.from(this);
|
||||
// dlgOrderView = inflater.inflate(R.layout.dlg_order_settime, null);
|
||||
// tpOrderTime = (TimePicker) dlgOrderView.findViewById(R.id.tp_dlg_time);
|
||||
// tpOrderTime.setIs24HourView(true);
|
||||
// btnDlgOk = (Button) dlgOrderView.findViewById(R.id.btn_dlg_ok);
|
||||
// btnDlgOk.setOnClickListener(this);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int count = 1;
|
||||
switch (v.getId()) {
|
||||
case R.id.btn_order_count_more:
|
||||
count = Integer.parseInt(tvOrderCount.getText().toString());
|
||||
if (count == 4) {
|
||||
toast("每份订单数量不能超过 4");
|
||||
} else {
|
||||
tvOrderCount.setText((count + 1) + "");
|
||||
}
|
||||
break;
|
||||
case R.id.btn_order_count_less:
|
||||
count = Integer.parseInt(tvOrderCount.getText().toString());
|
||||
if (count == 1) {
|
||||
toast("每份订单数量至少为 1 ");
|
||||
} else {
|
||||
tvOrderCount.setText((count - 1) + "");
|
||||
}
|
||||
break;
|
||||
case R.id.btn_set_time:
|
||||
// dlgSetOrderTime = new DialogOrder(this, R.style.MyDialog);
|
||||
// dlgSetOrderTime.show();
|
||||
final Calendar c = Calendar.getInstance();
|
||||
mHour = c.get(Calendar.HOUR_OF_DAY);
|
||||
mMinute = c.get(Calendar.MINUTE);
|
||||
dlgSetOrderTime = new TimePickerDialog(this, mTimeSetListener, mHour, mMinute, true);
|
||||
dlgSetOrderTime.show();
|
||||
break;
|
||||
case R.id.btn_dlg_ok:
|
||||
time = tpOrderTime.getCurrentHour() + " : " + tpOrderTime.getCurrentMinute();
|
||||
dlgSetOrderTime.dismiss();
|
||||
case R.id.btn_order_submit:
|
||||
// toast("小菜订单提交成功");
|
||||
postOrder();
|
||||
finish();
|
||||
// back();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交订单数据
|
||||
*/
|
||||
private void postOrder() {
|
||||
String count = tvOrderCount.getText().toString();
|
||||
String phone = etOrderPhone.getText().toString();
|
||||
String words = etOrderWords.getText().toString();
|
||||
float price = Integer.parseInt(count) * Float.parseFloat(good.getPrice());
|
||||
if (!Util.isPhoneNumberValid(phone)) {
|
||||
toast("请输入正确的联系电话, 方便取餐");
|
||||
} else {
|
||||
Order order = new Order();
|
||||
BmobUser user = BmobUser.getCurrentUser(this);
|
||||
order.setUserName(user.getUsername());
|
||||
order.setGoodID(good.getObjectId());
|
||||
order.setGoodName(good.getName());
|
||||
order.setShopID(shop.getObjectId());
|
||||
order.setShopName(shop.getName());
|
||||
order.setCount(count);
|
||||
order.setTime(time);
|
||||
order.setPrice(price + "");
|
||||
order.setPhone(phone);
|
||||
order.setTips(words);
|
||||
order.save(this, new SaveListener() {
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
// TODO Auto-generated method stub
|
||||
toast("订单提交成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int arg0, String arg1) {
|
||||
// TODO Auto-generated method stub
|
||||
toast("订单提交失败");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDisplay() {
|
||||
time = mHour + " : " + mMinute;
|
||||
tvOrderTime.setText(time);
|
||||
}
|
||||
|
||||
private void back() {
|
||||
Intent back = new Intent(OrderActivity.this, ShopItemActivity.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable("shop", shop);
|
||||
bundle.putString("shopID", shopID); // 商铺的ID需要单独传递,否则获取到的是null
|
||||
back.putExtras(bundle);
|
||||
startActivity(back);
|
||||
}
|
||||
|
||||
private void toast(String toast) {
|
||||
Toast.makeText(this, toast, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue