コード例 #1
2
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View view = null;
    if (convertView == null) {
      LayoutInflater inflator = context.getLayoutInflater();
      view = inflator.inflate(R.layout.filter_color_listview_row, parent, false);
      final ViewHolder viewHolder = new ViewHolder();
      viewHolder.checkbox = (CheckBox) view.findViewById(R.id.check_color);
      viewHolder.text = (TextView) view.findViewById(R.id.label_color);
      viewHolder.textcolor = (TextView) view.findViewById(R.id.color_display_txt);
      viewHolder.checkbox.setOnCheckedChangeListener(
          new CompoundButton.OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
              Model element = (Model) viewHolder.checkbox.getTag();
              element.setSelected(buttonView.isChecked());
            }
          });
      view.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View arg0) {
              // TODO Auto-generated method stub
              viewHolder.checkbox.setChecked(!viewHolder.checkbox.isChecked());
            }
          });
      view.setTag(viewHolder);
      viewHolder.checkbox.setTag(list.get(position));
    } else {
      view = convertView;
      ((ViewHolder) view.getTag()).checkbox.setTag(list.get(position));
    }
    ViewHolder holder = (ViewHolder) view.getTag();

    holder.text.setTextSize(5 * context.getResources().getDisplayMetrics().density);
    holder.checkbox.setChecked(list.get(position).isSelected());
    JSONArray object;
    try {
      object = new JSONArray(list.get(position).getName());
      final float scale = context.getResources().getDisplayMetrics().density;
      GradientDrawable gd = new GradientDrawable();
      gd.setColor(
          Color.parseColor(
              object.getString(
                  1))); // Changes this drawbale to use a single color instead of a gradient
      gd.setCornerRadius((int) (2 * scale + 0.5f));
      gd.setStroke((int) (2 * scale + 0.5f), Color.parseColor("#000000"));
      holder.textcolor.setBackgroundDrawable(gd);

      holder.text.setText(object.getString(0));
      // holder.textcolor.setBackgroundColor(Color.parseColor(object.getString(1)));
    } catch (JSONException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    return view;
  }
コード例 #2
1
  @Override
  public View getView(View convertView) {
    ViewHolder holder;
    View view;
    // We have a don't have a converView so we'll have to create a new one
    if (convertView == null || !convertView.getTag().getClass().equals(ViewHolder.class)) {
      ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.category_header_row, null);

      // Use the view holder pattern to save of already looked up subviews
      holder = new ViewHolder();
      holder.setCategoryTitleTextView((TextView) viewGroup.findViewById(R.id.categoryTitleTexView));
      viewGroup.setTag(holder);

      view = viewGroup;
    } else {
      // Get the holder back out
      view = convertView;
      holder = (ViewHolder) convertView.getTag();
    }

    // actually setup the view
    holder.getCategoryTitleTextView().setText(categoryTitle);

    return view;
  }
コード例 #3
1
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {

    int showPosition = bean.size() - 1 - position;

    DMViewHolder holder = null;
    if (convertView == null
        || convertView.getTag(R.drawable.ic_launcher + getItemViewType(showPosition)) == null) {
      switch (getItemViewType(showPosition)) {
        case TYPE_NORMAL:
          convertView = initNormalSimpleLayout(parent);
          break;
        case TYPE_MYSELF:
          convertView = initMySimpleLayout(parent);
          break;
        default:
          throw new IllegalArgumentException("dm user type is wrong");
      }
      holder = buildHolder(convertView);
      convertView.setTag(R.drawable.ic_launcher + getItemViewType(showPosition), holder);
      convertView.setTag(
          R.string.listview_index_tag, R.drawable.ic_launcher + getItemViewType(showPosition));

    } else {
      holder =
          (DMViewHolder) convertView.getTag(R.drawable.ic_launcher + getItemViewType(showPosition));
    }

    configViewFont(holder);
    configLayerType(holder);
    bindViewData(holder, showPosition);
    return convertView;
  }
コード例 #4
1
 public final void onClick(View paramView) {
   if (paramView.getTag() == null) {
     return;
   }
   int i = ((Integer) paramView.getTag()).intValue();
   hnv.nm(i);
 }
コード例 #5
0
ファイル: MMAlert.java プロジェクト: sloandev/RSADemo
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    final String textString = (String) getItem(position);
    ViewHolder holder;
    int type = types[position];
    if (convertView == null || ((ViewHolder) convertView.getTag()).type != type) {
      holder = new ViewHolder();
      if (type == TYPE_CANCEL) {
        convertView = View.inflate(context, R.layout.alert_dialog_menu_list_layout_cancel, null);
      } else if (type == TYPE_BUTTON) {
        convertView = View.inflate(context, R.layout.alert_dialog_menu_list_layout, null);
      } else if (type == TYPE_TITLE) {
        convertView = View.inflate(context, R.layout.alert_dialog_menu_list_layout_title, null);
      } else if (type == TYPE_EXIT) {
        convertView = View.inflate(context, R.layout.alert_dialog_menu_list_layout_special, null);
      }

      // holder.view = (LinearLayout) convertView.findViewById(R.id.popup_layout);
      holder.text = (TextView) convertView.findViewById(R.id.popup_text);
      holder.type = type;

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

    holder.text.setText(textString);
    return convertView;
  }
コード例 #6
0
ファイル: MemosAdapter.java プロジェクト: puma007/EverMemo
  @Override
  public void onClick(View v) {
    long span = System.currentTimeMillis() - mLastChangeStatus;
    if (span < 500) {
      return;
    }

    if (v.getTag(R.string.memo_first) != null && (Boolean) v.getTag(R.string.memo_first) == true) {
      mContext.startActivity(new Intent(mContext, MemoActivity.class));
    } else {
      switch (v.getId()) {
        case R.id.bottom:
          if (mOutItemId != 0) {
            Memo memo = (Memo) v.getTag(R.string.memo_data);
            mDeleteRecoverPanelLisener.wakeRecoveryPanel(memo);
            setOpenerItem(0);
            mContext
                .getContentResolver()
                .delete(
                    ContentUris.withAppendedId(MemoProvider.MEMO_URI, memo.getId()), null, null);
          }
          break;
        case R.id.hover:
          Intent intent = new Intent(mContext, MemoActivity.class);
          intent.putExtra("memo", (Memo) v.getTag(R.string.memo_data));
          mContext.startActivity(intent);
          break;
        default:
          break;
      }
    }
  }
コード例 #7
0
ファイル: MainActivity.java プロジェクト: naosim/QueuigSample
  @Override
  public void onClick(View v) {
    v.getTag();
    Task<String> task =
        new Task<String>("hoge" + (count++)) {

          @Override
          public void run(String userData) {
            try {
              Thread.sleep(1000);
            } catch (InterruptedException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }

            Log.e("Exe", userData);
          }

          @Override
          public void cancel() {}
        };

    if (((Boolean) v.getTag()).booleanValue()) {
      taskExecutor.addTaskToFirst(task);
    } else {
      taskExecutor.addTask(task);
    }
  }
コード例 #8
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   if (inflater == null) {
     inflater = LayoutInflater.from(getContext());
   }
   ViewHolder h;
   if (convertView != null
       && convertView.getTag() != null
       && convertView.getTag() instanceof ViewHolder) {
     h = (ViewHolder) convertView.getTag();
   } else {
     convertView = inflater.inflate(R.layout.list_item_select_address_to_send, null);
     h = new ViewHolder(convertView);
     convertView.setTag(h);
   }
   AddressBalance a = getItem(position);
   h.tvAddress.setText(a.address.getShortAddress());
   h.tvBalance.setText(GenericUtils.formatValueWithBold(a.balance));
   if (a.address.hasPrivKey()) {
     h.ivType.setImageResource(R.drawable.address_type_private);
   } else {
     h.ivType.setImageResource(R.drawable.address_type_watchonly);
   }
   h.ibtnAddressFull.setVisibility(View.GONE);
   convertView.setOnClickListener(new ListItemClick(a));
   return convertView;
 }
コード例 #9
0
ファイル: Adapter.java プロジェクト: slavabulgakov/BusesSpb
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
      convertView = _inflater.inflate(R.layout.listitem_selectroute, parent, false);
      _setViewHolder(convertView);
    } else if (((TransportCellViewHolder) convertView.getTag()).needInflate) {
      convertView = _inflater.inflate(R.layout.listitem_selectroute, parent, false);
      _setViewHolder(convertView);
    }

    TransportCellViewHolder vh = (TransportCellViewHolder) convertView.getTag();

    vh.leftText.setText(getItem(position).routeNumber);
    Pair<Integer, Integer> res = vh.backgroundAndIconByKind(getItem(position).kind);
    convertView.setBackgroundResource(res.first);
    vh.leftIcon.setImageResource(res.second);

    String fullName = getItem(position).fullName;
    TextView fullNameTextView = vh.rightText;
    if (fullName == null) {
      fullNameTextView.setVisibility(View.INVISIBLE);
    } else {
      fullNameTextView.setText(fullName);
      fullNameTextView.setVisibility(View.VISIBLE);
    }

    return convertView;
  }
コード例 #10
0
  public View getViewSeparator(int position, View convertView, ViewGroup parent) {
    View v = convertView;
    ViewHolder holder;

    /* convertView may be a recycled view but we must recreate it
     * if it does not correspond to a separator view. */
    boolean b_createView = true;
    if (v != null) {
      holder = (ViewHolder) v.getTag();
      if (holder.viewType == VIEW_SEPARATOR) b_createView = false;
    }

    if (b_createView) {
      LayoutInflater inflater =
          (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      v = inflater.inflate(R.layout.audio_browser_separator, parent, false);
      holder = new ViewHolder();
      holder.layout = v.findViewById(R.id.layout_item);
      holder.title = (TextView) v.findViewById(R.id.title);
      holder.viewType = VIEW_SEPARATOR;
      v.setTag(holder);
    } else holder = (ViewHolder) v.getTag();

    ListItem item = getItem(position);
    holder.title.setText(item.mTitle);

    return v;
  }
コード例 #11
0
  public View getViewMedia(int position, View convertView, ViewGroup parent) {
    View v = convertView;
    ViewHolder holder;

    /* convertView may be a recycled view but we must recreate it
     * if it does not correspond to a media view. */
    boolean b_createView = true;
    if (v != null) {
      holder = (ViewHolder) v.getTag();
      if (holder.viewType == VIEW_MEDIA) b_createView = false;
    }

    if (b_createView) {
      LayoutInflater inflater =
          (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      v = inflater.inflate(R.layout.audio_browser_item, parent, false);
      holder = new ViewHolder();
      holder.layout = v.findViewById(R.id.layout_item);
      holder.title = (TextView) v.findViewById(R.id.title);
      Util.setAlignModeByPref(mAlignMode, holder.title);
      holder.cover = (ImageView) v.findViewById(R.id.cover);
      holder.subtitle = (TextView) v.findViewById(R.id.subtitle);
      holder.footer = v.findViewById(R.id.footer);
      holder.more = (ImageView) v.findViewById(R.id.item_more);
      holder.viewType = VIEW_MEDIA;
      v.setTag(holder);
    } else holder = (ViewHolder) v.getTag();

    ListItem item = getItem(position);
    holder.title.setText(item.mTitle);

    RelativeLayout.LayoutParams paramsCover;
    if (mItemType == ITEM_WITH_COVER) {
      Media media = mItems.get(position).mMediaList.get(0);
      Bitmap cover = AudioUtil.getCover(v.getContext(), media, 64);
      if (cover == null) cover = BitmapCache.GetFromResource(v, R.drawable.icon);
      holder.cover.setImageBitmap(cover);
      int size = (int) mContext.getResources().getDimension(R.dimen.audio_browser_item_size);
      paramsCover = new RelativeLayout.LayoutParams(size, size);
    } else
      paramsCover = new RelativeLayout.LayoutParams(0, RelativeLayout.LayoutParams.WRAP_CONTENT);
    holder.cover.setLayoutParams(paramsCover);

    holder.subtitle.setVisibility(item.mSubTitle == null ? TextView.GONE : TextView.VISIBLE);
    holder.subtitle.setText(item.mSubTitle);

    // Remove the footer if the item is just above a separator.
    holder.footer.setVisibility(isMediaItemAboveASeparator(position) ? View.GONE : View.VISIBLE);

    final int pos = position;
    holder.more.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            if (mContextPopupMenuListener != null) mContextPopupMenuListener.onPopupMenu(v, pos);
          }
        });

    return v;
  }
コード例 #12
0
  @Override
  public View getView(int position, View itemView, ViewGroup parent) {
    View v = itemView;
    if (v == null) {
      LayoutInflater vi =
          (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      v = vi.inflate(R.layout.grocery_list_item, null);
      ViewHolder vh = new ViewHolder();
      vh.label = (TextView) v.findViewById(R.id.label);
      vh.icon = (ImageView) v.findViewById(R.id.icon);
      v.setTag(vh);
    }

    TextView label = ((ViewHolder) v.getTag()).label;
    Row row = getRow(position);
    JsonNode item = row.getValueAsNode();
    JsonNode itemText = item.get("text");
    if (itemText != null) {
      label.setText(itemText.getTextValue());
    } else {
      label.setText("");
    }

    ImageView icon = ((ViewHolder) v.getTag()).icon;
    JsonNode checkNode = item.get("check");
    if (checkNode != null) {
      if (checkNode.getBooleanValue()) {
        icon.setImageResource(R.drawable.list_area___checkbox___checked);
      } else {
        icon.setImageResource(R.drawable.list_area___checkbox___unchecked);
      }
    }

    return v;
  }
コード例 #13
0
 @Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   // display view for selected nav drawer item
   displayView(
       Integer.valueOf((String) view.getTag(R.string.cat_type)),
       Integer.valueOf((String) view.getTag(R.string.cat_id)));
 }
コード例 #14
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    Cursor cursor = this.getCursor();
    cursor.moveToPosition(position);
    long dateMilliseconds = cursor.getLong(cursor.getColumnIndex(ChatProvider.ChatConstants.DATE));
    String date = TimeUtil.getChatTime(dateMilliseconds);
    String message = cursor.getString(cursor.getColumnIndex(ChatProvider.ChatConstants.MESSAGE));
    String jid = cursor.getString(cursor.getColumnIndex(ChatProvider.ChatConstants.JID));

    String selection =
        ChatConstants.JID
            + " = '"
            + jid
            + "' AND "
            + ChatConstants.DIRECTION
            + " = "
            + ChatConstants.INCOMING
            + " AND "
            + ChatConstants.DELIVERY_STATUS
            + " = "
            + ChatConstants.DS_NEW; // 新消息数量字段
    Cursor msgcursor =
        mContentResolver.query(
            ChatProvider.CONTENT_URI,
            new String[] {
              "count(" + ChatConstants.PACKET_ID + ")", ChatConstants.DATE, ChatConstants.MESSAGE
            },
            selection,
            null,
            SORT_ORDER);
    msgcursor.moveToFirst();
    int count = msgcursor.getInt(0);
    ViewHolder viewHolder;
    if (convertView == null
        || convertView.getTag(R.drawable.ic_launcher + (int) dateMilliseconds) == null) {
      convertView = mLayoutInflater.inflate(R.layout.recent_listview_item, parent, false);
      viewHolder = buildHolder(convertView, jid);
      convertView.setTag(R.drawable.ic_launcher + (int) dateMilliseconds, viewHolder);
      convertView.setTag(R.string.app_name, R.drawable.ic_launcher + (int) dateMilliseconds);
    } else {
      viewHolder = (ViewHolder) convertView.getTag(R.drawable.ic_launcher + (int) dateMilliseconds);
    }
    viewHolder.jidView.setText(XMPPHelper.splitJidAndServer(jid));
    viewHolder.msgView.setText(
        XMPPHelper.convertNormalStringToSpannableString(mContext, message, true));
    viewHolder.dataView.setText(date);

    if (msgcursor.getInt(0) > 0) {
      viewHolder.msgView.setText(
          msgcursor.getString(msgcursor.getColumnIndex(ChatConstants.MESSAGE)));
      viewHolder.dataView.setText(
          TimeUtil.getChatTime(msgcursor.getLong(msgcursor.getColumnIndex(ChatConstants.DATE))));
      viewHolder.unReadView.setText(msgcursor.getString(0));
    }
    viewHolder.unReadView.setVisibility(count > 0 ? View.VISIBLE : View.GONE);
    viewHolder.unReadView.bringToFront();
    msgcursor.close();

    return convertView;
  }
コード例 #15
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_slope, container, false);
    slopeRG1 = (RadioGroup) root.findViewById(R.id.slopeRadioGroup1);
    slopeRG2 = (RadioGroup) root.findViewById(R.id.slopeRadioGroup2);
    slopeRG1.clearCheck(); // this is so we can start fresh, with no selection on both RadioGroups
    slopeRG2.clearCheck();
    // slopeRG1.setOnCheckedChangeListener(slopeListener1);
    // slopeRG2.setOnCheckedChangeListener(slopeListener2);

    for (int i = 0; i < slopeRG1.getChildCount(); i++) {
      // slopeChoices.add((String)slopeRG1.getChildAt(i).getTag());
      View v = slopeRG1.getChildAt(i);
      if (v instanceof RadioButton) {
        slopeChoices.add((String) v.getTag());
      }
    }
    for (int i = 0; i < slopeRG2.getChildCount(); i++) {
      // slopeChoices.add((String)slopeRG2.getChildAt(i).getTag());
      View v = slopeRG2.getChildAt(i);
      if (v instanceof RadioButton) {
        slopeChoices.add((String) v.getTag());
      }
    }

    Button clinometerB = (Button) root.findViewById(R.id.fragment_slope_clinometerButton);
    clinometerB.setOnClickListener(this);

    slopeTV = (TextView) root.findViewById(R.id.fragment_slope_clinometerResult);
    slopeTV.setVisibility(View.GONE);

    return root;
  }
コード例 #16
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   if (!favoritos) {
     Holder holder;
     if (convertView == null) {
       convertView = layoutInflater.inflate(R.layout.onibus_listview, null);
       holder = new Holder();
       holder.linhaNome = (TextView) convertView.findViewById(R.id.linha_nome);
       convertView.setTag(holder);
     } else {
       holder = (Holder) convertView.getTag();
     }
     Onibus onibus = lista.get(position);
     holder.linhaNome.setText(onibus.getLinha() + " - " + onibus.getNome());
   } else {
     Holder holder;
     if (convertView == null) {
       convertView = layoutInflater.inflate(R.layout.favoritos_listview, null);
       holder = new Holder();
       holder.linhaNome = (TextView) convertView.findViewById(R.id.linha_nome_favorito);
       convertView.setTag(holder);
     } else {
       holder = (Holder) convertView.getTag();
     }
     Onibus onibus = lista.get(position);
     holder.linhaNome.setText(onibus.getLinha() + " - " + onibus.getNome());
   }
   return convertView;
 }
コード例 #17
0
ファイル: StopListAdapter.java プロジェクト: Rrego6/GTNextBus
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
      LayoutInflater mInflater =
          (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
      convertView = mInflater.inflate(R.layout.card, null);
      holder.mText = (TextView) convertView.findViewById(R.id.stop);
      holder.imgIcon = (ImageView) convertView.findViewById(R.id.card_image);
      convertView.setTag(R.id.id_one, holder.mText);
      convertView.setTag(R.id.id_two, holder.imgIcon);
    } else {
      holder.mText = (TextView) convertView.getTag(R.id.id_one);
      holder.imgIcon = (ImageView) convertView.getTag(R.id.id_two);
    }

    holder.mText.setText(stopItems.get(position).getTitle());
    holder.mText.setTextColor(Color.parseColor(color));
    if (position == 0) {
      holder.mText.setTypeface(null, Typeface.BOLD_ITALIC);
      holder.mText.setTextSize(30);
    } else {
      holder.mText.setTextSize(20);
      holder.mText.setTypeface(null, Typeface.ITALIC);
    }

    if (!stopItems.get(position).getIconVisibility()) {
      holder.imgIcon.setVisibility(View.GONE);
    }

    return convertView;
  }
コード例 #18
0
  // /防止内存不够用
  @Override
  protected void onSaveInstanceState(Bundle outState) {

    // 内容
    outState.putString("content", contentEditText.getText().toString());
    // 地点
    outState.putString("location", locationString);
    // 图片
    ArrayList<String> imageList = new ArrayList<String>();
    int subviewsCount = addImageLayout.getChildCount();
    for (int i = 0; i < subviewsCount; i++) {
      View view = addImageLayout.getChildAt(i);
      if (null != view.getTag() && view != addImageView) {
        if (view.getTag() instanceof String) {
          imageList.add((String) view.getTag());
        }
      }
    }
    outState.putStringArrayList("images", imageList);
    if (null != tmpImageName && tmpImageName.length() > 0) {
      // 刚拍的照片
      outState.putString("tmpImageName", tmpImageName);
    }

    super.onSaveInstanceState(outState);
  }
コード例 #19
0
  public static boolean onViewClicked(Context context, View view) {
    if (view == null) return false;

    final Integer changeNumber = (Integer) view.getTag(R.id.changeNumber);
    final String filePath = (String) view.getTag(R.id.filePath);
    final Integer patchset = (Integer) view.getTag(R.id.patchSetNumber);

    if (changeNumber == null) return false;

    // If the server does not support diffs then do not show the dialog
    if (!Config.isDiffSupported(context)) {
      Tools.launchDiffInBrowser(context, changeNumber, patchset, filePath);
      return true;
    }

    PrefsFragment.DiffModes mode = PrefsFragment.getDiffDefault(context);
    if (mode == PrefsFragment.DiffModes.INTERNAL) {
      Tools.launchDiffViewer(context, changeNumber, patchset, filePath);
    } else if (mode == PrefsFragment.DiffModes.EXTERNAL) {
      Tools.launchDiffInBrowser(context, changeNumber, patchset, filePath);
    } else {
      Tools.launchDiffOptionDialog(context, changeNumber, patchset, filePath);
    }

    return true;
  }
コード例 #20
0
ファイル: MessagesAdapter.java プロジェクト: torresjeff/Yora
 @Override
 public void onClick(View view) {
   if (view.getTag() instanceof Message) {
     Message message = (Message) view.getTag();
     listener.onMessageClicked(message);
   }
 }
コード例 #21
0
 @Override
 public void willSwitchFromPhoto(
     MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) {
   int count = listView.getChildCount();
   for (int a = 0; a < count; a++) {
     View view = listView.getChildAt(a);
     if (view.getTag() == null) {
       continue;
     }
     PhotoPickerPhotoCell cell = (PhotoPickerPhotoCell) view;
     int num = (Integer) view.getTag();
     if (selectedAlbum != null) {
       if (num < 0 || num >= selectedAlbum.photos.size()) {
         continue;
       }
     } else {
       ArrayList<MediaController.SearchImage> array;
       if (searchResult.isEmpty() && lastSearchString == null) {
         array = recentImages;
       } else {
         array = searchResult;
       }
       if (num < 0 || num >= array.size()) {
         continue;
       }
     }
     if (num == index) {
       cell.checkBox.setVisibility(View.VISIBLE);
       break;
     }
   }
 }
コード例 #22
0
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
      final View view;
      ViewHolder vh;
      MyCell cell = (MyCell) getItem(position);

      if (convertView == null) {
        view = mInflater.inflate(R.layout.chain_cell, parent, false);
        setViewHolder(view);
      } else if (((ViewHolder) convertView.getTag()).needInflate) {
        view = mInflater.inflate(R.layout.chain_cell, parent, false);
        setViewHolder(view);
      } else {
        view = convertView;
      }

      vh = (ViewHolder) view.getTag();
      vh.text.setText(cell.name);
      vh.imageButton.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              deleteCell(view, position);
            }
          });

      return view;
    }
コード例 #23
0
  public void onClick(View v) {

    Log.v(TAG, "onClick" + v.getTag());
    String[] params = (String[]) v.getTag();
    Long babyId = Long.parseLong(params[0]);
    String babyName = params[1];

    switch (v.getId()) {
      case R.id.baby_select:
        MainActivity.ACTIVE_BABY_ID = babyId;
        MainActivity.ACTIVE_BABY_NAME = babyName;
        ((MainActivity) context)
            .handleFragments(
                new ActivitiesFragment(), ActivitiesFragment.TAG, ActivitiesFragment.KEEP_IN_STACK);
        break;
      case R.id.baby_edit:
        MainActivity.ACTIVE_BABY_ID = babyId;
        ((MainActivity) context)
            .handleFragments(
                new BabyProfileFragment(),
                BabyProfileFragment.TAG,
                BabyProfileFragment.KEEP_IN_STACK);
        break;
    }
  }
コード例 #24
0
ファイル: ExampleAdapter.java プロジェクト: ajrulez/ListBoost
  @Override
  public View getChildView(
      final int groupPosition,
      final int childPosition,
      boolean isLastChild,
      View convertView,
      ViewGroup parent) {

    if (convertView == null) {

      if (inflater == null) inflater = LayoutInflater.from(ctx);

      convertView = inflater.inflate(R.layout.expandable_list_child_item, null);
    }

    if (convertView.getTag() == null) {
      mHolder = new ExampleHolder();

      mHolder.mTitle = (TextView) convertView.findViewById(R.id.title);

      convertView.setTag(mHolder);
    } else mHolder = (ExampleHolder) convertView.getTag();

    mHolder.mTitle.setText(getChild(groupPosition, childPosition).toString());
    return convertView;
  }
  private void hideListItemsMenu(View v, boolean close) {
    boolean toBeHidden = false;
    for (int index = 0; index < list.getChildCount(); index++) {
      View view = list.getChildAt(index);
      if (view instanceof ViewSwitcher && ((ViewSwitcher) view).getDisplayedChild() == 1) {
        ((ViewSwitcher) view).showPrevious();
        toBeHidden = true;
        getPoiAdapter().setElementSelected(-1);
        postitionSelected = -1;
      }
    }
    if (!toBeHidden && v != null && v.getTag() != null && !close) {
      // no items needed to be flipped, fill and open details page
      FragmentTransaction fragmentTransaction =
          getSherlockActivity().getSupportFragmentManager().beginTransaction();
      PoiDetailsFragment fragment = new PoiDetailsFragment();

      Bundle args = new Bundle();
      args.putString(PoiDetailsFragment.ARG_POI_ID, ((PoiPlaceholder) v.getTag()).poi.getId());
      fragment.setArguments(args);

      fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
      // fragmentTransaction.detach(this);
      fragmentTransaction.replace(R.id.fragment_container, fragment, "pois");
      fragmentTransaction.addToBackStack(fragment.getTag());
      fragmentTransaction.commit();
    }
  }
コード例 #26
0
  @Override
  public void initListCell(int position, View listCell) {

    ListCellHolder listCellHolder;

    if (listCell.getTag() != null) {
      listCellHolder = (ListCellHolder) listCell.getTag();
    } else {
      ListCellHolder holder = new ListCellHolder();
      holder.setIvIcon((ImageView) listCell.findViewById(R.id.ivIcon));
      holder.setTvLabel((TextView) listCell.findViewById(R.id.tvLabel));
      listCell.setTag(holder);

      listCellHolder = holder;
    }

    ListCellData data = getItem(position);
    if (data.getIconBitmap() != null) {
      listCellHolder.getIvIcon().setImageBitmap(data.getIconBitmap());
    } else {
      listCellHolder.getIvIcon().setImageResource(R.drawable.ic_launcher);
      data.loadIconOnce(this);
    }
    listCellHolder.getTvLabel().setText(data.getLabel());
  }
コード例 #27
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    View view = null;
    ViewHolder holder = null;
    if (convertView == null || convertView.getTag() == null) {
      view = mLayoutInflater.inflate(R.layout.list_item, null);
      holder = new ViewHolder(view);
      /*
       * holder.imgFileIcon=(ImageView)view.findViewById(R.id.
       * imgSearchFileIcon);
       * holder.imgFileSelectIcon=(ImageView)view.findViewById
       * (R.id.imFileSelectIcon);
       */
      view.setTag(holder);
    } else {
      view = convertView;
      holder = (ViewHolder) convertView.getTag();
    }

    String text = getItem(position);
    // TODO

    holder.listText.setText(text);

    updateIsChecked(position, holder.listImgIcon);
    return view;
  }
コード例 #28
0
  /**
   * @param index 小于0则顺序插入(插入至最末尾);大于等于0则按指定索引值(index)插入
   * @param childView
   * @return
   */
  public boolean addChildView(int index, View childView) {
    if (childViews.contains(childView)) {
      return false;
    }

    if (null == childView.getTag()) {
      // 结构层操作
      // tag为null说明此view在添加至文件夹内之前是处于桌面上的,所以需要将其从根文件夹对象中删除
      GlobalDataCacheForMemorySingleton.getInstance
          .getRootDirectory()
          .getListFiles()
          .remove(((DragView) childView).getBookFile());
    } else {
      ((BookFolderLayout) childView.getTag()).removeChildView(childView, true);
    }

    if (null != childView.getParent()) {
      ((ViewGroup) childView.getParent()).removeView(childView);
    }

    if (index < 0) {
      childViews.add(childView);
    } else {
      childViews.add(index, childView);
    }

    // 生成缩略图控件
    BookThumbnailLayout bookThumbnailLayout = new BookThumbnailLayout(getContext());
    bookThumbnailLayout.bind((BookShelfBookCell) childView);
    childView.setTag(R.id.bookThumbnailView, bookThumbnailLayout);

    MyGridLayout.LayoutParams layoutParams = new MyGridLayout.LayoutParams();
    layoutParams.width = (int) getResources().getDimension(R.dimen.book_cell_width) / 3;
    layoutParams.height = (int) getResources().getDimension(R.dimen.book_image_height) / 3;
    layoutParams.topMargin = 4;
    layoutParams.leftMargin = 4;
    layoutParams.rightMargin = 4;
    layoutParams.bottomMargin = 4;

    // 顺序插入时,封面只显示前4本书
    if (index < 0) {
      if (gridLayout.getChildCount() < 4) {
        gridLayout.addView(bookThumbnailLayout, layoutParams);
      }
    }

    // 指定插入时,若索引值小于4则需将封面上多余的一张缩略图(即原第4张)删除
    else if (index < 4) {
      if (gridLayout.getChildCount() == 4) {
        gridLayout.removeViewAt(3);
      }
      gridLayout.addView(bookThumbnailLayout, index, layoutParams);
    }

    childView.setTag(this);

    updateFrontCover(); // 刷新封面

    return true;
  }
コード例 #29
0
    @Override
    public boolean onTouch(View v, MotionEvent event) {
      switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
          return true;
        case MotionEvent.ACTION_UP:
          if (event.getRawX()
              >= (v.getRight() - ((TextView) v).getCompoundDrawables()[2].getBounds().width())) {
            // 响应右侧图标点击事件
            Intent intent = new Intent(context, TerminalSubmitActivity.class);
            intent.putExtra("operate", "modify");
            intent.putExtra("terminalid", ((String) v.getTag()).split(",")[0]);
            ((Activity) context).startActivityForResult(intent, 0);
          } else {
            // 响应自己的点击事件
            if (!v.performClick()) {
              // 响应ListView点击事件
              int position = Integer.parseInt(((String) v.getTag()).split(",")[1]) + 1;
              listView.performItemClick(
                  listView.getChildAt(position - listView.getFirstVisiblePosition()),
                  position,
                  listView.getItemIdAtPosition(position));
            }
          }
      }

      return false;
    }
コード例 #30
0
 @Override
 public void onClick(View v) {
   mUpdateView = null;
   mNewsItem = null;
   switch (v.getId()) {
     case R.id.news_img: // 新闻图标
       String imageLink = (String) v.getTag(R.id.new_image_link_tag);
       if (TextUtils.isEmpty(imageLink)) {
         Toast.makeText(getApplicationContext(), "图标没有连接 ", Toast.LENGTH_SHORT).show();
       } else {
         startBrowser(imageLink, -1);
       }
       break;
     case R.id.news_context_item: // 新闻item
       String ling = (String) v.getTag(R.id.new_item_link_tag);
       mUpdateView = v;
       if (TextUtils.isEmpty(ling)) {
         Toast.makeText(getApplicationContext(), "item没有连接", Toast.LENGTH_SHORT).show();
       } else {
         mNewsItem = (NewsItem) v.getTag(R.id.new_item_obj);
         startBrowser(ling, mNewsItem.readStatus == 1 ? -1 : mNewsItem._id);
       }
       break;
     default:
       break;
   }
 }