Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public RemoteViews getViewAt(int position) {
- if (position == AdapterView.INVALID_POSITION || data == null || !data.moveToPosition(position)) {
- return null;
- }
- String symbol = data.getString(Quote.POSITION_SYMBOL);
- String price = CurrencyUtils.formatDollar(data.getDouble(Quote.POSITION_PRICE));
- double changeDouble = data.getDouble(Quote.POSITION_PERCENTAGE_CHANGE);
- String change = CurrencyUtils.formatDollarWithPlus(changeDouble);
- Intent fillInIntent = new Intent();
- intent.putExtra(EXTRA_SYMBOL, symbol);
- intent.putExtra(EXTRA_PRICE, price);
- intent.putExtra(EXTRA_CHANGE, change);
- RemoteViews views = new RemoteViews(getPackageName(), R.layout.widget_stocks_item);
- views.setTextViewText(R.id.widget_symbol, symbol);
- views.setTextViewText(R.id.widget_price, price);
- views.setTextViewText(R.id.widget_change, change);
- views.setInt(R.id.change, "setBackgroundResource",
- changeDouble > 0 ? R.drawable.percent_change_pill_green : R.drawable.percent_change_pill_red);
- views.setOnClickFillInIntent(R.id.widget_list_item, fillInIntent);
- return views;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement