Ramotion / direct-select-android

:octocat: ≡ DirectSelect is a selection widget with an ethereal, full-screen modal popup displaying the available choices when the widget is interact with.
https://www.ramotion.com/android-app-development-ui-library-for-selecting-items-from-a-list/
MIT License
530 stars 65 forks source link

Unable showcase data which is from restful api or SQLLite #1

Closed jeevan-antariksh closed 5 years ago

jeevan-antariksh commented 6 years ago

we are trying to populate the list of drop down options from a restful api or sqlite. It show the following error.

rocess: com.ramotion.directselect.examples.advenced, PID: 23396
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.widget.ArrayAdapter.getItem(int)' on a null object reference
        at com.ramotion.directselect.DSListView.hideListView(DSListView.java:224)
        at com.ramotion.directselect.DSListView.access$200(DSListView.java:36)
        at com.ramotion.directselect.DSListView$3.onTouch(DSListView.java:313)
        at android.view.View.dispatchTouchEvent(View.java:9941)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2666)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2344)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2672)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2672)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2672)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2672)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2672)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2672)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2672)
public void getData(){
        StringRequest stringRequest = new StringRequest(url, new com.android.volley.Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                GsonBuilder gsonBuilder = new GsonBuilder();
                Gson gson = gsonBuilder.create();
                Type listType = new TypeToken<List<ManFact>>(){}.getType();
                List<ManFact> manFacts = (List<ManFact>) gson.fromJson(response, listType);
                if(response.length()==0){
                    // Toast.makeText(,"No result",Toast.LENGTH_SHORT).show();
                }else {
                    try {
                        for (ManFact man : manFacts) {

                            impList = Arrays.asList(
                                    new AdvancedExampleCountryPOJO(man.getName(),R.drawable.ic_launcher_background)
                            );
                            stringArray.add(man.getName());
                            sqlUtil.addProduct(new AdvancedExampleCountryPOJO(man.getName(),R.drawable.ic_launcher_background));
                        }
                        ArrayAdapter<AdvancedExampleCountryPOJO> adapter = new AdvancedExampleCountryAdapter(
                                AdvancedExampleActivity.this, R.layout.advanced_example_country_list_item, sqlUtil.getAllProductList());

                        // Set adapter to our DSListView
                        DSListView<AdvancedExampleCountryPOJO> pickerView = findViewById(R.id.ds_county_list);
                        pickerView.setAdapter(adapter);
                    } catch (Exception e) {
                        e.printStackTrace();
                        //oast.makeText(context, e.toString(), Toast.LENGTH_SHORT).show();
                    }
                }

            }
        }, new com.android.volley.Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                if (error == null) {
                    //Toast.makeText(context,"No Internet",Toast.LENGTH_LONG).show();

                }
            }
        });
        RequestQueue requestQueue = Volley.newRequestQueue(this);
        requestQueue.add(stringRequest);
    }
kyurkchyan commented 6 years ago

I'm having the same issue. Have you resolved this?

aleks-zhigar commented 5 years ago

Any comments?

golovin47 commented 5 years ago

This issue was resolved by #7 commit.