Merge pull request #104 from deathbaba/hot-fix

[and] async query fix
This commit is contained in:
Viktor Govako 2014-02-07 16:07:16 +02:00
commit 2c0a683d95
3 changed files with 18 additions and 7 deletions

Binary file not shown.

View file

@ -30,7 +30,6 @@ import android.widget.TextView;
import com.guidewithme.article.ArticleInfo;
import com.guidewithme.async.QueryResultLoader;
import com.guidewithme.cpp.Storage;
import com.guidewithme.R;
import com.guidewithme.util.Utils;
import com.guidewithme.widget.StorageArticleInfoAdapter;
import com.mapswithme.maps.api.MWMPoint;
@ -47,7 +46,7 @@ import com.mapswithme.maps.api.MapsWithMeApi;
*/
public class ArticleInfoListFragment extends ListFragment
implements LoaderCallbacks<Storage>, TextWatcher,
OnClickListener, LocationListener
OnClickListener, LocationListener
{
public interface OnListIconClickedListener
@ -293,20 +292,20 @@ public class ArticleInfoListFragment extends ListFragment
{
final Bundle args = new Bundle(1);
args.putString(KEY_QUERY, s.toString());
getLoaderManager().restartLoader(SEARCH_LOADER, args, this).forceLoad();
getLoaderManager().restartLoader(SEARCH_LOADER, args, this);
hideIf(TextUtils.isEmpty(s), mCross);
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
{
search(s);
}
{}
@Override
public void afterTextChanged(Editable s)
{}
{
search(s.toString());
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after)

View file

@ -13,6 +13,8 @@ public class QueryResultLoader extends AsyncTaskLoader<Storage>
private final double mLon;
private final boolean mUseLocation;
private boolean mIsReady = false;
public QueryResultLoader(Context context, Storage storage, String query)
{
super(context);
@ -36,7 +38,17 @@ public class QueryResultLoader extends AsyncTaskLoader<Storage>
public Storage loadInBackground()
{
mStorage.query(mQuery, mUseLocation, mLat, mLon);
mIsReady = true;
return mStorage;
}
@Override
protected void onStartLoading()
{
if (mIsReady && !takeContentChanged())
deliverResult(mStorage);
else
forceLoad();
}
}