Back to project page PlayTunes.
The source code is released under:
Copyright (c) 2014, Impeccable Labs, LLC. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions ar...
If you think the Android project PlayTunes listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.ideabag.playtunes.adapter; /* ww w.jav a2 s . co m*/ import com.ideabag.playtunes.database.MediaQuery; import com.ideabag.playtunes.database.MediaQuery.OnQueryCompletedListener; import android.content.Context; import android.database.Cursor; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; public class AsyncQueryAdapter extends BaseAdapter implements MediaQuery.OnQueryCompletedListener { protected Context mContext; protected Cursor mCursor = null; protected MediaQuery mQuery = null; protected MediaQuery.OnQueryCompletedListener mListener = null; public AsyncQueryAdapter( Context context ) { mContext = context; } public MediaQuery getQuery() { return mQuery; } public void setOnQueryCompletedListener( OnQueryCompletedListener listener ) { mListener = listener; } protected void setMediaQuery( MediaQuery query ) { mQuery = query; requery(); } // // Probably depreciated, use requeryAsync instead // public void requery() { MediaQuery.executeAsync( mContext, mQuery, this ); } @Override public void onQueryCompleted( MediaQuery mQuery, Cursor mResult ) { if ( null != mCursor && !mCursor.isClosed() ) { mCursor.close(); } mCursor = mResult; notifyDataSetChanged(); if ( null != mListener ) { try { mListener.onQueryCompleted( mQuery, mResult ); } catch( Exception e) { } } } @Override public int getCount() { return ( null != mCursor && !mCursor.isClosed() ? mCursor.getCount() : 0 ); } @Override public Object getItem(int position) { return null; } @Override public long getItemId(int position) { return 0; } @Override public View getView(int position, View convertView, ViewGroup parent) { return null; } }