Back to project page tazDownloader.
The source code is released under:
GNU General Public License
If you think the Android project tazDownloader listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/******************************************************************************* * Copyright (c) 2012 Olaf Sebelin./* w w w . j a va2s . c o m*/ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. ******************************************************************************/ package read.taz; import java.util.Calendar; import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.util.Log; public abstract class AbstractTazReaderMainActivity extends Activity { @Override protected void onStart() { super.onStart(); Log.d(TAG, "Starting service"); if (isUnconfigured()) { showSettings(); } else { startService(new Intent(this, CleanupService.class)); configured(); } } protected void configured() { // subclasses resp. } protected String TAG = getClass().getSimpleName(); protected boolean receiverRegistered = false; protected boolean isUnconfigured() { SharedPreferences preferences = PreferenceManager .getDefaultSharedPreferences(this); String unset = "unset"; String uname = preferences.getString(getString(R.string.unameKey), unset); String passwd = preferences.getString(getString(R.string.passwdKey), unset); String filetype = preferences.getString(getString(R.string.fileTypeKey), unset); return uname.equals(unset) || passwd.equals(unset) || filetype.equals(unset); } protected void showSettings() { startActivity(new Intent(this, SettingsActivity.class)); } protected void startDownloadAndDisplay(Calendar forDate) { Log.d(TAG, "Starting download of taz for " + forDate.getTime()); Intent intent = new Intent(this, DownloadActivity.class); intent.putExtra(TazDownloadService.EXTRA_TAZ_DATE, forDate); startActivity(intent); } /** * Sundays taz is distributed on Saturdays. */ protected Calendar adjust(Calendar cal) { if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { Log.d(TAG, "Sundays taz is delivered on saturday. Adjusting date "); cal.add(Calendar.DAY_OF_MONTH, -1); } return cal; } }