use of com.newsrob.Entry in project newsrob by marianokamp.
the class PinTests method createArticleWithReadState.
private Entry createArticleWithReadState(ReadState desiredReadState) {
Entry e = new Entry();
e.setAtomId("atomid1");
e.setFeedTitle("feed_title");
e.setFeedAtomId("feed_atom_id1");
e.setTitle("title");
e.setUpdated(new Date().getTime() * 1000);
e.setReadState(desiredReadState);
entryManager.insert(e);
return entryManager.findEntryByAtomId("atomid1");
}
use of com.newsrob.Entry in project newsrob by marianokamp.
the class PinTests method testIncreaseUnreadLevelFromUnread.
public void testIncreaseUnreadLevelFromUnread() {
Entry article = createArticleWithReadState(ReadState.UNREAD);
entryManager.increaseUnreadLevel(article);
assertEquals(ReadState.PINNED, article.getReadState());
assertFalse(article.isReadStatePending());
entryManager.increaseUnreadLevel(article);
assertEquals(ReadState.PINNED, article.getReadState());
assertFalse(article.isReadStatePending());
}
use of com.newsrob.Entry in project newsrob by marianokamp.
the class TestUtil method populateDatabaseWithDataSet1.
public static void populateDatabaseWithDataSet1(EntryManager entryManager) {
Label l1 = new Label();
l1.setName("l1");
Label l2 = new Label();
l2.setName("l2");
// 1st article
Entry e = new Entry();
e.setAtomId("atomid1");
e.setFeedTitle("feed_title");
e.setFeedAtomId("feed_atom_id1");
e.setTitle("title");
e.setUpdated(new Date(2010, 10, 15).getTime() * 1000);
e.addLabel(l1);
entryManager.insert(e);
// 2nd article --- READ
e = new Entry();
e.setAtomId("atomid2");
e.setFeedTitle("feed_title2");
e.setFeedAtomId("feed_atom_id2");
e.setTitle("title2");
e.setUpdated(new Date(2010, 10, 14).getTime() * 1000);
e.addLabel(l1);
e.addLabel(l2);
e.setReadState(ReadState.READ);
entryManager.insert(e);
// 3rd article
e = new Entry();
e.setAtomId("atomid3");
e.setFeedTitle("feed_title1");
e.setFeedAtomId("feed_atom_id1");
e.setTitle("title3");
e.setUpdated(new Date(2010, 10, 16).getTime() * 1000);
e.addLabel(l2);
entryManager.insert(e);
// 4th article
e = new Entry();
e.setAtomId("atomid4");
e.setFeedTitle("feed_title1");
e.setFeedAtomId("feed_atom_id1");
e.setTitle("title4");
e.setUpdated(new Date(2010, 10, 17).getTime() * 1000);
e.addLabel(l2);
entryManager.insert(e);
// 5th article
e = new Entry();
e.setAtomId("atomid5");
e.setFeedTitle("feed_title1");
e.setFeedAtomId("feed_atom_id1");
e.setTitle("title5");
e.setUpdated(new Date(2010, 10, 18).getTime() * 1000);
e.addLabel(l2);
entryManager.insert(e);
}
use of com.newsrob.Entry in project newsrob by marianokamp.
the class UnsubscribeFeedTask method onContextItemSelected.
@Override
public boolean onContextItemSelected(final MenuItem item, final int position) {
Entry entry = findEntryByPosition(position);
if (entry == null)
return false;
if (position > -1 && item.getItemId() == MENU_ITEM_MARK_READ_UNTIL_HERE_ID) {
DBQuery dbq = new DBQuery(getDbQuery());
dbq.setDateLimit(entry.getUpdatedInHighResolution());
instantiateMarkAllReadDialog(dbq);
return true;
}
if (position > -1 && item.getItemId() == MENU_ITEM_UNSUBSCRIBE_FEED_ID) {
Feed f = getEntryManager().findFeedById(entry.getFeedId());
if (f == null)
return true;
final String feedAtomId = f.getAtomId();
Runnable r = new Runnable() {
@Override
public void run() {
new UnsubscribeFeedTask(getEntryManager()).execute(feedAtomId);
}
};
showConfirmationDialog("Unsubscribe from \'" + f.getTitle() + "\' during the next sync and mark all remaining articles read?", r);
return true;
}
if (ArticleViewHelper.articleActionSelected(this, item, getEntryManager(), entry))
return true;
return false;
}
use of com.newsrob.Entry in project newsrob by marianokamp.
the class UnsubscribeFeedTask method doFling.
private boolean doFling(float x1, float y1, float x2, float y2) {
final float xDiff = x1 - x2;
final float yDiff = y1 - y2;
final float xTravel = abs(xDiff);
final float yTravel = abs(yDiff);
final float maxFingerTravel = max(xTravel, yTravel);
if (minimumFlingTravel == null)
minimumFlingTravel = 18 * U.getDensity(this);
if (maxFingerTravel < minimumFlingTravel)
return false;
final float longerFingerTravel = maxFingerTravel;
final float shorterFingerTravel = min(xTravel, yTravel);
final float longerFingerTravelDominance = longerFingerTravel / shorterFingerTravel;
if (longerFingerTravelDominance < 1.3f)
return false;
boolean consumed = false;
if (xTravel > yTravel) {
int[] location = new int[2];
getListView().getLocationOnScreen(location);
int localX = (int) (x1 - location[0]);
int localY = (int) (y1 - location[1]);
int position = getListView().pointToPosition(localX, localY);
if (position == -1)
return true;
final Entry entry = findEntryByPosition(position);
if (entry == null)
return true;
consumed = true;
if (xDiff < 0) {
// LTR
if (entry == null)
return consumed;
getEntryManager().increaseReadLevel(entry);
} else {
// RTL
if (entry == null)
return consumed;
getEntryManager().increaseUnreadLevel(entry);
}
} else {
if (yDiff < 0) {
// TTB
} else {
// BTT
}
}
return consumed;
}
Aggregations