Made multicolored rows (gray-white), the text in SearchView is now white.

This commit is contained in:
ChronosX88 2019-02-25 16:29:52 +04:00
parent 798ceff79f
commit 9d7e85a80c
No known key found for this signature in database
GPG Key ID: 8F92E090A87804AA
12 changed files with 60 additions and 5 deletions

View File

@ -20,6 +20,7 @@ public interface MainContract {
void onFailureAnswer(int errorCode);
void refreshTree();
void startActivityByIntent(Intent intent);
int incTreeNodeIndex();
}
interface Presenter {

View File

@ -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();
}
}

View File

@ -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

View File

@ -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

View File

@ -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++;
}
}

View File

@ -147,4 +147,9 @@ public class SearchableActivity extends AppCompatActivity implements MainContrac
}
return super.onOptionsItemSelected(item);
}
@Override
public int incTreeNodeIndex() {
return 0;
}
}

View File

@ -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" />

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/parent_node_container_1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="?android:selectableItemBackground">

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/parent_node_container_2"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="vertical"

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/parent_node_container_3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"

View File

@ -25,7 +25,9 @@
<item name="android:textColorPrimary">@android:color/black</item>
<item name="android:textColorSecondary">@android:color/black</item>
</style>
<style name="CustomSearchStyle" parent="AppTheme">
<style name="MainActivity" parent="AppTheme.NoActionBar">
<item name="android:editTextColor">@android:color/white</item>
<item name="android:textColorHint">@android:color/white</item>
<item name="suggestionRowLayout">@layout/light_suggestion_hint</item>
<item name="colorControlNormal">@android:color/white</item>
<item name="android:colorControlNormal">@android:color/white</item>

View File

@ -8,9 +8,6 @@
<style name="MainActivity" parent="AppTheme.NoActionBar">
<item name="android:editTextColor">@android:color/white</item>
<item name="android:textColorHint">@android:color/white</item>
</style>
<style name="CustomSearchStyle" parent="AppTheme">
<item name="suggestionRowLayout">@layout/light_suggestion_hint</item>
<item name="colorControlNormal">@android:color/white</item>
</style>