Skip to content

Instantly share code, notes, and snippets.

View koalahamlet's full-sized avatar
㊙️
shhhh

Michael Alan Huff koalahamlet

㊙️
shhhh
View GitHub Profile
@koalahamlet
koalahamlet / gist:9669323
Last active August 29, 2015 13:57
submitNewUpload
private void submitNewUpload(String projectid, final String mediaid, String calloutId) {
handleUploadComplete(mediaid);
try {
JSONObject jsonObject = ServiceUtils.createInsertSubmitRequest(token, projectid,
mediaid, calloutId);
Log.d(CLASS_NAME, "submitNewUpload Send => " + jsonObject.toString());
String url = Constants.BASE_URL + API_SUBMIT_ENDPOINT;
JsonObjectRequest objectRequest = new JsonObjectRequest(Request.Method.POST, url,
jsonObject, new Response.Listener<JSONObject>() {
@koalahamlet
koalahamlet / gist:9669392
Created March 20, 2014 17:34
handleUploadComplete
private void handleUploadComplete(String mediaId) {
Intent postUploadSubmit = new Intent();
postUploadSubmit.setAction(Constants.ACTION_MEDIA_ID_RECEIVED);
postUploadSubmit.putExtra("upload_id", uploadId);
postUploadSubmit.putExtra("media_id", mediaId);
sendBroadcast(postUploadSubmit);
Log.d(CLASS_NAME, "UPLOAD COMPLETE FOR UPLOAD: " + uploadFile.getFilename());
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.leedir.MainActivity">
<View
android:id="@+id/loadingView"
android:layout_width="match_parent"
String[] blah = new String[1];
blah[0] =DB.Assets.KEY_REFERENCE_CODE;
Cursor cursor = db.query(DB.DB_ASSETS, blah, null, null, null, null, null);
if(cursor.moveToFirst())
db.execSQL(String.format(Locale.US,"ALTER TABLE %s ADD COLUMN ADD COLUMN %s",
DB.DB_ASSETS, DB.Assets.KEY_REFERENCE_CODE));
@koalahamlet
koalahamlet / gist:10499015
Created April 11, 2014 20:29
how to have picasso load into an image that you're not sure is there.
@Override
protected void onResume() {
super.onResume();
imageView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
loadImageIfReady();
}
});
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//make restAdapter
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint("http://prolific-interview.herokuapp.com/53444c44ce48cc11ad329ec5")
.build();
@koalahamlet
koalahamlet / gist:10950715
Created April 17, 2014 03:23
how I would usually share
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
// app icon in action bar clicked; go home
this.finish();
return true;
case R.id.menu_share:
Intent share = new Intent(Intent.ACTION_SEND);
@koalahamlet
koalahamlet / gist:10952233
Created April 17, 2014 04:09
shareActionProvider
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_book_detail, menu);
// Get the ActionProvider for later usage
provider = (ShareActionProvider) menu.findItem(R.id.menu_share).getActionProvider();
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
@koalahamlet
koalahamlet / gist:10953002
Last active August 29, 2015 13:59
book detail menu
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="mike.libraryplus.app.BookDetailActivty">
<item
android:id="@+id/menu_share"
android:actionProviderClass="android.widget.ShareActionProvider"
android:icon="@drawable/ic_share"
android:orderInCategory="100"
@koalahamlet
koalahamlet / gist:10953081
Created April 17, 2014 04:36
second attempt
@POST("/books")
void createBook(@Body Book book,
Callback<Book> cb);
04-16 20:59:24.782 8697-8697/mike.libraryplus.app E/DEBUG﹕ retrofit.RetrofitError: java.io.EOFException
04-16 20:59:33.219 8697-8697/mike.libraryplus.app E/DEBUG﹕ retrofit.RetrofitError: retrofit.converter.ConversionException: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2