Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class FilterDialog extends DialogFragment {
- private List<Countries> countriesList = new ArrayList<>();
- private ApiService service;
- private AutoCompleteTextView autoCompleteTextView;
- private List<Countries.CountriesData> countriesData = new ArrayList<>();
- private Countries data;
- private AutoCompleteCountryAdapter adapter;
- private Call<Countries> call;
- @Override
- public void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- service = RetrofitBuilder.createService(ApiService.class);
- getCountries();
- }
- private void getCountries() {
- call = service.getCountries();
- call.enqueue(new Callback<Countries>() {
- @Override
- public void onResponse(Call<Countries> call, Response<Countries> response) {
- if (response.isSuccessful()) {
- data = response.body();
- countriesData.addAll(data.getCountriesData());
- adapter.setCountryListFull(countriesData);
- }
- }
- @Override
- public void onFailure(Call<Countries> call, Throwable t) {
- }
- });
- }
- @Nullable
- @Override
- public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_filter, container);
- autoCompleteTextView = view.findViewById(R.id.actv_countries);
- adapter = new AutoCompleteCountryAdapter(getContext() ,countriesData);
- autoCompleteTextView.setAdapter(adapter);
- return view;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement