Skip to content

Instantly share code, notes, and snippets.

class LoadCategories extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
}
@Override
protected String doInBackground(String... args) {
return something;
}
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(CategoryActivity.this);
pDialog.setMessage("Listing Categories...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();
}
protected String doInBackground(String... args){
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
// getting JSON string from URL
String json = jsonParser.makeHttpRequest(URL_CATEGORY, "GET",
params);
// Check your log cat for JSON reponse
Log.d("Categories JSON: ", "> " + json);
Intent i = new Intent(getApplicationContext(),
CategoryDetail.class);
String category_id = ((TextView) view
.findViewById(R.id.category_id)).getText()
.toString();
i.putExtra("category_id", category_id);
startActivity(i);
package com.aiman.listviewexample;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.List;
import org.apache.http.HttpEntity;
package com.aiman.listviewexample;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.apache.http.NameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
package com.aiman.listviewexample;
import java.util.ArrayList;
import java.util.HashMap;
import com.squareup.picasso.Picasso;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
public class MainActivity extends AppCompatActivity
implements GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener {
private static final String TAG = MainActivity.class.getSimpleName();
private SupportMapFragment mapFragment;
private MapObservableProvider mapObservableProvider;
private CompositeSubscription subscriptions = Subscriptions.from();
private GoogleMap googleMap;
@aemxn
aemxn / speedtest-cli.py
Created October 28, 2015 06:52
Internet speed test python cli
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2012-2015 Matt Martz
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@aemxn
aemxn / ImageInputHelper.java
Created July 4, 2016 06:59 — forked from eluleci/ImageInputHelper.java
Android: Helper for Android for selecting image from gallery, taking a photo with camera and cropping image.
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.v4.app.Fragment;
import android.util.Log;
import java.io.File;
import java.io.IOException;