Android Open Source - UK-Weather-repo City Weather Cursor Adapter






From Project

Back to project page UK-Weather-repo.

License

The source code is released under:

Apache License

If you think the Android project UK-Weather-repo listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.haringeymobile.ukweather;
//w ww  . ja v a2  s  .  co  m
import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.TextView;

import com.haringeymobile.ukweather.database.CityTable;

public class CityWeatherCursorAdapter extends BaseCityCursorAdapter {

  /** A helper to implement the "view holder" design pattern. */
  private static class CityRowWeatherViewHolder {

    TextView cityNameTextView;
    ImageButton buttonCurrentWeather;
    ImageButton buttonDailyForecast;
    ImageButton buttonThreeHourlyForecast;

  }

  /**
   * An adapter to map the cities stored in the database to the city list rows
   * with buttons requesting various weather information.
   */
  CityWeatherCursorAdapter(Context context, int layout, Cursor c,
      String[] from, int[] to, int flags, OnClickListener onClickListener) {
    super(context, layout, c, from, to, flags, onClickListener);
  }

  @Override
  public View newView(Context context, Cursor cursor, ViewGroup parent) {
    View rowView = ((LayoutInflater) context
        .getSystemService("layout_inflater")).inflate(
        R.layout.row_city_list_with_weather_buttons, parent, false);

    CityRowWeatherViewHolder holder = new CityRowWeatherViewHolder();
    holder.cityNameTextView = (TextView) rowView
        .findViewById(R.id.city_name_in_list_row_text_view);
    holder.buttonCurrentWeather = (ImageButton) rowView
        .findViewById(R.id.city_current_weather_button);
    holder.buttonDailyForecast = (ImageButton) rowView
        .findViewById(R.id.city_daily_weather_forecast_button);
    holder.buttonThreeHourlyForecast = (ImageButton) rowView
        .findViewById(R.id.city_three_hourly_weather_forecast_button);
    holder.buttonCurrentWeather.setOnClickListener(onClickListener);
    holder.buttonDailyForecast.setOnClickListener(onClickListener);
    holder.buttonThreeHourlyForecast.setOnClickListener(onClickListener);
    rowView.setTag(holder);

    return rowView;
  }

  @Override
  public void bindView(View view, Context context, Cursor cursor) {
    CityRowWeatherViewHolder holder = (CityRowWeatherViewHolder) view
        .getTag();
    int nameColumsIndex = cursor
        .getColumnIndexOrThrow(CityTable.COLUMN_NAME);
    holder.cityNameTextView.setText(cursor.getString(nameColumsIndex));
  }

}




Java Source Code List

com.astuetz.PagerSlidingTabStrip.java
com.haringeymobile.ukweather.AboutActivity.java
com.haringeymobile.ukweather.BaseCityCursorAdapter.java
com.haringeymobile.ukweather.BaseCityListFragmentWithButtons.java
com.haringeymobile.ukweather.CityListFragmentWithUtilityButtons.java
com.haringeymobile.ukweather.CityListFragmentWithWeatherButtons.java
com.haringeymobile.ukweather.CityManagementActivity.java
com.haringeymobile.ukweather.CitySearchResultsDialog.java
com.haringeymobile.ukweather.CityUtilitiesCursorAdapter.java
com.haringeymobile.ukweather.CityWeatherCursorAdapter.java
com.haringeymobile.ukweather.DeleteCityDialog.java
com.haringeymobile.ukweather.GetAvailableCitiesTask.java
com.haringeymobile.ukweather.MainActivity.java
com.haringeymobile.ukweather.SettingsActivityPreHoneycomb.java
com.haringeymobile.ukweather.SettingsActivity.java
com.haringeymobile.ukweather.SettingsFragment.java
com.haringeymobile.ukweather.WeatherCurrentInfoFragment.java
com.haringeymobile.ukweather.WeatherDailyWeatherForecastChildFragment.java
com.haringeymobile.ukweather.WeatherForecastParentFragment.java
com.haringeymobile.ukweather.WeatherInfoActivity.java
com.haringeymobile.ukweather.WeatherInfoFragment.java
com.haringeymobile.ukweather.WeatherInfoType.java
com.haringeymobile.ukweather.WeatherThreeHourlyForecastChildFragment.java
com.haringeymobile.ukweather.WorkerFragmentToRetrieveJsonString.java
com.haringeymobile.ukweather.data.InitialCity.java
com.haringeymobile.ukweather.data.JsonFetcher.java
com.haringeymobile.ukweather.data.OpenWeatherMapUrl.java
com.haringeymobile.ukweather.data.objects.CityCurrentWeather.java
com.haringeymobile.ukweather.data.objects.CityDailyWeatherForecast.java
com.haringeymobile.ukweather.data.objects.CityInfo.java
com.haringeymobile.ukweather.data.objects.CityThreeHourlyWeatherForecast.java
com.haringeymobile.ukweather.data.objects.Clouds.java
com.haringeymobile.ukweather.data.objects.Coordinates.java
com.haringeymobile.ukweather.data.objects.NumericParameters.java
com.haringeymobile.ukweather.data.objects.Rain.java
com.haringeymobile.ukweather.data.objects.SearchResponseForDailyForecastQuery.java
com.haringeymobile.ukweather.data.objects.SearchResponseForFindQuery.java
com.haringeymobile.ukweather.data.objects.SearchResponseForThreeHourlyForecastQuery.java
com.haringeymobile.ukweather.data.objects.SystemParameters.java
com.haringeymobile.ukweather.data.objects.TemperatureScale.java
com.haringeymobile.ukweather.data.objects.Temperature.java
com.haringeymobile.ukweather.data.objects.WeatherInformation.java
com.haringeymobile.ukweather.data.objects.Weather.java
com.haringeymobile.ukweather.data.objects.WindSpeedMeasurementUnit.java
com.haringeymobile.ukweather.data.objects.Wind.java
com.haringeymobile.ukweather.database.CityTable.java
com.haringeymobile.ukweather.database.DatabaseHelper.java
com.haringeymobile.ukweather.database.GeneralDatabaseService.java
com.haringeymobile.ukweather.database.SqlOperation.java
com.haringeymobile.ukweather.database.WeatherContentProvider.java
com.haringeymobile.ukweather.utils.AsyncTaskWithProgressBar.java
com.haringeymobile.ukweather.utils.GlobalConstants.java
com.haringeymobile.ukweather.utils.MiscMethods.java
com.haringeymobile.ukweather.utils.SharedPrefsHelper.java