use of email.schaal.ocreader.database.model.Feed in project ocreader by schaal.
the class JsonTest method TestJsonWithUnexpectedNull.
@Test
public void TestJsonWithUnexpectedNull() throws IOException {
Moshi moshi = new Moshi.Builder().add(Feed.class, new FeedTypeAdapter()).build();
String feedJson = "{\"id\":28,\"url\":\"http://rss.slashdot.org/Slashdot/slashdot\",\"title\":\"Slashdot\",\"faviconLink\":null,\"added\":1435334890,\"folderId\":0,\"unreadCount\":1093,\"ordering\":null,\"link\":\"http://slashdot.org/\",\"pinned\":false}";
Feed feed = moshi.adapter(Feed.class).fromJson(feedJson);
assertNull(feed.getFaviconLink());
}
use of email.schaal.ocreader.database.model.Feed in project ocreader by schaal.
the class ManageFeedsActivity method changeFeed.
@Override
public void changeFeed(final long feedId, final long folderId) {
final Feed feed = Feed.get(getRealm(), feedId);
final ProgressDialog progressDialog = showProgress(this, getString(R.string.moving_feed));
API.get(this, new API.InstanceReadyCallback() {
@Override
public void onInstanceReady(API api) {
api.moveFeed(getRealm(), feed, folderId, new API.APICallback<Void, Throwable>() {
@Override
public void onSuccess(Void v) {
progressDialog.dismiss();
setResult(RESULT_OK);
}
@Override
public void onFailure(Throwable throwable) {
progressDialog.cancel();
showErrorMessage(getString(R.string.feed_move_failed), throwable.getLocalizedMessage());
}
});
}
@Override
public void onLoginFailure(Throwable e) {
progressDialog.cancel();
}
});
}
use of email.schaal.ocreader.database.model.Feed in project ocreader by schaal.
the class ManageFeedsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityManageFeedsBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_manage_feeds);
setSupportActionBar(binding.toolbarLayout.toolbar);
// noinspection ConstantConditions
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
folderSpinnerAdapter = new FolderSpinnerAdapter(this, getRealm().where(Folder.class).sort(Folder.NAME).findAll());
FeedsAdapter adapter = new FeedsAdapter(getRealm(), this);
binding.feedsRecyclerview.setAdapter(adapter);
binding.feedsRecyclerview.setLayoutManager(new LinearLayoutManager(this));
binding.feedsRecyclerview.addItemDecoration(new DividerItemDecoration(this, R.dimen.divider_inset));
binding.fabAddFeed.setOnClickListener(view -> AddNewFeedDialogFragment.show(ManageFeedsActivity.this, null, false));
if (Intent.ACTION_SEND.equals(getIntent().getAction())) {
Feed feed = new Feed(-1);
feed.setUrl(getIntent().getStringExtra(Intent.EXTRA_TEXT));
AddNewFeedDialogFragment.show(this, feed, true);
}
}
use of email.schaal.ocreader.database.model.Feed in project ocreader by schaal.
the class APIv2 method moveFeed.
@Override
public void moveFeed(final Realm realm, final Feed feed, final long folderId, APICallback<Void, Throwable> apiCallback) {
final Feed changedFeed = new Feed();
changedFeed.setUrl(feed.getUrl());
changedFeed.setFolderId(feed.getFolderId());
api.changeFeed(feed.getId(), changedFeed).enqueue(new BaseRetrofitCallback<Map<String, Feed>>(apiCallback) {
@Override
protected void onResponseReal(Response<Map<String, Feed>> response) {
final Map<String, Feed> feedMap = response.body();
if (feedMap != null)
Queries.insert(realm, feedMap.get("feed"));
}
});
}
use of email.schaal.ocreader.database.model.Feed in project ocreader by schaal.
the class DatabaseTest method testFeedInsert.
@Test
public void testFeedInsert() {
Realm realm = null;
try {
Feed feed = getTestFeed();
realm = Realm.getDefaultInstance();
Queries.insert(realm, feed);
feed = Feed.get(realm, 1);
assertNotNull(feed);
assertEquals(feed.getName(), FEED_TITLE);
} finally {
assertNotNull(realm);
realm.close();
}
}
Aggregations