11package al .shkurti .pullmenu .sample ;
22
33import android .app .Activity ;
4+ import android .content .SharedPreferences ;
5+ import android .content .res .Resources ;
6+ import android .graphics .Color ;
47import android .os .AsyncTask ;
58import android .os .Bundle ;
69import android .support .v4 .app .Fragment ;
10+ import android .util .TypedValue ;
711import android .view .LayoutInflater ;
812import android .view .View ;
913import android .view .ViewGroup ;
14+ import android .widget .RelativeLayout ;
15+ import android .widget .TextView ;
1016import android .widget .Toast ;
1117
18+ import com .nhaarman .supertooltips .ToolTip ;
19+ import com .nhaarman .supertooltips .ToolTipRelativeLayout ;
20+ import com .nhaarman .supertooltips .ToolTipView ;
21+
1222import java .util .ArrayList ;
1323
1424import al .shkurti .pullmenu .library .ActionBarPullMenu ;
@@ -22,6 +32,7 @@ public class PullMenuFragment extends Fragment implements OnRefreshListener {
2232
2333 private static final String ARG_SECTION_NUMBER = "section_number" ;
2434 private PullMenuLayout mPullMenuLayout ;
35+ ToolTipView myToolTipView ;
2536
2637 public static PullMenuFragment newInstance (int sectionNumber ) {
2738 PullMenuFragment fragment = new PullMenuFragment ();
@@ -56,6 +67,29 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
5667 getResources ().getColor (R .color .menuColor ),
5768 getResources ().getColor (R .color .progressBarColor ),mList );
5869
70+
71+ SharedPreferences prefs = getActivity ().getSharedPreferences ("pullMenu" , 0 );
72+ String restoredText = prefs .getString ("menu" , null );
73+ if (restoredText ==null ) {
74+ TextView mTextView = (TextView ) rootView .findViewById (R .id .filler_text );
75+
76+ int actionBarHeight = 0 ;
77+ TypedValue tv = new TypedValue ();
78+ if (getActivity ().getTheme ().resolveAttribute (android .R .attr .actionBarSize , tv , true ))
79+ {
80+ actionBarHeight = TypedValue .complexToDimensionPixelSize (tv .data ,getResources ().getDisplayMetrics ());
81+ }
82+ mTextView .setPadding (0 ,actionBarHeight , 0 , 0 );
83+
84+ ToolTipRelativeLayout toolTipRelativeLayout = (ToolTipRelativeLayout ) rootView .findViewById (R .id .tooltipframelayout );
85+
86+ ToolTip toolTip = new ToolTip ()
87+ .withText (getResources ().getString (R .string .tip_descr ))
88+ .withTextColor (getResources ().getColor (android .R .color .white ))
89+ .withColor (getResources ().getColor (R .color .tip_color ));
90+
91+ myToolTipView = toolTipRelativeLayout .showToolTipForView (toolTip , mTextView );
92+ }
5993 return rootView ;
6094 }
6195
@@ -64,6 +98,18 @@ public void onRefreshStarted(View view, int position, String selectedField) {
6498 // Hide the list
6599 Toast .makeText (getActivity (), position + " # " + selectedField , Toast .LENGTH_SHORT ).show ();
66100
101+ if (myToolTipView != null ) {
102+ myToolTipView .remove ();
103+ myToolTipView = null ;
104+
105+ TextView mTextView = (TextView ) getActivity ().findViewById (R .id .filler_text );
106+ mTextView .setPadding (0 ,0 ,0 ,0 );
107+
108+ SharedPreferences .Editor editor = getActivity ().getSharedPreferences ("pullMenu" , 0 ).edit ();
109+ editor .putString ("menu" , "Opened" );
110+ editor .commit ();
111+ }
112+
67113 /**
68114 * Simulate Refresh with 5 seconds sleep
69115 */
0 commit comments