Skip to content

Commit

Permalink
Merge pull request #3 from aizuzi/dev
Browse files Browse the repository at this point in the history
添加processor
  • Loading branch information
aizuzi authored Jul 27, 2018
2 parents fb97601 + be1cdcb commit 19663f6
Show file tree
Hide file tree
Showing 34 changed files with 1,058 additions and 263 deletions.
5 changes: 4 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ dependencies {
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.github.bumptech.glide:glide:4.7.1'
implementation project(':fastadapter')

annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
annotationProcessor project(":fastadapter_processor")
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.aizuzi.adapter.demo">

<uses-permission android:name="android.permission.INTERNET"/>
<!--
Allows Glide to monitor connectivity status and restart failed requests if users go from a
a disconnected to a connected network state.
-->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />


<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand Down
41 changes: 28 additions & 13 deletions app/src/main/java/com/aizuzi/adapter/demo/MainActivity.java
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);
}


}
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);
}
}

This file was deleted.

This file was deleted.

This file was deleted.

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;
}

This file was deleted.

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();
}
}
16 changes: 16 additions & 0 deletions app/src/main/res/layout/item_head.xml
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>
25 changes: 20 additions & 5 deletions app/src/main/res/layout/item_image.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,30 @@
<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"
android:gravity="center"
android:orientation="horizontal"
android:paddingBottom="15dp"
android:paddingTop="15dp"
>

<ImageView
android:id="@+id/image_view"
android:layout_marginLeft="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="80dp"
android:layout_height="80dp"
android:src="@drawable/ic_launcher_background"
/>

<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginLeft="30dp"
android:src="@drawable/ic_launcher_background"
/>

<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginLeft="30dp"
android:src="@drawable/ic_launcher_background"
/>

Expand Down
Loading

0 comments on commit 19663f6

Please sign in to comment.