Commit ecb0b032 by Kunj Gupta

UOFLMA-124 : Fixed - Make sure all API failures are handled and user is shown failure message.

parent 2d66699b
Showing with 283 additions and 162 deletions
...@@ -11,4 +11,5 @@ import java.util.List; ...@@ -11,4 +11,5 @@ import java.util.List;
*/ */
public interface GetCatalogueApiListener { public interface GetCatalogueApiListener {
void onDoneApiCall(List<Catalogue> catalogueList); void onDoneApiCall(List<Catalogue> catalogueList);
void onFailApiCall();
} }
...@@ -11,4 +11,5 @@ import java.util.List; ...@@ -11,4 +11,5 @@ import java.util.List;
*/ */
public interface GetCatalogueItemApiListener { public interface GetCatalogueItemApiListener {
void onDoneApiCall(List<CatalogueItem> catalogueItemList); void onDoneApiCall(List<CatalogueItem> catalogueItemList);
void onFailApiCall();
} }
...@@ -11,4 +11,5 @@ import java.util.List; ...@@ -11,4 +11,5 @@ import java.util.List;
*/ */
public interface GetCatalogueOrderApiListener { public interface GetCatalogueOrderApiListener {
void onDoneApiCall(List<CatalogueOrder> catalogueOrderList); void onDoneApiCall(List<CatalogueOrder> catalogueOrderList);
void onFailApiCall();
} }
...@@ -12,4 +12,5 @@ import java.util.List; ...@@ -12,4 +12,5 @@ import java.util.List;
*/ */
public interface GetCatalogueVariableApiListener { public interface GetCatalogueVariableApiListener {
void onDoneApiCall(List<CatalogueVariableSet> variableSetList, List<CatalogueVariable> variableList); void onDoneApiCall(List<CatalogueVariableSet> variableSetList, List<CatalogueVariable> variableList);
void onFailApiCall();
} }
...@@ -11,4 +11,5 @@ import java.util.List; ...@@ -11,4 +11,5 @@ import java.util.List;
*/ */
public interface GetIncidentApiListener { public interface GetIncidentApiListener {
void onDoneApiCall(List<Incident> incidentList); void onDoneApiCall(List<Incident> incidentList);
void onFailApiCall();
} }
...@@ -11,4 +11,5 @@ import java.util.List; ...@@ -11,4 +11,5 @@ import java.util.List;
*/ */
public interface GetMyRequestApiListener { public interface GetMyRequestApiListener {
void onDoneApiCall(List<MyRequest> catalogueList); void onDoneApiCall(List<MyRequest> catalogueList);
void onFailApiCall();
} }
...@@ -11,4 +11,5 @@ import java.util.List; ...@@ -11,4 +11,5 @@ import java.util.List;
*/ */
public interface GetReferenceApiListener { public interface GetReferenceApiListener {
void onDoneApiCall(List<Reference> referenceList); void onDoneApiCall(List<Reference> referenceList);
void onFailApiCall();
} }
...@@ -11,4 +11,5 @@ import java.util.List; ...@@ -11,4 +11,5 @@ import java.util.List;
*/ */
public interface GetUiPolicyApiListener { public interface GetUiPolicyApiListener {
void onDoneApiCall(List<UiPolicyItem> uiPolicyItemList); void onDoneApiCall(List<UiPolicyItem> uiPolicyItemList);
void onFailApiCall();
} }
...@@ -9,6 +9,7 @@ import java.util.List; ...@@ -9,6 +9,7 @@ import java.util.List;
* @author Kunj on 11/8/16 * @author Kunj on 11/8/16
* *
*/ */
public interface GetUserApiListener { public interface GetUserDetailApiListener {
void onDoneApiCall(List<UserApiValues> userValues); void onDoneApiCall(List<UserApiValues> userValues);
void onFailApiCall();
} }
package com.vsoft.uoflservicenow.api.listeners.get;
/**
* @since 1.0
* @author Kunj on 11/8/16
*
*/
public interface GetUserLoginApiListener {
void onDoneApiCall();
void onFailApiCall();
}
...@@ -11,4 +11,5 @@ import java.util.List; ...@@ -11,4 +11,5 @@ import java.util.List;
*/ */
public interface GetVariableChoiceApiListener { public interface GetVariableChoiceApiListener {
void onDoneApiCall(List<VariableChoice> variableChoiceList); void onDoneApiCall(List<VariableChoice> variableChoiceList);
void onFailApiCall();
} }
package com.vsoft.uoflservicenow.api.listeners.post;
/**
* @since 1.0
* @author Kunj on 11/8/16
*
*/
public interface PostAttachmentApiListener {
void onDoneApiCall();
void onFailApiCall();
}
...@@ -7,4 +7,5 @@ package com.vsoft.uoflservicenow.api.listeners.post; ...@@ -7,4 +7,5 @@ package com.vsoft.uoflservicenow.api.listeners.post;
*/ */
public interface PostIncidentApiListener { public interface PostIncidentApiListener {
void onDoneApiCall(String incidentNumber); void onDoneApiCall(String incidentNumber);
void onFailApiCall();
} }
...@@ -7,4 +7,5 @@ package com.vsoft.uoflservicenow.api.listeners.post; ...@@ -7,4 +7,5 @@ package com.vsoft.uoflservicenow.api.listeners.post;
*/ */
public interface PostVariableFormApiListener { public interface PostVariableFormApiListener {
void onDoneApiCall(String variableFromSysId); void onDoneApiCall(String variableFromSysId);
void onFailApiCall();
} }
...@@ -12,7 +12,6 @@ import com.vsoft.uoflservicenow.api.listeners.get.GetCatalogueApiListener; ...@@ -12,7 +12,6 @@ import com.vsoft.uoflservicenow.api.listeners.get.GetCatalogueApiListener;
import com.vsoft.uoflservicenow.api.listeners.get.GetCatalogueOrderApiListener; import com.vsoft.uoflservicenow.api.listeners.get.GetCatalogueOrderApiListener;
import com.vsoft.uoflservicenow.db.models.Catalogue; import com.vsoft.uoflservicenow.db.models.Catalogue;
import com.vsoft.uoflservicenow.db.models.CatalogueOrder; import com.vsoft.uoflservicenow.db.models.CatalogueOrder;
import com.vsoft.uoflservicenow.enums.SyncStatus;
import com.vsoft.uoflservicenow.utils.CatalogueLog; import com.vsoft.uoflservicenow.utils.CatalogueLog;
import com.vsoft.uoflservicenow.utils.Constants; import com.vsoft.uoflservicenow.utils.Constants;
...@@ -38,7 +37,7 @@ import retrofit2.Retrofit; ...@@ -38,7 +37,7 @@ import retrofit2.Retrofit;
*/ */
public class CatalogueApiManager { public class CatalogueApiManager {
public static SyncStatus getCatalogues(GetCatalogueApiListener listener) { public static void getCatalogues(final GetCatalogueApiListener listener) {
CatalogueLog.d("CatalogueApiManager: getCatalogues: "); CatalogueLog.d("CatalogueApiManager: getCatalogues: ");
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(Catalogue.Json.URL_PARAM_CATALOGUE_SYSPRM_QUERY_VALUE); stringBuilder.append(Catalogue.Json.URL_PARAM_CATALOGUE_SYSPRM_QUERY_VALUE);
...@@ -119,38 +118,42 @@ public class CatalogueApiManager { ...@@ -119,38 +118,42 @@ public class CatalogueApiManager {
} }
} }
} }
listener.onDoneApiCall(finalCatalogueList);
}
@Override
public void onFailApiCall() {
listener.onFailApiCall();
} }
}); });
listener.onDoneApiCall(finalCatalogueList);
} else { } else {
listener.onDoneApiCall(new ArrayList<Catalogue>(0)); listener.onDoneApiCall(new ArrayList<Catalogue>(0));
} }
} else { } else {
listener.onDoneApiCall(new ArrayList<Catalogue>(0)); listener.onDoneApiCall(new ArrayList<Catalogue>(0));
} }
return SyncStatus.SUCCESS;
} else } else
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (JSONException e) { } catch (JSONException e) {
CatalogueLog.e("CatalogueApiManager: getCatalogues: onResponse: ", e); CatalogueLog.e("CatalogueApiManager: getCatalogues: onResponse: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (IOException e) { } catch (IOException e) {
CatalogueLog.e("CatalogueApiManager: getCatalogues: onResponse: ", e); CatalogueLog.e("CatalogueApiManager: getCatalogues: onResponse: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} else { } else {
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} catch (IOException e) { } catch (IOException e) {
CatalogueLog.e("CatalogueApiManager: getCatalogues: IOException: ", e); CatalogueLog.e("CatalogueApiManager: getCatalogues: IOException: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (NullPointerException e) { } catch (NullPointerException e) {
CatalogueLog.e("CatalogueApiManager: getCatalogues: NullPointerException: ", e); CatalogueLog.e("CatalogueApiManager: getCatalogues: NullPointerException: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} }
public static SyncStatus getCatalogueOrder(GetCatalogueOrderApiListener listener) { public static void getCatalogueOrder(GetCatalogueOrderApiListener listener) {
CatalogueLog.d("CatalogueApiManager: getCatalogueOrder: "); CatalogueLog.d("CatalogueApiManager: getCatalogueOrder: ");
final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD); final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD);
...@@ -225,25 +228,24 @@ public class CatalogueApiManager { ...@@ -225,25 +228,24 @@ public class CatalogueApiManager {
} else { } else {
listener.onDoneApiCall(new ArrayList<CatalogueOrder>(0)); listener.onDoneApiCall(new ArrayList<CatalogueOrder>(0));
} }
return SyncStatus.SUCCESS;
} else } else
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (JSONException e) { } catch (JSONException e) {
CatalogueLog.e("CatalogueApiManager: getCatalogueOrder: onResponse: ", e); CatalogueLog.e("CatalogueApiManager: getCatalogueOrder: onResponse: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (IOException e) { } catch (IOException e) {
CatalogueLog.e("CatalogueApiManager: getCatalogueOrder: onResponse: ", e); CatalogueLog.e("CatalogueApiManager: getCatalogueOrder: onResponse: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} else { } else {
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} catch (IOException e) { } catch (IOException e) {
CatalogueLog.e("CatalogueApiManager: getCatalogueOrder: IOException: ", e); CatalogueLog.e("CatalogueApiManager: getCatalogueOrder: IOException: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (NullPointerException e) { } catch (NullPointerException e) {
CatalogueLog.e("CatalogueApiManager: getCatalogueOrder: NullPointerException: ", e); CatalogueLog.e("CatalogueApiManager: getCatalogueOrder: NullPointerException: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} }
} }
\ No newline at end of file
...@@ -10,7 +10,6 @@ import com.vsoft.uoflservicenow.api.RestClient; ...@@ -10,7 +10,6 @@ import com.vsoft.uoflservicenow.api.RestClient;
import com.vsoft.uoflservicenow.api.interfaces.CatalogueCategoryItemApi; import com.vsoft.uoflservicenow.api.interfaces.CatalogueCategoryItemApi;
import com.vsoft.uoflservicenow.api.listeners.get.GetCatalogueItemApiListener; import com.vsoft.uoflservicenow.api.listeners.get.GetCatalogueItemApiListener;
import com.vsoft.uoflservicenow.db.models.CatalogueItem; import com.vsoft.uoflservicenow.db.models.CatalogueItem;
import com.vsoft.uoflservicenow.enums.SyncStatus;
import com.vsoft.uoflservicenow.utils.CatalogueLog; import com.vsoft.uoflservicenow.utils.CatalogueLog;
import com.vsoft.uoflservicenow.utils.Constants; import com.vsoft.uoflservicenow.utils.Constants;
...@@ -34,7 +33,7 @@ import retrofit2.Retrofit; ...@@ -34,7 +33,7 @@ import retrofit2.Retrofit;
*/ */
public class CatalogueItemApiManager { public class CatalogueItemApiManager {
public static SyncStatus getCatalogueItems(String catalogueSysId, GetCatalogueItemApiListener listener) { public static void getCatalogueItems(String catalogueSysId, GetCatalogueItemApiListener listener) {
CatalogueLog.d("CatalogueItemApiManager: getCatalogueItems: "); CatalogueLog.d("CatalogueItemApiManager: getCatalogueItems: ");
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(CatalogueItem.Json.URL_PARAM_CATALOGUE_SYSPRM_QUERY_VALUE); stringBuilder.append(CatalogueItem.Json.URL_PARAM_CATALOGUE_SYSPRM_QUERY_VALUE);
...@@ -105,25 +104,24 @@ public class CatalogueItemApiManager { ...@@ -105,25 +104,24 @@ public class CatalogueItemApiManager {
} else { } else {
listener.onDoneApiCall(new ArrayList<CatalogueItem>(0)); listener.onDoneApiCall(new ArrayList<CatalogueItem>(0));
} }
return SyncStatus.SUCCESS;
} else } else
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (JSONException e) { } catch (JSONException e) {
CatalogueLog.e("CatalogueItemApiManager: getCatalogueItems: onResponse: ", e); CatalogueLog.e("CatalogueItemApiManager: getCatalogueItems: onResponse: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (IOException e) { } catch (IOException e) {
CatalogueLog.e("CatalogueItemApiManager: getCatalogueItems: onResponse: ", e); CatalogueLog.e("CatalogueItemApiManager: getCatalogueItems: onResponse: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} else { } else {
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} catch (IOException e) { } catch (IOException e) {
CatalogueLog.e("CatalogueItemApiManager: getCatalogueItems: IOException: ", e); CatalogueLog.e("CatalogueItemApiManager: getCatalogueItems: IOException: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (NullPointerException e) { } catch (NullPointerException e) {
CatalogueLog.e("CatalogueItemApiManager: getCatalogueItems: NullPointerException: ", e); CatalogueLog.e("CatalogueItemApiManager: getCatalogueItems: NullPointerException: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} }
} }
\ No newline at end of file
...@@ -10,12 +10,12 @@ import com.vsoft.uoflservicenow.api.RestClient; ...@@ -10,12 +10,12 @@ import com.vsoft.uoflservicenow.api.RestClient;
import com.vsoft.uoflservicenow.api.interfaces.CatalogueVariableApi; import com.vsoft.uoflservicenow.api.interfaces.CatalogueVariableApi;
import com.vsoft.uoflservicenow.api.listeners.get.GetCatalogueVariableApiListener; import com.vsoft.uoflservicenow.api.listeners.get.GetCatalogueVariableApiListener;
import com.vsoft.uoflservicenow.api.listeners.get.GetUiPolicyApiListener; import com.vsoft.uoflservicenow.api.listeners.get.GetUiPolicyApiListener;
import com.vsoft.uoflservicenow.api.listeners.post.PostAttachmentApiListener;
import com.vsoft.uoflservicenow.api.listeners.post.PostVariableFormApiListener; import com.vsoft.uoflservicenow.api.listeners.post.PostVariableFormApiListener;
import com.vsoft.uoflservicenow.db.models.CatalogueVariable; import com.vsoft.uoflservicenow.db.models.CatalogueVariable;
import com.vsoft.uoflservicenow.db.models.CatalogueVariableSet; import com.vsoft.uoflservicenow.db.models.CatalogueVariableSet;
import com.vsoft.uoflservicenow.db.models.UiPolicyAction; import com.vsoft.uoflservicenow.db.models.UiPolicyAction;
import com.vsoft.uoflservicenow.db.models.UiPolicyItem; import com.vsoft.uoflservicenow.db.models.UiPolicyItem;
import com.vsoft.uoflservicenow.enums.SyncStatus;
import com.vsoft.uoflservicenow.utils.CatalogueLog; import com.vsoft.uoflservicenow.utils.CatalogueLog;
import com.vsoft.uoflservicenow.utils.Constants; import com.vsoft.uoflservicenow.utils.Constants;
...@@ -42,7 +42,7 @@ import retrofit2.Retrofit; ...@@ -42,7 +42,7 @@ import retrofit2.Retrofit;
*/ */
public class CatalogueVariableApiManager { public class CatalogueVariableApiManager {
public static SyncStatus getCatalogueVariable(String catalogueItemSysId, GetCatalogueVariableApiListener listener) { public static void getCatalogueVariable(String catalogueItemSysId, GetCatalogueVariableApiListener listener) {
CatalogueLog.d("CatalogueVariableApiManager: getCatalogueVariable: "); CatalogueLog.d("CatalogueVariableApiManager: getCatalogueVariable: ");
final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD); final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD);
Call<ResponseBody> call = retrofit.create(CatalogueVariableApi.class).getVariable(catalogueItemSysId); Call<ResponseBody> call = retrofit.create(CatalogueVariableApi.class).getVariable(catalogueItemSysId);
...@@ -149,29 +149,28 @@ public class CatalogueVariableApiManager { ...@@ -149,29 +149,28 @@ public class CatalogueVariableApiManager {
} else { } else {
listener.onDoneApiCall(new ArrayList<CatalogueVariableSet>(0), new ArrayList<CatalogueVariable>(0)); listener.onDoneApiCall(new ArrayList<CatalogueVariableSet>(0), new ArrayList<CatalogueVariable>(0));
} }
return SyncStatus.SUCCESS;
} else } else
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (JSONException e) { } catch (JSONException e) {
CatalogueLog.e("CatalogueVariableApiManager: getCatalogueVariable: onResponse: ", e); CatalogueLog.e("CatalogueVariableApiManager: getCatalogueVariable: onResponse: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (IOException e) { } catch (IOException e) {
CatalogueLog.e("CatalogueVariableApiManager: getCatalogueVariable: onResponse: ", e); CatalogueLog.e("CatalogueVariableApiManager: getCatalogueVariable: onResponse: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} else { } else {
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} catch (IOException e) { } catch (IOException e) {
CatalogueLog.e("CatalogueVariableApiManager: getCatalogueVariable: IOException: ", e); CatalogueLog.e("CatalogueVariableApiManager: getCatalogueVariable: IOException: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (NullPointerException e) { } catch (NullPointerException e) {
CatalogueLog.e("CatalogueVariableApiManager: getCatalogueVariable: NullPointerException: ", e); CatalogueLog.e("CatalogueVariableApiManager: getCatalogueVariable: NullPointerException: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} }
public static SyncStatus getUiPolicy(String catalogueItemSysId, GetUiPolicyApiListener listener) { public static void getUiPolicy(String catalogueItemSysId, GetUiPolicyApiListener listener) {
CatalogueLog.d("CatalogueVariableApiManager: getUiPolicy: "); CatalogueLog.d("CatalogueVariableApiManager: getUiPolicy: ");
final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD); final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD);
Call<ResponseBody> call = retrofit.create(CatalogueVariableApi.class).getUiPolicy(catalogueItemSysId); Call<ResponseBody> call = retrofit.create(CatalogueVariableApi.class).getUiPolicy(catalogueItemSysId);
...@@ -245,29 +244,28 @@ public class CatalogueVariableApiManager { ...@@ -245,29 +244,28 @@ public class CatalogueVariableApiManager {
} else { } else {
listener.onDoneApiCall(new ArrayList<UiPolicyItem>(0)); listener.onDoneApiCall(new ArrayList<UiPolicyItem>(0));
} }
return SyncStatus.SUCCESS;
} else } else
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (JSONException e) { } catch (JSONException e) {
CatalogueLog.e("CatalogueVariableApiManager: getUiPolicy: onResponse: ", e); CatalogueLog.e("CatalogueVariableApiManager: getUiPolicy: onResponse: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (IOException e) { } catch (IOException e) {
CatalogueLog.e("CatalogueVariableApiManager: getUiPolicy: onResponse: ", e); CatalogueLog.e("CatalogueVariableApiManager: getUiPolicy: onResponse: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} else { } else {
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} catch (IOException e) { } catch (IOException e) {
CatalogueLog.e("CatalogueVariableApiManager: getUiPolicy: IOException: ", e); CatalogueLog.e("CatalogueVariableApiManager: getUiPolicy: IOException: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (NullPointerException e) { } catch (NullPointerException e) {
CatalogueLog.e("CatalogueVariableApiManager: getUiPolicy: NullPointerException: ", e); CatalogueLog.e("CatalogueVariableApiManager: getUiPolicy: NullPointerException: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} }
public static SyncStatus submitVariableForm(String catalogueItemSysId, String catalogueJsonString, PostVariableFormApiListener listener) { public static void submitVariableForm(String catalogueItemSysId, String catalogueJsonString, PostVariableFormApiListener listener) {
CatalogueLog.d("submitVariableForm: " + catalogueJsonString); CatalogueLog.d("submitVariableForm: " + catalogueJsonString);
final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD); final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD);
Call<ResponseBody> call = retrofit.create(CatalogueVariableApi.class).postCatalogueItem(catalogueItemSysId, catalogueJsonString); Call<ResponseBody> call = retrofit.create(CatalogueVariableApi.class).postCatalogueItem(catalogueItemSysId, catalogueJsonString);
...@@ -284,21 +282,21 @@ public class CatalogueVariableApiManager { ...@@ -284,21 +282,21 @@ public class CatalogueVariableApiManager {
} }
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
listener.onFailApiCall();
} }
return SyncStatus.SUCCESS;
} else { } else {
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} catch (IOException e) { } catch (IOException e) {
CatalogueLog.e("CatalogueVariableApiManager: submitVariableForm: IOException: ", e); CatalogueLog.e("CatalogueVariableApiManager: submitVariableForm: IOException: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (NullPointerException e) { } catch (NullPointerException e) {
CatalogueLog.e("CatalogueVariableApiManager: submitVariableForm: IOException: ", e); CatalogueLog.e("CatalogueVariableApiManager: submitVariableForm: IOException: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} }
public static SyncStatus postAttachment(String contentType, String tableSysId, String attachmentName, RequestBody requestBody/*String attachmentJsonString*/) { public static void postAttachment(String contentType, String tableSysId, String attachmentName, RequestBody requestBody, PostAttachmentApiListener listener) {
CatalogueLog.d("postAttachment: tableSysId: " + tableSysId); CatalogueLog.d("postAttachment: tableSysId: " + tableSysId);
final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD); final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD);
Call<ResponseBody> call = retrofit.create(CatalogueVariableApi.class).postAttachment(contentType, tableSysId, CatalogueVariable.Json.TABLE_NAME_VALUE, attachmentName, requestBody); Call<ResponseBody> call = retrofit.create(CatalogueVariableApi.class).postAttachment(contentType, tableSysId, CatalogueVariable.Json.TABLE_NAME_VALUE, attachmentName, requestBody);
...@@ -306,16 +304,16 @@ public class CatalogueVariableApiManager { ...@@ -306,16 +304,16 @@ public class CatalogueVariableApiManager {
//Retrofit synchronous call //Retrofit synchronous call
Response<ResponseBody> response = call.execute(); Response<ResponseBody> response = call.execute();
if (response.isSuccessful()) { if (response.isSuccessful()) {
return SyncStatus.SUCCESS; listener.onDoneApiCall();
} else { } else {
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} catch (IOException e) { } catch (IOException e) {
CatalogueLog.e("CatalogueVariableApiManager: postAttachment: IOException: ", e); CatalogueLog.e("CatalogueVariableApiManager: postAttachment: IOException: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (NullPointerException e) { } catch (NullPointerException e) {
CatalogueLog.e("CatalogueVariableApiManager: postAttachment: IOException: ", e); CatalogueLog.e("CatalogueVariableApiManager: postAttachment: IOException: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} }
} }
\ No newline at end of file
...@@ -11,7 +11,6 @@ import com.vsoft.uoflservicenow.api.interfaces.IncidentApi; ...@@ -11,7 +11,6 @@ import com.vsoft.uoflservicenow.api.interfaces.IncidentApi;
import com.vsoft.uoflservicenow.api.listeners.get.GetIncidentApiListener; import com.vsoft.uoflservicenow.api.listeners.get.GetIncidentApiListener;
import com.vsoft.uoflservicenow.api.listeners.post.PostIncidentApiListener; import com.vsoft.uoflservicenow.api.listeners.post.PostIncidentApiListener;
import com.vsoft.uoflservicenow.db.models.Incident; import com.vsoft.uoflservicenow.db.models.Incident;
import com.vsoft.uoflservicenow.enums.SyncStatus;
import com.vsoft.uoflservicenow.utils.CatalogueLog; import com.vsoft.uoflservicenow.utils.CatalogueLog;
import com.vsoft.uoflservicenow.utils.Constants; import com.vsoft.uoflservicenow.utils.Constants;
...@@ -35,7 +34,7 @@ import retrofit2.Retrofit; ...@@ -35,7 +34,7 @@ import retrofit2.Retrofit;
*/ */
public class IncidentApiManager { public class IncidentApiManager {
public static SyncStatus getIncident(GetIncidentApiListener listener) { public static void getIncident(GetIncidentApiListener listener) {
CatalogueLog.d("IncidentApiManager: getIncident: "); CatalogueLog.d("IncidentApiManager: getIncident: ");
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("caller_id=javascript:gs.getUserID()"); stringBuilder.append("caller_id=javascript:gs.getUserID()");
...@@ -104,30 +103,28 @@ public class IncidentApiManager { ...@@ -104,30 +103,28 @@ public class IncidentApiManager {
} else { } else {
listener.onDoneApiCall(new ArrayList<Incident>(0)); listener.onDoneApiCall(new ArrayList<Incident>(0));
} }
return SyncStatus.SUCCESS;
} else } else
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (JSONException e) { } catch (JSONException e) {
CatalogueLog.e("IncidentApiManager: getIncident: onResponse: ", e); CatalogueLog.e("IncidentApiManager: getIncident: onResponse: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (IOException e) { } catch (IOException e) {
CatalogueLog.e("IncidentApiManager: getIncident: onResponse: ", e); CatalogueLog.e("IncidentApiManager: getIncident: onResponse: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} else { } else {
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} catch (IOException e) { } catch (IOException e) {
CatalogueLog.e("IncidentApiManager: getIncident: IOException: ", e); CatalogueLog.e("IncidentApiManager: getIncident: IOException: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (NullPointerException e) { } catch (NullPointerException e) {
CatalogueLog.e("IncidentApiManager: getIncident: NullPointerException: ", e); CatalogueLog.e("IncidentApiManager: getIncident: NullPointerException: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} }
public static SyncStatus submitIncidentForm(String incidentJsonString, PostIncidentApiListener listener) { public static void submitIncidentForm(String incidentJsonString, PostIncidentApiListener listener) {
CatalogueLog.d("submitIncidentForm: incidentJson" + incidentJsonString); CatalogueLog.d("submitIncidentForm: incidentJson" + incidentJsonString);
final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD); final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD);
Call<ResponseBody> call = retrofit.create(IncidentApi.class).submitIncident(incidentJsonString); Call<ResponseBody> call = retrofit.create(IncidentApi.class).submitIncident(incidentJsonString);
...@@ -146,16 +143,15 @@ public class IncidentApiManager { ...@@ -146,16 +143,15 @@ public class IncidentApiManager {
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
return SyncStatus.SUCCESS;
} else { } else {
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} catch (IOException e) { } catch (IOException e) {
CatalogueLog.e("IncidentApiManager: submitIncidentForm: IOException: ", e); CatalogueLog.e("IncidentApiManager: submitIncidentForm: IOException: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (NullPointerException e){ } catch (NullPointerException e){
CatalogueLog.e("IncidentApiManager: submitIncidentForm: IOException: ", e); CatalogueLog.e("IncidentApiManager: submitIncidentForm: IOException: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} }
} }
\ No newline at end of file
...@@ -2,7 +2,7 @@ package com.vsoft.uoflservicenow.api.managers; ...@@ -2,7 +2,7 @@ package com.vsoft.uoflservicenow.api.managers;
import com.vsoft.uoflservicenow.api.RestClient; import com.vsoft.uoflservicenow.api.RestClient;
import com.vsoft.uoflservicenow.api.interfaces.LoginApi; import com.vsoft.uoflservicenow.api.interfaces.LoginApi;
import com.vsoft.uoflservicenow.enums.SyncStatus; import com.vsoft.uoflservicenow.api.listeners.get.GetUserLoginApiListener;
import com.vsoft.uoflservicenow.utils.CatalogueLog; import com.vsoft.uoflservicenow.utils.CatalogueLog;
import java.io.IOException; import java.io.IOException;
...@@ -17,7 +17,7 @@ import retrofit2.Retrofit; ...@@ -17,7 +17,7 @@ import retrofit2.Retrofit;
*/ */
public class LoginApiManger { public class LoginApiManger {
public static SyncStatus submitLoginValues(String garntType, String clientId, String clientSecret, String userName, String password) { public static void submitLoginValues(String garntType, String clientId, String clientSecret, String userName, String password, GetUserLoginApiListener listener) {
final Retrofit retrofit = RestClient.getInitializedRestAdapterWithOutAuthorizationHeader(); final Retrofit retrofit = RestClient.getInitializedRestAdapterWithOutAuthorizationHeader();
Call<ResponseBody> call = retrofit.create(LoginApi.class).postLoginValues(garntType, clientId, clientSecret, userName, password); Call<ResponseBody> call = retrofit.create(LoginApi.class).postLoginValues(garntType, clientId, clientSecret, userName, password);
try { try {
...@@ -27,20 +27,20 @@ public class LoginApiManger { ...@@ -27,20 +27,20 @@ public class LoginApiManger {
if (body != null) { if (body != null) {
if (body.contentLength() != -1) { if (body.contentLength() != -1) {
return SyncStatus.SUCCESS; listener.onDoneApiCall();
} else { } else {
return SyncStatus.SERVICEDOWN; listener.onFailApiCall();
} }
} else { } else {
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} catch (IOException e) { } catch (IOException e) {
CatalogueLog.e("LoginApiManger: submitLoginValues: IOException: ", e); CatalogueLog.e("LoginApiManger: submitLoginValues: IOException: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (NullPointerException e) { } catch (NullPointerException e) {
CatalogueLog.e("LoginApiManger: submitLoginValues: IOException: ", e); CatalogueLog.e("LoginApiManger: submitLoginValues: IOException: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} }
} }
...@@ -8,9 +8,8 @@ import com.google.gson.JsonElement; ...@@ -8,9 +8,8 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonParseException; import com.google.gson.JsonParseException;
import com.vsoft.uoflservicenow.api.RestClient; import com.vsoft.uoflservicenow.api.RestClient;
import com.vsoft.uoflservicenow.api.interfaces.UserApi; import com.vsoft.uoflservicenow.api.interfaces.UserApi;
import com.vsoft.uoflservicenow.api.listeners.get.GetUserApiListener; import com.vsoft.uoflservicenow.api.listeners.get.GetUserDetailApiListener;
import com.vsoft.uoflservicenow.db.models.UserApiValues; import com.vsoft.uoflservicenow.db.models.UserApiValues;
import com.vsoft.uoflservicenow.enums.SyncStatus;
import com.vsoft.uoflservicenow.utils.CatalogueLog; import com.vsoft.uoflservicenow.utils.CatalogueLog;
import com.vsoft.uoflservicenow.utils.Constants; import com.vsoft.uoflservicenow.utils.Constants;
...@@ -32,7 +31,7 @@ import retrofit2.Retrofit; ...@@ -32,7 +31,7 @@ import retrofit2.Retrofit;
* Created by kvemulavada on 8/31/2016. * Created by kvemulavada on 8/31/2016.
*/ */
public class UserApiManager { public class UserApiManager {
public static SyncStatus getUserDetailResponse(String userName, GetUserApiListener listener) { public static void getUserDetailResponse(String userName, GetUserDetailApiListener listener) {
final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD); final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD);
Call<ResponseBody> call = retrofit.create(UserApi.class).getuserDetails(userName); Call<ResponseBody> call = retrofit.create(UserApi.class).getuserDetails(userName);
...@@ -96,21 +95,20 @@ public class UserApiManager { ...@@ -96,21 +95,20 @@ public class UserApiManager {
} else { } else {
listener.onDoneApiCall(new ArrayList<UserApiValues>(0)); listener.onDoneApiCall(new ArrayList<UserApiValues>(0));
} }
return SyncStatus.SUCCESS;
} else } else
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (JSONException e) { } catch (JSONException e) {
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (IOException e) { } catch (IOException e) {
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} else { } else {
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} catch (IOException e) { } catch (IOException e) {
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (NullPointerException e) { } catch (NullPointerException e) {
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} }
......
...@@ -12,7 +12,6 @@ import com.vsoft.uoflservicenow.api.listeners.get.GetReferenceApiListener; ...@@ -12,7 +12,6 @@ import com.vsoft.uoflservicenow.api.listeners.get.GetReferenceApiListener;
import com.vsoft.uoflservicenow.api.listeners.get.GetVariableChoiceApiListener; import com.vsoft.uoflservicenow.api.listeners.get.GetVariableChoiceApiListener;
import com.vsoft.uoflservicenow.db.models.Reference; import com.vsoft.uoflservicenow.db.models.Reference;
import com.vsoft.uoflservicenow.db.models.VariableChoice; import com.vsoft.uoflservicenow.db.models.VariableChoice;
import com.vsoft.uoflservicenow.enums.SyncStatus;
import com.vsoft.uoflservicenow.utils.CatalogueLog; import com.vsoft.uoflservicenow.utils.CatalogueLog;
import com.vsoft.uoflservicenow.utils.Constants; import com.vsoft.uoflservicenow.utils.Constants;
...@@ -37,7 +36,7 @@ import retrofit2.Retrofit; ...@@ -37,7 +36,7 @@ import retrofit2.Retrofit;
*/ */
public class VariableChoiceApiManager { public class VariableChoiceApiManager {
public static SyncStatus getVariableChoice(String variableSysId, GetVariableChoiceApiListener listener) { public static void getVariableChoice(String variableSysId, GetVariableChoiceApiListener listener) {
CatalogueLog.d("VariableChoiceApiManager: getVariableChoice: "); CatalogueLog.d("VariableChoiceApiManager: getVariableChoice: ");
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(VariableChoice.Json.URL_PARAM_VARIABLE_CHOICE_SYSPRM_QUERY_VALUE); stringBuilder.append(VariableChoice.Json.URL_PARAM_VARIABLE_CHOICE_SYSPRM_QUERY_VALUE);
...@@ -107,29 +106,28 @@ public class VariableChoiceApiManager { ...@@ -107,29 +106,28 @@ public class VariableChoiceApiManager {
} else { } else {
listener.onDoneApiCall(new ArrayList<VariableChoice>(0)); listener.onDoneApiCall(new ArrayList<VariableChoice>(0));
} }
return SyncStatus.SUCCESS;
} else } else
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (JSONException e) { } catch (JSONException e) {
CatalogueLog.e("VariableChoiceApiManager: getVariableChoice: onResponse: ", e); CatalogueLog.e("VariableChoiceApiManager: getVariableChoice: onResponse: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (IOException e) { } catch (IOException e) {
CatalogueLog.e("VariableChoiceApiManager: getVariableChoice: onResponse: ", e); CatalogueLog.e("VariableChoiceApiManager: getVariableChoice: onResponse: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} else { } else {
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} catch (IOException e) { } catch (IOException e) {
CatalogueLog.e("VariableChoiceApiManager: getVariableChoice: IOException: ", e); CatalogueLog.e("VariableChoiceApiManager: getVariableChoice: IOException: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (NullPointerException e) { } catch (NullPointerException e) {
CatalogueLog.e("VariableChoiceApiManager: getVariableChoice: NullPointerException: ", e); CatalogueLog.e("VariableChoiceApiManager: getVariableChoice: NullPointerException: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} }
public static SyncStatus getReference(String tableName, Map<String,String> queryMap, GetReferenceApiListener listener) { public static void getReference(String tableName, Map<String,String> queryMap, GetReferenceApiListener listener) {
CatalogueLog.d("VariableChoiceApiManager: getReference: tableName: "+tableName); CatalogueLog.d("VariableChoiceApiManager: getReference: tableName: "+tableName);
final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD); final Retrofit retrofit = RestClient.getInitializedRestAdapter(Constants.API_AUTH_PARAM_USER_NAME, Constants.API_AUTH_PARAM_PASSWORD);
...@@ -194,25 +192,24 @@ public class VariableChoiceApiManager { ...@@ -194,25 +192,24 @@ public class VariableChoiceApiManager {
} else { } else {
listener.onDoneApiCall(new ArrayList<Reference>(0)); listener.onDoneApiCall(new ArrayList<Reference>(0));
} }
return SyncStatus.SUCCESS;
} else } else
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (JSONException e) { } catch (JSONException e) {
CatalogueLog.e("VariableChoiceApiManager: getReference: onResponse: ", e); CatalogueLog.e("VariableChoiceApiManager: getReference: onResponse: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (IOException e) { } catch (IOException e) {
CatalogueLog.e("VariableChoiceApiManager: getReference: onResponse: ", e); CatalogueLog.e("VariableChoiceApiManager: getReference: onResponse: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} else { } else {
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} catch (IOException e) { } catch (IOException e) {
CatalogueLog.e("VariableChoiceApiManager: getReference: IOException: ", e); CatalogueLog.e("VariableChoiceApiManager: getReference: IOException: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} catch (NullPointerException e) { } catch (NullPointerException e) {
CatalogueLog.e("VariableChoiceApiManager: getReference: NullPointerException: ", e); CatalogueLog.e("VariableChoiceApiManager: getReference: NullPointerException: ", e);
return SyncStatus.FAIL; listener.onFailApiCall();
} }
} }
} }
\ No newline at end of file
...@@ -168,6 +168,7 @@ public class SelectReferenceDialog extends DialogFragment { ...@@ -168,6 +168,7 @@ public class SelectReferenceDialog extends DialogFragment {
class FetchReference extends AsyncTask<String, Void, SyncStatus> { class FetchReference extends AsyncTask<String, Void, SyncStatus> {
private ProgressDialog progressDialog; private ProgressDialog progressDialog;
private SyncStatus syncStatus;
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
...@@ -183,12 +184,19 @@ public class SelectReferenceDialog extends DialogFragment { ...@@ -183,12 +184,19 @@ public class SelectReferenceDialog extends DialogFragment {
Map<String, String> stringMap = new HashMap<>(1); Map<String, String> stringMap = new HashMap<>(1);
stringMap.put(Constants.URL_PARAM_SYSPRM_FIELDS, "sys_id,"+mReferenceColumnName); stringMap.put(Constants.URL_PARAM_SYSPRM_FIELDS, "sys_id,"+mReferenceColumnName);
stringMap.put(Constants.URL_PARAM_SYSPRM_QUERY, mReferenceColumnName+"LIKE"+params[0]); stringMap.put(Constants.URL_PARAM_SYSPRM_QUERY, mReferenceColumnName+"LIKE"+params[0]);
return VariableChoiceApiManager.getReference(mReferenceTableName, stringMap, new GetReferenceApiListener() { VariableChoiceApiManager.getReference(mReferenceTableName, stringMap, new GetReferenceApiListener() {
@Override @Override
public void onDoneApiCall(List<Reference> referenceList) { public void onDoneApiCall(List<Reference> referenceList) {
syncStatus = SyncStatus.SUCCESS;
mReferenceList = referenceList; mReferenceList = referenceList;
} }
@Override
public void onFailApiCall() {
syncStatus = SyncStatus.FAIL;
}
}); });
return syncStatus;
} }
@Override @Override
......
...@@ -7,8 +7,7 @@ package com.vsoft.uoflservicenow.enums; ...@@ -7,8 +7,7 @@ package com.vsoft.uoflservicenow.enums;
*/ */
public enum SyncStatus { public enum SyncStatus {
SUCCESS (1), SUCCESS (1),
FAIL (2), FAIL (2);
SERVICEDOWN (3);
int id; int id;
......
...@@ -86,6 +86,7 @@ public class CatalogueItemScreen extends AppCompatActivity { ...@@ -86,6 +86,7 @@ public class CatalogueItemScreen extends AppCompatActivity {
class FetchCatalogueItem extends AsyncTask<String, Void, SyncStatus> { class FetchCatalogueItem extends AsyncTask<String, Void, SyncStatus> {
private ProgressDialog progressDialog; private ProgressDialog progressDialog;
private SyncStatus syncStatus;
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
...@@ -98,13 +99,20 @@ public class CatalogueItemScreen extends AppCompatActivity { ...@@ -98,13 +99,20 @@ public class CatalogueItemScreen extends AppCompatActivity {
@Override @Override
protected SyncStatus doInBackground(String... params) { protected SyncStatus doInBackground(String... params) {
return CatalogueItemApiManager.getCatalogueItems(mCatalogueSysId, new GetCatalogueItemApiListener() { CatalogueItemApiManager.getCatalogueItems(mCatalogueSysId, new GetCatalogueItemApiListener() {
@Override @Override
public void onDoneApiCall(List<CatalogueItem> catalogueItemList) { public void onDoneApiCall(List<CatalogueItem> catalogueItemList) {
syncStatus = SyncStatus.SUCCESS;
CatalogueLog.e("Data: catalogueItemList: "+catalogueItemList); CatalogueLog.e("Data: catalogueItemList: "+catalogueItemList);
mCatalogueItemList = catalogueItemList; mCatalogueItemList = catalogueItemList;
} }
@Override
public void onFailApiCall() {
syncStatus = SyncStatus.FAIL;
}
}); });
return syncStatus;
} }
@Override @Override
......
...@@ -77,6 +77,7 @@ public class CatalogueScreen extends AppCompatActivity { ...@@ -77,6 +77,7 @@ public class CatalogueScreen extends AppCompatActivity {
class FetchCatalogue extends AsyncTask<String, Void, SyncStatus> { class FetchCatalogue extends AsyncTask<String, Void, SyncStatus> {
private ProgressDialog progressDialog; private ProgressDialog progressDialog;
private SyncStatus syncStatus = SyncStatus.FAIL;
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
...@@ -89,13 +90,20 @@ public class CatalogueScreen extends AppCompatActivity { ...@@ -89,13 +90,20 @@ public class CatalogueScreen extends AppCompatActivity {
@Override @Override
protected SyncStatus doInBackground(String... params) { protected SyncStatus doInBackground(String... params) {
return CatalogueApiManager.getCatalogues(new GetCatalogueApiListener() { CatalogueApiManager.getCatalogues(new GetCatalogueApiListener() {
@Override @Override
public void onDoneApiCall(List<Catalogue> catalogueList) { public void onDoneApiCall(List<Catalogue> catalogueList) {
syncStatus = SyncStatus.SUCCESS;
CatalogueLog.e("Data: catalogueList: "+catalogueList); CatalogueLog.e("Data: catalogueList: "+catalogueList);
mCatalogueList = catalogueList; mCatalogueList = catalogueList;
} }
@Override
public void onFailApiCall() {
syncStatus = SyncStatus.FAIL;
}
}); });
return syncStatus;
} }
@Override @Override
......
...@@ -55,6 +55,7 @@ import com.vsoft.uoflservicenow.R; ...@@ -55,6 +55,7 @@ import com.vsoft.uoflservicenow.R;
import com.vsoft.uoflservicenow.api.listeners.get.GetCatalogueVariableApiListener; import com.vsoft.uoflservicenow.api.listeners.get.GetCatalogueVariableApiListener;
import com.vsoft.uoflservicenow.api.listeners.get.GetUiPolicyApiListener; import com.vsoft.uoflservicenow.api.listeners.get.GetUiPolicyApiListener;
import com.vsoft.uoflservicenow.api.listeners.get.GetVariableChoiceApiListener; import com.vsoft.uoflservicenow.api.listeners.get.GetVariableChoiceApiListener;
import com.vsoft.uoflservicenow.api.listeners.post.PostAttachmentApiListener;
import com.vsoft.uoflservicenow.api.listeners.post.PostVariableFormApiListener; import com.vsoft.uoflservicenow.api.listeners.post.PostVariableFormApiListener;
import com.vsoft.uoflservicenow.api.managers.CatalogueVariableApiManager; import com.vsoft.uoflservicenow.api.managers.CatalogueVariableApiManager;
import com.vsoft.uoflservicenow.api.managers.VariableChoiceApiManager; import com.vsoft.uoflservicenow.api.managers.VariableChoiceApiManager;
...@@ -123,6 +124,8 @@ public class CatalogueVariableScreen extends AppCompatActivity { ...@@ -123,6 +124,8 @@ public class CatalogueVariableScreen extends AppCompatActivity {
private static final int FILE_SELECT_CODE = 0; private static final int FILE_SELECT_CODE = 0;
private TextView mAttachmentTextView; private TextView mAttachmentTextView;
private SyncStatus mSyncStatus;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
...@@ -167,7 +170,6 @@ public class CatalogueVariableScreen extends AppCompatActivity { ...@@ -167,7 +170,6 @@ public class CatalogueVariableScreen extends AppCompatActivity {
class FetchCatalogueVariable extends AsyncTask<String, Void, SyncStatus> { class FetchCatalogueVariable extends AsyncTask<String, Void, SyncStatus> {
private ProgressDialog progressDialog; private ProgressDialog progressDialog;
SyncStatus syncStatus;
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
...@@ -180,25 +182,31 @@ public class CatalogueVariableScreen extends AppCompatActivity { ...@@ -180,25 +182,31 @@ public class CatalogueVariableScreen extends AppCompatActivity {
@Override @Override
protected SyncStatus doInBackground(final String... params) { protected SyncStatus doInBackground(final String... params) {
syncStatus = CatalogueVariableApiManager.getCatalogueVariable(mCatalogueItemSysId, new GetCatalogueVariableApiListener() { CatalogueVariableApiManager.getCatalogueVariable(mCatalogueItemSysId, new GetCatalogueVariableApiListener() {
@Override @Override
public void onDoneApiCall(List<CatalogueVariableSet> variableSetList, List<CatalogueVariable> variableList) { public void onDoneApiCall(List<CatalogueVariableSet> variableSetList, List<CatalogueVariable> variableList) {
mSyncStatus = SyncStatus.SUCCESS;
/*For variableset */ /*For variableset */
for (int i = 0; i <variableSetList.size(); i++) { for (int i = 0; i <variableSetList.size(); i++) {
CatalogueVariableSet catalogueVariableSet = variableSetList.get(i); CatalogueVariableSet catalogueVariableSet = variableSetList.get(i);
setVariableChoiceData(catalogueVariableSet.getVariables()); mSyncStatus = setVariableChoiceData(catalogueVariableSet.getVariables());
if(mSyncStatus == SyncStatus.FAIL)
break;
} }
if(mSyncStatus != SyncStatus.FAIL) {
/*For variable list*/ /*For variable list*/
setVariableChoiceData(variableList); mSyncStatus = setVariableChoiceData(variableList);
syncStatus = CatalogueVariableApiManager.getUiPolicy(mCatalogueItemSysId, new GetUiPolicyApiListener() { if(mSyncStatus != SyncStatus.FAIL) {
CatalogueVariableApiManager.getUiPolicy(mCatalogueItemSysId, new GetUiPolicyApiListener() {
@Override @Override
public void onDoneApiCall(List<UiPolicyItem> uiPolicyItemList) { public void onDoneApiCall(List<UiPolicyItem> uiPolicyItemList) {
mSyncStatus = SyncStatus.SUCCESS;
mUiPolicyItemList = uiPolicyItemList; mUiPolicyItemList = uiPolicyItemList;
for (int i = 0; i < mUiPolicyItemList.size(); i++) { for (int i = 0; i < mUiPolicyItemList.size(); i++) {
UiPolicyItem uiPolicyItem = mUiPolicyItemList.get(i); UiPolicyItem uiPolicyItem = mUiPolicyItemList.get(i);
String condition = uiPolicyItem.getCondition(); String condition = uiPolicyItem.getCondition();
if(condition!=null) { if (condition != null) {
String[] splitStrings = uiPolicyItem.getCondition().split("\\^"); String[] splitStrings = uiPolicyItem.getCondition().split("\\^");
List<PartialCondition> partialConditionList = new ArrayList<>(splitStrings.length - 1); List<PartialCondition> partialConditionList = new ArrayList<>(splitStrings.length - 1);
for (int j = 0; j < splitStrings.length - 1; j++) { for (int j = 0; j < splitStrings.length - 1; j++) {
...@@ -215,7 +223,7 @@ public class CatalogueVariableScreen extends AppCompatActivity { ...@@ -215,7 +223,7 @@ public class CatalogueVariableScreen extends AppCompatActivity {
partialCondition.setOperator(Operator.EQUAL); partialCondition.setOperator(Operator.EQUAL);
/*Below condition is use for condition=empty, /*Below condition is use for condition=empty,
*we need to handle empty condition in else statement*/ *we need to handle empty condition in else statement*/
if(strings.length >= 2) { if (strings.length >= 2) {
partialCondition.setOperatorValue(strings[1]); partialCondition.setOperatorValue(strings[1]);
} else { } else {
partialCondition.setOperatorValue(""); partialCondition.setOperatorValue("");
...@@ -227,10 +235,22 @@ public class CatalogueVariableScreen extends AppCompatActivity { ...@@ -227,10 +235,22 @@ public class CatalogueVariableScreen extends AppCompatActivity {
} }
} }
} }
@Override
public void onFailApiCall() {
mSyncStatus = SyncStatus.FAIL;
}
}); });
} }
}
}
@Override
public void onFailApiCall() {
mSyncStatus = SyncStatus.FAIL;
}
}); });
return syncStatus; return mSyncStatus;
} }
@Override @Override
...@@ -250,7 +270,7 @@ public class CatalogueVariableScreen extends AppCompatActivity { ...@@ -250,7 +270,7 @@ public class CatalogueVariableScreen extends AppCompatActivity {
} }
} }
private void setVariableChoiceData(List<CatalogueVariable> variableList) { private SyncStatus setVariableChoiceData(List<CatalogueVariable> variableList) {
if(!variableList.isEmpty()) { if(!variableList.isEmpty()) {
for (int i = 0; i < variableList.size(); i++) { for (int i = 0; i < variableList.size(); i++) {
final CatalogueVariable catalogueVariable = variableList.get(i); final CatalogueVariable catalogueVariable = variableList.get(i);
...@@ -260,6 +280,7 @@ public class CatalogueVariableScreen extends AppCompatActivity { ...@@ -260,6 +280,7 @@ public class CatalogueVariableScreen extends AppCompatActivity {
VariableChoiceApiManager.getVariableChoice(catalogueVariable.getSysId(), new GetVariableChoiceApiListener() { VariableChoiceApiManager.getVariableChoice(catalogueVariable.getSysId(), new GetVariableChoiceApiListener() {
@Override @Override
public void onDoneApiCall(List<VariableChoice> variableChoiceList) { public void onDoneApiCall(List<VariableChoice> variableChoiceList) {
mSyncStatus = SyncStatus.SUCCESS;
/*Sort List of CatalogueOrder*/ /*Sort List of CatalogueOrder*/
Collections.sort(variableChoiceList, new Comparator<VariableChoice>() { Collections.sort(variableChoiceList, new Comparator<VariableChoice>() {
@Override @Override
...@@ -269,11 +290,19 @@ public class CatalogueVariableScreen extends AppCompatActivity { ...@@ -269,11 +290,19 @@ public class CatalogueVariableScreen extends AppCompatActivity {
}); });
catalogueVariable.setVariableChoiceList(variableChoiceList); catalogueVariable.setVariableChoiceList(variableChoiceList);
} }
@Override
public void onFailApiCall() {
mSyncStatus = SyncStatus.FAIL;
}
}); });
if(mSyncStatus == SyncStatus.FAIL)
break;
} }
} }
mCatalogueVariableList.addAll(variableList); mCatalogueVariableList.addAll(variableList);
} }
return mSyncStatus;
} }
private void createView() { private void createView() {
...@@ -673,6 +702,7 @@ public class CatalogueVariableScreen extends AppCompatActivity { ...@@ -673,6 +702,7 @@ public class CatalogueVariableScreen extends AppCompatActivity {
class SubmitForm extends AsyncTask<String, Void, SyncStatus> { class SubmitForm extends AsyncTask<String, Void, SyncStatus> {
private ProgressDialog progressDialog; private ProgressDialog progressDialog;
private SyncStatus syncStatus = SyncStatus.FAIL;
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
...@@ -685,9 +715,10 @@ public class CatalogueVariableScreen extends AppCompatActivity { ...@@ -685,9 +715,10 @@ public class CatalogueVariableScreen extends AppCompatActivity {
@Override @Override
protected SyncStatus doInBackground(String... params) { protected SyncStatus doInBackground(String... params) {
return CatalogueVariableApiManager.submitVariableForm(mCatalogueItemSysId, params[0], new PostVariableFormApiListener() { CatalogueVariableApiManager.submitVariableForm(mCatalogueItemSysId, params[0], new PostVariableFormApiListener() {
@Override @Override
public void onDoneApiCall(String variableFromSysId) { public void onDoneApiCall(String variableFromSysId) {
syncStatus = SyncStatus.SUCCESS;
if(mAttachmentFile !=null) { if(mAttachmentFile !=null) {
String uriContentType = getMimeType(mAttachmentUri); String uriContentType = getMimeType(mAttachmentUri);
if(uriContentType != null) { if(uriContentType != null) {
...@@ -705,11 +736,29 @@ public class CatalogueVariableScreen extends AppCompatActivity { ...@@ -705,11 +736,29 @@ public class CatalogueVariableScreen extends AppCompatActivity {
e.printStackTrace(); e.printStackTrace();
} }
RequestBody requestBody = RequestBody.create(MediaType.parse(uriContentType), buf); RequestBody requestBody = RequestBody.create(MediaType.parse(uriContentType), buf);
CatalogueVariableApiManager.postAttachment(uriContentType, variableFromSysId, mAttachmentFile.getName(), requestBody); CatalogueVariableApiManager.postAttachment(uriContentType, variableFromSysId,
mAttachmentFile.getName(), requestBody, new PostAttachmentApiListener() {
@Override
public void onDoneApiCall() {
syncStatus = SyncStatus.SUCCESS;
}
@Override
public void onFailApiCall() {
syncStatus = SyncStatus.FAIL;
}
});
} }
} }
} }
@Override
public void onFailApiCall() {
syncStatus = SyncStatus.FAIL;
}
}); });
return syncStatus;
} }
@Override @Override
...@@ -1019,6 +1068,8 @@ public class CatalogueVariableScreen extends AppCompatActivity { ...@@ -1019,6 +1068,8 @@ public class CatalogueVariableScreen extends AppCompatActivity {
} }
private void runUIPolicyActions(String sysId) { private void runUIPolicyActions(String sysId) {
if(mUiPolicyItemList == null)
return;
for(int i=0; i<mUiPolicyItemList.size(); i++) { for(int i=0; i<mUiPolicyItemList.size(); i++) {
UiPolicyItem item = mUiPolicyItemList.get(i); UiPolicyItem item = mUiPolicyItemList.get(i);
/*UIPolicy condition is null then skip iterator*/ /*UIPolicy condition is null then skip iterator*/
......
...@@ -16,12 +16,11 @@ import android.widget.Toast; ...@@ -16,12 +16,11 @@ import android.widget.Toast;
import com.google.android.gms.analytics.Tracker; import com.google.android.gms.analytics.Tracker;
import com.vsoft.uoflservicenow.CatalogueApplication; import com.vsoft.uoflservicenow.CatalogueApplication;
import com.vsoft.uoflservicenow.R; import com.vsoft.uoflservicenow.R;
import com.vsoft.uoflservicenow.api.listeners.get.GetUserApiListener; import com.vsoft.uoflservicenow.api.listeners.get.GetUserDetailApiListener;
import com.vsoft.uoflservicenow.api.listeners.get.GetUserLoginApiListener;
import com.vsoft.uoflservicenow.api.managers.LoginApiManger; import com.vsoft.uoflservicenow.api.managers.LoginApiManger;
import com.vsoft.uoflservicenow.api.managers.UserApiManager; import com.vsoft.uoflservicenow.api.managers.UserApiManager;
import com.vsoft.uoflservicenow.db.models.UserApiValues; import com.vsoft.uoflservicenow.db.models.UserApiValues;
import com.vsoft.uoflservicenow.enums.SyncStatus;
import com.vsoft.uoflservicenow.utils.CatalogueLog;
import com.vsoft.uoflservicenow.utils.Constants; import com.vsoft.uoflservicenow.utils.Constants;
import com.vsoft.uoflservicenow.utils.DialogUtils; import com.vsoft.uoflservicenow.utils.DialogUtils;
import com.vsoft.uoflservicenow.utils.KeyboardUtil; import com.vsoft.uoflservicenow.utils.KeyboardUtil;
...@@ -39,14 +38,18 @@ import butterknife.OnClick; ...@@ -39,14 +38,18 @@ import butterknife.OnClick;
*/ */
public class LoginScreen extends Activity { public class LoginScreen extends Activity {
@BindView(R.id.login_screen_username_edit_text) @BindView(R.id.login_screen_username_edit_text) EditText mUserNameEditText;
EditText mUserNameEditText; @BindView(R.id.login_screen_password_edit_text) EditText mPasswordEditText;
@BindView(R.id.login_screen_password_edit_text)
EditText mPasswordEditText;
private List<UserApiValues> mUserDetails; private List<UserApiValues> mUserDetails;
private CatalogueApplication mApplication; private CatalogueApplication mApplication;
private static final int API_SUCCESS_USER_LOGIN = 1;
private static final int API_FAIL_USER_LOGIN = 2;
private static final int API_SUCCESS_USER_DETAIL = 3;
private static final int API_FAIL_USER_DETAIL = 4;
private int apiStatus;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
...@@ -115,10 +118,9 @@ public class LoginScreen extends Activity { ...@@ -115,10 +118,9 @@ public class LoginScreen extends Activity {
callLoginAPI(); callLoginAPI();
} }
private class LoginDetailsSendToServer extends AsyncTask<String, Integer, SyncStatus> { private class LoginDetailsSendToServer extends AsyncTask<String, Integer, Integer> {
private ProgressDialog progressDialog; private ProgressDialog progressDialog;
private static final int USER_DETAIL = 1; private static final int USER_DETAIL = 1;
private String userName; private String userName;
@Override @Override
...@@ -131,46 +133,34 @@ public class LoginScreen extends Activity { ...@@ -131,46 +133,34 @@ public class LoginScreen extends Activity {
} }
@Override @Override
protected SyncStatus doInBackground(String... params) { protected Integer doInBackground(String... params) {
SyncStatus syncStatus = null;
userName = params[0];//"a0kuma18"; userName = params[0];//"a0kuma18";
String password = params[1];//"v$0ftA$win"; String password = params[1];//"v$0ftA$win";
try { LoginApiManger.submitLoginValues(Constants.GRANT_TYPE, Constants.CLIENT_ID, Constants
syncStatus = LoginApiManger.submitLoginValues(Constants.GRANT_TYPE, Constants.CLIENT_ID, Constants .CLIENT_SECRET, userName, password, new GetUserLoginApiListener() {
.CLIENT_SECRET, userName, password); @Override
public void onDoneApiCall() {
if (syncStatus != null) { apiStatus = API_SUCCESS_USER_LOGIN;
if (syncStatus == SyncStatus.SUCCESS) {
publishProgress(USER_DETAIL); publishProgress(USER_DETAIL);
return UserApiManager.getUserDetailResponse(userName, new GetUserApiListener() { UserApiManager.getUserDetailResponse(userName, new GetUserDetailApiListener() {
@Override @Override
public void onDoneApiCall(List<UserApiValues> userValues) { public void onDoneApiCall(List<UserApiValues> userValues) {
apiStatus = API_SUCCESS_USER_DETAIL;
mUserDetails = userValues; mUserDetails = userValues;
} }
});
} else if (syncStatus == SyncStatus.SERVICEDOWN) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(LoginScreen.this, R.string.server_not_reachable, Toast.LENGTH_LONG).show();
}
});
} else if (syncStatus == SyncStatus.FAIL) {
runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void onFailApiCall() {
Toast.makeText(LoginScreen.this, R.string.login_screen_invalid_username_and_password_string, Toast.LENGTH_LONG).show(); apiStatus = API_FAIL_USER_DETAIL;
} }
}); });
} }
@Override
public void onFailApiCall() {
apiStatus = API_FAIL_USER_LOGIN;
} }
} catch (Exception e) { });
CatalogueLog.e("LoginScreen: LoginDetailsSendToServer: doInBackground: Exception: "+e); return apiStatus;
}
return syncStatus;
} }
@Override @Override
...@@ -182,12 +172,12 @@ public class LoginScreen extends Activity { ...@@ -182,12 +172,12 @@ public class LoginScreen extends Activity {
} }
@Override @Override
protected void onPostExecute(SyncStatus syncStatus) { protected void onPostExecute(Integer syncStatus) {
super.onPostExecute(syncStatus); super.onPostExecute(syncStatus);
if (progressDialog != null && progressDialog.isShowing()) { if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss(); progressDialog.dismiss();
} }
if (syncStatus != null && syncStatus == SyncStatus.SUCCESS) { if (syncStatus == API_SUCCESS_USER_DETAIL) {
if (mUserDetails != null) { if (mUserDetails != null) {
String firstName = mUserDetails.get(0).getFirstName(); String firstName = mUserDetails.get(0).getFirstName();
String lastName = mUserDetails.get(0).getLastName(); String lastName = mUserDetails.get(0).getLastName();
...@@ -198,6 +188,10 @@ public class LoginScreen extends Activity { ...@@ -198,6 +188,10 @@ public class LoginScreen extends Activity {
} else { } else {
Toast.makeText(LoginScreen.this, R.string.user_detail_not_available, Toast.LENGTH_LONG).show(); Toast.makeText(LoginScreen.this, R.string.user_detail_not_available, Toast.LENGTH_LONG).show();
} }
} else if (syncStatus == API_FAIL_USER_LOGIN) {
Toast.makeText(LoginScreen.this, R.string.login_screen_invalid_username_and_password_string, Toast.LENGTH_LONG).show();
} else if (syncStatus == API_FAIL_USER_DETAIL) {
Toast.makeText(LoginScreen.this, R.string.failed_to_fetch_user_detail_string, Toast.LENGTH_LONG).show();
} }
} }
} }
......
...@@ -93,6 +93,7 @@ public class MyIncidentScreen extends AppCompatActivity { ...@@ -93,6 +93,7 @@ public class MyIncidentScreen extends AppCompatActivity {
class FetchIncident extends AsyncTask<String, Void, SyncStatus> { class FetchIncident extends AsyncTask<String, Void, SyncStatus> {
private ProgressDialog progressDialog; private ProgressDialog progressDialog;
private SyncStatus syncStatus = SyncStatus.FAIL;
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
...@@ -105,13 +106,20 @@ public class MyIncidentScreen extends AppCompatActivity { ...@@ -105,13 +106,20 @@ public class MyIncidentScreen extends AppCompatActivity {
@Override @Override
protected SyncStatus doInBackground(String... params) { protected SyncStatus doInBackground(String... params) {
return IncidentApiManager.getIncident(new GetIncidentApiListener() { IncidentApiManager.getIncident(new GetIncidentApiListener() {
@Override @Override
public void onDoneApiCall(List<Incident> incidentList) { public void onDoneApiCall(List<Incident> incidentList) {
syncStatus = SyncStatus.SUCCESS;
CatalogueLog.e("Data: incidentList: "+incidentList); CatalogueLog.e("Data: incidentList: "+incidentList);
mIncidentList = incidentList; mIncidentList = incidentList;
} }
@Override
public void onFailApiCall() {
syncStatus = SyncStatus.FAIL;
}
}); });
return syncStatus;
} }
@Override @Override
......
...@@ -72,6 +72,7 @@ public class MyRequestActivity extends AppCompatActivity { ...@@ -72,6 +72,7 @@ public class MyRequestActivity extends AppCompatActivity {
class FetchMyRequestData extends AsyncTask<String, Void, SyncStatus> { class FetchMyRequestData extends AsyncTask<String, Void, SyncStatus> {
private ProgressDialog progressDialog; private ProgressDialog progressDialog;
private SyncStatus syncStatus = SyncStatus.FAIL;
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
...@@ -84,12 +85,19 @@ public class MyRequestActivity extends AppCompatActivity { ...@@ -84,12 +85,19 @@ public class MyRequestActivity extends AppCompatActivity {
@Override @Override
protected SyncStatus doInBackground(String... params) { protected SyncStatus doInBackground(String... params) {
return MyRequestApiManager.getMyrequests(new GetMyRequestApiListener() { MyRequestApiManager.getMyrequests(new GetMyRequestApiListener() {
@Override @Override
public void onDoneApiCall(List<MyRequest> requestList) { public void onDoneApiCall(List<MyRequest> requestList) {
syncStatus = SyncStatus.SUCCESS;
mMyRequestList = requestList; mMyRequestList = requestList;
} }
@Override
public void onFailApiCall() {
syncStatus = SyncStatus.FAIL;
}
}); });
return syncStatus;
} }
@Override @Override
......
...@@ -151,6 +151,7 @@ public class ReportIncidentScreen extends AppCompatActivity { ...@@ -151,6 +151,7 @@ public class ReportIncidentScreen extends AppCompatActivity {
class submitIncident extends AsyncTask<String, Void, SyncStatus> { class submitIncident extends AsyncTask<String, Void, SyncStatus> {
private ProgressDialog progressDialog; private ProgressDialog progressDialog;
private String number; private String number;
private SyncStatus syncStatus;
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
...@@ -174,12 +175,20 @@ public class ReportIncidentScreen extends AppCompatActivity { ...@@ -174,12 +175,20 @@ public class ReportIncidentScreen extends AppCompatActivity {
e.printStackTrace(); e.printStackTrace();
} }
return IncidentApiManager.submitIncidentForm(incidentJsonObject.toString(), new PostIncidentApiListener() { IncidentApiManager.submitIncidentForm(incidentJsonObject.toString(), new PostIncidentApiListener() {
@Override @Override
public void onDoneApiCall(String incidentNumber) { public void onDoneApiCall(String incidentNumber) {
syncStatus = SyncStatus.SUCCESS;
number = incidentNumber; number = incidentNumber;
} }
@Override
public void onFailApiCall() {
syncStatus = SyncStatus.FAIL;
}
}); });
return syncStatus;
} }
@Override @Override
......
...@@ -35,13 +35,13 @@ ...@@ -35,13 +35,13 @@
<string name="failed_to_fetch_reference_string">Failed to fetch References.</string> <string name="failed_to_fetch_reference_string">Failed to fetch References.</string>
<string name="failed_to_submit_form_string">Failed to submit form.</string> <string name="failed_to_submit_form_string">Failed to submit form.</string>
<string name="failed_to_fetch_incident_string">Failed to fetch incidents.</string> <string name="failed_to_fetch_incident_string">Failed to fetch incidents.</string>
<string name="failed_to_fetch_user_detail_string">Failed to fetch User Details.</string>
<!--Login Screen--> <!--Login Screen-->
<string name="login_screen_login_string">Login</string> <string name="login_screen_login_string">Login</string>
<string name="login_screen_logging_in_loading_string">Logging in&#8230;</string> <string name="login_screen_logging_in_loading_string">Logging in&#8230;</string>
<string name="login_screen_getting_user_detail_loading_string">Getting user details&#8230;</string> <string name="login_screen_getting_user_detail_loading_string">Getting user details&#8230;</string>
<string name="login_screen_invalid_username_and_password_string">Invalid username and password</string> <string name="login_screen_invalid_username_and_password_string">Invalid username and password</string>
<string name="server_not_reachable">Unable to connect to server. Please try again later.</string>
<string name="user_detail_not_available">Unable to fetch user details.</string> <string name="user_detail_not_available">Unable to fetch user details.</string>
<string name="user_error">Please enter username</string> <string name="user_error">Please enter username</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment