Skip to content

Commit

Permalink
Merge pull request #83 from AllenCoder/master
Browse files Browse the repository at this point in the history
add note and fix a bug
  • Loading branch information
CymChad authored Jun 19, 2016
2 parents 30085ca + 13dc394 commit db79b2c
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 98 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,19 @@ proguard/
.gradle
.idea
build
<<<<<<< HEAD
/build.gradle
/.idea/

build.gradle

.idea/misc.xml
=======
.DS_Store
local.properties
# build files
output/
# android studio
*.iml
.idea
>>>>>>> CymChad/master
3 changes: 2 additions & 1 deletion .idea/gradle.xml

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

81 changes: 0 additions & 81 deletions .idea/misc.xml

This file was deleted.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {

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

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 @@
#Fri Jun 17 11:45:15 CST 2016
#Sun Jun 19 09:50:29 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ public void setOnLoadMoreListener(RequestLoadMoreListener requestLoadMoreListene
this.mRequestLoadMoreListener = requestLoadMoreListener;
}

/**
* Sets the duration of the animation.
* @param duration The length of the animation, in milliseconds.
*/
public void setDuration(int duration) {
mDuration = duration;
}
Expand Down Expand Up @@ -156,25 +160,61 @@ public void setPageSize(int pageSize) {
public int getPageSize() {
return this.pageSize;
}

/**
* Register a callback to be invoked when an item in this AdapterView has
* been clicked.
*
* @param onRecyclerViewItemClickListener The callback that will be invoked.
*/
public void setOnRecyclerViewItemClickListener(OnRecyclerViewItemClickListener onRecyclerViewItemClickListener) {
this.onRecyclerViewItemClickListener = onRecyclerViewItemClickListener;
}

/**
* Interface definition for a callback to be invoked when an item in this
* AdapterView has been clicked.
*/
public interface OnRecyclerViewItemClickListener {
/**
* Callback method to be invoked when an item in this AdapterView has
* been clicked.
* @param view The view within the AdapterView that was clicked (this
* will be a view provided by the adapter)
* @param position The position of the view in the adapter.
*/
public void onItemClick(View view, int position);
}

/**
* Register a callback to be invoked when an item in this AdapterView has
* been clicked and held
*
* @param onRecyclerViewItemLongClickListener The callback that will run
*/
public void setOnRecyclerViewItemLongClickListener(OnRecyclerViewItemLongClickListener onRecyclerViewItemLongClickListener) {
this.onRecyclerViewItemLongClickListener = onRecyclerViewItemLongClickListener;
}

/**
* Interface definition for a callback to be invoked when an item in this
* view has been clicked and held
*/
public interface OnRecyclerViewItemLongClickListener {
/**
* callback method to be invoked when an item in this view has been
* click and held
* @param view The view whihin the AbsListView that was clicked
* @param position The position of the view int the adapter
* @return true if the callback consumed the long click ,false otherwise
*/
public boolean onItemLongClick(View view, int position);
}

private OnRecyclerViewItemChildClickListener mChildClickListener;

/**
* Register a callback to be invoked when childView in this AdapterView has
* been clicked and held
* {@link OnRecyclerViewItemChildClickListener}
* @param childClickListener The callback that will run
*/
public void setOnRecyclerViewItemChildClickListener(OnRecyclerViewItemChildClickListener childClickListener) {
this.mChildClickListener = childClickListener;
}
Expand Down Expand Up @@ -217,13 +257,21 @@ public BaseQuickAdapter(View contentView, List<T> data) {
mContentView = contentView;
}


/**
* remove the item associated with the specified position of adapter
* @param position
*/
public void remove(int position) {
mData.remove(position);
notifyItemRemoved(position + getHeaderViewsCount());

}

/**
* insert a item associated with the specified position of adapter
* @param position
* @param item
*/
public void add(int position, T item) {
mData.add(position, item);
notifyItemInserted(position);
Expand Down Expand Up @@ -255,7 +303,18 @@ public void addData(List<T> data) {
notifyDataSetChanged();
}

/**
* set a loadingView
* @param loadingView
*/
public void setLoadingView(View loadingView) {
this.mLoadingView = loadingView;
}

/**
* Get the data of list
* @return
*/
public List getData() {
return mData;
}
Expand All @@ -271,18 +330,33 @@ public T getItem(int position) {
return mData.get(position);
}

/**
* if setHeadView will be return 1 if not will be return 0
* @return
*/
public int getHeaderViewsCount() {
return mHeaderView == null ? 0 : 1;
}

/**
* if mFooterView will be return 1 or not will be return 0
* @return
*/
public int getFooterViewsCount() {
return mFooterView == null ? 0 : 1;
}

/**
* if mEmptyView will be return 1 or not will be return 0
* @return
*/
public int getmEmptyViewCount() {
return mEmptyView == null ? 0 : 1;
}

/**
* returns the number of item that will be created
*
* @return
*/
@Override
public int getItemCount() {
int i = isLoadMore() ? 1 : 0;
Expand Down Expand Up @@ -356,7 +430,7 @@ public int getItemViewType(int position) {
else if ((!mFootAndEmptyEnable || !mHeadAndEmptyEnable) && position == 1 && mFooterView != null) {
return FOOTER_VIEW;
}
} else if (mEmptyView != null && getItemCount() == (mHeadAndEmptyEnable ? 2 : 1) && mEmptyEnable) {
} else if (mData.size() == 0 &&mEmptyView != null && getItemCount() == (mHeadAndEmptyEnable ? 2 : 1) && mEmptyEnable) {
return EMPTY_VIEW;
} else if (position == mData.size() + getHeaderViewsCount()) {
if (mNextLoadEnable)
Expand Down Expand Up @@ -398,9 +472,6 @@ public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

}

public void setLoadingView(View loadingView) {
this.mLoadingView = loadingView;
}

private BaseViewHolder getLoadingView(ViewGroup parent) {
if (mLoadingView == null) {
Expand Down Expand Up @@ -579,15 +650,32 @@ private void addAnimation(RecyclerView.ViewHolder holder) {
}
}

/**
*
* @param anim
* @param index
*/
protected void startAnim(Animator anim, int index) {
anim.setDuration(mDuration).start();
anim.setInterpolator(mInterpolator);
}

/**
* Determine whether it is loaded more
* @return
*/
private boolean isLoadMore() {
return mNextLoadEnable && pageSize != -1 && mRequestLoadMoreListener != null && mData.size() >= pageSize;
}

/**
*
* @param layoutResId ID for an XML layout resource to load
* @param parent Optional view to be the parent of the generated hierarchy or else simply an object that
* provides a set of LayoutParams values for root of the returned
* hierarchy
* @return view will be return
*/
protected View getItemView(int layoutResId, ViewGroup parent) {
return mLayoutInflater.inflate(layoutResId, parent, false);
}
Expand Down Expand Up @@ -647,11 +735,17 @@ public void openLoadAnimation(BaseAnimation animation) {
this.mCustomAnimation = animation;
}

/**
* To open the animation when loading
*/
public void openLoadAnimation() {
this.mOpenAnimationEnable = true;
}


/**
* {@link #addAnimation(RecyclerView.ViewHolder)}
* @param firstOnly true just show anim when first loading false show anim when load the data every time
*/
public void isFirstOnly(boolean firstOnly) {
this.mFirstOnlyEnable = firstOnly;
}
Expand All @@ -664,7 +758,12 @@ public void isFirstOnly(boolean firstOnly) {
*/
protected abstract void convert(BaseViewHolder helper, T item);


/**
* Get the row id associated with the specified position in the list.
*
* @param position The position of the item within the adapter's data set whose row id we want.
* @return The id of the item at the specified position.
*/
@Override
public long getItemId(int position) {
return position;
Expand Down

0 comments on commit db79b2c

Please sign in to comment.