Removed multicolored rows (as a result of testing, this is terrible)

This commit is contained in:
ChronosX88 2019-02-25 18:20:18 +04:00
parent 06f3df407c
commit f29121ac7c
No known key found for this signature in database
GPG Key ID: 8F92E090A87804AA
9 changed files with 29 additions and 97 deletions

View File

@ -20,7 +20,6 @@ public interface MainContract {
void onFailureAnswer(int errorCode); void onFailureAnswer(int errorCode);
void refreshTree(); void refreshTree();
void startActivityByIntent(Intent intent); void startActivityByIntent(Intent intent);
int incTreeNodeIndex();
} }
interface Presenter { interface Presenter {
@ -68,8 +67,6 @@ public interface MainContract {
void setTreeViewChildren(ArrayList<TreeNode> children); void setTreeViewChildren(ArrayList<TreeNode> children);
void onFailureAnswer(int errorCode); void onFailureAnswer(int errorCode);
void swipeLayoutSetRefreshing(boolean state); void swipeLayoutSetRefreshing(boolean state);
int incTreeNodeIndex();
} }
interface ItemPresenter { interface ItemPresenter {

View File

@ -18,16 +18,12 @@ import ru.volgorobot.vrcatalog.model.FirstLevelModel;
public class FirstLevelNodeViewBinder extends BaseNodeViewBinder implements MainContract.ViewBinder { public class FirstLevelNodeViewBinder extends BaseNodeViewBinder implements MainContract.ViewBinder {
TextView textView; TextView textView;
ImageView imageView; ImageView imageView;
RelativeLayout layout;
ViewBinderPresenter viewBinderPresenter; ViewBinderPresenter viewBinderPresenter;
private MainContract.MainActivityView mView;
public FirstLevelNodeViewBinder(View itemView, MainContract.MainActivityView mView, Context context) { public FirstLevelNodeViewBinder(View itemView, MainContract.MainActivityView mView, Context context) {
super(itemView); super(itemView);
textView = (TextView) itemView.findViewById(R.id.node_name_view); textView = (TextView) itemView.findViewById(R.id.node_name_view);
imageView = (ImageView) itemView.findViewById(R.id.arrow_img); 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); viewBinderPresenter = new ViewBinderPresenter(mView, this, context);
} }
@ -40,13 +36,6 @@ public class FirstLevelNodeViewBinder extends BaseNodeViewBinder implements Main
public void bindView(TreeNode treeNode) { public void bindView(TreeNode treeNode) {
textView.setText(treeNode.getValue().toString()); textView.setText(treeNode.getValue().toString());
imageView.setRotation(treeNode.isExpanded() ? 90 : 0); 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 @Override

View File

@ -17,8 +17,6 @@ import ru.volgorobot.vrcatalog.model.SecondLevelModel;
public class SecondLevelNodeViewBinder extends BaseNodeViewBinder implements MainContract.ViewBinder { public class SecondLevelNodeViewBinder extends BaseNodeViewBinder implements MainContract.ViewBinder {
TextView textView; TextView textView;
ImageView imageView; ImageView imageView;
RelativeLayout layout;
private MainContract.MainActivityView mView;
MainContract.LevelLoaderPresenter viewBinderPresenter; MainContract.LevelLoaderPresenter viewBinderPresenter;
@ -26,8 +24,6 @@ public class SecondLevelNodeViewBinder extends BaseNodeViewBinder implements Mai
super(itemView); super(itemView);
textView = (TextView) itemView.findViewById(R.id.node_name_view); textView = (TextView) itemView.findViewById(R.id.node_name_view);
imageView = (ImageView) itemView.findViewById(R.id.arrow_img); 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); viewBinderPresenter = new ViewBinderPresenter(mView, this, context);
} }
@ -40,13 +36,6 @@ public class SecondLevelNodeViewBinder extends BaseNodeViewBinder implements Mai
public void bindView(final TreeNode treeNode) { public void bindView(final TreeNode treeNode) {
textView.setText(treeNode.getValue().toString()); textView.setText(treeNode.getValue().toString());
imageView.setRotation(treeNode.isExpanded() ? 90 : 0); 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 @Override

View File

@ -15,16 +15,12 @@ import ru.volgorobot.vrcatalog.model.ThirdLevelModel;
public class ThirdLevelNodeViewBinder extends BaseNodeViewBinder implements MainContract.ViewBinder { public class ThirdLevelNodeViewBinder extends BaseNodeViewBinder implements MainContract.ViewBinder {
TextView textView; TextView textView;
RelativeLayout layout;
private MainContract.MainActivityView mView;
MainContract.LevelLoaderPresenter viewBinderPresenter; MainContract.LevelLoaderPresenter viewBinderPresenter;
public ThirdLevelNodeViewBinder(View itemView, Context context, MainContract.MainActivityView mView) { public ThirdLevelNodeViewBinder(View itemView, Context context, MainContract.MainActivityView mView) {
super(itemView); super(itemView);
viewBinderPresenter = new ViewBinderPresenter(mView, this, context); viewBinderPresenter = new ViewBinderPresenter(mView, this, context);
textView = itemView.findViewById(R.id.node_name_view); textView = itemView.findViewById(R.id.node_name_view);
layout = itemView.findViewById(R.id.parent_node_container_3);
this.mView = mView;
} }
@Override @Override
@ -35,13 +31,6 @@ public class ThirdLevelNodeViewBinder extends BaseNodeViewBinder implements Main
@Override @Override
public void bindView(final TreeNode treeNode) { public void bindView(final TreeNode treeNode) {
textView.setText(treeNode.getValue().toString()); 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 @Override

View File

@ -32,7 +32,7 @@ public class ViewBinderPresenter implements MainContract.LevelLoaderPresenter {
@Override @Override
public void fetchSecondLevel(FirstLevelModel firstLevelModel, TreeNode treeNode) { public void fetchSecondLevel(FirstLevelModel firstLevelModel, TreeNode treeNode) {
new AsyncTask<FirstLevelModel, Void, ResultWithErrorCode<ArrayList<SecondLevelModel>>>() { new AsyncTask<FirstLevelModel, Void, ResultWithErrorCode<ArrayList<TreeNode>>>() {
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
super.onPreExecute(); super.onPreExecute();
@ -40,31 +40,32 @@ public class ViewBinderPresenter implements MainContract.LevelLoaderPresenter {
} }
@Override @Override
protected ResultWithErrorCode<ArrayList<SecondLevelModel>> doInBackground(FirstLevelModel... firstLevelModel) { protected ResultWithErrorCode<ArrayList<TreeNode>> doInBackground(FirstLevelModel... firstLevelModel) {
ArrayList<SecondLevelModel> secondLevelModels = null; ArrayList<SecondLevelModel> secondLevelModels = null;
ArrayList<TreeNode> treeNodes = new ArrayList<>();
try { try {
secondLevelModels = coreModel.fetchSecondLevelByParentID(firstLevelModel[0].getID()); secondLevelModels = coreModel.fetchSecondLevelByParentID(firstLevelModel[0].getID());
} catch (NetworkErrorException networkErrorException) { } catch (NetworkErrorException networkErrorException) {
return new ResultWithErrorCode<>(secondLevelModels, networkErrorException.getErrorCode()); return new ResultWithErrorCode<>(null, networkErrorException.getErrorCode());
} catch (NullPointerException nullPointerException) { } catch (NullPointerException nullPointerException) {
return new ResultWithErrorCode<>(secondLevelModels, 3); return new ResultWithErrorCode<>(null, 3);
} }
return new ResultWithErrorCode<>(secondLevelModels, 0); for (int i = 0; i < secondLevelModels.size(); i++) {
TreeNode treeNode = new TreeNode(secondLevelModels.get(i));
treeNode.setLevel(1);
treeNodes.add(treeNode);
}
return new ResultWithErrorCode<>(treeNodes, 0);
} }
@Override @Override
protected void onPostExecute(ResultWithErrorCode<ArrayList<SecondLevelModel>> result) { protected void onPostExecute(ResultWithErrorCode<ArrayList<TreeNode>> result) {
super.onPostExecute(result); super.onPostExecute(result);
switch (result.getErrorCode()) { switch (result.getErrorCode()) {
case 0: { case 0: {
ArrayList<TreeNode> treeNodes = new ArrayList<>(); treeNode.setChildren(result.getData());
for (int i = 0; i < result.getData().size(); i++) {
TreeNode treeNode1 = new TreeNode(result.getData().get(i));
treeNode1.setLevel(1);
treeNodes.add(treeNode1);
}
treeNode.setChildren(treeNodes);
mView.refreshTree(); mView.refreshTree();
viewBinder.rotateImageView(); viewBinder.rotateImageView();
break; break;
@ -89,7 +90,7 @@ public class ViewBinderPresenter implements MainContract.LevelLoaderPresenter {
@Override @Override
public void fetchThirdLevel(SecondLevelModel secondLevelModel, TreeNode treeNode) { public void fetchThirdLevel(SecondLevelModel secondLevelModel, TreeNode treeNode) {
new AsyncTask<SecondLevelModel, Void, ResultWithErrorCode<ArrayList<ThirdLevelModel>>>() { new AsyncTask<SecondLevelModel, Void, ResultWithErrorCode<ArrayList<TreeNode>>>() {
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
super.onPreExecute(); super.onPreExecute();
@ -97,30 +98,32 @@ public class ViewBinderPresenter implements MainContract.LevelLoaderPresenter {
} }
@Override @Override
protected ResultWithErrorCode<ArrayList<ThirdLevelModel>> doInBackground(SecondLevelModel... secondLevelModel) { protected ResultWithErrorCode<ArrayList<TreeNode>> doInBackground(SecondLevelModel... secondLevelModel) {
ArrayList<ThirdLevelModel> thirdLevelModels = null; ArrayList<ThirdLevelModel> thirdLevelModels = null;
ArrayList<TreeNode> treeNodes = new ArrayList<>();
try { try {
thirdLevelModels = coreModel.fetchThirdLevelByParentID(secondLevelModel[0].getID()); thirdLevelModels = coreModel.fetchThirdLevelByParentID(secondLevelModel[0].getID());
} catch (NetworkErrorException networkErrorException) { } catch (NetworkErrorException networkErrorException) {
return new ResultWithErrorCode<>(thirdLevelModels, networkErrorException.getErrorCode()); return new ResultWithErrorCode<>(null, networkErrorException.getErrorCode());
} catch (NullPointerException nullPointerException) { } catch (NullPointerException nullPointerException) {
return new ResultWithErrorCode<>(thirdLevelModels, 3); return new ResultWithErrorCode<>(null, 3);
} }
return new ResultWithErrorCode<>(thirdLevelModels, 0);
for (int i = 0; i < thirdLevelModels.size(); i++) {
TreeNode treeNode1 = new TreeNode(thirdLevelModels.get(i));
treeNode1.setLevel(2);
treeNodes.add(treeNode1);
}
return new ResultWithErrorCode<>(treeNodes, 0);
} }
@Override @Override
protected void onPostExecute(ResultWithErrorCode<ArrayList<ThirdLevelModel>> result) { protected void onPostExecute(ResultWithErrorCode<ArrayList<TreeNode>> result) {
super.onPostExecute(result); super.onPostExecute(result);
switch (result.getErrorCode()) { switch (result.getErrorCode()) {
case 0: { case 0: {
ArrayList<TreeNode> treeNodes = new ArrayList<>(); treeNode.setChildren(result.getData());
for (int i = 0; i < result.getData().size(); i++) {
TreeNode treeNode1 = new TreeNode(result.getData().get(i));
treeNode1.setLevel(2);
treeNodes.add(treeNode1);
}
treeNode.setChildren(treeNodes);
mView.refreshTree(); mView.refreshTree();
viewBinder.rotateImageView(); viewBinder.rotateImageView();
break; break;

View File

@ -14,15 +14,11 @@ import ru.volgorobot.vrcatalog.R;
public class FirstLevelNodeViewBinder extends BaseNodeViewBinder { public class FirstLevelNodeViewBinder extends BaseNodeViewBinder {
TextView textView; TextView textView;
ImageView imageView; ImageView imageView;
RelativeLayout layout;
MainContract.MainActivityView mView;
public FirstLevelNodeViewBinder(View itemView, MainContract.MainActivityView mView) { public FirstLevelNodeViewBinder(View itemView, MainContract.MainActivityView mView) {
super(itemView); super(itemView);
textView = (TextView) itemView.findViewById(R.id.node_name_view); textView = (TextView) itemView.findViewById(R.id.node_name_view);
imageView = (ImageView) itemView.findViewById(R.id.arrow_img); imageView = (ImageView) itemView.findViewById(R.id.arrow_img);
layout = itemView.findViewById(R.id.parent_node_container_1);
this.mView = mView;
} }
@Override @Override
@ -34,13 +30,6 @@ public class FirstLevelNodeViewBinder extends BaseNodeViewBinder {
public void bindView(TreeNode treeNode) { public void bindView(TreeNode treeNode) {
textView.setText(treeNode.getValue().toString()); textView.setText(treeNode.getValue().toString());
imageView.setRotation(treeNode.isExpanded() ? 90 : 0); 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 @Override

View File

@ -14,15 +14,11 @@ import ru.volgorobot.vrcatalog.R;
public class SecondLevelNodeViewBinder extends BaseNodeViewBinder { public class SecondLevelNodeViewBinder extends BaseNodeViewBinder {
TextView textView; TextView textView;
ImageView imageView; ImageView imageView;
RelativeLayout layout;
MainContract.MainActivityView mView;
public SecondLevelNodeViewBinder(View itemView, MainContract.MainActivityView mView) { public SecondLevelNodeViewBinder(View itemView, MainContract.MainActivityView mView) {
super(itemView); super(itemView);
textView = (TextView) itemView.findViewById(R.id.node_name_view); textView = (TextView) itemView.findViewById(R.id.node_name_view);
imageView = (ImageView) itemView.findViewById(R.id.arrow_img); imageView = (ImageView) itemView.findViewById(R.id.arrow_img);
layout = itemView.findViewById(R.id.parent_node_container_2);
this.mView = mView;
} }
@Override @Override
@ -34,13 +30,6 @@ public class SecondLevelNodeViewBinder extends BaseNodeViewBinder {
public void bindView(TreeNode treeNode) { public void bindView(TreeNode treeNode) {
textView.setText(treeNode.getValue().toString()); textView.setText(treeNode.getValue().toString());
imageView.setRotation(treeNode.isExpanded() ? 90 : 0); 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 @Override

View File

@ -45,7 +45,6 @@ public class MainActivity extends AppCompatActivity
private ImageView mConnectionErrorImageView; private ImageView mConnectionErrorImageView;
private ViewGroup mTreeViewContainer; private ViewGroup mTreeViewContainer;
private TextView mErrorTextView; private TextView mErrorTextView;
private int treeNodeIndex;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -125,7 +124,6 @@ public class MainActivity extends AppCompatActivity
@Override @Override
public void onRefresh() { public void onRefresh() {
treeNodeIndex = 0;
mConnectionErrorImageView.setVisibility(View.INVISIBLE); mConnectionErrorImageView.setVisibility(View.INVISIBLE);
mErrorTextView.setVisibility(View.INVISIBLE); mErrorTextView.setVisibility(View.INVISIBLE);
mTreeViewContainer.setVisibility(View.VISIBLE); mTreeViewContainer.setVisibility(View.VISIBLE);
@ -207,11 +205,6 @@ public class MainActivity extends AppCompatActivity
search.setQueryHint("Имя детали"); search.setQueryHint("Имя детали");
return true; return true;
} }
@Override
public int incTreeNodeIndex() {
return treeNodeIndex++;
}
} }

View File

@ -35,7 +35,6 @@ public class SearchableActivity extends AppCompatActivity implements MainContrac
private ImageView mConnectionErrorImageView; private ImageView mConnectionErrorImageView;
private NestedScrollView mTreeViewContainer; private NestedScrollView mTreeViewContainer;
private TextView mErrorTextView; private TextView mErrorTextView;
private int treeNodeIndex;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -148,9 +147,4 @@ public class SearchableActivity extends AppCompatActivity implements MainContrac
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@Override
public int incTreeNodeIndex() {
return treeNodeIndex++;
}
} }