@Override
  public RemoteViews getViewAt(int position) {
    if (position == AdapterView.INVALID_POSITION
        || mCursor == null
        || !mCursor.moveToPosition(position)) {
      return null;
    }
    RemoteViews remoteViews = new RemoteViews(mContext.getPackageName(), R.layout.widget_list);

    String homeTeamName = mCursor.getString(Utilities.DATABASE_HOME_COL);
    String awayTeamName = mCursor.getString(Utilities.DATABASE_AWAY_COL);

    remoteViews.setTextViewText(R.id.home_name, homeTeamName);
    remoteViews.setTextViewText(R.id.away_name, awayTeamName);

    String score =
        mUtilities.getScores(
            mCursor.getInt(Utilities.DATABASE_HOME_GOALS_COL),
            mCursor.getInt(Utilities.DATABASE_AWAY_GOALS_COL));
    remoteViews.setTextViewText(R.id.score_textview, score);

    remoteViews.setTextViewText(R.id.data_textview, mCursor.getString(Utilities.DATABASE_TIME_COL));

    remoteViews.setImageViewResource(
        R.id.home_crest, mUtilities.getTeamCrestByTeamName(homeTeamName));
    remoteViews.setImageViewResource(
        R.id.away_crest, mUtilities.getTeamCrestByTeamName(awayTeamName));

    return remoteViews;
  }
Пример #2
0
 @Override
 public RemoteViews getViewAt(int position) {
   scoresCursor.moveToPosition(position);
   final RemoteViews remoteViews =
       new RemoteViews(context.getPackageName(), R.layout.scores_list_item);
   remoteViews.setTextViewText(R.id.home_name, scoresCursor.getString(ScoresAdapter.COL_HOME));
   remoteViews.setTextViewText(R.id.away_name, scoresCursor.getString(ScoresAdapter.COL_AWAY));
   remoteViews.setTextViewText(
       R.id.data_textview, scoresCursor.getString(ScoresAdapter.COL_MATCHTIME));
   remoteViews.setTextViewText(
       R.id.score_textview,
       Utilities.getScores(
           scoresCursor.getInt(ScoresAdapter.COL_HOME_GOALS),
           scoresCursor.getInt(ScoresAdapter.COL_AWAY_GOALS)));
   remoteViews.setImageViewResource(
       R.id.home_crest,
       Utilities.getTeamCrestByTeamName(
           context, scoresCursor.getString(ScoresAdapter.COL_HOME)));
   remoteViews.setImageViewResource(
       R.id.away_crest,
       Utilities.getTeamCrestByTeamName(
           context, scoresCursor.getString(ScoresAdapter.COL_AWAY)));
   return remoteViews;
 }