List of usage examples for android.widget LabelView setText
public void setText(String text)
From source file:com.Bhailal_Chauhan.retailapp.view.fragment.ProductDetailsFragment.java
public void fillProductData() { if (!isFromCart) { //Fetch and display item from Gloabl Data Model itemName.setText(GlobaDataHolder.getGlobaDataHolder().getProductMap().get(subcategoryKey) .get(productListNumber).getItemName()); quanitity.setText(GlobaDataHolder.getGlobaDataHolder().getProductMap().get(subcategoryKey) .get(productListNumber).getQuantity()); itemdescription.setText(GlobaDataHolder.getGlobaDataHolder().getProductMap().get(subcategoryKey) .get(productListNumber).getItemDetail()); String sellCostString = Money.rupees(BigDecimal.valueOf(Long.valueOf(GlobaDataHolder .getGlobaDataHolder().getProductMap().get(subcategoryKey).get(productListNumber).getSellMRP()))) .toString() + " "; String buyMRP = Money.rupees(BigDecimal.valueOf(Long.valueOf(GlobaDataHolder.getGlobaDataHolder() .getProductMap().get(subcategoryKey).get(productListNumber).getMRP()))).toString(); String costString = sellCostString + buyMRP; itemSellPrice.setText(costString, BufferType.SPANNABLE); Spannable spannable = (Spannable) itemSellPrice.getText(); spannable.setSpan(new StrikethroughSpan(), sellCostString.length(), costString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); mDrawableBuilder = TextDrawable.builder().beginConfig().withBorder(4).endConfig().roundRect(10); drawable = mDrawableBuilder.build( String.valueOf(GlobaDataHolder.getGlobaDataHolder().getProductMap().get(subcategoryKey) .get(productListNumber).getItemName().charAt(0)), mColorGenerator.getColor(GlobaDataHolder.getGlobaDataHolder().getProductMap() .get(subcategoryKey).get(productListNumber).getItemName())); Picasso.with(getActivity())/*from w w w.j a v a 2 s . c o m*/ .load(GlobaDataHolder.getGlobaDataHolder().getProductMap().get(subcategoryKey) .get(productListNumber).getImageURL()) .placeholder(drawable).error(drawable).fit().centerCrop().networkPolicy(NetworkPolicy.OFFLINE) .into(itemImage, new Callback() { @Override public void onSuccess() { } @Override public void onError() { // Try again online if cache failed Picasso.with(getActivity()) .load(GlobaDataHolder.getGlobaDataHolder().getProductMap().get(subcategoryKey) .get(productListNumber).getImageURL()) .placeholder(drawable).error(drawable).fit().centerCrop().into(itemImage); } }); LabelView label = new LabelView(getActivity()); label.setText(GlobaDataHolder.getGlobaDataHolder().getProductMap().get(subcategoryKey) .get(productListNumber).getDiscount()); label.setBackgroundColor(0xffE91E63); label.setTargetView(itemImage, 10, LabelView.Gravity.RIGHT_TOP); } else { //Fetch and display products from Shopping list itemName.setText( GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(productListNumber).getItemName()); quanitity.setText( GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(productListNumber).getQuantity()); itemdescription.setText( GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(productListNumber).getItemDetail()); String sellCostString = Money.rupees(BigDecimal.valueOf(Long.valueOf( GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(productListNumber).getSellMRP()))) .toString() + " "; String buyMRP = Money.rupees(BigDecimal.valueOf(Long.valueOf( GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(productListNumber).getMRP()))) .toString(); String costString = sellCostString + buyMRP; itemSellPrice.setText(costString, BufferType.SPANNABLE); Spannable spannable = (Spannable) itemSellPrice.getText(); spannable.setSpan(new StrikethroughSpan(), sellCostString.length(), costString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); mDrawableBuilder = TextDrawable.builder().beginConfig().withBorder(4).endConfig().roundRect(10); drawable = mDrawableBuilder.build( String.valueOf(GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(productListNumber) .getItemName().charAt(0)), mColorGenerator.getColor(GlobaDataHolder.getGlobaDataHolder().getShoppingList() .get(productListNumber).getItemName())); Picasso.with(getActivity()) .load(GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(productListNumber) .getImageURL()) .placeholder(drawable).error(drawable).fit().centerCrop().networkPolicy(NetworkPolicy.OFFLINE) .into(itemImage, new Callback() { @Override public void onSuccess() { } @Override public void onError() { // Try again online if cache failed Picasso.with(getActivity()) .load(GlobaDataHolder.getGlobaDataHolder().getShoppingList() .get(productListNumber).getImageURL()) .placeholder(drawable).error(drawable).fit().centerCrop().into(itemImage); } }); LabelView label = new LabelView(getActivity()); label.setText( GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(productListNumber).getDiscount()); label.setBackgroundColor(0xffE91E63); label.setTargetView(itemImage, 10, LabelView.Gravity.RIGHT_TOP); } }