package demo.example.com.spotifysample;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;


public class MainActivity extends ActionBarActivity {

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

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}

@@ -34,16 +34,71 @@
 ample;%0A%0A
+import android.os.AsyncTask;%0Aimport android.os.Bundle;%0A
 import a
@@ -149,33 +149,32 @@
 ort android.
-os.Bundle
+util.Log
 ;%0Aimport and
@@ -224,62 +224,374 @@
 m;%0A%0A
-%0Apublic class MainActivity extends ActionBarActivity %7B
+import java.util.List;%0A%0Aimport kaaes.spotify.webapi.android.SpotifyApi;%0Aimport kaaes.spotify.webapi.android.SpotifyService;%0Aimport kaaes.spotify.webapi.android.models.Artist;%0Aimport kaaes.spotify.webapi.android.models.ArtistsPager;%0A%0A%0Apublic class MainActivity extends ActionBarActivity %7B%0A%0A    private static final String LOG_TAG = MainActivity.class.getSimpleName();
 %0A%0A  
@@ -750,16 +750,99 @@
 y_main);
+%0A%0A        SearchSpotifyTask task = new SearchSpotifyTask();%0A        task.execute();
 %0A    %7D%0A%0A
@@ -1568,11 +1568,604 @@
 );%0A    %7D
+%0A%0A    public class SearchSpotifyTask extends AsyncTask%3CVoid, Void, Void%3E%0A    %7B%0A        @Override%0A        protected Void doInBackground(Void... strings) %7B%0A            SpotifyApi api = new SpotifyApi();%0A            SpotifyService service = api.getService();%0A%0A            ArtistsPager results = service.searchArtists(%22Paul%22);%0A            List%3CArtist%3E artists = results.artists.items;%0A            for (int i = 0; i %3C artists.size(); i++) %7B%0A                Artist artist = artists.get(i);%0A                Log.i(LOG_TAG, i + %22 %22 + artist.name);%0A            %7D%0A            return null;%0A        %7D%0A    %7D
 %0A%7D%0A

Add Spotify wrapper call in AsyncTask.