Created
May 28, 2019 20:14
-
-
Save immujahidkhan/674075d0dca100c6675a86e384f05a69 to your computer and use it in GitHub Desktop.
This file contains 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
/* HttpLoggingInterceptor logging = new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY); | |
//setup cache | |
File httpCacheDirectory = new File(getCacheDir(), "responses"); | |
int cacheSize = 10 * 1024 * 1024; // 10 MiB | |
Cache cache = new Cache(httpCacheDirectory, cacheSize); | |
// | |
OkHttpClient.Builder httpClient = new OkHttpClient.Builder().cache(cache).addInterceptor(logging); | |
//OkHttpClient.Builder httpClient = new OkHttpClient.Builder().addInterceptor(logging); | |
GLOBA_API_CALL api = GLOBA_API_CALL.getAllData(httpClient).create(GLOBA_API_CALL.class); | |
api.getMainModel().enqueue(new Callback<ArrayList<QuotesList>>() { | |
@Override | |
public void onResponse(Call<ArrayList<QuotesList>> call, Response<ArrayList<QuotesList>> response) { | |
if (response.isSuccessful()) { | |
lists = response.body(); | |
int x = 1; | |
for (QuotesList quotesList : response.body()) { | |
databaseModelClasses.add(new DatabaseModelClass(x, quotesList.getField1Text(), quotesList.getField2Text(), quotesList.getField2Text())); | |
//databaseHandler.insertNote(quotesList.getField1Text(), quotesList.getField2Text()); | |
x++; | |
} | |
Collections.shuffle(databaseModelClasses); | |
adpters.notifyDataSetChanged(); | |
spinKitView.setVisibility(View.GONE); | |
Log.d("response", String.valueOf(response.body().size())); | |
} | |
} | |
@Override | |
public void onFailure(Call<ArrayList<QuotesList>> call, Throwable t) { | |
t.printStackTrace(); | |
spinKitView.setVisibility(View.GONE); | |
Toast.makeText(MainActivity.this, t.toString(), Toast.LENGTH_SHORT).show(); | |
} | |
});*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment