Search in sources :

Example 1 with SimpleFloatViewManager

use of com.mobeta.android.dslv.SimpleFloatViewManager in project JamsMusicPlayer by psaravan.

the class CustomizeScreensDialog method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    parentActivity = getActivity();
    dialogFragment = (DialogFragment) getFragmentManager().findFragmentByTag("customizeScreensDialog");
    sharedPreferences = parentActivity.getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE);
    rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.customize_screens_layout, null);
    customizeScreensText = (TextView) rootView.findViewById(R.id.customize_screens_text);
    customizeScreensText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    customizeScreensText.setPaintFlags(customizeScreensText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    //Populate the arraylists with the settings saved in SharedPreferences.
    page1 = sharedPreferences.getString("PAGE_1", getResources().getString(R.string.artists_caps));
    page2 = sharedPreferences.getString("PAGE_2", getResources().getString(R.string.albums_caps));
    page3 = sharedPreferences.getString("PAGE_3", getResources().getString(R.string.songs_caps));
    page4 = sharedPreferences.getString("PAGE_4", getResources().getString(R.string.playlists_caps));
    page5 = sharedPreferences.getString("PAGE_5", getResources().getString(R.string.genres_caps));
    page6 = sharedPreferences.getString("PAGE_6", getResources().getString(R.string.folders_caps));
    if (!page1.equals("null") || !page1.equals(null)) {
        screenTitlesList.add(page1);
    }
    if (!page2.equals("null") || !page2.equals(null)) {
        screenTitlesList.add(page2);
    }
    if (!page3.equals("null") || !page3.equals(null)) {
        screenTitlesList.add(page3);
    }
    if (!page4.equals("null") || !page4.equals(null)) {
        screenTitlesList.add(page4);
    }
    if (!page5.equals("null") || !page5.equals(null)) {
        screenTitlesList.add(page5);
    }
    if (!page6.equals("null") || !page6.equals(null)) {
        screenTitlesList.add(page6);
    }
    listView = (DragSortListView) rootView.findViewById(R.id.customize_screens_listview);
    adapter = new CustomizeScreensListAdapter(parentActivity, screenTitlesList);
    listView.setAdapter(adapter);
    listView.setDropListener(onDrop);
    SimpleFloatViewManager simpleFloatViewManager = new SimpleFloatViewManager(listView);
    simpleFloatViewManager.setBackgroundColor(Color.TRANSPARENT);
    listView.setFloatViewManager(simpleFloatViewManager);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    //Set the dialog title.
    builder.setTitle(R.string.customize_screens);
    builder.setView(rootView);
    builder.setPositiveButton(R.string.done, new OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            dialogFragment.dismiss();
            //adapter.getItem(i) will get us the order for the screens.
            sharedPreferences.edit().putString("PAGE_1", adapter.getItem(0).toString().toUpperCase()).commit();
            sharedPreferences.edit().putString("PAGE_2", adapter.getItem(1).toString().toUpperCase()).commit();
            sharedPreferences.edit().putString("PAGE_3", adapter.getItem(2).toString().toUpperCase()).commit();
            sharedPreferences.edit().putString("PAGE_4", adapter.getItem(3).toString().toUpperCase()).commit();
            sharedPreferences.edit().putString("PAGE_5", adapter.getItem(4).toString().toUpperCase()).commit();
            sharedPreferences.edit().putString("PAGE_6", adapter.getItem(5).toString().toUpperCase()).commit();
            Toast.makeText(parentActivity, R.string.changes_saved, Toast.LENGTH_SHORT).show();
            //Restart the app.
            Intent i = parentActivity.getBaseContext().getPackageManager().getLaunchIntentForPackage(parentActivity.getBaseContext().getPackageName());
            i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            dialogFragment.dismiss();
            getActivity().finish();
            startActivity(i);
        }
    });
    return builder.create();
}
Also used : SimpleFloatViewManager(com.mobeta.android.dslv.SimpleFloatViewManager) AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener) Intent(android.content.Intent) SuppressLint(android.annotation.SuppressLint) Paint(android.graphics.Paint)

Example 2 with SimpleFloatViewManager

use of com.mobeta.android.dslv.SimpleFloatViewManager in project JamsMusicPlayer by psaravan.

the class NowPlayingQueueFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    //Inflate the correct layout based on the selected theme.
    mContext = getActivity().getApplicationContext();
    mApp = (Common) mContext;
    nowPlayingQueueFragment = this;
    sharedPreferences = mContext.getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE);
    mCursor = mApp.getService().getCursor();
    View rootView = (ViewGroup) inflater.inflate(R.layout.now_playing_queue_layout, container, false);
    receiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            updateSongInfo();
        }
    };
    //Notify the application that this fragment is now visible.
    sharedPreferences.edit().putBoolean("NOW_PLAYING_QUEUE_VISIBLE", true).commit();
    //Get the screen's parameters.
    displayMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    screenWidth = displayMetrics.widthPixels;
    screenHeight = displayMetrics.heightPixels;
    noMusicPlaying = (TextView) rootView.findViewById(R.id.now_playing_queue_no_music_playing);
    nowPlayingAlbumArt = (ImageView) rootView.findViewById(R.id.now_playing_queue_album_art);
    nowPlayingSongTitle = (TextView) rootView.findViewById(R.id.now_playing_queue_song_title);
    nowPlayingSongArtist = (TextView) rootView.findViewById(R.id.now_playing_queue_song_artist);
    nowPlayingSongContainer = (RelativeLayout) rootView.findViewById(R.id.now_playing_queue_current_song_container);
    noMusicPlaying.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
    nowPlayingSongTitle.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
    nowPlayingSongArtist.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
    nowPlayingQueueListView = (DragSortListView) rootView.findViewById(R.id.now_playing_queue_list_view);
    progressBar = (ProgressBar) rootView.findViewById(R.id.now_playing_queue_progressbar);
    playPauseButton = (ImageButton) rootView.findViewById(R.id.now_playing_queue_play);
    nextButton = (ImageButton) rootView.findViewById(R.id.now_playing_queue_next);
    previousButton = (ImageButton) rootView.findViewById(R.id.now_playing_queue_previous);
    //Apply the card layout's background based on the color theme.
    if (sharedPreferences.getString(Common.CURRENT_THEME, "LIGHT_CARDS_THEME").equals("LIGHT_CARDS_THEME")) {
        rootView.setBackgroundColor(0xFFEEEEEE);
        nowPlayingQueueListView.setDivider(getResources().getDrawable(R.drawable.transparent_drawable));
        nowPlayingQueueListView.setDividerHeight(3);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        layoutParams.setMargins(7, 3, 7, 3);
        nowPlayingQueueListView.setLayoutParams(layoutParams);
    } else if (sharedPreferences.getString(Common.CURRENT_THEME, "LIGHT_CARDS_THEME").equals("DARK_CARDS_THEME")) {
        rootView.setBackgroundColor(0xFF000000);
        nowPlayingQueueListView.setDivider(getResources().getDrawable(R.drawable.transparent_drawable));
        nowPlayingQueueListView.setDividerHeight(3);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        layoutParams.setMargins(7, 3, 7, 3);
        nowPlayingQueueListView.setLayoutParams(layoutParams);
    }
    //Set the Now Playing container layout's background.
    nowPlayingSongContainer.setBackgroundColor(UIElementsHelper.getNowPlayingQueueBackground(mContext));
    //Loop through the service's cursor and retrieve the current queue's information.
    if (sharedPreferences.getBoolean("SERVICE_RUNNING", false) == false || mApp.getService().getCurrentMediaPlayer() == null) {
        //No audio is currently playing.
        noMusicPlaying.setVisibility(View.VISIBLE);
        nowPlayingAlbumArt.setImageBitmap(mApp.decodeSampledBitmapFromResource(R.drawable.default_album_art, screenWidth / 3, screenWidth / 3));
        nowPlayingQueueListView.setVisibility(View.GONE);
        nowPlayingSongTitle.setVisibility(View.GONE);
        nowPlayingSongArtist.setVisibility(View.GONE);
        progressBar.setVisibility(View.GONE);
    } else {
        //Set the current play/pause conditions.
        try {
            //Hide the progressBar and display the controls.
            progressBar.setVisibility(View.GONE);
            playPauseButton.setVisibility(View.VISIBLE);
            nextButton.setVisibility(View.VISIBLE);
            previousButton.setVisibility(View.VISIBLE);
            if (mApp.getService().getCurrentMediaPlayer().isPlaying()) {
                playPauseButton.setImageResource(R.drawable.pause_holo_light);
            } else {
                playPauseButton.setImageResource(R.drawable.play_holo_light);
            }
        } catch (Exception e) {
            /* The mediaPlayer hasn't been initialized yet, so let's just keep the controls 
        		 * hidden for now. Once the mediaPlayer is initialized and it starts playing, 
        		 * updateSongInfo() will be called, and we can show the controls/hide the progressbar 
        		 * there. For now though, we'll display the progressBar.
        		 */
            progressBar.setVisibility(View.VISIBLE);
            playPauseButton.setVisibility(View.GONE);
            nextButton.setVisibility(View.GONE);
            previousButton.setVisibility(View.GONE);
        }
        //Retrieve and set the current title/artist/artwork.
        mCursor.moveToPosition(mApp.getService().getPlaybackIndecesList().get(mApp.getService().getCurrentSongIndex()));
        String currentTitle = mCursor.getString(mCursor.getColumnIndex(DBAccessHelper.SONG_TITLE));
        String currentArtist = mCursor.getString(mCursor.getColumnIndex(DBAccessHelper.SONG_ARTIST));
        nowPlayingSongTitle.setText(currentTitle);
        nowPlayingSongArtist.setText(currentArtist);
        File file = new File(mContext.getExternalCacheDir() + "/current_album_art.jpg");
        Bitmap bm = null;
        if (file.exists()) {
            bm = mApp.decodeSampledBitmapFromFile(file, screenWidth, screenHeight);
            nowPlayingAlbumArt.setScaleX(1.0f);
            nowPlayingAlbumArt.setScaleY(1.0f);
        } else {
            int defaultResource = UIElementsHelper.getIcon(mContext, "default_album_art");
            bm = mApp.decodeSampledBitmapFromResource(defaultResource, screenWidth, screenHeight);
            nowPlayingAlbumArt.setScaleX(0.5f);
            nowPlayingAlbumArt.setScaleY(0.5f);
        }
        nowPlayingAlbumArt.setImageBitmap(bm);
        noMusicPlaying.setPaintFlags(noMusicPlaying.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
        nowPlayingSongTitle.setPaintFlags(nowPlayingSongTitle.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.FAKE_BOLD_TEXT_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
        nowPlayingSongArtist.setPaintFlags(nowPlayingSongArtist.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
        /* Set the adapter. We'll pass in playbackIndecesList as the adapter's data backend.
             * The array can then be manipulated (reordered, items removed, etc) with no restrictions. 
             * Each integer element in the array will be used as a pointer to a specific cursor row, 
             * so there's no need to fiddle around with the actual cursor itself. */
        nowPlayingQueueListViewAdapter = new NowPlayingQueueListViewAdapter(getActivity(), mApp.getService().getPlaybackIndecesList());
        nowPlayingQueueListView.setAdapter(nowPlayingQueueListViewAdapter);
        nowPlayingQueueListView.setFastScrollEnabled(true);
        nowPlayingQueueListView.setDropListener(onDrop);
        nowPlayingQueueListView.setRemoveListener(onRemove);
        SimpleFloatViewManager simpleFloatViewManager = new SimpleFloatViewManager(nowPlayingQueueListView);
        simpleFloatViewManager.setBackgroundColor(Color.TRANSPARENT);
        nowPlayingQueueListView.setFloatViewManager(simpleFloatViewManager);
        //Scroll down to the current song.
        nowPlayingQueueListView.setSelection(mApp.getService().getCurrentSongIndex());
        nowPlayingQueueListView.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> arg0, View view, int index, long arg3) {
                mApp.getService().skipToTrack(index);
            }
        });
        playPauseButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                mApp.getService().togglePlaybackState();
            }
        });
        nextButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                mApp.getService().skipToNextTrack();
            }
        });
        previousButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                mApp.getService().skipToPreviousTrack();
            }
        });
    }
    return rootView;
}
Also used : Context(android.content.Context) SimpleFloatViewManager(com.mobeta.android.dslv.SimpleFloatViewManager) LayoutParams(android.view.ViewGroup.LayoutParams) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ViewGroup(android.view.ViewGroup) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver) ImageView(android.widget.ImageView) DragSortListView(com.mobeta.android.dslv.DragSortListView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) DisplayMetrics(android.util.DisplayMetrics) Paint(android.graphics.Paint) Bitmap(android.graphics.Bitmap) RelativeLayout(android.widget.RelativeLayout) OnClickListener(android.view.View.OnClickListener) File(java.io.File)

Example 3 with SimpleFloatViewManager

use of com.mobeta.android.dslv.SimpleFloatViewManager in project JamsMusicPlayer by psaravan.

the class QueueDrawerFragment method initListViewAdapter.

/**
     * Initializes the drag sort list view.
     *
     * @param initViewParams Pass true if the ListView is being
     *                       initialized for the very first time
     *                       (dividers, background colors and other
     *                       layout settings will be applied). Pass
     *                       false if the list just needs to be updated
     *                       with the current song.
     */
private void initListViewAdapter(boolean initViewParams) {
    if (initViewParams) {
        //Reset the initialization flag.
        mInitListViewParams = false;
        if (mApp.getCurrentTheme() == Common.DARK_THEME) {
            mListView.setDivider(mContext.getResources().getDrawable(R.drawable.list_divider));
        } else {
            mListView.setDivider(mContext.getResources().getDrawable(R.drawable.list_divider_light));
        }
        mListView.setDividerHeight(1);
        mListView.setFastScrollEnabled(true);
        //KitKat ListView margins.
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            //Calculate navigation bar height.
            int navigationBarHeight = 0;
            int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
            if (resourceId > 0) {
                navigationBarHeight = getResources().getDimensionPixelSize(resourceId);
            }
            mListView.setClipToPadding(false);
            mListView.setPadding(0, 0, 0, navigationBarHeight);
        }
    }
    mListViewAdapter = new QueueDrawerAdapter(mContext, mApp.getService().getPlaybackIndecesList());
    mListView.setAdapter(mListViewAdapter);
    mListView.setOnItemClickListener(onClick);
    mListView.setDropListener(onDrop);
    mListView.setRemoveListener(onRemove);
    SimpleFloatViewManager simpleFloatViewManager = new SimpleFloatViewManager(mListView);
    simpleFloatViewManager.setBackgroundColor(Color.TRANSPARENT);
    mListView.setFloatViewManager(simpleFloatViewManager);
    mListView.setVisibility(View.VISIBLE);
    mEmptyInfoText.setVisibility(View.INVISIBLE);
    /*
         * If the drawer is open, the user is probably scrolling through
         * the list already, so don't move the list to the new position.
         */
    if (!isDrawerOpen())
        mListView.setSelection(mApp.getService().getCurrentSongIndex());
}
Also used : SimpleFloatViewManager(com.mobeta.android.dslv.SimpleFloatViewManager) SuppressLint(android.annotation.SuppressLint) Paint(android.graphics.Paint)

Aggregations

Paint (android.graphics.Paint)3 SimpleFloatViewManager (com.mobeta.android.dslv.SimpleFloatViewManager)3 SuppressLint (android.annotation.SuppressLint)2 Intent (android.content.Intent)2 AlertDialog (android.app.AlertDialog)1 BroadcastReceiver (android.content.BroadcastReceiver)1 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 OnClickListener (android.content.DialogInterface.OnClickListener)1 Bitmap (android.graphics.Bitmap)1 DisplayMetrics (android.util.DisplayMetrics)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 ViewGroup (android.view.ViewGroup)1 LayoutParams (android.view.ViewGroup.LayoutParams)1 AdapterView (android.widget.AdapterView)1 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)1 ImageView (android.widget.ImageView)1 RelativeLayout (android.widget.RelativeLayout)1 TextView (android.widget.TextView)1