Remove ThemeableListFragment
Not sure why it was added initially but now it appears to be unneeded: the support library does everything right and the lists are themed properly without any hacks.
This commit is contained in:
parent
817cac3002
commit
080527bf2e
@ -7,6 +7,7 @@ import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.ListFragment;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.content.CursorLoader;
|
||||
import android.support.v4.content.Loader;
|
||||
@ -24,7 +25,7 @@ import org.fdroid.fdroid.data.App;
|
||||
import org.fdroid.fdroid.data.AppProvider;
|
||||
import org.fdroid.fdroid.views.AppListAdapter;
|
||||
|
||||
public abstract class AppListFragment extends ThemeableListFragment implements
|
||||
public abstract class AppListFragment extends ListFragment implements
|
||||
AdapterView.OnItemClickListener,
|
||||
Preferences.ChangeListener,
|
||||
LoaderManager.LoaderCallbacks<Cursor> {
|
||||
|
@ -1,73 +0,0 @@
|
||||
package org.fdroid.fdroid.views.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.ListFragment;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ListView;
|
||||
|
||||
import org.fdroid.fdroid.R;
|
||||
|
||||
public abstract class ThemeableListFragment extends ListFragment {
|
||||
|
||||
protected int getThemeStyle() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected int getHeaderLayout() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected View getHeaderView() {
|
||||
return headerView;
|
||||
}
|
||||
|
||||
private View headerView;
|
||||
|
||||
private View getHeaderView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (getHeaderLayout() == 0) {
|
||||
return null;
|
||||
}
|
||||
if (headerView == null) {
|
||||
headerView = inflater.inflate(getHeaderLayout(), null, false);
|
||||
}
|
||||
return headerView;
|
||||
}
|
||||
|
||||
private LayoutInflater getThemedInflater(Context context) {
|
||||
Context c = (getThemeStyle() == 0) ? context : new ContextThemeWrapper(context, getThemeStyle());
|
||||
return (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normally we'd just let the baseclass ListFrament.onCreateView() from the support library do its magic.
|
||||
* However, it doesn't allow us to theme it. That is, it always passes getActivity() into the constructor
|
||||
* of widgets. We are more interested in a ContextThemeWrapper, so that the widgets get appropriately
|
||||
* themed. In order to get it working, we need to work around android bug 21742 as well
|
||||
* (https://code.google.com/p/android/issues/detail?id=21742).
|
||||
*/
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
LayoutInflater themedInflater = getThemedInflater(inflater.getContext());
|
||||
|
||||
View view = themedInflater.inflate(R.layout.list_content, container, false);
|
||||
|
||||
View headerView = getHeaderView(themedInflater, container);
|
||||
if (headerView != null) {
|
||||
ListView listView = (ListView) view.findViewById(android.R.id.list);
|
||||
listView.addHeaderView(headerView);
|
||||
}
|
||||
|
||||
// Workaround for https://code.google.com/p/android/issues/detail?id=21742
|
||||
view.findViewById(android.R.id.empty).setId(0x00ff0001);
|
||||
view.findViewById(R.id.progressContainer).setId(0x00ff0002);
|
||||
view.findViewById(android.R.id.progress).setId(0x00ff0003);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user