Search in sources :

Example 11 with Gist

use of com.meisolsson.githubsdk.model.Gist in project PocketHub by pockethub.

the class NewsEventTextTest method testGist.

/**
 * Verify text of Gist event
 */
@UiThreadTest
public void testGist() {
    Gist gist = Gist.builder().id("1").build();
    GistPayload payload = GistPayload.builder().action(GistPayload.Action.Created).gist(gist).build();
    GitHubEvent event = createEvent(GitHubEventType.GistEvent, payload);
    updateView(event);
    verify("user created Gist 1");
}
Also used : Gist(com.meisolsson.githubsdk.model.Gist) GistPayload(com.meisolsson.githubsdk.model.payload.GistPayload) GitHubEvent(com.meisolsson.githubsdk.model.GitHubEvent) UiThreadTest(android.test.UiThreadTest)

Example 12 with Gist

use of com.meisolsson.githubsdk.model.Gist in project PocketHub by pockethub.

the class GistsViewActivity method onPageSelected.

@Override
public void onPageSelected(int position) {
    super.onPageSelected(position);
    String gistId = gists[position];
    Gist gist = store.getGist(gistId);
    updateActionBar(gist, gistId);
}
Also used : Gist(com.meisolsson.githubsdk.model.Gist)

Example 13 with Gist

use of com.meisolsson.githubsdk.model.Gist in project PocketHub by pockethub.

the class CreateCommentActivityTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    User user = User.builder().login("abc").build();
    Gist gist = Gist.builder().user(user).id("123").build();
    setActivityIntent(CreateCommentActivity.createIntent(gist));
}
Also used : Gist(com.meisolsson.githubsdk.model.Gist) User(com.meisolsson.githubsdk.model.User)

Example 14 with Gist

use of com.meisolsson.githubsdk.model.Gist in project PocketHub by pockethub.

the class GistStore method addGist.

/**
 * Add gist to store
 *
 * @param gist
 * @return gist
 */
public Gist addGist(Gist gist) {
    Gist current = getGist(gist.id());
    if (current != null && current.equals(gist)) {
        return current;
    }
    gist = gist.toBuilder().files(sortFiles(gist)).build();
    gists.put(gist.id(), gist);
    return gist;
}
Also used : CreateGist(com.meisolsson.githubsdk.model.request.gist.CreateGist) Gist(com.meisolsson.githubsdk.model.Gist)

Example 15 with Gist

use of com.meisolsson.githubsdk.model.Gist in project PocketHub by pockethub.

the class GistUriMatcher method getGist.

/**
 * Parse a {@link Gist} from a non-null {@link Uri}
 *
 * @param uri
 * @return {@link Gist} or null if none found in given {@link Uri}
 */
public static Gist getGist(final Uri uri) {
    List<String> segments = uri.getPathSegments();
    if (segments.size() != 1) {
        return null;
    }
    String gistId = segments.get(0);
    if (TextUtils.isEmpty(gistId)) {
        return null;
    }
    Gist gist = Gist.builder().id(gistId).build();
    if (TextUtils.isDigitsOnly(gistId)) {
        return gist;
    }
    if (PATTERN.matcher(gistId).matches()) {
        return gist;
    }
    return null;
}
Also used : Gist(com.meisolsson.githubsdk.model.Gist)

Aggregations

Gist (com.meisolsson.githubsdk.model.Gist)17 GitHubEvent (com.meisolsson.githubsdk.model.GitHubEvent)4 MenuItem (android.view.MenuItem)3 GistStore (com.github.pockethub.android.core.gist.GistStore)3 Issue (com.meisolsson.githubsdk.model.Issue)3 Repository (com.meisolsson.githubsdk.model.Repository)3 Bundle (android.os.Bundle)2 NonNull (android.support.annotation.NonNull)2 Menu (android.view.Menu)2 MenuInflater (android.view.MenuInflater)2 View (android.view.View)2 Builder (com.github.pockethub.android.Intents.Builder)2 R (com.github.pockethub.android.R)2 UserPair (com.github.pockethub.android.core.user.UserEventMatcher.UserPair)2 ToastUtils (com.github.pockethub.android.util.ToastUtils)2 Single (io.reactivex.Single)2 AndroidSchedulers (io.reactivex.android.schedulers.AndroidSchedulers)2 Schedulers (io.reactivex.schedulers.Schedulers)2 IOException (java.io.IOException)2 Inject (javax.inject.Inject)2