@Override
  public View getView(int i, View view, ViewGroup viewGroup) {
    View row = view;
    MessageRoomItemHolder holder = null;

    if (row == null) {
      LayoutInflater layoutInflater =
          (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      row = layoutInflater.inflate(R.layout.messages_room_item, viewGroup, false);
      holder = new MessageRoomItemHolder(row);
      row.setTag(holder);

    } else {
      holder = (MessageRoomItemHolder) row.getTag();
    }
    MessageRoomBean message_bean = listOfConversations.get(i);
    if (isCustomer) {
      loader.displayImage(listOfEventsImage.get(i), holder.customerOrEventImage);
    } else if (message_bean.getCustomerImageFacebookUrl() != null
        && !message_bean.getCustomerImageFacebookUrl().isEmpty()) {
      Picasso.with(context)
          .load(message_bean.getCustomerImageFacebookUrl())
          .into(holder.customerOrEventImage);
    } else if (message_bean.getCustomerImage() != null) {
      loader.displayImage(message_bean.getCustomerImage(), holder.customerOrEventImage);
    }
    holder.messageBody.setText(message_bean.getLastMessage());
    holder.customerOrEventName.setText(message_bean.getCustomer_id());
    holder.customerOrEventImage.setTag(message_bean);
    holder.customerOrEventName.setTag(message_bean);
    holder.messageBody.setTag(message_bean);

    return row;
  }
 /**
  * 给ImageView加载普通图片
  *
  * @param uri 图片资源所对应的URI
  * @param imageView 需要加载到的ImageView容器
  * @param options 自定义的Display
  * @param outsideLoadingListener 加载事件监听器
  * @param progressListener 进度监听器
  */
 private void loadImage(
     String uri,
     ImageView imageView,
     DisplayImageOptions options,
     ImageLoadingListener outsideLoadingListener,
     ImageLoadingProgressListener progressListener) {
   // use image cache
   String fileName = fileHandler.getFileNameInUrl(uri);
   String fullPath = mImageCacheDir + fileName;
   if (fileHandler.isFileExists(fullPath)) {
     imageLoader.displayImage(
         ImageLoaderHelper.URI_PREFIX_FILE + fullPath,
         imageView,
         options,
         outsideLoadingListener,
         progressListener);
   } else {
     imageLoader.displayImage(
         uri,
         imageView,
         options,
         new SaveCacheImageLoadingListener(fullPath, outsideLoadingListener),
         progressListener);
   }
 }
Exemple #3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_photo_lview);
    //		UtilMethod.showProgressDialog(PhotoLView.this);
    ImageLoader imageLoader = ImageLoader.getInstance();
    DisplayImageOptions options =
        new DisplayImageOptions.Builder()
            .showImageForEmptyUri(R.drawable.default_photo)
            .cacheInMemory(false)
            .cacheOnDisc(false)
            .bitmapConfig(Bitmap.Config.RGB_565)
            .build();
    path = getIntent().getStringExtra("photo_path");
    type = getIntent().getStringExtra("type");
    LinearLayout linearRight = (LinearLayout) findViewById(R.id.topbar_linear2);
    LinearLayout linearLeft = (LinearLayout) findViewById(R.id.topbar_linear1);
    if ("0".equals(type)) {
      linearRight.setVisibility(View.VISIBLE);
      linearRight.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View arg0) {
              // TODO Auto-generated method stub
              Intent data = new Intent();
              data.putExtra("sendImg", path);
              setResult(Activity.RESULT_OK, data);
              finish();
            }
          });
    } else {
      linearRight.setVisibility(View.INVISIBLE);
    }
    TextView tView = (TextView) findViewById(R.id.topbar_tv);
    tView.setText("个人图像");
    ImageView photo_img = (ImageView) findViewById(R.id.large_photo);
    linearLeft.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            finish();
          }
        });
    try {
      if ("0".equals(type)) {
        imageLoader.displayImage("file://" + path, photo_img, options);
      } else {
        imageLoader.displayImage(path, photo_img, options);
      }
      //			UtilMethod.dismissProgressDialog(PhotoLView.this);
    } catch (Exception e) {
      // TODO: handle exception
      Toast.makeText(PhotoLView.this, "文件没有找到", 2000).show();
    }
  }
  @Override
  protected void onActivityResult(int arg1, int arg0, Intent arg2) {
    super.onActivityResult(arg1, arg0, arg2);

    if (arg1 == REQUEST_CODE && arg0 == RESULT_OK) {
      if (mList != null) {
        mList.clear();
      }
      mImageUri = arg2.getData();
      if (mImageUri != null) {
        String path = getImagePath(mImageUri);
        mList.add(path);
        imageLoader.displayImage(
            mList.get(0).replace("/mnt", "file:/"), user_manager_user_head, options);
      }

    } else if (arg1 == REQUEST_CODE1 && arg0 == Activity.RESULT_OK) {
      if (mList != null) {
        mList.clear();
      }
      if (file != null && file.exists()) {
        mList.add(file.getPath());
        imageLoader.displayImage(
            mList.get(0).replace("/mnt", "file:/"), user_manager_user_head, options);
      }
    }

    if (arg0 == MyConstants.REQUEST_NICKNAME) {
      nicknameTextView.setText(arg2.getExtras().getString("nickname"));
    }
    if (arg0 == MyConstants.REQUEST_PASSWORD) {
      if (arg2.getExtras().getString("password") != null) {
        user_manager_alter_passwd_stub.setText(arg2.getExtras().getString("password"));
        pwchange = true;
      }
    }
    if (arg0 == MyConstants.REQUEST_NAME) {
      user_manager_tv_name.setText(arg2.getExtras().getString("name"));
    }
    if (arg0 == MyConstants.REQUEST_PHONENUB) {
      user_manager_tv_phonnumber.setText(arg2.getExtras().getString("phonenub"));
    }
    if (arg0 == MyConstants.REQUEST_EMAIL) {
      user_manager_tv_qq.setText(arg2.getExtras().getString("email"));
    }
    if (arg0 == MyConstants.REQUEST_ADDRESS) {
      user_manager_tv_address.setText(arg2.getExtras().getString("address"));
    }
    if (arg0 == MyConstants.REQUEST_NET) {
      user_manager_tv_net.setText(arg2.getExtras().getString("net"));
    }

    if (arg0 == MyConstants.REQUEST_COMPANY) {
      user_manager_tv_company.setText(arg2.getExtras().getString("company"));
    }
  }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {

    final ViewHolder holder;
    if (convertView == null) {

      convertView = infalter.inflate(R.layout.gallery_item, null);
      holder = new ViewHolder();
      holder.imgQueue = (ImageView) convertView.findViewById(R.id.imgQueue);
      convertView.setTag(holder);

    } else {
      holder = (ViewHolder) convertView.getTag();
    }
    holder.imgQueue.setTag(position);

    try {

      imageLoader.displayImage(
          "file://" + data.get(position).sdcardPath,
          holder.imgQueue,
          new SimpleImageLoadingListener() {
            @Override
            public void onLoadingStarted(String imageUri, View view) {
              holder.imgQueue.setImageResource(R.drawable.no_media);
              super.onLoadingStarted(imageUri, view);
            }
          });

    } catch (Exception e) {
      e.printStackTrace();
    }

    return convertView;
  }
  /**
   * 当界面每显示出来一个item时,就会调用该方法,getView()有三个参数,第一个参数表示该item在Adapter中的位置;
   * 第二个参数是item的View对象,是滑动list时将要显示在界面上的item,如果有item在显示界面消失,这时
   * android会将消失的item返回,称为旧view,也就是说此时的view不为null;第三个参数用在加载xml视图。
   */
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder viewHolder = new ViewHolder(); // 获得实例对象
    if (convertView == null) { // 当滑动list时,如果没有item消失(应该是没有任何操作,保存当前的实例),
      // 这时参数对象view是没有任何指向的,为null
      Log.d("convertView == null", "aa11");
      //                viewHolder = new ViewHolder();
      convertView = mInflater.inflate(R.layout.item_grid, null);
      viewHolder.image2 = (ImageView) convertView.findViewById(R.id.tou_ming_img);
      viewHolder.image2.setAlpha(100);
      viewHolder.Title = (TextView) convertView.findViewById(R.id.title);
      viewHolder.image = (ImageView) convertView.findViewById(R.id.iv_grid_image);
      convertView.setTag(viewHolder); // 向view中添加附加数据信息,在这里也就是两个ImageView和textview对象
    } else {
      Log.d("convertView != null", "bb11");
      // 如果有旧的view对象返回(该情况是滑动list时有item消失),从该view中提取已经创建的
      // 两个ImageView和textview对象,达到对象循环使用
      viewHolder = (ViewHolder) convertView.getTag();
    }
    viewHolder.Title.setText(allTypeDataTitle.get(position));
    Log.d("imageUrls.size()", "" + imageUrls.size());
    imageLoader.displayImage(imageUrls.get(position), viewHolder.image, options);

    return convertView;
  }
 @SuppressWarnings("unchecked")
 @Override
 public View getConvertView(Node node, int position, View convertView, ViewGroup parent) {
   ViewHolder viewHolder = null;
   if (convertView == null) {
     convertView = mInflater.inflate(R.layout.item_tree_list, parent, false);
     viewHolder = new ViewHolder();
     viewHolder.icon = (ImageView) convertView.findViewById(R.id.treenode_icon);
     viewHolder.label = (TextView) convertView.findViewById(R.id.treenode_label);
     viewHolder.user = (TextView) convertView.findViewById(R.id.treenode_user);
     viewHolder.head = (CircleImageView) convertView.findViewById(R.id.treenode_head);
     convertView.setTag(viewHolder);
   } else {
     viewHolder = (ViewHolder) convertView.getTag();
   }
   if (node.getIcon() == -1) {
     viewHolder.icon.setVisibility(View.INVISIBLE);
   } else {
     viewHolder.icon.setVisibility(View.VISIBLE);
     viewHolder.icon.setImageResource(node.getIcon());
   }
   viewHolder.label.setText(node.getName());
   ProjectVO vo = (ProjectVO) node.getData();
   viewHolder.user.setText(vo.getCREATE_USER_NAME());
   imageLoader.displayImage(
       String.format(URLConstants.URL_IMG, vo.getCREATE_USER_HEAD()), viewHolder.head, options);
   return convertView;
 }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder viewHolder;
    if (convertView == null) {
      convertView = LayoutInflater.from(mcontext).inflate(R.layout.item_horizaontal_index, null);
      viewHolder = new ViewHolder();
      viewHolder.imageView = (ImageView) convertView.findViewById(R.id.imageView_item_hor_index);
      viewHolder.textView = (TextView) convertView.findViewById(R.id.text_item_hor_index);
      convertView.setTag(viewHolder);
    } else {
      viewHolder = (ViewHolder) convertView.getTag();
    }
    IndexItemInfo investment = list.get(position);
    String imageUrl = Url.prePic + investment.getLogo();
    String name = investment.getCompany_name();

    //        Picasso.with(mcontext)
    //                .load(imageUrl)
    //                .into(viewHolder.imageView);
    imageLoader.displayImage(
        imageUrl, viewHolder.imageView, MyDisplayImageOptions.getdefaultImageOptions());
    //        viewHolder.imageView.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                Intent intent=new Intent(mcontext, CPDetailActivity.class);
    //                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    //                mcontext.startActivity(intent);
    //                Activity activity= (Activity) mcontext;
    //                activity.overridePendingTransition(R.anim.in_from_right,R.anim.out_to_left);
    //            }
    //        });
    viewHolder.textView.setText(name);
    return convertView;
  }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {

    final Image image = getItem(position);

    if (convertView == null) {
      convertView =
          LayoutInflater.from(getContext()).inflate(R.layout.gallery_image_layout, parent, false);
    }

    ImageLoader imageLoader = ImageLoader.getInstance();

    ImageView IVGalleryImage = (ImageView) convertView.findViewById(R.id.IVGalleryImage);
    imageLoader.displayImage(image.getThumbURL(), IVGalleryImage);

    IVGalleryImage.setClickable(true);
    IVGalleryImage.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            State.setImage(image);
            Intent intent = new Intent(context, ImageActivity.class);
            context.startActivity(intent);
          }
        });

    return convertView;
  }
 /**
  * Adds display image task to execution pool. Image will be set to ImageAware when it's turn.<br>
  * <b>NOTE:</b> {@link #init(ImageLoaderConfiguration)} method must be called before this method
  * call
  *
  * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
  * @param imageAware {@linkplain com.nostra13.universalimageloader.core.imageaware.ImageAware
  *     Image aware view} which should display image
  * @param options {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions Options}
  *     for image decoding and displaying. If <b>null</b> - default display image options
  *     {@linkplain
  *     ImageLoaderConfiguration.Builder#defaultDisplayImageOptions(DisplayImageOptions) from
  *     configuration} will be used.
  * @param listener {@linkplain ImageLoadingListener Listener} for image loading process. Listener
  *     fires events on UI thread if this method is called on UI thread.
  * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called
  *     before
  * @throws IllegalArgumentException if passed <b>imageAware</b> is null
  */
 public void displayImage(
     String uri,
     ImageAware imageAware,
     DisplayImageOptions options,
     ImageLoadingListener listener) {
   displayImage(uri, imageAware, options, listener, null);
 }
  private void loadImage(String imageURL) {
    Log.i("Image Url ", imageURL);
    imageLoader.displayImage(
        imageURL,
        sd_imageview,
        options,
        new SimpleImageLoadingListener() {
          @Override
          public void onLoadingStarted(String imageUri, View view) {
            // holder.progressBarCircular.setVisibility(View.VISIBLE);
          }

          @Override
          public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
            // holder.progressBarCircular.setVisibility(View.VISIBLE);
          }

          @Override
          public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            // holder.progressBarCircular.setVisibility(View.GONE);
          }
        },
        new ImageLoadingProgressListener() {
          @Override
          public void onProgressUpdate(String imageUri, View view, int current, int total) {
            // holder.progressBarCircular.setVisibility(View.VISIBLE);
          }
        });
  }
Exemple #12
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   ViewHolder holder;
   if (convertView == null) {
     convertView = inflater.inflate(R.layout.pwpraise_item, parent, false);
     holder = new ViewHolder();
     holder.iv_uface = (ImageView) convertView.findViewById(R.id.iv_uface);
     holder.tv_uname = (TextView) convertView.findViewById(R.id.tv_uname);
     holder.tv_praise_time = (TextView) convertView.findViewById(R.id.tv_praise_time);
     //			holder.v_gender_age = (GenderWithAgeView) convertView
     //					.findViewById(R.id.v_gender_age);
     //			holder.tv_des = (TextView) convertView.findViewById(R.id.tv_des);
     convertView.setTag(holder);
   } else {
     holder = (ViewHolder) convertView.getTag();
   }
   final PWPraiseModel model = mList.get(position);
   imageLoader.displayImage(model.getAvatarThumbnail(), holder.iv_uface, options);
   holder.tv_uname.setText(UserManager.getRealName(model.getUid(), model.getName(), context));
   //		holder.v_gender_age.displayGenderWithAge(model.getGender(),
   //				TimeUtil.getAgeByBirthday(model.getBirthday()));
   //		holder.tv_des.setText(model.getSlogan());
   holder.tv_praise_time.setText(TimeUtil.getMsgTimeDisplay(model.getPraiseTime()));
   return convertView;
 }
Exemple #13
0
 public void displayImage(
     ImageView imageView,
     String url,
     DisplayImageOptions displayImageOptions,
     SimpleImageLoadingListener listener) {
   imageLoader.displayImage(url, imageView, displayImageOptions, listener);
 }
  /*
   * (non-Javadoc)
   *
   * @see android.widget.ArrayAdapter#getView(int, android.view.View,
   * android.view.ViewGroup)
   */
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    PartyJoinInfo tweet = memList.get(position);

    options =
        new DisplayImageOptions.Builder()
            .showStubImage(R.drawable.stub_image)
            .showImageForEmptyUri(R.drawable.image_for_empty_url)
            .cacheInMemory()
            .cacheOnDisc()
            .displayer(new RoundedBitmapDisplayer(20))
            .build();
    if (convertView == null) {
      convertView = mInflater.inflate(mResource, null);
    }
    TextView fname = (TextView) convertView.findViewById(R.id.fname);
    fname.setText(tweet.getmname());

    ImageView fpic = (ImageView) convertView.findViewById(R.id.fpic);
    imageloader.displayImage(tweet.getmpic(), fpic, options);

    btn_invite = (Button) convertView.findViewById(R.id.btn_invite);
    btn_invite.setOnClickListener(on_FrpicClick);
    btn_invite.setTag(Integer.valueOf(position));
    btn_invite.setText("승인");

    btn_none = (Button) convertView.findViewById(R.id.btn_none);
    btn_none.setOnClickListener(none_FrpicClick);
    btn_none.setTag(Integer.valueOf(position));
    btn_none.setText("거절");

    return convertView;
  }
  protected void onPostExecute(String result) {
    super.onPostExecute(result);
    progressDialog.dismiss();

    Log.i("TAG", "onPostExcecute");
    Log.i("TAG", String.valueOf(similarProductListDTO.size()));
    Log.i("TAG", String.valueOf(productDetailDTO.imagePath));

    similarProductListView.setAdapter(
        new SimilarProductListAdapter(context, similarProductListDTO, imageLoader, options));

    productName.setText(productDetailDTO.getPdtName());
    productType.setText(productDetailDTO.getPdtType());
    productBrandDetail.setText(productDetailDTO.getPdtBrand());
    productFeaturePrice.setText(productDetailDTO.getPdtFeaturedPrice());
    productFeatureDecimalPrice.setText("00");
    productPrice.setText(productDetailDTO.getPdtPrice());
    productDecimalPrice.setText("00");
    productAvailable.setText(productDetailDTO.getIsStockout());
    productDesc.setText(productDetailDTO.getPdtDesc());

    imageLoader.displayImage(productDetailDTO.getImagePath(), productImageView, options);

    //		((Activity) context).runOnUiThread(new Runnable(){
    //		    public void run(){
    //		        imageLoader.displayImage(productDetailDTO.getImagePath(), productImageView,
    // options);
    //		        Log.i("TAG", "ImagePath"+":"+String.valueOf(productDetailDTO.imagePath)+ " "
    //		        +"ImageView"+ productImageView
    //		        		);
    //		    }
    //		});
  }
 // 封装方法
 public void displayImage(String mResName, ImageView imageView) {
   if (mResName.startsWith("http://")) {
     mImageLoader.displayImage(mResName, imageView);
   } else if (mResName.startsWith("assets://")) {
     mImageLoader.displayImage(mResName, imageView);
   } else if (mResName.startsWith("file:///mnt")) {
     mImageLoader.displayImage(mResName, imageView);
   } else if (mResName.startsWith("content://")) {
     mImageLoader.displayImage(mResName, imageView);
   } else if (mResName.startsWith("drawable://")) {
     mImageLoader.displayImage(mResName, imageView);
   } else {
     Uri uri = Uri.parse(mResName);
     imageView.setImageURI(uri);
   }
 }
  private void addHeader() {
    View viewauth = View.inflate(DetailActivity.this, R.layout.authinfo, null);
    ImageView imageView = (ImageView) viewauth.findViewById(R.id.imageView);
    TextView tv_author_name = (TextView) viewauth.findViewById(R.id.tv_author_name);
    TextView tv_author_date = (TextView) viewauth.findViewById(R.id.tv_author_date);
    TextView tv_reply = (TextView) viewauth.findViewById(R.id.tv_reply);
    TextView tv_title = (TextView) viewauth.findViewById(R.id.tv_title);
    TextView tv_content = (TextView) viewauth.findViewById(R.id.tv_content);

    loader.displayImage("http:" + topic.member.avatar_large, imageView);
    imageView.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            anotherActivity(topic.member.username);
          }
        });
    tv_author_name.setText(topic.member.username);
    String beforeLong = TimeUtils.getStandardDate(topic.created + "");
    tv_author_date.setText(beforeLong);
    tv_reply.setText(topic.replies + "个回复");
    tv_title.setText(topic.title);
    tv_content.setText(topic.content);

    linkiFy(tv_content);

    listView.addHeaderView(viewauth);
  }
  private void initUI() {
    mFriendIcon = (ImageView) findViewById(R.id.friend_detail_icon);
    mFriendName = (TextView) findViewById(R.id.friend_detail_name);
    mEditMemoName = (EditText) findViewById(R.id.edit_memo_name);
    mTxtGroupName = (TextView) findViewById(R.id.manage_grouptext);
    mTxtGroupName.setOnClickListener(this);

    String result = mBundle.getString("Detail");
    String[] resultinfo = result.split("\\|");

    try {

      JSONObject jsonObject = new JSONObject(resultinfo[1]);
      mFriendInfo = new SettingUserInfo(jsonObject);

      mFriendName.setText(mFriendInfo.getName());

      // 图片加载
      imageLoader.displayImage(
          HttpClientUtil.SERVER_PATH + mFriendInfo.getIcon(), mFriendIcon, options);

    } catch (JSONException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
  @SuppressLint("InflateParams")
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
      convertView = LayoutInflater.from(context).inflate(R.layout.user_item, null);
      ItemViewCache itemViewCache = new ItemViewCache();
      itemViewCache.imageViewUser = (ImageView) convertView.findViewById(R.id.imageViewUser);
      itemViewCache.textViewUser = (TextView) convertView.findViewById(R.id.textViewUser);
      itemViewCache.textViewCount = (TextView) convertView.findViewById(R.id.textViewCount);
      itemViewCache.textViewDate = (TextView) convertView.findViewById(R.id.textViewDate);
      convertView.setTag(itemViewCache);
    }

    ItemViewCache cache = (ItemViewCache) convertView.getTag();
    User user = userList.get(position);
    URL url = user.getUserAvatar();
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(128, 128);
    layoutParams.leftMargin = 5;
    layoutParams.rightMargin = 5;
    layoutParams.topMargin = 5;
    layoutParams.bottomMargin = 5;
    cache.imageViewUser.setLayoutParams(layoutParams);
    if (url != null) {
      imageLoader.displayImage(url.toString(), cache.imageViewUser);
    }

    cache.textViewUser.setText(user.getTitle());
    cache.textViewCount.setText("随笔总数:" + user.getPostCount());
    cache.textViewDate.setText("最后更新:" + AppUtils.parseDateToString(user.getUpdatedDate()));

    return convertView;
  }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
      convertView = mInflater.inflate(R.layout.picture_grid_item, parent, false);
      if (parent instanceof StaggeredGridView) {
        convertView = mInflater.inflate(R.layout.picture_pin_item, parent, false);
      }
    }
    final ImageView imageView = (ImageView) convertView.findViewById(R.id.iv_image);
    String path = hasHeaderIdList.get(position).getPath();
    // if (mLruCache.get(path) == null)
    // {
    // new BitmapWorkerTask(imageView).execute(path);
    // }
    // else
    // {
    // imageView.setImageBitmap(mLruCache.get(path));
    // }

    DisplayImageOptions options =
        new DisplayImageOptions.Builder()
            .imageScaleType(ImageScaleType.EXACTLY_STRETCHED)
            .showStubImage(R.drawable.ic_default_image)
            .showImageForEmptyUri(R.drawable.ic_default_image)
            .bitmapConfig(Config.RGB_565)
            .build();

    mImageLoader.displayImage("file://" + path, imageView, options);
    //		mImageLoader.displayImage("file://" + path, imageView, new ImageLoadingListenerImpl());
    imageView.setOnClickListener(new OnClickListenerImpl(path));
    return convertView;
  }
  @SuppressLint("SetJavaScriptEnabled")
  private void initView() {
    // TODO Auto-generated method stub
    product_detail_listview_image = (ImageView) findViewById(R.id.product_detail_listview_image);
    product_detail_listview_text_name =
        (TextView) findViewById(R.id.product_detail_listview_text_name);
    product_detail_listview_text_price =
        (TextView) findViewById(R.id.product_detail_listview_text_price);
    product_detail_listview_text_describe =
        (TextView) findViewById(R.id.product_detail_listview_text_describe);
    productWebView = (WebView) findViewById(R.id.product_webview);
    WebSettings webSettings = productWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);

    webViewUtil = new WebViewUtil();

    imageLoader = ImageLoader.getInstance();
    imageLoader.init(ImageLoaderConfiguration.createDefault(this));
    options =
        new DisplayImageOptions.Builder()
            .displayer(new RoundedBitmapDisplayer(0xff000000, 10))
            .cacheInMemory()
            .cacheOnDisc()
            .build();

    product_detail_listview_text_name.setText(product.getProductName());
    product_detail_listview_text_price.setText(product.getProductPrice());
    product_detail_listview_text_describe.setText(product.getProductDescribe());
    imageLoader.displayImage(product.getImageUrl(), product_detail_listview_image, options);
  }
 private void init() {
   if (windowHeight < 1) {
     WindowManager m = ((Activity) context).getWindowManager();
     Display d = m.getDefaultDisplay(); // 获取屏幕宽、高用
     windowHeight = d.getHeight();
   }
   ViewGroup.LayoutParams p = root.getLayoutParams(); // getWindow().getAttributes();
   if (bean == null || bean.getImgUrlSize() > 2) {
     p.height = (int) (windowHeight * 0.2);
     img1.setVisibility(View.VISIBLE);
     img2.setVisibility(View.VISIBLE);
     img3.setVisibility(View.VISIBLE);
     imageLoader.displayImage(bean.getImgUrl(0), img1);
     imageLoader.displayImage(bean.getImgUrl(1), img2);
     imageLoader.displayImage(bean.getImgUrl(2), img3);
     int dp = DensityUtil.dip2px(context, 5);
     root.setPadding(dp, dp, dp, dp);
     img1.setScaleType(ScaleType.CENTER_INSIDE);
     img2.setScaleType(ScaleType.CENTER_INSIDE);
     img3.setScaleType(ScaleType.CENTER_INSIDE);
   } else if (bean.getImgUrlSize() > 1) {
     p.height = (int) (windowHeight * 0.3);
     img1.setVisibility(View.VISIBLE);
     img2.setVisibility(View.VISIBLE);
     img3.setVisibility(View.GONE);
     imageLoader.displayImage(bean.getImgUrl(0), img1);
     imageLoader.displayImage(bean.getImgUrl(1), img2);
     img1.setScaleType(ScaleType.CENTER_INSIDE);
     img2.setScaleType(ScaleType.CENTER_INSIDE);
     int dp = DensityUtil.dip2px(context, 5);
     root.setPadding(dp, dp, dp, dp);
   } else if (bean.getImgUrlSize() > 0) {
     p.height = (int) (windowHeight * 0.4);
     imageLoader.displayImage(bean.getImgUrl(0), img1);
     img1.setVisibility(View.VISIBLE);
     img2.setVisibility(View.GONE);
     img3.setVisibility(View.GONE);
     root.setPadding(0, 0, 0, 0);
     img1.setScaleType(ScaleType.CENTER_CROP);
   } else {
     p.height = 0;
     img1.setVisibility(View.GONE);
     img2.setVisibility(View.GONE);
     img3.setVisibility(View.GONE);
   }
   root.setLayoutParams(p);
 }
 /**
  * Adds display image task to execution pool. Image will be set to ImageView when it's turn.<br>
  * <b>NOTE:</b> {@link #init(ImageLoaderConfiguration)} method must be called before this method
  * call
  *
  * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
  * @param imageView {@link ImageView} which should display image
  * @param options {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions Options}
  *     for image decoding and displaying. If <b>null</b> - default display image options
  *     {@linkplain
  *     ImageLoaderConfiguration.Builder#defaultDisplayImageOptions(DisplayImageOptions) from
  *     configuration} will be used.
  * @param listener {@linkplain ImageLoadingListener Listener} for image loading process. Listener
  *     fires events on UI thread if this method is called on UI thread.
  * @param progressListener {@linkplain
  *     com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener Listener} for
  *     image loading progress. Listener fires events on UI thread if this method is called on UI
  *     thread. Caching on disk should be enabled in {@linkplain
  *     com.nostra13.universalimageloader.core.DisplayImageOptions options} to make this listener
  *     work.
  * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called
  *     before
  * @throws IllegalArgumentException if passed <b>imageView</b> is null
  */
 public void displayImage(
     String uri,
     ImageView imageView,
     DisplayImageOptions options,
     ImageLoadingListener listener,
     ImageLoadingProgressListener progressListener) {
   displayImage(uri, new ImageViewAware(imageView), options, listener, progressListener);
 }
 /** 获取本地图片并显示 */
 public static void getLocaImage(Context context, String picUrl, ImageView imageView, File path) {
   if (path == null) {
     return;
   }
   String url = path.getPath() + "/" + picUrl;
   String imageUrl = ImageDownloader.Scheme.FILE.wrap(url);
   imageLoader.displayImage(imageUrl, imageView, ImageOptHelper.getImgOptions());
 }
 @Override
 public void fill(Event model) {
   if (isImageTrue(model.getImages())) {
     imageLoader.displayImage(model.getImages().get(0).getImage(), ivEventImage);
   }
   tvEventHashTag.setText(SystemUtils.eventHashTagByTitle(model.getTitle()));
   tvEventName.setText(model.getTitle());
 }
Exemple #26
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder viewHolder = null;
    if (null == convertView) {
      viewHolder = new ViewHolder();
      convertView = LayoutInflater.from(context).inflate(R.layout.main_news_item, parent, false);
      viewHolder.tv_topic = (TextView) convertView.findViewById(R.id.tv_topic);
      viewHolder.tv_title = (TextView) convertView.findViewById(R.id.tv_title);
      viewHolder.iv_title = (ImageView) convertView.findViewById(R.id.iv_title);
      viewHolder.item_RL = (RelativeLayout) convertView.findViewById(R.id.item_RL);
      viewHolder.title_RL = (RelativeLayout) convertView.findViewById(R.id.title_RL);
      convertView.setTag(viewHolder);
    } else {
      viewHolder = (ViewHolder) convertView.getTag();
    }

    ((RelativeLayout) viewHolder.item_RL.getParent())
        .setBackgroundColor(
            context
                .getResources()
                .getColor(isLight ? R.color.light_news_item : R.color.dark_news_item));
    viewHolder.tv_topic.setTextColor(
        context
            .getResources()
            .getColor(isLight ? R.color.light_news_topic : R.color.dark_news_topic));
    viewHolder.tv_title.setTextColor(
        context.getResources().getColor(isLight ? android.R.color.black : android.R.color.white));

    final StoriesEntity entity = list.get(position);
    if (entity.getType() == Constant.TOPIC) {
      ((RelativeLayout) viewHolder.tv_topic.getParent()).setBackgroundColor(Color.TRANSPARENT);
      viewHolder.title_RL.setVisibility(View.GONE);
      viewHolder.tv_topic.setVisibility(View.VISIBLE);
      viewHolder.tv_topic.setText(entity.getTitle());
    } else {
      ((RelativeLayout) viewHolder.tv_title.getParent().getParent())
          .setBackgroundResource(
              isLight
                  ? R.drawable.item_background_selector_light
                  : R.drawable.item_background_selector_dark);
      viewHolder.tv_topic.setVisibility(View.GONE);
      viewHolder.title_RL.setVisibility(View.VISIBLE);
      viewHolder.tv_title.setText(entity.getTitle());
      if (null != entity.getImages()) {
        mImageLoader.displayImage(entity.getImages().get(0), viewHolder.iv_title, options);
      }
    }
    viewHolder.title_RL.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(context, NewsContentActivity.class);
            intent.putExtra("entity", entity);
            context.startActivity(intent);
          }
        });
    return convertView;
  }
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
    final ViewHolder vh;
    if (convertView == null) {
      View view = mInflater.inflate(R.layout.item_my_article, parent, false);
      vh = ViewHolder.create(view);
      view.setTag(vh);
    } else {
      vh = (ViewHolder) convertView.getTag();
    }

    final Article item = objects.get(position);

    try {
      vh.lblName.setText(item.AuthorID.Nickname);
      vh.lblAge.setText(", " + item.AuthorID.age);
      //            vh.lblNumberFollower.setText(item.AuthorID.follower + " followers");
      vh.lblNumberFollower.setText(
          item.AuthorID.follower + " follower" + (item.AuthorID.follower > 1 ? "s" : ""));
      vh.lblContent.setText(item.ArticleText);
      imageLoader.displayImage(item.AuthorID.Avatar, vh.icon, options);
      vh.lblTitle.setText(item.Title);
      //            vh.lblTip.setText("Tip " + (position + 1) + " out of " +
      // item.Collection.ArticleCountTip + ",");
      vh.lblTip.setText("Tip " + (position + 1) + " out of " + objects.size() + ",");
      vh.lblCollection.setText(item.Collection.Name);
      vh.lblTime.setText(
          DateUtils.formatTimeStamp(item.Date_modified * 1000, Contains.FORMAT_TIME));
    } catch (Exception e) {
      Logs.log(e);
    }

    vh.buttonEdit.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(context, AddTipActivity.class);
            intent.putExtra(Contains.PARAM_ARTICLE, item.toJSON());
            intent.putExtra(Contains.PARAM_EDIT, true);
            ((HomeActivity) context).startActivityForResult(intent, Contains.REQUEST_EDIT);
          }
        });

    vh.buttonShare.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("text/plain");
            intent.putExtra(Intent.EXTRA_SUBJECT, item.Title);
            intent.putExtra(Intent.EXTRA_TEXT, item.ArticleText);
            context.startActivity(
                Intent.createChooser(intent, context.getString(R.string.app_name)));
          }
        });

    return vh.rootView;
  }
  @Override
  public Object instantiateItem(ViewGroup view, int position) {
    View imageLayout = inflater.inflate(R.layout.image_pager_item, view, false);
    ImageView imageView = (ImageView) imageLayout.findViewById(R.id.image);

    final ProgressBar spinner = (ProgressBar) imageLayout.findViewById(R.id.loading);
    String uri = uriList.get(position);
    if (type == 0) {
      uri = "file://" + uri;
    }
    final PhotoViewAttacher mAttacher = new PhotoViewAttacher(imageView);
    imageLoader.displayImage(
        uri,
        imageView,
        options,
        new SimpleImageLoadingListener() {
          @Override
          public void onLoadingStarted(String imageUri, View view) {
            spinner.setVisibility(View.VISIBLE);
          }

          @Override
          public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
            // int message = 0;
            // switch (failReason.getType()) {
            // case IO_ERROR:
            // message = R.string.io_error;
            // break;
            // case DECODING_ERROR:
            // message = R.string.decode_error;
            // break;
            // case NETWORK_DENIED:
            // message = R.string.network_error;
            // break;
            // case OUT_OF_MEMORY:
            // message = R.string.out_of_memory;
            // break;
            // case UNKNOWN:
            // message = R.string.unknown_error;
            // break;
            // }
            // Toast.makeText(context, message, Toast.LENGTH_SHORT)
            // .show();

            spinner.setVisibility(View.GONE);
          }

          @Override
          public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            spinner.setVisibility(View.GONE);
            mAttacher.update();
            // Debug.o(new Exception(), "imageUri = " + imageUri);
          }
        });

    view.addView(imageLayout, 0);
    return imageLayout;
  }
 public static void displayRoundImage(ImageView view, String path, ImageLoadingListener listener) {
   ImageLoader loader = ImageLoader.getInstance();
   try {
     loader.displayImage(path, view, ROUND_DISPLAY_IMAGE_OPTIONS, listener);
   } catch (OutOfMemoryError e) {
     e.printStackTrace();
     loader.clearMemoryCache();
   }
 }
  public void loadSongsDetails(SongDetail mDetail) {
    String contentURI = "content://media/external/audio/media/" + mDetail.getId() + "/albumart";
    imageLoader.displayImage(contentURI, songAlbumbg, options, animateFirstListener);
    imageLoader.displayImage(contentURI, img_bottom_slideone, options, animateFirstListener);
    imageLoader.displayImage(contentURI, img_bottom_slidetwo, options, animateFirstListener);

    txt_playesongname.setText(mDetail.getTitle());
    txt_songartistname.setText(mDetail.getArtist());
    txt_playesongname_slidetoptwo.setText(mDetail.getTitle());
    txt_songartistname_slidetoptwo.setText(mDetail.getArtist());

    if (txt_timetotal != null) {
      long duration = Long.valueOf(mDetail.getDuration());
      txt_timetotal.setText(
          duration != 0 ? String.format("%d:%02d", duration / 60, duration % 60) : "-:--");
    }
    updateProgress(mDetail);
  }