use of com.activeandroid.query.Select in project ActiveAndroid by pardom.
the class ExistsTest method testExistsEmptyResult.
/**
* Should return {@code false} since the where-clause matches zero rows and thus the result set
* is empty.
*/
public void testExistsEmptyResult() {
cleanTable();
populateTable();
From from = new Select().from(MockModel.class).where("intField = ?", 3);
final List<MockModel> list = from.execute();
final boolean exists = from.exists();
assertFalse(exists);
assertFalse(list.size() > 0);
}
use of com.activeandroid.query.Select in project ActiveAndroid by pardom.
the class ExistsTest method testCountOrderBySql.
/**
* Shouldn't include <i>order by</i> as it has no influence on the result of <i>exists</i> and
* should improve performance.
*/
public void testCountOrderBySql() {
final String expected = "SELECT EXISTS(SELECT 1 FROM MockModel WHERE intField <> ? GROUP BY intField )";
String actual = new Select().from(MockModel.class).groupBy("intField").orderBy("intField").where("intField <> ?", 0).toExistsSql();
assertEquals(expected, actual);
}
use of com.activeandroid.query.Select in project ActiveAndroid by pardom.
the class SelectTest method testSelectDistinct.
public void testSelectDistinct() {
assertSqlEquals("SELECT DISTINCT * ", new Select().distinct());
assertSqlEquals("SELECT DISTINCT * ", new Select().all().distinct());
}
use of com.activeandroid.query.Select in project nmid-headline by miao1007.
the class FavFeedFragment method loadNewFeeds.
@Override
void loadNewFeeds() {
List<Feed> feeds = new ArrayList<>();
feeds = new Select().from(Feed.class).orderBy("idMember desc").limit(this.feed_limit).execute();
if (feeds == null || feeds.isEmpty()) {
showErrorView(View.VISIBLE);
} else {
newsBeans.addAll(feeds);
adapter.notifyDataSetChanged();
}
mSwipeRefreshLayout.setRefreshing(false);
}
use of com.activeandroid.query.Select in project AnimeTaste by daimajia.
the class Animation method addToFavorite.
public void addToFavorite(final UpdateFinishCallback callback) {
IsFav = true;
new Thread() {
@Override
public void run() {
super.run();
boolean exist = new Select().from(Animation.class).where("AnimationId='" + AnimationId + "'").executeSingle() != null;
if (!exist)
save();
else
new com.activeandroid.query.Update(Animation.class).set("IsFavorite='1'").where("AnimationId='" + AnimationId + "'").execute();
Message msg = Message.obtain();
Looper.prepare();
msg.setTarget(new FavoriteHandler(callback, Method.ADD_FAVORITE));
msg.sendToTarget();
Looper.loop();
}
}.start();
}
Aggregations