Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

改了不少 #30

Merged
merged 7 commits into from

2 participants

@whoseyourdady
Collaborator

改了不少

whoseyourdady added some commits
whoseyourdady Merge branch 'master' of git://github.com/Leeforall/NFCShopping 564f71c
whoseyourdady Merge branch 'master' of git://github.com/Leeforall/NFCShopping 1caa877
whoseyourdady Signed-off-by: whoseyourdady <whoseyourdady@sina.cn> ca7daa1
whoseyourdady Merge branch 'master' of git://github.com/Leeforall/NFCShopping
Conflicts:
	mobile phone client/NFCShopping/src/scut/bgooo/ui/CommentListActivity.java

Signed-off-by: whoseyourdady <whoseyourdady@sina.cn>
c470d73
whoseyourdady Merge branch 'master' of git://github.com/Leeforall/NFCShopping
Conflicts:
	mobile phone client/NFCShopping/src/scut/bgooo/ui/ProductActivity.java

Signed-off-by: whoseyourdady <whoseyourdady@sina.cn>
a274f36
whoseyourdady Signed-off-by: whoseyourdady <whoseyourdady@sina.cn> dcacaeb
whoseyourdady Merge branch 'master' of git://github.com/Leeforall/NFCShopping
Conflicts:
	mobile phone client/NFCShopping/src/scut/bgooo/ui/ProductActivity.java

Signed-off-by: whoseyourdady <whoseyourdady@sina.cn>
54e2b33
@Leeforall Leeforall merged commit b6563df into Leeforall:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 8, 2012
Commits on Apr 9, 2012
  1. Signed-off-by: whoseyourdady <whoseyourdady@sina.cn>

    whoseyourdady authored
Commits on Apr 10, 2012
  1. Merge branch 'master' of git://github.com/Leeforall/NFCShopping

    whoseyourdady authored
    Conflicts:
    	mobile phone client/NFCShopping/src/scut/bgooo/ui/CommentListActivity.java
    
    Signed-off-by: whoseyourdady <whoseyourdady@sina.cn>
  2. Merge branch 'master' of git://github.com/Leeforall/NFCShopping

    whoseyourdady authored
    Conflicts:
    	mobile phone client/NFCShopping/src/scut/bgooo/ui/ProductActivity.java
    
    Signed-off-by: whoseyourdady <whoseyourdady@sina.cn>
  3. Signed-off-by: whoseyourdady <whoseyourdady@sina.cn>

    whoseyourdady authored
  4. Merge branch 'master' of git://github.com/Leeforall/NFCShopping

    whoseyourdady authored
    Conflicts:
    	mobile phone client/NFCShopping/src/scut/bgooo/ui/ProductActivity.java
    
    Signed-off-by: whoseyourdady <whoseyourdady@sina.cn>
This page is out of date. Refresh to see the latest.
View
2  WebSite/WebSite/NFCShoppingWebSite.Publish.xml
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<publishData>
- <publishProfile publishUrl="localhost" deleteExistingFiles="False" ftpAnonymousLogin="False" ftpPassiveMode="True" msdeploySite="WebSite/NFCShopping" msdeploySiteID="" msdeployRemoteSitePhysicalPath="" msdeployAllowUntrustedCertificate="False" msdeploySkipExtraFilesOnServer="True" msdeployMarkAsApp="True" profileName="配置文件" publishMethod="MSDeploy" replaceMatchingFiles="True" userName="" savePWD="False" userPWD="" SelectedForPublish="True" />
+ <publishProfile publishUrl="localhost" deleteExistingFiles="False" ftpAnonymousLogin="False" ftpPassiveMode="True" msdeploySite="Web/NFCShopping" msdeploySiteID="" msdeployRemoteSitePhysicalPath="" msdeployAllowUntrustedCertificate="False" msdeploySkipExtraFilesOnServer="True" msdeployMarkAsApp="True" profileName="配置文件" publishMethod="MSDeploy" replaceMatchingFiles="True" userName="" savePWD="False" userPWD="" SelectedForPublish="True" />
</publishData>
View
2  mobile phone client/NFCShopping/AndroidManifest.xml
@@ -4,7 +4,7 @@
android:versionCode="1"
android:versionName="1.0" >
- <uses-sdk android:minSdkVersion="8" />
+ <uses-sdk android:minSdkVersion="5" />
<uses-permission android:name="android.permission.INTERNET" >
</uses-permission>
View
20 mobile phone client/NFCShopping/src/scut/bgooo/concern/ConcernItem.java
@@ -56,10 +56,16 @@ public static int getCount() {
/**
* 这个是从数据库获取item的构造函数,要传入id
* */
+
+ /**
+ *商品图片
+ */
+ private byte [] icon;
+
public ConcernItem(int id, int productId, String name, int type,
String seccategory, float price, float rating, String brand,
String location, String barcode, String description,
- long timestamp, short iscollected) {
+ long timestamp, short iscollected, byte[] data) {
Id = id;
ProductId = productId;
Name = name;
@@ -73,6 +79,7 @@ public ConcernItem(int id, int productId, String name, int type,
setDescription(description);
Timestamp = timestamp;
IsCollected = iscollected;
+ icon = data;
}
public ConcernItem(long timestamp) {
@@ -104,6 +111,9 @@ public Object getAttribute(int index) {
case 6:
temp = getRating();
break;
+ case 7: {
+ temp = getIcon();
+ }break;
default:
break;
}
@@ -161,6 +171,10 @@ public long getTimestamp() {
public int getType() {
return Type;
}
+
+ public byte[] getIcon() {
+ return icon;
+ }
public void setBarcode(String barcode) {
Barcode = barcode;
@@ -193,4 +207,8 @@ public void setRating(float rating) {
public void setSecCategory(String secCategory) {
SecCategory = secCategory;
}
+
+ public void setIcon(byte[] data) {
+ icon = data;
+ }
}
View
6 mobile phone client/NFCShopping/src/scut/bgooo/concern/ConcernItemAdapter.java
@@ -7,6 +7,8 @@
import scut.bgooo.ui.R;
import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -84,7 +86,9 @@ public View getView(int position, View convertView, ViewGroup parent) {
vh.mGoodsPrice = (TextView) concernitem.findViewById(R.id.price);
ConcernItem item = mItems.get(position);
- vh.mImageView.setBackgroundColor(R.drawable.logo);
+ byte [] data = item.getIcon();
+ Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
+ vh.mImageView.setImageBitmap(bitmap);
vh.mGoodScore.setRating(item.getRating());
vh.mGoodsNmae.setText(item.getName());
vh.mGoodsPrice.setText(String.valueOf(item.getPrice()));
View
18 mobile phone client/NFCShopping/src/scut/bgooo/concern/ConcernManager.java
@@ -34,7 +34,7 @@
DBHelper.PRICE_COL, DBHelper.RATING_COL, DBHelper.TIMESTAMP_COL,
DBHelper.ISCOLLECTED_COL, DBHelper.BRAND_COL,
DBHelper.LOCATION_COL, DBHelper.BARCODE_COL,
- DBHelper.SECCATEGORY_COL, DBHelper.DESCRIPTION_COL };
+ DBHelper.SECCATEGORY_COL, DBHelper.DESCRIPTION_COL , DBHelper.CONCERN_PRODUCTIMAGE};
private static final String[] COUNT_COLUMN = { "COUNT(1)" };
@@ -110,6 +110,7 @@ public boolean hasConcernItems() {
String barcode = cursor.getString(10);
String category = cursor.getString(11);
String description = cursor.getString(12);
+ byte[] data = cursor.getBlob(13);
// 添加时间标签的代码段
// 用来根据刷卡的日期进行日期归类
scanDate = new Date(timestamp);
@@ -122,7 +123,7 @@ public boolean hasConcernItems() {
// 这里还需要补充ConcernItem对象的具体属性才能确定
items.add(new ConcernItem(id, pid, name, type, category, price,
rating, brand, location, barcode, description,
- timestamp, iscollected));
+ timestamp, iscollected, data));
}
return items;
} catch (ParseException e) {
@@ -164,6 +165,7 @@ public boolean hasConcernItems() {
String barcode = cursor.getString(10);
String category = cursor.getString(11);
String description = cursor.getString(12);
+ byte[] data = cursor.getBlob(13);
// 添加时间标签的代码段
// 用来根据刷卡的日期进行日期归类
scanDate = new Date(timestamp);
@@ -173,9 +175,9 @@ public boolean hasConcernItems() {
Date tag = formater.parse(date);
items.add(new ConcernItem(tag.getTime()));
}
- items.add(new ConcernItem(id, pid, name, type, category, price,
+ items.add(new ConcernItem(id, pid, name, type, category, price,
rating, brand, location, barcode, description,
- timestamp, iscollected));
+ timestamp, iscollected, data));
}
return items;
} catch (ParseException e) {
@@ -211,10 +213,11 @@ public ConcernItem buildConcernItem(int number) {
String barcode = cursor.getString(10);
String category = cursor.getString(11);
String description = cursor.getString(12);
+ byte[] data = cursor.getBlob(13);
// 这里还需要补充ConcernItem对象的具体属性才能确定
return new ConcernItem(id, pid, name, type, category, price,
rating, brand, location, barcode, description, timestamp,
- iscollected);
+ iscollected, data);
} finally {
close(cursor, db);
}
@@ -253,10 +256,11 @@ public ConcernItem buildConcernItemById(int id) {
String barcode = cursor.getString(10);
String category = cursor.getString(11);
String description = cursor.getString(12);
+ byte[] data = cursor.getBlob(13);
// 这里还需要补充ConcernItem对象的具体属性才能确定
return new ConcernItem(id, pid, name, type, category, price,
rating, brand, location, barcode, description, timestamp,
- iscollected);
+ iscollected, data);
} finally {
close(cursor, db);
}
@@ -364,7 +368,7 @@ public void addConcernItem(ConcernItem item) {
values.put(DBHelper.ISCOLLECTED_COL, item.getIsCollected());
values.put(DBHelper.SECCATEGORY_COL, item.getSecCategory());
values.put(DBHelper.DESCRIPTION_COL, item.getDescription());
-
+ values.put(DBHelper.CONCERN_PRODUCTIMAGE, item.getIcon());
try {
db = helper.getWritableDatabase();
cursor = db.query(DBHelper.CONCERN_TABLE_NAME,
View
3  mobile phone client/NFCShopping/src/scut/bgooo/db/DBHelper.java
@@ -38,6 +38,7 @@
public static final String END_TIMESTAMP_COL = "endtimestamp";
public static final String TIMESTAMP_COL = "timestamp";
public static final String ISCOLLECTED_COL = "collected";
+ public static final String CONCERN_PRODUCTIMAGE = "icon";
public DBHelper(Context context, String name, CursorFactory factory,
int version) {
@@ -65,7 +66,7 @@ public void onCreate(SQLiteDatabase db) {
+ " REAL, " + RATING_COL + " REAL, " + BRAND_COL + " varchar, "
+ LOCATION_COL + " varchar, " + BARCODE_COL + " varchar, "
+ DESCRIPTION_COL + " varchar, " + TIMESTAMP_COL + " INTEGER, "
- + ISCOLLECTED_COL + " INTEGER);");
+ + ISCOLLECTED_COL + " INTEGER," + CONCERN_PRODUCTIMAGE + " blob);");
Log.e("Database", "onCreate");
}
View
1  mobile phone client/NFCShopping/src/scut/bgooo/ui/CollectionListActivity.java
@@ -178,6 +178,7 @@ public void onItemClick(AdapterView<?> arg0, View arg1, int position,
CommentListActivity.class);
intent.putExtra("mItem", mItems.get(position));
startActivity(intent);
+
}
};
View
2  mobile phone client/NFCShopping/src/scut/bgooo/ui/CommentListActivity.java
@@ -357,4 +357,4 @@ public View getView(int position, View convertView, ViewGroup parent) {
private ViewHolder vh = new ViewHolder();
-}
+}
View
33 mobile phone client/NFCShopping/src/scut/bgooo/ui/DiscountItemListActivity.java
@@ -15,6 +15,7 @@
import android.app.Activity;
import android.content.Context;
+import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
@@ -22,6 +23,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
+import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
@@ -30,7 +32,6 @@
private ArrayList<HashMap<String, Object>> mTempitems = null;
private ListView mListView;
-
private View mProgress;
@Override
@@ -44,8 +45,8 @@ protected void onCreate(Bundle savedInstanceState) {
HashMap<String, Integer> map = new HashMap<String, Integer>();
map.put("ID", id);
Task task = new Task(Task.GET_DISCOUNTITEM, map);
- TaskHandler.allActivity.put(
- DiscountItemListActivity.class.getSimpleName(), this);
+ TaskHandler.allActivity.put(DiscountItemListActivity.class
+ .getSimpleName(), this);
TaskHandler.addTask(task);
mListView = (ListView) findViewById(R.id.privilege_listview);
@@ -62,16 +63,17 @@ public void init() {
public void refresh(Object... param) {
// TODO Auto-generated method stub
String result = (String) param[0];
- if (result.equals("OK")) {
- Vector<DiscountItem> discountitem = (Vector<DiscountItem>) param[1];
+ if (result.equals("OK")) {
+ Vector<DiscountItem> discountitem = (Vector<DiscountItem>) param[1];
if (discountitem != null) {
- PrivilegeAdapter ma = new PrivilegeAdapter(this, discountitem);
+ PrivilegeAdapter ma = new PrivilegeAdapter(this, discountitem);
mListView.setAdapter(ma);
}
mProgress.setVisibility(View.GONE);
+ } else if (result.equals("IMAGE")) {
+ ((PrivilegeAdapter) mListView.getAdapter()).notifyDataSetChanged();
}
}
-
}
class PrivilegeAdapter extends BaseAdapter {
@@ -139,6 +141,8 @@ public View getView(int position, View convertView, ViewGroup parent) {
.findViewById(R.id.tvDiscount);
vh.tvDuration = (TextView) privilegeitem
.findViewById(R.id.tvDuration);
+ vh.ProductImage = (ImageView) privilegeitem
+ .findViewById(R.id.ivProductImage);
double cost = Double.valueOf(((Product) items.get(position)
.getProperty(8)).getProperty(5).toString())
@@ -159,16 +163,23 @@ public View getView(int position, View convertView, ViewGroup parent) {
+ "结束:" + items.get(position).getProperty(7).toString();
vh.tvDuration.setText(duration);
+ Product product = ((Product) items.get(position).getProperty(8));
+ int productID = Integer.valueOf(product.getProperty(1).toString());
+ if (TaskHandler.allIcon.get(productID) != null) {
+ Bitmap bitmap = TaskHandler.allIcon.get(productID);
+ vh.ProductImage.setImageBitmap(bitmap);
+ }
return privilegeitem;
}
}
private static class ViewHolder {
- TextView tvProductName;
- TextView tvPrivilegeCost;
- TextView tvDiscount;
- TextView tvDuration;
+ TextView tvProductName;// 商品名
+ TextView tvPrivilegeCost;//
+ TextView tvDiscount;// 优惠力度
+ TextView tvDuration;// 周期
+ ImageView ProductImage;
}
private ViewHolder vh = new ViewHolder();
View
110 mobile phone client/NFCShopping/src/scut/bgooo/ui/ProductActivity.java
@@ -1,14 +1,22 @@
package scut.bgooo.ui;
-
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.Random;
import scut.bgooo.concern.ConcernItem;
import scut.bgooo.concern.ConcernManager;
import scut.bgooo.entities.Product;
import scut.bgooo.entities.SecCategory;
+import scut.bgooo.utility.Task;
import scut.bgooo.webservice.WebServiceUtil;
import android.app.Activity;
import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
import android.nfc.NfcAdapter;
import android.os.Bundle;
@@ -28,11 +36,13 @@
protected static final int SUCCESS = 0;
protected static final int FAILE = 1;
protected static final int REFRESHRATING = 2;
+ protected static final int GET_PRODUCTIMAGE = 3;
private float mRating;
private ConcernManager mConcernManager = null;
private String mBarcodeStr = "";
+ private byte[] mdata = null;
private ConcernItem mItem;
private Product mProduct;
@@ -65,7 +75,7 @@ protected void onCreate(Bundle savedInstanceState) {
mDescription = (TextView) findViewById(R.id.tvDescription);
mBarcode = (TextView) findViewById(R.id.tvBarcode);
mCategory = (TextView) findViewById(R.id.tvType);
-
+ mPicture = (ImageView) findViewById(R.id.ivPicture);
btCheckComment = (Button) findViewById(R.id.btCheckComment);
btAddToCompare = (Button) findViewById(R.id.btAddToCompare);
@@ -107,6 +117,8 @@ void resolveIntent(Intent intent) {
}
private void DownloadInfo() {
+
+
Thread thread = new Thread(new Runnable() {
@Override
@@ -122,6 +134,7 @@ public void run() {
message.obj = mProduct;
DownloadRating(Integer.valueOf(mProduct.getProperty(1)
.toString()));
+ DownloadPicture();
}
handler.sendMessage(message);
}
@@ -149,6 +162,32 @@ public void run() {
thread = null;
}
+ private void DownloadPicture() {
+ Thread thread = new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+ // TODO Auto-generated method stub
+ try {
+ //int id = Integer.valueOf(mProduct.getProperty(1).toString());
+ String URL = WebServiceUtil.ImageURL + mProduct.getProperty(8).toString();
+ URL url;
+ url = new URL(URL);
+ Bitmap bitmap = getProductImage(url);
+ Message msg = new Message();
+ msg.arg1 = GET_PRODUCTIMAGE;
+ msg.obj = bitmap;
+ handler.sendMessage(msg);
+ } catch (MalformedURLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ });
+ thread.start();
+ thread = null;
+ }
+
final Handler handler = new Handler() {
@Override
@@ -174,22 +213,65 @@ public void handleMessage(Message msg) {
btCheckComment.setClickable(false);
mProcess.setVisibility(View.GONE);
break;
- case REFRESHRATING:
- mItem = new ConcernItem(0, Integer.valueOf(mProduct
- .getProperty(1).toString()), mProduct.getProperty(4)
- .toString(), Integer.valueOf(mProduct.getProperty(2)
- .toString()), ((SecCategory) mProduct.getProperty(10))
- .getProperty(3).toString(), Float.valueOf(mProduct
- .getProperty(5).toString()), mRating, mProduct
- .getProperty(6).toString(), mProduct.getProperty(7)
- .toString(), mProduct.getProperty(3).toString(),
- mProduct.getProperty(9).toString(),
- System.currentTimeMillis(), (short) 0);
- mConcernManager.addConcernItem(mItem);
+ case REFRESHRATING:
btCheckComment.setClickable(true);
break;
+ case GET_PRODUCTIMAGE: {
+ if (msg.obj != null) {
+ mItem = new ConcernItem(0, Integer.valueOf(mProduct
+ .getProperty(1).toString()), mProduct.getProperty(4)
+ .toString(), Integer.valueOf(mProduct.getProperty(2)
+ .toString()), ((SecCategory) mProduct.getProperty(10))
+ .getProperty(3).toString(), Float.valueOf(mProduct
+ .getProperty(5).toString()), mRating, mProduct
+ .getProperty(6).toString(), mProduct.getProperty(7)
+ .toString(), mProduct.getProperty(3).toString(),
+ mProduct.getProperty(9).toString(),
+ System.currentTimeMillis(), (short) 0, mdata);
+ mConcernManager.addConcernItem(mItem);
+ mPicture.setImageBitmap((Bitmap)msg.obj);
+ }
+ }break;
}
}
};
+
+ public Bitmap getProductImage(URL Url) {
+ Bitmap bitmap = null;
+ try {
+ URL url = Url;
+ HttpURLConnection conn;
+ conn = (HttpURLConnection) url.openConnection();
+ conn.setRequestMethod("GET");
+ conn.setReadTimeout(1000);
+ InputStream inputstream = conn.getInputStream();
+ mdata = readInputStream(inputstream);
+ bitmap = BitmapFactory.decodeByteArray(mdata, 0, mdata.length);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return bitmap;
+ }
+
+ public byte[] readInputStream(InputStream inStream) throws Exception {
+ // 构造一个ByteArrayOutputStream
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ // 设置一个缓冲区
+ byte[] buffer = new byte[1024];
+ int len = 0;
+ // 判断输入流长度是否等于-1,即非空
+ while ((len = inStream.read(buffer)) != -1) {
+ // 把缓冲区的内容写入到输出流中,从0开始读取,长度为len
+ outStream.write(buffer, 0, len);
+ }
+ // 关闭输入流
+ inStream.close();
+ return outStream.toByteArray();
+ }
}
View
1  mobile phone client/NFCShopping/src/scut/bgooo/utility/Task.java
@@ -10,6 +10,7 @@
public static final int SEND_COMMENT_WEIBO = 2;//完成评论后,发送评论信息
public static final int GET_DISCOUNT = 3;//获得商品优惠列表
public static final int GET_DISCOUNTITEM = 4;//获得具体某期的商品优惠条目
+ public static final int GET_PRODUCTIMAGE = 5;//在获得优惠列表的时候,获得商品的图片
public Task(int id, Map param) {
mTaskId = id;
View
68 mobile phone client/NFCShopping/src/scut/bgooo/utility/TaskHandler.java
@@ -4,6 +4,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
@@ -13,6 +15,7 @@
import scut.bgooo.entities.Discount;
import scut.bgooo.entities.DiscountItem;
+import scut.bgooo.entities.Product;
import scut.bgooo.ui.CommentActivity;
import scut.bgooo.ui.DiscountItemListActivity;
import scut.bgooo.ui.DiscountListActivity;
@@ -24,6 +27,9 @@
import weibo4android.Weibo;
import weibo4android.WeiboException;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
@@ -33,6 +39,7 @@
private boolean isrun = true;
private static List<Task> mTaskList = new ArrayList<Task>();// 任务列表
public static HashMap<String, INFCActivity> allActivity = new HashMap<String, INFCActivity>();
+ public static HashMap<Integer, Bitmap> allIcon = new HashMap<Integer, Bitmap>();
public Weibo mWeibo = null;
@Override
@@ -106,9 +113,9 @@ private void doTask(Task task) {
try {
Weibo weibo = new Weibo();
Map<String, String> m = task.getTaskParam();
- weibo.setToken(
- WeiboUserListActivity.defaultUserInfo.GetAToken(),
- WeiboUserListActivity.defaultUserInfo.GetASecret());
+ weibo.setToken(WeiboUserListActivity.defaultUserInfo
+ .GetAToken(), WeiboUserListActivity.defaultUserInfo
+ .GetASecret());
String commit = m.get("COMMIT");
weibo.updateStatus(commit);
@@ -136,12 +143,38 @@ private void doTask(Task task) {
int id = Integer.valueOf(task.getTaskParam().get("ID").toString());
Vector<DiscountItem> discountitem = WebServiceUtil.getInstance()
.getDiscountItems(id);
+ for (int i = 0; i < discountitem.size(); i++) {
+ Product product = ((Product) discountitem.get(i).getProperty(8));
+ HashMap<Integer, Object> map = new HashMap<Integer, Object>();
+ map.put(0, product);
+ Task new_task = new Task(Task.GET_PRODUCTIMAGE, map);
+ TaskHandler.addTask(new_task);
+ }
Message msg = new Message();
msg.what = Task.GET_DISCOUNTITEM;
msg.obj = discountitem;
mHandle.sendMessage(msg);
}
break;
+ case Task.GET_PRODUCTIMAGE: {
+ try {
+ Product product = (Product) task.getTaskParam().get(0);
+ int id = Integer.valueOf(product.getProperty(1).toString());
+ String URL = WebServiceUtil.ImageURL + product.getProperty(8).toString();
+ URL url;
+ url = new URL(URL);
+ Bitmap bitmap = getProductImage(url);
+ allIcon.put(id, bitmap);
+ Message msg = new Message();
+ msg.what = Task.GET_PRODUCTIMAGE;
+ mHandle.sendMessage(msg);
+ } catch (MalformedURLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+ break;
default: {
}
@@ -183,6 +216,12 @@ public void handleMessage(Message msg) {
iwa.refresh("OK", msg.obj);
}
break;
+ case Task.GET_PRODUCTIMAGE: {
+ INFCActivity iwa = allActivity
+ .get(DiscountItemListActivity.class.getSimpleName());
+ iwa.refresh("IMAGE", msg.obj);
+ }
+ break;
default: {
}
@@ -206,4 +245,27 @@ public void handleMessage(Message msg) {
inStream.close();
return outStream.toByteArray();
}
+
+ public Bitmap getProductImage(URL Url) {
+ Bitmap bitmap = null;
+ try {
+ URL url = Url;
+ HttpURLConnection conn;
+ conn = (HttpURLConnection) url.openConnection();
+ conn.setRequestMethod("GET");
+ conn.setReadTimeout(1000);
+ InputStream inputstream = conn.getInputStream();
+ byte[] data = readInputStream(inputstream);
+ bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return bitmap;
+ }
+
}
View
1  mobile phone client/NFCShopping/src/scut/bgooo/webservice/WebServiceUtil.java
@@ -28,6 +28,7 @@
private static final String NAMESPACE = "http://tempuri.org/";
private static String URL = "http://192.168.1.103:8080/NFCShopping/ShopWebService.asmx";
+ public static String ImageURL = "http://192.168.1.103:8080/NFCShopping/Images/Products/";
private static final String REGIST = "Regist";
Something went wrong with that request. Please try again.