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.jelly.music.player.Dialogs.CautionEditArtistsDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { parentActivity = getActivity();/*from www . jav a 2s . c o m*/ dialogFragment = this; EDIT_TYPE = this.getArguments().getString("EDIT_TYPE"); ARTIST = this.getArguments().getString("ARTIST"); rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.fragment_caution_edit_artists, null); cautionText = (TextView) rootView.findViewById(R.id.caution_text); cautionText.setText(R.string.caution_artists_text); cautionText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); cautionText.setPaintFlags(cautionText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); sharedPreferences = getActivity().getSharedPreferences("com.jelly.music.player", Context.MODE_PRIVATE); sharedPreferences.edit().putBoolean("SHOW_ARTIST_EDIT_CAUTION", false).commit(); dontShowAgainText = (TextView) rootView.findViewById(R.id.dont_show_again_text); dontShowAgainText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); dontShowAgainText.setPaintFlags( dontShowAgainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); dontShowAgainCheckbox = (CheckBox) rootView.findViewById(R.id.dont_show_again_checkbox); dontShowAgainCheckbox.setChecked(true); dontShowAgainCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton arg0, boolean isChecked) { if (isChecked == true) { sharedPreferences.edit().putBoolean("SHOW_ARTIST_EDIT_CAUTION", false).commit(); } else { sharedPreferences.edit().putBoolean("SHOW_ARTIST_EDIT_CAUTION", true).commit(); } } }); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); //Set the dialog title. builder.setTitle(R.string.caution); builder.setView(rootView); builder.setNegativeButton(R.string.no, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogFragment.dismiss(); } }); builder.setPositiveButton(R.string.yes, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogFragment.dismiss(); FragmentTransaction ft = getFragmentManager().beginTransaction(); Bundle bundle = new Bundle(); bundle.putString("EDIT_TYPE", EDIT_TYPE); bundle.putString("ARTIST", ARTIST); ID3sArtistEditorDialog dialog = new ID3sArtistEditorDialog(); dialog.setArguments(bundle); dialog.show(ft, "id3ArtistEditorDialog"); } }); return builder.create(); }
From source file:com.aniruddhc.acemusic.player.Dialogs.CautionEditArtistsDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { parentActivity = getActivity();/* w w w .j a v a2 s . c om*/ dialogFragment = this; EDIT_TYPE = this.getArguments().getString("EDIT_TYPE"); ARTIST = this.getArguments().getString("ARTIST"); rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.fragment_caution_edit_artists, null); cautionText = (TextView) rootView.findViewById(R.id.caution_text); cautionText.setText(R.string.caution_artists_text); cautionText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); cautionText.setPaintFlags(cautionText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); sharedPreferences = getActivity().getSharedPreferences("com.aniruddhc.acemusic.player", Context.MODE_PRIVATE); sharedPreferences.edit().putBoolean("SHOW_ARTIST_EDIT_CAUTION", false).commit(); dontShowAgainText = (TextView) rootView.findViewById(R.id.dont_show_again_text); dontShowAgainText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); dontShowAgainText.setPaintFlags( dontShowAgainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); dontShowAgainCheckbox = (CheckBox) rootView.findViewById(R.id.dont_show_again_checkbox); dontShowAgainCheckbox.setChecked(true); dontShowAgainCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton arg0, boolean isChecked) { if (isChecked == true) { sharedPreferences.edit().putBoolean("SHOW_ARTIST_EDIT_CAUTION", false).commit(); } else { sharedPreferences.edit().putBoolean("SHOW_ARTIST_EDIT_CAUTION", true).commit(); } } }); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); //Set the dialog title. builder.setTitle(R.string.caution); builder.setView(rootView); builder.setNegativeButton(R.string.no, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogFragment.dismiss(); } }); builder.setPositiveButton(R.string.yes, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogFragment.dismiss(); FragmentTransaction ft = getFragmentManager().beginTransaction(); Bundle bundle = new Bundle(); bundle.putString("EDIT_TYPE", EDIT_TYPE); bundle.putString("ARTIST", ARTIST); ID3sArtistEditorDialog dialog = new ID3sArtistEditorDialog(); dialog.setArguments(bundle); dialog.show(ft, "id3ArtistEditorDialog"); } }); return builder.create(); }
From source file:se.attentec.attenhome.TypefaceSpan.java
@Override public void updateDrawState(TextPaint tp) { tp.setTypeface(mTypeface);//from w ww.j a v a 2 s . c om tp.setTextSize(mTextSize); tp.setColor(mColor); // Note: This flag is required for proper typeface rendering tp.setFlags(tp.getFlags() | Paint.SUBPIXEL_TEXT_FLAG); }
From source file:com.Duo.music.player.Dialogs.CautionEditAlbumsDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { parentActivity = getActivity();/*w w w . j av a 2s. c o m*/ dialogFragment = this; album = this.getArguments().getString("ALBUM"); artist = this.getArguments().getString("ARTIST"); callingActivity = this.getArguments().getString("CALLING_FRAGMENT"); rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.fragment_caution_edit_albums, null); cautionText = (TextView) rootView.findViewById(R.id.caution_text); cautionText.setText(R.string.caution_albums_text); cautionText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); cautionText.setPaintFlags(cautionText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); sharedPreferences = getActivity().getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE); dontShowAgainText = (TextView) rootView.findViewById(R.id.dont_show_again_text); dontShowAgainText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); dontShowAgainText.setPaintFlags( dontShowAgainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); dontShowAgainCheckbox = (CheckBox) rootView.findViewById(R.id.dont_show_again_checkbox); dontShowAgainCheckbox.setChecked(true); sharedPreferences.edit().putBoolean("SHOW_ALBUM_EDIT_CAUTION", false).commit(); dontShowAgainCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton arg0, boolean isChecked) { if (isChecked == true) { sharedPreferences.edit().putBoolean("SHOW_ALBUM_EDIT_CAUTION", false).commit(); } else { sharedPreferences.edit().putBoolean("SHOW_ALBUM_EDIT_CAUTION", true).commit(); } } }); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); //Set the dialog title. builder.setTitle(R.string.caution); builder.setView(rootView); builder.setNegativeButton(R.string.no, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogFragment.dismiss(); } }); builder.setPositiveButton(R.string.yes, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogFragment.dismiss(); FragmentTransaction ft = getFragmentManager().beginTransaction(); Bundle bundle = new Bundle(); bundle.putString("EDIT_TYPE", "ALBUM"); bundle.putString("ALBUM", album); bundle.putString("ARTIST", artist); bundle.putString("CALLING_FRAGMENT", callingActivity); ID3sAlbumEditorDialog dialog = new ID3sAlbumEditorDialog(); dialog.setArguments(bundle); dialog.show(ft, "id3EditorDialog"); } }); return builder.create(); }
From source file:com.jelly.music.player.Dialogs.CautionEditAlbumsDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { parentActivity = getActivity();/*from ww w . j a v a 2 s. c o m*/ dialogFragment = this; album = this.getArguments().getString("ALBUM"); artist = this.getArguments().getString("ARTIST"); callingActivity = this.getArguments().getString("CALLING_FRAGMENT"); rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.fragment_caution_edit_albums, null); cautionText = (TextView) rootView.findViewById(R.id.caution_text); cautionText.setText(R.string.caution_albums_text); cautionText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); cautionText.setPaintFlags(cautionText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); sharedPreferences = getActivity().getSharedPreferences("com.jelly.music.player", Context.MODE_PRIVATE); dontShowAgainText = (TextView) rootView.findViewById(R.id.dont_show_again_text); dontShowAgainText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); dontShowAgainText.setPaintFlags( dontShowAgainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); dontShowAgainCheckbox = (CheckBox) rootView.findViewById(R.id.dont_show_again_checkbox); dontShowAgainCheckbox.setChecked(true); sharedPreferences.edit().putBoolean("SHOW_ALBUM_EDIT_CAUTION", false).commit(); dontShowAgainCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton arg0, boolean isChecked) { if (isChecked == true) { sharedPreferences.edit().putBoolean("SHOW_ALBUM_EDIT_CAUTION", false).commit(); } else { sharedPreferences.edit().putBoolean("SHOW_ALBUM_EDIT_CAUTION", true).commit(); } } }); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); //Set the dialog title. builder.setTitle(R.string.caution); builder.setView(rootView); builder.setNegativeButton(R.string.no, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogFragment.dismiss(); } }); builder.setPositiveButton(R.string.yes, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogFragment.dismiss(); FragmentTransaction ft = getFragmentManager().beginTransaction(); Bundle bundle = new Bundle(); bundle.putString("EDIT_TYPE", "ALBUM"); bundle.putString("ALBUM", album); bundle.putString("ARTIST", artist); bundle.putString("CALLING_FRAGMENT", callingActivity); ID3sAlbumEditorDialog dialog = new ID3sAlbumEditorDialog(); dialog.setArguments(bundle); dialog.show(ft, "id3EditorDialog"); } }); return builder.create(); }
From source file:com.aniruddhc.acemusic.player.Dialogs.CautionEditAlbumsDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { parentActivity = getActivity();// w w w .j a va2s .c om dialogFragment = this; album = this.getArguments().getString("ALBUM"); artist = this.getArguments().getString("ARTIST"); callingActivity = this.getArguments().getString("CALLING_FRAGMENT"); rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.fragment_caution_edit_albums, null); cautionText = (TextView) rootView.findViewById(R.id.caution_text); cautionText.setText(R.string.caution_albums_text); cautionText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); cautionText.setPaintFlags(cautionText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); sharedPreferences = getActivity().getSharedPreferences("com.aniruddhc.acemusic.player", Context.MODE_PRIVATE); dontShowAgainText = (TextView) rootView.findViewById(R.id.dont_show_again_text); dontShowAgainText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); dontShowAgainText.setPaintFlags( dontShowAgainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); dontShowAgainCheckbox = (CheckBox) rootView.findViewById(R.id.dont_show_again_checkbox); dontShowAgainCheckbox.setChecked(true); sharedPreferences.edit().putBoolean("SHOW_ALBUM_EDIT_CAUTION", false).commit(); dontShowAgainCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton arg0, boolean isChecked) { if (isChecked == true) { sharedPreferences.edit().putBoolean("SHOW_ALBUM_EDIT_CAUTION", false).commit(); } else { sharedPreferences.edit().putBoolean("SHOW_ALBUM_EDIT_CAUTION", true).commit(); } } }); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); //Set the dialog title. builder.setTitle(R.string.caution); builder.setView(rootView); builder.setNegativeButton(R.string.no, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogFragment.dismiss(); } }); builder.setPositiveButton(R.string.yes, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogFragment.dismiss(); FragmentTransaction ft = getFragmentManager().beginTransaction(); Bundle bundle = new Bundle(); bundle.putString("EDIT_TYPE", "ALBUM"); bundle.putString("ALBUM", album); bundle.putString("ARTIST", artist); bundle.putString("CALLING_FRAGMENT", callingActivity); ID3sAlbumEditorDialog dialog = new ID3sAlbumEditorDialog(); dialog.setArguments(bundle); dialog.show(ft, "id3EditorDialog"); } }); return builder.create(); }
From source file:com.aniruddhc.acemusic.player.MiscFragments.BuildingLibraryProgressFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mContext = getActivity().getApplicationContext(); mApp = (Common) mContext;// w w w. j ava2 s.com mRootView = (View) getActivity().getLayoutInflater().inflate(R.layout.fragment_building_library_progress, null); mProgressElementsContainer = (RelativeLayout) mRootView.findViewById(R.id.progress_elements_container); mProgressElementsContainer.setVisibility(View.INVISIBLE); mCurrentTaskText = (TextView) mRootView.findViewById(R.id.building_library_task); mCurrentTaskText.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Light")); mCurrentTaskText .setPaintFlags(mCurrentTaskText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); mProgressBar = (ProgressBar) mRootView.findViewById(R.id.building_library_progress); mProgressBar.setMax(1000000); mFadeInAnimation = AnimationUtils.loadAnimation(mContext, R.anim.fade_in); mFadeInAnimation.setAnimationListener(fadeInListener); mFadeInAnimation.setDuration(700); return mRootView; }
From source file:com.Duo.music.player.Dialogs.CustomizeScreensDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { parentActivity = getActivity();//from w w w .ja va 2 s . c o m dialogFragment = (DialogFragment) getFragmentManager().findFragmentByTag("customizeScreensDialog"); sharedPreferences = parentActivity.getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE); rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.customize_screens_layout, null); customizeScreensText = (TextView) rootView.findViewById(R.id.customize_screens_text); customizeScreensText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); customizeScreensText.setPaintFlags( customizeScreensText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); //Populate the arraylists with the settings saved in SharedPreferences. page1 = sharedPreferences.getString("PAGE_1", getResources().getString(R.string.artists_caps)); page2 = sharedPreferences.getString("PAGE_2", getResources().getString(R.string.albums_caps)); page3 = sharedPreferences.getString("PAGE_3", getResources().getString(R.string.songs_caps)); page4 = sharedPreferences.getString("PAGE_4", getResources().getString(R.string.playlists_caps)); page5 = sharedPreferences.getString("PAGE_5", getResources().getString(R.string.genres_caps)); page6 = sharedPreferences.getString("PAGE_6", getResources().getString(R.string.folders_caps)); if (!page1.equals("null") || !page1.equals(null)) { screenTitlesList.add(page1); } if (!page2.equals("null") || !page2.equals(null)) { screenTitlesList.add(page2); } if (!page3.equals("null") || !page3.equals(null)) { screenTitlesList.add(page3); } if (!page4.equals("null") || !page4.equals(null)) { screenTitlesList.add(page4); } if (!page5.equals("null") || !page5.equals(null)) { screenTitlesList.add(page5); } if (!page6.equals("null") || !page6.equals(null)) { screenTitlesList.add(page6); } listView = (DragSortListView) rootView.findViewById(R.id.customize_screens_listview); adapter = new CustomizeScreensListAdapter(parentActivity, screenTitlesList); listView.setAdapter(adapter); listView.setDropListener(onDrop); SimpleFloatViewManager simpleFloatViewManager = new SimpleFloatViewManager(listView); simpleFloatViewManager.setBackgroundColor(Color.TRANSPARENT); listView.setFloatViewManager(simpleFloatViewManager); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); //Set the dialog title. builder.setTitle(R.string.customize_screens); builder.setView(rootView); builder.setPositiveButton(R.string.done, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogFragment.dismiss(); //adapter.getItem(i) will get us the order for the screens. sharedPreferences.edit().putString("PAGE_1", adapter.getItem(0).toString().toUpperCase()).commit(); sharedPreferences.edit().putString("PAGE_2", adapter.getItem(1).toString().toUpperCase()).commit(); sharedPreferences.edit().putString("PAGE_3", adapter.getItem(2).toString().toUpperCase()).commit(); sharedPreferences.edit().putString("PAGE_4", adapter.getItem(3).toString().toUpperCase()).commit(); sharedPreferences.edit().putString("PAGE_5", adapter.getItem(4).toString().toUpperCase()).commit(); sharedPreferences.edit().putString("PAGE_6", adapter.getItem(5).toString().toUpperCase()).commit(); Toast.makeText(parentActivity, R.string.changes_saved, Toast.LENGTH_SHORT).show(); //Restart the app. Intent i = parentActivity.getBaseContext().getPackageManager() .getLaunchIntentForPackage(parentActivity.getBaseContext().getPackageName()); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); dialogFragment.dismiss(); getActivity().finish(); startActivity(i); } }); return builder.create(); }
From source file:com.jelly.music.player.Dialogs.CustomizeScreensDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { parentActivity = getActivity();/* ww w .j a v a 2s . c o m*/ dialogFragment = (DialogFragment) getFragmentManager().findFragmentByTag("customizeScreensDialog"); sharedPreferences = parentActivity.getSharedPreferences("com.jelly.music.player", Context.MODE_PRIVATE); rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.customize_screens_layout, null); customizeScreensText = (TextView) rootView.findViewById(R.id.customize_screens_text); customizeScreensText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); customizeScreensText.setPaintFlags( customizeScreensText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); //Populate the arraylists with the settings saved in SharedPreferences. page1 = sharedPreferences.getString("PAGE_1", getResources().getString(R.string.artists_caps)); page2 = sharedPreferences.getString("PAGE_2", getResources().getString(R.string.albums_caps)); page3 = sharedPreferences.getString("PAGE_3", getResources().getString(R.string.songs_caps)); page4 = sharedPreferences.getString("PAGE_4", getResources().getString(R.string.playlists_caps)); page5 = sharedPreferences.getString("PAGE_5", getResources().getString(R.string.genres_caps)); page6 = sharedPreferences.getString("PAGE_6", getResources().getString(R.string.folders_caps)); if (!page1.equals("null") || !page1.equals(null)) { screenTitlesList.add(page1); } if (!page2.equals("null") || !page2.equals(null)) { screenTitlesList.add(page2); } if (!page3.equals("null") || !page3.equals(null)) { screenTitlesList.add(page3); } if (!page4.equals("null") || !page4.equals(null)) { screenTitlesList.add(page4); } if (!page5.equals("null") || !page5.equals(null)) { screenTitlesList.add(page5); } if (!page6.equals("null") || !page6.equals(null)) { screenTitlesList.add(page6); } listView = (DragSortListView) rootView.findViewById(R.id.customize_screens_listview); adapter = new CustomizeScreensListAdapter(parentActivity, screenTitlesList); listView.setAdapter(adapter); listView.setDropListener(onDrop); SimpleFloatViewManager simpleFloatViewManager = new SimpleFloatViewManager(listView); simpleFloatViewManager.setBackgroundColor(Color.TRANSPARENT); listView.setFloatViewManager(simpleFloatViewManager); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); //Set the dialog title. builder.setTitle(R.string.customize_screens); builder.setView(rootView); builder.setPositiveButton(R.string.done, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogFragment.dismiss(); //adapter.getItem(i) will get us the order for the screens. sharedPreferences.edit().putString("PAGE_1", adapter.getItem(0).toString().toUpperCase()).commit(); sharedPreferences.edit().putString("PAGE_2", adapter.getItem(1).toString().toUpperCase()).commit(); sharedPreferences.edit().putString("PAGE_3", adapter.getItem(2).toString().toUpperCase()).commit(); sharedPreferences.edit().putString("PAGE_4", adapter.getItem(3).toString().toUpperCase()).commit(); sharedPreferences.edit().putString("PAGE_5", adapter.getItem(4).toString().toUpperCase()).commit(); sharedPreferences.edit().putString("PAGE_6", adapter.getItem(5).toString().toUpperCase()).commit(); Toast.makeText(parentActivity, R.string.changes_saved, Toast.LENGTH_SHORT).show(); //Restart the app. Intent i = parentActivity.getBaseContext().getPackageManager() .getLaunchIntentForPackage(parentActivity.getBaseContext().getPackageName()); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); dialogFragment.dismiss(); getActivity().finish(); startActivity(i); } }); return builder.create(); }
From source file:com.aniruddhc.acemusic.player.Dialogs.CustomizeScreensDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { parentActivity = getActivity();//from w ww. j a v a 2 s . c om dialogFragment = (DialogFragment) getFragmentManager().findFragmentByTag("customizeScreensDialog"); sharedPreferences = parentActivity.getSharedPreferences("com.aniruddhc.acemusic.player", Context.MODE_PRIVATE); rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.customize_screens_layout, null); customizeScreensText = (TextView) rootView.findViewById(R.id.customize_screens_text); customizeScreensText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); customizeScreensText.setPaintFlags( customizeScreensText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); //Populate the arraylists with the settings saved in SharedPreferences. page1 = sharedPreferences.getString("PAGE_1", getResources().getString(R.string.artists_caps)); page2 = sharedPreferences.getString("PAGE_2", getResources().getString(R.string.albums_caps)); page3 = sharedPreferences.getString("PAGE_3", getResources().getString(R.string.songs_caps)); page4 = sharedPreferences.getString("PAGE_4", getResources().getString(R.string.playlists_caps)); page5 = sharedPreferences.getString("PAGE_5", getResources().getString(R.string.genres_caps)); page6 = sharedPreferences.getString("PAGE_6", getResources().getString(R.string.folders_caps)); if (!page1.equals("null") || !page1.equals(null)) { screenTitlesList.add(page1); } if (!page2.equals("null") || !page2.equals(null)) { screenTitlesList.add(page2); } if (!page3.equals("null") || !page3.equals(null)) { screenTitlesList.add(page3); } if (!page4.equals("null") || !page4.equals(null)) { screenTitlesList.add(page4); } if (!page5.equals("null") || !page5.equals(null)) { screenTitlesList.add(page5); } if (!page6.equals("null") || !page6.equals(null)) { screenTitlesList.add(page6); } listView = (DragSortListView) rootView.findViewById(R.id.customize_screens_listview); adapter = new CustomizeScreensListAdapter(parentActivity, screenTitlesList); listView.setAdapter(adapter); listView.setDropListener(onDrop); SimpleFloatViewManager simpleFloatViewManager = new SimpleFloatViewManager(listView); simpleFloatViewManager.setBackgroundColor(Color.TRANSPARENT); listView.setFloatViewManager(simpleFloatViewManager); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); //Set the dialog title. builder.setTitle(R.string.customize_screens); builder.setView(rootView); builder.setPositiveButton(R.string.done, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogFragment.dismiss(); //adapter.getItem(i) will get us the order for the screens. sharedPreferences.edit().putString("PAGE_1", adapter.getItem(0).toString().toUpperCase()).commit(); sharedPreferences.edit().putString("PAGE_2", adapter.getItem(1).toString().toUpperCase()).commit(); sharedPreferences.edit().putString("PAGE_3", adapter.getItem(2).toString().toUpperCase()).commit(); sharedPreferences.edit().putString("PAGE_4", adapter.getItem(3).toString().toUpperCase()).commit(); sharedPreferences.edit().putString("PAGE_5", adapter.getItem(4).toString().toUpperCase()).commit(); sharedPreferences.edit().putString("PAGE_6", adapter.getItem(5).toString().toUpperCase()).commit(); Toast.makeText(parentActivity, R.string.changes_saved, Toast.LENGTH_SHORT).show(); //Restart the app. Intent i = parentActivity.getBaseContext().getPackageManager() .getLaunchIntentForPackage(parentActivity.getBaseContext().getPackageName()); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); dialogFragment.dismiss(); getActivity().finish(); startActivity(i); } }); return builder.create(); }