Search in sources :

Example 1 with API

use of email.schaal.ocreader.api.API 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();
        }
    });
}
Also used : API(email.schaal.ocreader.api.API) ProgressDialog(android.app.ProgressDialog) Feed(email.schaal.ocreader.database.model.Feed)

Example 2 with API

use of email.schaal.ocreader.api.API in project ocreader by schaal.

the class ManageFeedsActivity method addNewFeed.

@Override
public void addNewFeed(final String url, final long folderId, final boolean finishAfterAdd) {
    final ProgressDialog progressDialog = showProgress(this, getString(R.string.adding_feed));
    API.get(this, new API.InstanceReadyCallback() {

        @Override
        public void onInstanceReady(API api) {
            api.createFeed(getRealm(), url, folderId, new API.APICallback<Void, Throwable>() {

                @Override
                public void onSuccess(Void success) {
                    progressDialog.dismiss();
                    setResult(RESULT_OK);
                    if (finishAfterAdd)
                        finish();
                }

                @Override
                public void onFailure(Throwable throwable) {
                    progressDialog.cancel();
                    showErrorMessage(getString(R.string.feed_add_failed), throwable.getLocalizedMessage());
                }
            });
        }

        @Override
        public void onLoginFailure(Throwable e) {
            progressDialog.cancel();
        }
    });
}
Also used : API(email.schaal.ocreader.api.API) ProgressDialog(android.app.ProgressDialog)

Example 3 with API

use of email.schaal.ocreader.api.API in project ocreader by schaal.

the class ManageFeedsActivity method deleteFeed.

@Override
public void deleteFeed(final Feed feed) {
    new AlertDialog.Builder(this).setMessage(getString(R.string.confirm_feed_deletion, feed.getName())).setPositiveButton(R.string.delete, (dialog, which) -> {
        final ProgressDialog progressDialog = showProgress(ManageFeedsActivity.this, getString(R.string.deleting_feed, feed.getName()));
        API.get(ManageFeedsActivity.this, new API.InstanceReadyCallback() {

            @Override
            public void onInstanceReady(API api) {
                api.deleteFeed(getRealm(), feed, new API.APICallback<Void, Throwable>() {

                    @Override
                    public void onSuccess(Void n) {
                        progressDialog.dismiss();
                        setResult(RESULT_OK);
                    }

                    @Override
                    public void onFailure(Throwable throwable) {
                        progressDialog.cancel();
                        showErrorMessage(getString(R.string.delete_feed_failed), throwable.getLocalizedMessage());
                    }
                });
            }

            @Override
            public void onLoginFailure(Throwable e) {
                progressDialog.cancel();
            }
        });
    }).setNegativeButton(android.R.string.cancel, null).show();
}
Also used : API(email.schaal.ocreader.api.API) ProgressDialog(android.app.ProgressDialog)

Aggregations

ProgressDialog (android.app.ProgressDialog)3 API (email.schaal.ocreader.api.API)3 Feed (email.schaal.ocreader.database.model.Feed)1