@Override protected List<DateIndexedEntity> getDataListFromLocal(String searchWord, String limitSql) { String where = COL_NAME_SHOP_ID + "=?"; List<String> argList = new ArrayList<String>(); argList.add(shopId); if (searchWord != null && searchWord.trim().length() > 0) { where += " and content like ? "; argList.add("%" + searchWord + "%"); } String[] whereArgs = argList.toArray(new String[argList.size()]); List<DateIndexedEntity> result = saleData.getSaleCountByPublishDate(where, whereArgs, limitSql); for (DateIndexedEntity entity : result) { String publishDate = DateUtils.getDateString_yyyyMMdd(entity.getDate()); entity.setSubItemList(saleData.getSaleListByPublishDate(where, whereArgs, publishDate)); } return result; }
private static void updateShareDetailView( final ShareEntity share, final Activity activity, View shareView) { if (share == null) { return; } UserEntity publisher = share.getPublisher(); UserClickListener userClickListener = new UserClickListener(publisher, activity, -1); // 设置分享者的头像 ImageView userImg = (ImageView) shareView.findViewById(R.id.user_img); userImg.setScaleType(ImageView.ScaleType.CENTER_CROP); userImg.setLayoutParams( new LinearLayout.LayoutParams(PUBLISHER_IMAGE_WIDTH, PUBLISHER_IMAGE_WIDTH)); String userPhoto = publisher.getPhoto(); if (userPhoto != null && userPhoto.length() > 0) { ImageLoader.getInstance().displayImage(userPhoto, userImg, true); } else { userImg.setImageResource(R.drawable.default_user_photo); } userImg.setOnClickListener(userClickListener); // 设置朋友的点击监听 TextView userView = (TextView) shareView.findViewById(R.id.user_name); userView.getPaint().setFakeBoldText(true); // TODO:使用样式表来处理 userView.setOnClickListener(userClickListener); userView.setText(publisher.getName()); // 设置内容 TextView contentView = (TextView) shareView.findViewById(R.id.share_content); contentView.setText(share.getContent()); // 设置时间 long publishTime = share.getPublishTime(); TextView publishTimeView = (TextView) shareView.findViewById(R.id.share_publish_time); publishTimeView.setText(DateUtils.formatTime_MMdd(publishTime)); // 设置上传的图片 List<FileEntity> images = share.getImages(); GridView picContainer = (GridView) shareView.findViewById(R.id.share_pic_container); // 设置GridView的列数 DisplayMetrics displayMetrics = activity.getResources().getDisplayMetrics(); int colNumber = displayMetrics.widthPixels / (ShareImageAdapter.IMAGE_VIEW_WIDTH + 25); picContainer.setNumColumns(colNumber); picContainer.setAdapter(new ShareImageAdapter(activity, images)); // 设置商铺及距离信息 final ShopEntity shop = share.getShop(); if (shop != null) { TextView shareShopView = (TextView) shareView.findViewById(R.id.share_shop_name); shareShopView.getPaint().setFakeBoldText(true); shareShopView.setText(shop.getName()); shareShopView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(activity, ShopBaseInfoActivity.class); intent.putExtra(ShopConst.COL_NAME_UUID, shop.getUuid()); activity.startActivity(intent); } }); LocationEntity shopLoc = shop.getLocation(); LocationEntity userLoc = RunEnv.getInstance().getLocationEntity(); if (shopLoc != null && userLoc != null) { TextView distView = (TextView) shareView.findViewById(R.id.share_shop_distance); distView.setText( new DecimalFormat("###,###.## 米").format(LocationUtils.distance(shopLoc, userLoc))); } } else { shareView.findViewById(R.id.row_share_shop).setVisibility(View.GONE); } }