List of usage examples for android.graphics Paint SUBPIXEL_TEXT_FLAG
int SUBPIXEL_TEXT_FLAG
To view the source code for android.graphics Paint SUBPIXEL_TEXT_FLAG.
Click Source Link
From source file:com.justwayward.reader.view.recyclerview.adapter.BaseViewHolder.java
public BaseViewHolder setTypeface(Typeface typeface, int... viewIds) { for (int viewId : viewIds) { TextView view = getView(viewId); view.setTypeface(typeface);//ww w .j av a 2 s . c om view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG); } return this; }
From source file:com.aniruddhc.acemusic.player.Dialogs.ID3sSongEditorDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { mContext = getActivity();//from ww w.j a va 2s . 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.LauncherActivity.LauncherActivity.java
@SuppressLint("NewApi") @Override/*from w ww . j a v a2 s. c om*/ public void onCreate(Bundle savedInstanceState) { setTheme(R.style.AppThemeNoActionBar); super.onCreate(savedInstanceState); setContentView(R.layout.activity_launcher); mContext = this; mActivity = this; mApp = (Common) mContext.getApplicationContext(); mHandler = new Handler(); //Increment the start count. This value will be used to determine when the library should be rescanned. int startCount = mApp.getSharedPreferences().getInt("START_COUNT", 1); mApp.getSharedPreferences().edit().putInt("START_COUNT", startCount + 1).commit(); //Save the dimensions of the layout for later use on KitKat devices. final RelativeLayout launcherRootView = (RelativeLayout) findViewById(R.id.launcher_root_view); launcherRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { try { int screenDimens[] = new int[2]; int screenHeight = 0; int screenWidth = 0; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { //API levels 14, 15 and 16. screenDimens = getTrueDeviceResolution(); screenWidth = screenDimens[0]; screenHeight = screenDimens[1]; } else { //API levels 17+. Display display = getWindowManager().getDefaultDisplay(); DisplayMetrics metrics = new DisplayMetrics(); display.getRealMetrics(metrics); screenHeight = metrics.heightPixels; screenWidth = metrics.widthPixels; } int layoutHeight = launcherRootView.getHeight(); int layoutWidth = launcherRootView.getWidth(); int extraHeight = screenHeight - layoutHeight; int extraWidth = screenWidth = layoutWidth; mApp.getSharedPreferences().edit().putInt("KITKAT_HEIGHT", layoutHeight).commit(); mApp.getSharedPreferences().edit().putInt("KITKAT_WIDTH", layoutWidth).commit(); mApp.getSharedPreferences().edit().putInt("KITKAT_HEIGHT_LAND", layoutWidth - extraHeight) .commit(); mApp.getSharedPreferences().edit().putInt("KITKAT_WIDTH_LAND", screenHeight).commit(); } catch (Exception e) { e.printStackTrace(); } } }); //Build the music library based on the user's scan frequency preferences. int scanFrequency = mApp.getSharedPreferences().getInt("SCAN_FREQUENCY", 5); int updatedStartCount = mApp.getSharedPreferences().getInt("START_COUNT", 1); //Launch the appropriate activity based on the "FIRST RUN" flag. if (mApp.getSharedPreferences().getBoolean(Common.FIRST_RUN, true) == true) { //Create the default Playlists directory if it doesn't exist. File playlistsDirectory = new File(Environment.getExternalStorageDirectory() + "/Playlists/"); if (!playlistsDirectory.exists() || !playlistsDirectory.isDirectory()) { playlistsDirectory.mkdir(); } //Disable equalizer for HTC devices by default. if (mApp.getSharedPreferences().getBoolean(Common.FIRST_RUN, true) == true && Build.PRODUCT.contains("HTC")) { mApp.getSharedPreferences().edit().putBoolean("EQUALIZER_ENABLED", false).commit(); } //Send out a test broadcast to initialize the homescreen/lockscreen widgets. sendBroadcast(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME)); Intent intent = new Intent(this, WelcomeActivity.class); startActivity(intent); overridePendingTransition(R.anim.fade_in, R.anim.fade_out); } else if (mApp.isBuildingLibrary()) { buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text); buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info); buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout); buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryInfoText.setPaintFlags( buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryMainText.setPaintFlags( buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setText(R.string.jams_is_building_library); buildingLibraryLayout.setVisibility(View.VISIBLE); //Initialize the runnable that will fire once the scan process is complete. mHandler.post(scanFinishedCheckerRunnable); } else if (mApp.getSharedPreferences().getBoolean("RESCAN_ALBUM_ART", false) == true) { buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text); buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info); buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout); buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryInfoText.setPaintFlags( buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryMainText.setPaintFlags( buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setText(R.string.jams_is_caching_artwork); initScanProcess(0); } else if ((mApp.getSharedPreferences().getBoolean("REBUILD_LIBRARY", false) == true) || (scanFrequency == 0 && mApp.isScanFinished() == false) || (scanFrequency == 1 && mApp.isScanFinished() == false && updatedStartCount % 3 == 0) || (scanFrequency == 2 && mApp.isScanFinished() == false && updatedStartCount % 5 == 0) || (scanFrequency == 3 && mApp.isScanFinished() == false && updatedStartCount % 10 == 0) || (scanFrequency == 4 && mApp.isScanFinished() == false && updatedStartCount % 20 == 0)) { buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text); buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info); buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout); buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryInfoText.setPaintFlags( buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryMainText.setPaintFlags( buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); initScanProcess(1); } else { //Check if this activity was called from Settings. if (getIntent().hasExtra("UPGRADE")) { if (getIntent().getExtras().getBoolean("UPGRADE") == true) { mExplicitShowTrialFragment = true; } else { mExplicitShowTrialFragment = false; } } //initInAppBilling(); launchMainActivity(); } //Fire away a report to Google Analytics. try { if (mApp.isGoogleAnalyticsEnabled() == true) { EasyTracker easyTracker = EasyTracker.getInstance(this); easyTracker.send(MapBuilder.createEvent("ACE startup.", // Event category (required) "User started ACE.", // Event action (required) "User started ACE.", // Event label null) // Event value .build()); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.Duo.music.player.LauncherActivity.LauncherActivity.java
@SuppressLint("NewApi") @Override//w w w. ja v a2 s . co m public void onCreate(Bundle savedInstanceState) { setTheme(R.style.AppThemeNoActionBar); super.onCreate(savedInstanceState); setContentView(R.layout.activity_launcher); mContext = this; mActivity = this; mApp = (Common) mContext.getApplicationContext(); mHandler = new Handler(); //Increment the start count. This value will be used to determine when the library should be rescanned. int startCount = mApp.getSharedPreferences().getInt("START_COUNT", 1); mApp.getSharedPreferences().edit().putInt("START_COUNT", startCount + 1).commit(); //Save the dimensions of the layout for later use on KitKat devices. final RelativeLayout launcherRootView = (RelativeLayout) findViewById(R.id.launcher_root_view); launcherRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { try { int screenDimens[] = new int[2]; int screenHeight = 0; int screenWidth = 0; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { //API levels 14, 15 and 16. screenDimens = getTrueDeviceResolution(); screenWidth = screenDimens[0]; screenHeight = screenDimens[1]; } else { //API levels 17+. Display display = getWindowManager().getDefaultDisplay(); DisplayMetrics metrics = new DisplayMetrics(); display.getRealMetrics(metrics); screenHeight = metrics.heightPixels; screenWidth = metrics.widthPixels; } int layoutHeight = launcherRootView.getHeight(); int layoutWidth = launcherRootView.getWidth(); int extraHeight = screenHeight - layoutHeight; int extraWidth = screenWidth = layoutWidth; mApp.getSharedPreferences().edit().putInt("KITKAT_HEIGHT", layoutHeight).commit(); mApp.getSharedPreferences().edit().putInt("KITKAT_WIDTH", layoutWidth).commit(); mApp.getSharedPreferences().edit().putInt("KITKAT_HEIGHT_LAND", layoutWidth - extraHeight) .commit(); mApp.getSharedPreferences().edit().putInt("KITKAT_WIDTH_LAND", screenHeight).commit(); } catch (Exception e) { e.printStackTrace(); } } }); //Build the music library based on the user's scan frequency preferences. int scanFrequency = mApp.getSharedPreferences().getInt("SCAN_FREQUENCY", 5); int updatedStartCount = mApp.getSharedPreferences().getInt("START_COUNT", 1); //Launch the appropriate activity based on the "FIRST RUN" flag. if (mApp.getSharedPreferences().getBoolean(Common.FIRST_RUN, true) == true) { //Create the default Playlists directory if it doesn't exist. File playlistsDirectory = new File(Environment.getExternalStorageDirectory() + "/Playlists/"); if (!playlistsDirectory.exists() || !playlistsDirectory.isDirectory()) { playlistsDirectory.mkdir(); } //Disable equalizer for HTC devices by default. if (mApp.getSharedPreferences().getBoolean(Common.FIRST_RUN, true) == true && Build.PRODUCT.contains("HTC")) { mApp.getSharedPreferences().edit().putBoolean("EQUALIZER_ENABLED", false).commit(); } //Send out a test broadcast to initialize the homescreen/lockscreen widgets. sendBroadcast(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME)); Intent intent = new Intent(this, WelcomeActivity.class); startActivity(intent); overridePendingTransition(R.anim.fade_in, R.anim.fade_out); } else if (mApp.isBuildingLibrary()) { buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text); buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info); buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout); buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryInfoText.setPaintFlags( buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryMainText.setPaintFlags( buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setText(R.string.jams_is_building_library); buildingLibraryLayout.setVisibility(View.VISIBLE); //Initialize the runnable that will fire once the scan process is complete. mHandler.post(scanFinishedCheckerRunnable); } else if (mApp.getSharedPreferences().getBoolean("RESCAN_ALBUM_ART", false) == true) { buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text); buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info); buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout); buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryInfoText.setPaintFlags( buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryMainText.setPaintFlags( buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setText(R.string.jams_is_caching_artwork); initScanProcess(0); } else if ((mApp.getSharedPreferences().getBoolean("REBUILD_LIBRARY", false) == true) || (scanFrequency == 0 && mApp.isScanFinished() == false) || (scanFrequency == 1 && mApp.isScanFinished() == false && updatedStartCount % 3 == 0) || (scanFrequency == 2 && mApp.isScanFinished() == false && updatedStartCount % 5 == 0) || (scanFrequency == 3 && mApp.isScanFinished() == false && updatedStartCount % 10 == 0) || (scanFrequency == 4 && mApp.isScanFinished() == false && updatedStartCount % 20 == 0)) { buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text); buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info); buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout); buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryInfoText.setPaintFlags( buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryMainText.setPaintFlags( buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); initScanProcess(1); } else { //Check if this activity was called from Settings. if (getIntent().hasExtra("UPGRADE")) { if (getIntent().getExtras().getBoolean("UPGRADE") == true) { mExplicitShowTrialFragment = true; } else { mExplicitShowTrialFragment = false; } } //initInAppBilling(); launchMainActivity(); } //Fire away a report to Google Analytics. try { if (mApp.isGoogleAnalyticsEnabled() == true) { EasyTracker easyTracker = EasyTracker.getInstance(this); easyTracker.send(MapBuilder.createEvent("Jams startup.", // Event category (required) "User started Jams.", // Event action (required) "User started Jams.", // Event label null) // Event value .build()); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.jams.music.player.LauncherActivity.LauncherActivity.java
@SuppressLint("NewApi") @Override/* w ww. java 2 s. com*/ public void onCreate(Bundle savedInstanceState) { setTheme(R.style.AppThemeNoActionBar); super.onCreate(savedInstanceState); setContentView(R.layout.activity_launcher); mContext = this; mActivity = this; mApp = (Common) mContext.getApplicationContext(); mHandler = new Handler(); //Increment the start count. This value will be used to determine when the library should be rescanned. int startCount = mApp.getSharedPreferences().getInt("START_COUNT", 1); mApp.getSharedPreferences().edit().putInt("START_COUNT", startCount + 1).commit(); //Save the dimensions of the layout for later use on KitKat devices. final RelativeLayout launcherRootView = (RelativeLayout) findViewById(R.id.launcher_root_view); launcherRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { try { int screenDimens[] = new int[2]; int screenHeight = 0; int screenWidth = 0; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { //API levels 14, 15 and 16. screenDimens = getTrueDeviceResolution(); screenWidth = screenDimens[0]; screenHeight = screenDimens[1]; } else { //API levels 17+. Display display = getWindowManager().getDefaultDisplay(); DisplayMetrics metrics = new DisplayMetrics(); display.getRealMetrics(metrics); screenHeight = metrics.heightPixels; screenWidth = metrics.widthPixels; } int layoutHeight = launcherRootView.getHeight(); int layoutWidth = launcherRootView.getWidth(); int extraHeight = screenHeight - layoutHeight; int extraWidth = screenWidth = layoutWidth; mApp.getSharedPreferences().edit().putInt("KITKAT_HEIGHT", layoutHeight).commit(); mApp.getSharedPreferences().edit().putInt("KITKAT_WIDTH", layoutWidth).commit(); mApp.getSharedPreferences().edit().putInt("KITKAT_HEIGHT_LAND", layoutWidth - extraHeight) .commit(); mApp.getSharedPreferences().edit().putInt("KITKAT_WIDTH_LAND", screenHeight).commit(); } catch (Exception e) { e.printStackTrace(); } } }); //Build the music library based on the user's scan frequency preferences. int scanFrequency = mApp.getSharedPreferences().getInt("SCAN_FREQUENCY", 5); int updatedStartCount = mApp.getSharedPreferences().getInt("START_COUNT", 1); //Launch the appropriate activity based on the "FIRST RUN" flag. if (mApp.getSharedPreferences().getBoolean(Common.FIRST_RUN, true) == true) { //Create the default Playlists directory if it doesn't exist. File playlistsDirectory = new File(Environment.getExternalStorageDirectory() + "/Playlists/"); if (!playlistsDirectory.exists() || !playlistsDirectory.isDirectory()) { playlistsDirectory.mkdir(); } //Disable equalizer for HTC devices by default. if (mApp.getSharedPreferences().getBoolean(Common.FIRST_RUN, true) == true && Build.PRODUCT.contains("HTC")) { mApp.getSharedPreferences().edit().putBoolean("EQUALIZER_ENABLED", false).commit(); } //Send out a test broadcast to initialize the homescreen/lockscreen widgets. sendBroadcast(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME)); Intent intent = new Intent(this, WelcomeActivity.class); startActivity(intent); overridePendingTransition(R.anim.fade_in, R.anim.fade_out); } else if (mApp.isBuildingLibrary()) { buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text); buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info); buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout); buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryInfoText.setPaintFlags( buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryMainText.setPaintFlags( buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setText(R.string.jams_is_building_library); buildingLibraryLayout.setVisibility(View.VISIBLE); //Initialize the runnable that will fire once the scan process is complete. mHandler.post(scanFinishedCheckerRunnable); } else if (mApp.getSharedPreferences().getBoolean("RESCAN_ALBUM_ART", false) == true) { buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text); buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info); buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout); buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryInfoText.setPaintFlags( buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryMainText.setPaintFlags( buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setText(R.string.jams_is_caching_artwork); initScanProcess(0); } else if ((mApp.getSharedPreferences().getBoolean("REBUILD_LIBRARY", false) == true) || (scanFrequency == 0 && mApp.isScanFinished() == false) || (scanFrequency == 1 && mApp.isScanFinished() == false && updatedStartCount % 3 == 0) || (scanFrequency == 2 && mApp.isScanFinished() == false && updatedStartCount % 5 == 0) || (scanFrequency == 3 && mApp.isScanFinished() == false && updatedStartCount % 10 == 0) || (scanFrequency == 4 && mApp.isScanFinished() == false && updatedStartCount % 20 == 0)) { buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text); buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info); buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout); buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryInfoText.setPaintFlags( buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryMainText.setPaintFlags( buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); initScanProcess(1); } else { //Check if this activity was called from Settings. if (getIntent().hasExtra("UPGRADE")) { if (getIntent().getExtras().getBoolean("UPGRADE") == true) { mExplicitShowTrialFragment = true; } else { mExplicitShowTrialFragment = false; } } //initInAppBilling(); launchMainActivity(); } //Fire away a report to Google Analytics. try { if (mApp.isGoogleAnalyticsEnabled() == true) { EasyTracker easyTracker = EasyTracker.getInstance(this); easyTracker.send(MapBuilder.createEvent("Genesis Music startup.", // Event category (required) "User started Genesis Music.", // Event action (required) "User started Genesis Music.", // Event label null) // Event value .build()); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.jelly.music.player.LauncherActivity.LauncherActivity.java
@SuppressLint("NewApi") @Override/*w w w . j a v a2 s.c o m*/ public void onCreate(Bundle savedInstanceState) { Parse.initialize(this, "aZiGV1G02m1Mj3SaaD9riuyrucDclK7abpc2Ibz3", "eCPoMrWrFnnHPVmBbDDIAFAMTA5EJLgtHLS2U9St"); Map<String, String> dimensions = new HashMap<String, String>(); // What type of news is this? dimensions.put("category", "politics"); // Is it a weekday or the weekend? dimensions.put("dayType", "weekday"); // Send the dimensions to Parse along with the 'read' event ParseAnalytics.trackEvent("read", dimensions); setTheme(R.style.AppThemeNoActionBar); super.onCreate(savedInstanceState); setContentView(R.layout.activity_launcher); mContext = this; mActivity = this; mApp = (Common) mContext.getApplicationContext(); mHandler = new Handler(); //Increment the start count. This value will be used to determine when the library should be rescanned. int startCount = mApp.getSharedPreferences().getInt("START_COUNT", 1); mApp.getSharedPreferences().edit().putInt("START_COUNT", startCount + 1).commit(); //Save the dimensions of the layout for later use on KitKat devices. final RelativeLayout launcherRootView = (RelativeLayout) findViewById(R.id.launcher_root_view); launcherRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { try { int screenDimens[] = new int[2]; int screenHeight = 0; int screenWidth = 0; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { //API levels 14, 15 and 16. screenDimens = getTrueDeviceResolution(); screenWidth = screenDimens[0]; screenHeight = screenDimens[1]; } else { //API levels 17+. Display display = getWindowManager().getDefaultDisplay(); DisplayMetrics metrics = new DisplayMetrics(); display.getRealMetrics(metrics); screenHeight = metrics.heightPixels; screenWidth = metrics.widthPixels; } int layoutHeight = launcherRootView.getHeight(); int layoutWidth = launcherRootView.getWidth(); int extraHeight = screenHeight - layoutHeight; int extraWidth = screenWidth = layoutWidth; mApp.getSharedPreferences().edit().putInt("KITKAT_HEIGHT", layoutHeight).commit(); mApp.getSharedPreferences().edit().putInt("KITKAT_WIDTH", layoutWidth).commit(); mApp.getSharedPreferences().edit().putInt("KITKAT_HEIGHT_LAND", layoutWidth - extraHeight) .commit(); mApp.getSharedPreferences().edit().putInt("KITKAT_WIDTH_LAND", screenHeight).commit(); } catch (Exception e) { e.printStackTrace(); } } }); //Build the music library based on the user's scan frequency preferences. int scanFrequency = mApp.getSharedPreferences().getInt("SCAN_FREQUENCY", 5); int updatedStartCount = mApp.getSharedPreferences().getInt("START_COUNT", 1); //Launch the appropriate activity based on the "FIRST RUN" flag. if (mApp.getSharedPreferences().getBoolean(Common.FIRST_RUN, true) == true) { //Create the default Playlists directory if it doesn't exist. File playlistsDirectory = new File(Environment.getExternalStorageDirectory() + "/Playlists/"); if (!playlistsDirectory.exists() || !playlistsDirectory.isDirectory()) { playlistsDirectory.mkdir(); } //Disable equalizer for HTC devices by default. if (mApp.getSharedPreferences().getBoolean(Common.FIRST_RUN, true) == true && Build.PRODUCT.contains("HTC")) { mApp.getSharedPreferences().edit().putBoolean("EQUALIZER_ENABLED", false).commit(); } //Send out a test broadcast to initialize the homescreen/lockscreen widgets. sendBroadcast(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME)); Intent intent = new Intent(this, WelcomeActivity.class); startActivity(intent); overridePendingTransition(R.anim.fade_in, R.anim.fade_out); } else if (mApp.isBuildingLibrary()) { buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text); buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info); buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout); buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryInfoText.setPaintFlags( buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryMainText.setPaintFlags( buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setText(R.string.jams_is_building_library); buildingLibraryLayout.setVisibility(View.VISIBLE); //Initialize the runnable that will fire once the scan process is complete. mHandler.post(scanFinishedCheckerRunnable); } else if (mApp.getSharedPreferences().getBoolean("RESCAN_ALBUM_ART", false) == true) { buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text); buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info); buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout); buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryInfoText.setPaintFlags( buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryMainText.setPaintFlags( buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setText(R.string.jams_is_caching_artwork); initScanProcess(0); } else if ((mApp.getSharedPreferences().getBoolean("REBUILD_LIBRARY", false) == true) || (scanFrequency == 0 && mApp.isScanFinished() == false) || (scanFrequency == 1 && mApp.isScanFinished() == false && updatedStartCount % 3 == 0) || (scanFrequency == 2 && mApp.isScanFinished() == false && updatedStartCount % 5 == 0) || (scanFrequency == 3 && mApp.isScanFinished() == false && updatedStartCount % 10 == 0) || (scanFrequency == 4 && mApp.isScanFinished() == false && updatedStartCount % 20 == 0)) { buildingLibraryMainText = (TextView) findViewById(R.id.building_music_library_text); buildingLibraryInfoText = (TextView) findViewById(R.id.building_music_library_info); buildingLibraryLayout = (RelativeLayout) findViewById(R.id.building_music_library_layout); buildingLibraryInfoText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryInfoText.setPaintFlags( buildingLibraryInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); buildingLibraryMainText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); buildingLibraryMainText.setPaintFlags( buildingLibraryMainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); initScanProcess(1); } else { //Check if this activity was called from Settings. if (getIntent().hasExtra("UPGRADE")) { if (getIntent().getExtras().getBoolean("UPGRADE") == true) { mExplicitShowTrialFragment = true; } else { mExplicitShowTrialFragment = false; } } //initInAppBilling(); launchMainActivity(); } //Fire away a report to Google Analytics. try { if (mApp.isGoogleAnalyticsEnabled() == true) { EasyTracker easyTracker = EasyTracker.getInstance(this); easyTracker.send(MapBuilder.createEvent("Jelly startup.", // Event category (required) "User started Jelly.", // Event action (required) "User started Jelly.", // Event label null) // Event value .build()); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.aniruddhc.acemusic.player.Dialogs.ID3sArtistEditorDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { mContext = getActivity();//from w w w. java 2s. c o 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();// w w w .j a v a 2 s . c o 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.elpstudio.player.EqualizerActivity.java
@Override public void onCreate(Bundle savedInstanceState) { //Context./*from w ww. j a v a 2s .com*/ mContext = getApplicationContext(); mApp = (Common) mContext.getApplicationContext(); mFragment = this; //setTheme(); super.onCreate(savedInstanceState); //Equalizer container elements. mScrollView = (ScrollView) findViewById(R.id.equalizerScrollView); //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); //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); 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); 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(); /* getSupportActionBar().setHomeButtonEnabled(false); getSupportActionBar().setDisplayHomeAsUpEnabled(true);*/ }
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;/* ww w.j a va 2 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; }