Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.08 KB | None | 0 0
  1. /**
  2. * Utility Class for showcase view.
  3. */
  4. public class ShowCaseViewHelper {
  5. private FragmentActivity context;
  6.  
  7. //Constructor
  8. public ShowCaseViewHelper(FragmentActivity context) {
  9. this.context = context;
  10. }
  11.  
  12. /**
  13. * Method to show the showCaseView
  14. *
  15. * @param headerText String for header
  16. * @param subHeaderText String for subHeader
  17. * @param view View to showcase
  18. * @param uniqueID String unique ID for auto-management of sharedPreferences
  19. */
  20. public void getShowCaseView(String headerText, String subHeaderText, View view, String uniqueID) {
  21.  
  22. spotlightViewBuilder(headerText, subHeaderText, view, uniqueID)
  23. .show();
  24. }
  25.  
  26. /**
  27. * Method to display cascade showcase views i.e two showcase views one after another
  28. *
  29. * @param headerText Header text i.e string
  30. * @param subHeaderText SubHeader text i.e String
  31. * @param view View to be showcase i.e View
  32. * @param uniqueID Unique ID for auto-management of sharedPreferences i.e String
  33. * @param cascadeHeaderText Cascade header text i.e string
  34. * @param cascadeSubHeaderText Cascade subHeader text i.e String
  35. * @param cascadeView Cascade View to be showcase i.e View
  36. * @param cascadeUniqueID Cascade Unique ID for auto-management of sharedPreferences i.e String
  37. */
  38. public void getCascadeShowCaseView(final String headerText, final String subHeaderText, View view,
  39. String uniqueID, final String cascadeHeaderText,
  40. final String cascadeSubHeaderText, final View cascadeView,
  41. final String cascadeUniqueID) {
  42.  
  43. spotlightViewBuilder(headerText, subHeaderText, view, uniqueID)
  44. .setListener(new SpotlightListener() {
  45. @Override
  46. public void onUserClicked(String s) {
  47. getShowCaseView(cascadeHeaderText, cascadeSubHeaderText, cascadeView, cascadeUniqueID);
  48. }
  49. }).show();
  50.  
  51. }
  52.  
  53. private SpotlightView.Builder spotlightViewBuilder(final String headerText, final String subHeaderText, View view,
  54. String uniqueID) {
  55.  
  56. return new SpotlightView.Builder(context)
  57. .introAnimationDuration(200) //Intro animation duration (For Reveal and Fadein) i.e long
  58. .enableRevealAnimation(false) //Enable reveal animation (Only for Lollipop and above) i.e boolean
  59. .performClick(true) //Perform a click on target view i.e boolean
  60. .fadeinTextDuration(200)//Fade in animation duration for spotlight text (Heading and Sub-heading) i.e long
  61. .headingTvColor(ContextCompat.getColor(context, R.color.showcaseview_headertext))//Color of heading text i.e int
  62. .headingTvSize(32)//Size of heading text i.e int
  63. .headingTvText(headerText) //Text to display in heading i.e CharSequence
  64. .subHeadingTvColor(ContextCompat.getColor(context, R.color.showcaseview_subheadertext))//Color of sub-heading text i.e int
  65. .subHeadingTvSize(16)//Size of sub-heading text i.e int
  66. .subHeadingTvText(subHeaderText)//Text to display in sub-heading i.e CharSequence
  67. .maskColor(ContextCompat.getColor(context, R.color.showcaseview_maskcolor)) //Overlay Color i.e intl
  68. .target(view) //View to showcase i.e View
  69. .lineAnimDuration(200) //Line animation duration i.e long
  70. .lineAndArcColor(ContextCompat.getColor(context, R.color.showcaseview_linearccolor))//Color of the spotlight line i.e int
  71. .dismissOnTouch(true)//Dismiss on touch outside i.e boolean
  72. .dismissOnBackPress(true)//Dismiss on back pressed i.e boolean
  73. .enableDismissAfterShown(true)//Dismiss on touch outside after spotlight is completely visible i.e boolean
  74. .usageId(uniqueID); //UNIQUE ID i.e String
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement