Skip to content

Commit

Permalink
update to version 0.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Zhang authored and Frank Zhang committed Jun 24, 2018
1 parent c3467d9 commit fe74667
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 57 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
.DS_Store
/build
/captures
.idea
35 changes: 20 additions & 15 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion '24.0.2'
compileSdkVersion 27
buildToolsVersion '27.0.3'

defaultConfig {
applicationId "com.aspsine.irecyclerview.demo"
minSdkVersion 15
targetSdkVersion 24
versionCode 5
versionName "1.5"
targetSdkVersion 27
versionCode 6
versionName "1.6"
}
buildTypes {
release {
Expand All @@ -20,14 +20,19 @@ android {
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile project(':library')
// compile 'com.github.Aspsine:IRecyclerView:0.0.3'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0@aar'
api fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
implementation project(':library')
// implementation 'com.github.Aspsine:IRecyclerView:0.0.3'
implementation ('com.android.support:appcompat-v7:27.1.1')
implementation ('com.android.support:recyclerview-v7:27.1.1')
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.squareup.okhttp3:okhttp:3.9.0'
implementation ('com.github.JakeWharton:ViewPagerIndicator:2.4.1'){
transitive = true
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'support-v7'
}
implementation 'com.github.bumptech.glide:glide:3.8.0'
implementation 'com.github.bumptech.glide:okhttp3-integration:1.4.0@aar'
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ public class NetworkAPI {
public static void requestImages(int page, final Callback<List<Image>> callback) {
String url = Constants.ImagesAPI(page);
final Request request = new Request.Builder().get().url(url).build();
OkHttp.getOkHttpClient().newCall(request).enqueue(new GsonCallbackWrapper<List<Image>>(callback, new TypeToken<List<Image>>() {
OkHttp.getOkHttpClient().newCall(request).enqueue(new GsonCallbackWrapper<>(callback, new TypeToken<List<Image>>() {
}));
}

public static void requestBanners(final Callback<List<Image>> callback) {
String url = Constants.BannerAPI;
final Request request = new Request.Builder().get().url(url).build();
OkHttp.getOkHttpClient().newCall(request).enqueue(new GsonCallbackWrapper<List<Image>>(callback, new TypeToken<List<Image>>() {
OkHttp.getOkHttpClient().newCall(request).enqueue(new GsonCallbackWrapper<>(callback, new TypeToken<List<Image>>() {
}));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class MainActivity extends AppCompatActivity implements OnItemClickListen
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
iRecyclerView = (IRecyclerView) findViewById(R.id.iRecyclerView);
iRecyclerView = findViewById(R.id.iRecyclerView);
iRecyclerView.setLayoutManager(new LinearLayoutManager(this));

bannerView = (BannerView) LayoutInflater.from(this).inflate(R.layout.layout_banner_view, iRecyclerView.getHeaderContainer(), false);
Expand Down Expand Up @@ -162,21 +162,9 @@ public void onSuccess(final List<Image> images) {
if (ListUtils.isEmpty(images)) {
loadMoreFooterView.setStatus(LoadMoreFooterView.Status.THE_END);
} else {

// mPage++;
// loadMoreFooterView.setStatus(LoadMoreFooterView.Status.GONE);
// mAdapter.append(images);
/**
* FIXME here we post delay to see more animation, you don't need to do this.
*/
loadMoreFooterView.postDelayed(new Runnable() {
@Override
public void run() {
mPage++;
loadMoreFooterView.setStatus(LoadMoreFooterView.Status.GONE);
mAdapter.append(images);
}
}, 2000);
mPage++;
loadMoreFooterView.setStatus(LoadMoreFooterView.Status.GONE);
mAdapter.append(images);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void remove(int position) {
notifyItemRemoved(position);
}

public void clear(){
public void clear() {
mImages.clear();
notifyDataSetChanged();
}
Expand All @@ -74,9 +74,11 @@ public void onClick(View v) {
* {@code IViewHolder.getIAdapterPosition()}
*/
final int position = holder.getIAdapterPosition();
final Image image = mImages.get(position);
if (mOnItemClickListener != null) {
mOnItemClickListener.onItemClick(position, image, v);
if (position != RecyclerView.NO_POSITION) {
final Image image = mImages.get(position);
if (mOnItemClickListener != null) {
mOnItemClickListener.onItemClick(position, image, v);
}
}
}
});
Expand Down
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-rc1'
classpath 'com.android.tools.build:gradle:3.1.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -16,6 +17,7 @@ allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
google()
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Aug 11 08:45:15 CST 2016
#Sun Jun 24 20:49:02 CST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
18 changes: 9 additions & 9 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 24
buildToolsVersion '24.0.2'
compileSdkVersion 27
buildToolsVersion '27.0.3'

defaultConfig {
minSdkVersion 11
targetSdkVersion 24
versionCode 5
versionName "0.0.5"
minSdkVersion 14
targetSdkVersion 27
versionCode 6
versionName "0.0.6"
}
buildTypes {
release {
Expand All @@ -19,7 +19,7 @@ android {
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:recyclerview-v7:24.2.0'
api fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
api 'com.android.support:recyclerview-v7:27.1.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public final int getILayoutPosition() {
}

public final int getIAdapterPosition() {
if (getAdapterPosition() == RecyclerView.NO_POSITION) {
return RecyclerView.NO_POSITION;
}
return getAdapterPosition() - 2;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.aspsine.irecyclerview;

import android.support.annotation.NonNull;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
Expand Down Expand Up @@ -74,7 +75,7 @@ public RecyclerView.Adapter getAdapter() {
}

@Override
public void onAttachedToRecyclerView(final RecyclerView recyclerView) {
public void onAttachedToRecyclerView(@NonNull final RecyclerView recyclerView) {
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
if (layoutManager instanceof GridLayoutManager) {
final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
Expand All @@ -95,7 +96,7 @@ public int getSpanSize(int position) {
}

@Override
public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
public void onViewAttachedToWindow(@NonNull RecyclerView.ViewHolder holder) {
super.onViewAttachedToWindow(holder);
int position = holder.getAdapterPosition();
int type = getItemViewType(position);
Expand Down Expand Up @@ -134,8 +135,9 @@ public int getItemViewType(int position) {
throw new IllegalArgumentException("Wrong type! Position = " + position);
}

@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if (viewType == REFRESH_HEADER) {
return new RefreshHeaderContainerViewHolder(mRefreshHeaderContainer);
} else if (viewType == HEADER) {
Expand All @@ -150,36 +152,36 @@ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType
}

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (1 < position && position < mAdapter.getItemCount() + 2) {
mAdapter.onBindViewHolder(holder, position - 2);
}
}

static class RefreshHeaderContainerViewHolder extends RecyclerView.ViewHolder {

public RefreshHeaderContainerViewHolder(View itemView) {
RefreshHeaderContainerViewHolder(View itemView) {
super(itemView);
}
}

static class HeaderContainerViewHolder extends RecyclerView.ViewHolder {

public HeaderContainerViewHolder(View itemView) {
HeaderContainerViewHolder(View itemView) {
super(itemView);
}
}

static class FooterContainerViewHolder extends RecyclerView.ViewHolder {

public FooterContainerViewHolder(View itemView) {
FooterContainerViewHolder(View itemView) {
super(itemView);
}
}

static class LoadMoreFooterContainerViewHolder extends RecyclerView.ViewHolder {

public LoadMoreFooterContainerViewHolder(View itemView) {
LoadMoreFooterContainerViewHolder(View itemView) {
super(itemView);
}
}
Expand Down

0 comments on commit fe74667

Please sign in to comment.