Last active
October 16, 2017 20:09
-
-
Save Danil0v3s/fdf616052a60cf6359e9a13ceb763c4f 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
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