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:andlabs.lounge.lobby.ui.LobbyFragment.java

@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
    Ln.v(" groupPosition = %d, childPosition = %d", groupPosition, childPosition);
    Game game = (Game) mLobbyAdapter.getGroup(groupPosition);
    Match match = (Match) mLobbyAdapter.getChild(groupPosition, childPosition);
    Ln.d(" game = %s, match = %s", game, match);

    // If the game is open...
    if ((Integer) v.getTag() == LobbyListAdapter.TYPE_OPENGAME) {
        final String gameID = game.gameID;
        if (Utils.isGameInstalled(getActivity(), gameID)) { // ...and installed, join it...
            mLoungeLobbyController.joinMatch(gameID, match.matchID);
        } else { // ...otherwise, open the play store
            Utils.openPlay(getActivity(), gameID);
        }// ww  w.  j a  v  a 2  s  . co m
    } else {
        if ("running".equalsIgnoreCase(match.status)) {
            // If the game is already running, and you are involved
            Intent intent = Utils.launchGameApp(getActivity(), game.gameID, match);
            if (intent != null) {
                getActivity().startActivity(intent);
                getActivity().finish();
            }
        } else {
            Toast.makeText(getActivity(), "Game not started yet", Toast.LENGTH_LONG).show();
        }
    }
    return false;
}

From source file:com.hybris.mobile.app.commerce.adapter.OrderProductListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {

    View rowView;

    if (convertView == null) {
        LayoutInflater inflater = (LayoutInflater) getContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        rowView = inflater.inflate(R.layout.item_order_product, parent, false);
        rowView.setTag(new OrderViewHolder(rowView, position));
    } else {//from   w w  w  .  jav  a 2 s.  co  m
        rowView = convertView;
    }

    final OrderViewHolder orderViewHolder = (OrderViewHolder) rowView.getTag();

    final OrderEntry orderProduct = mProducts.get(position);
    if (orderProduct != null) {
        // Name
        orderViewHolder.productNameTextView.setText(orderProduct.getProduct().getName());

        // Price
        if (orderProduct.getBasePrice() != null) {
            orderViewHolder.productPrice.setText(orderProduct.getBasePrice().getFormattedValue());
        }

        // Promotion
        if (orderProduct.getPromotionResult() != null) {
            if (StringUtils.isNotBlank(orderProduct.getPromotionResult().getDescription())) {
                orderViewHolder.productPromotion.setText(orderProduct.getPromotionResult().getDescription());
            }

            orderViewHolder.productPromotion.setVisibility(View.VISIBLE);
        } else {
            orderViewHolder.productPromotion.setVisibility(View.GONE);

        }

        // Variants
        if (orderProduct.getProduct().getBaseOptions() != null
                && !orderProduct.getProduct().getBaseOptions().isEmpty()) {
            orderViewHolder.linearLayoutVariants.setVisibility(View.VISIBLE);
            orderViewHolder.linearLayoutVariants.removeAllViews();
        }

        // Redirecting to the product detail page when clicking on the image
        orderViewHolder.orderItemClickableLyout.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                ProductHelper.redirectToProductDetail(getContext(), orderProduct.getProduct().getCode());
            }
        });

        // Loading the product image
        if (StringUtils.isNotBlank(orderProduct.getProduct().getImageThumbnailUrl())) {
            CommerceApplication.getContentServiceHelper().loadImage(
                    orderProduct.getProduct().getImageThumbnailUrl(), null, orderViewHolder.productImageView, 0,
                    0, true, null, true);
        }

        // Quantity
        orderViewHolder.quantityTextView
                .setText(getContext().getString(R.string.order_confirmation_qty, orderProduct.getQuantity()));

        // Total price
        if (orderProduct.getTotalPrice() != null) {
            orderViewHolder.productTotalPrice.setText(orderProduct.getTotalPrice().getFormattedValue());
        }

    }
    return rowView;
}

From source file:cn.newgxu.android.bbs.activity.ViewTopicActivity.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.send_reply_icon:
        Toast.makeText(this, "send click!", Toast.LENGTH_SHORT).show();
        break;// w w  w . ja v a2 s.  c o  m
    default:
        Toast.makeText(this, "user click!", Toast.LENGTH_SHORT).show();
        FragmentManager fm = getSupportFragmentManager();
        if (fm.findFragmentByTag(Consts.USER) == null) {
            UserFragment fragment = new UserFragment();
            Bundle args = new Bundle();
            final String str = v.getTag().toString();
            Log.d(TAG, str);
            args.putInt(Consts.UID, Integer.parseInt(str));
            fragment.setArguments(args);
            getSupportActionBar().setTitle(R.string.user_info);
            getSupportActionBar().setSubtitle(null);
            fm.beginTransaction().replace(R.id.fragment_container, fragment, Consts.USER).addToBackStack(null)
                    .commit();
        }
        break;
    }
}

From source file:com.aboveware.sms.contacts.ContactSuggestionsAdapter.java

@Override
public void bindView(View view, Context context, Cursor cursor) {
    ChildViewCache views = (ChildViewCache) view.getTag();

    contact = PadContacts.getPadContact(Long.parseLong(cursor.getString(mIconName2Col)));
    int flags = 0;
    if (mFlagsCol != INVALID_INDEX) {
        flags = cursor.getInt(mFlagsCol);
    }/*from   w  ww  . j a  va2 s.c  om*/
    if (views.mText1 != null) {
        String text1 = getStringOrNull(cursor, mText1Col);
        setViewText(views.mText1, text1);
    }
    if (views.mText2 != null) {
        // First check TEXT_2_URL
        CharSequence text2 = getStringOrNull(cursor, mText2UrlCol);
        if (text2 != null) {
            text2 = formatUrl(text2);
        } else {
            text2 = getStringOrNull(cursor, mText2Col);
        }

        // If no second line of text is indicated, allow the first line of text
        // to be up to two lines if it wants to be.
        if (TextUtils.isEmpty(text2)) {
            if (views.mText1 != null) {
                views.mText1.setSingleLine(false);
                views.mText1.setMaxLines(2);
            }
        } else {
            if (views.mText1 != null) {
                views.mText1.setSingleLine(true);
                views.mText1.setMaxLines(1);
            }
        }
        setViewText(views.mText2, text2);
    }

    if (views.mIcon1 != null) {
        setViewDrawable(views.mIcon1, getIcon1(cursor), View.GONE);
    }
    if (views.mIcon2 != null) {
        setViewDrawable(views.mIcon2, getIcon2(cursor), View.GONE);
    }
    if (mQueryRefinement == REFINE_ALL
            || (mQueryRefinement == REFINE_BY_ENTRY && (flags & SearchManager.FLAG_QUERY_REFINEMENT) != 0)) {
        views.mIconRefine.setVisibility(View.VISIBLE);
        views.mIconRefine.setTag(views.mText1.getText());
        views.mIconRefine.setOnClickListener(this);
    } else {
        views.mIconRefine.setVisibility(View.GONE);
    }
}

From source file:com.blueverdi.rosietheriveter.SitesFragment.java

public void onClick(View v) {
    switch (v.getId()) {
    case R.id.infoButton:
        Intent i = new Intent(getActivity(), SiteActivity.class);
        Site s = (Site) v.getTag();
        i.putExtra(Site.PARCEL_NAME, s);
        SiteDetails sd = s.getDetails();
        if (sd != null) {
            i.putExtra(SiteDetails.PARCEL_NAME, sd);
        }//w w  w .  j  a  v  a  2s  .  c om
        startActivity(i);
        getActivity().overridePendingTransition(R.anim.zoom_in, 0);
        break;
    case R.id.tourButton:
        s = (Site) v.getTag();
        if (myTour.getSiteByName(s.getString(Site.NAME)) == null) {
            myTour.addSite(s);
        }
        Toast.makeText(getActivity(), getString(R.string.added_to_tour), Toast.LENGTH_SHORT).show();
    }
}

From source file:com.notalenthack.blaster.CommandActivity.java

@Override
public void onClick(View v) {
    Integer position = (Integer) v.getTag();
    if (v.getId() == R.id.btnEditCommand) {
        final Command cmd = mListAdapter.getCommand(position);
        Log.d(TAG, "Edit button click for position " + position);
        //Creating the instance of PopupMenu
        PopupMenu popup = new PopupMenu(this, v);
        //Inflating the Popup using xml file
        popup.getMenuInflater().inflate(R.menu.edit_delete, popup.getMenu());
        popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
            @Override//from   w w  w  .j a va 2 s  .c  o m
            public boolean onMenuItemClick(MenuItem item) {
                if (item.getItemId() == R.id.edit) {
                    editCommand(cmd);
                } else if (item.getItemId() == R.id.delete) {
                    mListAdapter.deleteCommand(cmd);
                } else {
                    return false;
                }
                saveCommands(); // update commands in pref for presistent
                mListAdapter.notifyDataSetChanged();
                return true;
            }
        });

        // show the popup
        popup.show();

    } else if (v.getId() == R.id.btnCommandAction) {
        Log.d(TAG, "Play button click for position " + position);
        handlePlayCommand(position);
    }
}

From source file:net.openwatch.acluaz.fragment.FormFragment.java

public JSONObject toJson(ViewGroup container, JSONObject json) {
    String TAG = "FormFragment-ToJSON";
    if (container == null) {
        Log.e(TAG, "null container passed to toJson");
        return new JSONObject();
    }//from   ww w . ja  va  2 s  .  c om

    if (json == null)
        json = new JSONObject();
    View view;
    for (int x = 0; x < container.getChildCount(); x++) {
        view = container.getChildAt(x);

        if (EditText.class.isInstance(view)) {
            if (view.getTag() != null) {
                if (((EditText) view).getText().toString().compareTo("") == 0)
                    continue; // skip blank input
                try {
                    Log.i(TAG, "Mapping: " + view.getTag().toString() + " value: "
                            + ((EditText) view).getText().toString());
                    if (view.getTag().toString().compareTo(getString(R.string.zipcode_tag)) == 0)
                        json.put(view.getTag().toString(),
                                Integer.parseInt(((EditText) view).getText().toString()));
                    else
                        json.put(view.getTag().toString(), ((EditText) view).getText().toString());
                } catch (JSONException e) {
                    Log.e(TAG, "Error jsonifying text input");
                    e.printStackTrace();
                }

            }
        } else if (CompoundButton.class.isAssignableFrom(view.getClass())) {
            if (view.getTag() != null) {
                // if location toggle, bundle location
                if (((String) view.getTag()).compareTo(getString(R.string.device_location_tag)) == 0
                        && view.getTag(R.id.view_tag) != null) {
                    if (((CompoundButton) view).isChecked()) {
                        try {
                            json.put(getString(R.string.device_lat),
                                    ((Location) view.getTag(R.id.view_tag)).getLatitude());
                            json.put(getString(R.string.device_lon),
                                    ((Location) view.getTag(R.id.view_tag)).getLongitude());
                        } catch (JSONException e) {
                            Log.e(TAG, "Error jsonifying toggle input");
                            e.printStackTrace();
                        }
                    }
                } else if (((String) view.getTag()).compareTo(getString(R.string.device_location_tag)) == 0
                        && view.getTag(R.id.view_tag) == null) {
                    // no location tagged, get last known
                    LocationManager lm = (LocationManager) container.getContext()
                            .getSystemService(Context.LOCATION_SERVICE);
                    Location last = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
                    try {
                        json.put(getString(R.string.device_lat), last.getLatitude());
                        json.put(getString(R.string.device_lon), last.getLongitude());
                    } catch (JSONException e) {
                        Log.e(TAG, "Error jsonifying last location");
                        e.printStackTrace();
                    } catch (NullPointerException e2) {
                        Log.e(TAG, "No current or historical location info on this device");
                    }
                }

            }
        }

        // combine date and time fields into a single datetime
        if (json.has(getString(R.string.date_tag)) && json.has(getString(R.string.time_tag))) {
            Log.i(TAG, "found date and time tag, let's smush 'em");
            try {
                //TESTING
                //String datetime = combineDateAndTime(json.getString(getString(R.string.date_tag)), json.getString(getString(R.string.time_tag)));
                //Log.i(TAG,"datetime: " + datetime);
                json.put(getString(R.string.date_tag),
                        combineDateAndTime(json.getString(getString(R.string.date_tag)),
                                json.getString(getString(R.string.time_tag))));
                Log.i(TAG, json.toString());
                //json.remove(getString(R.string.date_tag));
                json.remove(getString(R.string.time_tag));
            } catch (JSONException e) {
                Log.e(TAG, "Error creating json datetime field from date and time");
                e.printStackTrace();
            }
        }

    }
    Log.i(TAG, "toJson: " + json.toString());
    return json;

}

From source file:com.lovejoy777sarootool.rootool.adapters.BrowserListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final ViewHolder mViewHolder;
    int num_items = 0;
    final File file = new File(getItem(position));
    DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.getDefault());

    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.item_browserlist, parent, false);
        mViewHolder = new ViewHolder(convertView);
        convertView.setTag(mViewHolder);
    } else {/* w  w w . ja  v a2  s  .co  m*/
        mViewHolder = (ViewHolder) convertView.getTag();
    }

    if (Settings.mListAppearance > 0) {
        mViewHolder.dateview.setVisibility(TextView.VISIBLE);
    } else {
        mViewHolder.dateview.setVisibility(TextView.GONE);
    }

    // get icon
    IconPreview.getFileIcon(file, mViewHolder.icon);

    if (file.isFile()) {
        // Shows the size of File
        mViewHolder.bottomView.setText(FileUtils.byteCountToDisplaySize(file.length()));
    } else {
        String[] list = file.list();

        if (list != null)
            num_items = list.length;

        // show the number of files in Folder
        mViewHolder.bottomView.setText(num_items + mResources.getString(R.string.files));
    }

    mViewHolder.topView.setText(file.getName());
    mViewHolder.dateview.setText(df.format(file.lastModified()));

    return convertView;
}