udacity / Sunshine-Version-2

The official repository for Developing Android Apps
Apache License 2.0
2.87k stars 4.41k forks source link

Issue in ForecastFragment FORECAST_COLUMNS and indices - Location_id column is missing #304

Open nirthik opened 7 years ago

nirthik commented 7 years ago

WeatherContract.WeatherEntry.COLUMN_LOC_KEY, is missing in FORECAST_COLUMNS columns.

In onCreateView Cursor cursor = (Cursor) adapterView.getItemAtPosition(position); the cursor returns the WeatherContract.WeatherEntry.COLUMN_LOC_KEY in second position and WeatherContract.WeatherEntry.COLUMN_DATE, in third position.

So the indices for the FORECAST_COLUMNS also need to be changed.

The following lines need to be added in ForecastFragment:

        WeatherContract.WeatherEntry.COLUMN_LOC_KEY,

static final int COL_LOCATION_ID = 1; static final int COL_WEATHER_DATE = 2;

aqib-git commented 7 years ago

I'm facing this issue also, I made FORECAST_COULMN public then did some refactoring in ForecastAdapter as given below


int dateInMillisIndex = cursor.getColumnIndex(ForecastFragment.FORECAST_COLUMNS[ForecastFragment.COL_WEATHER_DATE]);

long dateInMillis = cursor.getLong(dateInMillisIndex);