-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
82 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 56 additions & 63 deletions
119
app/src/main/java/com/chad/baserecyclerviewadapterhelper/data/DataServer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,70 @@ | ||
package com.chad.baserecyclerviewadapterhelper.data; | ||
package com.chad.baserecyclerviewadapterhelper.data | ||
|
||
|
||
import com.chad.baserecyclerviewadapterhelper.entity.DiffEntity; | ||
import com.chad.baserecyclerviewadapterhelper.entity.Status; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import com.chad.baserecyclerviewadapterhelper.entity.DiffEntity | ||
import com.chad.baserecyclerviewadapterhelper.entity.Status | ||
|
||
/** | ||
* https://github.com/CymChad/BaseRecyclerViewAdapterHelper | ||
*/ | ||
public class DataServer { | ||
|
||
public static final String HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK = "https://avatars1.githubusercontent.com/u/7698209?v=3&s=460"; | ||
public static final String CYM_CHAD = "CymChad"; | ||
public static final String CHAY_CHAN = "ChayChan"; | ||
|
||
private DataServer() { | ||
} | ||
|
||
public static List<Status> getSampleData(int lenth) { | ||
List<Status> list = new ArrayList<>(); | ||
for (int i = 0; i < lenth; i++) { | ||
Status status = new Status(); | ||
status.setUserName("Chad" + i); | ||
status.setCreatedAt("04/05/" + i); | ||
status.setRetweet(i % 2 == 0); | ||
status.setUserAvatar("https://avatars1.githubusercontent.com/u/7698209?v=3&s=460"); | ||
status.setText("BaseRecyclerViewAdpaterHelper https://www.recyclerview.org"); | ||
list.add(status); | ||
object DataServer { | ||
const val HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK = | ||
"https://avatars1.githubusercontent.com/u/7698209?v=3&s=460" | ||
const val CYM_CHAD = "CymChad" | ||
const val CHAY_CHAN = "ChayChan" | ||
fun getSampleData(lenth: Int): List<Status> { | ||
val list: MutableList<Status> = ArrayList() | ||
for (i in 0 until lenth) { | ||
val status = Status() | ||
status.userName = "Chad$i" | ||
status.createdAt = "04/05/$i" | ||
status.isRetweet = i % 2 == 0 | ||
status.userAvatar = "https://avatars1.githubusercontent.com/u/7698209?v=3&s=460" | ||
status.text = "BaseRecyclerViewAdpaterHelper https://www.recyclerview.org" | ||
list.add(status) | ||
} | ||
return list; | ||
return list | ||
} | ||
|
||
public static List<Status> addData(List list, int dataSize) { | ||
for (int i = 0; i < dataSize; i++) { | ||
Status status = new Status(); | ||
status.setUserName("Chad" + i); | ||
status.setCreatedAt("04/05/" + i); | ||
status.setRetweet(i % 2 == 0); | ||
status.setUserAvatar("https://avatars1.githubusercontent.com/u/7698209?v=3&s=460"); | ||
status.setText("Powerful and flexible RecyclerAdapter https://github.com/CymChad/BaseRecyclerViewAdapterHelper"); | ||
list.add(status); | ||
fun addData(list: MutableList<Status>, dataSize: Int): List<Status> { | ||
for (i in 0 until dataSize) { | ||
val status = Status() | ||
status.userName = "Chad$i" | ||
status.createdAt = "04/05/$i" | ||
status.isRetweet = i % 2 == 0 | ||
status.userAvatar = "https://avatars1.githubusercontent.com/u/7698209?v=3&s=460" | ||
status.text = | ||
"Powerful and flexible RecyclerAdapter https://github.com/CymChad/BaseRecyclerViewAdapterHelper" | ||
list.add(status) | ||
} | ||
|
||
return list; | ||
return list | ||
} | ||
|
||
|
||
|
||
public static List<String> getStrData() { | ||
List<String> list = new ArrayList<>(); | ||
for (int i = 0; i < 20; i++) { | ||
String str = HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK; | ||
if (i % 2 == 0) { | ||
str = CYM_CHAD; | ||
val strData: List<String> | ||
get() { | ||
val list: MutableList<String> = ArrayList() | ||
for (i in 0..19) { | ||
var str = HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK | ||
if (i % 2 == 0) { | ||
str = CYM_CHAD | ||
} | ||
list.add(str) | ||
} | ||
list.add(str); | ||
return list | ||
} | ||
return list; | ||
} | ||
|
||
|
||
public static List<DiffEntity> getDiffUtilDemoEntities() { | ||
List<DiffEntity> list = new ArrayList<>(); | ||
for (int i = 0; i < 10; i++){ | ||
list.add(new DiffEntity( | ||
i, | ||
"Item " + i, | ||
"This item " + i + " content", | ||
"06-12") | ||
); | ||
@JvmStatic | ||
val diffUtilDemoEntities: List<DiffEntity> | ||
get() { | ||
val list: MutableList<DiffEntity> = ArrayList() | ||
for (i in 0..9) { | ||
list.add( | ||
DiffEntity( | ||
i, | ||
"Item $i", | ||
"This item $i content", | ||
"06-12" | ||
) | ||
) | ||
} | ||
return list | ||
} | ||
return list; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters