Пример #1
0
    @Override
    public View getView(int position, View view, ViewGroup parent) {
      // TODO Auto-generated method stub
      if (view == null) {
        view =
            LayoutInflater.from(getApplicationContext()).inflate(R.layout.large_item_layout, null);
        holder = new Holder();

        holder.code = (TextView) view.findViewById(R.id.large_item_layout_product_code);
        holder.title = (TextView) view.findViewById(R.id.large_text_item);
        holder.quantity = (TextView) view.findViewById(R.id.large_text_quantity);
        holder.price = (TextView) view.findViewById(R.id.large_text_price);
        view.setTag(holder);
      } else {
        holder = (Holder) view.getTag();
      }

      //
      ArrayList<Product> list = basket.getList();

      Product p = list.get(position);
      String product_name = p.getName();
      String product_code = p.getProduct_Code();
      int product_quantity = basket.getMapQuan().get(p);
      int product_price = basket.getMapPrice().get(p);
      holder.code.setText(" <" + product_code + "> ");
      holder.title.setText(product_name);
      holder.quantity.setText(product_quantity + " item(s)");
      holder.price.setText(product_price + "");
      return view;
    }
Пример #2
0
  public Holder doParse(String html, String url) {
    Holder holder = new Holder();
    holder.url = url;

    Document doc = Jsoup.parse(html, url);
    Elements typeElement =
        doc.select("body > div.main_w.clearfix > div.main.clearfix > ul > li:nth-child(5) > a");
    holder.dishType = typeElement.text();

    Elements titleElement =
        doc.select(
            "body > div.main_w.clearfix > div.main.clearfix > div.cp_header.clearfix > div.cp_main_info_w > div.info1 > h1 > a");

    holder.title = titleElement.text();

    Elements methodElement =
        doc.select(
            "body > div.main_w.clearfix > div.main.clearfix > div.cp_header.clearfix > div.cp_main_info_w > div.info2 > ul > li:nth-child(1) > a");
    holder.method = methodElement.text();

    Elements materialElement =
        doc.select(
            "body > div.main_w.clearfix > div.main.clearfix > div.cp_body.clearfix > div.cp_body_left > div.materials > div > div.yl.zl.clearfix > ul > li > div > h4 > a");

    holder.mainMaterial = materialElement.text();

    Elements stepE =
        doc.select(
            "body > div.main_w.clearfix > div.main.clearfix > div.cp_body.clearfix > div.cp_body_left > div.measure > div.editnew.edit > div.content.clearfix");
    //
    // body > div.main_w.clearfix > div.main.clearfix > div.cp_body.clearfix
    // > div.cp_body_left > div.measure > div.editnew.edit >
    // div.content.clearfix
    // body > div.main_w.clearfix > div.main.clearfix > div.cp_body.clearfix
    // > div.cp_body_left > div.measure > div.edit > p:nth-child(1) > em
    //

    if (stepE.size() == 0) {
      stepE =
          doc.select(
              "body > div.main_w.clearfix > div.main.clearfix > div.cp_body.clearfix > div.cp_body_left > div.measure > div.edit > p");
    }

    for (int i = 0; i < stepE.size(); i++) {
      Element e = stepE.get(i);

      if (e.children().hasClass("step")) {
        String step = e.text();
        if (!"".equals(step)) {
          holder.steps.add(step);
        }
      }
    }
    // body > div.main_w.clearfix > div.main.clearfix > div.cp_body.clearfix
    // > div.cp_body_left > div.measure > div.editnew.edit >
    // div:nth-child(1)

    return holder;
  }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    Holder holder;
    Downloader downloader = getItem(position);
    DownloadRequest request = downloader.getDownloadRequest();
    // Inflate layout
    if (convertView == null) {
      holder = new Holder();
      LayoutInflater inflater =
          (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      convertView = inflater.inflate(R.layout.downloadlist_item, parent, false);
      holder.title = (TextView) convertView.findViewById(R.id.txtvTitle);
      holder.downloaded = (TextView) convertView.findViewById(R.id.txtvDownloaded);
      holder.percent = (TextView) convertView.findViewById(R.id.txtvPercent);
      holder.progbar = (ProgressBar) convertView.findViewById(R.id.progProgress);
      holder.butSecondary = (ImageButton) convertView.findViewById(R.id.butSecondaryAction);

      convertView.setTag(holder);
    } else {
      holder = (Holder) convertView.getTag();
    }

    if (position == selectedItemIndex) {
      convertView.setBackgroundColor(
          ContextCompat.getColor(
              convertView.getContext(), ThemeUtils.getSelectionBackgroundColor()));
    } else {
      convertView.setBackgroundResource(0);
    }

    holder.title.setText(request.getTitle());

    holder.progbar.setIndeterminate(request.getSoFar() <= 0);

    String strDownloaded = Converter.byteToString(request.getSoFar());
    if (request.getSize() != DownloadStatus.SIZE_UNKNOWN) {
      strDownloaded += " / " + Converter.byteToString(request.getSize());
      holder.percent.setText(request.getProgressPercent() + "%");
      holder.progbar.setProgress(request.getProgressPercent());
      holder.percent.setVisibility(View.VISIBLE);
    } else {
      holder.progbar.setProgress(0);
      holder.percent.setVisibility(View.INVISIBLE);
    }

    holder.downloaded.setText(strDownloaded);

    holder.butSecondary.setFocusable(false);
    holder.butSecondary.setTag(downloader);
    holder.butSecondary.setOnClickListener(butSecondaryListener);

    return convertView;
  }
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
    Holder holder = null;
    if (convertView == null) {
      holder = new Holder();
      convertView = inflater.inflate(R.layout.good_report_item, null);
      holder.handImg = (ImageView) convertView.findViewById(R.id.iv_goodbg_hand);

      holder.title = (TextView) convertView.findViewById(R.id.tv_goodbg_title);
      holder.aName = (TextView) convertView.findViewById(R.id.tv_goodbg__aname);
      holder.price = (TextView) convertView.findViewById(R.id.tv_goodbg_price);
      holder.body = (TextView) convertView.findViewById(R.id.tv_goodbg_text);
      holder.download = (ImageButton) convertView.findViewById(R.id.ib_bg_download);
      convertView.setTag(holder);
    } else {
      holder = (Holder) convertView.getTag();
    }
    final Report report = data.get(position);
    holder.handImg.setTag(report.getPpath());
    // holder.handImg.setImageResource(Integer.parseInt(data.get(position).get("hand").toString()));
    holder.title.setText(report.getName());
    holder.aName.setText(report.getAuthor());
    holder.price.setText(report.getPrice());
    holder.body.setText(report.getIntro());
    ImageResourse imageResource = new ImageResourse();
    imageResource.setIconUrl(data.get(position).getPpath() + "/big.png");
    imageResource.setIconId(report.getId());
    imageResource.setIconTime(report.getProtime());
    asyncImageLoader.loadDrawable(
        imageResource,
        new ImageCallback() {

          @Override
          public void imageLoaded(Drawable imageDrawable, String imageUrl) {
            ImageView img = (ImageView) goodList.findViewWithTag(report.getPpath());
            if (img != null && imageDrawable != null) {
              // img.setLayoutParams(new Gallery.LayoutParams(360, 160));
              img.setScaleType(ImageView.ScaleType.FIT_CENTER);
              img.setImageDrawable(imageDrawable);
            }
          }
        });
    holder.download.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {}
        });
    return convertView;
  }
Пример #5
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      final Holder holder;
      final AppInfo item = getItem(position);
      View view;

      if (convertView == null) {
        holder = new Holder();
        view = mInflater.inflate(R.layout.whitelist_item, parent, false);
        holder.icon = (ImageView) view.findViewById(R.id.icon);
        holder.title = (TextView) view.findViewById(android.R.id.title);
        holder.summary = (TextView) view.findViewById(android.R.id.summary);
        holder.checkbox = (CheckBox) view.findViewById(R.id.checkbox);
        view.setTag(holder);
      } else {
        view = convertView;
        holder = (Holder) view.getTag();
      }

      holder.title.setText(item.title);
      holder.summary.setText(item.summary);
      holder.icon.setImageDrawable(item.icon);

      holder.checkbox.setChecked(item.enabled);
      holder.checkbox.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              item.enabled = holder.checkbox.isChecked();
              if (holder.checkbox.isChecked()) {
                mSettingsHelper.addListItem(item.summary);
              } else {
                mSettingsHelper.removeListItem(item.summary);
              }
            }
          });

      return view;
    }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    Holder holder;
    View view = convertView;

    if (view == null) {
      view = LayoutInflater.from(context).inflate(R.layout.grid_item, parent, false);
      holder = new Holder();
      holder.title = (TextView) view.findViewById(R.id.grid_item_title);
      holder.cover = (ImageView) view.findViewById(R.id.grid_item_cover);
      view.setTag(holder);
    } else {
      holder = (Holder) view.getTag();
    }

    GridItem item = list.get(position);
    holder.title.setText(item.getTitle());
    holder.cover.setImageBitmap(BrowserUnit.file2Bitmap(context, item.getFilename()));
    ViewUnit.setElevation(
        view, context.getResources().getDimensionPixelSize(R.dimen.elevation_1dp));

    return view;
  }
Пример #7
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    final Holder holder;
    if (convertView == null) {
      convertView = mInflater.inflate(resource, parent, false);
      holder = new Holder();
      holder.chkBox = (CheckBox) convertView.findViewById(R.id.checkbox);
      holder.img = (ImageView) convertView.findViewById(R.id.icon);
      holder.title = (TextView) convertView.findViewById(R.id.title);
      holder.subtitle = (TextView) convertView.findViewById(R.id.subtitle);
      convertView.setTag(holder);
    } else {
      holder = (Holder) convertView.getTag();
    }

    bindView(position, holder);

    convertView.setBackgroundColor(Color.TRANSPARENT);
    // when we scroll the gridview, we may creating the new item
    // in this case, we need to know the status of the checkbox

    return convertView;
  }
  public View getView(final int position, View convertView, ViewGroup parent) {
    final ProgressBar bar;
    final TextView tv;
    Holder holder = null;
    if (convertView == null) {
      holder = new Holder();
      convertView = inflater.inflate(R.layout.yjbg_book_shelf_item, null);
      holder.handImg = (ImageView) convertView.findViewById(R.id.yjbg_book_shelf_hand_img);

      holder.title = (TextView) convertView.findViewById(R.id.yjbg_book_shelf_title);
      holder.aName = (TextView) convertView.findViewById(R.id.yjbg_book_shelf_aname);
      holder.price = (TextView) convertView.findViewById(R.id.yjbg_book_shelf_price);
      holder.body = (TextView) convertView.findViewById(R.id.yjbg_book_shelf_text);
      convertView.setTag(holder);
    } else {
      holder = (Holder) convertView.getTag();
    }
    final Report report = data.get(position);
    holder.handImg.setTag(report.getPpath());
    holder.handImg.setImageResource(R.drawable.report1);
    holder.title.setText(report.getName());
    holder.aName.setText(report.getAuthor());
    holder.price.setText(report.getPrice());
    if (report.getIntro().length() > 100) {
      holder.body.setText(report.getIntro().replace("\n", "").subSequence(0, 100) + "...");
    } else {
      holder.body.setText(report.getIntro().replace("\n", ""));
    }

    ImageResourse imageResource = new ImageResourse();
    imageResource.setIconUrl(data.get(position).getSmallPpath().replace("/big.png", ""));
    imageResource.setIconId(data.get(position).getId());
    imageResource.setIconTime(data.get(position).getProtime());
    if (drawables.containsKey(report.getSmallPpath().replace("/big.png", ""))
        && drawables.get(report.getSmallPpath().replace("/big.png", "")) != null) {
      holder.handImg.setImageDrawable(
          drawables.get(report.getSmallPpath().replace("/big.png", "")));
      Log.i("view", position + "起作用了");
    } else {
      asyncImageLoader.loadDrawable(
          imageResource,
          new ImageCallback() {

            @Override
            public void imageLoaded(Drawable imageDrawable, String imageUrl) {
              ImageView img = (ImageView) listView.findViewWithTag(report.getPpath());
              if (img != null && imageDrawable != null) {
                // img.setLayoutParams(new Gallery.LayoutParams(360, 160));
                drawables.put(report.getSmallPpath().replace("/big.png", ""), imageDrawable);
                img.setScaleType(ImageView.ScaleType.FIT_CENTER);
                img.setImageDrawable(imageDrawable);
              }
            }
          });
    }
    tv = (TextView) convertView.findViewById(R.id.yjbg_book_list_item_tv);
    bar = (ProgressBar) convertView.findViewById(R.id.yjbg_book_list_item_pro);
    /*if (!report.getIsLoad().equals("yes")) {
    	tv.setVisibility(View.VISIBLE);
    	bar.setVisibility(View.VISIBLE);
    	Handler handler = new Handler() {

    		@Override
    		public void handleMessage(Message msg) {
    			bar.setProgress(msg.arg1);
    			tv.setText(msg.arg1 + "%");
    			if (msg.arg1 == 100) {
    				tv.setText("100%");
    				report.setIsLoad("yes");
    				dataHelper.UpdateReportZT(report);
    			}
    		}

    	};

    	String path = report.getDownpath().toString();
    	File savedir = new File(Report.SD_PATH+ report.getName());
    	// Environment.getExternalStorageDirectory().getAbsolutePath() + "/cei/bg/"
    	if (!savedir.exists()) {
    		savedir.mkdirs();
    	}

    	try {
    		NewFileDownload.download(path, savedir, handler);
    	} catch (Exception e) {
    		e.printStackTrace();
    	}
    }*/
    if (report.getIsLoad().equals("yes")) {
      tv.setText("100%");
    }
    return convertView;
  }