This file contains hidden or 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
| struct DataEncodable<T> { | |
| static func encode(var value: T) -> NSData { | |
| return withUnsafePointer(&value) { NSData(bytes: $0, length: sizeof(T)) } | |
| } | |
| static func decode(data: NSData) -> T { | |
| let pointer = UnsafeMutablePointer<T>.alloc(sizeof(T)) | |
| data.getBytes(pointer, length: sizeof(T)) | |
This file contains hidden or 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
| package se.marteinn.utils; | |
| import android.content.Context; | |
| import android.os.AsyncTask; | |
| import android.view.View; | |
| import android.view.inputmethod.InputMethodManager; | |
| import android.widget.EditText; | |
| /** | |
| * Created by martinsandstrom on 2014-04-21. |
This file contains hidden or 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
| public class MyAsyncTask extends AsyncTask<Void, Void, Cursor> { | |
| @Override | |
| protected Cursor doInBackground(Void... params) { | |
| DatabaseHelper helper = new DatabaseHelper(MainActivity.this); | |
| return helper.getReadableDatabase().rawQuery("SELECT * FROM myTable", null); | |
| } | |
| @Override |
This file contains hidden or 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
| package com.gndec.gcm | |
| import android.app.AlertDialog; | |
| import android.content.Context; | |
| import android.content.DialogInterface; | |
| public class AlertDialogManager { | |
| // Function to display simple Alert Dialog | |
| public void showAlertDialog(Context context, String title, String message, |
This file contains hidden or 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
| AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); | |
| alertDialog.setTitle("New Location"); | |
| alertDialog.setMessage("Is this the new location?"); | |
| alertDialog.setPositiveButton ("Yes", new DialogInterface.OnClickListener() { | |
| public void onClick(DialogInterface dialog, int which) { | |
| returnResult(); | |
| } | |
| }); | |
| alertDialog.setNegativeButton("No", new DialogInterface.OnClickListener() { | |
| public void onClick(DialogInterface dialogo1, int id) { |
This file contains hidden or 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
| package com.tediscript.time; | |
| /** | |
| * | |
| * @author tediscript | |
| */ | |
| public class TimeAgo { | |
| public static long SECOND = 1000l; | |
| public static long MINUTE = SECOND * 60l; |