Skip to content

Commit

Permalink
Merge pull request #60 from zenochan/pullreq
Browse files Browse the repository at this point in the history
RcvAdapterWrapper, RcvAdapterItem
  • Loading branch information
kaleai committed May 8, 2017
2 parents 99d0033 + dc7cebf commit 7e4440a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion adapter/src/main/java/kale/adapter/CommonRcvAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public int getCurrentPosition() {
// 内部用到的viewHold
///////////////////////////////////////////////////////////////////////////

static class RcvAdapterItem extends RecyclerView.ViewHolder {
public static class RcvAdapterItem extends RecyclerView.ViewHolder {

protected AdapterItem item;

Expand Down
25 changes: 17 additions & 8 deletions adapter/src/main/java/kale/adapter/RcvAdapterWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,19 +242,28 @@ public int getFooterCount() {

private void setFullSpan(@Nullable View view, RecyclerView.LayoutManager layoutManager) {
if (view != null) {
final int itemHeight = view.getLayoutParams() != null ?
view.getLayoutParams().height : RecyclerView.LayoutParams.WRAP_CONTENT;
int itemWidth = view.getLayoutParams() != null ?
view.getLayoutParams().height : RecyclerView.LayoutParams.WRAP_CONTENT;
int itemHeight = view.getLayoutParams() != null ?
view.getLayoutParams().height : RecyclerView.LayoutParams.WRAP_CONTENT;

if (layoutManager instanceof StaggeredGridLayoutManager) {
if (((StaggeredGridLayoutManager) layoutManager).getOrientation() == LinearLayoutManager.VERTICAL) {
itemWidth = ViewGroup.LayoutParams.MATCH_PARENT;
} else {
itemHeight = ViewGroup.LayoutParams.MATCH_PARENT;
}
StaggeredGridLayoutManager.LayoutParams layoutParams =
new StaggeredGridLayoutManager.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, itemHeight);
new StaggeredGridLayoutManager.LayoutParams(itemWidth, itemHeight);
layoutParams.setFullSpan(true);
view.setLayoutParams(layoutParams);
} else if (layoutManager instanceof GridLayoutManager
|| layoutManager instanceof LinearLayoutManager) {
view.setLayoutParams(new RecyclerView.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, itemHeight));
} else if (layoutManager instanceof LinearLayoutManager) {
if (((LinearLayoutManager) layoutManager).getOrientation() == LinearLayoutManager.VERTICAL) {
itemWidth = ViewGroup.LayoutParams.MATCH_PARENT;
} else {
itemHeight = ViewGroup.LayoutParams.MATCH_PARENT;
}
view.setLayoutParams(new RecyclerView.LayoutParams(itemWidth, itemHeight));
}
notifyDataSetChanged();
}
Expand Down

0 comments on commit 7e4440a

Please sign in to comment.