If you think the Android project RateBeer-Mobile 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
/*
* Copyright 2010, Jesper Fussing Mrk/*fromwww.java2s.com*/
*
* This file is part of Ratebeer Mobile for Android.
*
* Ratebeer Mobile 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.
*
* Ratebeer Mobile 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 Ratebeer Mobile. If not, see <http://www.gnu.org/licenses/>.
*/package dk.moerks.ratebeermobile.activity;
import android.R;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.Window;
import android.widget.TextView;
import android.widget.Toast;
import com.github.droidfu.activities.BetterListActivity;
import dk.moerks.ratebeermobile.Settings;
import dk.moerks.ratebeermobile.exceptions.RBException;
publicabstractclass BetterRBListActivity extends BetterListActivity implements BetterRBActivity {
privatestaticfinal String EXTRA_HAS_TASK = "has_running_task";
privateboolean hasTask;
@Override
publicvoid onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Request progress bar
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
}
@Override
protectedvoid onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(EXTRA_HAS_TASK, hasRunningTask());
}
@Override
protectedvoid onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
hasRunningTask(savedInstanceState.getBoolean(EXTRA_HAS_TASK));
this.setProgressBarIndeterminateVisibility(hasRunningTask());
}
publicvoid reportError(RBException e) {
// Show the error as Toast popup
Toast.makeText(this, e.getAlertMessage(), Toast.LENGTH_LONG).show();
if (getListAdapter() == null || getListAdapter().getCount() <= 0) {
// No items shown: it's safe to also display the error message as the list view's empty text
((TextView)findViewById(R.id.empty)).setText(e.getAlertMessage());
}
}
public Context getContext() {
returnthis;
}
publicvoid setTitle(String message) {
super.setTitle(message);
}
public String getUserId() {
SharedPreferences settings = getApplicationContext().getSharedPreferences(Settings.PREFERENCETAG, 0);
return settings.getString("rb_userid", "");
}
publicvoid hasRunningTask(boolean hasTask) {
this.hasTask = hasTask;
}
publicboolean hasRunningTask() {
return this.hasTask;
}
}