Android Open Source - UK-Weather-repo City List Fragment With Utility Buttons






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  w  w .java 2 s  . c  om
import android.app.Activity;
import android.view.View;

/**
 * A fragment containing a list of cities with clickable buttons, requesting
 * utility work, such as renaming a city, or removing it from the database.
 */
public class CityListFragmentWithUtilityButtons extends
    BaseCityListFragmentWithButtons {

  /** A listener for utility button clicks. */
  public interface OnUtilityButtonClickedListener {

    /**
     * Reacts to the request to remove the specified city from the database.
     * 
     * @param cityId
     *            OpenWeatherMap city ID
     * @param cityName
     *            city name in the database
     */
    public void onCityRecordDeletionRequested(int cityId, String cityName);

    /**
     * Reacts to the request to rename the specified city.
     * 
     * @param cityId
     *            OpenWeatherMap city ID
     * @param cityOriginalName
     *            current city name in the database
     */
    public void onCityNameChangeRequested(int cityId,
        String cityOriginalName);

  }

  private OnUtilityButtonClickedListener onUtilityButtonClickedListener;

  @Override
  public void onAttach(Activity activity) {
    super.onAttach(activity);
    try {
      onUtilityButtonClickedListener = (OnUtilityButtonClickedListener) activity;
    } catch (ClassCastException e) {
      throw new ClassCastException(activity.toString()
          + " must implement OnUtilityButtonClickedListener");
    }
  }

  @Override
  protected BaseCityCursorAdapter getCityCursorAdapter() {
    return new CityUtilitiesCursorAdapter(parentActivity,
        R.layout.row_city_list_with_weather_buttons, null,
        COLUMNS_TO_DISPLAY, TO, 0, this);
  }

  @Override
  public void onDetach() {
    super.onDetach();
    onUtilityButtonClickedListener = null;
  }

  @Override
  public void onClick(View view) {
    int listItemPosition = getListView().getPositionForView(view);
    int cityId = cursorAdapter.getCityId(listItemPosition);
    String cityName = cursorAdapter.getCityName(listItemPosition);

    int viewId = view.getId();
    switch (viewId) {
    case R.id.city_rename_button:
      onUtilityButtonClickedListener.onCityNameChangeRequested(cityId,
          cityName);
      break;
    case R.id.city_delete_button:
      onUtilityButtonClickedListener.onCityRecordDeletionRequested(
          cityId, cityName);
      break;
    default:
      throw new IllegalArgumentException("Not supported view ID: "
          + viewId);
    }
  }

}




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