use of com.meisolsson.githubsdk.model.request.gist.CreateGist in project PocketHub by pockethub.
the class CreateGistActivity method createGist.
private void createGist() {
final boolean isPublic = publicCheckBox.isChecked();
String enteredDescription = descriptionText.getText().toString().trim();
final String description = enteredDescription.length() > 0 ? enteredDescription : getString(R.string.gist_description_hint);
String enteredName = nameText.getText().toString().trim();
final String name = enteredName.length() > 0 ? enteredName : getString(R.string.gist_file_name_hint);
final String content = contentText.getText().toString();
Map<String, GistFile> map = new HashMap<>();
map.put(name, GistFile.builder().filename(name).content(content).build());
CreateGist createGist = CreateGist.builder().files(map).description(description).isPublic(isPublic).build();
ServiceGenerator.createService(this, GistService.class).createGist(createGist).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).compose(RxProgress.bindToLifecycle(this, R.string.creating_gist)).as(AutoDisposeUtils.bindToLifecycle(this)).subscribe(response -> {
startActivity(GistsViewActivity.createIntent(response.body()));
setResult(RESULT_OK);
finish();
}, e -> {
Log.d(TAG, "Exception creating Gist", e);
ToastUtils.show(this, e.getMessage());
});
}
Aggregations