Example usage for android.view View getTag

List of usage examples for android.view View getTag

Introduction

In this page you can find the example usage for android.view View getTag.

Prototype

@ViewDebug.ExportedProperty
public Object getTag() 

Source Link

Document

Returns this view's tag.

Usage

From source file:com.juick.android.MessagesFragment.java

private boolean canStartScroll(MotionEvent event) {
    View view = JuickMessagesAdapter.findViewForCoordinates(
            (ViewGroup) getActivity().getWindow().getDecorView(), event.getX(), event.getY());
    while (view != null) {
        Object tag = view.getTag();
        if (tag instanceof String) {
            String stag = (String) tag;
            if (stag.contains("horizontal-slider")) {
                return false;
            }//from ww  w.j av  a  2  s . co  m
        }
        if (view instanceof ImageGallery) {
            return false;
        }
        if (view.getParent() instanceof View) {
            view = (View) view.getParent();
        } else {
            break;
        }
    }
    return true;
}

From source file:co.taqat.call.LinphoneActivity.java

public void refreshAccounts() {
    if (LinphoneManager.getLc().getProxyConfigList().length > 1) {
        accountsList.setVisibility(View.VISIBLE);
        accountsList.setAdapter(new AccountsListAdapter());
        accountsList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override/*from ww w . ja  va 2  s.c  o  m*/
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                if (view != null && view.getTag() != null) {
                    int position = Integer.parseInt(view.getTag().toString());
                    LinphoneActivity.instance().displayAccountSettings(position);
                }
                openOrCloseSideMenu(false);
            }
        });
    } else {
        accountsList.setVisibility(View.GONE);
    }
    displayMainAccount();
}

From source file:com.mb.kids_mind.Adapter.SimilarListAdapterdetail.java

@Override
public View getView(final int position, View cView, ViewGroup parent) {
    ViewHolder holder = null;/*from   w w w  . j  av  a2  s.  com*/

    final SimilarItem contents = list.get(position);

    final SharedPreferences pref = mContext.getSharedPreferences("pref", mContext.MODE_PRIVATE);
    final SharedPreferences.Editor editor = pref.edit();
    if (cView == null) {
        //cView=View.inflate(mContext, layout,null);
        cView = LayoutInflater.from(mContext).inflate(layout, parent, false);
        holder = new ViewHolder();
        holder.image = (ImageView) cView.findViewById(R.id.image);
        holder.loading = (ImageView) cView.findViewById(R.id.loadingimg);
        holder.loading.setVisibility(View.GONE);
        holder.loading.setBackgroundResource(R.anim.progress);
        holder.loadinglinear = (LinearLayout) cView.findViewById(R.id.loading);
        holder.loadinglinear.setVisibility(View.GONE);
        loadingViewAnim = (AnimationDrawable) holder.loading.getBackground();

        //         holder.question=(TextView)cView.findViewById(R.id.question);
        //         holder.date=(TextView)cView.findViewById(R.id.date);
        cView.setTag(holder);
        //   Log.v(TAG,"cvew==null");
    } else {

        holder = (ViewHolder) cView.getTag();
        //   Log.v(TAG,"cvew!=null");
    }

    //holder.image.setImageResource(contents.getRes());
    //      String DirPath = Environment.getExternalStorageDirectory()
    //            .getAbsolutePath();
    //      DirPath = DirPath + "/" + "KidsMind2" + "/";
    //
    //      File cameraDir = new File(DirPath);
    //      if (!cameraDir.exists()) {
    //
    //         cameraDir.mkdirs();
    //      }
    //      File f1 = new File(cameraDir, contents.advice_image);
    //      if (f1.exists()) {
    //          holder.image.setImageURI(Uri.fromFile(f1)); 
    //         //mLoader.DisplayImage(f1.getAbsolutePath(), holder.imageView);
    //
    //      } else {
    //         new DownTask().execute(
    //               (Const.IMAGE_LOAD_URL+"/" + contents.advice_image).trim(),f1,holder.image);
    //
    //         }
    requestMyImage(holder.loading, holder.loadinglinear, holder.image, contents.advice_image);
    //      if("Q1".equals(contents.question_id)){
    //         holder.question.setText("  ");
    //      }else if("Q2".equals(contents.question_id)){
    //         holder.question.setText("  ");
    //      }else if("Q3".equals(contents.question_id)){
    //         holder.question.setText("  ");
    //      }else if("Q4".equals(contents.question_id)){
    //         holder.question.setText("  ");
    //      }
    //      String da=contents.getDate().substring(0, 9);
    //      holder.date.setText(da);

    return cView;
}

From source file:com.siso.app.adapter.MarketListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder listItemView = null;/*from   w w  w .ja  v  a  2  s.  c om*/
    if (convertView == null) {
        convertView = listContainer.inflate(this.itemViewResource, null, false);
        listItemView = new ViewHolder();
        listItemView.content = (TextView) convertView.findViewById(R.id.marketList_title);
        listItemView.priceTextView = (TextView) convertView.findViewById(R.id.marketList_price);
        listItemView.username = (TextView) convertView.findViewById(R.id.marketList_username);
        listItemView.imageView = (ImageView) convertView.findViewById(R.id.marketList_img);
        listItemView.linearLayout = (LinearLayout) convertView.findViewById(R.id.nearby);
        listItemView.likeButton = (LinearLayout) convertView.findViewById(R.id.item_goods_like);
        listItemView.likeCount = (TextView) convertView.findViewById(R.id.item_goods_like_text);
        listItemView.viewCount = (TextView) convertView.findViewById(R.id.item_goods_viewcount);
        listItemView.likeImageButton = (ImageButton) convertView.findViewById(R.id.item_goods_like_btn);
        if (type == 1) {
            listItemView.username.setVisibility(View.GONE);
            listItemView.linearLayout.setVisibility(View.VISIBLE);
            listItemView.schoolname = (TextView) convertView.findViewById(R.id.marketList_schoolname);
            listItemView.distance = (TextView) convertView.findViewById(R.id.marketList_distance);
        }
        convertView.setTag(listItemView);
    } else {
        listItemView = (ViewHolder) convertView.getTag();
    }

    final GoodsEntity tmpGoodsEntity = listItems.get(position);
    listItemView.content.setText(tmpGoodsEntity.getGoodTitle());
    listItemView.priceTextView.setText("" + tmpGoodsEntity.getGoodPrice());
    listItemView.username.setText(tmpGoodsEntity.getUserName());
    if (type == 1) {
        listItemView.schoolname.setText("?[" + tmpGoodsEntity.getSchoolName() + "]");
        listItemView.distance.setText(tmpGoodsEntity.getDistance() + "Km");
    }
    if (tmpGoodsEntity.isLike()) {
        listItemView.likeImageButton.setBackgroundResource(R.drawable.liked);
    }
    listItemView.likeCount.setText(tmpGoodsEntity.getLikeCount() + "");
    listItemView.viewCount.setText(tmpGoodsEntity.getViewCount() + "");

    listItemView.likeButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (MyApplication.userInfo == null) {
                Toast.makeText(context, context.getResources().getString(R.string.has_no_login),
                        Toast.LENGTH_SHORT).show();
                return;
            }

            ImageButton imageButton = (ImageButton) view.findViewById(R.id.item_goods_like_btn);
            TextView likeCount = (TextView) view.findViewById(R.id.item_goods_like_text);
            if (tmpGoodsEntity.isLike()) {
                postData(tmpGoodsEntity.getId(), "delete");
                tmpGoodsEntity.setLike(false);
                imageButton.setBackgroundResource(R.drawable.like);
                String textString = likeCount.getText().toString();
                if (textString != null) {
                    likeCount.setText(Integer.parseInt(textString) - 1 + "");
                }
            } else {
                postData(tmpGoodsEntity.getId(), "add");
                tmpGoodsEntity.setLike(true);
                imageButton.setBackgroundResource(R.drawable.liked);
                String textString = likeCount.getText().toString();
                if (textString != null) {
                    likeCount.setText(Integer.parseInt(textString) + 1 + "");
                }
            }

        }
    });

    if (tmpGoodsEntity.getGoodImages() != null) {
        Picasso picasso = Picasso.with(listItemView.imageView.getContext());
        picasso.load(CommonUtils.getFirstImg(tmpGoodsEntity.getGoodImages()))
                .placeholder(R.drawable.ic_img_loading).into(listItemView.imageView);
    } else {
        listItemView.imageView.setBackgroundResource(R.drawable.ic_img_loading);
    }

    return convertView;
}

From source file:com.juick.android.JuickMessagesAdapter.java

public void recycleView(View view) {
    if (view instanceof ViewGroup) {
        ListRowRuntime lrr = (ListRowRuntime) view.getTag();
        if (lrr != null) {
            if (lrr.userpicListener != null) {
                lrr.removeListenerIfExists();
            }/*from   w w w  .  ja v  a 2  s. c o m*/
        }
        ViewGroup vg = (ViewGroup) view;
        if (vg.getChildCount() > 1 && vg.getChildAt(1) instanceof ImageGallery
                && vg instanceof PressableLinearLayout) {
            PressableLinearLayout pll = (PressableLinearLayout) vg;
            // our view
            ImageGallery gallery = (ImageGallery) vg.getChildAt(1);
            Object tag = gallery.getTag();
            if (tag instanceof HashMap) {
                HashMap<Integer, ImageLoaderConfiguration> loaders = (HashMap<Integer, ImageLoaderConfiguration>) tag;
                for (ImageLoaderConfiguration imageLoader : loaders.values()) {
                    imageLoader.loader.terminate();
                }
            }
            pll.blockLayoutRequests = true;
            gallery.cleanup();
            gallery.setTag(null);
            vg.removeViewAt(1);
            vg.measure(View.MeasureSpec.makeMeasureSpec(vg.getRight() - vg.getLeft(), View.MeasureSpec.EXACTLY),
                    View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
            vg.layout(vg.getLeft(), vg.getTop(), vg.getRight(), vg.getTop() + vg.getMeasuredHeight());
            pll.blockLayoutRequests = false;
        }
    }
}

From source file:cl.smartcities.isci.transportinspector.adapters.dialogAdapters.BusSelectionAdapter.java

public View getView(final int position, View convertView, final ViewGroup parent) {
    final ViewHolder holder;
    /* set view */
    if (convertView == null) {
        convertView = inflater.inflate(R.layout.bus_selection_dialog_bus_row, parent, false);
        holder = new ViewHolder();

        /* initialize holder */
        holder.busRoute = (TextView) convertView.findViewById(R.id.bus_route);
        holder.licensePlate1 = (TextView) convertView.findViewById(R.id.license_plate_1);
        holder.licencePlate2 = (TextView) convertView.findViewById(R.id.license_plate_2);
        holder.doNotKnowIcon = (TextView) convertView.findViewById(R.id.do_not_know_icon);
        holder.doNotKnow = (LinearLayout) convertView.findViewById(R.id.do_not_know_layout);
        holder.busImage = (ImageView) convertView.findViewById(R.id.bus_image);
        holder.dropDownButton = (ImageButton) convertView.findViewById(R.id.button);
        holder.platesLayout = convertView.findViewById(R.id.bus_options);
        holder.headerLayout = convertView.findViewById(R.id.route_info);

        /* get and set typefaces */
        Typeface iconFont = Typeface.createFromAsset(this.getContext().getAssets(),
                this.getContext().getString(R.string.icon_font));
        Typeface robotoBold = Typeface.createFromAsset(this.getContext().getAssets(),
                this.getContext().getString(R.string.roboto_bold_font));
        holder.doNotKnowIcon.setTypeface(iconFont);
        holder.setHolderTypefaceBold(robotoBold);
        holder.position = position;//from   www  .  j a  v a2 s.c  om

        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
        if (activeHolder != null && holder.position == activeHolder.position) {
            activeHolder = null;
        }
    }

    holder.platesLayout.setVisibility(View.GONE);

    setUpNormalRow(holder, position);

    setBackgroundColor(holder, position);

    return convertView;

}

From source file:com.b44t.ui.ActionBar.BottomSheet.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Window window = getWindow();/*from w  w w.j a v  a2  s . c  om*/
    window.setWindowAnimations(R.style.DialogNoAnimation);
    setContentView(container, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    if (containerView == null) {
        containerView = new FrameLayout(getContext()) {
            @Override
            public boolean hasOverlappingRendering() {
                return false;
            }
        };
        containerView.setBackgroundDrawable(shadowDrawable);
        containerView.setPadding(backgroundPaddingLeft,
                (applyTopPadding ? AndroidUtilities.dp(8) : 0) + backgroundPaddingTop, backgroundPaddingLeft,
                (applyBottomPadding ? AndroidUtilities.dp(8) : 0));
    }
    if (Build.VERSION.SDK_INT >= 21) {
        containerView.setFitsSystemWindows(true);
    }
    containerView.setVisibility(View.INVISIBLE);
    container.addView(containerView, 0,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM));

    if (customView != null) {
        if (customView.getParent() != null) {
            ViewGroup viewGroup = (ViewGroup) customView.getParent();
            viewGroup.removeView(customView);
        }
        containerView.addView(customView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
                LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP));
    } else {
        int topOffset = 0;
        if (title != null) {
            TextView titleView = new TextView(getContext());
            titleView.setLines(1);
            titleView.setSingleLine(true);
            titleView.setText(title);
            titleView.setTextColor(0xff757575);
            titleView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
            titleView.setEllipsize(TextUtils.TruncateAt.MIDDLE);
            titleView.setPadding(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), AndroidUtilities.dp(8));
            titleView.setGravity(Gravity.CENTER_VERTICAL);
            containerView.addView(titleView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48));
            titleView.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    return true;
                }
            });
            topOffset += 48;
        }
        if (items != null) {
            FrameLayout rowLayout = null;
            int lastRowLayoutNum = 0;
            for (int a = 0; a < items.length; a++) {
                BottomSheetCell cell = new BottomSheetCell(getContext(), 0);
                cell.setTextAndIcon(items[a], itemIcons != null ? itemIcons[a] : 0);
                containerView.addView(cell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48,
                        Gravity.LEFT | Gravity.TOP, 0, topOffset, 0, 0));
                topOffset += 48;
                cell.setTag(a);
                cell.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dismissWithButtonClick((Integer) v.getTag());
                    }
                });
                itemViews.add(cell);
            }
        }
    }

    WindowManager.LayoutParams params = window.getAttributes();
    params.width = ViewGroup.LayoutParams.MATCH_PARENT;
    params.gravity = Gravity.TOP | Gravity.LEFT;
    params.dimAmount = 0;
    params.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND;
    if (!focusable) {
        params.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
    }
    params.height = ViewGroup.LayoutParams.MATCH_PARENT;
    window.setAttributes(params);
}

From source file:com.nttec.everychan.ui.gallery.GalleryActivity.java

private void recycleTag(GalleryItemViewTag tag, boolean cancelTask) {
    if (tag.layout != null) {
        for (int i = 0; i < tag.layout.getChildCount(); ++i) {
            View v = tag.layout.getChildAt(i);
            if (v instanceof FixedSubsamplingScaleImageView) {
                ((FixedSubsamplingScaleImageView) v).recycle();
            } else if (v != null && v.getId() == R.id.gallery_video_container) {
                try {
                    ((VideoView) v.findViewById(R.id.gallery_video_view)).stopPlayback();
                } catch (Exception e) {
                    Logger.e(TAG, "cannot release videoview", e);
                }/*from   w w  w  .  j  av  a 2 s .c o  m*/
            } else if (v != null) {
                Object gifTag = v.getTag();
                if (gifTag != null && gifTag instanceof GifDrawable) {
                    ((GifDrawable) gifTag).recycle();
                }
            }
        }
        tag.layout.removeAllViews();
    }

    if (cancelTask && tag.downloadingTask != null)
        tag.downloadingTask.cancel();
    if (tag.timer != null)
        tag.timer.cancel();
    if (tag.audioPlayer != null) {
        try {
            tag.audioPlayer.release();
        } catch (Exception e) {
            Logger.e(TAG, "cannot release audio mediaplayer", e);
        } finally {
            tag.audioPlayer = null;
        }
    }

    System.gc();
}

From source file:com.adafruit.bluefruit.le.connect.app.MainActivity.java

public void onClickScannedDevice(final View view) {
    final int groupPosition = (Integer) view.getTag();

    if (mScannedDevicesListView.isGroupExpanded(groupPosition)) {
        mScannedDevicesListView.collapseGroup(groupPosition);
    } else {// ww w  .ja v a2  s.  c o  m
        mScannedDevicesListView.expandGroup(groupPosition, true);

        // Force scrolling to view the children
        mDevicesScrollView.post(new Runnable() {
            @Override
            public void run() {
                mScannedDevicesListView.scrollToGroup(groupPosition, view, mDevicesScrollView);
            }
        });
    }
}

From source file:cn.suishen.email.activity.MessageViewFragmentBase.java

/**
 * Updates all current attachments on the attachment tab.
 *///  w  w w .  j a v a2s .c  o  m
private void updateAttachmentTab() {
    for (int i = 0, count = mAttachments.getChildCount(); i < count; i++) {
        View view = mAttachments.getChildAt(i);
        MessageViewAttachmentInfo oldInfo = (MessageViewAttachmentInfo) view.getTag();
        MessageViewAttachmentInfo newInfo = new MessageViewAttachmentInfo(getActivity(), oldInfo);
        updateAttachmentButtons(newInfo);
        view.setTag(newInfo);
    }
}