Skip to content

Commit

Permalink
上传到maven
Browse files Browse the repository at this point in the history
  • Loading branch information
linjunhua committed Jan 8, 2018
1 parent 58bb0ab commit 77ea879
Show file tree
Hide file tree
Showing 20 changed files with 68 additions and 151 deletions.
27 changes: 14 additions & 13 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
compileSdkVersion rootProject.android.compileSdkVersion
buildToolsVersion rootProject.android.buildToolsVersion
defaultConfig {
applicationId "cn.junhua.android.commonadapter"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
applicationId rootProject.android.applicationId
minSdkVersion rootProject.android.minSdkVersion
targetSdkVersion rootProject.android.targetSdkVersion
versionCode rootProject.android.versionCode
versionName rootProject.android.versionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand All @@ -24,14 +24,15 @@ dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:25.2.0'
testImplementation 'junit:junit:4.12'
implementation project(':adapter')
implementation 'com.android.support:recyclerview-v7:25.2.0'
implementation 'com.android.support:cardview-v7:25.2.0'
implementation 'cn.junhua.android.view:indicatorviewlibrary:1.0.0'
implementation project(':multitypeadapter')
//supportLib
implementation rootProject.ext.supportLib['appcompat-v7']
implementation rootProject.ext.supportLib['recyclerview-v7']
implementation rootProject.ext.supportLib['support-annotations']
//three lib
implementation 'com.youth.banner:banner:1.4.10'
compile('com.github.bumptech.glide:glide:3.7.0') {
implementation('com.github.bumptech.glide:glide:3.7.0') {
exclude group: 'com.android.support'
}
}
5 changes: 1 addition & 4 deletions app/src/main/res/layout/binder_goods_show.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="8dp"
card_view:cardElevation="8dp">
android:layout_height="wrap_content">


<LinearLayout
Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ allprojects {
task clean(type: Delete) {
delete rootProject.buildDir
}

apply from: 'config.gradle'
19 changes: 19 additions & 0 deletions config.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
rootProject.ext {
android = [
compileSdkVersion: 25,
buildToolsVersion: "26.0.2",
applicationId : "cn.junhua.android.commonadapter",
minSdkVersion : 15,
targetSdkVersion : 25,
versionCode : 2,
versionName : "2.0.0"
]

supportVersion = "25.2.0"
supportLib = [
"appcompat-v7" : "com.android.support:appcompat-v7:$supportVersion",
"recyclerview-v7": "com.android.support:recyclerview-v7:$supportVersion",
"support-annotations": "com.android.support:support-annotations:$supportVersion",
]

}
File renamed without changes.
36 changes: 19 additions & 17 deletions adapter/build.gradle → multitypeadapter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ apply plugin: 'com.android.library'

ext {
bintrayRepo = 'maven'
bintrayName = 'adapter'
bintrayName = 'multitypeadapter'

//GROUP_ID:ARTIFACT_ID:VERSION dependencies format
publishedGroupId = 'cn.junhua.android.adapter'
libraryName = 'adapter'
artifact = 'adapter'
artifact = 'multitypeadapter'
libraryVersion = rootProject.android.versionName
//cn.junhua.android.adapter:MultiTypeAdapter:x.y.z
libraryName = 'MultiTypeAdapter'

libraryDescription = 'some common for ListView and RecyclerView on Android'
libraryDescription = 'a common adapter for RecyclerView on Android'

siteUrl = 'https://github.com/JunhuaLin/CommonAdapter'
gitUrl = 'https://github.com/JunhuaLin/CommonAdapter.git'

libraryVersion = '1.0.0'
siteUrl = 'https://github.com/JunhuaLin/MultiTypeAdapter'
gitUrl = 'https://github.com/JunhuaLin/MultiTypeAdapter.git'

developerId = 'linjunhua'
developerName = 'linjunhua'
Expand All @@ -25,18 +26,17 @@ ext {
}

android {
compileSdkVersion 25
buildToolsVersion '26.0.2'

compileSdkVersion rootProject.android.compileSdkVersion
buildToolsVersion rootProject.android.buildToolsVersion
defaultConfig {
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
minSdkVersion rootProject.android.minSdkVersion
targetSdkVersion rootProject.android.targetSdkVersion
versionCode rootProject.android.versionCode
versionName rootProject.android.versionName

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}

buildTypes {
release {
minifyEnabled false
Expand All @@ -48,7 +48,9 @@ android {
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
compile 'com.android.support:recyclerview-v7:25.2.0'
//supportLib
implementation rootProject.ext.supportLib['recyclerview-v7']
implementation rootProject.ext.supportLib['support-annotations']
}

apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import cn.junhua.android.adapter.imp.OneToManyMapper;

/**
* 功能:Adapter封装简化使用步骤,适用于RecyclerView的任意类别条目的列表数据填充
* created by 林军华 on 2016/5/18 0026.
* a common adapter for RecyclerView on Android
* created by linjunhua on 2016/5/18 0026.
*/
public class MultiTypeAdapter extends RecyclerView.Adapter<ViewHolder> {
// data res
Expand All @@ -36,32 +36,17 @@ public MultiTypeAdapter(Context context) {
mList = Collections.emptyList();
}

/**
* 注册ViewBinder
*
* @param viewBinder SingleViewBinder
*/
public void registerViewBinder(ViewBinder viewBinder) {
if (viewBinder == null) {
return;
}
mViewBinderMap.put(viewBinder.getBeanClass(), viewBinder);
}

/**
* @param beanClass 数据对象的类类型
* @param <T> 数据的类型
* @return OneToManyMapper<T>
*/
public <T> OneToManyMapper<T> registerViewBinder(Class<T> beanClass) {
return new OneToManyBuilder<>(this, beanClass);
}

/**
* 注册ViewBinder
*
* @param viewBinderCollection ViewBinder集合
*/
public void registerViewBinder(Collection<? extends ViewBinder> viewBinderCollection) {
if (viewBinderCollection == null) {
return;
Expand All @@ -71,9 +56,7 @@ public void registerViewBinder(Collection<? extends ViewBinder> viewBinderCollec
}
}

/**
* 注销ViewBinder
*/

public void unregisterViewBinder(ViewBinder viewBinder) {
if (viewBinder == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import cn.junhua.android.adapter.imp.TypeMatcher;

/**
* 多类型条目包装类->多条目由多个SingleTypeViewBinder组成
* MultiViewBinder consists of multiple ViewBinder
*/
public class MultiViewBinder<T> extends ViewBinder<T> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import cn.junhua.android.adapter.imp.OneToManyMatcher;

/**
* MultiTypeViewBinder构造器
* MultiTypeViewBinder Builder
* Created by junhua.lin on 2017/12/28.
*/
public class OneToManyBuilder<T> implements OneToManyMapper<T>, OneToManyMatcher<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@


/**
* 单类型条目封装类
* SingleViewBinder
* Created by junhua.lin on 2017/12/28.
*/
public abstract class SingleViewBinder<T> extends ViewBinder<T> {
private int mLayoutId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import android.support.annotation.LayoutRes;

/**
* 视图绑定器基类
* the base class for binding view.
* Created by junhua.lin on 2017/12/27.
*/
@SuppressWarnings("unchecked")
Expand All @@ -16,11 +16,6 @@ public ViewBinder(Class<T> clazz) {
this.mBeanClass = clazz;
}

/**
* 返回数据类的Class
*
* @return 返回数据类的Class
*/
public final Class<T> getBeanClass() {
return mBeanClass;
}
Expand All @@ -30,70 +25,27 @@ public Context getContext() {
}


/**
* 获得ViewBinder中findView次数,即需要缓存View的个数
*
* @param bean 数据
* @param position 数据在集合中的位置
* @return ViewBinder中findView次数
*/
public int performCountView(Object bean, int position) {
return onCountView((T) bean, position);
}

/**
* 应该在子类中重写该方法<br/>
* 作用:<br/>
* 1.避免存储结构扩容带来的性能消耗。<br/>
* 2.避免容量未完全使用带来的内存浪费。<br/>
*
* @return 需要缓存View的个数, 默认值6
*/
public int onCountView(T bean, int position) {
return 6;
}

/**
* 执行获取布局id操作
*
* @param bean 数据
* @param position 在列表中的位置
* @return 返回布局文件的id
*/
public @LayoutRes
int performCreateItemView(Object bean, int position) {
return onCreateItemView((T) bean, position);
}

/**
* 返回布局文件的id
*
* @param bean 数据
* @param position 在列表中的位置
* @return 返回布局文件的id
*/
public abstract @LayoutRes
int onCreateItemView(T bean, int position);


/**
* 执行绑定视图操作
*
* @param holder 视图的holder
* @param bean 数据
* @param position 在列表中的位置
*/
public void performBindView(ViewHolder holder, Object bean, int position) {
onBindView(holder, (T) bean, position);
}

/**
* 处理数据与视图绑定
*
* @param holder 封装adapter中item的复用操作代码的对象
* @param bean 数据Bean需要强制类型转化
* @param position 当前条目位置
*/
public abstract void onBindView(ViewHolder holder, T bean, int position);


Expand Down
Loading

0 comments on commit 77ea879

Please sign in to comment.