Search in sources :

Example 1 with CreateGist

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());
    });
}
Also used : HashMap(java.util.HashMap) CreateGist(com.meisolsson.githubsdk.model.request.gist.CreateGist) GistFile(com.meisolsson.githubsdk.model.GistFile)

Aggregations

GistFile (com.meisolsson.githubsdk.model.GistFile)1 CreateGist (com.meisolsson.githubsdk.model.request.gist.CreateGist)1 HashMap (java.util.HashMap)1