Last active
May 27, 2019 11:23
-
-
Save nikunjparadva/48b96d0aad034f2349c9c6af3783dc8e to your computer and use it in GitHub Desktop.
Stackoverflow issue :- https://stackoverflow.com/a/56321583/5773037
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package paradva.nikss.test; | |
| import android.support.v7.app.AppCompatActivity; | |
| import android.os.Bundle; | |
| import android.util.Log; | |
| import android.widget.Toast; | |
| import java.util.List; | |
| import retrofit2.Call; | |
| import retrofit2.Callback; | |
| import retrofit2.Response; | |
| import retrofit2.Retrofit; | |
| import retrofit2.converter.gson.GsonConverterFactory; | |
| import retrofit2.http.GET; | |
| public class MainActivity extends AppCompatActivity { | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.activity_main); | |
| fetch_information(); | |
| } | |
| public static String Base_URL ; | |
| public static Retrofit retrofit; | |
| public static Retrofit getApiClient() | |
| { | |
| if (retrofit == null) | |
| { | |
| Base_URL ="https://xenzet.com/GameCheat/"; | |
| retrofit = new Retrofit.Builder().baseUrl(Base_URL) | |
| .addConverterFactory(GsonConverterFactory.create()).build(); | |
| } | |
| return retrofit; | |
| } | |
| public interface Api { | |
| @GET("viewgamesjson.php") | |
| Call<List<Games>> GetGames(); | |
| } | |
| public void fetch_information() { | |
| Api api = getApiClient().create(Api.class); | |
| Call<List<Games>> call = api.GetGames(); | |
| call.enqueue(new Callback<List<Games>>() { | |
| @Override | |
| public void onResponse(Call<List<Games>> call, Response<List<Games>> response) { | |
| if(response.isSuccessful()) { | |
| Log.e("onResponse", "onResponse: "+response.body() ); | |
| } | |
| } | |
| @Override | |
| public void onFailure(Call<List<Games>> call, Throwable t) { | |
| Toast.makeText(getApplicationContext(), t.getMessage(), Toast.LENGTH_SHORT).show(); | |
| } | |
| }); | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
now you need to pass this list to recylerview adapter and show in the recylerview