示例#1
0
 /** 获取应用下载数据 */
 private void getAppDownLoad() {
   if (mKXApplication.mMyRecommendAppDownLoadResults.isEmpty()) {
     InputStream inputStream;
     try {
       inputStream = mContext.getAssets().open("data/recommend_appdownload.KX");
       String json = new TextUtil(mKXApplication).readTextFile(inputStream);
       JSONArray array = new JSONArray(json);
       RecommendResult result = null;
       for (int i = 0; i < array.length(); i++) {
         result = new RecommendResult();
         result.setName(array.getJSONObject(i).getString("name"));
         result.setIcon(array.getJSONObject(i).getString("icon"));
         result.setDescription(array.getJSONObject(i).getString("description"));
         mKXApplication.mMyRecommendAppDownLoadResults.add(result);
       }
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 }
示例#2
0
 public View getView(int position, View convertView, ViewGroup parent) {
   ViewHolder holder = null;
   if (convertView == null) {
     convertView = LayoutInflater.from(mContext).inflate(R.layout.recommend_item, null);
     holder = new ViewHolder();
     holder.title = (TextView) convertView.findViewById(R.id.recommend_item_title);
     holder.title_line = (ImageView) convertView.findViewById(R.id.recommend_item_title_line);
     holder.icon = (ImageView) convertView.findViewById(R.id.recommend_item_icon);
     holder.name = (TextView) convertView.findViewById(R.id.recommend_item_name);
     holder.description = (TextView) convertView.findViewById(R.id.recommend_item_description);
     convertView.setTag(holder);
   } else {
     holder = (ViewHolder) convertView.getTag();
   }
   RecommendResult result = mResults.get(position);
   if (mIsOfficial) {
     holder.description.setVisibility(View.GONE);
     if (result.isTitle()) {
       holder.title.setVisibility(View.VISIBLE);
       holder.title_line.setVisibility(View.VISIBLE);
       holder.title.setText(result.getTitleName());
     } else {
       holder.title.setVisibility(View.GONE);
       holder.title_line.setVisibility(View.GONE);
     }
   } else {
     holder.description.setVisibility(View.VISIBLE);
     holder.title.setVisibility(View.GONE);
     holder.title_line.setVisibility(View.GONE);
     holder.description.setText(result.getDescription());
   }
   holder.icon.setImageBitmap(mKXApplication.getRecommend(result.getIcon()));
   holder.name.setText(result.getName());
   return convertView;
 }