Skip to content

Commit 8c36ad4

Browse files
Bugfix & update canScrollVertically()
1 parent bc5a9ad commit 8c36ad4

File tree

17 files changed

+227
-311
lines changed

17 files changed

+227
-311
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Step 1. Add it in your **root** build.gradle at the end of repositories:
2525
Step 2. Add the dependency
2626

2727
dependencies {
28-
implementation 'com.github.simonebortolin:FlowLayoutManager:1.5'
28+
implementation 'com.github.simonebortolin:FlowLayoutManager:1.7'
2929
}
3030

3131
Item per line limitation

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ android {
77
applicationId "com.xiaofeng.androidlibs"
88
minSdkVersion androidMinSdkVersion
99
targetSdkVersion androidTargetSdkVersion
10-
versionCode 15
11-
versionName "1.5"
10+
versionCode 17
11+
versionName "1.7"
1212
vectorDrawables.useSupportLibrary = true
1313
}
1414
buildTypes {

app/src/main/java/com/xiaofeng/androidlibs/DemoAdapter.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.xiaofeng.androidlibs;
22

3+
import android.support.annotation.NonNull;
34
import android.support.v7.widget.RecyclerView;
45
import android.view.LayoutInflater;
56
import android.view.View;
@@ -13,9 +14,8 @@
1314
*/
1415
public class DemoAdapter extends RecyclerView.Adapter<DemoViewHolder> {
1516
private List<String> items;
16-
private boolean showMeta = false;
1717

18-
public DemoAdapter() {
18+
private DemoAdapter() {
1919
this.items = new LinkedList<>();
2020
}
2121

@@ -24,13 +24,14 @@ public DemoAdapter(List<String> items) {
2424
this.items.addAll(items);
2525
}
2626

27+
@NonNull
2728
@Override
28-
public DemoViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
29-
return new DemoViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.main_item, parent, false)).setShowMeta(showMeta);
29+
public DemoViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
30+
return new DemoViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.main_item, parent, false));
3031
}
3132

3233
@Override
33-
public void onBindViewHolder(final DemoViewHolder holder, final int position) {
34+
public void onBindViewHolder(@NonNull final DemoViewHolder holder, final int position) {
3435
holder.setTagText(items.get(position));
3536
holder.tagSize.setClickable(false);
3637
holder.tagText.setClickable(false);

app/src/main/java/com/xiaofeng/androidlibs/DemoViewHolder.java

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,18 @@
55
import android.widget.TextView;
66

77
public class DemoViewHolder extends RecyclerView.ViewHolder {
8-
boolean showMeta = false;
98
TextView tagText, tagSize;
109
public DemoViewHolder(View itemView) {
1110
super(itemView);
12-
tagText = (TextView)itemView.findViewById(R.id.tag_text);
13-
tagSize = (TextView)itemView.findViewById(R.id.tag_count);
11+
tagText = itemView.findViewById(R.id.tag_text);
12+
tagSize = itemView.findViewById(R.id.tag_count);
1413
}
1514

1615
public void setTagText(String tag) {
1716
tagText.setText(tag);
18-
if (showMeta) {
19-
String[] lines = tag.split("\n");
20-
StringBuilder sb = new StringBuilder();
21-
sb.append("(").append(lines.length).append(":");
22-
int length = 0;
23-
boolean first = true;
24-
for (String line : lines) {
25-
if (first) {
26-
first = false;
27-
} else {
28-
sb.append(",");
29-
}
30-
sb.append(line.length());
31-
length += line.length();
32-
}
33-
sb.append(":").append(length).append(")");
34-
tagSize.setText(sb.toString());
35-
}
36-
}
3717

38-
public DemoViewHolder setShowMeta(boolean showMeta) {
39-
this.showMeta = showMeta;
40-
if (showMeta) {
41-
tagSize.setVisibility(View.VISIBLE);
42-
} else {
43-
tagSize.setVisibility(View.GONE);
44-
}
45-
return this;
18+
4619
}
20+
21+
4722
}

app/src/main/java/com/xiaofeng/androidlibs/MainActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
3232
switch (item.getItemId()) {
3333
case R.id.navigation_left:
3434
flowLayoutManager = new FlowLayoutManager().setAlignment(Alignment.LEFT);
35+
flowLayoutManager.setAutoMeasureEnabled(true);
3536

3637
recyclerView.setLayoutManager(flowLayoutManager);
3738
recyclerView.getAdapter().notifyDataSetChanged();

app/src/main/java/com/xiaofeng/androidlibs/util/ArrayUtil.java

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

app/src/main/java/com/xiaofeng/androidlibs/util/CollectionUtil.java

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

app/src/main/res/layout/main_activity.xml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@
77
android:layout_height="match_parent"
88
tools:context="com.xiaofeng.androidlibs.MainActivity">
99

10-
<android.support.v7.widget.RecyclerView
11-
android:id="@+id/list"
12-
android:layout_width="match_parent"
13-
android:layout_height="match_parent"
14-
android:clipToPadding="false"
15-
android:fadeScrollbars="false"
16-
android:padding="48dp"
17-
android:scrollbarStyle="outsideOverlay"
18-
android:scrollbars="vertical" />
10+
<android.support.v7.widget.RecyclerView
11+
android:id="@+id/list"
12+
android:layout_width="match_parent"
13+
android:layout_height="wrap_content"
14+
app:layout_constraintBottom_toTopOf="@id/navigation"
15+
app:layout_constraintLeft_toLeftOf="parent"
16+
app:layout_constraintRight_toRightOf="parent"
17+
app:layout_constraintTop_toTopOf="parent"
18+
android:clipToPadding="false"
19+
android:fadeScrollbars="false"
20+
android:padding="48dp"
21+
android:scrollbarStyle="outsideOverlay"
22+
android:scrollbars="vertical" />
1923

2024
<android.support.design.widget.BottomNavigationView
2125
android:id="@+id/navigation"

app/src/main/res/layout/main_item.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
34
android:layout_width="wrap_content"
45
android:layout_height="wrap_content"
56
android:background="@drawable/tagbg"
@@ -13,13 +14,14 @@
1314
android:layout_width="wrap_content"
1415
android:layout_height="wrap_content"
1516
android:layout_marginRight="4dp"
16-
android:text="0000"
17-
android:textColor="@color/colorPrimary" />
17+
tools:text="0000"
18+
android:textColor="@color/colorPrimary"
19+
android:layout_marginEnd="4dp" />
1820
<TextView
1921
android:id="@+id/tag_count"
2022
android:layout_width="wrap_content"
2123
android:layout_height="wrap_content"
22-
android:text="(4)"
24+
tools:text="(4)"
2325
android:textColor="@color/colorPrimary" />
2426

2527
</LinearLayout>

app/src/main/res/menu/navigation.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@
44
<item
55
android:id="@+id/navigation_left"
66
android:icon="@drawable/ic_format_align_left_black_24dp"
7-
android:title="Left" />
7+
android:title="@string/left" />
88

99
<item
1010
android:id="@+id/navigation_center"
1111
android:icon="@drawable/ic_format_align_center_black_24dp"
12-
android:title="Center" />
12+
android:title="@string/center" />
1313

1414
<item
1515
android:id="@+id/navigation_rigth"
1616
android:icon="@drawable/ic_format_align_right_black_24dp"
17-
android:title="Rigth" />
18-
17+
android:title="@string/rigth" />
1918
</menu>

0 commit comments

Comments
 (0)