// HashMap<String, MyListAdapter> mAdapters = new HashMap<String, ActivityBaseFragment.MyListAdapter>();
public ListItemAdapter ensureHeader(int sectionName) {
- return ensureHeader(mAdapter.getSectionCount(), getActivity().getString(sectionName));
+ return ensureHeader(mAdapter.getSectionCount(), getContext().getString(sectionName));
}
public ListItemAdapter ensureHeader(String sectionName) {
}
public ListItemAdapter ensureHeader(int index, int sectionName) {
- return ensureHeader(index, getActivity().getString(sectionName));
+ return ensureHeader(index, getContext().getString(sectionName));
}
public ListItemAdapter ensureHeader(int index, String sectionName) {
ListItemAdapter adapter = mAdapter.getSection(sectionName);
}
public ListItemAdapter getSection(int section) {
- return getSection(getActivity().getString(section));
+ return getSection(getContext().getString(section));
}
public ListItemAdapter getSection(String section) {
}
public ListItem addItem(int sectionName, ListItem item) {
- return addItem(getActivity().getString(sectionName), item);
+ return addItem(getContext().getString(sectionName), item);
}
public ListItem addItem(int sectionName, ListItem item, int index) {
- return addItem(getActivity().getString(sectionName), item, index);
+ return addItem(getContext().getString(sectionName), item, index);
}
public ListItem addItem(String sectionName, ListItem item) {
}
public int getSectionItemCount(int section) {
- return getSectionItemCount(getActivity().getString(section));
+ return getSectionItemCount(getContext().getString(section));
}
public int getSectionItemCount(String section) {
}
public ListItem findItem(int item) {
- String text = getActivity().getString(item);
+ String text = getContext().getString(item);
for (ListItemAdapter adapter: mAdapter.getSections())
{
}
protected void setPadding() {
- float hor = getActivity().getResources().getDimension(R.dimen.list_horizontal_margin);
- float ver = getActivity().getResources().getDimension(R.dimen.list_vertical_margin);
+ float hor = getContext().getResources().getDimension(R.dimen.list_horizontal_margin);
+ float ver = getContext().getResources().getDimension(R.dimen.list_vertical_margin);
mListView.setPadding((int)hor, (int)ver, (int)hor, (int)ver);
}
}
public Context getContext() {
- return getFragment().getActivity();
+ return getFragment().getContext();
}
public FragmentInterfaceWrapper getFragment() {
package com.koushikdutta.widgets;
import android.app.Activity;
+import android.content.Context;
import android.os.Bundle;
import android.view.View;
public interface FragmentInterfaceWrapper {
public Activity getActivity();
+ public Context getContext();
public FragmentInterface getInternal();
public void setHasOptionsMenu(boolean options);
final FragmentManager fm = fa.getSupportFragmentManager();
FragmentTransaction ft = fa.getSupportFragmentManager().beginTransaction();
if (isPaged()) {
- final int curSize = fm.getBackStackEntryCount();
View v = getFragment().getView();
Assert.assertNotNull(v);
final View l = v.findViewById(R.id.list_fragment);
mFragment.mAdapter.notifyDataSetChanged();
return this;
}
-//
-// boolean mUseOnOff = false;
-// public void useYesNo() {
-// mUseOnOff = true;
-// }
-//
-// private void setSwitch(View view) {
-// Switch s = (Switch)view;
-// s.setTextOn(Context.getString(R.string.yes).toUpperCase());
-// s.setTextOff(Context.getString(R.string.no).toUpperCase());
-// view.setTag(view);
-// }
-
- private int mTheme;
- public int getTheme() {
- return mTheme;
- }
-
- public ListItem setTheme(int theme) {
- mTheme = theme;
- return this;
- }
public View getView(Context context, View convertView) {
- LayoutInflater inflater;
- int theme = getTheme();
- if (theme != 0) {
- inflater = (LayoutInflater) new ContextThemeWrapper(context, theme).getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- }
- else {
- inflater = LayoutInflater.from(context);
- }
+ LayoutInflater inflater = LayoutInflater.from(context);
if (convertView == null || convertView.getTag() != null) {
convertView = inflater.inflate(mFragment.getListItemResource(), null);
}
ListItem.this.onClick(cv);
}
});
-// if (mUseOnOff && !(cb instanceof CheckBox)) {
-// setSwitch(cb);
-// }
+
cb.setVisibility(CheckboxVisible ? View.VISIBLE : View.GONE);
cb.setChecked(checked);
import android.app.Activity;
import android.app.Fragment;
+import android.content.Context;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.LayoutInflater;
super.onResume();
}
+ @Override
+ public Context getContext() {
+ return getActivity();
+ }
+
public void onDetach() {
super.onDetach();
internal.onDetach();
package com.koushikdutta.widgets;
import android.app.Activity;
+import android.content.Context;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v4.app.Fragment;
public abstract class SupportFragment<T extends FragmentInterface> extends Fragment implements FragmentInterfaceWrapper {
public abstract T createFragmentInterface();
+ public Context getContext() {
+ return getActivity();
+ }
+
T internal;
public SupportFragment() {
internal = createFragmentInterface();
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>