Skip to content

Commit 4abd758

Browse files
committed
Adding super tool tip tutorial
1 parent 42b54d4 commit 4abd758

7 files changed

Lines changed: 69 additions & 6 deletions

File tree

PullMenuSample/PullMenuSample.iml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@
8686
<orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" />
8787
<orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />
8888
<orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />
89+
<orderEntry type="library" exported="" name="library-2.4.0" level="project" />
90+
<orderEntry type="library" exported="" name="library-3.0.0" level="project" />
8991
<orderEntry type="module" module-name="PullMenuLib" exported="" />
9092
</component>
9193
</module>

PullMenuSample/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ dependencies {
2323
compile fileTree(dir: 'libs', include: ['*.jar'])
2424
compile 'com.android.support:appcompat-v7:21.0.3'
2525
compile project(':PullMenuLib')
26+
compile 'com.nhaarman.supertooltips:library:3.0.+'
2627
}

PullMenuSample/src/main/java/al/shkurti/pullmenu/sample/PullMenuFragment.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
package al.shkurti.pullmenu.sample;
22

33
import android.app.Activity;
4+
import android.content.SharedPreferences;
5+
import android.content.res.Resources;
6+
import android.graphics.Color;
47
import android.os.AsyncTask;
58
import android.os.Bundle;
69
import android.support.v4.app.Fragment;
10+
import android.util.TypedValue;
711
import android.view.LayoutInflater;
812
import android.view.View;
913
import android.view.ViewGroup;
14+
import android.widget.RelativeLayout;
15+
import android.widget.TextView;
1016
import android.widget.Toast;
1117

18+
import com.nhaarman.supertooltips.ToolTip;
19+
import com.nhaarman.supertooltips.ToolTipRelativeLayout;
20+
import com.nhaarman.supertooltips.ToolTipView;
21+
1222
import java.util.ArrayList;
1323

1424
import 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
*/
173 KB
Loading

PullMenuSample/src/main/res/layout/fragment_main.xml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<al.shkurti.pullmenu.library.PullMenuLayout
2-
xmlns:android="http://schemas.android.com/apk/res/android"
1+
<al.shkurti.pullmenu.library.PullMenuLayout xmlns:android="http://schemas.android.com/apk/res/android"
32
android:id="@+id/pm_layout"
43
android:layout_width="match_parent"
54
android:layout_height="match_parent">
@@ -11,10 +10,22 @@
1110
android:padding="8dp"
1211
android:scrollbarStyle="outsideInset">
1312

14-
<TextView
13+
<RelativeLayout
1514
android:layout_width="match_parent"
16-
android:layout_height="wrap_content"
17-
android:text="@string/filler_text"/>
15+
android:layout_height="wrap_content">
16+
17+
<com.nhaarman.supertooltips.ToolTipRelativeLayout
18+
android:id="@+id/tooltipframelayout"
19+
android:layout_width="match_parent"
20+
android:layout_height="match_parent" />
21+
22+
<TextView
23+
android:id="@+id/filler_text"
24+
android:layout_width="match_parent"
25+
android:layout_height="wrap_content"
26+
android:text="@string/filler_text" />
27+
</RelativeLayout>
28+
1829

1930
</ScrollView>
2031

PullMenuSample/src/main/res/values/colors.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33

44
<color name="menuColor">#303F9F</color>
55
<color name="progressBarColor">#4CAF50</color>
6+
<color name="tip_color">#009688</color>
67
</resources>

PullMenuSample/src/main/res/values/strings.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
<string name="action_example">Example action</string>
1111
<string name="action_settings">Settings</string>
1212

13-
<string name="filler_text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec
13+
<string name="tip_descr">Pull down to open PullMenu</string>
14+
15+
<string name="filler_text"> * IN * PE * RA * TO * RE * BT *\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Donec
1416
sollicitudin mauris varius lacus porttitor eget blandit massa facilisis. Nulla pellentesque
1517
odio sed purus fermentum vitae viverra orci faucibus. Sed ullamcorper condimentum vulputate.
1618
Curabitur sit amet convallis velit. Vestibulum posuere eleifend risus ac adipiscing. Nam

0 commit comments

Comments
 (0)