-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(0.9.6): 添加详情demo,调整数据绑定Holder manager
Signed-off-by: free46000 <[email protected]>
- Loading branch information
Showing
20 changed files
with
431 additions
and
26 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
17 changes: 17 additions & 0 deletions
17
demo/src/main/java/com/freelib/multiitem/demo/EmptyAndErrorActivity.java
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.freelib.multiitem.demo; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
|
||
import org.androidannotations.annotations.EActivity; | ||
|
||
@EActivity(R.layout.layout_recycler) | ||
public class EmptyAndErrorActivity extends AppCompatActivity { | ||
|
||
public static void startActivity(Context context) { | ||
// EmptyAndErrorActivity_. | ||
} | ||
|
||
} |
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
71 changes: 71 additions & 0 deletions
71
demo/src/main/java/com/freelib/multiitem/demo/UserInfoActivity.java
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.freelib.multiitem.demo; | ||
|
||
import android.content.Context; | ||
import android.databinding.ViewDataBinding; | ||
import android.icu.text.UnicodeSet; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.LinearLayoutManager; | ||
import android.support.v7.widget.RecyclerView; | ||
|
||
import com.freelib.multiitem.adapter.BaseItemAdapter; | ||
import com.freelib.multiitem.adapter.holder.DataBindViewHolderManager; | ||
import com.freelib.multiitem.demo.bean.ImageBean; | ||
import com.freelib.multiitem.demo.bean.ImageTextBean; | ||
import com.freelib.multiitem.demo.bean.ItemInfo; | ||
import com.freelib.multiitem.demo.bean.TextBean; | ||
import com.freelib.multiitem.demo.bean.UserBean; | ||
import com.freelib.multiitem.demo.viewholder.ImageAndTextManager; | ||
import com.freelib.multiitem.demo.viewholder.ImageViewManager; | ||
import com.freelib.multiitem.demo.viewholder.TextViewManager; | ||
|
||
import org.androidannotations.annotations.AfterViews; | ||
import org.androidannotations.annotations.EActivity; | ||
import org.androidannotations.annotations.ViewById; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@EActivity(R.layout.layout_recycler) | ||
public class UserInfoActivity extends AppCompatActivity { | ||
@ViewById(R.id.recyclerView) | ||
protected RecyclerView recyclerView; | ||
|
||
public static void startActivity(Context context) { | ||
UserInfoActivity_.intent(context).start(); | ||
} | ||
|
||
@AfterViews | ||
protected void initViews() { | ||
setTitle(R.string.user_info_title); | ||
|
||
UserBean userBean = getUserBean(); | ||
|
||
recyclerView.setLayoutManager(new LinearLayoutManager(this)); | ||
//初始化adapter | ||
BaseItemAdapter adapter = new BaseItemAdapter(); | ||
//为UserBean数据源注册数据绑定View Holder Manager管理类 | ||
adapter.register(ItemInfo.class, new DataBindViewHolderManager<>( | ||
R.layout.item_image_text_data_bind, BR.itemData)); | ||
recyclerView.setAdapter(adapter); | ||
|
||
List<ItemInfo> list = new ArrayList<>(5); | ||
list.add(new ItemInfo("名字", userBean.getName())); | ||
list.add(new ItemInfo("性别", userBean.getSex())); | ||
list.add(new ItemInfo("年龄", userBean.getAge())); | ||
list.add(new ItemInfo("城市", userBean.getAddr())); | ||
list.add(new ItemInfo("介绍", userBean.getInfo())); | ||
adapter.setDataItems(list); | ||
} | ||
|
||
|
||
private UserBean getUserBean() { | ||
UserBean userBean = new UserBean(); | ||
userBean.setName("张三"); | ||
userBean.setSex("男"); | ||
userBean.setInfo("简单介绍"); | ||
userBean.setAddr("中国北京"); | ||
userBean.setAge("26岁"); | ||
return userBean; | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
demo/src/main/java/com/freelib/multiitem/demo/bean/ItemInfo.java
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.freelib.multiitem.demo.bean; | ||
|
||
/** | ||
* Created by free46000 on 2017/4/22. | ||
*/ | ||
public class ItemInfo { | ||
private String name; | ||
private String value; | ||
|
||
public ItemInfo(String name, String value) { | ||
this.name = name; | ||
this.value = value; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
public void setValue(String value) { | ||
this.value = value; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
demo/src/main/java/com/freelib/multiitem/demo/bean/UserBean.java
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.freelib.multiitem.demo.bean; | ||
|
||
/** | ||
* Created by free46000 on 2017/4/22. | ||
*/ | ||
public class UserBean { | ||
private String name; | ||
private String sex; | ||
private String info; | ||
private String age; | ||
private String addr; | ||
|
||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getSex() { | ||
return sex; | ||
} | ||
|
||
public void setSex(String sex) { | ||
this.sex = sex; | ||
} | ||
|
||
public String getInfo() { | ||
return info; | ||
} | ||
|
||
public void setInfo(String info) { | ||
this.info = info; | ||
} | ||
|
||
public String getAge() { | ||
return age; | ||
} | ||
|
||
public void setAge(String age) { | ||
this.age = age; | ||
} | ||
|
||
public String getAddr() { | ||
return addr; | ||
} | ||
|
||
public void setAddr(String addr) { | ||
this.addr = addr; | ||
} | ||
} |
7 changes: 0 additions & 7 deletions
7
demo/src/main/java/com/freelib/multiitem/demo/input/ItemEdit.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
|
||
<data> | ||
|
||
<variable | ||
name="itemData" | ||
type="com.freelib.multiitem.demo.bean.ItemInfo"/> | ||
</data> | ||
|
||
<android.support.constraint.ConstraintLayout | ||
android:id="@+id/content_lay" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="10dp" | ||
> | ||
|
||
|
||
<TextView | ||
android:id="@+id/name_txt" | ||
app:layout_constraintLeft_toLeftOf="@id/content_lay" | ||
app:layout_constraintTop_toTopOf="@id/content_lay" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="@{itemData.name}" | ||
android:textColor="@android:color/black" | ||
android:textSize="@dimen/text_medium" | ||
tools:text="name" | ||
/> | ||
|
||
<TextView | ||
android:id="@+id/value_txt" | ||
app:layout_constraintLeft_toRightOf="@id/name_txt" | ||
app:layout_constraintRight_toRightOf="@id/content_lay" | ||
app:layout_constraintTop_toTopOf="@id/name_txt" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="@{itemData.value}" | ||
android:textColor="@android:color/black" | ||
android:textSize="@dimen/text_medium" | ||
tools:text="value" | ||
/> | ||
|
||
</android.support.constraint.ConstraintLayout> | ||
</layout> |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.constraint.ConstraintLayout | ||
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" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
> | ||
|
||
<TextView | ||
android:id="@+id/tip_txt" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
app:layout_constraintBottom_toTopOf="@+id/handler_btn" | ||
app:layout_constraintLeft_toLeftOf="parent" | ||
app:layout_constraintRight_toRightOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintVertical_chainStyle="packed" | ||
tools:text="xin xi" | ||
/> | ||
|
||
<Button | ||
android:id="@+id/handler_btn" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintLeft_toLeftOf="parent" | ||
app:layout_constraintRight_toRightOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/tip_txt" | ||
tools:text="xin xi" | ||
/> | ||
</android.support.constraint.ConstraintLayout> | ||
|
||
|
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
31 changes: 31 additions & 0 deletions
31
library/src/main/java/com/freelib/multiitem/adapter/holder/BaseItemState.java
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.freelib.multiitem.adapter.holder; | ||
|
||
import android.support.annotation.LayoutRes; | ||
import android.support.annotation.NonNull; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
/** | ||
* ViewHolder的管理类,默认采用{@link BaseViewHolder}的实现 | ||
* <p> | ||
* Created by free46000 on 2017/3/16. | ||
*/ | ||
public abstract class BaseItemState<T extends BaseItemState> extends ViewHolderManager<T, BaseViewHolder> { | ||
@Override | ||
public abstract void onBindViewHolder(BaseViewHolder holder, T t); | ||
|
||
@NonNull | ||
@Override | ||
public BaseViewHolder onCreateViewHolder(@NonNull ViewGroup parent) { | ||
BaseViewHolder viewHolder = new BaseViewHolder(getItemView(parent)); | ||
onCreateViewHolder(viewHolder); | ||
return viewHolder; | ||
} | ||
|
||
/** | ||
* {@link #onCreateViewHolder} | ||
*/ | ||
protected void onCreateViewHolder(@NonNull BaseViewHolder holder) { | ||
} | ||
|
||
} |
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
Oops, something went wrong.