Skip to content

Instantly share code, notes, and snippets.

@Danil0v3s
Last active October 16, 2017 20:09
Show Gist options
  • Save Danil0v3s/fdf616052a60cf6359e9a13ceb763c4f to your computer and use it in GitHub Desktop.
Save Danil0v3s/fdf616052a60cf6359e9a13ceb763c4f to your computer and use it in GitHub Desktop.
public class MainActivity extends AppCompatActivity {
private WikipediaService wikipediaService;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
wikipediaService = BaseService.getInstance().getWikiService();
doSearch("Retrofit2");
}
private void doSearch(String query) {
HashMap<String, String> options = new HashMap<>();
options.put("srsearch", query);
options.put("sroffset", "0");
wikipediaService.search(options).enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
ResponseBody responseBody = response.body();
if (responseBody != null) {
// Faça o restante das coisas aqui
}
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment