Skip to content

Commit 5489340

Browse files
AndroidDeveloperLBAndroidDeveloperLB
AndroidDeveloperLB
authored and
AndroidDeveloperLB
committed
updated sdks
1 parent 4e2e98b commit 5489340

20 files changed

+299
-318
lines changed

LollipopContactsRecyclerViewFastScroller.iml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<module external.linked.project.id="LollipopContactsRecyclerViewFastScroller" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
2+
<module external.linked.project.id="LollipopContactsRecyclerViewFastScroller" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
33
<component name="FacetManager">
44
<facet type="java-gradle" name="Java-Gradle">
55
<configuration>

app/app.iml

+78-53
Large diffs are not rendered by default.

app/build.gradle

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 23
5-
buildToolsVersion "23.0.2"
4+
compileSdkVersion 29
65

76
defaultConfig {
87
applicationId "com.lb.lollipopcontactsrecyclerviewfastscroller"
9-
minSdkVersion 11
10-
targetSdkVersion 23
8+
minSdkVersion 14
9+
targetSdkVersion 29
1110
versionCode 1
1211
versionName "1.0"
1312
}
@@ -20,9 +19,10 @@ android {
2019
}
2120

2221
dependencies {
23-
compile fileTree(dir: 'libs', include: ['*.jar'])
24-
compile 'com.android.support:recyclerview-v7:23.1.1'
25-
compile 'com.android.support:appcompat-v7:23.1.1'
26-
compile 'com.android.support:design:23.1.1'
27-
compile project(':library')
22+
api fileTree(dir: 'libs', include: ['*.jar'])
23+
// api "androidx.viewpager2:viewpager2:1.0.0-beta04"
24+
api 'androidx.recyclerview:recyclerview:1.0.0'
25+
api 'androidx.appcompat:appcompat:1.1.0'
26+
api 'com.google.android.material:material:1.0.0'
27+
api project(':library')
2828
}

app/src/main/AndroidManifest.xml

+6-12
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.lb.lollipopcontactsrecyclerviewfastscroller">
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.lb.lollipopcontactsrecyclerviewfastscroller">
32

43
<application
5-
android:allowBackup="true"
6-
android:label="@string/app_name"
7-
android:icon="@mipmap/ic_launcher"
8-
android:theme="@style/AppTheme">
4+
android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"
5+
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
96
<activity
10-
android:name="com.lb.recyclerview_fast_scroller.MainActivity"
11-
android:icon="@mipmap/ic_launcher"
12-
android:label="@string/app_name">
7+
android:name="com.lb.recyclerview_fast_scroller.MainActivity" android:icon="@mipmap/ic_launcher" android:label="@string/app_name">
138

14-
<!-- android:uiOptions="splitActionBarWhenNarrow" -->
159
<intent-filter>
16-
<action android:name="android.intent.action.MAIN"/>
10+
<action android:name="android.intent.action.MAIN" />
1711

18-
<category android:name="android.intent.category.LAUNCHER"/>
12+
<category android:name="android.intent.category.LAUNCHER" />
1913
</intent-filter>
2014
</activity>
2115
</application>

app/src/main/java/com/lb/recyclerview_fast_scroller/LargeAdapter.java

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.lb.recyclerview_fast_scroller;
22

3-
import android.support.v7.widget.RecyclerView;
43
import android.view.LayoutInflater;
54
import android.view.View;
65
import android.view.ViewGroup;
@@ -11,14 +10,20 @@
1110
import java.util.ArrayList;
1211
import java.util.List;
1312

13+
import androidx.recyclerview.widget.RecyclerView;
14+
1415
public final class LargeAdapter extends RecyclerView.Adapter<LargeAdapter.ViewHolder> implements BubbleTextGetter {
15-
private final List<String> items;
16+
private List<String> items;
1617

1718
public LargeAdapter(int numberOfItems) {
19+
setItemsCount(numberOfItems);
20+
}
21+
22+
public void setItemsCount(int numberOfItems) {
1823
List<String> items = new ArrayList<>();
1924
java.util.Random r = new java.util.Random();
2025
for (int i = 0; i < numberOfItems; i++)
21-
items.add(((char) ('A' + r.nextInt('Z' - 'A'))) + " " + Integer.toString(i));
26+
items.add(((char) ('A' + r.nextInt('Z' - 'A'))) + " " + i);
2227
java.util.Collections.sort(items);
2328
this.items = items;
2429
}
@@ -50,7 +55,7 @@ public static final class ViewHolder extends RecyclerView.ViewHolder {
5055

5156
private ViewHolder(View itemView) {
5257
super(itemView);
53-
this.textView = (TextView) itemView.findViewById(android.R.id.text1);
58+
this.textView = itemView.findViewById(android.R.id.text1);
5459
}
5560

5661
public void setText(CharSequence text) {

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

+32-42
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,39 @@
33
import android.content.Intent;
44
import android.net.Uri;
55
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;
186
import android.view.LayoutInflater;
197
import android.view.Menu;
208
import android.view.MenuItem;
219
import android.view.View;
2210
import android.view.ViewGroup;
23-
import android.widget.Toast;
2411

12+
import com.google.android.material.tabs.TabLayout;
2513
import com.lb.lollipopcontactsrecyclerviewfastscroller.R;
2614

15+
import androidx.annotation.Nullable;
16+
import androidx.appcompat.app.AppCompatActivity;
17+
import androidx.appcompat.widget.Toolbar;
18+
import androidx.fragment.app.Fragment;
19+
import androidx.fragment.app.FragmentManager;
20+
import androidx.fragment.app.FragmentStatePagerAdapter;
21+
import androidx.recyclerview.widget.LinearLayoutManager;
22+
import androidx.recyclerview.widget.RecyclerView;
23+
import androidx.recyclerview.widget.RecyclerView.State;
24+
import androidx.viewpager.widget.ViewPager;
25+
2726
public class MainActivity extends AppCompatActivity {
2827
@Override
2928
protected void onCreate(Bundle savedInstanceState) {
3029
super.onCreate(savedInstanceState);
3130
setContentView(R.layout.activity_main);
32-
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
31+
Toolbar toolbar = findViewById(R.id.toolbar);
3332
setSupportActionBar(toolbar);
3433
//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-
});
4734

4835
DesignDemoPagerAdapter adapter = new DesignDemoPagerAdapter(getSupportFragmentManager());
49-
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
36+
ViewPager viewPager = findViewById(R.id.viewpager);
5037
viewPager.setAdapter(adapter);
51-
TabLayout tabLayout = (TabLayout) findViewById(R.id.tablayout);
38+
TabLayout tabLayout = findViewById(R.id.tablayout);
5239
tabLayout.setupWithViewPager(viewPager);
5340
}
5441

@@ -58,7 +45,6 @@ public boolean onCreateOptionsMenu(final Menu menu) {
5845
return super.onCreateOptionsMenu(menu);
5946
}
6047

61-
@SuppressWarnings("deprecation")
6248
@Override
6349
public boolean onOptionsItemSelected(final MenuItem item) {
6450
String url = null;
@@ -92,7 +78,9 @@ public DesignDemoPagerAdapter(FragmentManager fm) {
9278
@Override
9379
public Fragment getItem(int position) {
9480
final RecyclerViewFragment recyclerViewFragment = new RecyclerViewFragment();
95-
recyclerViewFragment.numberOfItems = getFragmentItemsCount(position);
81+
Bundle args = new Bundle();
82+
args.putInt(RecyclerViewFragment.ITEMS_COUNT, getFragmentItemsCount(position));
83+
recyclerViewFragment.setArguments(args);
9684
return recyclerViewFragment;
9785
}
9886

@@ -113,29 +101,24 @@ public CharSequence getPageTitle(int position) {
113101

114102

115103
public static class RecyclerViewFragment extends Fragment {
104+
public static final String ITEMS_COUNT = "ITEMS_COUNT";
116105
public int numberOfItems;
117106

118107
@Nullable
119108
@Override
120109
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
110+
numberOfItems = getArguments().getInt(ITEMS_COUNT);
121111
View rootView = inflater.inflate(R.layout.fragment_recycler_view, container, false);
122-
RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerview);
112+
RecyclerView recyclerView = rootView.findViewById(R.id.recyclerview);
123113
final LargeAdapter adapter = new LargeAdapter(numberOfItems);
124114
recyclerView.setAdapter(adapter);
125-
final RecyclerViewFastScroller fastScroller = (RecyclerViewFastScroller) rootView.findViewById(R.id.fastscroller);
115+
final RecyclerViewFastScroller fastScroller = rootView.findViewById(R.id.fastscroller);
126116
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false) {
127117
@Override
128-
public void onLayoutChildren(final RecyclerView.Recycler recycler, final RecyclerView.State state) {
129-
super.onLayoutChildren(recycler, state);
130-
//TODO if the items are filtered, considered hiding the fast scroller here
118+
public void onLayoutCompleted(final State state) {
119+
super.onLayoutCompleted(state);
131120
final int firstVisibleItemPosition = findFirstVisibleItemPosition();
132-
if (firstVisibleItemPosition != 0) {
133-
// this avoids trying to handle un-needed calls
134-
if (firstVisibleItemPosition == -1)
135-
//not initialized, or no items shown, so hide fast-scroller
136-
fastScroller.setVisibility(View.GONE);
137-
return;
138-
}
121+
//Log.d("AppLog", "onLayoutCompleted firstVisibleItemPosition:"+firstVisibleItemPosition);
139122
final int lastVisibleItemPosition = findLastVisibleItemPosition();
140123
int itemsShown = lastVisibleItemPosition - firstVisibleItemPosition + 1;
141124
//if all items are shown, hide the fast-scroller
@@ -144,6 +127,13 @@ public void onLayoutChildren(final RecyclerView.Recycler recycler, final Recycle
144127
});
145128
fastScroller.setRecyclerView(recyclerView);
146129
fastScroller.setViewsToUse(R.layout.recycler_view_fast_scroller__fast_scroller, R.id.fastscroller_bubble, R.id.fastscroller_handle);
130+
//new Handler().postDelayed(new Runnable() {
131+
// @Override
132+
// public void run() {
133+
// adapter.setItemsCount(new Random().nextInt(20));
134+
// adapter.notifyDataSetChanged();
135+
// }
136+
//}, 2000L);
147137
return rootView;
148138
}
149139
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
3+
4+
<corners
5+
android:bottomLeftRadius="0px" android:bottomRightRadius="44dp" android:topLeftRadius="44dp" android:topRightRadius="44dp" />
6+
7+
<solid android:color="#FF0288D1" />
8+
<size
9+
android:width="88dp" android:height="88dp" />
10+
</shape>
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<shape xmlns:android="http://schemas.android.com/apk/res/android"
3-
android:shape="rectangle">
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
43

54
<corners
6-
android:topLeftRadius="44dp"
7-
android:topRightRadius="44dp"
8-
android:bottomLeftRadius="44dp"
9-
android:bottomRightRadius="0px"/>
5+
android:bottomLeftRadius="44dp" android:bottomRightRadius="0px" android:topLeftRadius="44dp" android:topRightRadius="44dp" />
106

11-
<solid android:color="#FF0288D1"/>
7+
<solid android:color="#FF0288D1" />
128
<size
13-
android:height="88dp"
14-
android:width="88dp"/>
15-
</shape>
9+
android:width="88dp" android:height="88dp" />
10+
</shape>

app/src/main/res/drawable/recycler_view_fast_scroller__handle.xml

+9-15
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<selector xmlns:android="http://schemas.android.com/apk/res/android">
33
<item android:state_selected="true">
4-
<shape xmlns:android="http://schemas.android.com/apk/res/android"
5-
android:shape="rectangle">
4+
<shape android:shape="rectangle">
65

7-
<corners android:radius="2dp"/>
6+
<corners android:radius="2dp" />
87

9-
<solid android:color="#FF0288D1"/>
8+
<solid android:color="#FF0288D1" />
109

11-
<size
12-
android:height="32dp"
13-
android:width="4dp"/>
10+
<size android:width="4dp" android:height="32dp" />
1411
</shape>
1512
</item>
16-
<item >
17-
<shape xmlns:android="http://schemas.android.com/apk/res/android"
18-
android:shape="rectangle">
13+
<item>
14+
<shape android:shape="rectangle">
1915

20-
<corners android:radius="2dp"/>
16+
<corners android:radius="2dp" />
2117

22-
<solid android:color="#FF737373"/>
18+
<solid android:color="#FF737373" />
2319

24-
<size
25-
android:height="32dp"
26-
android:width="4dp"/>
20+
<size android:width="4dp" android:height="32dp" />
2721
</shape>
2822
</item>
2923

+15-38
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,22 @@
1-
<android.support.design.widget.CoordinatorLayout
2-
android:id="@+id/coordinator"
3-
xmlns:android="http://schemas.android.com/apk/res/android"
4-
xmlns:app="http://schemas.android.com/apk/res-auto"
5-
android:layout_width="match_parent"
6-
android:layout_height="match_parent">
1+
<androidx.coordinatorlayout.widget.CoordinatorLayout
2+
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"
3+
android:id="@+id/coordinator" android:layout_width="match_parent" android:layout_height="match_parent">
74

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">
5+
<com.google.android.material.appbar.AppBarLayout
6+
android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/ThemeOverlay.AppCompat.Dark">
127

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"/>
8+
<androidx.appcompat.widget.Toolbar
9+
android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary"
10+
app:layout_scrollFlags="scroll|enterAlways" />
1911

20-
<android.support.design.widget.TabLayout
21-
android:id="@+id/tablayout" app:tabMode="scrollable"
22-
android:layout_width="match_parent"
23-
android:layout_height="wrap_content" app:tabGravity="center"
24-
android:background="?attr/colorPrimary"
25-
/>
12+
<com.google.android.material.tabs.TabLayout
13+
android:id="@+id/tablayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/colorPrimary" android:layoutDirection="ltr"
14+
app:tabGravity="center" app:tabMode="scrollable" tools:targetApi="jelly_bean_mr1" />
2615

27-
</android.support.design.widget.AppBarLayout>
16+
</com.google.android.material.appbar.AppBarLayout>
2817

29-
<android.support.v4.view.ViewPager
30-
android:id="@+id/viewpager"
31-
android:layout_width="match_parent"
32-
android:layout_height="match_parent"
33-
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
18+
<androidx.viewpager.widget.ViewPager
19+
android:id="@+id/viewpager" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" />
3420

35-
<android.support.design.widget.FloatingActionButton
36-
android:id="@+id/fab"
37-
android:layout_width="wrap_content"
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"
43-
/>
4421

45-
</android.support.design.widget.CoordinatorLayout>
22+
</androidx.coordinatorlayout.widget.CoordinatorLayout>

0 commit comments

Comments
 (0)