Android Open Source - UK-Weather-repo General Database Service 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.database;
/ / f r o m w w w . j a v a 2 s . c o m
import android.app.IntentService;
import android.content.Intent;
import com.haringeymobile.ukweather.CityManagementActivity;
import com.haringeymobile.ukweather.MainActivity;
import com.haringeymobile.ukweather.WeatherInfoType;
import com.haringeymobile.ukweather.utils.SharedPrefsHelper;
public class GeneralDatabaseService extends IntentService {
private static final String APP_PACKAGE = "com.haringeymobile.ukweather" ;
public static final String ACTION_INSERT_OR_UPDATE_CITY_RECORD = APP_PACKAGE
+ ".insert_or_update_city_records" ;
public static final String ACTION_UPDATE_WEATHER_INFO = APP_PACKAGE
+ ".update_weather_info_records" ;
public static final String ACTION_RENAME_CITY = APP_PACKAGE
+ ".rename_city" ;
public static final String ACTION_DELETE_CITY_RECORDS = APP_PACKAGE
+ ".delete_city_records" ;
private static final String WORKER_THREAD_NAME = "General database service thread" ;
public GeneralDatabaseService() {
super (WORKER_THREAD_NAME);
}
@Override
protected void onHandleIntent(Intent intent) {
String action = intent.getAction();
if (ACTION_INSERT_OR_UPDATE_CITY_RECORD.equals(action)) {
int cityId = intent.getIntExtra(MainActivity.CITY_ID,
CityTable.CITY_ID_DOES_NOT_EXIST);
String cityName = intent.getStringExtra(MainActivity.CITY_NAME);
String currentWeatherJsonString = intent
.getStringExtra(MainActivity.WEATHER_INFO_JSON_STRING);
new SqlOperation(this , WeatherInfoType.CURRENT_WEATHER)
.updateOrInsertCityWithCurrentWeather(cityId, cityName,
currentWeatherJsonString);
} else if (ACTION_UPDATE_WEATHER_INFO.equals(action)) {
int cityId = SharedPrefsHelper.getCityIdFromSharedPrefs(this );
String jsonString = intent
.getStringExtra(MainActivity.WEATHER_INFO_JSON_STRING);
WeatherInfoType weatherInfoType = intent
.getParcelableExtra(MainActivity.WEATHER_INFORMATION_TYPE);
new SqlOperation(this , weatherInfoType).updateWeatherInfo(cityId,
jsonString);
} else if (ACTION_RENAME_CITY.equals(action)) {
int cityId = intent.getIntExtra(CityManagementActivity.CITY_ID,
CityTable.CITY_ID_DOES_NOT_EXIST);
String newName = intent
.getStringExtra(CityManagementActivity.CITY_NEW_NAME);
new SqlOperation(this ).renameCity(cityId, newName);
} else if (ACTION_DELETE_CITY_RECORDS.equals(action)) {
int cityId = intent.getIntExtra(CityManagementActivity.CITY_ID,
CityTable.CITY_ID_DOES_NOT_EXIST);
new SqlOperation(this ).deleteCity(cityId);
} else {
throw new IllegalArgumentException("Unsupported action: " + action);
}
}
}
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