Reports on error ui.
This commit is contained in:
parent
8a04ae371c
commit
ddf4eef07d
3 changed files with 31 additions and 4 deletions
|
@ -12,7 +12,7 @@
|
|||
<string name="no_route">Rota yok</string>
|
||||
<string name="delete_target_point">Hedef kaldırmak</string>
|
||||
<string name="target_point">Ara nokta %1$s</string>
|
||||
<string name="intermediate_point">Intermediate hedef % 1 $ s</string>
|
||||
<string name="intermediate_point">Intermediate hedef %1$s</string>
|
||||
<string name="context_menu_item_last_intermediate_point">Son ara nokta olarak ekle</string>
|
||||
<string name="context_menu_item_first_intermediate_point">İlk ara hedef eklemek</string>
|
||||
<string name="add_as_last_destination_point">Son ara nokta olarak ekle</string>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="data_is_not_available">Data is not available</string>
|
||||
<string name="shared_string_remove">Remove</string>
|
||||
<string name="clear_updates_proposition_message">"You can remove downloaded updates and get back to the original map edition"</string>
|
||||
<string name="add_time_span">Add time span</string>
|
||||
|
@ -2153,5 +2154,5 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
|
|||
<string name="select_month_and_country">Select month and country</string>
|
||||
<string name="number_of_contributors">Number of contributors</string>
|
||||
<string name="number_of_edits">Number of edits</string>
|
||||
<string name="reports_for">Report for:</string>
|
||||
<string name="reports_for">Report for</string>
|
||||
</resources>
|
||||
|
|
|
@ -147,10 +147,24 @@ public class ReportsFragment extends BaseOsmAndFragment implements SearchSelecti
|
|||
disableProgress();
|
||||
}
|
||||
};
|
||||
GetJsonAsyncTask.OnErrorListener onErrorListener =
|
||||
new GetJsonAsyncTask.OnErrorListener() {
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
if (contributorsTextView != null) {
|
||||
contributorsTextView.setText(R.string.data_is_not_available);
|
||||
}
|
||||
if (editsTextView != null) {
|
||||
editsTextView.setText(R.string.data_is_not_available);
|
||||
}
|
||||
disableProgress();
|
||||
}
|
||||
};
|
||||
enableProgress();
|
||||
GetJsonAsyncTask<Protocol.TotalChangesByMonthResponse> totalChangesByMontAsyncTask =
|
||||
new GetJsonAsyncTask<>(Protocol.TotalChangesByMonthResponse.class);
|
||||
totalChangesByMontAsyncTask.setOnResponseListener(onResponseListener);
|
||||
totalChangesByMontAsyncTask.setOnErrorListener(onErrorListener);
|
||||
String finalUrl = String.format(TOTAL_CHANGES_BY_MONTH_URL_PATTERN, monthUrlString, regionUrlString);
|
||||
totalChangesByMontAsyncTask.execute(finalUrl);
|
||||
}
|
||||
|
@ -262,6 +276,8 @@ public class ReportsFragment extends BaseOsmAndFragment implements SearchSelecti
|
|||
private final Class<P> protocolClass;
|
||||
private final Gson gson = new Gson();
|
||||
private OnResponseListener<P> onResponseListener;
|
||||
private OnErrorListener onErrorListener;
|
||||
private volatile String error;
|
||||
|
||||
public GetJsonAsyncTask(Class<P> protocolClass) {
|
||||
this.protocolClass = protocolClass;
|
||||
|
@ -270,7 +286,7 @@ public class ReportsFragment extends BaseOsmAndFragment implements SearchSelecti
|
|||
@Override
|
||||
protected P doInBackground(String... params) {
|
||||
StringBuilder response = new StringBuilder();
|
||||
String error = NetworkUtils.sendGetRequest(params[0], null, response);
|
||||
error = NetworkUtils.sendGetRequest(params[0], null, response);
|
||||
if (error == null) {
|
||||
return gson.fromJson(response.toString(), protocolClass);
|
||||
}
|
||||
|
@ -280,8 +296,10 @@ public class ReportsFragment extends BaseOsmAndFragment implements SearchSelecti
|
|||
|
||||
@Override
|
||||
protected void onPostExecute(P protocol) {
|
||||
if (onResponseListener != null) {
|
||||
if (protocol != null) {
|
||||
onResponseListener.onResponse(protocol);
|
||||
} else {
|
||||
onErrorListener.onError(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -289,9 +307,17 @@ public class ReportsFragment extends BaseOsmAndFragment implements SearchSelecti
|
|||
this.onResponseListener = onResponseListener;
|
||||
}
|
||||
|
||||
public void setOnErrorListener(OnErrorListener onErrorListener) {
|
||||
this.onErrorListener = onErrorListener;
|
||||
}
|
||||
|
||||
public interface OnResponseListener<Protocol> {
|
||||
void onResponse(Protocol response);
|
||||
}
|
||||
|
||||
public interface OnErrorListener {
|
||||
void onError(String error);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CountrySearchSelectionFragment extends SearchSelectionFragment {
|
||||
|
|
Loading…
Reference in a new issue