diff --git a/.idea/assetWizardSettings.xml b/.idea/assetWizardSettings.xml
index 978ee3f..4367245 100644
--- a/.idea/assetWizardSettings.xml
+++ b/.idea/assetWizardSettings.xml
@@ -18,7 +18,7 @@
@@ -28,8 +28,8 @@
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 35eb1dd..8306744 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -2,5 +2,6 @@
+
\ No newline at end of file
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 01295d9..2cbde48 100644
--- a/app/src/main/java/ru/volgorobot/vrcatalog/view/MainActivity.java
+++ b/app/src/main/java/ru/volgorobot/vrcatalog/view/MainActivity.java
@@ -9,6 +9,7 @@ import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.DrawerLayout;
+import android.support.v4.widget.NestedScrollView;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
@@ -16,10 +17,14 @@ import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
+import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
+import android.view.View;
import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
@@ -39,6 +44,9 @@ public class MainActivity extends AppCompatActivity
private TreeView treeView;
private TreeNode rootNode = TreeNode.root();
private SwipeRefreshLayout mSwipeRefreshLayout;
+ private ImageView mConnectionErrorImageView;
+ private ViewGroup mTreeViewContainer;
+ private TextView mErrorTextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -56,7 +64,7 @@ public class MainActivity extends AppCompatActivity
NavigationView navigationView = findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
- mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
+ mSwipeRefreshLayout = findViewById(R.id.swipeRefreshLayout);
mSwipeRefreshLayout.setOnRefreshListener(MainActivity.this);
mSwipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
@@ -64,11 +72,14 @@ public class MainActivity extends AppCompatActivity
treeView = new TreeView(rootNode, MainActivity.this, new NodeViewFactory(MainActivity.this, this, this.mPresenter.getCoreModel()));
treeView.setItemAnimator(new DefaultItemAnimator());
- ((ViewGroup) findViewById(R.id.treeViewContainer)).addView(treeView.getView());
+ mTreeViewContainer = findViewById(R.id.treeViewContainer);
+ mTreeViewContainer.addView(treeView.getView());
mSwipeRefreshLayout.setRefreshing(true);
mPresenter.getFirstLevel();
}
+
+
@Override
public void onBackPressed() {
DrawerLayout drawer = findViewById(R.id.drawer_layout);
@@ -111,27 +122,42 @@ public class MainActivity extends AppCompatActivity
@Override
public void onRefresh() {
+ mConnectionErrorImageView.setVisibility(View.INVISIBLE);
+ mErrorTextView.setVisibility(View.INVISIBLE);
+ mTreeViewContainer.setVisibility(View.VISIBLE);
mPresenter.getFirstLevel();
}
public void onFailureAnswer(int errorCode) {
switch (errorCode) {
case 1: {
+ mErrorTextView.setText("Ошибка сети. Проверьте подключение к сети или данные подключения к API!");
Toast.makeText(MainActivity.this, "Ошибка сети. Проверьте подключение к сети или данные подключения к API!", Toast.LENGTH_LONG).show();
Log.e("MainActivity", "Network Error! Re-check your connection credentials or network settings!");
mSwipeRefreshLayout.setRefreshing(false);
+ mTreeViewContainer.setVisibility(View.GONE);
+ mConnectionErrorImageView.setVisibility(View.VISIBLE);
+ mErrorTextView.setVisibility(View.VISIBLE);
break;
}
case 2: {
+ mErrorTextView.setText("Ответ от сервера неверен! Перепроверьте данные подключения!");
Toast.makeText(MainActivity.this, "Ответ от сервера неверен! Перепроверьте данные подключения!", Toast.LENGTH_LONG).show();
Log.e("MainActivity", "Answer of server is wrong! Re-check your connection credentials!");
mSwipeRefreshLayout.setRefreshing(false);
+ mTreeViewContainer.setVisibility(View.GONE);
+ mConnectionErrorImageView.setVisibility(View.VISIBLE);
+ mErrorTextView.setVisibility(View.VISIBLE);
break;
}
case 3: {
+ mErrorTextView.setText("Вы ввели неверный URL. Пример: http://example.ru");
Toast.makeText(this, "Вы ввели неверный URL. Пример: http://example.ru", Toast.LENGTH_LONG).show();
Log.e("MainActivity", "Invalid-formatted URL. Please, check URL (change his if it need) and try again.");
mSwipeRefreshLayout.setRefreshing(false);
+ mTreeViewContainer.setVisibility(View.GONE);
+ mConnectionErrorImageView.setVisibility(View.VISIBLE);
+ mErrorTextView.setVisibility(View.VISIBLE);
break;
}
}
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 612fe25..a83a8e1 100644
--- a/app/src/main/java/ru/volgorobot/vrcatalog/view/SearchableActivity.java
+++ b/app/src/main/java/ru/volgorobot/vrcatalog/view/SearchableActivity.java
@@ -2,13 +2,17 @@ package ru.volgorobot.vrcatalog.view;
import android.app.SearchManager;
import android.content.Intent;
+import android.support.v4.widget.NestedScrollView;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.DefaultItemAnimator;
import android.util.Log;
import android.view.MenuItem;
+import android.view.View;
import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
@@ -27,6 +31,9 @@ public class SearchableActivity extends AppCompatActivity implements MainContrac
private String detailName;
private TreeView treeView;
private TreeNode rootNode = TreeNode.root();
+ private ImageView mConnectionErrorImageView;
+ private NestedScrollView mTreeViewContainer;
+ private TextView mErrorTextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -41,6 +48,10 @@ public class SearchableActivity extends AppCompatActivity implements MainContrac
mSwipeRefreshLayout.setOnRefreshListener(SearchableActivity.this);
mSwipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
+ mConnectionErrorImageView = findViewById(R.id.searchableConnectionErrorImageView);
+ mTreeViewContainer = findViewById(R.id.searchableTreeViewContainer);
+ mErrorTextView = findViewById(R.id.searchableErrorTextView);
+
treeView = new TreeView(rootNode, SearchableActivity.this, new SearchableNodeViewFactory(SearchableActivity.this, this));
treeView.setItemAnimator(new DefaultItemAnimator());
((ViewGroup) findViewById(R.id.searchableTreeViewContainer)).addView(treeView.getView());
@@ -62,20 +73,32 @@ public class SearchableActivity extends AppCompatActivity implements MainContrac
public void onFailureAnswer(int errorCode) {
switch (errorCode) {
case 1: {
- Toast.makeText(SearchableActivity.this, "Ошибка сети. Проверьте подключение к сети или данные подключения к API!", Toast.LENGTH_LONG).show();
+ mErrorTextView.setText("Ошибка сети. Проверьте подключение к сети или данные подключения к API!");
+ //Toast.makeText(SearchableActivity.this, "Ошибка сети. Проверьте подключение к сети или данные подключения к API!", Toast.LENGTH_LONG).show();
Log.e("VRCatalog", "Network Error! Re-check your connection credentials or network settings! Technical info: null");
mSwipeRefreshLayout.setRefreshing(false);
+ mTreeViewContainer.setVisibility(View.GONE);
+ mConnectionErrorImageView.setVisibility(View.VISIBLE);
+ mErrorTextView.setVisibility(View.VISIBLE);
break;
}
case 2: {
- Toast.makeText(SearchableActivity.this, "Ответ от сервера неверен! Перепроверьте данные подключения!", Toast.LENGTH_LONG).show();
+ mErrorTextView.setText("Ответ от сервера неверен! Перепроверьте данные подключения!");
+ //Toast.makeText(SearchableActivity.this, "Ответ от сервера неверен! Перепроверьте данные подключения!", Toast.LENGTH_LONG).show();
Log.e("VRCatalog", "Answer of server is wrong! Re-check your connection credentials! Technical info: null");
mSwipeRefreshLayout.setRefreshing(false);
+ mTreeViewContainer.setVisibility(View.GONE);
+ mConnectionErrorImageView.setVisibility(View.VISIBLE);
+ mErrorTextView.setVisibility(View.VISIBLE);
break;
}
case 3: {
- Toast.makeText(SearchableActivity.this, "Вы ввели неверный URL. Пример: http://example.ru", Toast.LENGTH_LONG).show();
+ mErrorTextView.setText("Вы ввели неверный URL. Пример: http://example.ru");
+ //Toast.makeText(SearchableActivity.this, "Вы ввели неверный URL. Пример: http://example.ru", Toast.LENGTH_LONG).show();
mSwipeRefreshLayout.setRefreshing(false);
+ mTreeViewContainer.setVisibility(View.GONE);
+ mConnectionErrorImageView.setVisibility(View.VISIBLE);
+ mErrorTextView.setVisibility(View.VISIBLE);
break;
}
}
@@ -83,6 +106,9 @@ public class SearchableActivity extends AppCompatActivity implements MainContrac
@Override
public void onRefresh() {
+ mConnectionErrorImageView.setVisibility(View.INVISIBLE);
+ mErrorTextView.setVisibility(View.INVISIBLE);
+ mTreeViewContainer.setVisibility(View.VISIBLE);
searchablePresenter.fetchDetailsTreeByName(detailName);
}
diff --git a/app/src/main/res/layout/activity_searchable.xml b/app/src/main/res/layout/activity_searchable.xml
index 3af0744..8afd301 100644
--- a/app/src/main/res/layout/activity_searchable.xml
+++ b/app/src/main/res/layout/activity_searchable.xml
@@ -10,12 +10,45 @@
android:orientation="horizontal"
android:id="@+id/searchableSwipeRefreshLayout">
-
-
+ android:layout_height="match_parent">
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml
index 88dce18..98a6740 100644
--- a/app/src/main/res/layout/content_main.xml
+++ b/app/src/main/res/layout/content_main.xml
@@ -10,12 +10,53 @@
android:orientation="horizontal"
android:id="@+id/swipeRefreshLayout">
-
-
+ android:layout_height="match_parent">
+
+
+
+
+
+
+
+
+
\ No newline at end of file