OSDN Git Service

theme cleanups
authorKoushik Dutta <koushd@gmail.com>
Fri, 1 Mar 2013 22:59:36 +0000 (14:59 -0800)
committerKoushik Dutta <koushd@gmail.com>
Fri, 1 Mar 2013 22:59:36 +0000 (14:59 -0800)
Change-Id: I38a9261b6eb7448ec909cdeeca20d9768061283a

Widgets/src/com/koushikdutta/widgets/BetterListFragmentInternal.java
Widgets/src/com/koushikdutta/widgets/FragmentInterface.java
Widgets/src/com/koushikdutta/widgets/FragmentInterfaceWrapper.java
Widgets/src/com/koushikdutta/widgets/ListContentFragmentInternal.java
Widgets/src/com/koushikdutta/widgets/ListItem.java
Widgets/src/com/koushikdutta/widgets/NativeFragment.java
Widgets/src/com/koushikdutta/widgets/SupportFragment.java
WidgetsSample/.classpath

index 12d1906..e201b18 100644 (file)
@@ -139,7 +139,7 @@ public class BetterListFragmentInternal extends FragmentInterface {
 //    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) {
@@ -147,7 +147,7 @@ public class BetterListFragmentInternal extends FragmentInterface {
     }
 
     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);
@@ -161,7 +161,7 @@ public class BetterListFragmentInternal extends FragmentInterface {
     }
     
     public ListItemAdapter getSection(int section) {
-        return getSection(getActivity().getString(section));
+        return getSection(getContext().getString(section));
     }
     
     public ListItemAdapter getSection(String section) {
@@ -169,11 +169,11 @@ public class BetterListFragmentInternal extends FragmentInterface {
     }
 
     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) {
@@ -181,7 +181,7 @@ public class BetterListFragmentInternal extends FragmentInterface {
     }
     
     public int getSectionItemCount(int section) {
-        return getSectionItemCount(getActivity().getString(section));
+        return getSectionItemCount(getContext().getString(section));
     }
     
     public int getSectionItemCount(String section) {
@@ -213,7 +213,7 @@ public class BetterListFragmentInternal extends FragmentInterface {
     }
     
     public ListItem findItem(int item) {
-        String text = getActivity().getString(item);
+        String text = getContext().getString(item);
         
         for (ListItemAdapter adapter: mAdapter.getSections())
         {
@@ -315,8 +315,8 @@ public class BetterListFragmentInternal extends FragmentInterface {
     }
 
     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);
     }
 
index 02556db..7292bd9 100644 (file)
@@ -35,7 +35,7 @@ public abstract class FragmentInterface {
     }
     
     public Context getContext() {
-        return getFragment().getActivity();
+        return getFragment().getContext();
     }
     
     public FragmentInterfaceWrapper getFragment() {
index 3793a57..9062a49 100644 (file)
 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);
     
index bd77d34..cd41057 100644 (file)
@@ -163,7 +163,6 @@ public class ListContentFragmentInternal extends BetterListFragmentInternal {
             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);
index f4e30c3..ce70da5 100644 (file)
@@ -150,38 +150,9 @@ public class ListItem {
         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);
         }
@@ -199,9 +170,7 @@ public class ListItem {
                 ListItem.this.onClick(cv);
             }
         });
-//        if (mUseOnOff && !(cb instanceof CheckBox)) {
-//            setSwitch(cb);
-//        }
+
         cb.setVisibility(CheckboxVisible ? View.VISIBLE : View.GONE);
         cb.setChecked(checked);
 
index f87d1d5..74bc465 100644 (file)
@@ -18,6 +18,7 @@ package com.koushikdutta.widgets;
 
 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;
@@ -35,6 +36,11 @@ public abstract class NativeFragment<T extends FragmentInterface> extends Fragme
         super.onResume();
     }
     
+    @Override
+    public Context getContext() {
+        return getActivity();
+    }
+    
     public void onDetach() {
         super.onDetach();
         internal.onDetach();
index e6a1a74..85bafea 100644 (file)
@@ -17,6 +17,7 @@
 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;
@@ -30,6 +31,10 @@ import android.view.ViewGroup;
 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();
index a4763d1..3f9691c 100644 (file)
@@ -1,8 +1,8 @@
 <?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>