Example usage for android.graphics Paint FAKE_BOLD_TEXT_FLAG

List of usage examples for android.graphics Paint FAKE_BOLD_TEXT_FLAG

Introduction

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

Prototype

int FAKE_BOLD_TEXT_FLAG

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

Click Source Link

Document

Paint flag that applies a synthetic bolding effect to drawn text.

Usage

From source file:com.byagowi.persiancalendar.view.QiblaCompassView.java

public void initCompassView() {
    setFocusable(true);/* ww  w  .  ja va  2 s .  c o  m*/
    initAstronomicParameters();
    northString = "N";
    eastString = "E";
    southString = "S";
    westString = "W";

    dashPath = new DashPathEffect(new float[] { 2, 5 }, 1);
    dashedPaint = new Paint(Paint.FAKE_BOLD_TEXT_FLAG);
    dashedPaint.setPathEffect(dashPath);
    dashedPaint.setStrokeWidth(2);
    dashedPaint.setPathEffect(dashPath);
    dashedPaint.setColor(ContextCompat.getColor(getContext(), R.color.qibla_color));

    textPaint = new Paint(Paint.FAKE_BOLD_TEXT_FLAG);
    textPaint.setColor(ContextCompat.getColor(getContext(), (R.color.qibla_color)));
    textPaint.setTextSize(20);
}

From source file:com.aniruddhc.acemusic.player.Dialogs.ViewPlaylistInformationDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    parentActivity = getActivity();// w w  w.  ja  v a  2 s.  c  o  m
    dialogFragment = this;

    rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.dialog_playlist_information, null);

    playlistName = getArguments().getString("PLAYLIST_NAME");
    playlistFilePath = getArguments().getString("PLAYLIST_FILE_PATH");

    //Header text declarations.
    playlistNameText = (TextView) rootView.findViewById(R.id.playlist_name_text);
    playlistNameText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistNameText.setPaintFlags(playlistNameText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG
            | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);

    playlistFormatText = (TextView) rootView.findViewById(R.id.playlist_format_text);
    playlistFormatText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistFormatText.setPaintFlags(playlistFormatText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG
            | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);

    playlistLocationText = (TextView) rootView.findViewById(R.id.playlist_location_text);
    playlistLocationText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistLocationText.setPaintFlags(playlistLocationText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG
            | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);

    playlistNumberOfSongsText = (TextView) rootView.findViewById(R.id.playlist_number_of_songs_text);
    playlistNumberOfSongsText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistNumberOfSongsText.setPaintFlags(playlistNumberOfSongsText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG
            | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);

    playlistLastModifiedText = (TextView) rootView.findViewById(R.id.playlist_last_modified_text);
    playlistLastModifiedText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistLastModifiedText.setPaintFlags(playlistLastModifiedText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG
            | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);

    playlistAddedToLibraryText = (TextView) rootView.findViewById(R.id.playlist_added_to_library_text);
    playlistAddedToLibraryText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistAddedToLibraryText.setPaintFlags(playlistAddedToLibraryText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG
            | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);

    playlistCreatedText = (TextView) rootView.findViewById(R.id.playlist_created_text);
    playlistCreatedText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistCreatedText.setPaintFlags(playlistCreatedText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG
            | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);

    //Values declarations.
    playlistNameValue = (TextView) rootView.findViewById(R.id.playlist_name_value);
    playlistNameValue.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistNameValue.setPaintFlags(
            playlistNameValue.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    playlistFormatValue = (TextView) rootView.findViewById(R.id.playlist_format_value);
    playlistFormatValue.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistFormatValue.setPaintFlags(
            playlistFormatValue.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    playlistLocationValue = (TextView) rootView.findViewById(R.id.playlist_location_value);
    playlistLocationValue.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistLocationValue.setPaintFlags(
            playlistLocationValue.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    playlistNumberOfSongsValue = (TextView) rootView.findViewById(R.id.playlist_number_of_songs_value);
    playlistNumberOfSongsValue.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistNumberOfSongsValue.setPaintFlags(
            playlistNumberOfSongsValue.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    playlistLastModifiedValue = (TextView) rootView.findViewById(R.id.playlist_last_modified_value);
    playlistLastModifiedValue.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistLastModifiedValue.setPaintFlags(
            playlistLastModifiedValue.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    playlistAddedToLibraryValue = (TextView) rootView.findViewById(R.id.playlist_added_to_library_value);
    playlistAddedToLibraryValue
            .setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistAddedToLibraryValue.setPaintFlags(
            playlistAddedToLibraryValue.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    playlistCreatedValue = (TextView) rootView.findViewById(R.id.playlist_created_value);
    playlistCreatedValue.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    playlistCreatedValue.setPaintFlags(
            playlistCreatedValue.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    //Set the playlist name and the file format.
    playlistNameValue.setText(playlistName);

    int extensionDotIndex = playlistFilePath.lastIndexOf(".");

    String extension = "";
    if (!playlistFilePath.isEmpty()) {
        extension = playlistFilePath.substring(extensionDotIndex, playlistFilePath.length());
    } else {
        extension = "Unknown";
    }
    playlistFormatValue.setText(extension);

    /*//Retrieve the information that needs to tbe displayed in the dialog.
    DBAccessHelper dbHelper = new DBAccessHelper(parentActivity);
    Cursor cursor = dbHelper.getPlaylistByFilePath(playlistFilePath);
            
    if (cursor.getCount() > 0) {
       //Get the number of songs in the playlist.
       playlistNumberOfSongs = cursor.getCount() + "";
       playlistNumberOfSongsValue.setText(playlistNumberOfSongs);
               
       //Get the date that the playlist was added to the library.
       cursor.moveToFirst();
               
       //Note that addTime isn't the actual "Last modification" date. It's actually the date the playlist was added to the library.
       long addTime = cursor.getLong(cursor.getColumnIndex(DBAccessHelper.PLAYLIST_LAST_MODIFIED));
       Date addDate = new Date(addTime);
               
       SimpleDateFormat addDateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm aa", Locale.getDefault());
       addDateFormat.setTimeZone(TimeZone.getDefault());
       playlistAddedToLibrary = addDateFormat.format(addDate);
               
       playlistAddedToLibraryValue.setText(playlistAddedToLibrary);
               
    }
            
    //Get a File that points to the playlist file on the filesystem.
    File file = new File(playlistFilePath);
    long lastModifiedTime = file.lastModified();
            
    if (lastModifiedTime==0) {
       playlistLastModifiedValue.setText("Unknown");
    } else {
       Date lastModifiedDate = new Date(lastModifiedTime);
               
       SimpleDateFormat lastModifiedDateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm aa", Locale.getDefault());
       lastModifiedDateFormat.setTimeZone(TimeZone.getDefault());
               
       playlistLastModified = lastModifiedDateFormat.format(lastModifiedDate);
       playlistLastModifiedValue.setText(playlistLastModified);
       playlistCreatedValue.setText(playlistLastModified);
    }*/

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    //Set the dialog title.
    builder.setTitle(playlistName);
    builder.setView(rootView);
    builder.setNegativeButton(R.string.done, new OnClickListener() {

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

        }

    });

    return builder.create();
}

From source file:com.aniruddhc.acemusic.player.Drawers.InnerNavigationDrawerFragment.java

@SuppressLint("NewApi")
@Override// w  w  w .  j a v a  2s .c  o  m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.navigation_drawer_layout, null);
    mApp = (Common) getActivity().getApplicationContext();

    browsersListView = (ListView) rootView.findViewById(R.id.browsers_list_view);
    librariesListView = (ListView) rootView.findViewById(R.id.libraries_list_view);
    browsersHeaderText = (TextView) rootView.findViewById(R.id.browsers_header_text);
    librariesHeaderText = (TextView) rootView.findViewById(R.id.libraries_header_text);
    librariesColorTagImageView = (ImageView) rootView.findViewById(R.id.library_color_tag);
    librariesIcon = (ImageView) rootView.findViewById(R.id.libraries_icon);
    librariesIcon.setImageResource(UIElementsHelper.getIcon(getActivity(), "libraries"));

    Drawable backgroundDrawable;
    if (mApp.getCurrentTheme() == Common.DARK_THEME) {
        backgroundDrawable = new ColorDrawable(0x191919);
    } else {
        backgroundDrawable = getResources().getDrawable(R.drawable.holo_white_selector);
    }

    int currentAPI = android.os.Build.VERSION.SDK_INT;
    if (currentAPI < android.os.Build.VERSION_CODES.JELLY_BEAN) {
        rootView.setBackgroundDrawable(backgroundDrawable);
    } else {
        rootView.setBackground(backgroundDrawable);
    }

    //Set the header text fonts/colors.
    browsersHeaderText.setTypeface(TypefaceHelper.getTypeface(getActivity(), "RobotoCondensed-Light"));
    librariesHeaderText.setTypeface(TypefaceHelper.getTypeface(getActivity(), "RobotoCondensed-Light"));
    browsersHeaderText.setPaintFlags(browsersHeaderText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    librariesHeaderText.setPaintFlags(librariesHeaderText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    //Apply the Browser ListView's adapter.
    List<String> titles = Arrays
            .asList(getActivity().getResources().getStringArray(R.array.sliding_menu_array));
    NavigationDrawerAdapter slidingMenuAdapter = new NavigationDrawerAdapter(getActivity(),
            new ArrayList<String>(titles));
    browsersListView.setAdapter(slidingMenuAdapter);
    browsersListView.setOnItemClickListener(browsersClickListener);
    setListViewHeightBasedOnChildren(browsersListView);

    /*//Apply the Libraries ListView's adapter.
    userLibrariesDBHelper = new DBAccessHelper(getActivity().getApplicationContext());
    cursor = userLibrariesDBHelper.getAllUniqueLibraries();
    NavigationDrawerLibrariesAdapter slidingMenuLibrariesAdapter = new NavigationDrawerLibrariesAdapter(getActivity(), cursor);
    librariesListView.setAdapter(slidingMenuLibrariesAdapter);
    setListViewHeightBasedOnChildren(librariesListView);*/
    librariesListView.setVisibility(View.GONE);
    librariesHeaderText.setVisibility(View.GONE);
    librariesIcon.setVisibility(View.GONE);

    return rootView;
}

From source file:com.jigarmjoshi.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (SimpleDatabaseUtil.isFirstApplicationStart(this)) {
        Log.i(MainActivity.class.getSimpleName(), "creating database for the first time");
        SQLiteSimple databaseSimple = new SQLiteSimple(this, DATABASE_VERSION);
        databaseSimple.create(Report.class, LastLocation.class);
    } else if (SimpleDatabaseUtil.isFirstStartOnAppVersion(this, DATABASE_VERSION)) {
        Log.i(MainActivity.class.getSimpleName(),
                "creating database for the first time for this version " + DATABASE_VERSION);

        SQLiteSimple databaseSimple = new SQLiteSimple(this, DATABASE_VERSION);
        databaseSimple.create(Report.class, LastLocation.class);

    }/*ww  w.  j  a  v a 2 s  .  c om*/
    // initialize services
    EntryDao.getInstance(this);
    LastLocationDao.getInstance(this);

    // scheduler
    mgr = (AlarmManager) getSystemService(ALARM_SERVICE);

    Intent i = new Intent(this, LocationPoller.class);
    com.jigarmjoshi.service.LocationManager locationManager = com.jigarmjoshi.service.LocationManager
            .getInstance(getApplicationContext());
    List<String> providers = locationManager.getAllProviders();
    boolean fusedSupported = false;
    for (String provider : providers) {
        if (com.jigarmjoshi.service.LocationManager.FUSED_PROVIDER.equals(provider)) {
            fusedSupported = true;
            break;
        }
    }
    i.putExtra(LocationPoller.EXTRA_INTENT, new Intent(this, com.jigarmjoshi.reciever.LocationReceiver.class));
    i.putExtra(LocationPoller.EXTRA_PROVIDER,
            (fusedSupported ? LocationManager.FUSED_PROVIDER : LocationManager.GPS_PROVIDER));

    pi = PendingIntent.getBroadcast(this, 0, i, 0);
    mgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, 0,
            Long.parseLong(ConfigService.get(ConfigService.GPS_TASK_INTERVAL, "40000")), pi);

    // upload task
    Timer timer = new Timer();
    TimerTask timerTask = new UploaderTask(this);
    timer.schedule(timerTask, 0,
            Long.parseLong(ConfigService.get(ConfigService.UPLOAD_TASK_INTERVAL, "40000")));

    selectedTextView = new TextView(this);
    selectedTextView.setTextColor(Color.BLACK);
    selectedTextView.setGravity(Gravity.CENTER);
    selectedTextView.setPaintFlags(Paint.FAKE_BOLD_TEXT_FLAG);

    unSelectedTextView = new TextView(this);
    unSelectedTextView.setTextColor(Color.GRAY);
    unSelectedTextView.setGravity(Gravity.CENTER);
    unSelectedTextView.setPaintFlags(Paint.FAKE_BOLD_TEXT_FLAG);
    // create if first time

    getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    actionBar = getActionBar();
    actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#40808080")));
    actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#40808080")));
    setContentView(R.layout.activity_main);

    // Initilization
    viewPager = (ViewPager) findViewById(R.id.pager);
    mAdapter = new TabsPagerAdapter(getSupportFragmentManager());

    viewPager.setAdapter(mAdapter);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Adding Tabs
    boolean first = false;
    for (String tab_name : tabs) {
        Tab tab = actionBar.newTab().setText(tab_name).setTabListener(this);
        if (first) {
            first = false;
            selectedTextView.setText(tab.getText().toString().toUpperCase(Locale.getDefault()));
            tab.setCustomView(selectedTextView);
        } else {
            unSelectedTextView.setText(tab.getText().toString().toUpperCase(Locale.getDefault()));
            tab.setCustomView(unSelectedTextView);
        }
        actionBar.addTab(tab);
    }

    /**
     * on swiping the viewpager make respective tab selected
     * */
    viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            // on changing the page
            // make respected tab selected
            actionBar.setSelectedNavigationItem(position);
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }
    });
    Toast.makeText(this, getString(R.string.wait_gps), Toast.LENGTH_LONG).show();
}

From source file:com.aniruddhc.acemusic.player.Dialogs.ID3sSongEditorDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    mContext = getActivity();//from ww  w. j  a va2 s.c o m
    parentActivity = getActivity();
    dialogFragment = this;

    rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.fragment_edit_id3_artist_album_dialog,
            null);

    titleText = (TextView) rootView.findViewById(R.id.edit_title_text);
    artistText = (TextView) rootView.findViewById(R.id.edit_artist_text);
    albumText = (TextView) rootView.findViewById(R.id.edit_album_text);
    albumArtistText = (TextView) rootView.findViewById(R.id.edit_album_artist_text);
    genreText = (TextView) rootView.findViewById(R.id.edit_genre_text);
    producerText = (TextView) rootView.findViewById(R.id.edit_producer_text);
    yearText = (TextView) rootView.findViewById(R.id.edit_year_text);
    trackText = (TextView) rootView.findViewById(R.id.edit_track_text);
    ofText = (TextView) rootView.findViewById(R.id.text_of);
    commentsText = (TextView) rootView.findViewById(R.id.edit_comment_text);

    titleEditText = (EditText) rootView.findViewById(R.id.edit_title_field);
    artistEditText = (EditText) rootView.findViewById(R.id.edit_artist_field);
    albumEditText = (EditText) rootView.findViewById(R.id.edit_album_field);
    albumArtistEditText = (EditText) rootView.findViewById(R.id.edit_album_artist_field);
    genreEditText = (EditText) rootView.findViewById(R.id.edit_genre_field);
    producerEditText = (EditText) rootView.findViewById(R.id.edit_producer_field);
    yearEditText = (EditText) rootView.findViewById(R.id.edit_year_field);
    trackEditText = (EditText) rootView.findViewById(R.id.edit_track_field);
    trackTotalEditText = (EditText) rootView.findViewById(R.id.edit_track_total_field);
    commentsEditText = (EditText) rootView.findViewById(R.id.edit_comment_field);

    titleCheckbox = (CheckBox) rootView.findViewById(R.id.title_checkbox);
    artistCheckbox = (CheckBox) rootView.findViewById(R.id.artist_checkbox);
    albumCheckbox = (CheckBox) rootView.findViewById(R.id.album_checkbox);
    albumArtistCheckbox = (CheckBox) rootView.findViewById(R.id.album_artist_checkbox);
    genreCheckbox = (CheckBox) rootView.findViewById(R.id.genre_checkbox);
    producerCheckbox = (CheckBox) rootView.findViewById(R.id.producer_checkbox);
    yearCheckbox = (CheckBox) rootView.findViewById(R.id.year_checkbox);
    trackCheckbox = (CheckBox) rootView.findViewById(R.id.track_checkbox);
    commentCheckbox = (CheckBox) rootView.findViewById(R.id.comment_checkbox);

    titleText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    artistText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    albumText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    albumArtistText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    genreText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    producerText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    yearText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    trackText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    ofText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    commentsText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));

    titleText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    artistText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    albumText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    albumArtistText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    genreText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    producerText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    yearText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    trackText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    ofText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    commentsText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);

    titleEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    artistEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    albumEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    albumArtistEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    genreEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    producerEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    yearEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    trackEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    trackTotalEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    commentsEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));

    titleEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    artistEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    albumEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    albumArtistEditText
            .setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    genreEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    producerEditText
            .setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    yearEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    trackEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    trackTotalEditText
            .setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    commentsEditText
            .setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    //Keep all the fields locked by default.
    titleCheckbox.setChecked(false);
    artistCheckbox.setChecked(false);
    albumCheckbox.setChecked(false);
    albumArtistCheckbox.setChecked(false);
    genreCheckbox.setChecked(false);
    producerCheckbox.setChecked(false);
    yearCheckbox.setChecked(false);
    trackCheckbox.setChecked(false);
    commentCheckbox.setChecked(false);

    //Disable all EditTexts by default.
    titleEditText.setEnabled(false);
    artistEditText.setEnabled(false);
    albumEditText.setEnabled(false);
    albumArtistEditText.setEnabled(false);
    genreEditText.setEnabled(false);
    producerEditText.setEnabled(false);
    yearEditText.setEnabled(false);
    trackEditText.setEnabled(false);
    commentsEditText.setEnabled(false);

    //Register click registers on each checkbox.
    titleCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                titleEdited = true;
                titleEditText.setEnabled(true);
            } else {
                titleEdited = false;
                titleEditText.setEnabled(false);
            }

        }

    });

    artistCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                artistEdited = true;
                artistEditText.setEnabled(true);
                ;
            } else {
                artistEdited = false;
                artistEditText.setEnabled(false);
            }

        }

    });

    albumArtistCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                albumEdited = true;
                albumEditText.setEnabled(true);
                ;
            } else {
                albumEdited = false;
                albumEditText.setEnabled(false);
            }

        }

    });

    albumCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                albumArtistEdited = true;
                albumArtistEditText.setEnabled(true);
                ;
            } else {
                albumArtistEdited = false;
                albumArtistEditText.setEnabled(false);
            }

        }

    });

    genreCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                genreEdited = true;
                genreEditText.setEnabled(true);
                ;
            } else {
                genreEdited = false;
                genreEditText.setEnabled(false);
            }

        }

    });

    producerCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                producerEdited = true;
                producerEditText.setEnabled(true);
                ;
            } else {
                producerEdited = false;
                producerEditText.setEnabled(false);
            }

        }

    });

    yearCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                yearEdited = true;
                yearEditText.setEnabled(true);
                ;
            } else {
                yearEdited = false;
                yearEditText.setEnabled(false);
            }

        }

    });

    trackCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                trackEdited = true;
                trackEditText.setEnabled(true);
                ;
            } else {
                trackEdited = false;
                trackEditText.setEnabled(false);
            }

        }

    });

    commentCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                commentEdited = true;
                commentsEditText.setEnabled(true);
                ;
            } else {
                commentEdited = false;
                commentsEditText.setEnabled(false);
            }

        }

    });

    //Get the song uri.
    SONG_URI = getArguments().getString("SONG");

    //Get the calling Fragment and retrieve the child view from it.
    CALLING_FRAGMENT = getArguments().getString("CALLING_FRAGMENT");

    if (SONG_URI != null) {

        //Populate the ArrayLists with the song tags.
        try {
            getSongTags(SONG_URI);
        } catch (CannotReadException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (TagException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ReadOnlyFileException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InvalidAudioFrameException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    //Set the dialog title.
    builder.setTitle(R.string.edit_tags);
    builder.setView(rootView);
    builder.setPositiveButton(R.string.save, new OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            dialogFragment.dismiss();
            boolean saveSucceeded = saveSongTags(SONG_URI);

            //Check if the write operations succeeded. If they didn't, display an error message.
            if (saveSucceeded == true) {
                Toast.makeText(getActivity().getApplicationContext(), R.string.song_tags_saved,
                        Toast.LENGTH_SHORT).show();

                /*               //Reinitialize the calling fragment.
                               if (CALLING_FRAGMENT.equals("SONGS_FRAGMENT")) {
                        
                        
                               } else if (CALLING_FRAGMENT.equals("ARTISTS_FLIPPED_SONGS_FRAGMENT")) {
                                  //ArtistsFlippedSongsFragment.getCursor();
                                  ArtistsFlippedSongsFragment.songsListViewAdapter.notifyDataSetChanged();
                               } else if (CALLING_FRAGMENT.equals("ALBUMS_FLIPPED_FRAGMENT")) {
                                  AlbumsFlippedFragment.getCursor();
                                  AlbumsFlippedFragment.albumsFlippedListViewAdapter.notifyDataSetChanged();
                               } else if (CALLING_FRAGMENT.equals("ALBUM_ARTISTS_FLIPPED_SONGS_FRAGMENT")) {
                                  AlbumArtistsFlippedSongsFragment.getCursor();
                                  AlbumArtistsFlippedSongsFragment.songsListViewAdapter.notifyDataSetChanged();
                               } else if (CALLING_FRAGMENT.equals("GENRES_FLIPPED_SONGS_FRAGMENT")) {
                                  GenresFlippedFragment.getCursor();
                                  GenresFlippedFragment.genresFlippedListViewAdapter.notifyDataSetChanged();
                               }*/

            } else {
                Toast.makeText(parentActivity, R.string.error_occurred_tags, Toast.LENGTH_LONG).show();
            }

        }

    });

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

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

        }

    });

    return builder.create();

}

From source file:com.aniruddhc.acemusic.player.Dialogs.ID3sArtistEditorDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    mContext = getActivity();//from   w  w w  .ja  v  a  2  s .  co m
    parentActivity = getActivity();
    dialogFragment = this;

    //Get the artist name.
    ARTIST = getArguments().getString("ARTIST");

    rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.fragment_edit_id3_artist_album_dialog,
            null);

    titleText = (TextView) rootView.findViewById(R.id.edit_title_text);
    artistText = (TextView) rootView.findViewById(R.id.edit_artist_text);
    albumText = (TextView) rootView.findViewById(R.id.edit_album_text);
    albumArtistText = (TextView) rootView.findViewById(R.id.edit_album_artist_text);
    genreText = (TextView) rootView.findViewById(R.id.edit_genre_text);
    producerText = (TextView) rootView.findViewById(R.id.edit_producer_text);
    yearText = (TextView) rootView.findViewById(R.id.edit_year_text);
    trackText = (TextView) rootView.findViewById(R.id.edit_track_text);
    ofText = (TextView) rootView.findViewById(R.id.text_of);
    commentsText = (TextView) rootView.findViewById(R.id.edit_comment_text);

    titleEditText = (EditText) rootView.findViewById(R.id.edit_title_field);
    artistEditText = (EditText) rootView.findViewById(R.id.edit_artist_field);
    albumEditText = (EditText) rootView.findViewById(R.id.edit_album_field);
    albumArtistEditText = (EditText) rootView.findViewById(R.id.edit_album_artist_field);
    genreEditText = (EditText) rootView.findViewById(R.id.edit_genre_field);
    producerEditText = (EditText) rootView.findViewById(R.id.edit_producer_field);
    yearEditText = (EditText) rootView.findViewById(R.id.edit_year_field);
    trackEditText = (EditText) rootView.findViewById(R.id.edit_track_field);
    trackTotalEditText = (EditText) rootView.findViewById(R.id.edit_track_total_field);
    commentsEditText = (EditText) rootView.findViewById(R.id.edit_comment_field);

    titleCheckbox = (CheckBox) rootView.findViewById(R.id.title_checkbox);
    artistCheckbox = (CheckBox) rootView.findViewById(R.id.artist_checkbox);
    albumCheckbox = (CheckBox) rootView.findViewById(R.id.album_checkbox);
    albumArtistCheckbox = (CheckBox) rootView.findViewById(R.id.album_artist_checkbox);
    genreCheckbox = (CheckBox) rootView.findViewById(R.id.genre_checkbox);
    producerCheckbox = (CheckBox) rootView.findViewById(R.id.producer_checkbox);
    yearCheckbox = (CheckBox) rootView.findViewById(R.id.year_checkbox);
    trackCheckbox = (CheckBox) rootView.findViewById(R.id.track_checkbox);
    commentCheckbox = (CheckBox) rootView.findViewById(R.id.comment_checkbox);

    titleText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    artistText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    albumText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    albumArtistText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    genreText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    producerText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    yearText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    trackText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    ofText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    commentsText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));

    titleText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    artistText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    albumText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    albumArtistText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    genreText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    producerText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    yearText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    trackText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    ofText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    commentsText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);

    titleEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    artistEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    albumEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    albumArtistEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    genreEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    producerEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    yearEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    trackEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    trackTotalEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    commentsEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));

    titleEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    artistEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    albumEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    albumArtistEditText
            .setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    genreEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    producerEditText
            .setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    yearEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    trackEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    trackTotalEditText
            .setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    commentsEditText
            .setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    //Keep all the fields locked by default.
    titleCheckbox.setChecked(false);
    artistCheckbox.setChecked(false);
    albumCheckbox.setChecked(false);
    albumArtistCheckbox.setChecked(false);
    genreCheckbox.setChecked(false);
    producerCheckbox.setChecked(false);
    yearCheckbox.setChecked(false);
    trackCheckbox.setChecked(false);
    commentCheckbox.setChecked(false);

    //Disable all EditTexts by default.
    titleEditText.setEnabled(false);
    artistEditText.setEnabled(false);
    albumEditText.setEnabled(false);
    albumArtistEditText.setEnabled(false);
    genreEditText.setEnabled(false);
    producerEditText.setEnabled(false);
    yearEditText.setEnabled(false);
    trackEditText.setEnabled(false);
    commentsEditText.setEnabled(false);

    //Register click registers on each checkbox.
    titleCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                titleEdited = true;
                titleEditText.setEnabled(true);
            } else {
                titleEdited = false;
                titleEditText.setEnabled(false);
            }

        }

    });

    artistCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                artistEdited = true;
                artistEditText.setEnabled(true);
                ;
            } else {
                artistEdited = false;
                artistEditText.setEnabled(false);
            }

        }

    });

    albumArtistCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                albumEdited = true;
                albumEditText.setEnabled(true);
                ;
            } else {
                albumEdited = false;
                albumEditText.setEnabled(false);
            }

        }

    });

    albumCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                albumArtistEdited = true;
                albumArtistEditText.setEnabled(true);
                ;
            } else {
                albumArtistEdited = false;
                albumArtistEditText.setEnabled(false);
            }

        }

    });

    genreCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                genreEdited = true;
                genreEditText.setEnabled(true);
                ;
            } else {
                genreEdited = false;
                genreEditText.setEnabled(false);
            }

        }

    });

    producerCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                producerEdited = true;
                producerEditText.setEnabled(true);
                ;
            } else {
                producerEdited = false;
                producerEditText.setEnabled(false);
            }

        }

    });

    yearCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                yearEdited = true;
                yearEditText.setEnabled(true);
                ;
            } else {
                yearEdited = false;
                yearEditText.setEnabled(false);
            }

        }

    });

    trackCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                trackEdited = true;
                trackEditText.setEnabled(true);
                ;
            } else {
                trackEdited = false;
                trackEditText.setEnabled(false);
            }

        }

    });

    commentCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                commentEdited = true;
                commentsEditText.setEnabled(true);
                ;
            } else {
                commentEdited = false;
                commentsEditText.setEnabled(false);
            }

        }

    });

    if (ARTIST != null) {
        songURIsList = getAllSongsByArtist(ARTIST);

        //Populate the ArrayLists with the song tags.
        try {
            getSongTags(songURIsList);
        } catch (CannotReadException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (TagException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ReadOnlyFileException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InvalidAudioFrameException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        //Now check if any of the ArrayLists contain the same exact elements.
        boolean titlesSame = checkIfAllElementsEqual(titlesList);
        boolean artistsSame = checkIfAllElementsEqual(artistsList);
        boolean albumsSame = checkIfAllElementsEqual(albumsList);
        boolean albumArtistsSame = checkIfAllElementsEqual(albumArtistsList);
        boolean genresSame = checkIfAllElementsEqual(genresList);
        boolean producersSame = checkIfAllElementsEqual(producersList);
        boolean yearsSame = checkIfAllElementsEqual(yearsList);
        boolean tracksSame = checkIfAllElementsEqual(trackNumbersList);
        boolean totalTracksSame = checkIfAllElementsEqual(totalTracksList);
        boolean commentsSame = checkIfAllElementsEqual(commentsList);

        //Populate the EditTexts.
        setEditorFields(titlesSame, titlesList, titleEditText);
        setEditorFields(artistsSame, artistsList, artistEditText);
        setEditorFields(albumsSame, albumsList, albumEditText);
        setEditorFields(albumArtistsSame, albumArtistsList, albumArtistEditText);
        setEditorFields(genresSame, genresList, genreEditText);
        setEditorFields(producersSame, producersList, producerEditText);
        setEditorFields(yearsSame, yearsList, yearEditText);
        setEditorFields(tracksSame, trackNumbersList, trackEditText);
        setEditorFields(totalTracksSame, totalTracksList, trackTotalEditText);
        setEditorFields(commentsSame, commentsList, commentsEditText);

    }

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    //Set the dialog title.
    builder.setTitle(R.string.edit_tags);
    builder.setView(rootView);
    builder.setPositiveButton(R.string.save, new OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            dialogFragment.dismiss();
            AsyncSaveArtistTagsTask asyncSaveArtistTagsTask = new AsyncSaveArtistTagsTask(getActivity(),
                    getActivity());
            asyncSaveArtistTagsTask.execute();

        }

    });

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

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

        }

    });

    return builder.create();

}

From source file:com.aniruddhc.acemusic.player.Dialogs.ID3sAlbumEditorDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    mApp = (Common) getActivity().getApplicationContext();
    parentActivity = getActivity();/*from   w  w  w .  ja v  a 2 s .  co  m*/
    dialogFragment = this;

    titlesList = new ArrayList<String>();
    artistsList = new ArrayList<String>();
    albumsList = new ArrayList<String>();
    albumArtistsList = new ArrayList<String>();
    genresList = new ArrayList<String>();
    producersList = new ArrayList<String>();
    yearsList = new ArrayList<String>();
    trackNumbersList = new ArrayList<String>();
    totalTracksList = new ArrayList<String>();
    commentsList = new ArrayList<String>();
    songURIsList = new ArrayList<String>();
    songSourcesList = new ArrayList<String>();
    songIdsList = new ArrayList<String>();

    rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.fragment_edit_id3_artist_album_dialog,
            null);

    titleText = (TextView) rootView.findViewById(R.id.edit_title_text);
    artistText = (TextView) rootView.findViewById(R.id.edit_artist_text);
    albumText = (TextView) rootView.findViewById(R.id.edit_album_text);
    albumArtistText = (TextView) rootView.findViewById(R.id.edit_album_artist_text);
    genreText = (TextView) rootView.findViewById(R.id.edit_genre_text);
    producerText = (TextView) rootView.findViewById(R.id.edit_producer_text);
    yearText = (TextView) rootView.findViewById(R.id.edit_year_text);
    trackText = (TextView) rootView.findViewById(R.id.edit_track_text);
    ofText = (TextView) rootView.findViewById(R.id.text_of);
    commentsText = (TextView) rootView.findViewById(R.id.edit_comment_text);

    titleEditText = (EditText) rootView.findViewById(R.id.edit_title_field);
    artistEditText = (EditText) rootView.findViewById(R.id.edit_artist_field);
    albumEditText = (EditText) rootView.findViewById(R.id.edit_album_field);
    albumArtistEditText = (EditText) rootView.findViewById(R.id.edit_album_artist_field);
    genreEditText = (EditText) rootView.findViewById(R.id.edit_genre_field);
    producerEditText = (EditText) rootView.findViewById(R.id.edit_producer_field);
    yearEditText = (EditText) rootView.findViewById(R.id.edit_year_field);
    trackEditText = (EditText) rootView.findViewById(R.id.edit_track_field);
    trackTotalEditText = (EditText) rootView.findViewById(R.id.edit_track_total_field);
    commentsEditText = (EditText) rootView.findViewById(R.id.edit_comment_field);

    titleCheckbox = (CheckBox) rootView.findViewById(R.id.title_checkbox);
    artistCheckbox = (CheckBox) rootView.findViewById(R.id.artist_checkbox);
    albumCheckbox = (CheckBox) rootView.findViewById(R.id.album_checkbox);
    albumArtistCheckbox = (CheckBox) rootView.findViewById(R.id.album_artist_checkbox);
    genreCheckbox = (CheckBox) rootView.findViewById(R.id.genre_checkbox);
    producerCheckbox = (CheckBox) rootView.findViewById(R.id.producer_checkbox);
    yearCheckbox = (CheckBox) rootView.findViewById(R.id.year_checkbox);
    trackCheckbox = (CheckBox) rootView.findViewById(R.id.track_checkbox);
    commentCheckbox = (CheckBox) rootView.findViewById(R.id.comment_checkbox);

    titleText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    artistText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    albumText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    albumArtistText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    genreText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    producerText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    yearText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    trackText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    ofText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    commentsText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));

    titleText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    artistText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    albumText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    albumArtistText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    genreText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    producerText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    yearText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    trackText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    ofText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);
    commentsText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG
            | Paint.FAKE_BOLD_TEXT_FLAG);

    titleEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    artistEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    albumEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    albumArtistEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    genreEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    producerEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    yearEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    trackEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    trackTotalEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    commentsEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));

    titleEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    artistEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    albumEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    albumArtistEditText
            .setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    genreEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    producerEditText
            .setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    yearEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    trackEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    trackTotalEditText
            .setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    commentsEditText
            .setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    //Keep all the fields locked by default.
    titleCheckbox.setChecked(false);
    artistCheckbox.setChecked(false);
    albumCheckbox.setChecked(false);
    albumArtistCheckbox.setChecked(false);
    genreCheckbox.setChecked(false);
    producerCheckbox.setChecked(false);
    yearCheckbox.setChecked(false);
    trackCheckbox.setChecked(false);
    commentCheckbox.setChecked(false);

    //Disable all EditTexts by default.
    titleEditText.setEnabled(false);
    artistEditText.setEnabled(false);
    albumEditText.setEnabled(false);
    albumArtistEditText.setEnabled(false);
    genreEditText.setEnabled(false);
    producerEditText.setEnabled(false);
    yearEditText.setEnabled(false);
    trackEditText.setEnabled(false);
    commentsEditText.setEnabled(false);

    //Register click registers on each checkbox.
    titleCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                titleEdited = true;
                titleEditText.setEnabled(true);
            } else {
                titleEdited = false;
                titleEditText.setEnabled(false);
            }

        }

    });

    artistCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                artistEdited = true;
                artistEditText.setEnabled(true);
                ;
            } else {
                artistEdited = false;
                artistEditText.setEnabled(false);
            }

        }

    });

    albumArtistCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                albumEdited = true;
                albumEditText.setEnabled(true);
                ;
            } else {
                albumEdited = false;
                albumEditText.setEnabled(false);
            }

        }

    });

    albumCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                albumArtistEdited = true;
                albumArtistEditText.setEnabled(true);
                ;
            } else {
                albumArtistEdited = false;
                albumArtistEditText.setEnabled(false);
            }

        }

    });

    genreCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                genreEdited = true;
                genreEditText.setEnabled(true);
                ;
            } else {
                genreEdited = false;
                genreEditText.setEnabled(false);
            }

        }

    });

    producerCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                producerEdited = true;
                producerEditText.setEnabled(true);
                ;
            } else {
                producerEdited = false;
                producerEditText.setEnabled(false);
            }

        }

    });

    yearCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                yearEdited = true;
                yearEditText.setEnabled(true);
                ;
            } else {
                yearEdited = false;
                yearEditText.setEnabled(false);
            }

        }

    });

    trackCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                trackEdited = true;
                trackEditText.setEnabled(true);
                ;
            } else {
                trackEdited = false;
                trackEditText.setEnabled(false);
            }

        }

    });

    commentCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean checked) {

            if (checked == true) {
                commentEdited = true;
                commentsEditText.setEnabled(true);
                ;
            } else {
                commentEdited = false;
                commentsEditText.setEnabled(false);
            }

        }

    });

    //Get the album and artist name.
    ARTIST = getArguments().getString("ARTIST");
    ALBUM = getArguments().getString("ALBUM");
    CALLING_FRAGMENT = getArguments().getString("CALLING_FRAGMENT");

    if (ARTIST != null && ALBUM != null) {
        songURIsList = getAllSongsInAlbum(ALBUM, ARTIST);

        //Populate the ArrayLists with the song tags.
        try {
            getSongTags(songURIsList);
        } catch (CannotReadException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (TagException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ReadOnlyFileException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InvalidAudioFrameException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        //Now check if any of the ArrayLists contain the same exact elements.
        boolean titlesSame = checkIfAllElementsEqual(titlesList);
        boolean artistsSame = checkIfAllElementsEqual(artistsList);
        boolean albumsSame = checkIfAllElementsEqual(albumsList);
        boolean albumArtistsSame = checkIfAllElementsEqual(albumArtistsList);
        boolean genresSame = checkIfAllElementsEqual(genresList);
        boolean producersSame = checkIfAllElementsEqual(producersList);
        boolean yearsSame = checkIfAllElementsEqual(yearsList);
        boolean tracksSame = checkIfAllElementsEqual(trackNumbersList);
        boolean totalTracksSame = checkIfAllElementsEqual(totalTracksList);
        boolean commentsSame = checkIfAllElementsEqual(commentsList);

        //Populate the EditTexts.
        setEditorFields(titlesSame, titlesList, titleEditText);
        setEditorFields(artistsSame, artistsList, artistEditText);
        setEditorFields(albumsSame, albumsList, albumEditText);
        setEditorFields(albumArtistsSame, albumArtistsList, albumArtistEditText);
        setEditorFields(genresSame, genresList, genreEditText);
        setEditorFields(producersSame, producersList, producerEditText);
        setEditorFields(yearsSame, yearsList, yearEditText);
        setEditorFields(tracksSame, trackNumbersList, trackEditText);
        setEditorFields(totalTracksSame, totalTracksList, trackTotalEditText);
        setEditorFields(commentsSame, commentsList, commentsEditText);

    }

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    //Set the dialog title.
    builder.setTitle(R.string.edit_tags);
    builder.setView(rootView);
    builder.setNeutralButton(R.string.save, new OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            AsyncSaveAlbumTagsTask asyncSaveAlbumTagsTask = new AsyncSaveAlbumTagsTask(getActivity(),
                    getActivity());
            asyncSaveAlbumTagsTask.execute();

        }

    });

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

        @Override
        public void onClick(DialogInterface dialog, int which) {
            clearArrayLists();
            dialogFragment.dismiss();

        }

    });

    return builder.create();

}

From source file:com.dongdong.wheel.WheelView.java

/**
 * Initializes resources/*from   ww  w . j a v  a2s.  c o m*/
 */
private void initResourcesIfNecessary() {
    if (mItemsPaint == null) {
        mItemsPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
        //mItemsPaint.density = getResources().getDisplayMetrics().density;
        mItemsPaint.setTextSize(TEXT_SIZE);
    }

    if (mValuePaint == null) {
        mValuePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.FAKE_BOLD_TEXT_FLAG | Paint.DITHER_FLAG);
        //mValuePaint.density = getResources().getDisplayMetrics().density;
        mValuePaint.setTextSize(TEXT_SIZE);
        mValuePaint.setShadowLayer(0.1f, 0, 0.1f, 0xFFC0C0C0);
    }

    if (mCenterDrawable == null) {
        mCenterDrawable = ContextCompat.getDrawable(getContext(), R.drawable.wheel_val);
    }

    if (mTopShadow == null) {
        mTopShadow = new GradientDrawable(Orientation.TOP_BOTTOM, SHADOWS_COLORS);
    }

    if (mBottomShadow == null) {
        mBottomShadow = new GradientDrawable(Orientation.BOTTOM_TOP, SHADOWS_COLORS);
    }

    setBackgroundResource(R.drawable.wheel_bg);
}

From source file:com.Duo.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  a2 s  .c o  m*/
    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;
}

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;//w  w  w.j a va2 s  .c om
    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;
}