Made multicolored rows (gray-white) in SearchableView
This commit is contained in:
parent
4d331326b0
commit
06f3df407c
@ -68,6 +68,8 @@ public interface MainContract {
|
||||
void setTreeViewChildren(ArrayList<TreeNode> children);
|
||||
void onFailureAnswer(int errorCode);
|
||||
void swipeLayoutSetRefreshing(boolean state);
|
||||
int incTreeNodeIndex();
|
||||
|
||||
}
|
||||
|
||||
interface ItemPresenter {
|
||||
|
@ -23,9 +23,9 @@ public class SearchableNodeViewFactory extends BaseNodeViewFactory {
|
||||
public BaseNodeViewBinder getNodeViewBinder(View view, int level) {
|
||||
switch (level) {
|
||||
case 0:
|
||||
return new FirstLevelNodeViewBinder(view);
|
||||
return new FirstLevelNodeViewBinder(view, mView);
|
||||
case 1:
|
||||
return new SecondLevelNodeViewBinder(view);
|
||||
return new SecondLevelNodeViewBinder(view, mView);
|
||||
case 2:
|
||||
return new ThirdLevelNodeViewBinder(view, context, mView);
|
||||
default:
|
||||
|
@ -1,21 +1,28 @@
|
||||
package ru.volgorobot.vrcatalog.searchNodeViewBinders;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import me.texy.treeview.TreeNode;
|
||||
import me.texy.treeview.base.BaseNodeViewBinder;
|
||||
import ru.volgorobot.vrcatalog.MainContract;
|
||||
import ru.volgorobot.vrcatalog.R;
|
||||
|
||||
public class FirstLevelNodeViewBinder extends BaseNodeViewBinder {
|
||||
TextView textView;
|
||||
ImageView imageView;
|
||||
RelativeLayout layout;
|
||||
MainContract.MainActivityView mView;
|
||||
|
||||
public FirstLevelNodeViewBinder(View itemView) {
|
||||
public FirstLevelNodeViewBinder(View itemView, MainContract.MainActivityView mView) {
|
||||
super(itemView);
|
||||
textView = (TextView) itemView.findViewById(R.id.node_name_view);
|
||||
imageView = (ImageView) itemView.findViewById(R.id.arrow_img);
|
||||
layout = itemView.findViewById(R.id.parent_node_container_1);
|
||||
this.mView = mView;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -26,6 +33,14 @@ public class FirstLevelNodeViewBinder extends BaseNodeViewBinder {
|
||||
@Override
|
||||
public void bindView(TreeNode treeNode) {
|
||||
textView.setText(treeNode.getValue().toString());
|
||||
imageView.setRotation(treeNode.isExpanded() ? 90 : 0);
|
||||
int index = mView.incTreeNodeIndex();
|
||||
treeNode.setIndex(index);
|
||||
if(index % 2 == 1) {
|
||||
layout.setBackgroundColor(Color.parseColor("#FFFFFF"));
|
||||
} else {
|
||||
layout.setBackgroundColor(Color.parseColor("#BABABA"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,21 +1,28 @@
|
||||
package ru.volgorobot.vrcatalog.searchNodeViewBinders;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import me.texy.treeview.TreeNode;
|
||||
import me.texy.treeview.base.BaseNodeViewBinder;
|
||||
import ru.volgorobot.vrcatalog.MainContract;
|
||||
import ru.volgorobot.vrcatalog.R;
|
||||
|
||||
public class SecondLevelNodeViewBinder extends BaseNodeViewBinder {
|
||||
TextView textView;
|
||||
ImageView imageView;
|
||||
RelativeLayout layout;
|
||||
MainContract.MainActivityView mView;
|
||||
|
||||
public SecondLevelNodeViewBinder(View itemView) {
|
||||
public SecondLevelNodeViewBinder(View itemView, MainContract.MainActivityView mView) {
|
||||
super(itemView);
|
||||
textView = (TextView) itemView.findViewById(R.id.node_name_view);
|
||||
imageView = (ImageView) itemView.findViewById(R.id.arrow_img);
|
||||
layout = itemView.findViewById(R.id.parent_node_container_2);
|
||||
this.mView = mView;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -26,6 +33,14 @@ public class SecondLevelNodeViewBinder extends BaseNodeViewBinder {
|
||||
@Override
|
||||
public void bindView(TreeNode treeNode) {
|
||||
textView.setText(treeNode.getValue().toString());
|
||||
imageView.setRotation(treeNode.isExpanded() ? 90 : 0);
|
||||
int index = mView.incTreeNodeIndex();
|
||||
treeNode.setIndex(index);
|
||||
if(index % 2 == 1) {
|
||||
layout.setBackgroundColor(Color.parseColor("#FFFFFF"));
|
||||
} else {
|
||||
layout.setBackgroundColor(Color.parseColor("#BABABA"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -125,6 +125,7 @@ public class MainActivity extends AppCompatActivity
|
||||
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
treeNodeIndex = 0;
|
||||
mConnectionErrorImageView.setVisibility(View.INVISIBLE);
|
||||
mErrorTextView.setVisibility(View.INVISIBLE);
|
||||
mTreeViewContainer.setVisibility(View.VISIBLE);
|
||||
|
@ -35,6 +35,7 @@ public class SearchableActivity extends AppCompatActivity implements MainContrac
|
||||
private ImageView mConnectionErrorImageView;
|
||||
private NestedScrollView mTreeViewContainer;
|
||||
private TextView mErrorTextView;
|
||||
private int treeNodeIndex;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -150,6 +151,6 @@ public class SearchableActivity extends AppCompatActivity implements MainContrac
|
||||
|
||||
@Override
|
||||
public int incTreeNodeIndex() {
|
||||
return 0;
|
||||
return treeNodeIndex++;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user