If you think the Android project Todo 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 2013 Chris Banes/*www.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 uk.co.senab.actionbarpulltorefresh.extras.actionbarsherlock;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.app.SherlockExpandableListActivity;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.app.SherlockListActivity;
import com.actionbarsherlock.app.SherlockPreferenceActivity;
import android.app.Activity;
import android.content.Context;
publicclass PullToRefreshAttacher extends
uk.co.senab.actionbarpulltorefresh.library.PullToRefreshAttacher {
publicstatic PullToRefreshAttacher get(Activity activity) {
return get(activity, new Options());
}
publicstatic PullToRefreshAttacher get(Activity activity, Options options) {
returnnew PullToRefreshAttacher(activity, options);
}
protected PullToRefreshAttacher(Activity activity, Options options) {
super(activity, options);
}
@Override
protected EnvironmentDelegate createDefaultEnvironmentDelegate() {
returnnew AbsEnvironmentDelegate();
}
@Override
protected HeaderTransformer createDefaultHeaderTransformer() {
returnnew AbsDefaultHeaderTransformer();
}
publicstaticclass AbsEnvironmentDelegate extends EnvironmentDelegate {
/**
* @return Context which should be used for inflating the header layout
*/public Context getContextForInflater(Activity activity) {
if (activity instanceof SherlockActivity) {
return ((SherlockActivity) activity).getSupportActionBar().getThemedContext();
} elseif (activity instanceof SherlockListActivity) {
return ((SherlockListActivity) activity).getSupportActionBar().getThemedContext();
} elseif (activity instanceof SherlockFragmentActivity) {
return ((SherlockFragmentActivity) activity).getSupportActionBar()
.getThemedContext();
} elseif (activity instanceof SherlockExpandableListActivity) {
return ((SherlockExpandableListActivity) activity).getSupportActionBar()
.getThemedContext();
} elseif (activity instanceof SherlockPreferenceActivity) {
return ((SherlockPreferenceActivity) activity).getSupportActionBar()
.getThemedContext();
}
return super.getContextForInflater(activity);
}
}
}