// Path: android/app/src/main/java/com/ustwo/sample/data/Commit.java
// public class Commit {
//     public String message;
//     public Author author;
// 
//     public class Author {
//         public String name;
//         public String email;
//         public String date;
//     }
// }
// 
// Path: android/app/src/main/java/com/ustwo/sample/data/CommitSummary.java
// public class CommitSummary {
//     public String sha;
//     public Commit commit;
// 
//     public class Commit {
//         public Author author;
//         public String message;
//     }
// 
//     public class Author {
//         public String date;
//     }
// }
// 
// Path: android/app/src/main/java/com/ustwo/sample/data/GitHub.java
// public interface GitHub {
//     @GET("/repos/{username}/{repo}")
//     void repository(@Path("username") String username,
//                     @Path("repo") String repo,
//                     Callback<RepositoryInfo> commit);
// 
//     @GET("/repos/{username}/{repo}/commits")
//     void commitList(@Path("username") String username,
//                     @Path("repo") String repo,
//                     Callback<List<CommitSummary>> commit);
// 
//     @GET("/repos/{username}/{repo}/git/commits/{commit}")
//     void commit(@Path("username") String username,
//                 @Path("repo") String repo,
//                 @Path("commit") String commit,
//                 Callback<Commit> user);
// }


import android.widget.TextView;
import com.ustwo.sample.data.Commit;
import com.ustwo.sample.data.CommitSummary;
import com.ustwo.sample.data.GitHub;
import retrofit.Callback;
import retrofit.RestAdapter;
import retrofit.RetrofitError;
import retrofit.client.Response;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
/**
 * The MIT License (MIT)
 *
 * Copyright (c) 2015 ustwo™
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:

 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 */
package com.ustwo.sample;




/**
 * Created by emma on 1/8/15.
 */
public class CommitDetailActivity extends ActionBarActivity {
    private static final String TAG = CommitDetailActivity.class.getSimpleName();
    private static final String EXTRA_KEY_COMMIT_SHA = "key_commit_sha";

    private ProgressDialog mProgressDialog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_commit_detail);

        mProgressDialog = ProgressDialog.show(this, "", getString(R.string.shared_loading), true, false);

        retrieveCommitInfo(getIntent().getStringExtra(EXTRA_KEY_COMMIT_SHA));
    }

    @Override
    protected void onPause() {
        super.onPause();

        dismissProgressDialog();
    }

    private void dismissProgressDialog() {
        if (mProgressDialog != null) {
            mProgressDialog.dismiss();
            mProgressDialog = null;
        }
    }

    private void retrieveCommitInfo(String commit) {
        RestAdapter restAdapter = new RestAdapter.Builder()
                .setEndpoint(getString(R.string.app_endpoint_url))
                .build();

        GitHub service = restAdapter.create(GitHub.class);
// Path: android/app/src/main/java/com/ustwo/sample/data/Commit.java
// public class Commit {
//     public String message;
//     public Author author;
// 
//     public class Author {
//         public String name;
//         public String email;
//         public String date;
//     }
// }
// 
// Path: android/app/src/main/java/com/ustwo/sample/data/CommitSummary.java
// public class CommitSummary {
//     public String sha;
//     public Commit commit;
// 
//     public class Commit {
//         public Author author;
//         public String message;
//     }
// 
//     public class Author {
//         public String date;
//     }
// }
// 
// Path: android/app/src/main/java/com/ustwo/sample/data/GitHub.java
// public interface GitHub {
//     @GET("/repos/{username}/{repo}")
//     void repository(@Path("username") String username,
//                     @Path("repo") String repo,
//                     Callback<RepositoryInfo> commit);
// 
//     @GET("/repos/{username}/{repo}/commits")
//     void commitList(@Path("username") String username,
//                     @Path("repo") String repo,
//                     Callback<List<CommitSummary>> commit);
// 
//     @GET("/repos/{username}/{repo}/git/commits/{commit}")
//     void commit(@Path("username") String username,
//                 @Path("repo") String repo,
//                 @Path("commit") String commit,
//                 Callback<Commit> user);
// }


// Path: android/app/src/main/java/com/ustwo/sample/CommitDetailActivity.java
import android.widget.TextView;
import com.ustwo.sample.data.Commit;
import com.ustwo.sample.data.CommitSummary;
import com.ustwo.sample.data.GitHub;
import retrofit.Callback;
import retrofit.RestAdapter;
import retrofit.RetrofitError;
import retrofit.client.Response;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;

/**
 * The MIT License (MIT)
 *
 * Copyright (c) 2015 ustwo™
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:

 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 */
package com.ustwo.sample;




/**
 * Created by emma on 1/8/15.
 */
public class CommitDetailActivity extends ActionBarActivity {
    private static final String TAG = CommitDetailActivity.class.getSimpleName();
    private static final String EXTRA_KEY_COMMIT_SHA = "key_commit_sha";

    private ProgressDialog mProgressDialog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_commit_detail);

        mProgressDialog = ProgressDialog.show(this, "", getString(R.string.shared_loading), true, false);

        retrieveCommitInfo(getIntent().getStringExtra(EXTRA_KEY_COMMIT_SHA));
    }

    @Override
    protected void onPause() {
        super.onPause();

        dismissProgressDialog();
    }

    private void dismissProgressDialog() {
        if (mProgressDialog != null) {
            mProgressDialog.dismiss();
            mProgressDialog = null;
        }
    }

    private void retrieveCommitInfo(String commit) {
        RestAdapter restAdapter = new RestAdapter.Builder()
                .setEndpoint(getString(R.string.app_endpoint_url))
                .build();

        GitHub service = restAdapter.create(GitHub.class);
        service.commit(getString(R.string.default_repository_user), getString(R.string.default_repository_name), commit, new Callback<Commit>() {