-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from aizuzi/dev
添加processor
- Loading branch information
Showing
34 changed files
with
1,058 additions
and
263 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
41 changes: 28 additions & 13 deletions
41
app/src/main/java/com/aizuzi/adapter/demo/MainActivity.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 |
---|---|---|
@@ -1,41 +1,56 @@ | ||
package com.aizuzi.adapter.demo; | ||
|
||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.LinearLayoutManager; | ||
import android.support.v7.widget.RecyclerView; | ||
import butterknife.BindView; | ||
import butterknife.ButterKnife; | ||
import com.aizuzi.adapter.demo.viewholder.ItemViewHolder_; | ||
import com.aizuzi.adapter.demo.viewholder.TopViewHolder; | ||
import com.zuzi.adapter.FastAdapter; | ||
import com.aizuzi.adapter.demo.viewholder.EmptyHolder; | ||
import com.aizuzi.adapter.demo.viewholder.ImageViewHolder; | ||
import com.aizuzi.adapter.demo.viewholder.TextViewHolder; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
|
||
private RecyclerView mRecyclerView; | ||
private static final String[] images = new String[] { | ||
"https://ww1.sinaimg.cn/large/0065oQSqly1ftf1snjrjuj30se10r1kx.jpg", | ||
"https://ww1.sinaimg.cn/large/0065oQSqly1ftdtot8zd3j30ju0pt137.jpg", | ||
"http://ww1.sinaimg.cn/large/0073sXn7ly1ft82s05kpaj30j50pjq9v.jpg", | ||
"https://ww1.sinaimg.cn/large/0065oQSqly1ft5q7ys128j30sg10gnk5.jpg", | ||
"http://ww1.sinaimg.cn/large/0065oQSqly1fszxi9lmmzj30f00jdadv.jpg", | ||
"http://ww1.sinaimg.cn/large/0065oQSqly1fsysqszneoj30hi0pvqb7.jpg", | ||
"http://ww1.sinaimg.cn/large/0065oQSqly1fswhaqvnobj30sg14hka0.jpg", | ||
"http://ww1.sinaimg.cn/large/0065oQSqly1fsvb1xduvaj30u013175p.jpg", | ||
"http://ww1.sinaimg.cn/large/0065oQSqly1fsq9iq8ttrj30k80q9wi4.jpg", | ||
"http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg" | ||
}; | ||
|
||
@BindView(R.id.recycler_view) | ||
RecyclerView mRecyclerView; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
ButterKnife.bind(this); | ||
|
||
mRecyclerView = findViewById(R.id.recycler_view); | ||
mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); | ||
mRecyclerView.addItemDecoration(new ColorItemDecoration()); | ||
|
||
setAdapter(); | ||
} | ||
|
||
private void setAdapter(){ | ||
private void setAdapter() { | ||
FastAdapter fastAdapter = new FastAdapter(this); | ||
fastAdapter.addItem(new TopViewHolder()); | ||
|
||
for (int i = 0; i < 100; i++) { | ||
fastAdapter.addItem(TextViewHolder.class,"Text ViewHolder:"+i); | ||
fastAdapter.addItem(ImageViewHolder.class,"your image path"); | ||
fastAdapter.addItem(EmptyHolder.class); | ||
for (int i = 0; i < images.length * 10; i++) { | ||
fastAdapter.addItem(new ItemViewHolder_() | ||
.setTitle("ViewHolder:" + i) | ||
.setIcon(R.mipmap.ic_launcher) | ||
.setImage(images[i % images.length])); | ||
} | ||
|
||
mRecyclerView.setAdapter(fastAdapter); | ||
} | ||
|
||
|
||
} |
30 changes: 30 additions & 0 deletions
30
app/src/main/java/com/aizuzi/adapter/demo/viewholder/AppBaseHolder.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.aizuzi.adapter.demo.viewholder; | ||
|
||
import android.view.View; | ||
import android.widget.ImageView; | ||
import butterknife.ButterKnife; | ||
import com.bumptech.glide.Glide; | ||
import com.zuzi.adapter.FastBaseHolder; | ||
|
||
/** | ||
* @author liyi | ||
* create at 2018/4/28 | ||
**/ | ||
public abstract class AppBaseHolder extends FastBaseHolder { | ||
@Override public void bind(View itemView, int position) { | ||
super.bind(itemView, position); | ||
ButterKnife.bind(this, itemView); | ||
} | ||
|
||
@Override public boolean handlerViewValue(View view, Object obj) { | ||
|
||
if (view instanceof ImageView && obj != null) { | ||
if (obj instanceof String) { | ||
Glide.with(itemView.getContext()) | ||
.load("" + obj) | ||
.into((ImageView) view); | ||
} | ||
} | ||
return super.handlerViewValue(view, obj); | ||
} | ||
} |
21 changes: 0 additions & 21 deletions
21
app/src/main/java/com/aizuzi/adapter/demo/viewholder/BaseViewHolder.java
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
app/src/main/java/com/aizuzi/adapter/demo/viewholder/EmptyHolder.java
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
app/src/main/java/com/aizuzi/adapter/demo/viewholder/ImageViewHolder.java
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
app/src/main/java/com/aizuzi/adapter/demo/viewholder/ItemViewHolder.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,22 @@ | ||
package com.aizuzi.adapter.demo.viewholder; | ||
|
||
import com.aizuzi.adapter.demo.R; | ||
import com.zuzi.adapter.annotation.FastAttribute; | ||
import com.zuzi.adapter.annotation.RecyclerItemLayoutId; | ||
|
||
/** | ||
* @author liyi | ||
* create at 2018/4/26 | ||
**/ | ||
@RecyclerItemLayoutId(R.layout.item_text) | ||
public class ItemViewHolder extends AppBaseHolder { | ||
|
||
@FastAttribute(bindViewId = R.id.title_tv) | ||
String title; | ||
|
||
@FastAttribute(bindViewId = R.id.icon_view) | ||
int icon; | ||
|
||
@FastAttribute(bindViewId = R.id.image_view) | ||
String image; | ||
} |
31 changes: 0 additions & 31 deletions
31
app/src/main/java/com/aizuzi/adapter/demo/viewholder/TextViewHolder.java
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
app/src/main/java/com/aizuzi/adapter/demo/viewholder/TopViewHolder.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,25 @@ | ||
package com.aizuzi.adapter.demo.viewholder; | ||
|
||
import android.widget.ImageView; | ||
import android.widget.Toast; | ||
import butterknife.BindView; | ||
import butterknife.OnClick; | ||
import com.aizuzi.adapter.demo.R; | ||
import com.zuzi.adapter.annotation.FastAttribute; | ||
import com.zuzi.adapter.annotation.RecyclerItemLayoutId; | ||
|
||
/** | ||
* @author liyi | ||
* create at 2018/4/26 | ||
**/ | ||
@RecyclerItemLayoutId(R.layout.item_image) | ||
public class TopViewHolder extends AppBaseHolder { | ||
|
||
@FastAttribute | ||
String url; | ||
|
||
@OnClick(R.id.image_view) | ||
public void onClickImage() { | ||
Toast.makeText(itemView.getContext(), "onClickImage", Toast.LENGTH_SHORT).show(); | ||
} | ||
} |
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,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical" | ||
android:gravity="center_vertical" | ||
> | ||
|
||
<ImageView | ||
android:id="@+id/image_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="160dp" | ||
android:background="#FF4081" | ||
/> | ||
|
||
</LinearLayout> |
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.