Skip to content

Instantly share code, notes, and snippets.

func test() {
var human: [String:AnyObject] = [:]
human["name"] = "Gosho" as? AnyObject
human["id"] = 1 as? AnyObject
var pet: [String:AnyObject] = [:]
pet["name"] = "Zubi" as? AnyObject
pet["id"] = 1 as? AnyObject
var pet2: [String:AnyObject] = [:]
@TonyNikolov
TonyNikolov / compile
Created January 10, 2018 08:29
How to handle camera result in production
compile 'com.android.support:exifinterface:26.1.0'
try {
//..First convert the Image to the allowable size so app do not throw Memory_Out_Bound Exception
BitmapFactory.Options options = new BitmapFactory.Options();
// this will calculate the size of the image, without decoding it
options.inJustDecodeBounds = true;
// we load the image's dimension into options
BitmapFactory.decodeStream(getContentResolver().openInputStream(uri), null, options);
// we calculate the new image's dimensions as close as possible to the desired width/height
public static void replaceFragmentToActivity (@NonNull FragmentManager fragmentManager,
@NonNull Fragment fragment, int frameId) {
Fragment fragmentToBacktrack = fragmentManager.findFragmentById(frameId);
FragmentTransaction transaction = fragmentManager.beginTransaction();
if(fragmentToBacktrack!=null)
transaction.addToBackStack(fragmentToBacktrack.toString());
transaction.replace(frameId, fragment);
transaction.commit();
public class AddNewRecipeFragment extends Fragment implements IView.AddNewRecipeView {
public static final int TAG_INGREDIENT_NAME = 2001;
public static final int TAG_INGREDIENT_QUANITY = 2002;
private Bitmap RecipeThumbnail;
private ArrayList<LinearLayout> ingredientsList;
private String encodedBitmap;
@BindView(R.id.camera_button)
Button cameraButton;
@TonyNikolov
TonyNikolov / superheroes.json
Created February 7, 2017 14:38
Superheroes api
[
{
"id": 10,
"name": "Black Widow",
"secretIdentity": "Natasha_0",
"imageUrl": "https://s-media-cache-ak0.pinimg.com/736x/e7/c3/f4/e7c3f4d64b090c0f011b16a75f10708c.jpg"
},
{
"id": 11,
"name": "Black Widow",
[{
"name": "Reticulated Giraffe",
"species": "Giraffa camelopardalis reticulata",
"description": "The reticulated giraffe (Giraffa camelopardalis reticulata), also known as the Somali giraffe, is a subspecies of giraffe native to Somalia, southern Ethiopia, and northern Kenya. Reticulated giraffes can interbreed with other giraffe subspecies in captivity or if they come into contact with populations of other subspecies in the wild. \nThe reticulated giraffe is among the most well-known of the nine giraffe subspecies. Together with the Rothschild giraffe, it is by far the giraffe most commonly seen in zoos. Its coat consists of large, polygonal, liver-colored spots outlined by a network of bright-white lines. The blocks may sometimes appear deep red and may also cover the legs. The extraordinary height of giraffes is attributed to a ritual known as \"necking\", where two males fight for reproduction rights by slamming their necks into one another. The giraffes with the tallest and strongest necks are victor