SHARE
TWEET

Untitled

a guest Apr 21st, 2017 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @Override
  2.             public RemoteViews getViewAt(int position) {
  3.                 if (position == AdapterView.INVALID_POSITION || data == null || !data.moveToPosition(position)) {
  4.                     return null;
  5.                 }
  6.  
  7.                 String symbol = data.getString(Quote.POSITION_SYMBOL);
  8.                 String price = CurrencyUtils.formatDollar(data.getDouble(Quote.POSITION_PRICE));
  9.  
  10.                 double changeDouble = data.getDouble(Quote.POSITION_PERCENTAGE_CHANGE);
  11.                 String change = CurrencyUtils.formatDollarWithPlus(changeDouble);
  12.  
  13.                 Intent fillInIntent = new Intent();
  14.                 intent.putExtra(EXTRA_SYMBOL, symbol);
  15.                 intent.putExtra(EXTRA_PRICE, price);
  16.                 intent.putExtra(EXTRA_CHANGE, change);
  17.  
  18.                 RemoteViews views = new RemoteViews(getPackageName(), R.layout.widget_stocks_item);
  19.                 views.setTextViewText(R.id.widget_symbol, symbol);
  20.                 views.setTextViewText(R.id.widget_price, price);
  21.                 views.setTextViewText(R.id.widget_change, change);
  22.  
  23.                 views.setInt(R.id.change, "setBackgroundResource",
  24.                         changeDouble > 0 ? R.drawable.percent_change_pill_green : R.drawable.percent_change_pill_red);
  25.  
  26.                 views.setOnClickFillInIntent(R.id.widget_list_item, fillInIntent);
  27.  
  28.                 return views;
  29.             }
RAW Paste Data
Top