package com.blocksolid.okrello;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.ProgressBar;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {

    public static ProgressBar progressBar;
    public static Button getListsBtn;
    public static ListView listView;

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

        progressBar = (ProgressBar) findViewById(R.id.main_progress);
        progressBar.setVisibility(View.INVISIBLE);

        getListsBtn = (Button) findViewById(R.id.main_btn_get_lists);
        listView = (ListView) findViewById(R.id.main_list_lists);

        getListsBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getLists();
            }
        });
    }

    private void getLists() {
        // Show progress indicator while working
        progressBar.setVisibility(View.VISIBLE);

        // TODO make retrofit call to capture Lists to an array
        // TODO get list names to an array of strings
        // Manually created array for the purpose of testing

        // Populate list view with strings from array
        ArrayList<String> trelloListsArray = new ArrayList<>();
        trelloListsArray.add("Q1 2015");
        trelloListsArray.add("Q2 2015");
        trelloListsArray.add("Q3 2015");
        trelloListsArray.add("Q4 2015");

        listView.setAdapter(new ArrayAdapter<>(MainActivity.this, android.R.layout.simple_list_item_1, trelloListsArray));

        // Hide progress indicator when done
        progressBar.setVisibility(View.INVISIBLE);

    }
}

@@ -101,16 +101,41 @@
 Bundle;%0A
+import android.util.Log;%0A
 import a
@@ -289,91 +289,448 @@
 ar;%0A
-%0Aimport java.util.ArrayList;%0A%0Apublic class MainActivity extends AppCompatActivity %7B
+import android.widget.Toast;%0A%0Aimport com.blocksolid.okrello.api.TrelloApi;%0Aimport com.blocksolid.okrello.model.TrelloList;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport retrofit.Call;%0Aimport retrofit.Callback;%0Aimport retrofit.GsonConverterFactory;%0Aimport retrofit.Response;%0Aimport retrofit.Retrofit;%0A%0Apublic class MainActivity extends AppCompatActivity %7B%0A%0A    public static final String BASE_URL = %22https://api.trello.com/1/%22;
 %0A%0A  
@@ -808,16 +808,64 @@
 stsBtn;%0A
+    public static List%3CTrelloList%3E trelloLists;%0A
     publ
@@ -1718,167 +1718,693 @@
  // 
-TODO get list names to an array of strings%0A        // Manually created array for the purpose of testing%0A%0A        // Populate list view with strings from array%0A
+Retrofit stuff starts here%0A        // Retrofit stuff here%0A        Retrofit retrofit = new Retrofit.Builder()%0A                .baseUrl(BASE_URL)%0A                .addConverterFactory(GsonConverterFactory.create())%0A                .build();%0A%0A        TrelloApi trelloApi = retrofit.create(TrelloApi.class);%0A%0A        String key = %22cf2308ac2c68ab9a54037478108439e4%22;%0A%0A        // Make the call%0A        final Call%3CList%3CTrelloList%3E%3E call = trelloApi.getLists(key);%0A        call.enqueue(new Callback%3CList%3CTrelloList%3E%3E() %7B%0A%0A%0A            @Override%0A            public void onResponse(Response%3CList%3CTrelloList%3E%3E response, Retrofit retrofit) %7B%0A                trelloLists = response.body();%0A%0A        
     
@@ -2463,24 +2463,29 @@
 st%3C%3E();%0A
+%0A    
         
 trelloLi
@@ -2480,165 +2480,205 @@
     
-trelloListsArray.add(%22Q1 2015%22);%0A        trelloListsArray.add(%22Q2 2015%22);%0A        trelloListsArray.add(%22Q3 2015%22);%0A        trelloListsArray.add(%22Q4 2015%22);%0A%0A
+    for (TrelloList listItem : trelloLists) %7B%0A                    trelloListsArray.add(listItem.getName());%0A                %7D%0A%0A                // Populate list view with strings from array%0A        
     
@@ -2793,24 +2793,32 @@
 tsArray));%0A%0A
+        
         // H
@@ -2850,32 +2850,40 @@
 en done%0A        
+  
+      
 progressBar.setV
@@ -2905,21 +2905,397 @@
 INVISIBLE);%0A
+            %7D%0A%0A            @Override%0A            public void onFailure(Throwable t) %7B%0A                // Log error here since request failed%0A                Toast.makeText(getApplicationContext(), t.getMessage(), Toast.LENGTH_LONG).show();%0A                Log.d(%22Retrofit%22, t.getMessage());%0A                progressBar.setVisibility(View.INVISIBLE);%0A            %7D%0A%0A        %7D);
 %0A    %7D%0A%7D%0A

Update app to make a getLists call to Trello API using retrofit