diff options
| author | Reiner Herrmann <reiner@reiner-h.de> | 2012-12-27 22:10:02 +0100 |
|---|---|---|
| committer | Reiner Herrmann <reiner@reiner-h.de> | 2012-12-27 22:10:02 +0100 |
| commit | 8a2d76c4903687b3f9199c125c2e945b9285d1a3 (patch) | |
| tree | 15631335c6f9314679f0fc949fb65d5f63e50fe0 /src/eu/deki/paste/PasteTask.java | |
| parent | 2c2a35d664fc7a22d55f6006e58bfd57a76eb093 (diff) | |
working SSL connection and POST request to deki.eu
Diffstat (limited to 'src/eu/deki/paste/PasteTask.java')
| -rw-r--r-- | src/eu/deki/paste/PasteTask.java | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/eu/deki/paste/PasteTask.java b/src/eu/deki/paste/PasteTask.java new file mode 100644 index 0000000..29b5c32 --- /dev/null +++ b/src/eu/deki/paste/PasteTask.java @@ -0,0 +1,62 @@ +package eu.deki.paste; + +import java.io.IOException; +import android.os.AsyncTask; +import android.widget.Toast; +import android.content.Context; +import android.util.Log; + +public abstract class PasteTask extends AsyncTask<String, Void, String> +{ + private String errorMessage = null; + protected Context parentActivity = null; + + public PasteTask(Context parent) + { + super(); + parentActivity = parent; + } + + @Override + protected String doInBackground(String... params) + { + String title, content, expiration, result; + + if(params.length != 3) + return null; + + title = params[0]; + content = params[1]; + expiration = params[2]; + + try + { + result = paste(title, content, expiration); + } + catch(IOException ex) + { + cancel(false); + errorMessage = ex.getLocalizedMessage(); + result = errorMessage; + Log.e("PasteIt", "doInBackground", ex); + } + + return result; + } + + @Override + protected void onPostExecute(String result) + { + + } + + @Override + protected void onCancelled() + { + //Toast toast = Toast.makeText(parentActivity.getApplicationContext(), errorMessage, Toast.LENGTH_SHORT); + //toast.show(); + } + + protected abstract String paste(String title, String content, String delay) throws IOException; +} + |
