在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):linisme/SlimAdapter开源软件地址(OpenSource Url):https://github.com/linisme/SlimAdapter开源编程语言(OpenSource Language):Java 95.4%开源软件介绍(OpenSource Introduction):PLEASE NOTE, THIS PROJECT IS NO LONGER BEING MAINTAINEDFirst At A Glance :)IntroA slim & clean & typeable Adapter without# VIEWHOLDER Features
Ex Features
Setupcompile 'net.idik:slimadapter:2.1.2' UsagesJavaStep 0: Create SlimAdapterSlimAdapter.create()
SlimAdapter.create(SlimAdapterEx.class) //For ex features if need Step 1: register data types & attachTo target RecyclerView
SlimAdapter.create()
.register(R.layout.item_user, new SlimInjector<User>() {
@Override
protected void onInject(User data, IViewInjector injector) {
...// inject data into views,step 2
}
})
.register(R.layout.item_interger, new SlimInjector<Integer>() {
@Override
protected void onInject(Integer data, IViewInjector injector) {
...// inject data into views,step 2
}
})
.register(R.layout.item_string, new SlimInjector<String>() {
@Override
protected void onInject(String data, IViewInjector injector) {
...// inject data into views,step 2
}
})
.registerDefault(R.layout.item_string, new SlimInjector() {
@Override
protected void onInject(Object data, IViewInjector injector) {
...// inject data into views,step 2
}
})
.attachTo(recyclerView);
}
Step 2: Inject data into views with fluent apisinjector.text(R.id.name, data.getName())
.text(R.id.age, String.valueOf(data.getAge()))
.textColor(R.id.age, Color.RED)
.textSize(R.id.age, 8)
.longClicked(R.id.name, new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
//do stuff...
return false;
}
})
.clicked(R.id.text, new View.OnClickListener() {
@Override
public void onClick(View v) {
//do stuff...
}
})
.with(R.id.name, new IViewInjector.Action<TextView>() {
@Override
public void action(TextView view) {
//do stuff...
}
})
...; Step 3: Use SlimAdapter as normal adapter List<Object> data = new ArrayList<>();
{
data.add(new SectionHeader("My Friends"));
data.add(new User("Jack", 21, R.drawable.icon1, "123456789XX"));
data.add(new User("Marry", 17, R.drawable.icon2, "123456789XX"));
data.add(new SectionHeader("My Images"));
data.add(new Image(R.drawable.cover1));
data.add(new Image(R.drawable.cover2));
data.add(new Image(R.drawable.cover3));
data.add(new Image(R.drawable.cover4));
data.add(new Image(R.drawable.cover5));
data.add(new Image(R.drawable.cover6));
data.add(new Image(R.drawable.cover7));
data.add(new Image(R.drawable.cover8));
data.add(new Image(R.drawable.cover9));
data.add(new Image(R.drawable.cover10));
data.add(new Image(R.drawable.cover11));
data.add(new SectionHeader("My Musics"));
data.add(new Music("Love story", R.drawable.icon3));
data.add(new Music("Nothing's gonna change my love for u", R.drawable.icon4));
data.add(new Music("Just one last dance", R.drawable.icon5));
}
slimAdapter.updateData(data);
About SlimAdapterExSlimAdapter aims to be "Slim", not "Super", so the SlimAdapter core lib is focus on wrapping the RecycleAdapter to provide a more friendly api. Anyway, Someone needs a more power Adpter, and this is the reason why SlimAdapterEx exsit. In a word, SlimAdapterEx is focus on providing some power feature in a slim way. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论