Esempio n. 1
1
  public void onClick(View v, int position, int countitem) {
    ImageView selectedShip = ((MapBuilder) context).getSelectedShip();
    if (selectedShip != null) {
      ShipOnMap som = new ShipOnMap();
      RelativeLayout fl = (RelativeLayout) v;
      RelativeLayout.LayoutParams params =
          new RelativeLayout.LayoutParams(selectedShip.getWidth(), selectedShip.getHeight());
      som.start.x = x;
      som.start.y = y - v.getTop();
      som.time = (countitem - 1 - position) * 3 + 1;
      String[] shipinfo = ((String) selectedShip.getTag()).split(":");
      som.type = shipinfo[0];
      som.weapon = shipinfo[1];
      params.leftMargin = x - (selectedShip.getWidth() / 2);
      params.topMargin = y - v.getTop() - (selectedShip.getHeight() / 2);
      ImageView iv = new ImageView(context);
      iv.setImageDrawable(selectedShip.getDrawable());
      int h = fl.getHeight();
      int w = fl.getWidth();
      if (!ship.containsKey(position)) {
        ship.put(position, new LinkedList<ShipOnMap>());
      }

      som.ship = iv.getDrawable();
      som.param = params;
      List<ShipOnMap> lship = ship.get(position);
      lship.add(som);
      iv.setTag(position + "/" + (lship.size() - 1));
      ((MapBuilder) context).registerForContextMenu(iv);
      fl.addView(iv, params);
      fl.getLayoutParams().height = h;
      fl.getLayoutParams().width = w;
    }
  }
 private void createSelectionLayer(Context context) {
   final LayoutInflater inflater =
       (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   mSelectionDragLayer = (DragLayer) inflater.inflate(R.layout.selection_drag_layer, null);
   mDragController = new DragController(context);
   mDragController.setDragListener(this);
   mDragController.addDropTarget(mSelectionDragLayer);
   mSelectionDragLayer.setDragController(mDragController);
   mStartSelectionHandle = (ImageView) mSelectionDragLayer.findViewById(R.id.startHandle);
   mStartSelectionHandle.setTag(HandleType.START);
   mEndSelectionHandle = (ImageView) mSelectionDragLayer.findViewById(R.id.endHandle);
   mEndSelectionHandle.setTag(HandleType.END);
   final OnTouchListener handleTouchListener =
       new OnTouchListener() {
         @Override
         public boolean onTouch(View v, MotionEvent event) {
           boolean handledHere = false;
           if (event.getAction() == MotionEvent.ACTION_DOWN) {
             handledHere = startDrag(v);
             mLastTouchedSelectionHandle = (HandleType) v.getTag();
           }
           return handledHere;
         }
       };
   mStartSelectionHandle.setOnTouchListener(handleTouchListener);
   mEndSelectionHandle.setOnTouchListener(handleTouchListener);
 }
Esempio n. 3
0
  public void setContent(Object param) {
    if (param instanceof BaseComment) {
      BaseComment comment = (BaseComment) param;

      String nameString = comment.owner.name;
      long timeParam = comment.created_at;
      String iconUri = comment.owner.avatar;

      imageLoadTool.loadImage(icon, iconUri);
      icon.setTag(comment.owner.global_key);
      name.setText(nameString);
      time.setText(Global.dayToNow(timeParam));
      layout.setTag(comment);

    } else if (param instanceof Commit) {
      Commit commit = (Commit) param;
      String nameString = commit.getName();
      long timeParam = commit.getCommitTime();
      String iconUri = commit.getIcon();

      imageLoadTool.loadImage(icon, iconUri);
      icon.setTag(commit.getGlobalKey());
      name.setText(nameString);
      time.setText(Global.dayToNow(timeParam));
      layout.setTag(commit);
    }
  }
Esempio n. 4
0
  public View getView(final int position, View convertView, ViewGroup parent) {
    // Log.i(TAG, "getView, position:" + position);
    if (position >= mListView.size()) {
      return null;
    }

    convertView = mListView.get(position);

    ImageView editImageView = (ImageView) convertView.findViewById(R.id.editImageView);
    editImageView.setTag(convertView);
    ImageView deleteImageView = (ImageView) convertView.findViewById(R.id.deleteImageView);
    deleteImageView.setTag(convertView);
    editImageView.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View arg0) {
            View parent = (View) arg0.getTag();
            int index = (Integer) parent.getTag();
            editItem(index);
          }
        });
    deleteImageView.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View arg0) {
            View parent = (View) arg0.getTag();
            int index = (Integer) parent.getTag();
            deleteItem(index);
          }
        });

    return convertView;
  }
  private void lightBulbs() {
    String binaryString = Integer.toBinaryString(count);
    List<Integer> bits = new ArrayList<>(8);
    for (int count = binaryString.length() - 1; count >= 0; count--) {
      int bit = Integer.parseInt(String.valueOf(binaryString.charAt(count)));
      bits.add(bit);
    }
    //  Toast.makeText(getActivity(), bits.size() + " "+ images.size(), Toast.LENGTH_LONG).show();
    // use bits.siz()
    for (int i = bits.size() - 1; i >= 0; i--) {
      if (bits.get(i) != null && bits.get(i) == 1) {
        ImageView currentView = images.get(i);
        currentView.setImageDrawable(
            getActivity().getResources().getDrawable(R.drawable.red_light_bulb));
        currentView.setTag("on");

      } else {
        ImageView currentView = images.get(i);
        currentView.setImageDrawable(
            getActivity().getResources().getDrawable(R.drawable.green_light_bulb));
        currentView.setTag("off");
      }
    }

    displayBinaryValue();
  }
  private void animateBulbs(String biString) {
    List<Integer> bits = new ArrayList<>(8);

    for (int count = biString.length() - 1; count >= 0; count--) {
      int bit = Integer.parseInt(String.valueOf(biString.charAt(count)));
      bits.add(bit);
    }
    //  Toast.makeText(getActivity(), bits.size() + " "+ images.size(), Toast.LENGTH_LONG).show();
    // use bits.siz()
    for (int i = bits.size() - 1; i >= 0; i--) {
      if (bits.get(i) != null && bits.get(i) == 1) {
        ImageView currentView = images.get(i);
        @SuppressWarnings("ResourceType")
        AnimationDrawable drawable =
            (AnimationDrawable) getActivity().getResources().getDrawable(R.anim.splash);

        currentView.setImageDrawable(drawable);
        drawable.start();
        currentView.setTag("on");

      } else {
        ImageView currentView = images.get(i);
        currentView.setImageDrawable(
            getActivity().getResources().getDrawable(R.drawable.green_light_bulb));
        currentView.setTag("off");
      }
    }

    displayBinaryValue();
  }
  private boolean changePhoto() {
    Bitmap photo = mBitmapQueue.poll();
    if (photo != null) {
      ImageView destination = getBackface();
      Bitmap old = mBitmapStore.get(destination);
      int width = photo.getWidth();
      int height = photo.getHeight();
      int orientation = (width > height ? LANDSCAPE : PORTRAIT);

      destination.setImageBitmap(photo);
      destination.setTag(R.id.photo_orientation, new Integer(orientation));
      destination.setTag(R.id.photo_width, new Integer(width));
      destination.setTag(R.id.photo_height, new Integer(height));
      setScaleType(destination);

      mBitmapStore.put(destination, photo);

      if (old != null) {
        old.recycle();
      }

      return true;
    } else {
      return false;
    }
  }
Esempio n. 8
0
  private void initializeVariables() { // אתחול משתנים

    msg = (TextView) findViewById(R.id.tvMsg);
    iv0 = (ImageView) findViewById(R.id.iv0);
    iv1 = (ImageView) findViewById(R.id.iv1);
    iv2 = (ImageView) findViewById(R.id.iv2);
    iv3 = (ImageView) findViewById(R.id.iv3);
    iv4 = (ImageView) findViewById(R.id.iv4);
    iv5 = (ImageView) findViewById(R.id.iv5);
    iv6 = (ImageView) findViewById(R.id.iv6);
    iv7 = (ImageView) findViewById(R.id.iv7);
    iv8 = (ImageView) findViewById(R.id.iv8);

    // אתחול לתגים

    iv0.setTag("empty");
    iv1.setTag("empty");
    iv2.setTag("empty");
    iv3.setTag("empty");
    iv4.setTag("empty");
    iv5.setTag("empty");
    iv6.setTag("empty");
    iv7.setTag("empty");
    iv8.setTag("empty");

    iv0.setOnClickListener(this);
    iv1.setOnClickListener(this);
    iv2.setOnClickListener(this);
    iv3.setOnClickListener(this);
    iv4.setOnClickListener(this);
    iv5.setOnClickListener(this);
    iv6.setOnClickListener(this);
    iv7.setOnClickListener(this);
    iv8.setOnClickListener(this);
  }
Esempio n. 9
0
  public void clickNewGame(View view) {
    Button newGame = (Button) view;
    iv0.setImageResource(0);
    iv1.setImageResource(0);
    iv2.setImageResource(0);
    iv3.setImageResource(0);
    iv4.setImageResource(0);
    iv5.setImageResource(0);
    iv6.setImageResource(0);
    iv7.setImageResource(0);
    iv8.setImageResource(0);

    iv0.setTag("empty");
    iv1.setTag("empty");
    iv2.setTag("empty");
    iv3.setTag("empty");
    iv4.setTag("empty");
    iv5.setTag("empty");
    iv6.setTag("empty");
    iv7.setTag("empty");
    iv8.setTag("empty");

    turn = true;
    msg.setText("");
  } // הגדרת הניצחון
  private void manageDayView(TextView dayTV, ImageView dayIV, Item item) {
    dayTV.setText(item.getDay());

    switch (item.getType()) { // apply styles
      case DEFAULT:
        {
          dayTV.setTextColor(getResources().getColor(R.color.black));
          dayIV.setImageResource(R.drawable.calendarcell);
          dayIV.setTag(item);
          dayIV.setOnClickListener(this);
        }
        break;

      case LEAVEDAY:
        {
          ItemLeaveDay itemLeaveDay = (ItemLeaveDay) item;
          dayTV.setTextColor(getResources().getColor(R.color.black));
          if (itemLeaveDay.getDuration() == Leave.Duration.AM)
            dayIV.setImageResource(R.drawable.calendarcell_sel_pm);
          else if (itemLeaveDay.getDuration() == Leave.Duration.PM)
            dayIV.setImageResource(R.drawable.calendarcell_sel_am);
          else dayIV.setImageResource(R.drawable.calendarcell_sel);
          dayIV.setTag(itemLeaveDay);
          dayIV.setOnClickListener(
              (itemLeaveDay.getDuration() == Leave.Duration.ONEDAY) ? null : this);
        }
        break;

      case NONWORKINGDAY:
        {
          dayTV.setTextColor(getResources().getColor(android.R.color.tertiary_text_light));
          dayIV.setImageResource(R.drawable.calendarcell_na);
          dayIV.setOnClickListener(null);
        }
        break;
    }

    // let the selected items be colored blue on reuse
    if (leaveEndCalendar != null && tempEndLeaveEndCalendar != null) {
      if (item.getType() == ITEMTYPE.DEFAULT
          && item.getDate().compareTo(leaveEndCalendar.getTime()) >= 0
          && item.getDate().compareTo(tempEndLeaveEndCalendar.getTime()) <= 0) {
        dayIV.setImageResource(R.drawable.calendarcell_leave);
      } else if (item.getType() == ITEMTYPE.LEAVEDAY
          && item.getDate().compareTo(tempEndLeaveEndCalendar.getTime()) == 0) {
        if (Math.abs(leaveDays.get(item.getStringedDate()) - 0.1) < 0.00001)
          dayIV.setImageResource(R.drawable.calendarcell_leave_am_whole);
        else dayIV.setImageResource(R.drawable.calendarcell_leave_pm_whole);
      }
    }
  }
Esempio n. 11
0
    @Override
    public View getChildView(
        int groupPosition,
        final int childPosition,
        boolean isLastChild,
        View convertView,
        ViewGroup parent) {

      ViewHolder holder;
      ViewHolder amount;
      ViewHolder when;

      if (convertView == null) {

        convertView =
            inf.inflate(R.layout.wallets_teens_fragment_receive_list_detail, parent, false);
        holder = new ViewHolder();

        holder.text = (TextView) convertView.findViewById(R.id.notes);

        convertView.setTag(holder);

        amount = new ViewHolder();
        amount.text = (TextView) convertView.findViewById(R.id.amount);

        amount.text.setText(transactions_amounts[groupPosition][childPosition].toString());

        when = new ViewHolder();
        when.text = (TextView) convertView.findViewById(R.id.when);

        when.text.setText(transactions_whens[groupPosition][childPosition].toString());

        // asigned tagId at icons action
        ImageView icon_receive_form_contact =
            (ImageView) convertView.findViewById(R.id.icon_receive_form_contact);
        icon_receive_form_contact.setTag(
            "ReceiveFromContactActivity|" + groupPosition + "-" + childPosition);

        ImageView send_message = (ImageView) convertView.findViewById(R.id.icon_chat_over_trx);
        send_message.setTag("ChatOverTrxActivity|" + groupPosition + "|" + childPosition);

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

      holder.text.setText(getChild(groupPosition, childPosition).toString());

      return convertView;
    }
    public void load() {
      ImageView imageView = mImageViewRef.get();
      if (imageView != null) {
        ApptentiveLog.v("ApptentiveAttachmentLoader load requested:" + uri);
        ApptentiveLog.v("ApptentiveAttachmentLoader load requested on:" + imageView.toString());

        // Handle the duplicate requests on the same grid item view
        LoaderRequest oldLoaderRequest = (LoaderRequest) imageView.getTag(DRAWABLE_DOWNLOAD_TAG);
        if (oldLoaderRequest != null) {
          // If old request on the same view also loads from the same source, cancel the current one
          if (oldLoaderRequest.getUrl().equals(uri)) {
            ApptentiveLog.v("ApptentiveAttachmentLoader load new request denied:" + uri);
            return;
          }
          // If old request on the same view loads from different source, cancel the old one
          oldLoaderRequest.cancel();
        }

        if (TextUtils.isEmpty(uri)) {
          ApptentiveLog.v("ApptentiveAttachmentLoader loadDrawable(clear)");
          loadDrawable(null);
          imageView.setTag(DRAWABLE_DOWNLOAD_TAG, null);
          return;
        }

        Bitmap cachedBitmap =
            (bLoadImage)
                ? (Bitmap)
                    bitmapMemoryCache.getObjectFromCache(
                        ImageMemoryCache.generateMemoryCacheEntryKey(
                            uri, imageViewWidth, imageViewHeight))
                : null;
        if (cachedBitmap != null) {
          mWasDownloaded = false;

          ApptentiveLog.v("ApptentiveAttachmentLoader loadDrawable(found in cache)");
          loadDrawable(cachedBitmap);
          imageView.setTag(DRAWABLE_DOWNLOAD_TAG, null);
        } else {
          imageView.setTag(DRAWABLE_DOWNLOAD_TAG, this);
          if (bLoadImage) {
            loadImageFromDisk(imageView);
          } else {
            loadAttachmentFromDisk(imageView);
          }
        }
      }
    }
Esempio n. 13
0
 public View getView(int i, View view, ViewGroup paramViewGroup) {
   ImageView imageView = (ImageView) view;
   if (imageView == null) {
     imageView =
         new ImageView(EmojiView.this.getContext()) {
           public void onMeasure(int paramAnonymousInt1, int paramAnonymousInt2) {
             setMeasuredDimension(
                 View.MeasureSpec.getSize(paramAnonymousInt1),
                 View.MeasureSpec.getSize(paramAnonymousInt1));
           }
         };
     imageView.setOnClickListener(
         new View.OnClickListener() {
           public void onClick(View view) {
             if (EmojiView.this.listener != null) {
               EmojiView.this.listener.onEmojiSelected(
                   EmojiView.this.convert((Long) view.getTag()));
             }
             EmojiView.this.addToRecent((Long) view.getTag());
           }
         });
     imageView.setBackgroundResource(R.drawable.list_selector);
     imageView.setScaleType(ImageView.ScaleType.CENTER);
   }
   imageView.setImageDrawable(Emoji.getEmojiBigDrawable(data[i]));
   imageView.setTag(data[i]);
   return imageView;
 }
  @Override
  public View getView(
      Context context,
      View recycled,
      int thumbWidth,
      int thumbHeight,
      int placeholderResourcedId,
      LocalDataAdapter adapter,
      boolean isInProgress) {
    final ImageView imageView;
    if (recycled != null) {
      imageView = (ImageView) recycled;
    } else {
      imageView = new ImageView(context);
      imageView.setTag(R.id.mediadata_tag_viewtype, getItemViewType().ordinal());
    }

    byte[] jpegData = Storage.getJpegForSession(mUri);
    int currentVersion = Storage.getJpegVersionForSession(mUri);
    Glide.with(context)
        .loadFromImage(jpegData, mUri.toString() + currentVersion)
        .skipDiskCache(true)
        .fitCenter()
        .into(imageView);

    imageView.setContentDescription(
        context.getResources().getString(R.string.media_processing_content_description));
    return imageView;
  }
  /**
   * Notifies the pager indicator that the data set has changed. Be sure to notify the pager as well
   * (though you may wish to place that call in here yourself).
   */
  public void notifyDataSetChanged() {
    if (pager != null && pager.getAdapter() != null) {

      // remove the old items (if any exist)
      itemContainer.removeAllViews();

      // I'm sure this could be optimised a lot more, eg,
      // by reusing existing ImageViews, but it
      // does the job well enough for now.
      items.removeAll(items);

      // now create the new items.
      for (int i = 0; i < pager.getAdapter().getCount(); i++) {

        ImageView item = new ImageView(context);

        if (i == pager.getCurrentItem()) {
          item.setImageResource(R.drawable.bulb_lit4);
        } else {
          item.setImageResource(R.drawable.bulb_unlit4);
        }

        item.setTag(i);
        item.setOnClickListener(itemClickListener);
        items.add(item);

        itemContainer.addView(item);
      }
    }
  }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ImageView imageView = null;
    try {
      if (convertView == null) { // if it's not recycled, initialize some
        // attributes
        imageView = new ImageView(mContext);

        imageView.setLayoutParams(
            new GridView.LayoutParams(
                android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                android.view.ViewGroup.LayoutParams.WRAP_CONTENT));

        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        imageView.setPadding(
            Integer.parseInt("8"),
            Integer.parseInt("8"),
            Integer.parseInt("8"),
            Integer.parseInt("8"));
      } else {
        imageView = (ImageView) convertView;
      }

      imageView.setBackgroundResource(mThumbIds[position]);
      imageView.setTag(mTags[position]);
    } catch (Exception ex) {
      PhrescoLogger.info(TAG + " - getView  - Exception : " + ex.toString());
      PhrescoLogger.warning(ex);
    }
    return imageView;
  }
  /**
   * Takes an ImageView and alternately rotates it clockwise and counterclockwise Based on the
   * previous rotation. This change is applied directly to the ImageView This animation lasts for
   * half a second
   *
   * @param v {ImageView} : the source view
   */
  public static void rotateImage(final ImageView v) {
    // Initialize the tag on the imageview
    // Signals if we rotate clockwise or counterclockwise
    if (v.getTag() == null) v.setTag(false);
    final boolean tag = (boolean) v.getTag();

    Animation a =
        new Animation() {
          @Override
          protected void applyTransformation(float interpolatedTime, Transformation t) {
            Matrix matrix = new Matrix();
            v.setScaleType(ImageView.ScaleType.MATRIX);
            // Rotates counterclockwise if the tag is true
            float rotation = interpolatedTime * 180f;
            if (tag) rotation = 180f - rotation;
            matrix.postRotate(
                rotation,
                v.getDrawable().getBounds().width() / 2,
                v.getDrawable().getBounds().height() / 2);
            v.setImageMatrix(matrix);
            // Inverse the tag, so next run it will rotate the inverse direction
            v.setTag(!tag);
          }

          @Override
          public boolean willChangeBounds() {
            return false;
          }
        };
    a.setDuration(500);
    v.startAnimation(a);
  }
Esempio n. 18
0
 @Override
 protected void onPostExecute(Bitmap result) {
   // 回调设置图片
   ImageView imageView = (ImageView) actualListView.findViewWithTag(url);
   if (imageView != null) {
     Bitmap bitmap = getBitmapFromMemoryOrDisk(context, url, blean);
     if (null != bitmap) {
       addBitmapToMemoryCache(url, bitmap);
       if (blean) {
         bitmap = getRoundedCornerBitmap(bitmap, 10.0f);
       }
       imageView.setImageBitmap(bitmap);
       // 该url对应的task已经下载完成,从map中将其删除
       removeTaskFormMap(url);
     } else {
       imageView.setImageResource(defalutImg);
       //                    if (blean) {
       //                        imageView.setImageResource(R.drawable.icon);
       //                    } else {
       //                        imageView.setImageResource(R.drawable.moren);
       //                    }
     }
     imageView.setTag("");
   }
   super.onPostExecute(result);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    generateShuffle();

    mainLayout = (LinearLayout) findViewById(R.id.activity_main_linear_layout);
    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
    params.weight = 1f;
    for (int i = 0; i < 4; i++) {
      LinearLayout row = new LinearLayout(this);
      // row.setOrientation(LinearLayout.HORIZONTAL);
      for (int j = 0; j < 3; j++) {
        ImageView imageView = new ImageView(this);
        imageView.setTag(tag++);
        imageView.setOnClickListener(this);
        imageView.setImageResource(R.drawable.card_back);
        row.addView(imageView, params);
      }
      mainLayout.addView(row, params);
    }
  }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == RESULT_OK) {
      if (requestCode == 1) {

        Bitmap imagemFoto = BitmapFactory.decodeFile(path);
        Bitmap imagemFotoReduzida =
            Bitmap.createScaledBitmap(imagemFoto, imagemFoto.getWidth(), 300, true);

        viewImage.setImageBitmap(imagemFotoReduzida);
        viewImage.setTag(path);
        viewImage.setScaleType(ImageView.ScaleType.FIT_XY);

      } else if (requestCode == 2) {
        Uri selectedImage = data.getData();
        String[] filePath = {MediaStore.Images.Media.DATA};
        Cursor c = getContentResolver().query(selectedImage, filePath, null, null, null);
        c.moveToFirst();
        int columnIndex = c.getColumnIndex(filePath[0]);
        path = c.getString(columnIndex);
        c.close();
        Bitmap thumbnail = (BitmapFactory.decodeFile(path));
        viewImage.setImageBitmap(thumbnail);
      }
    }
  }
Esempio n. 21
0
  @Override
  public void convert(ViewHolder holder, CommentListBean s) {
    holder.setText(R.id.comment_name, s.getPath_with_namespace());
    holder.setText(R.id.comment_contribute, s.getDescription());
    ImageView imageView = (ImageView) holder.getView(R.id.comment_head);
    ImageEffectTool.ImageLoaderTool(
        mContext, 0, s.owner.getNew_portrait(), (ImageView) holder.getView(R.id.comment_head));

    //  holder.setText(R.id.text_info, s.getAuthor());
    TypefaceUtil.setIconText(
        (TextView) holder.getView(R.id.comment_detail),
        "\uf06e   "
            + s.getWatches_count()
            + "   \uf005   "
            + s.getStars_count()
            + "   \uf024   "
            + s.getStars_count()
            + "   \uf02c   "
            + s.getLanguage());

    holder.getView(R.id.comment_contribute).setTag(s);
    if (!imageView.hasOnClickListeners())
      holder.getView(R.id.comment_contribute).setOnClickListener(new ClickListner2());

    imageView.setTag(s);
    if (!imageView.hasOnClickListeners()) imageView.setOnClickListener(new ClickListner());
  }
Esempio n. 22
0
    @Override
    public Object instantiateItem(ViewGroup container, final int position) {
      String imageUrl = mAdList.get(position);
      ImageView imageView = null;
      if (mImageViewCacheList.isEmpty()) {
        imageView = new ImageView(mContext);
        imageView.setLayoutParams(
            new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        imageView.setScaleType(ImageView.ScaleType.FIT_XY);

      } else {
        imageView = mImageViewCacheList.remove(0);
      }
      // 设置图片点击监听
      imageView.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              mImageCycleViewListener.onImageClick(position, v);
            }
          });
      imageView.setTag(imageUrl);
      container.addView(imageView);
      mImageCycleViewListener.displayImage(imageUrl, imageView);
      return imageView;
    }
Esempio n. 23
0
    /** {@inheritDoc} */
    @Override
    public void bindView(View view, Context context, Cursor cursor) {
      final ViewHolder viewHolder = (ViewHolder) view.getTag();

      // Save the movie id
      viewHolder.artistId = cursor.getInt(ArtistListQuery.ARTISTID);
      viewHolder.artistName = cursor.getString(ArtistListQuery.ARTIST);

      viewHolder.nameView.setText(viewHolder.artistName);
      viewHolder.genresView.setText(cursor.getString(ArtistListQuery.GENRE));

      String thumbnail = cursor.getString(ArtistListQuery.THUMBNAIL);
      UIUtils.loadImageWithCharacterAvatar(
          context,
          hostManager,
          thumbnail,
          viewHolder.artistName,
          viewHolder.artView,
          artWidth,
          artHeight);

      // For the popupmenu
      ImageView contextMenu = (ImageView) view.findViewById(R.id.list_context_menu);
      contextMenu.setTag(viewHolder);
      contextMenu.setOnClickListener(artistlistItemMenuClickListener);
    }
Esempio n. 24
0
  private boolean displayCallStatusIconAndReturnCallPaused(
      LinearLayout callView, LinphoneCall call) {
    boolean isCallPaused, isInConference;
    ImageView callState = (ImageView) callView.findViewById(R.id.callStatus);
    callState.setTag(call);
    callState.setOnClickListener(this);

    if (call.getState() == State.Paused
        || call.getState() == State.PausedByRemote
        || call.getState() == State.Pausing) {
      callState.setImageResource(R.drawable.pause);
      isCallPaused = true;
      isInConference = false;
    } else if (call.getState() == State.OutgoingInit
        || call.getState() == State.OutgoingProgress
        || call.getState() == State.OutgoingRinging) {
      callState.setImageResource(R.drawable.call_state_ringing_default);
      isCallPaused = false;
      isInConference = false;
    } else {
      if (isConferenceRunning && call.isInConference()) {
        callState.setImageResource(R.drawable.remove);
        isInConference = true;
      } else {
        callState.setImageResource(R.drawable.play);
        isInConference = false;
      }
      isCallPaused = false;
    }

    return isCallPaused || isInConference;
  }
  private synchronized void loadLocalImage(
      ImageView imageView, String filePath, int width, int height) {
    if (MediaUtils.isValidImage(filePath)) {
      imageView.setTag(filePath);

      Bitmap bitmap = WordPress.getBitmapCache().get(filePath);
      if (bitmap != null) {
        imageView.setImageBitmap(bitmap);
      } else {
        BitmapWorkerTask task =
            new BitmapWorkerTask(
                imageView,
                width,
                height,
                new BitmapWorkerCallback() {
                  @Override
                  public void onBitmapReady(String path, ImageView imageView, Bitmap bitmap) {
                    imageView.setImageBitmap(bitmap);
                    WordPress.getBitmapCache().put(path, bitmap);
                  }
                });
        task.execute(filePath);
      }
    }
  }
        @Override
        public Object instantiateItem(ViewGroup container, final int position) {

          ImageView imageView = new ImageView(SubjectWallActivity.this);
          imageView.setLayoutParams(
              new ViewGroup.LayoutParams(
                  ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
          imageView.setTag(position);
          imageView.setScaleType(ImageView.ScaleType.FIT_XY);
          imageView.setOnClickListener(
              new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                  SubjectDetailActivity_.intent(SubjectWallActivity.this)
                      .subjectDescObject(mHotTweetDescObjects.get(position))
                      .start();
                }
              });
          getImageLoad()
              .loadImage(
                  imageView,
                  mHotTweetDescObjects.get(position).image_url,
                  ImageLoadTool.bannerOptions);
          container.addView(imageView);
          return imageView;
        }
Esempio n. 27
0
  private void processImageResponse(
      ImageResponse response, String graphObjectId, ImageView imageView) {
    pendingRequests.remove(graphObjectId);
    if (response.getError() != null) {
      callOnErrorListener(response.getError());
    }

    if (imageView == null) {
      // This was a pre-fetch request.
      if (response.getBitmap() != null) {
        // Is the cache too big?
        if (prefetchedPictureCache.size() >= MAX_PREFETCHED_PICTURES) {
          // Find the oldest one and remove it.
          String oldestId = prefetchedProfilePictureIds.remove(0);
          prefetchedPictureCache.remove(oldestId);
        }
        prefetchedPictureCache.put(graphObjectId, response);
      }
    } else if (graphObjectId.equals(imageView.getTag())) {
      Exception error = response.getError();
      Bitmap bitmap = response.getBitmap();
      if (error == null && bitmap != null) {
        imageView.setImageBitmap(bitmap);
        imageView.setTag(response.getRequest().getImageUri());
      }
    }
  }
Esempio n. 28
0
  public void setColorPreview(LinearLayout colorPreview, Integer selectedColor) {
    if (colorPreview == null) return;
    this.colorPreview = colorPreview;
    if (selectedColor == null) selectedColor = 0;
    int children = colorPreview.getChildCount();
    if (children == 0 || colorPreview.getVisibility() != View.VISIBLE) return;

    for (int i = 0; i < children; i++) {
      View childView = colorPreview.getChildAt(i);
      if (!(childView instanceof LinearLayout)) continue;
      LinearLayout childLayout = (LinearLayout) childView;
      if (i == selectedColor) {
        childLayout.setBackgroundColor(Color.WHITE);
      }
      ImageView childImage = (ImageView) childLayout.findViewById(R.id.image_preview);
      childImage.setClickable(true);
      childImage.setTag(i);
      childImage.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              if (v == null) return;
              Object tag = v.getTag();
              if (tag == null || !(tag instanceof Integer)) return;
              setSelectedColor((int) tag);
            }
          });
    }
  }
Esempio n. 29
0
  @Override
  public Object instantiateItem(ViewGroup container, int position) {

    //        Log.i(TAG, "instantiateItem: "+container.getLayoutParams().width);
    //        ImageView image = (ImageView) container.getChildAt(position);

    //        image.setLayoutParams(params);
    String url = mImageIds[position];
    ImageView imageView = new ImageView(mContext);
    imageView.setBackgroundColor(Color.RED);

    Log.i(TAG, "instantiateItem Width: " + imageView.getMeasuredWidth());
    Log.i(TAG, "instantiateItem Height " + imageView.getMeasuredHeight());
    /*ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(1200,600);
    imageView.setLayoutParams(params);*/
    imageView.setScaleType(ImageView.ScaleType.FIT_XY);
    imageView.setImageResource(R.mipmap.ic_launcher);
    /*        ViewGroup.LayoutParams lp= imageView.getLayoutParams();
    lp.width = 1200;
    lp.height = 600;
    imageView.setLayoutParams(lp);*/
    // Log.i(TAG, "instantiateItem: 123" + imageView.getLayoutParams().width);

    imageView.setTag(url);
    ImageLoader.getInstance().showBitmap(url, imageView);
    list.add(imageView);
    container.addView(imageView);
    return imageView;
  }
Esempio n. 30
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   ImageView imageView;
   if (convertView == null) {
     imageView = new ImageView(context);
     imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
     imageView.setScaleType(ScaleType.CENTER);
   } else {
     imageView = (ImageView) convertView;
   }
   imageView.setImageResource(mImageIds[position]);
   if (position < 65) imageView.setTag("[" + position + "]");
   else if (position < 100) imageView.setTag("[" + (position + 1) + "]");
   else imageView.setTag("[" + (position + 2) + "]");
   return imageView;
 }