Question

As the title says, I'm getting the classic "You need to call notifyDataSetChanged()" exception. However, I'm getting this while clicking on a ListView item. This might be as simple as forgetting a notifyDataSetChanged(), but I've been looking at this code for so long, some extra eyes might help. This is a simple photo streaming app that pulls JSON data from a URL, puts it into a custom Object, puts it into an ArrayList, then displays a thumbnail of the photo with the name in a ListView. Clicking the item should take it to a photo activity. Note, I have not implemented the OnItemClickListener() for the recent tab yet, I'll do that when I get the viewed tab one is working.

Update: After more testing, the issue has come into better view. When the application starts, the progress dialog pops up, and is destroyed as expected. If I click a ListView item at this point, I get the behavior as described above. However, if I change to the "Most Recent" tab, then change back, and click, it works. It also works if I reselect the "Most Viewed" tab. Maybe the AsyncTask isn't finished? If not, how can I change my code so the user cannot interact with the list until the background thread is finished? Thanks again.

Update 2: Tried using .get(long time, TimeUnit.MILLISECONDS); to make sure the AsyncTask finishes, but the behavior from the first update persists. Apparently the ListView is not updating, like the exception implies. Not sure how this is happening, considering how often I update the adapter.

Update 4: Added some LogCat. Cleaned up my MainActivity to make it a bit easier for you guys to read, hopefully, too. Tried extending my ArrayAdapter to BaseAdapter, but no dice. :/ Same behavior as in the first update.

Update 5: I've moved on to other things in the meantime, but now I'm back to this. Tried tackling a different bug where the data doesn't change when you change tabs. I've noticed that clearing the ArrayList before each AsyncTask myAsync.get() will blank out the screen, even though the Async should repopulate the ArrayList and refill the ListView with items. Seems like the Async updates once and then never updates again, even when calling myAsync.get() again.

   MainActivity (private nested AsyncTasks not included. Will be provided below)
public class MainActivity extends ActionBarActivity 
{
    final String MOST_VIEWED_URL = "http://photostream.iastate.edu/api/photo?key=14a53634bbcf67893ab7&order=views_desc";
    final String MOST_RECENT_URL = "http://photostream.iastate.edu/api/photo?key=14a53634bbcf67893ab7&order=date_desc";
    final StringAsync syncStringViews = new StringAsync(null);
    final PhotoAsync syncImageViews = new PhotoAsync(null);
    final StringAsync syncStringRecent = new StringAsync(null);
    final PhotoAsync syncImageRecent = new PhotoAsync(null);
    boolean isOnMostViewed = true;
    public static ArrayList<PhotoItem> photos = new ArrayList<PhotoItem>(20);
    boolean started = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {


         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);


         android.app.ActionBar actionBar = getActionBar();

         actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);


    }

    @Override
    protected void onStart()
    {
        super.onStart();
        final PhotoArrayAdapter photoListAdapterRecent = new PhotoArrayAdapter(MainActivity.this, photos);
        final PhotoArrayAdapter photoListAdapterViewed = new PhotoArrayAdapter(MainActivity.this, photos);

        syncStringViews.setAdapter(photoListAdapterViewed);
        syncImageViews.setAdapter(photoListAdapterViewed);
        syncStringRecent.setAdapter(photoListAdapterRecent);
        syncImageRecent.setAdapter(photoListAdapterRecent);

        photoListAdapterViewed.setNotifyOnChange(true);
        photoListAdapterRecent.setNotifyOnChange(true);



        if(!syncStringViews.hasExecuted)
        {
            syncStringViews.execute(MOST_VIEWED_URL);
            syncStringViews.hasExecuted = true;
        }
        if(!syncImageViews.hasExecuted) 
        {
            syncImageViews.hasExecuted = true;
            syncImageViews.execute(photos);
        }
        if(!syncStringRecent.hasExecuted) 
        {
            syncStringRecent.hasExecuted = true;
            syncStringRecent.execute(MOST_RECENT_URL);
        }
        if(!syncImageRecent.hasExecuted) 
        {
            syncImageRecent.hasExecuted = true;
            syncImageRecent.execute(photos);
        }

        android.app.ActionBar actionBar = getActionBar();
        android.app.ActionBar.Tab tabOne = actionBar.newTab();
        android.app.ActionBar.Tab tabTwo = actionBar.newTab();

        tabOne.setText("Most Viewed");
        tabTwo.setText("Most Recent");

        tabOne.setTabListener(new TabListener() 
        {



                @Override
                public void onTabSelected(android.app.ActionBar.Tab tab, android.app.FragmentTransaction ft)        
                {
                    setContentView(R.layout.most_viewed);
                    final ListView viewedList = (ListView) findViewById(R.id.list_viewed);
                    viewedList.setAdapter(photoListAdapterViewed);
                    isOnMostViewed = true;

                    try 
                    {
                        syncStringViews.get(5000, TimeUnit.MILLISECONDS);
                        syncImageViews.get(5000, TimeUnit.MILLISECONDS);
                        photoListAdapterViewed.notifyDataSetChanged();
                        photoListAdapterRecent.notifyDataSetChanged();
                        viewedList.requestLayout();
                    } 
                    catch (InterruptedException e) 
                    {
                        e.printStackTrace();
                    } 
                    catch (ExecutionException e) 
                    {
                        e.printStackTrace();
                    } catch (TimeoutException e) 
                    {
                        e.printStackTrace();
                    }

                    //NOTE: THIS IS WHERE I SET UP MY ONCLICKLISTENER
                    viewedList.setOnItemClickListener(new OnItemClickListener()
                    {

                        @Override
                        public void onItemClick(AdapterView<?> parent, View view, int position, long id) 
                        {
                            Intent intent = new Intent(MainActivity.this, PhotoActivity.class);
                            intent.putExtra("id", photos.get(position).getId());
                            photoListAdapterViewed.notifyDataSetChanged();
                            photoListAdapterRecent.notifyDataSetChanged();
                            viewedList.requestLayout();
                            startActivity(intent);
                        }

                    });
                }

                @Override
                public void onTabUnselected(android.app.ActionBar.Tab tab,  android.app.FragmentTransaction ft)
                {
                    photoListAdapterViewed.notifyDataSetChanged();
                    photoListAdapterRecent.notifyDataSetChanged();

                }

                @Override
                public void onTabReselected(android.app.ActionBar.Tab tab,  android.app.FragmentTransaction ft) 
                {
                    setContentView(R.layout.most_viewed);
                    final ListView viewedList = (ListView) findViewById(R.id.list_viewed);
                    viewedList.setAdapter(photoListAdapterViewed);
                    isOnMostViewed = true;

                    try 
                    {
                        syncStringViews.get(5000, TimeUnit.MILLISECONDS);
                        syncImageViews.get(5000, TimeUnit.MILLISECONDS);
                        photoListAdapterViewed.notifyDataSetChanged();
                        photoListAdapterRecent.notifyDataSetChanged();
                        viewedList.requestLayout();
                    } 
                    catch (InterruptedException e) 
                    {

                        e.printStackTrace();
                    } 
                    catch (ExecutionException e) 
                    {

                        e.printStackTrace();
                    } catch (TimeoutException e) {

                        e.printStackTrace();
                    }

                    viewedList.setOnItemClickListener(new OnItemClickListener()
                    {

                        @Override
                        public void onItemClick(AdapterView<?> parent,
                                View view, int position, long id) 
                        {
                            Intent intent = new Intent(MainActivity.this, PhotoActivity.class);
                            intent.putExtra("id", photos.get(position).getId());
                            photoListAdapterViewed.notifyDataSetChanged();
                            photoListAdapterRecent.notifyDataSetChanged();
                            viewedList.requestLayout();
                            startActivity(intent);
                        }

                    });

                }
            });

            tabTwo.setTabListener(new TabListener() {

                @Override
                public void onTabSelected(android.app.ActionBar.Tab tab, android.app.FragmentTransaction ft)        
                {
                    setContentView(R.layout.most_recent);
                    ListView recentList = (ListView) findViewById(R.id.list_recent);
                    recentList.setAdapter(photoListAdapterRecent);
                    isOnMostViewed = false;

                    try {
                        syncStringRecent.get(5000, TimeUnit.MILLISECONDS);
                        syncImageRecent.get(5000, TimeUnit.MILLISECONDS);
                        photoListAdapterViewed.notifyDataSetChanged();
                        photoListAdapterRecent.notifyDataSetChanged();
                        recentList.requestLayout();
                    } catch (InterruptedException e) {

                        e.printStackTrace();
                    } catch (ExecutionException e) {

                        e.printStackTrace();
                    } catch (TimeoutException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                }

                @Override
                public void onTabUnselected(android.app.ActionBar.Tab tab, android.app.FragmentTransaction ft)  
                {
                    photoListAdapterViewed.notifyDataSetChanged();
                    photoListAdapterRecent.notifyDataSetChanged();

                }

                @Override
                public void onTabReselected(android.app.ActionBar.Tab tab, android.app.FragmentTransaction ft) 
                {
                    setContentView(R.layout.most_recent);
                    ListView recentList = (ListView) findViewById(R.id.list_recent);
                    recentList.setAdapter(photoListAdapterRecent);
                    isOnMostViewed=false;

                    try {
                        syncStringRecent.get(5000, TimeUnit.MILLISECONDS);
                        syncImageRecent.get(5000, TimeUnit.MILLISECONDS);
                        photoListAdapterViewed.notifyDataSetChanged();
                        photoListAdapterRecent.notifyDataSetChanged();
                        recentList.requestLayout();
                    } catch (InterruptedException e) {

                        e.printStackTrace();
                    } catch (ExecutionException e) {

                        e.printStackTrace();
                    } catch (TimeoutException e) {

                        e.printStackTrace();
                    }
                }
            });
            photoListAdapterViewed.notifyDataSetChanged();
            photoListAdapterRecent.notifyDataSetChanged();

            if (!started) 
            {
                actionBar.addTab(tabOne);
                actionBar.addTab(tabTwo);
                started = true;
            }

            if(isOnMostViewed)
            {
                try 
                {
                    syncStringViews.get(5000, TimeUnit.MILLISECONDS);
                    syncImageViews.get(5000, TimeUnit.MILLISECONDS);
                    photoListAdapterViewed.notifyDataSetChanged();
                    photoListAdapterRecent.notifyDataSetChanged();
                } 
                catch (InterruptedException e) 
                {
                    e.printStackTrace();
                } 
                catch (ExecutionException e) 
                {
                    e.printStackTrace();
                } catch (TimeoutException e) {

                    e.printStackTrace();
                }

            }

                else if(!isOnMostViewed)
                {


                    try {
                        syncStringRecent.get(5000, TimeUnit.MILLISECONDS);
                        syncImageRecent.get(5000, TimeUnit.MILLISECONDS);
                        photoListAdapterViewed.notifyDataSetChanged();
                        photoListAdapterRecent.notifyDataSetChanged();

                    } catch (InterruptedException e) {

                        e.printStackTrace();
                    } catch (ExecutionException e) {

                        e.printStackTrace();
                    } catch (TimeoutException e) {

                        e.printStackTrace();
                    }
                }

    }

First Nested Async. This retrieves the details of the photos.

private class StringAsync extends AsyncTask<String, Integer, ArrayList<PhotoItem>>
    {
        public boolean hasExecuted = false;
        ProgressDialog progressDialog;
        PhotoArrayAdapter currentAdapter;


        public StringAsync(PhotoArrayAdapter temp)
        {
            super();
            currentAdapter = temp;
        }

        @Override
        protected void onPreExecute()
        {

            progressDialog = ProgressDialog.show(MainActivity.this, "Loading Data","Getting photo details.", true);

            //do initialization of required objects objects here                
        };

        @Override
        protected ArrayList<PhotoItem> doInBackground(String...urls) 
        {
            ArrayList<PhotoItem> resultList = new ArrayList<PhotoItem>();
            String result = "";
            InputStream is = null;
            // HTTP
            try {           
                HttpClient httpclient = new DefaultHttpClient(); // for port 80 requests!
                HttpPost httppost = new HttpPost(urls[0]);
                HttpResponse response = httpclient.execute(httppost);
                HttpEntity entity = response.getEntity();
                is = entity.getContent();
            } catch(Exception e) {

            }

            // Read response to string
            try {           
                BufferedReader reader = new BufferedReader(new InputStreamReader(is,"utf-8"),8);
                StringBuilder sb = new StringBuilder();
                String line = null;
                while ((line = reader.readLine()) != null) {
                    sb.append(line + "\n");
                }
                is.close();
                result = sb.toString();             
            } catch(Exception e) {

            }
            JSONArray array = new JSONArray();

            try {
                array = new JSONArray(result);
            } catch (JSONException e1) {
                e1.printStackTrace();
            }

            for (int i = 0; i < array.length(); i++)
            {
                try {
                    JSONObject image = array.getJSONObject(i);
                    PhotoItem newItem = new PhotoItem(image.getString("title"), image.getInt("id"), image.getInt("views"), image.getString("description"), image.getString("image_small"), image.getString("image_medium"));
                    resultList.add(newItem);
                } catch (JSONException e) {
                    e.printStackTrace();
                }

            }





            return resultList;
        }


        @Override
        protected void onPostExecute(ArrayList<PhotoItem> result) 
        {

            super.onPostExecute(result);

            int i = 0;
            for(i = 0; i < result.size(); i++)
            {
                MainActivity.photos.add(i, result.get(i));

            }

            if (MainActivity.photos.size() > result.size())
            {
                for (i = result.size() - 1; i < MainActivity.photos.size(); i++)
                {
                    MainActivity.photos.remove(i);
                }
            }

            currentAdapter.notifyDataSetChanged();
            progressDialog.dismiss();

        }

        public void setAdapter(PhotoArrayAdapter temp)
        {
            currentAdapter = temp;
        }



    }

Last nested Async. This retrieves the Bitmaps of the photos, themselves.

     private class PhotoAsync extends AsyncTask<ArrayList<PhotoItem>, Integer, ArrayList<Bitmap>>
    {

        public boolean hasExecuted = false;
        ProgressDialog progressDialog;

        PhotoArrayAdapter currentAdapter;


        public PhotoAsync(PhotoArrayAdapter temp)
        {
            super();
            currentAdapter = temp;
        }


        @Override
        protected void onPreExecute()
        {

            progressDialog = ProgressDialog.show(MainActivity.this, "Loading Data","Getting photo details.", true);

            //do initialization of required objects objects here                
        };

        @Override
        protected ArrayList<Bitmap> doInBackground(ArrayList<PhotoItem>...idArg) 
        {

            ArrayList<Bitmap> result = new ArrayList<Bitmap>();



            for(int i = 0; i < idArg[0].size(); i++)
            {
                result.add(getBitmapFromURL(idArg[0].get(i).getThumbURL()));
                result.add(getBitmapFromURL(idArg[0].get(i).getFullURL()));
            }


            return result;
        }

        @Override
        protected synchronized void onPostExecute(ArrayList<Bitmap> result)
        {
            super.onPostExecute(result);
            int position = 0;
            for(int i = 0; i < result.size(); i++)
            {
                MainActivity.photos.get(position).setThumbImageBM(result.get(i));
                if ((i + 1) != result.size()) i++;
                MainActivity.photos.get(position).setFullImageBM(result.get(i));
                if ((position + 1) != MainActivity.photos.size()) position++;
            }
            currentAdapter.notifyDataSetChanged();
            progressDialog.dismiss();
        }

        private Bitmap getBitmapFromURL(String src) 
        {
            try {
                java.net.URL url = new java.net.URL(src);
                HttpURLConnection connection = (HttpURLConnection) url
                        .openConnection();
                connection.setDoInput(true);
                connection.connect();
                InputStream input = connection.getInputStream();

                BitmapFactory.Options option = new BitmapFactory.Options();
                option.inSampleSize = 8;

                Bitmap myBitmap = BitmapFactory.decodeStream(input);
                return myBitmap;
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        }

        public void setAdapter(PhotoArrayAdapter temp)
        {
            currentAdapter = temp;
        }

    }

}

Here is the Activity I'm switching to when the exception is thrown.

public class PhotoActivity extends ActionBarActivity 
{

        protected void onCreate(Bundle savedInstanceState) 
        {


             super.onCreate(savedInstanceState);

             setContentView(R.layout.activity_photo);
             Intent intent = getIntent();
             int id = intent.getIntExtra("id", 0);
             Bitmap thisImage = null;
             String name = "";

             for(int i = 0; i < MainActivity.photos.size(); i++)
             {
                 if(MainActivity.photos.get(i).getId() == id)
                 {
                     thisImage = MainActivity.photos.get(i).getLargeImage();
                     name = MainActivity.photos.get(i).getName();
                 }
             }
             this.setTitle(name);

             ImageView image = (ImageView) findViewById(R.id.photo_activity_image_view);

             image.setImageBitmap(thisImage);
        }

}

I've been wrestling with this for weeks. Please help! Thanks!

Update 3: My custom adapter, as requested.

    public class PhotoArrayAdapter extends ArrayAdapter<PhotoItem>
{
    private final Context myContext;
    private final ArrayList<PhotoItem> myImages;

    public PhotoArrayAdapter(Context context, ArrayList<PhotoItem> photos) 
    {
        super(context,R.layout.photo_list_item_layout);
        myContext = context;
        myImages = photos;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent)
    {

        View v = convertView;
        if (v == null)
        {
            LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = inflater.inflate(R.layout.photo_list_item_layout, null);
        }






        ImageView thumb = (ImageView) v.findViewById(R.id.image);
        TextView name = (TextView) v.findViewById(R.id.title);


        thumb.setImageBitmap(myImages.get(position).getThumbImage());
        name.setText(myImages.get(position).getName());








        return v;
    }


    @Override
    public int getCount() 
    {

        return myImages.size();
    }



}

LogCat:

04-24 16:37:33.397: E/InputEventReceiver(24541): Exception dispatching input event.
04-24 16:37:33.397: E/MessageQueue-JNI(24541): Exception in MessageQueue callback: handleReceiveCallback
04-24 16:37:33.407: E/MessageQueue-JNI(24541): java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. Make sure your adapter calls notifyDataSetChanged() when its content changes. [in ListView(2131034175, class android.widget.ListView) with Adapter(class edu.iastate.its.webdev.training.photostream.PhotoArrayAdapter)]
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.widget.ListView.layoutChildren(ListView.java:1555)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.widget.AbsListView.onTouchUp(AbsListView.java:3617)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.widget.AbsListView.onTouchEvent(AbsListView.java:3429)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.View.dispatchTouchEvent(View.java:7706)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2210)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1945)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2068)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1515)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.app.Activity.dispatchTouchEvent(Activity.java:2458)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.support.v7.app.ActionBarActivityDelegateICS$WindowCallbackWrapper.dispatchTouchEvent(ActionBarActivityDelegateICS.java:268)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2016)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.View.dispatchPointerEvent(View.java:7886)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:3954)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3833)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3399)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3449)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3418)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3525)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3426)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3582)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3399)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3449)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3418)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3426)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3399)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5602)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5582)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5553)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5682)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.os.MessageQueue.nativePollOnce(Native Method)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.os.MessageQueue.next(MessageQueue.java:138)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.os.Looper.loop(Looper.java:123)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at android.app.ActivityThread.main(ActivityThread.java:5017)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at java.lang.reflect.Method.invokeNative(Native Method)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at java.lang.reflect.Method.invoke(Method.java:515)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
04-24 16:37:33.407: E/MessageQueue-JNI(24541):  at dalvik.system.NativeStart.main(Native Method)
04-24 16:37:33.407: D/AndroidRuntime(24541): Shutting down VM
Was it helpful?

Solution

My problems stemmed from poor organization. Firstly, with the I tried to share models in both of my MVCs which was a bad idea. One problem (which wasn't stated here because it wasn't my most immediate bug) was that the content of the ListView wouldn't change between Most Viewed and Most Recent. Adding a separate ArrayList so each type had its own List solved that problem. In order to get rid of my original problem, I merged my StringAsync and PhotoAsync, but created a separate AsyncTask so I could have one for my Most Viewed photos and one for my Most Recent. After doing that, and changing the other logic in order to make those organizational changes work, my app magically worked. Perfectly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top