Search in sources :

Example 16 with ActionBar

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));
    }
}
Also used : SpannableString(android.text.SpannableString) FragmentTransaction(android.support.v4.app.FragmentTransaction) Intent(android.content.Intent) DisplayMetrics(android.util.DisplayMetrics) Fragment(android.support.v4.app.Fragment) ActionBar(android.app.ActionBar) TypefaceSpan(com.jams.music.player.Utils.TypefaceSpan)

Example 17 with ActionBar

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);
}
Also used : DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions) SpannableString(android.text.SpannableString) Tab(android.app.ActionBar.Tab) FadeInBitmapDisplayer(com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer) BitmapFactory(android.graphics.BitmapFactory) ActionBar(android.app.ActionBar)

Example 18 with ActionBar

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);
}
Also used : SpannableString(android.text.SpannableString) MenuInflater(android.view.MenuInflater) ActionBar(android.app.ActionBar) TypefaceSpan(com.jams.music.player.Utils.TypefaceSpan)

Example 19 with ActionBar

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);
}
Also used : SpannableString(android.text.SpannableString) MenuInflater(android.view.MenuInflater) ActionBar(android.app.ActionBar) TypefaceSpan(com.jams.music.player.Utils.TypefaceSpan)

Example 20 with ActionBar

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);
        }
    }
}
Also used : DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions) DBAccessHelper(com.jams.music.player.DBHelpers.DBAccessHelper) SpannableString(android.text.SpannableString) View(android.view.View) Tab(android.app.ActionBar.Tab) FadeInBitmapDisplayer(com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer) BitmapFactory(android.graphics.BitmapFactory) ActionBar(android.app.ActionBar) TypedValue(android.util.TypedValue)

Aggregations

ActionBar (android.app.ActionBar)265 View (android.view.View)58 Intent (android.content.Intent)35 TextView (android.widget.TextView)21 ColorDrawable (android.graphics.drawable.ColorDrawable)20 OnClickListener (android.view.View.OnClickListener)14 AdapterView (android.widget.AdapterView)14 ListView (android.widget.ListView)12 Bundle (android.os.Bundle)10 Test (org.junit.Test)10 SharedPreferences (android.content.SharedPreferences)9 Uri (android.net.Uri)9 Button (android.widget.Button)9 AlertDialog (android.app.AlertDialog)8 DialogInterface (android.content.DialogInterface)8 ViewPager (android.support.v4.view.ViewPager)8 SpannableString (android.text.SpannableString)8 ComponentName (android.content.ComponentName)7 ArrayAdapter (android.widget.ArrayAdapter)7 FrameLayout (android.widget.FrameLayout)7