diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2015-09-12 21:57:47 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2015-09-12 21:57:47 +0900 |
commit | 8257fb0f2e6f43eda3beb5767e1408eea126d53d (patch) | |
tree | 23b920334b694ae891d1f029ab42dfa4fb60e7c3 /app/src/main/java/net/lacolaco/smileessence/view | |
parent | 97e4fbe6c0a81ec43b163bdcc6a4012039b8753a (diff) | |
download | SmileEssence-8257fb0f2e6f43eda3beb5767e1408eea126d53d.tar.gz |
PageFragment の名前をリフレクションで取るのはちょっと無理があったかもしれない
Diffstat (limited to 'app/src/main/java/net/lacolaco/smileessence/view')
9 files changed, 12 insertions, 38 deletions
diff --git a/app/src/main/java/net/lacolaco/smileessence/view/HistoryFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/HistoryFragment.java index a0e05283..a26832c1 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/HistoryFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/HistoryFragment.java @@ -35,11 +35,6 @@ import net.lacolaco.smileessence.activity.MainActivity; */ public class HistoryFragment extends CustomListFragment { - @Override - public String getName() { - return getString(R.string.page_name_history); - } - // --------------------- GETTER / SETTER METHODS --------------------- @Override diff --git a/app/src/main/java/net/lacolaco/smileessence/view/HomeFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/HomeFragment.java index f9b8262a..23b1339b 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/HomeFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/HomeFragment.java @@ -47,10 +47,6 @@ import java.util.List; import java.util.ListIterator; public class HomeFragment extends CustomListFragment { - @Override - public String getName() { - return getString(R.string.page_name_home); - } // --------------------- GETTER / SETTER METHODS --------------------- diff --git a/app/src/main/java/net/lacolaco/smileessence/view/MentionsFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/MentionsFragment.java index 2b0e95ef..831bd41e 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/MentionsFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/MentionsFragment.java @@ -44,10 +44,6 @@ import twitter4j.Twitter; import java.util.List; public class MentionsFragment extends CustomListFragment { - @Override - public String getName() { - return getString(R.string.page_name_mentions); - } // --------------------- GETTER / SETTER METHODS --------------------- diff --git a/app/src/main/java/net/lacolaco/smileessence/view/MessagesFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/MessagesFragment.java index 8f0232c5..ac0e8067 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/MessagesFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/MessagesFragment.java @@ -47,10 +47,6 @@ import java.util.List; * Fragment of messages list */ public class MessagesFragment extends CustomListFragment { - @Override - public String getName() { - return getString(R.string.page_name_messages); - } // --------------------- GETTER / SETTER METHODS --------------------- diff --git a/app/src/main/java/net/lacolaco/smileessence/view/PageFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/PageFragment.java index 335b4328..b5f54474 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/PageFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/PageFragment.java @@ -3,5 +3,4 @@ package net.lacolaco.smileessence.view; import android.app.Fragment; public abstract class PageFragment extends Fragment { - public abstract String getName(); } diff --git a/app/src/main/java/net/lacolaco/smileessence/view/PostFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/PostFragment.java index 22daa18c..91e0b05f 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/PostFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/PostFragment.java @@ -62,11 +62,6 @@ import java.io.File; public class PostFragment extends PageFragment implements TextWatcher, View.OnFocusChangeListener, View.OnClickListener, PostState.OnPostStateChangeListener { - @Override - public String getName() { - return getString(R.string.page_name_post); - } - // ------------------------------ FIELDS ------------------------------ private EditText editText; diff --git a/app/src/main/java/net/lacolaco/smileessence/view/SearchFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/SearchFragment.java index 381affba..f1a069bc 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/SearchFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/SearchFragment.java @@ -66,10 +66,6 @@ import java.util.List; public class SearchFragment extends CustomListFragment implements View.OnClickListener, View.OnFocusChangeListener, SearchListAdapter.OnQueryChangeListener { - @Override - public String getName() { - return getString(R.string.page_name_search); - } // ------------------------------ FIELDS ------------------------------ diff --git a/app/src/main/java/net/lacolaco/smileessence/view/UserListFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/UserListFragment.java index 620584eb..3733358a 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/UserListFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/UserListFragment.java @@ -57,10 +57,6 @@ import twitter4j.Twitter; import java.util.List; public class UserListFragment extends CustomListFragment implements View.OnClickListener { - @Override - public String getName() { - return getString(R.string.page_name_list); - } // ------------------------------ FIELDS ------------------------------ diff --git a/app/src/main/java/net/lacolaco/smileessence/view/adapter/PageListAdapter.java b/app/src/main/java/net/lacolaco/smileessence/view/adapter/PageListAdapter.java index 71b00124..bc933e88 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/adapter/PageListAdapter.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/adapter/PageListAdapter.java @@ -36,6 +36,8 @@ import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.logging.Logger; import net.lacolaco.smileessence.view.PageFragment; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; @@ -102,13 +104,12 @@ public class PageListAdapter extends FragmentPagerAdapter implements ViewPager.O return Fragment.instantiate(context, info.getFragmentClass().getName(), info.getArgs()); } - public void addPage(Class<? extends PageFragment> klass, Bundle args) { - this.addPage(klass, args, true); + public void addPage(Class<? extends PageFragment> klass, String name, Bundle args) { + this.addPage(klass, name, args, true); } - public void addPage(Class<? extends PageFragment> klass, Bundle args, boolean notifyChanged) { - PageInfo info = new PageInfo(klass, args); - pages.add(info); + public void addPage(Class<? extends PageFragment> klass, String name, Bundle args, boolean notifyChanged) { + pages.add(new PageInfo(klass, name, args)); if (notifyChanged) notifyDataSetChanged(); } @@ -124,7 +125,7 @@ public class PageListAdapter extends FragmentPagerAdapter implements ViewPager.O public void notifyDataSetChanged() { ArrayList<String> itemList = new ArrayList<>(); for (PageInfo f : pages) { - itemList.add(f.getFragmentClass().getName()); //TODO + itemList.add(f.getName()); } ArrayAdapter<String> adapter = new ArrayAdapter<>(context, R.layout.navigation_list_item, R.id.navigation_list_item_text, itemList); actionBar.setListNavigationCallbacks(adapter, this); @@ -134,9 +135,11 @@ public class PageListAdapter extends FragmentPagerAdapter implements ViewPager.O private static final class PageInfo { private final Class<? extends PageFragment> fragmentClass; private final Bundle args; + private final String name; - PageInfo(Class<? extends PageFragment> _fragmentClass, Bundle _args) { + PageInfo(Class<? extends PageFragment> _fragmentClass, String _name, Bundle _args) { fragmentClass = _fragmentClass; + name = _name; args = _args; } @@ -144,6 +147,8 @@ public class PageListAdapter extends FragmentPagerAdapter implements ViewPager.O return fragmentClass; } + public String getName() { return name; } + public Bundle getArgs() { return args; } |