Fixed infinity refreshing (when error occured) for SwipeRefreshLayout.
This commit is contained in:
parent
2d823ac11c
commit
0279a95ab3
Binary file not shown.
@ -143,7 +143,7 @@ public class MainActivity extends AppCompatActivity
|
|||||||
|
|
||||||
private void refreshTree(boolean clean) throws IllegalStateException {
|
private void refreshTree(boolean clean) throws IllegalStateException {
|
||||||
|
|
||||||
SwipeRefreshLayout mSwipeRefreshLayout = findViewById(R.id.swipeRefreshLayout);
|
final SwipeRefreshLayout mSwipeRefreshLayout = findViewById(R.id.swipeRefreshLayout);
|
||||||
mSwipeRefreshLayout.setRefreshing(true);
|
mSwipeRefreshLayout.setRefreshing(true);
|
||||||
if(clean) {
|
if(clean) {
|
||||||
List<TreeNode> list = new ArrayList<>(root.getChildren());
|
List<TreeNode> list = new ArrayList<>(root.getChildren());
|
||||||
@ -176,10 +176,12 @@ public class MainActivity extends AppCompatActivity
|
|||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
Toast.makeText(MainActivity.this, "Ответ от сервера неверен! Перепроверьте данные подключения!", Toast.LENGTH_LONG).show();
|
Toast.makeText(MainActivity.this, "Ответ от сервера неверен! Перепроверьте данные подключения!", Toast.LENGTH_LONG).show();
|
||||||
Log.e("ERROR", "Answer of server is wrong! Re-check your connection credentials! Error: " + response.message());
|
Log.e("ERROR", "Answer of server is wrong! Re-check your connection credentials! Error: " + response.message());
|
||||||
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
}
|
}
|
||||||
fillRootNode();
|
fillRootNode();
|
||||||
} else {
|
} else {
|
||||||
Log.e("ERROR", "Что-то пошло не так...");
|
Log.e("ERROR", "Что-то пошло не так...");
|
||||||
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -188,6 +190,7 @@ public class MainActivity extends AppCompatActivity
|
|||||||
public void onFailure(Call<List<FirstLevelModel>> call, Throwable t) {
|
public void onFailure(Call<List<FirstLevelModel>> call, Throwable t) {
|
||||||
Toast.makeText(MainActivity.this, "Ошибка сети. Проверьте подключение к сети или данные подключения к API!", Toast.LENGTH_LONG).show();
|
Toast.makeText(MainActivity.this, "Ошибка сети. Проверьте подключение к сети или данные подключения к API!", Toast.LENGTH_LONG).show();
|
||||||
Log.e("ERROR", "getFirstLevel() failed!");
|
Log.e("ERROR", "getFirstLevel() failed!");
|
||||||
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user