Skip to content

Commit 290b36d

Browse files
Readme of kotlin
Remove unneccesary code
1 parent 5110340 commit 290b36d

3 files changed

Lines changed: 22 additions & 6 deletions

File tree

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,29 @@ Single item per line
3434
```java
3535
recyclerView.setLayoutManager(new FlowLayoutManager().singleItemPerLine());
3636
```
37+
38+
```kotlin
39+
recyclerView.setLayoutManager(FlowLayoutManager().singleItemPerLine())
40+
```
41+
3742
or x items per line
3843
```java
3944
recyclerView.setLayoutManager(new FlowLayoutManager().maxItemsPerLine(x));
4045
```
4146

47+
```kotlin
48+
recyclerView.setLayoutManager(FlowLayoutManager().maxItemsPerLine(x))
49+
```
50+
4251
to remove Item per line limitation
4352
```java
4453
((FlowLayoutManager)recyclerView.getLayoutManager()).removeItemPerLineLimit();
4554
```
4655

56+
```kotlin
57+
(recyclerView.getLayoutManager() as FlowLayoutManager).removeItemPerLineLimit()
58+
```
59+
4760
Auto measurement
4861
---
4962
```java
@@ -52,11 +65,20 @@ flowLayoutManager.setAutoMeasureEnabled(true);
5265
recyclerView.setLayoutManager(flowLayoutManager);
5366
```
5467

68+
```kotlin
69+
flowLayoutManager = FlowLayoutManager()
70+
flowLayoutManager.setAutoMeasureEnabled(true)
71+
recyclerView.setLayoutManager(flowLayoutManager)
72+
```
73+
5574
Alignment
5675
---
5776
```java
5877
recyclerView.setLayoutManager(new FlowLayoutManager().setAlignment(Alignment.LEFT));
5978
```
79+
```kotlin
80+
recyclerView.setLayoutManager(FlowLayoutManager().setAlignment(Alignment.LEFT))
81+
```
6082
Alignment could be LEFT, CENTER or RIGHT.
6183

6284
## Credits

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22

33
import java.util.ArrayList;
44
import java.util.List;
5-
import java.util.Random;
65

76
/**
87
* Utility for demo item listWords
98
*/
109
public class DemoUtil {
11-
private static final Random random = new Random();
12-
private static final String STRING_BASE = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
1310

1411
public static List<String> listWords() {
1512
ArrayList<String> result = new ArrayList<>();

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
3535

3636
recyclerView.setLayoutManager(flowLayoutManager);
3737
recyclerView.getAdapter().notifyDataSetChanged();
38-
recyclerView.addItemDecoration(itemDecoration);
3938

4039
return true;
4140
case R.id.navigation_center:
@@ -44,7 +43,6 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
4443

4544
recyclerView.setLayoutManager(flowLayoutManager);
4645
recyclerView.getAdapter().notifyDataSetChanged();
47-
recyclerView.addItemDecoration(itemDecoration);
4846

4947
return true;
5048
case R.id.navigation_rigth:
@@ -53,7 +51,6 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
5351

5452
recyclerView.setLayoutManager(flowLayoutManager);
5553
recyclerView.getAdapter().notifyDataSetChanged();
56-
recyclerView.addItemDecoration(itemDecoration);
5754

5855
return true;
5956
}

0 commit comments

Comments
 (0)