-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
getting programmatic timeout working
- Loading branch information
Showing
8 changed files
with
163 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<mockservice version="1.0" xml:lang="en-US"> | ||
<service default_real_url_index="0" default_scenario_id="1" description="" hang_time="0" http_content_type="application/json;" name="TimeoutService" service_response_type="1" url="TimeoutService"> | ||
<scenario id="1" name="Default"> | ||
<scenario_match/> | ||
<scenario_response><![CDATA[{"status":"SUCCESS"}]]></scenario_response> | ||
</scenario> | ||
</service> | ||
</mockservice> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="horizontal" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" | ||
android:padding="3dp" | ||
> | ||
<ImageView android:id="@+id/image" | ||
android:layout_width="wrap_content" | ||
android:layout_height="fill_parent" | ||
android:layout_marginRight="10dp" | ||
/> | ||
<TextView android:id="@+id/text" | ||
android:layout_width="wrap_content" | ||
android:layout_height="fill_parent" | ||
android:textColor="#000" | ||
/> | ||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/me/ericmiles/mobiletrans/rest/SendFailedMessageService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* | ||
*/ | ||
package me.ericmiles.mobiletrans.rest; | ||
|
||
import me.ericmiles.mobiletrans.Constants; | ||
import me.ericmiles.mobiletrans.operations.Operation; | ||
import me.ericmiles.mobiletrans.operations.Operation.OperationResponse.Status; | ||
import me.ericmiles.mobiletrans.operations.OperationIntentFactory; | ||
import android.app.IntentService; | ||
import android.content.Intent; | ||
import android.util.Log; | ||
|
||
/** | ||
* @author emiles | ||
* | ||
*/ | ||
public class SendFailedMessageService extends IntentService { | ||
|
||
private static final String TAG = SendFailedMessageService.class.getSimpleName(); | ||
|
||
public SendFailedMessageService() { | ||
super("SendFailedMessageService"); | ||
} | ||
|
||
/* | ||
* (non-Javadoc) | ||
* | ||
* @see android.app.IntentService#onHandleIntent(android.content.Intent) | ||
*/ | ||
@Override | ||
protected void onHandleIntent(Intent intent) { | ||
// we could do all sorts of things here, but all we're going to do is | ||
// notify | ||
// the calling activity that the call failed | ||
try { | ||
|
||
// we're gonna cheat massively here, but I want to ensure that the | ||
// error activity has finished up before we send this result | ||
// broadcast | ||
Thread.sleep(1000); | ||
|
||
Class<? extends Operation.OperationResponse> clazz = ((Operation.OperationRequest) intent | ||
.getParcelableExtra(Constants.REST_REQUEST)).getResponseType(); | ||
Operation.OperationResponse response = clazz.newInstance(); | ||
response.status = Status.FAILED; | ||
response.errorMsg = "Sorry! Something went terribly wrong"; | ||
|
||
// create the response broadcast and send on | ||
final Intent forward = OperationIntentFactory.getInstance(getApplicationContext()).createIntent(response); | ||
sendOrderedBroadcast(forward, Constants.PERMISSION); | ||
} catch (Exception e) { | ||
Log.e(TAG, "oops", e); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters