NetworkResponse¶
-
public class
NetworkResponse
<E>¶ Class to store responses after attempting networking tasks
Constructors¶
NetworkResponse¶
-
public
NetworkResponse
(NetworkResponse<?> toConvert)¶ Create a new NetworkResponse of the type designated in
<>
from another NetworkResponse of any other type. Any payload in the source object will not be transferred to the created one. All other fields are copied.Parameters: - toConvert – Source to create new object from. All properties except payload will be copied.
NetworkResponse¶
-
public
NetworkResponse
(boolean inFail)¶ Constructor that creates a generic message based on “inFail”
Parameters: - inFail – Failure state provided by user (true if failed)
NetworkResponse¶
-
public
NetworkResponse
(boolean inFail, int inMessageID)¶ Constructor that sets message and failures state based on arguments
Parameters: - inFail – Failure state provided by user (true if failed)
- inMessageID – ID for string resource containing message
NetworkResponse¶
-
public
NetworkResponse
(E inPayload)¶ Constructor that stores a payload and sets the failure state to false
Parameters: - inPayload – Payload returned by networking request
Methods¶
fail¶
-
public boolean
fail
()¶ Check whether the network request failed
Returns: true if the request failed, false if it succeeded
genErrorDialog¶
-
public static AlertDialog
genErrorDialog
(Context context, int messageID)¶ Get an error dialog that can be displayed to the user
Parameters: - context – Context upon which to display error dialog (Should be
someClass.this
) - messageID – String resource ID of message to display
Returns: AlertDialog
with specified alert message.- context – Context upon which to display error dialog (Should be
genErrorDialog¶
-
public static AlertDialog
genErrorDialog
(Context context, int messageID, boolean authFail)¶ Get an error dialog that can be displayed to the user
Parameters: - context – Context upon which to display error dialog (Should be
someClass.this
) - messageID – String resource ID of message to display
- authFail – Whether or not the user should be directed to
LoginActivity
upon dismissing the dialog
Returns: AlertDialog
with specified alert message and which directs the user toLoginActivity
upon dismissal ifauthFail
is true.- context – Context upon which to display error dialog (Should be
genSuccessDialog¶
-
public static AlertDialog
genSuccessDialog
(Context context, int messageID)¶ Get a confirmation dialog that can be displayed to the user to reflect a successful operation
Parameters: - context – Context upon which to display dialog (Should be
someClass.this
) - messageID – String resource ID of message to display
Returns: AlertDialog
with specified alert message- context – Context upon which to display dialog (Should be
getAuthFailed¶
-
public static NetworkResponse<API.Get.LoginResponse>
getAuthFailed
(int messageID)¶ Get a NetworkResponse object with
NetworkResponse.isAuthFailed
istrue
. This means that when the user dismisses the error dialog generated byNetworkResponse.getErrorDialog(Context)
orNetworkResponse.showErrorDialog(Context)
,LoginActivity
will be launched.Parameters: - messageID – String reference to the message describing the error. Will be shown to user
Returns: NetworkResponse object to describe an authentication failure.
getErrorDialog¶
-
public AlertDialog
getErrorDialog
(Context context)¶ Get an error dialog that can be displayed to show message from messageID to user
Parameters: - context – Context upon which to display error dialog (Should be
someClass.this
)
Returns: Dialog that can be shown
- context – Context upon which to display error dialog (Should be
getMessageID¶
-
public int
getMessageID
()¶ Get the resource ID of the message to display to the user
Returns: Resource ID of message
getPayload¶
-
public E
getPayload
()¶ Get the payload returned by the network operation
Returns: Payload returned by network operation
isAuthFailed¶
-
public boolean
isAuthFailed
()¶ Get whether the current object represents a failed authentication
Returns: true
if object represents an authentication failure,false
otherwise
setAuthFailed¶
-
public void
setAuthFailed
(boolean isAuthFailed)¶ Set whether the current object represents a failed authentication
Parameters: - isAuthFailed –
true
if object represents an authentication failure,false
otherwise
- isAuthFailed –