From 9d7e85a80c70bb6c00fc5801c22cdea8c4e01ee4 Mon Sep 17 00:00:00 2001 From: ChronosX88 Date: Mon, 25 Feb 2019 16:29:52 +0400 Subject: [PATCH] Made multicolored rows (gray-white), the text in SearchView is now white. --- .../ru/volgorobot/vrcatalog/MainContract.java | 1 + .../FirstLevelNodeViewBinder.java | 16 ++++++++++++++++ .../SecondLevelNodeViewBinder.java | 13 +++++++++++++ .../ThirdLevelNodeViewBinder.java | 13 +++++++++++++ .../volgorobot/vrcatalog/view/MainActivity.java | 5 +++++ .../vrcatalog/view/SearchableActivity.java | 5 +++++ app/src/main/res/layout/app_bar_main.xml | 2 +- app/src/main/res/layout/first_level_item.xml | 1 + app/src/main/res/layout/second_level_item.xml | 1 + app/src/main/res/layout/third_level_item.xml | 1 + app/src/main/res/values-v21/styles.xml | 4 +++- app/src/main/res/values/styles.xml | 3 --- 12 files changed, 60 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/ru/volgorobot/vrcatalog/MainContract.java b/app/src/main/java/ru/volgorobot/vrcatalog/MainContract.java index 991ebef..14c60b6 100644 --- a/app/src/main/java/ru/volgorobot/vrcatalog/MainContract.java +++ b/app/src/main/java/ru/volgorobot/vrcatalog/MainContract.java @@ -20,6 +20,7 @@ public interface MainContract { void onFailureAnswer(int errorCode); void refreshTree(); void startActivityByIntent(Intent intent); + int incTreeNodeIndex(); } interface Presenter { diff --git a/app/src/main/java/ru/volgorobot/vrcatalog/nodeViewBinders/FirstLevelNodeViewBinder.java b/app/src/main/java/ru/volgorobot/vrcatalog/nodeViewBinders/FirstLevelNodeViewBinder.java index b3ddcad..7f55e80 100644 --- a/app/src/main/java/ru/volgorobot/vrcatalog/nodeViewBinders/FirstLevelNodeViewBinder.java +++ b/app/src/main/java/ru/volgorobot/vrcatalog/nodeViewBinders/FirstLevelNodeViewBinder.java @@ -1,8 +1,11 @@ package ru.volgorobot.vrcatalog.nodeViewBinders; import android.content.Context; +import android.graphics.Color; +import android.support.v7.widget.RecyclerView; import android.view.View; import android.widget.ImageView; +import android.widget.RelativeLayout; import android.widget.TextView; import me.texy.treeview.TreeNode; @@ -15,12 +18,16 @@ import ru.volgorobot.vrcatalog.model.FirstLevelModel; public class FirstLevelNodeViewBinder extends BaseNodeViewBinder implements MainContract.ViewBinder { TextView textView; ImageView imageView; + RelativeLayout layout; ViewBinderPresenter viewBinderPresenter; + private MainContract.MainActivityView mView; public FirstLevelNodeViewBinder(View itemView, MainContract.MainActivityView mView, Context context) { 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; viewBinderPresenter = new ViewBinderPresenter(mView, this, context); } @@ -32,6 +39,14 @@ public class FirstLevelNodeViewBinder extends BaseNodeViewBinder implements Main @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 @@ -48,4 +63,5 @@ public class FirstLevelNodeViewBinder extends BaseNodeViewBinder implements Main public void rotateImageView() { imageView.animate().rotation(90).setDuration(200).start(); } + } diff --git a/app/src/main/java/ru/volgorobot/vrcatalog/nodeViewBinders/SecondLevelNodeViewBinder.java b/app/src/main/java/ru/volgorobot/vrcatalog/nodeViewBinders/SecondLevelNodeViewBinder.java index 9dacb60..04c114f 100644 --- a/app/src/main/java/ru/volgorobot/vrcatalog/nodeViewBinders/SecondLevelNodeViewBinder.java +++ b/app/src/main/java/ru/volgorobot/vrcatalog/nodeViewBinders/SecondLevelNodeViewBinder.java @@ -1,8 +1,10 @@ package ru.volgorobot.vrcatalog.nodeViewBinders; import android.content.Context; +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; @@ -15,6 +17,8 @@ import ru.volgorobot.vrcatalog.model.SecondLevelModel; public class SecondLevelNodeViewBinder extends BaseNodeViewBinder implements MainContract.ViewBinder { TextView textView; ImageView imageView; + RelativeLayout layout; + private MainContract.MainActivityView mView; MainContract.LevelLoaderPresenter viewBinderPresenter; @@ -22,6 +26,8 @@ public class SecondLevelNodeViewBinder extends BaseNodeViewBinder implements Mai 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; viewBinderPresenter = new ViewBinderPresenter(mView, this, context); } @@ -34,6 +40,13 @@ public class SecondLevelNodeViewBinder extends BaseNodeViewBinder implements Mai public void bindView(final 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 diff --git a/app/src/main/java/ru/volgorobot/vrcatalog/nodeViewBinders/ThirdLevelNodeViewBinder.java b/app/src/main/java/ru/volgorobot/vrcatalog/nodeViewBinders/ThirdLevelNodeViewBinder.java index f18c3e6..6d39968 100644 --- a/app/src/main/java/ru/volgorobot/vrcatalog/nodeViewBinders/ThirdLevelNodeViewBinder.java +++ b/app/src/main/java/ru/volgorobot/vrcatalog/nodeViewBinders/ThirdLevelNodeViewBinder.java @@ -1,7 +1,9 @@ package ru.volgorobot.vrcatalog.nodeViewBinders; import android.content.Context; +import android.graphics.Color; import android.view.View; +import android.widget.RelativeLayout; import android.widget.TextView; import me.texy.treeview.TreeNode; @@ -13,12 +15,16 @@ import ru.volgorobot.vrcatalog.model.ThirdLevelModel; public class ThirdLevelNodeViewBinder extends BaseNodeViewBinder implements MainContract.ViewBinder { TextView textView; + RelativeLayout layout; + private MainContract.MainActivityView mView; MainContract.LevelLoaderPresenter viewBinderPresenter; public ThirdLevelNodeViewBinder(View itemView, Context context, MainContract.MainActivityView mView) { super(itemView); viewBinderPresenter = new ViewBinderPresenter(mView, this, context); textView = itemView.findViewById(R.id.node_name_view); + layout = itemView.findViewById(R.id.parent_node_container_3); + this.mView = mView; } @Override @@ -29,6 +35,13 @@ public class ThirdLevelNodeViewBinder extends BaseNodeViewBinder implements Main @Override public void bindView(final TreeNode treeNode) { textView.setText(treeNode.getValue().toString()); + int index = mView.incTreeNodeIndex(); + treeNode.setIndex(index); + if(index % 2 == 1) { + layout.setBackgroundColor(Color.parseColor("#FFFFFF")); + } else { + layout.setBackgroundColor(Color.parseColor("#BABABA")); + } } @Override diff --git a/app/src/main/java/ru/volgorobot/vrcatalog/view/MainActivity.java b/app/src/main/java/ru/volgorobot/vrcatalog/view/MainActivity.java index 3be56e8..d97ed36 100644 --- a/app/src/main/java/ru/volgorobot/vrcatalog/view/MainActivity.java +++ b/app/src/main/java/ru/volgorobot/vrcatalog/view/MainActivity.java @@ -45,6 +45,7 @@ public class MainActivity extends AppCompatActivity private ImageView mConnectionErrorImageView; private ViewGroup mTreeViewContainer; private TextView mErrorTextView; + private int treeNodeIndex; @Override protected void onCreate(Bundle savedInstanceState) { @@ -206,6 +207,10 @@ public class MainActivity extends AppCompatActivity return true; } + @Override + public int incTreeNodeIndex() { + return treeNodeIndex++; + } } diff --git a/app/src/main/java/ru/volgorobot/vrcatalog/view/SearchableActivity.java b/app/src/main/java/ru/volgorobot/vrcatalog/view/SearchableActivity.java index f411fcd..b6846bb 100644 --- a/app/src/main/java/ru/volgorobot/vrcatalog/view/SearchableActivity.java +++ b/app/src/main/java/ru/volgorobot/vrcatalog/view/SearchableActivity.java @@ -147,4 +147,9 @@ public class SearchableActivity extends AppCompatActivity implements MainContrac } return super.onOptionsItemSelected(item); } + + @Override + public int incTreeNodeIndex() { + return 0; + } } diff --git a/app/src/main/res/layout/app_bar_main.xml b/app/src/main/res/layout/app_bar_main.xml index 45fe46a..b87ac6b 100644 --- a/app/src/main/res/layout/app_bar_main.xml +++ b/app/src/main/res/layout/app_bar_main.xml @@ -16,7 +16,7 @@ android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" - android:theme="@style/CustomSearchStyle" + android:theme="@style/MainActivity" app:titleTextColor="@android:color/white" app:popupTheme="@style/AppTheme.PopupOverlay" /> diff --git a/app/src/main/res/layout/first_level_item.xml b/app/src/main/res/layout/first_level_item.xml index bac1b57..15caa90 100644 --- a/app/src/main/res/layout/first_level_item.xml +++ b/app/src/main/res/layout/first_level_item.xml @@ -1,5 +1,6 @@ diff --git a/app/src/main/res/layout/second_level_item.xml b/app/src/main/res/layout/second_level_item.xml index 213ff48..66db43e 100644 --- a/app/src/main/res/layout/second_level_item.xml +++ b/app/src/main/res/layout/second_level_item.xml @@ -1,5 +1,6 @@ @android:color/black @android:color/black - - -