use of android.app.ActionBar in project JamsMusicPlayer by psaravan.
the class NowPlayingQueueActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
mContext = this;
sharedPreferences = getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE);
//Get the screen's parameters.
DisplayMetrics displayMetrics = new DisplayMetrics();
this.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int screenWidth = displayMetrics.widthPixels;
//Set the UI theme.
if (sharedPreferences.getString(Common.CURRENT_THEME, "LIGHT_CARDS_THEME").equals("DARK_THEME") || sharedPreferences.getString(Common.CURRENT_THEME, "LIGHT_CARDS_THEME").equals("DARK_CARDS_THEME")) {
setTheme(R.style.AppTheme);
} else {
setTheme(R.style.AppThemeLight);
}
super.onCreate(savedInstanceState);
if (getOrientation().equals("PORTRAIT")) {
//Finish this activity and relaunch the activity that called this one.
Intent intent = new Intent(this, (Class<?>) getIntent().getSerializableExtra("CALLING_CLASS"));
intent.putExtras(getIntent());
intent.putExtra("NEW_PLAYLIST", false);
intent.putExtra("CALLED_FROM_FOOTER", true);
intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
finish();
startActivity(intent);
return;
} else {
setContentView(R.layout.activity_now_playing_queue);
final Fragment nowPlayingQueueFragment = new NowPlayingQueueFragment();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.add(R.id.now_playing_queue_container, nowPlayingQueueFragment, "nowPlayingQueueFragment");
transaction.commit();
SpannableString s = new SpannableString(getResources().getString(R.string.current_queue));
s.setSpan(new TypefaceSpan(this, "RobotoCondensed-Light"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
// Update the action bar title with the TypefaceSpan instance.
ActionBar actionBar = getActionBar();
actionBar.setTitle(s);
actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.holo_gray_selector));
}
}
use of android.app.ActionBar in project JamsMusicPlayer by psaravan.
the class PlaylistEditorActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
//Initialize Context and SharedPreferences.
mContext = this;
mApp = (Common) this.getApplicationContext();
sharedPreferences = mContext.getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE);
//Set the UI theme.
if (mApp.getCurrentTheme() == Common.DARK_THEME) {
setTheme(R.style.AppTheme);
} else {
setTheme(R.style.AppThemeLight);
}
super.onCreate(savedInstanceState);
//Create a set of options to optimize the bitmap memory usage.
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
options.inJustDecodeBounds = false;
options.inPurgeable = true;
//Display Image Options.
displayImageOptions = new DisplayImageOptions.Builder().showImageForEmptyUri(R.drawable.default_album_art).showImageOnFail(R.drawable.default_album_art).showStubImage(R.drawable.transparent_drawable).cacheInMemory(false).cacheOnDisc(true).decodingOptions(options).imageScaleType(ImageScaleType.EXACTLY).bitmapConfig(Bitmap.Config.RGB_565).displayer(new FadeInBitmapDisplayer(400)).delayBeforeLoading(100).build();
//Attach tabs to the ActionBar.
ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
//Add the artists tab.
String artistsLabel = getResources().getString(R.string.artists);
Tab tab = actionBar.newTab();
tab.setText(artistsLabel);
TabListener<ArtistsPickerFragment> artistsTabListener = new TabListener<ArtistsPickerFragment>(this, artistsLabel, ArtistsPickerFragment.class);
tab.setTabListener(artistsTabListener);
actionBar.addTab(tab);
//Add the albums tab.
String albumsLabel = getResources().getString(R.string.albums);
tab = actionBar.newTab();
tab.setText(albumsLabel);
TabListener<AlbumsPickerFragment> albumsTabListener = new TabListener<AlbumsPickerFragment>(this, albumsLabel, AlbumsPickerFragment.class);
tab.setTabListener(albumsTabListener);
actionBar.addTab(tab);
//Add the songs tab.
String songsLabel = getResources().getString(R.string.songs);
tab = actionBar.newTab();
tab.setText(songsLabel);
TabListener<SongsPickerFragment> songsTabListener = new TabListener<SongsPickerFragment>(this, songsLabel, SongsPickerFragment.class);
tab.setTabListener(songsTabListener);
actionBar.addTab(tab);
}
use of android.app.ActionBar in project JamsMusicPlayer by psaravan.
the class PlaylistEditorActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.add_to_music_library, menu);
ActionBar actionBar = getActionBar();
SpannableString s = new SpannableString(getResources().getString(R.string.create_playlist));
s.setSpan(new TypefaceSpan(this, "RobotoCondensed-Light"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
actionBar.setTitle(s);
return super.onCreateOptionsMenu(menu);
}
use of android.app.ActionBar in project JamsMusicPlayer by psaravan.
the class MusicLibraryEditorActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.add_to_music_library, menu);
ActionBar actionBar = getActionBar();
actionBar.setBackgroundDrawable(UIElementsHelper.getGeneralActionBarBackground(mContext));
actionBar.setIcon(mContext.getResources().getIdentifier(libraryIconName, "drawable", mContext.getPackageName()));
SpannableString s = new SpannableString(libraryName);
s.setSpan(new TypefaceSpan(this, "RobotoCondensed-Light"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
actionBar.setTitle(s);
return super.onCreateOptionsMenu(menu);
}
use of android.app.ActionBar in project JamsMusicPlayer by psaravan.
the class MusicLibraryEditorActivity method onCreate.
@SuppressWarnings("unchecked")
@Override
public void onCreate(Bundle savedInstanceState) {
//Initialize Context and SharedPreferences.
mContext = this;
mApp = (Common) mContext.getApplicationContext();
//Retrieve the name/icon of the library from the arguments.
libraryName = getIntent().getExtras().getString("LIBRARY_NAME");
libraryIconName = getIntent().getExtras().getString("LIBRARY_ICON");
if (getIntent().getExtras().getSerializable("SONG_IDS_HASH_SET") != null) {
songDBIdsList = (HashSet<String>) getIntent().getExtras().getSerializable("SONG_IDS_HASH_SET");
}
//Set the UI theme.
if (mApp.getCurrentTheme() == Common.DARK_THEME) {
setTheme(R.style.AppTheme);
} else {
setTheme(R.style.AppThemeLight);
}
super.onCreate(savedInstanceState);
//Initialize the database helper.
dbHelper = new DBAccessHelper(mContext.getApplicationContext());
//Create a set of options to optimize the bitmap memory usage.
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
options.inJustDecodeBounds = false;
options.inPurgeable = true;
//Display Image Options.
int defaultArt = UIElementsHelper.getIcon(mContext, "default_album_art_padded");
displayImageOptions = new DisplayImageOptions.Builder().showImageForEmptyUri(R.drawable.default_album_art).showImageOnFail(R.drawable.default_album_art).showStubImage(R.drawable.transparent_drawable).cacheInMemory(false).cacheOnDisc(true).decodingOptions(options).imageScaleType(ImageScaleType.EXACTLY).bitmapConfig(Bitmap.Config.RGB_565).displayer(new FadeInBitmapDisplayer(400)).delayBeforeLoading(100).build();
//Attach tabs to the ActionBar.
ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
//Add the artists tab.
String artistsLabel = getResources().getString(R.string.artists);
Tab tab = actionBar.newTab();
tab.setText(artistsLabel);
TabListener<ArtistsPickerFragment> artistsTabListener = new TabListener<ArtistsPickerFragment>(this, artistsLabel, ArtistsPickerFragment.class);
tab.setTabListener(artistsTabListener);
actionBar.addTab(tab);
//Add the albums tab.
String albumsLabel = getResources().getString(R.string.albums);
tab = actionBar.newTab();
tab.setText(albumsLabel);
TabListener<AlbumsPickerFragment> albumsTabListener = new TabListener<AlbumsPickerFragment>(this, albumsLabel, AlbumsPickerFragment.class);
tab.setTabListener(albumsTabListener);
actionBar.addTab(tab);
//Add the songs tab.
String songsLabel = getResources().getString(R.string.songs);
tab = actionBar.newTab();
tab.setText(songsLabel);
TabListener<SongsPickerFragment> songsTabListener = new TabListener<SongsPickerFragment>(this, songsLabel, SongsPickerFragment.class);
tab.setTabListener(songsTabListener);
actionBar.addTab(tab);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
getWindow().setBackgroundDrawable(UIElementsHelper.getGeneralActionBarBackground(mContext));
int topPadding = Common.getStatusBarHeight(mContext);
View activityView = (View) findViewById(android.R.id.content);
//Calculate ActionBar height
TypedValue tv = new TypedValue();
int actionBarHeight = 0;
if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
}
if (activityView != null) {
activityView.setPadding(0, topPadding + actionBarHeight, 0, 0);
}
}
}
Aggregations