Код: Выделить всё
public class GithubUser {
@SerializedName("body")
@Expose
private String body;
@SerializedName("time")
@Expose
private Integer time;
@SerializedName("title")
@Expose
private String title;
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
public Integer getTime() {
return time;
}
public void setTime(Integer time) {
this.time = time;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
Код: Выделить всё
public interface GitHubService {
@GET("/quests/get/?id={user_id}")
Call getQuest(@Query("user_id") String iser_id);
Код: Выделить всё
private void onUserConnect() {
Log.d("LOGO", "12");
ConnectivityManager connMgr = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
Log.d("LOGO", "13");
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
Log.d("LOGO", "14");
if (networkInfo != null && networkInfo.isConnected()) {
Log.d("LOGO", "15");
SharedPreferences sPref = getSharedPreferences("id", MODE_PRIVATE);
Log.d("LOGO", "17");
String user_id = sPref.getString("Idtest", "");
Log.d("LOGO", "18");
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://styleru2.herokuapp.com")
.addConverterFactory(GsonConverterFactory.create())
.build();
Log.d("LOGO", "19");
GitHubService service = retrofit.create(GitHubService.class);
Log.d("LOGO", user_id);
Call<GithubUser> call = service.getQuest(user_id);
Log.d("LOGO", "21");
call.enqueue(new Callback <GithubUser>(){
@Override
public void onResponse(Call<GithubUser> call, Response<GithubUser> response) {
Log.d("LOGO", "22");
Toast.makeText(getApplication(), "Даааааа", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(Call<GithubUser> call, Throwable t) {
}
});
}
}