Example usage for android.graphics Paint SUBPIXEL_TEXT_FLAG

List of usage examples for android.graphics Paint SUBPIXEL_TEXT_FLAG

Introduction

In this page you can find the example usage for android.graphics Paint SUBPIXEL_TEXT_FLAG.

Prototype

int SUBPIXEL_TEXT_FLAG

To view the source code for android.graphics Paint SUBPIXEL_TEXT_FLAG.

Click Source Link

Document

Paint flag that enables subpixel positioning of text.

Usage

From source file:com.jelly.music.player.NowPlayingQueueActivity.NowPlayingQueueFragment.java

@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;//from  w  w w.j  a  v  a 2  s.  c  o m
    nowPlayingQueueFragment = this;
    sharedPreferences = mContext.getSharedPreferences("com.jelly.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;
}

From source file:com.aniruddhc.acemusic.player.NowPlayingQueueActivity.NowPlayingQueueFragment.java

@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;//from w  ww .  j  a va 2s  .co m
    nowPlayingQueueFragment = this;
    sharedPreferences = mContext.getSharedPreferences("com.aniruddhc.acemusic.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;
}

From source file:com.aniruddhc.acemusic.player.EqualizerActivity.EqualizerActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    //Context./*from ww w  .  j  a v  a  2  s.c  o m*/
    mContext = getApplicationContext();
    mApp = (Common) mContext.getApplicationContext();
    mFragment = this;

    setTheme();
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_equalizer);

    //Equalizer container elements.
    mScrollView = (ScrollView) findViewById(R.id.equalizerScrollView);
    mScrollView.setBackgroundColor(UIElementsHelper.getBackgroundColor(mContext));

    //50Hz equalizer controls.
    equalizer50HzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer50Hz);
    text50HzGainTextView = (TextView) findViewById(R.id.text50HzGain);
    text50Hz = (TextView) findViewById(R.id.text50Hz);

    //130Hz equalizer controls.
    equalizer130HzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer130Hz);
    text130HzGainTextView = (TextView) findViewById(R.id.text130HzGain);
    text130Hz = (TextView) findViewById(R.id.text130Hz);

    //320Hz equalizer controls.
    equalizer320HzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer320Hz);
    text320HzGainTextView = (TextView) findViewById(R.id.text320HzGain);
    text320Hz = (TextView) findViewById(R.id.text320Hz);

    //800Hz equalizer controls.
    equalizer800HzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer800Hz);
    text800HzGainTextView = (TextView) findViewById(R.id.text800HzGain);
    text800Hz = (TextView) findViewById(R.id.text800Hz);

    //2kHz equalizer controls.
    equalizer2kHzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer2kHz);
    text2kHzGainTextView = (TextView) findViewById(R.id.text2kHzGain);
    text2kHz = (TextView) findViewById(R.id.text2kHz);

    //5kHz equalizer controls.
    equalizer5kHzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer5kHz);
    text5kHzGainTextView = (TextView) findViewById(R.id.text5kHzGain);
    text5kHz = (TextView) findViewById(R.id.text5kHz);

    //12.5kHz equalizer controls.
    equalizer12_5kHzSeekBar = (VerticalSeekBar) findViewById(R.id.equalizer12_5kHz);
    text12_5kHzGainTextView = (TextView) findViewById(R.id.text12_5kHzGain);
    text12_5kHz = (TextView) findViewById(R.id.text12_5kHz);

    //Equalizer preset controls.
    loadPresetButton = (RelativeLayout) findViewById(R.id.loadPresetButton);
    saveAsPresetButton = (RelativeLayout) findViewById(R.id.saveAsPresetButton);
    resetAllButton = (RelativeLayout) findViewById(R.id.resetAllButton);
    loadPresetText = (TextView) findViewById(R.id.load_preset_text);
    savePresetText = (TextView) findViewById(R.id.save_as_preset_text);
    resetAllText = (TextView) findViewById(R.id.reset_all_text);

    //Audio FX elements.
    virtualizerSeekBar = (SeekBar) findViewById(R.id.virtualizer_seekbar);
    bassBoostSeekBar = (SeekBar) findViewById(R.id.bass_boost_seekbar);
    reverbSpinner = (Spinner) findViewById(R.id.reverb_spinner);
    virtualizerTitle = (TextView) findViewById(R.id.virtualizer_title_text);
    bassBoostTitle = (TextView) findViewById(R.id.bass_boost_title_text);
    reverbTitle = (TextView) findViewById(R.id.reverb_title_text);

    text50HzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text130HzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text320HzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text800HzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text2kHzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text5kHzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text12_5kHzGainTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text50Hz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text130Hz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text320Hz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text800Hz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text2kHz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text5kHz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    text12_5kHz.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));

    loadPresetText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Bold"));
    savePresetText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Bold"));
    resetAllText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Bold"));

    text50HzGainTextView.setPaintFlags(
            text50HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text130HzGainTextView.setPaintFlags(
            text130HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text320HzGainTextView.setPaintFlags(
            text320HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text800HzGainTextView.setPaintFlags(
            text130HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text2kHzGainTextView.setPaintFlags(
            text320HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text5kHzGainTextView.setPaintFlags(
            text130HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text12_5kHzGainTextView.setPaintFlags(
            text320HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text50Hz.setPaintFlags(text50Hz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text130Hz.setPaintFlags(text130Hz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text320Hz.setPaintFlags(text320Hz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text800Hz.setPaintFlags(text800Hz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text2kHz.setPaintFlags(text2kHz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text5kHz.setPaintFlags(text5kHz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    text12_5kHz.setPaintFlags(text12_5kHz.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);

    loadPresetText.setPaintFlags(
            text50HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    savePresetText.setPaintFlags(
            text50HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    resetAllText.setPaintFlags(
            text50HzGainTextView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);

    text50HzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text130HzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text320HzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text800HzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text2kHzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text5kHzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text12_5kHzGainTextView.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text50Hz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text130Hz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text320Hz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text800Hz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text2kHz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text5kHz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    text12_5kHz.setTextColor(UIElementsHelper.getSmallTextColor(mContext));

    //Init reverb presets.
    ArrayList<String> reverbPresets = new ArrayList<String>();
    reverbPresets.add("None");
    reverbPresets.add("Large Hall");
    reverbPresets.add("Large Room");
    reverbPresets.add("Medium Hall");
    reverbPresets.add("Medium Room");
    reverbPresets.add("Small Room");
    reverbPresets.add("Plate");

    ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
            reverbPresets);
    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    reverbSpinner.setAdapter(dataAdapter);

    //Set the max values for the seekbars.
    virtualizerSeekBar.setMax(1000);
    bassBoostSeekBar.setMax(1000);

    virtualizerTitle.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    virtualizerTitle.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    virtualizerTitle
            .setPaintFlags(virtualizerTitle.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    bassBoostTitle.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    bassBoostTitle.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    bassBoostTitle
            .setPaintFlags(bassBoostTitle.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    reverbTitle.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Regular"));
    reverbTitle.setTextColor(UIElementsHelper.getSmallTextColor(mContext));
    reverbTitle.setPaintFlags(reverbTitle.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    resetAllButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            //Reset all sliders to 0.
            equalizer50HzSeekBar.setProgressAndThumb(16);
            equalizer130HzSeekBar.setProgressAndThumb(16);
            equalizer320HzSeekBar.setProgressAndThumb(16);
            equalizer800HzSeekBar.setProgressAndThumb(16);
            equalizer2kHzSeekBar.setProgressAndThumb(16);
            equalizer5kHzSeekBar.setProgressAndThumb(16);
            equalizer12_5kHzSeekBar.setProgressAndThumb(16);
            virtualizerSeekBar.setProgress(0);
            bassBoostSeekBar.setProgress(0);
            reverbSpinner.setSelection(0, false);

            //Apply the new setings to the service.
            applyCurrentEQSettings();

            //Show a confirmation toast.
            Toast.makeText(mContext, R.string.eq_reset, Toast.LENGTH_SHORT).show();

        }

    });

    loadPresetButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            buildLoadPresetDialog().show();

        }

    });

    saveAsPresetButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            buildSavePresetDialog().show();

        }

    });

    equalizer50HzSeekBar.setOnSeekBarChangeListener(equalizer50HzListener);
    equalizer130HzSeekBar.setOnSeekBarChangeListener(equalizer130HzListener);
    equalizer320HzSeekBar.setOnSeekBarChangeListener(equalizer320HzListener);
    equalizer800HzSeekBar.setOnSeekBarChangeListener(equalizer800HzListener);
    equalizer2kHzSeekBar.setOnSeekBarChangeListener(equalizer2kHzListener);
    equalizer5kHzSeekBar.setOnSeekBarChangeListener(equalizer5kHzListener);
    equalizer12_5kHzSeekBar.setOnSeekBarChangeListener(equalizer12_5kHzListener);

    virtualizerSeekBar.setOnSeekBarChangeListener(virtualizerListener);
    bassBoostSeekBar.setOnSeekBarChangeListener(bassBoostListener);
    reverbSpinner.setOnItemSelectedListener(reverbListener);

    //Get the saved equalizer settings and apply them to the UI elements.
    new AsyncInitSlidersTask().execute();

}

From source file:com.cicada.yuanxiaobao.common.BaseAdapterHelper.java

/** Apply the typeface to the given viewId, and enable subpixel rendering. */
public BaseAdapterHelper setTypeface(int viewId, Typeface typeface) {
    TextView view = retrieveView(viewId);
    view.setTypeface(typeface);//from  ww  w  . j  a v  a 2 s  .c om
    view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
    return this;
}

From source file:com.cicada.yuanxiaobao.common.BaseAdapterHelper.java

/**
 * Apply the typeface to all the given viewIds, and enable subpixel
 * rendering./*from  w w  w.  j  a va 2s .  com*/
 */
public BaseAdapterHelper setTypeface(Typeface typeface, int... viewIds) {
    for (int viewId : viewIds) {
        TextView view = retrieveView(viewId);
        view.setTypeface(typeface);
        view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
    }
    return this;
}

From source file:com.aniruddhc.acemusic.player.LauncherActivity.LauncherActivity.java

public void showTrialDialog(final boolean expired, int numDaysRemaining) {

    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    builder.setTitle(R.string.app_name);
    builder.setCancelable(false);/*from ww  w  .j a v a  2s . c  o  m*/

    View view = this.getLayoutInflater().inflate(R.layout.trial_expiry_dialog, null);
    TextView trialExpiredText = (TextView) view.findViewById(R.id.trial_message);
    TextView trialDaysRemaining = (TextView) view.findViewById(R.id.trial_days_remaining);
    TextView trialDaysCaps = (TextView) view.findViewById(R.id.days_caps);

    trialExpiredText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
    trialExpiredText
            .setPaintFlags(trialExpiredText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    trialDaysRemaining.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));

    trialDaysCaps.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
    trialDaysCaps
            .setPaintFlags(trialDaysCaps.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    if (expired) {
        trialDaysRemaining.setText(R.string.expired);
        trialExpiredText.setText(R.string.trial_expired);
        trialDaysRemaining.setTextColor(0xFFFF8800);
        trialDaysCaps.setVisibility(View.GONE);
        trialDaysRemaining.setTextSize(36);
        trialDaysRemaining.setPaintFlags(
                trialDaysRemaining.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    } else {
        trialExpiredText.setText(R.string.trial_running);
        trialDaysRemaining.setText("" + numDaysRemaining);
        trialDaysCaps.setVisibility(View.VISIBLE);
        trialDaysRemaining.setTextColor(0xFF0099CC);
        trialDaysRemaining.setPaintFlags(trialDaysRemaining.getPaintFlags() | Paint.ANTI_ALIAS_FLAG
                | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
    }

    builder.setView(view);
    builder.setPositiveButton(R.string.upgrade, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            showUpgradeFragmentWithPromo();

        }

    });

    builder.setNegativeButton(R.string.later, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (expired) {
                finish();
            } else {
                launchMainActivity();
            }

        }

    });

    builder.create().show();
}

From source file:com.gm.goldencity.util.Utils.java

/**
 * Apply typeface to a plane text and return spannableString
 *
 * @param text     Text that you want to apply typeface
 * @param typeface Typeface that you want to apply to your text
 * @return spannableString//from   w w w  . ja  v  a2  s  .c o m
 */
public static SpannableString applyTypefaceToString(String text, final Typeface typeface) {
    SpannableString spannableString = new SpannableString(text);
    spannableString.setSpan(new MetricAffectingSpan() {
        @Override
        public void updateMeasureState(TextPaint p) {
            p.setTypeface(typeface);

            // Note: This flag is required for proper typeface rendering
            p.setFlags(p.getFlags() | Paint.SUBPIXEL_TEXT_FLAG);
        }

        @Override
        public void updateDrawState(TextPaint tp) {
            tp.setTypeface(typeface);

            // Note: This flag is required for proper typeface rendering
            tp.setFlags(tp.getFlags() | Paint.SUBPIXEL_TEXT_FLAG);
        }
    }, 0, spannableString.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    return spannableString;
}

From source file:com.elpstudio.player.EqualizerActivity.java

/**
 * Builds the "Save Preset" dialog. Does not call the show() method, so you 
 * should do this manually when calling this method.
 * //from   w w w . j a v a 2  s . c  o  m
 * @return A fully built AlertDialog reference.
 */
private AlertDialog buildSavePresetDialog() {

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    View dialogView = getLayoutInflater().inflate(R.layout.add_new_equalizer_preset_dialog_layout, null);

    final EditText newPresetNameField = (EditText) dialogView.findViewById(R.id.new_preset_name_text_field);
    //newPresetNameField.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Light"));
    newPresetNameField.setPaintFlags(
            newPresetNameField.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    //Set the dialog title.
    builder.setTitle("Save Preset");
    builder.setView(dialogView);
    builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int arg1) {
            dialog.dismiss();

        }

    });

    builder.setPositiveButton("Done", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {

            //Get the preset name from the text field.
            if (newPresetNameField.getText().toString().trim().length() > 0) {
                String presetName = newPresetNameField.getText().toString();

                //Add the preset and it's values to the DB.
                mApp.getDBAccessHelper().addNewEQPreset(presetName, fiftyHertzLevel, oneThirtyHertzLevel,
                        threeTwentyHertzLevel, eightHundredHertzLevel, twoKilohertzLevel, fiveKilohertzLevel,
                        twelvePointFiveKilohertzLevel, (short) virtualizerSeekBar.getProgress(),
                        (short) bassBoostSeekBar.getProgress(),
                        (short) reverbSpinner.getSelectedItemPosition());

                Toast.makeText(mContext, "Saved .. commented", Toast.LENGTH_SHORT).show();
                dialog.dismiss();
            }

        }

    });

    return builder.create();

}

From source file:com.aniruddhc.acemusic.player.EqualizerActivity.EqualizerActivity.java

/**
 * Builds the "Save Preset" dialog. Does not call the show() method, so you 
 * should do this manually when calling this method.
 * /*w  ww  . j a  va2  s .co  m*/
 * @return A fully built AlertDialog reference.
 */
private AlertDialog buildSavePresetDialog() {

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    View dialogView = getLayoutInflater().inflate(R.layout.add_new_equalizer_preset_dialog_layout, null);

    final EditText newPresetNameField = (EditText) dialogView.findViewById(R.id.new_preset_name_text_field);
    newPresetNameField.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Light"));
    newPresetNameField.setPaintFlags(
            newPresetNameField.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    //Set the dialog title.
    builder.setTitle(R.string.save_preset);
    builder.setView(dialogView);
    builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int arg1) {
            dialog.dismiss();

        }

    });

    builder.setPositiveButton(R.string.done, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {

            //Get the preset name from the text field.
            String presetName = newPresetNameField.getText().toString();

            //Add the preset and it's values to the DB.
            mApp.getDBAccessHelper().addNewEQPreset(presetName, fiftyHertzLevel, oneThirtyHertzLevel,
                    threeTwentyHertzLevel, eightHundredHertzLevel, twoKilohertzLevel, fiveKilohertzLevel,
                    twelvePointFiveKilohertzLevel, (short) virtualizerSeekBar.getProgress(),
                    (short) bassBoostSeekBar.getProgress(), (short) reverbSpinner.getSelectedItemPosition());

            Toast.makeText(mContext, R.string.preset_saved, Toast.LENGTH_SHORT).show();
            dialog.dismiss();
        }

    });

    return builder.create();

}