Last active
December 31, 2015 18:22
-
-
Save blundell/8025897 to your computer and use it in GitHub Desktop.
1 line annon inner class array initialisation because I want to be able to add & remove but I'm too lazy to extend BaseAdapter.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NavDrawerArrayAdapter extends ArrayAdapter<String> { | |
public NavDrawerArrayAdapter(final Context context) { | |
super(context, android.R.layout.simple_list_item_activated_1, android.R.id.text1, | |
new ArrayList<String>() {{ | |
add(context.getString(R.string.nav_drawer_section_explore)); | |
add(context.getString(R.string.nav_drawer_section_rewards)); | |
add(context.getString(R.string.nav_drawer_section_offers)); | |
add(context.getString(R.string.nav_drawer_section_events)); | |
}}); | |
refresh(); | |
} | |
public void refresh() { | |
if (MyApplication.isSignedIn()) { | |
remove(getContext().getString(R.string.nav_drawer_section_sign_in_up)); | |
add(getContext().getString(R.string.nav_drawer_section_account)); | |
} else { | |
add(getContext().getString(R.string.nav_drawer_section_sign_in_up)); | |
remove(getContext().getString(R.string.nav_drawer_section_account)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment