NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

package tt.directionapitest;

import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;

import org.json.JSONArray;
import org.json.JSONObject;
import org.jsoup.Jsoup;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity extends AppCompatActivity
{

JSONArray dS = new JSONArray();

@BindView(R.id.etBasla) EditText etBasla;
@BindView(R.id.etBitis) EditText etBitis;
@BindView(R.id.lv) ListView lv;
LayoutInflater li;
BaseAdapter ba;

protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);


ButterKnife.bind(MainActivity.this);

li = LayoutInflater.from(MainActivity.this);
ba = new BaseAdapter() {
@Override
public int getCount() {
return dS.length();
}

@Override
public Object getItem(int i) {
return null;
}

@Override
public long getItemId(int i) {
return 0;
}

@Override
public View getView(int i, View view, ViewGroup viewGroup) {
if (view == null)
view = li.inflate(android.R.layout.simple_list_item_1, null);

TextView tv = (TextView) view.findViewById(android.R.id.text1);

try
{
String info = dS.getJSONObject(i).getString("html_instructions");
tv.setText(Html.fromHtml(info));
} catch (Exception e) {}

return view;
}
};

lv.setAdapter(ba);
}

@OnClick(R.id.btn)
void ara()
{
new AsyncTask<String, String, String>()
{
protected String doInBackground(String... p)
{
try
{
/*
https://maps.googleapis.com/maps/api/directions/json? origin,destination
*/
String response = Jsoup.connect("https://maps.googleapis.com/maps/api/directions/json")
.timeout(10000)
.userAgent("Mozilla")
.ignoreContentType(true)
.data("origin", p[0])
.data("destination", p[1])
.get()
.text();

JSONObject jo = new JSONObject(response);
dS = jo.getJSONArray("routes")
.getJSONObject(0)
.getJSONArray("legs")
.getJSONObject(0)
.getJSONArray("steps");
Log.e("x","STEP CNT : "+dS.length());

//Log.i("x","Response : "+response);
} catch (Exception e) { Log.e("x","Parse Error : "+e);}
return null;
}

@Override
protected void onPostExecute(String s) {
ba.notifyDataSetChanged();
//BaseAdapter'i Yenile
}
}.execute(etBasla.getText().toString(), etBitis.getText().toString());
}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.