external/koush/Widgets
Révision | e220b863b498c27e6399d93e9efdf3a001757f14 (tree) |
---|---|
l'heure | 2013-02-28 08:58:45 |
Auteur | Koushik Dutta <koushd@gmai...> |
Commiter | Koushik Dutta |
convenience functions and fixes
@@ -1,5 +1,7 @@ | ||
1 | 1 | package com.koushikdutta.widgets; |
2 | 2 | |
3 | +import com.koushikdutta.widgets.BetterListFragmentInternal.ListItemAdapter; | |
4 | + | |
3 | 5 | import android.os.Bundle; |
4 | 6 | import android.view.View; |
5 | 7 |
@@ -29,4 +31,68 @@ public class BetterListFragment extends SupportFragment<BetterListFragmentIntern | ||
29 | 31 | |
30 | 32 | protected void onCreate(Bundle savedInstanceState, View view) { |
31 | 33 | } |
34 | + | |
35 | + | |
36 | + public void removeSection(int section) { | |
37 | + getInternal().removeSection(section); | |
38 | + } | |
39 | + | |
40 | + public void removeSection(String section) { | |
41 | + getInternal().removeSection(section); | |
42 | + } | |
43 | + | |
44 | + | |
45 | + | |
46 | + public ListItemAdapter ensureHeader(int sectionName) { | |
47 | + return getInternal().ensureHeader(sectionName); | |
48 | + } | |
49 | + | |
50 | + public ListItemAdapter ensureHeader(String sectionName) { | |
51 | + return getInternal().ensureHeader(sectionName); | |
52 | + } | |
53 | + | |
54 | + public ListItemAdapter ensureHeader(int index, int sectionName) { | |
55 | + return getInternal().ensureHeader(sectionName); | |
56 | + } | |
57 | + public ListItemAdapter ensureHeader(int index, String sectionName) { | |
58 | + return getInternal().ensureHeader(index, sectionName); | |
59 | + | |
60 | + } | |
61 | + | |
62 | + public ListItemAdapter getSection(int section) { | |
63 | + return getInternal().getSection(section); | |
64 | + } | |
65 | + | |
66 | + public ListItemAdapter getSection(String section) { | |
67 | + return getInternal().getSection(section); | |
68 | + } | |
69 | + | |
70 | + public ListItem addItem(int sectionName, ListItem item) { | |
71 | + return getInternal().addItem(sectionName, item); | |
72 | + } | |
73 | + | |
74 | + public ListItem addItem(int sectionName, ListItem item, int index) { | |
75 | + return getInternal().addItem(sectionName, item); | |
76 | + } | |
77 | + | |
78 | + public ListItem addItem(String sectionName, ListItem item) { | |
79 | + return getInternal().addItem(sectionName, item); | |
80 | + } | |
81 | + | |
82 | + public void clear() { | |
83 | + getInternal().clear(); | |
84 | + } | |
85 | + | |
86 | + public void clearSection(int section) { | |
87 | + getInternal().clearSection(section); | |
88 | + } | |
89 | + | |
90 | + public void clearSection(String section) { | |
91 | + getInternal().clearSection(section); | |
92 | + } | |
93 | + | |
94 | + public void removeItem(ListItem item) { | |
95 | + getInternal().removeItem(item); | |
96 | + } | |
97 | + | |
32 | 98 | } |
@@ -1,9 +1,13 @@ | ||
1 | 1 | package com.koushikdutta.widgets; |
2 | 2 | |
3 | 3 | import android.app.Activity; |
4 | +import android.os.Bundle; | |
4 | 5 | |
5 | 6 | public interface FragmentInterfaceWrapper { |
6 | 7 | public Activity getActivity(); |
7 | 8 | public FragmentInterface getInternal(); |
8 | 9 | public void setHasOptionsMenu(boolean options); |
10 | + | |
11 | + void setArguments(Bundle bundle); | |
12 | + Bundle getArguments(); | |
9 | 13 | } |
@@ -54,15 +54,12 @@ public class ListContentFragmentInternal extends BetterListFragmentInternal { | ||
54 | 54 | return mContainer instanceof ViewSwitcher; |
55 | 55 | } |
56 | 56 | |
57 | - void setContentNative(FragmentInterfaceWrapper last) { | |
57 | + void setContentNative() { | |
58 | 58 | android.app.Fragment f = (android.app.Fragment)mCurrentContent; |
59 | 59 | Activity fa = getActivity(); |
60 | 60 | android.app.FragmentTransaction ft = fa.getFragmentManager().beginTransaction(); |
61 | - if (last != null) | |
62 | - ft.replace(R.id.content, f); | |
63 | - else | |
64 | - ft.add(R.id.content, f); | |
65 | - ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); | |
61 | + ft.replace(R.id.content, f); | |
62 | + ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); | |
66 | 63 | if (mContainer instanceof ViewSwitcher) { |
67 | 64 | ViewSwitcher switcher = (ViewSwitcher)mContainer; |
68 | 65 | if (mContent != switcher.getCurrentView()) |
@@ -72,16 +69,12 @@ public class ListContentFragmentInternal extends BetterListFragmentInternal { | ||
72 | 69 | } |
73 | 70 | |
74 | 71 | public void setContent(FragmentInterfaceWrapper content, boolean clearChoices) { |
75 | - FragmentInterfaceWrapper last = mCurrentContent; | |
76 | 72 | mCurrentContent = content; |
77 | 73 | if (getActivity() instanceof FragmentActivity) { |
78 | 74 | Fragment f = (Fragment)mCurrentContent; |
79 | 75 | FragmentActivity fa = (FragmentActivity)getActivity(); |
80 | 76 | FragmentTransaction ft = fa.getSupportFragmentManager().beginTransaction(); |
81 | - if (last != null) | |
82 | - ft.replace(R.id.content, f); | |
83 | - else | |
84 | - ft.add(R.id.content, f); | |
77 | + ft.replace(R.id.content, f); | |
85 | 78 | ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); |
86 | 79 | if (mContainer instanceof ViewSwitcher) { |
87 | 80 | ViewSwitcher switcher = (ViewSwitcher)mContainer; |
@@ -91,7 +84,7 @@ public class ListContentFragmentInternal extends BetterListFragmentInternal { | ||
91 | 84 | ft.commit(); |
92 | 85 | } |
93 | 86 | else { |
94 | - setContentNative(last); | |
87 | + setContentNative(); | |
95 | 88 | } |
96 | 89 | |
97 | 90 | if (clearChoices) |