Сделано обновление дерева

This commit is contained in:
ChronosX88 2019-01-03 12:33:25 +04:00
parent 4833269e0f
commit 79a32d590b
No known key found for this signature in database
GPG Key ID: 8F92E090A87804AA
3 changed files with 9 additions and 39 deletions

View File

@ -1,35 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="NullableNotNullManager"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="7">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="6">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

View File

@ -108,12 +108,13 @@ public class MainActivity extends AppCompatActivity
firstLevelNodes.add(new TreeNode(firstLevelObjects.get(i).getName())); firstLevelNodes.add(new TreeNode(firstLevelObjects.get(i).getName()));
} }
ViewGroup containerView = findViewById(R.id.treeViewContainer);
containerView.removeAllViews();
TreeNode root = TreeNode.root(); TreeNode root = TreeNode.root();
root.addChildren(firstLevelNodes); root.addChildren(firstLevelNodes);
AndroidTreeView treeView = new AndroidTreeView(MainActivity.this, root); AndroidTreeView treeView = new AndroidTreeView(MainActivity.this, root);
treeView.setDefaultAnimation(true); treeView.setDefaultAnimation(true);
treeView.setDefaultContainerStyle(R.style.TreeNodeStyle); treeView.setDefaultContainerStyle(R.style.TreeNodeStyle);
ViewGroup containerView = findViewById(R.id.treeViewContainer);
containerView.addView(treeView.getView()); containerView.addView(treeView.getView());
} }
@ -127,14 +128,6 @@ public class MainActivity extends AppCompatActivity
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
// //
} }
mSwipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
mSwipeRefreshLayout.setRefreshing(false);
}
});
} }
private void refreshTree(boolean clean) throws IllegalStateException { private void refreshTree(boolean clean) throws IllegalStateException {
@ -165,6 +158,12 @@ public class MainActivity extends AppCompatActivity
if(response != null) { if(response != null) {
try { try {
firstLevelObjects.addAll(response.body()); firstLevelObjects.addAll(response.body());
mSwipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
mSwipeRefreshLayout.setRefreshing(false);
}
});
} catch(Exception e) { } catch(Exception e) {
Toast.makeText(MainActivity.this, "Ответ от сервера неверен! Перепроверьте данные подключения!", Toast.LENGTH_LONG).show(); Toast.makeText(MainActivity.this, "Ответ от сервера неверен! Перепроверьте данные подключения!", Toast.LENGTH_LONG).show();
Log.e("VRCatalog", "Answer of server is wrong! Re-check your connection credentials! Error: " + response.message()); Log.e("VRCatalog", "Answer of server is wrong! Re-check your connection credentials! Error: " + response.message());