diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9c4de58 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..bdae3e2 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +GitApp \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..30aa626 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..96cc43e --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..97626ba --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..195e217 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..ae5256f --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..79e4115 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..6564d52 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/GitApp.iml b/GitApp.iml new file mode 100644 index 0000000..a4effd2 --- /dev/null +++ b/GitApp.iml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/app.iml b/app/app.iml new file mode 100644 index 0000000..0ab62c2 --- /dev/null +++ b/app/app.iml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..9cc570a --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,28 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 23 + buildToolsVersion "23.0.1" + + defaultConfig { + applicationId "br.com.victoriamachado.gitapp" + minSdkVersion 15 + targetSdkVersion 23 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + testCompile 'junit:junit:4.12' + compile 'com.android.support:appcompat-v7:23.2.0' + compile 'com.squareup.retrofit:retrofit:1.9.0' + compile 'com.squareup.picasso:picasso:2.5.2' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..1b2eaf2 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:\opensource\AndroidStudio1.4.1_SDK/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/app/src/androidTest/java/br/com/victoriamachado/gitapp/ApplicationTest.java b/app/src/androidTest/java/br/com/victoriamachado/gitapp/ApplicationTest.java new file mode 100644 index 0000000..c982275 --- /dev/null +++ b/app/src/androidTest/java/br/com/victoriamachado/gitapp/ApplicationTest.java @@ -0,0 +1,13 @@ +package br.com.victoriamachado.gitapp; + +import android.app.Application; +import android.test.ApplicationTestCase; + +/** + * Testing Fundamentals + */ +public class ApplicationTest extends ApplicationTestCase { + public ApplicationTest() { + super(Application.class); + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..14fd605 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + diff --git a/app/src/main/java/br/com/victoriamachado/gitapp/GitAPI.java b/app/src/main/java/br/com/victoriamachado/gitapp/GitAPI.java new file mode 100644 index 0000000..a969fe2 --- /dev/null +++ b/app/src/main/java/br/com/victoriamachado/gitapp/GitAPI.java @@ -0,0 +1,14 @@ +package br.com.victoriamachado.gitapp; + +import retrofit.Callback; +import retrofit.http.GET; +import retrofit.http.Path; + +/** + * Created by rm75283 on 28/10/2016. + */ +public interface GitAPI { + + @GET("/users/{user}") + void getGithubModel(@Path("user") String user, Callback githubModelCallback); +} diff --git a/app/src/main/java/br/com/victoriamachado/gitapp/GithubModel.java b/app/src/main/java/br/com/victoriamachado/gitapp/GithubModel.java new file mode 100644 index 0000000..b183cc9 --- /dev/null +++ b/app/src/main/java/br/com/victoriamachado/gitapp/GithubModel.java @@ -0,0 +1,25 @@ +package br.com.victoriamachado.gitapp; + +/** + * Created by rm75283 on 28/10/2016. + */ +public class GithubModel { + private String name; + private String avatar_url; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAvatar_url() { + return avatar_url; + } + + public void setAvatar_url(String avatar_url) { + this.avatar_url = avatar_url; + } +} diff --git a/app/src/main/java/br/com/victoriamachado/gitapp/MainActivity.java b/app/src/main/java/br/com/victoriamachado/gitapp/MainActivity.java new file mode 100644 index 0000000..bcba1d2 --- /dev/null +++ b/app/src/main/java/br/com/victoriamachado/gitapp/MainActivity.java @@ -0,0 +1,81 @@ +package br.com.victoriamachado.gitapp; + +import android.app.ProgressDialog; +import android.media.Image; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.View; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.TextView; + +import com.squareup.picasso.Picasso; + +import retrofit.Callback; +import retrofit.RestAdapter; +import retrofit.RetrofitError; +import retrofit.client.Response; + +public class MainActivity extends AppCompatActivity { + + private EditText etUser; + private TextView tvName; + private String avatar_url; + private ImageView ivAvatar; + + private GithubModel user; + + private ProgressDialog progress; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + etUser = (EditText)findViewById(R.id.etUser); + tvName = (TextView)findViewById(R.id.tvName); + ivAvatar = (ImageView)findViewById(R.id.ivAvatar); + } + + public void search(View v){ + exibirProgress(); + + final RestAdapter restAdapter = new RestAdapter.Builder().setEndpoint("https://api.github.com").build(); + + GitAPI api = restAdapter.create(GitAPI.class); + + api.getGithubModel(etUser.getText().toString(), new Callback() { + @Override + public void success(GithubModel githubModel, Response response) { + user = githubModel; + tvName.setText(user.getName()); + avatar_url = user.getAvatar_url(); + Picasso.with(MainActivity.this).load(avatar_url).into(ivAvatar); + } + + @Override + public void failure(RetrofitError error) { + + } + }); + + fecharProgress(); + + } + + + private void exibirProgress(){ + progress = new ProgressDialog(this); + progress.setMessage("Pesquisando..."); + progress.setIndeterminate(true); + progress.show(); + } + + private void fecharProgress(){ + if(progress != null){ + if(progress.isShowing()){ + progress.dismiss(); + } + } + } +} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..2bdf9a3 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,49 @@ + + + + + +