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 (c) 2009 Matthias Kppler
*//fromwww.java2s.com
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/package com.github.droidfu.activities;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ListAdapter;
import com.github.droidfu.DroidFuApplication;
import com.github.droidfu.adapters.ListAdapterWithProgress;
publicclass BetterListActivity extends ListActivity implements BetterActivity {
privatestaticfinal String IS_BUSY_EXTRA = "is_busy";
privateboolean wasCreated, wasInterrupted;
private Intent currentIntent;
@Override
protectedvoid onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.wasCreated = true;
this.currentIntent = getIntent();
((DroidFuApplication) getApplication()).setActiveContext(getClass().getCanonicalName(),
this);
}
@Override
protectedvoid onDestroy() {
super.onDestroy();
// ((DroidFuApplication)
// getApplication()).resetActiveContext(getClass().getCanonicalName());
}
@Override
protectedvoid onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
ListAdapter adapter = getListAdapter();
if (adapter instanceof ListAdapterWithProgress<?>) {
boolean isLoading = ((ListAdapterWithProgress<?>) adapter).isLoadingData();
outState.putBoolean(IS_BUSY_EXTRA, isLoading);
}
}
@Override
protectedvoid onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
ListAdapter adapter = getListAdapter();
if (adapter instanceof ListAdapterWithProgress<?>) {
boolean isLoading = savedInstanceState.getBoolean(IS_BUSY_EXTRA);
((ListAdapterWithProgress<?>) adapter).setIsLoadingData(isLoading);
}
wasInterrupted = true;
}
@Override
protectedvoid onPause() {
super.onPause();
wasCreated = wasInterrupted = false;
}
@Override
protectedvoid onNewIntent(Intent intent) {
super.onNewIntent(intent);
this.currentIntent = intent;
}
publicint getWindowFeatures() {
return BetterActivityHelper.getWindowFeatures(this);
}
publicboolean isRestoring() {
return wasInterrupted;
}
publicboolean isResuming() {
return !wasCreated;
}
publicboolean isLaunching() {
return !wasInterrupted && wasCreated;
}
publicboolean isApplicationBroughtToBackground() {
return BetterActivityHelper.isApplicationBroughtToBackground(this);
}
public Intent getCurrentIntent() {
return currentIntent;
}
publicboolean isLandscapeMode() {
return getWindowManager().getDefaultDisplay().getOrientation() == 1;
}
publicboolean isPortraitMode() {
return !isLandscapeMode();
}
}