Skip to content

Commit

Permalink
add long click update gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
ChadCym committed May 11, 2016
1 parent f01b30b commit 1c2de90
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(path: ':library')
compile project(':material-spinner-1.0.5')
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Toast;

import com.chad.baserecyclerviewadapterhelper.adapter.HomeAdapter;
import com.chad.baserecyclerviewadapterhelper.entity.HomeItem;
Expand Down Expand Up @@ -37,6 +38,13 @@ public void onItemClick(View view, int position) {
startActivity(intent);
}
});
homeAdapter.setOnRecyclerViewItemLongClickListener(new BaseQuickAdapter.OnRecyclerViewItemLongClickListener() {
@Override
public boolean onItemLongClick(View view, int position) {
Toast.makeText(HomeActivity.this,"onItemLongClick",Toast.LENGTH_LONG).show();
return true;
}
});
mRecyclerView.setAdapter(homeAdapter);
}

Expand Down
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@ buildscript {
repositories {
jcenter()
mavenLocal()
mavenCentral()

}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}

allprojects {
repositories {
jcenter()
mavenCentral()
}
}


12 changes: 6 additions & 6 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
buildToolsVersion "23.0.3"

defaultConfig {
minSdkVersion 14
Expand All @@ -19,9 +19,9 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.android.support:recyclerview-v7:24.0.0-alpha1'
compile files('libs/glide-3.7.0.jar')

compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:cardview-v7:23.3.0'
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
}
Binary file removed library/libs/glide-3.7.0.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public abstract class BaseQuickAdapter<T> extends RecyclerView.Adapter<RecyclerV
private int mDuration = 300;
private int mLastPosition = -1;
private OnRecyclerViewItemClickListener onRecyclerViewItemClickListener;
private OnRecyclerViewItemLongClickListener onRecyclerViewItemLongClickListener;
private RequestLoadMoreListener mRequestLoadMoreListener;
@AnimationType
private BaseAnimation mCustomAnimation;
Expand Down Expand Up @@ -155,6 +156,13 @@ public void setOnRecyclerViewItemClickListener(OnRecyclerViewItemClickListener o
public interface OnRecyclerViewItemClickListener {
public void onItemClick(View view, int position);
}
public void setOnRecyclerViewItemLongClickListener(OnRecyclerViewItemLongClickListener onRecyclerViewItemLongClickListener) {
this.onRecyclerViewItemLongClickListener = onRecyclerViewItemLongClickListener;
}

public interface OnRecyclerViewItemLongClickListener {
public boolean onItemLongClick(View view, int position);
}

private OnRecyclerViewItemChildClickListener mChildClickListener;

Expand Down Expand Up @@ -435,6 +443,14 @@ public void onClick(View v) {
}
});
}
if (onRecyclerViewItemLongClickListener != null) {
baseViewHolder.convertView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
return onRecyclerViewItemLongClickListener.onItemLongClick(v, holder.getLayoutPosition() - getHeaderViewsCount());
}
});
}
}

private void addAnimation(RecyclerView.ViewHolder holder) {
Expand Down

0 comments on commit 1c2de90

Please sign in to comment.