private void initBarbers() { // 设置没有barber时的文字 // if(barbers.size() == 0){ // none_barber.setVisibility(VISIBLE); // }else{ // none_barber.setVisibility(GONE); // } if (barbers.size() == 0) { barber1.setImageDrawable(null); barber2.setImageDrawable(null); barber3.setImageDrawable(null); baber1_txt.setVisibility(INVISIBLE); baber2_txt.setVisibility(INVISIBLE); baber3_txt.setVisibility(INVISIBLE); } else if (barbers.size() == 1) { try { imageFetcher.loadFormCache(barbers.get(0).getPhoto(), barber1); baber1_txt.setVisibility(VISIBLE); baber1_txt.setText(SalonTools.getName(barbers.get(0))); barber2.setImageDrawable(null); barber3.setImageDrawable(null); baber2_txt.setVisibility(INVISIBLE); baber3_txt.setVisibility(INVISIBLE); } catch (Exception e) { e.printStackTrace(); } } else if (barbers.size() == 2) { try { imageFetcher.loadFormCache(barbers.get(0).getPhoto(), barber1); baber1_txt.setVisibility(VISIBLE); baber1_txt.setText(SalonTools.getName(barbers.get(0))); imageFetcher.loadFormCache(barbers.get(1).getPhoto(), barber2); baber2_txt.setVisibility(VISIBLE); baber2_txt.setText(SalonTools.getName(barbers.get(1))); barber3.setImageDrawable(null); baber3_txt.setVisibility(INVISIBLE); } catch (Exception e) { e.printStackTrace(); } } else if (barbers.size() == 3) { try { imageFetcher.loadFormCache(barbers.get(0).getPhoto(), barber1); baber1_txt.setVisibility(VISIBLE); baber1_txt.setText(SalonTools.getName(barbers.get(0))); imageFetcher.loadFormCache(barbers.get(1).getPhoto(), barber2); baber2_txt.setVisibility(VISIBLE); baber2_txt.setText(SalonTools.getName(barbers.get(1))); imageFetcher.loadFormCache(barbers.get(2).getPhoto(), barber3); baber3_txt.setVisibility(VISIBLE); baber3_txt.setText(SalonTools.getName(barbers.get(2))); } catch (Exception e) { e.printStackTrace(); } } }
private void initSalons() { // 设置没有salon时的文字 // if(salons.size() == 0){ // none_salon.setVisibility(VISIBLE); // }else{ // none_salon.setVisibility(GONE); // } if (salons.size() == 0) { salon1.setImageDrawable(null); salon2.setImageDrawable(null); salon1_txt.setVisibility(INVISIBLE); salon2_txt.setVisibility(INVISIBLE); } else if (salons.size() == 1) { try { imageFetcher.loadFormCache(salons.get(0).getPhotos().get(0), salon1); salon2.setImageDrawable(null); salon1_txt.setVisibility(VISIBLE); salon2_txt.setVisibility(INVISIBLE); salon1_txt.setText(salons.get(0).getNick()); } catch (Exception e) { e.printStackTrace(); } } else if (salons.size() == 2) { try { imageFetcher.loadFormCache(salons.get(0).getPhotos().get(0), salon1); imageFetcher.loadFormCache(salons.get(1).getPhotos().get(0), salon2); salon1_txt.setVisibility(VISIBLE); salon2_txt.setVisibility(VISIBLE); salon1_txt.setText(salons.get(0).getNick()); salon2_txt.setText(salons.get(1).getNick()); } catch (Exception e) { e.printStackTrace(); } } }
private void initAdViewPager() { ArrayList<String> photos = banners.get(0).getPhotos(); if (photos.size() == 0) { none_ad.setVisibility(VISIBLE); return; } none_ad.setVisibility(GONE); advPics.clear(); for (int i = 0; i < photos.size(); i++) { ImageView img = new ImageView(mContext); img.setBackgroundColor(backcolor); advPics.add(img); try { imageFetcher.loadFormCache(photos.get(i), advPics.get(i)); } catch (Exception e) { e.printStackTrace(); } } // 对imageviews进行填充 imageViewsAd = new ImageView[advPics.size()]; // 小图标 for (int i = 0; i < advPics.size(); i++) { imageView = new ImageView(mContext); imageView.setLayoutParams(new LayoutParams(20, 20)); imageView.setPadding(5, 5, 5, 5); imageViewsAd[i] = imageView; if (i == 0) { imageViewsAd[i].setBackgroundResource(Indicator_select); } else { imageViewsAd[i].setBackgroundResource(Indicator_unselect); } ad_indicators.addView(imageViewsAd[i]); } ad_pager.setAdapter(new AdvAdapter(advPics)); ad_pager.setOnPageChangeListener(new GuidePageChangeListenerAd()); ad_pager.setOnTouchListener( new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_MOVE: isContinueAd = false; break; case MotionEvent.ACTION_UP: isContinueAd = true; break; default: isContinueAd = true; break; } return false; } }); new Thread( new Runnable() { @Override public void run() { while (true) { if (isContinueAd) { viewHandlerAd.sendEmptyMessage(whatAd.get()); whatOptionAd(); } } } }) .start(); }
private void initMallViewPager() { ArrayList<String> photos = banners.get(1).getPhotos(); if (photos.size() == 0) { none_mall.setVisibility(VISIBLE); return; } none_mall.setVisibility(GONE); mallPics.clear(); for (int i = 0; i < photos.size(); i++) { ImageView img = new ImageView(mContext); img.setBackgroundColor(backcolor); mallPics.add(img); try { imageFetcher.loadFormCache(photos.get(i), mallPics.get(i)); } catch (Exception e) { e.printStackTrace(); } } for (int i = 0; i < mallPics.size(); i++) { mallPics .get(i) .setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { final Uri uri = Uri.parse(MALL_WEB); final Intent it = new Intent(Intent.ACTION_VIEW, uri); mContext.startActivity(it); } }); } imageViewsMall = new ImageView[mallPics.size()]; // 小图标 for (int i = 0; i < mallPics.size(); i++) { imageView = new ImageView(mContext); imageView.setLayoutParams(new LayoutParams(20, 20)); imageView.setPadding(5, 5, 5, 5); imageViewsMall[i] = imageView; if (i == 0) { imageViewsMall[i].setBackgroundResource(Indicator_select); } else { imageViewsMall[i].setBackgroundResource(Indicator_unselect); } mall_indicators.addView(imageViewsMall[i]); } mall_pager.setAdapter(new AdvAdapter(mallPics)); mall_pager.setOnPageChangeListener(new GuidePageChangeListenerMall()); mall_pager.setOnTouchListener( new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_MOVE: isContinueMall = false; break; case MotionEvent.ACTION_UP: isContinueMall = true; break; default: isContinueMall = true; break; } return false; } }); new Thread( new Runnable() { @Override public void run() { while (true) { if (isContinueMall) { viewHandlerMall.sendEmptyMessage(whatMall.get()); whatOptionMall(); } } } }) .start(); }