Skip to content

Commit 2da906a

Browse files
-separated library from sample.
-added some design library usage for the sample -made it more customizable to set how the handle and bubble look like.
1 parent d8cf203 commit 2da906a

File tree

19 files changed

+421
-114
lines changed

19 files changed

+421
-114
lines changed

app/app.iml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
7373
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
7474
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.1/jars" />
75+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/23.0.1/jars" />
7576
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.0.1/jars" />
7677
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.1/jars" />
7778
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
@@ -91,9 +92,11 @@
9192
</content>
9293
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
9394
<orderEntry type="sourceFolder" forTests="false" />
94-
<orderEntry type="library" exported="" name="recyclerview-v7-23.0.1" level="project" />
95-
<orderEntry type="library" exported="" name="support-v4-23.0.1" level="project" />
95+
<orderEntry type="library" exported="" name="design-23.0.1" level="project" />
9696
<orderEntry type="library" exported="" name="appcompat-v7-23.0.1" level="project" />
97+
<orderEntry type="library" exported="" name="support-v4-23.0.1" level="project" />
98+
<orderEntry type="library" exported="" name="recyclerview-v7-23.0.1" level="project" />
9799
<orderEntry type="library" exported="" name="support-annotations-23.0.1" level="project" />
100+
<orderEntry type="module" module-name="library" exported="" />
98101
</component>
99102
</module>

app/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ dependencies {
2323
compile fileTree(dir: 'libs', include: ['*.jar'])
2424
compile 'com.android.support:recyclerview-v7:23.0.1'
2525
compile 'com.android.support:appcompat-v7:23.0.1'
26+
compile 'com.android.support:design:23.0.1'
27+
compile project(':library')
2628
}

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
android:icon="@mipmap/ic_launcher"
88
android:theme="@style/AppTheme">
99
<activity
10-
android:name="com.lb.lollipop_contacts_recyclerview_fast_scroller.MainActivity"
10+
android:name="com.lb.recyclerview_fast_scroller.MainActivity"
1111
android:icon="@mipmap/ic_launcher"
1212
android:label="@string/app_name">
1313

app/src/main/java/com/lb/lollipop_contacts_recyclerview_fast_scroller/BubbleTextGetter.java

Lines changed: 0 additions & 5 deletions
This file was deleted.

app/src/main/java/com/lb/lollipop_contacts_recyclerview_fast_scroller/MainActivity.java

Lines changed: 0 additions & 55 deletions
This file was deleted.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
package com.lb.lollipop_contacts_recyclerview_fast_scroller;
1+
package com.lb.recyclerview_fast_scroller;
22

33
import android.support.v7.widget.RecyclerView;
44
import android.view.LayoutInflater;
55
import android.view.View;
66
import android.view.ViewGroup;
77
import android.widget.TextView;
88

9+
import com.lb.recyclerview_fast_scroller.RecyclerViewFastScroller.BubbleTextGetter;
10+
911
import java.util.ArrayList;
1012
import java.util.List;
1113

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
package com.lb.recyclerview_fast_scroller;
2+
3+
import android.content.Intent;
4+
import android.net.Uri;
5+
import android.os.Bundle;
6+
import android.support.annotation.Nullable;
7+
import android.support.design.widget.FloatingActionButton;
8+
import android.support.design.widget.Snackbar;
9+
import android.support.design.widget.TabLayout;
10+
import android.support.v4.app.Fragment;
11+
import android.support.v4.app.FragmentManager;
12+
import android.support.v4.app.FragmentStatePagerAdapter;
13+
import android.support.v4.view.ViewPager;
14+
import android.support.v7.app.AppCompatActivity;
15+
import android.support.v7.widget.LinearLayoutManager;
16+
import android.support.v7.widget.RecyclerView;
17+
import android.support.v7.widget.Toolbar;
18+
import android.view.LayoutInflater;
19+
import android.view.Menu;
20+
import android.view.MenuItem;
21+
import android.view.View;
22+
import android.view.ViewGroup;
23+
import android.widget.Toast;
24+
25+
import com.lb.lollipopcontactsrecyclerviewfastscroller.R;
26+
27+
public class MainActivity extends AppCompatActivity {
28+
@Override
29+
protected void onCreate(Bundle savedInstanceState) {
30+
super.onCreate(savedInstanceState);
31+
setContentView(R.layout.activity_main);
32+
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
33+
setSupportActionBar(toolbar);
34+
//note : part of the design library sample code was taken from : https://github.com/sitepoint-editors/Design-Demo/
35+
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
36+
fab.setOnClickListener(new View.OnClickListener() {
37+
@Override
38+
public void onClick(View v) {
39+
Snackbar.make(findViewById(R.id.coordinator), "I'm a Snackbar", Snackbar.LENGTH_LONG).setAction("Action", new View.OnClickListener() {
40+
@Override
41+
public void onClick(View v) {
42+
Toast.makeText(MainActivity.this, "Snackbar Action", Toast.LENGTH_LONG).show();
43+
}
44+
}).show();
45+
}
46+
});
47+
48+
DesignDemoPagerAdapter adapter = new DesignDemoPagerAdapter(getSupportFragmentManager());
49+
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
50+
viewPager.setAdapter(adapter);
51+
TabLayout tabLayout = (TabLayout) findViewById(R.id.tablayout);
52+
tabLayout.setupWithViewPager(viewPager);
53+
}
54+
55+
@Override
56+
public boolean onCreateOptionsMenu(final Menu menu) {
57+
getMenuInflater().inflate(R.menu.activity_main, menu);
58+
return super.onCreateOptionsMenu(menu);
59+
}
60+
61+
@SuppressWarnings("deprecation")
62+
@Override
63+
public boolean onOptionsItemSelected(final MenuItem item) {
64+
String url = null;
65+
switch (item.getItemId()) {
66+
case R.id.menuItem_all_my_apps:
67+
url = "https://play.google.com/store/apps/developer?id=AndroidDeveloperLB";
68+
break;
69+
case R.id.menuItem_all_my_repositories:
70+
url = "https://github.com/AndroidDeveloperLB";
71+
break;
72+
case R.id.menuItem_current_repository_website:
73+
url = "https://github.com/AndroidDeveloperLB/LollipopContactsRecyclerViewFastScroller";
74+
break;
75+
}
76+
if (url == null)
77+
return true;
78+
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
79+
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
80+
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
81+
startActivity(intent);
82+
return true;
83+
}
84+
85+
86+
static class DesignDemoPagerAdapter extends FragmentStatePagerAdapter {
87+
88+
public DesignDemoPagerAdapter(FragmentManager fm) {
89+
super(fm);
90+
}
91+
92+
@Override
93+
public Fragment getItem(int position) {
94+
return new RecyclerViewFragment();
95+
}
96+
97+
@Override
98+
public int getCount() {
99+
return 3;
100+
}
101+
102+
@Override
103+
public CharSequence getPageTitle(int position) {
104+
return "Tab " + position;
105+
}
106+
}
107+
108+
109+
public static class RecyclerViewFragment extends Fragment {
110+
@Nullable
111+
@Override
112+
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
113+
View rootView = inflater.inflate(R.layout.fragment_recycler_view, container, false);
114+
RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerview);
115+
recyclerView.setAdapter(new LargeAdapter());
116+
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
117+
RecyclerViewFastScroller fastScroller = (RecyclerViewFastScroller) rootView.findViewById(R.id.fastscroller);
118+
fastScroller.setRecyclerView(recyclerView);
119+
fastScroller.setViewsToUse(R.layout.recycler_view_fast_scroller__fast_scroller, R.id.fastscroller_bubble, R.id.fastscroller_handle);
120+
return rootView;
121+
}
122+
}
123+
}
Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,45 @@
1-
<RelativeLayout
1+
<android.support.design.widget.CoordinatorLayout
2+
android:id="@+id/coordinator"
23
xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:tools="http://schemas.android.com/tools"
4+
xmlns:app="http://schemas.android.com/apk/res-auto"
45
android:layout_width="match_parent"
56
android:layout_height="match_parent">
67

7-
<android.support.v7.widget.RecyclerView
8-
android:id="@+id/recyclerview"
8+
<android.support.design.widget.AppBarLayout
9+
android:layout_width="match_parent"
10+
android:layout_height="wrap_content"
11+
android:theme="@style/ThemeOverlay.AppCompat.Dark">
12+
13+
<android.support.v7.widget.Toolbar
14+
android:id="@+id/toolbar"
15+
android:layout_width="match_parent"
16+
android:layout_height="?attr/actionBarSize"
17+
android:background="?attr/colorPrimary"
18+
app:layout_scrollFlags="scroll|enterAlways"/>
19+
20+
<android.support.design.widget.TabLayout
21+
android:id="@+id/tablayout"
22+
android:layout_width="match_parent"
23+
android:layout_height="wrap_content"
24+
android:background="?attr/colorPrimary"
25+
app:tabGravity="fill"/>
26+
27+
</android.support.design.widget.AppBarLayout>
28+
29+
<android.support.v4.view.ViewPager
30+
android:id="@+id/viewpager"
931
android:layout_width="match_parent"
1032
android:layout_height="match_parent"
11-
android:paddingBottom="@dimen/activity_vertical_margin"
12-
android:paddingLeft="@dimen/activity_horizontal_margin"
13-
android:paddingRight="@dimen/activity_horizontal_margin"
14-
android:paddingTop="@dimen/activity_vertical_margin"
15-
android:scrollbars="none"
16-
tools:context=".MainActivity"/>
33+
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
1734

18-
<com.lb.lollipop_contacts_recyclerview_fast_scroller.FastScroller
19-
android:id="@+id/fastscroller"
35+
<android.support.design.widget.FloatingActionButton
36+
android:id="@+id/fab"
2037
android:layout_width="wrap_content"
21-
android:layout_height="match_parent"
22-
android:layout_alignBottom="@id/recyclerview"
23-
android:layout_alignParentEnd="true"
24-
android:layout_alignParentRight="true"
25-
android:layout_alignTop="@id/recyclerview"
38+
android:layout_height="wrap_content"
39+
android:layout_alignParentBottom="true"
40+
android:layout_gravity="bottom|right"
41+
android:layout_marginBottom="@dimen/activity_vertical_margin"
42+
android:layout_marginRight="@dimen/activity_horizontal_margin"
2643
/>
27-
</RelativeLayout>
2844

45+
</android.support.design.widget.CoordinatorLayout>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<RelativeLayout
2+
xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent">
6+
7+
<android.support.v7.widget.RecyclerView
8+
android:id="@+id/recyclerview"
9+
android:layout_width="match_parent"
10+
android:layout_height="match_parent"
11+
android:paddingBottom="@dimen/activity_vertical_margin"
12+
android:paddingLeft="@dimen/activity_horizontal_margin"
13+
android:paddingRight="@dimen/activity_horizontal_margin"
14+
android:paddingTop="@dimen/activity_vertical_margin"
15+
tools:context=".MainActivity"/>
16+
17+
<com.lb.recyclerview_fast_scroller.RecyclerViewFastScroller
18+
android:id="@+id/fastscroller"
19+
android:layout_width="wrap_content"
20+
android:layout_height="match_parent"
21+
android:layout_alignBottom="@id/recyclerview"
22+
android:layout_alignParentEnd="true"
23+
android:layout_alignParentRight="true"
24+
android:layout_alignTop="@id/recyclerview"
25+
/>
26+
</RelativeLayout>
27+

app/src/main/res/values/styles.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33

4-
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
4+
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
5+
<!-- Customize your theme here. -->
56
<item name="colorPrimary">#0288D1</item>
67
<item name="colorPrimaryDark">#0277BD</item>
8+
<item name="colorAccent">#FF4081</item>
79
</style>
810

911
</resources>

library/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

library/build.gradle

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apply plugin: 'com.android.library'
2+
3+
android {
4+
compileSdkVersion 23
5+
buildToolsVersion "23.0.1"
6+
7+
defaultConfig {
8+
minSdkVersion 11
9+
targetSdkVersion 23
10+
versionCode 1
11+
versionName "1.0"
12+
}
13+
buildTypes {
14+
release {
15+
minifyEnabled false
16+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17+
}
18+
}
19+
}
20+
21+
dependencies {
22+
compile fileTree(dir: 'libs', include: ['*.jar'])
23+
compile 'com.android.support:appcompat-v7:23.0.1'
24+
compile 'com.android.support:recyclerview-v7:23.0.1'
25+
}

0 commit comments

Comments
 (0)