This file contains 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 base; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.io.UnsupportedEncodingException; | |
import org.apache.http.HttpEntity; | |
import org.apache.http.HttpResponse; |
This file contains 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
@Override | |
protected String doInBackground(City... params) { | |
// TODO Auto-generated method stub | |
String nameCity, idCity; | |
nameCity = "Palmas"; | |
idCity = null; | |
try { | |
JSONParser jsonParser = new JSONParser(); | |
String url = "http://mobile.nuvolscloud.com.br/cidade/api/cidade/1/?format=json"; | |
JSONObject json = jsonParser.getJSONFromUrl(url); |
This file contains 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
def get_form(self, request, obj=None, **kwargs): | |
form = super(EstabelecimentoAdmin, self).get_form(request, obj, **kwargs) | |
import pdb | |
pdb.set_trace() | |
try: | |
if not request.user.is_superuser: | |
if Usuario(user=request.user).get_limit() >= self.model.objects.filter(user=request.user).count() and obj == None: | |
return render_to_response('limit_places.html', {'app_label': 'Limite atingido'}) | |
form.base_fields['cidade'].queryset = Usuario(user=request.user).get_city() | |
except Exception, e: |
This file contains 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 Estado | |
{ | |
public int id { get; set; } | |
public string nome { get; set; } | |
public string uf { get; set; } | |
} | |
public class City | |
{ |
This file contains 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
private async void StartGeoLocation() | |
{ | |
try | |
{ | |
City city = new City(); | |
if (city.GetCurrencyCity() == null) | |
{ | |
//TODO Preciso verificar o load da localizacao | |
Geolocator geolocator = new Geolocator(); | |
geolocator.DesiredAccuracyInMeters = 50; |
This file contains 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
protected override async void OnNavigatedTo(NavigationEventArgs e) | |
{ | |
LoadCity(); | |
await StartGeoLocation(); | |
base.OnNavigatedTo(e); | |
} | |
private async Task StartGeoLocation() | |
{ | |
try |
This file contains 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
private void Address_Tap(object sender, System.Windows.Input.GestureEventArgs e) | |
{ | |
try | |
{ | |
MapsDirectionsTask mapsDirectionsTask = new MapsDirectionsTask(); | |
GeoCoordinate CoordenadaFinal = new GeoCoordinate(LatItem, LngItem); | |
LabeledMapLocation EndPoint = new LabeledMapLocation(PanoramaDetailItem.Title.ToString(), CoordenadaFinal); | |
mapsDirectionsTask.End = EndPoint; |
This file contains 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
JSONObject jsonobj; // declared locally so that it destroys after serving its purpose | |
jsonobj = new JSONObject(); | |
JSONObject header = new JSONObject(); | |
jsonobj.put("nome", "Guilherme"); | |
jsonobj.put("pais", "Brasil"); | |
jsonobj.put("chave", regIdGCMService.toString()); | |
jsonobj.put("Authorization", "Token 0d0c898a1c26235f25f256ed853c9a09f3dce8bd"); | |
DefaultHttpClient httpclient = new DefaultHttpClient(); |
This file contains 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
def send_message(self): | |
json_data ={"collapse_key":"msg","data":{"data":"xyz",},"registration_ids":['APA91bH2DtFn9494z-*****bMP1BPUsVI8ltb395MNp-39k8sp0',],} | |
url ='https://android.googleapis.com/gcm/send' | |
myKey ="AIzaSyC********************A7S" | |
data = json.dumps(json_data) | |
headers ={'Content-Type':'application/json','Authorization':'key=%s'% myKey} | |
req = urllib2.Request(url, data, headers) | |
f = urllib2.urlopen(req) | |
response = json.loads(f.read()) |
This file contains 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
JSONObject jsonobject = new JSONObject(); | |
HttpClient httpclient = new DefaultHttpClient(); | |
HttpPost httppost = new HttpPost("http://*******/apirestfull/******/"); | |
httppost.setHeader("Content-Type","application/json"); | |
httppost.setHeader("Authentication", "Token 0d0c898a*****e8bd"); | |
jsonobject.put("nome", "Guilherme"); | |
jsonobject.put("pais", "Brasil"); | |
jsonobject.put("chave", Key); |
OlderNewer