Skip to content

Commit

Permalink
修复一个可能导致重叠的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
pye52 committed Sep 25, 2017
1 parent b76599b commit cb71265
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android {
minSdkVersion 15
targetSdkVersion 26
versionCode 21
versionName "0.3.2"
versionName "0.3.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.kanade.nestviewholder;

public interface INestviewholder<T> {
void addChild(Nestitemview<T> nestitemview, T item);

Nestitemview<T> removeChild();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,25 @@
import android.view.View;
import android.widget.FrameLayout;

public abstract class Nestviewholder<T> extends RecyclerView.ViewHolder {
public abstract class Nestviewholder<T> extends RecyclerView.ViewHolder implements INestviewholder<T> {
protected Nestitemview<T> nestitemview;
protected FrameLayout root;

public Nestviewholder(View root) {
super(root);
}

@Override
public void addChild(Nestitemview<T> nestitemview, T item) {
this.nestitemview = nestitemview;
nestitemview.dispatch(root, item);
if (root.getChildCount() != 0) {
root.removeAllViews();
}
root.addView(nestitemview.getItemView());
}

@Override
public Nestitemview<T> removeChild() {
root.removeView(nestitemview.getItemView());
return nestitemview;
Expand Down

0 comments on commit cb71265

Please sign in to comment.