Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Enrique Diaz
committed
Jul 7, 2011
1 parent
34a66be
commit 230c65c
Showing
132 changed files
with
5,372 additions
and
58 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
83 changes: 83 additions & 0 deletions
83
.metadata/.plugins/org.eclipse.core.resources/.history/0/10b0a79e73a800101125cb1fec0380ce
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,83 @@ | ||
package org.androidtitlan.itam.simpledownload; | ||
|
||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
|
||
import org.apache.http.client.HttpClient; | ||
import org.apache.http.client.ResponseHandler; | ||
import org.apache.http.client.methods.HttpGet; | ||
import org.apache.http.impl.client.DefaultHttpClient; | ||
|
||
import android.app.Activity; | ||
import android.app.IntentService; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.os.Environment; | ||
import android.os.Message; | ||
import android.os.Messenger; | ||
import android.util.Log; | ||
|
||
public class SimpleDownload extends IntentService { | ||
public static final String EXTRA_MESSENGER="org.androidtitlan.itam.EXTRA_MESSENGER"; | ||
|
||
private HttpClient mHttpClient = null; | ||
|
||
public SimpleDownload() { | ||
super("SimpleDownload"); | ||
} | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
mHttpClient = new DefaultHttpClient(); | ||
} | ||
@Override | ||
public void onDestroy() { | ||
super.onDestroy(); | ||
mHttpClient.getConnectionManager().shutdown(); | ||
} | ||
|
||
@Override | ||
protected void onHandleIntent(Intent i) { | ||
HttpGet getMethod= new HttpGet(i.getData().toString()); | ||
int result = Activity.RESULT_CANCELED; | ||
|
||
try{ | ||
ResponseHandler<byte[]> mResponseHandler = new ByteArrayResponseHandler(); | ||
byte[] responseBody = mHttpClient.execute(getMethod, mResponseHandler); | ||
File output=new File(Environment.getExternalStorageDirectory(), | ||
i.getData().getLastPathSegment()); | ||
|
||
if(output.exists()){ | ||
output.delete(); | ||
} | ||
|
||
FileOutputStream fos = FileOutputStream(output.getPath()); | ||
fos.write(responseBody); | ||
fos.close(); | ||
result = Activity.RESULT_OK; | ||
|
||
catch (Exception e2) { | ||
Log.e(getClass().getName(), "Exception in download", e2); | ||
} | ||
Bundle extras = i.getExtras(); | ||
|
||
if(extras!=null){ | ||
Messenger messenger = (Messenger)extras.get(EXTRA_MESSENGER); | ||
Message msg = Message.obtain(); | ||
|
||
msg.arg1 = result; | ||
try{ | ||
messenger.send(msg); | ||
} | ||
catch(android.os.RemoteException e1){ | ||
Log.w(getClass().getName(), "Exception sending Message",e1); | ||
|
||
} | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
67 changes: 67 additions & 0 deletions
67
.metadata/.plugins/org.eclipse.core.resources/.history/1/60c258ff72a800101125cb1fec0380ce
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,67 @@ | ||
package org.androidtitlan.itam.simpledownload; | ||
|
||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
|
||
import org.apache.http.client.HttpClient; | ||
import org.apache.http.client.ResponseHandler; | ||
import org.apache.http.client.methods.HttpGet; | ||
import org.apache.http.impl.client.DefaultHttpClient; | ||
|
||
import android.app.Activity; | ||
import android.app.IntentService; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.os.Environment; | ||
import android.util.Log; | ||
|
||
public class SimpleDownload extends IntentService { | ||
public static final String EXTRA_MESSENGER="org.androidtitlan.itam.EXTRA_MESSENGER"; | ||
|
||
private HttpClient mHttpClient = null; | ||
|
||
public SimpleDownload() { | ||
super("SimpleDownload"); | ||
} | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
mHttpClient = new DefaultHttpClient(); | ||
} | ||
@Override | ||
public void onDestroy() { | ||
super.onDestroy(); | ||
mHttpClient.getConnectionManager().shutdown(); | ||
} | ||
|
||
@Override | ||
protected void onHandleIntent(Intent i) { | ||
HttpGet getMethod= new HttpGet(i.getData().toString()); | ||
int result = Activity.RESULT_CANCELED; | ||
|
||
try{ | ||
ResponseHandler<byte[]> mResponseHandler = new ByteArrayResponseHandler(); | ||
byte[] responseBody = mHttpClient.execute(getMethod, mResponseHandler); | ||
File output=new File(Environment.getExternalStorageDirectory(), | ||
i.getData().getLastPathSegment()); | ||
|
||
if(output.exists()){ | ||
output.delete(); | ||
} | ||
|
||
FileOutputStream fos = FileOutputStream(output.getPath()); | ||
fos.write(responseBody); | ||
fos.close(); | ||
result = Activity.RESULT_OK; | ||
|
||
catch (Exception e2) { | ||
Log.e(getClass().getName(), "Exception in download", e2); | ||
} | ||
Bundle extras = i.getExtras(); | ||
|
||
|
||
|
||
|
||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
.metadata/.plugins/org.eclipse.core.resources/.history/1/9017d1ea70a800101125cb1fec0380ce
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 org.androidtitlan.itam.simpledownload; | ||
|
||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
|
||
import org.apache.http.client.HttpClient; | ||
import org.apache.http.client.ResponseHandler; | ||
import org.apache.http.client.methods.HttpGet; | ||
import org.apache.http.impl.client.DefaultHttpClient; | ||
|
||
import android.app.Activity; | ||
import android.app.IntentService; | ||
import android.content.Intent; | ||
import android.os.Environment; | ||
|
||
public class SimpleDownload extends IntentService { | ||
public static final String EXTRA_MESSENGER="org.androidtitlan.itam.EXTRA_MESSENGER"; | ||
|
||
private HttpClient mHttpClient = null; | ||
|
||
public SimpleDownload() { | ||
super("SimpleDownload"); | ||
} | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
mHttpClient = new DefaultHttpClient(); | ||
} | ||
@Override | ||
public void onDestroy() { | ||
super.onDestroy(); | ||
mHttpClient.getConnectionManager().shutdown(); | ||
} | ||
|
||
@Override | ||
protected void onHandleIntent(Intent i) { | ||
HttpGet getMethod= new HttpGet(i.getData().toString()); | ||
int result = Activity.RESULT_CANCELED; | ||
|
||
try{ | ||
ResponseHandler<byte[]> mResponseHandler = new ByteArrayResponseHandler(); | ||
byte[] responseBody = mHttpClient.execute(getMethod, mResponseHandler); | ||
File output=new File(Environment.getExternalStorageDirectory(), | ||
i.getData().getLastPathSegment()); | ||
|
||
if(output.exists()){ | ||
output.delete(); | ||
} | ||
|
||
FileOutputStream fos = FileOutputStream(output.getPath()); | ||
fos.write(responseBody); | ||
fos.close(); | ||
} | ||
} | ||
|
||
|
||
} |
51 changes: 51 additions & 0 deletions
51
.metadata/.plugins/org.eclipse.core.resources/.history/15/40f1bc306fa800101125cb1fec0380ce
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,51 @@ | ||
package org.androidtitlan.itam.simpledownload; | ||
|
||
import java.io.File; | ||
|
||
import org.apache.http.client.HttpClient; | ||
import org.apache.http.client.ResponseHandler; | ||
import org.apache.http.client.methods.HttpGet; | ||
import org.apache.http.impl.client.DefaultHttpClient; | ||
|
||
import android.app.Activity; | ||
import android.app.IntentService; | ||
import android.content.Intent; | ||
import android.os.Environment; | ||
|
||
public class SimpleDownload extends IntentService { | ||
public static final String EXTRA_MESSENGER="org.androidtitlan.itam.EXTRA_MESSENGER"; | ||
|
||
private HttpClient mHttpClient = null; | ||
public SimpleDownload(String name) { | ||
|
||
super(name); | ||
} | ||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
mHttpClient = new DefaultHttpClient(); | ||
} | ||
@Override | ||
public void onDestroy() { | ||
super.onDestroy(); | ||
mHttpClient.getConnectionManager().shutdown(); | ||
} | ||
|
||
@Override | ||
protected void onHandleIntent(Intent intent) { | ||
HttpGet getMethod= new HttpGet(i.getData().toString()); | ||
int result =Activity.RESULT_CANCELED; | ||
|
||
try{ | ||
ResponseHandler<byte[]> responseHandler = new ByteArrayResponseHandler(); | ||
byte[] responseBody = mHttpClient.execute(getMethod, responseHandler); | ||
File output=new File(Environment.getExternalStorageDirectory(),i.getData().getLastPathSegment()); | ||
|
||
if(output.exists()){ | ||
output.delete(); | ||
} | ||
} | ||
} | ||
|
||
|
||
} |
84 changes: 84 additions & 0 deletions
84
.metadata/.plugins/org.eclipse.core.resources/.history/19/309362a973a800101125cb1fec0380ce
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,84 @@ | ||
package org.androidtitlan.itam.simpledownload; | ||
|
||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
|
||
import org.apache.http.client.HttpClient; | ||
import org.apache.http.client.ResponseHandler; | ||
import org.apache.http.client.methods.HttpGet; | ||
import org.apache.http.impl.client.DefaultHttpClient; | ||
|
||
import android.app.Activity; | ||
import android.app.IntentService; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.os.Environment; | ||
import android.os.Message; | ||
import android.os.Messenger; | ||
import android.util.Log; | ||
|
||
public class SimpleDownload extends IntentService { | ||
public static final String EXTRA_MESSENGER="org.androidtitlan.itam.EXTRA_MESSENGER"; | ||
|
||
private HttpClient mHttpClient = null; | ||
|
||
public SimpleDownload() { | ||
super("SimpleDownload"); | ||
} | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
mHttpClient = new DefaultHttpClient(); | ||
} | ||
@Override | ||
public void onDestroy() { | ||
super.onDestroy(); | ||
mHttpClient.getConnectionManager().shutdown(); | ||
} | ||
|
||
@Override | ||
protected void onHandleIntent(Intent i) { | ||
HttpGet getMethod= new HttpGet(i.getData().toString()); | ||
int result = Activity.RESULT_CANCELED; | ||
|
||
try{ | ||
ResponseHandler<byte[]> mResponseHandler = new ByteArrayResponseHandler(); | ||
byte[] responseBody = mHttpClient.execute(getMethod, mResponseHandler); | ||
File output=new File(Environment.getExternalStorageDirectory(), | ||
i.getData().getLastPathSegment()); | ||
|
||
if(output.exists()){ | ||
output.delete(); | ||
} | ||
|
||
FileOutputStream fos = FileOutputStream(output.getPath()); | ||
fos.write(responseBody); | ||
fos.close(); | ||
result = Activity.RESULT_OK; | ||
} | ||
|
||
catch (Exception e2) { | ||
Log.e(getClass().getName(), "Exception in download", e2); | ||
} | ||
Bundle extras = i.getExtras(); | ||
|
||
if(extras!=null){ | ||
Messenger messenger = (Messenger)extras.get(EXTRA_MESSENGER); | ||
Message msg = Message.obtain(); | ||
|
||
msg.arg1 = result; | ||
try{ | ||
messenger.send(msg); | ||
} | ||
catch(android.os.RemoteException e1){ | ||
Log.w(getClass().getName(), "Exception sending Message",e1); | ||
|
||
} | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.