Search in sources :

Example 86 with User

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

the class UserUriMatcherTest method testHttpsUriWithName.

/**
 * Verify URI with name
 */
@Test
public void testHttpsUriWithName() {
    User user = UserUriMatcher.getUser(Uri.parse("https://github.com/mojombo"));
    assertNotNull(user);
    assertEquals("mojombo", user.login());
}
Also used : User(com.meisolsson.githubsdk.model.User) Test(org.junit.Test)

Example 87 with User

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

the class LoginActivity method endAuth.

private void endAuth(final String accessToken, final String scope) {
    progressDialog.setContent(getString(R.string.loading_user));
    TokenStore.getInstance(this).saveToken(accessToken);
    userService.getUser().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).as(AutoDisposeUtils.bindToLifecycle(this)).subscribe(response -> {
        User user = response.body();
        Account account = new Account(user.login(), getString(R.string.account_type));
        Bundle userData = AccountsHelper.buildBundle(user.name(), user.email(), user.avatarUrl(), scope);
        userData.putString(AccountManager.KEY_AUTHTOKEN, accessToken);
        accountManager.addAccountExplicitly(account, null, userData);
        accountManager.setAuthToken(account, getString(R.string.account_type), accessToken);
        Bundle result = new Bundle();
        result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
        result.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type);
        result.putString(AccountManager.KEY_AUTHTOKEN, accessToken);
        configureSyncFor(account);
        setAccountAuthenticatorResult(result);
        finish();
    }, Throwable::printStackTrace);
}
Also used : Account(android.accounts.Account) User(com.meisolsson.githubsdk.model.User) Bundle(android.os.Bundle)

Example 88 with User

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

the class SyncCampaign method run.

@Override
public void run() {
    List<User> orgs;
    try {
        orgs = cache.requestAndStore(persistedOrgs);
        syncResult.stats.numUpdates++;
    } catch (SQLException e) {
        syncResult.stats.numIoExceptions++;
        Log.d(TAG, "Exception requesting users and orgs", e);
        return;
    }
    Log.d(TAG, "Syncing " + orgs.size() + " users and orgs");
    for (User org : orgs) {
        if (cancelled) {
            return;
        }
        Log.d(TAG, "Syncing repos for " + org.login());
        try {
            cache.requestAndStore(repos.create(org));
            syncResult.stats.numUpdates++;
        } catch (SQLException e) {
            syncResult.stats.numIoExceptions++;
            Log.d(TAG, "Exception requesting repositories", e);
        }
    }
    Log.d(TAG, "Sync campaign finished");
}
Also used : User(com.meisolsson.githubsdk.model.User) SQLException(android.database.SQLException)

Example 89 with User

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

the class UserEventMatcher method getUsers.

/**
 * Get {@link UserPair} from event
 *
 * @param event
 * @return user or null if event doesn't apply
 */
public static UserPair getUsers(final GitHubEvent event) {
    if (event == null || event.payload() == null) {
        return null;
    }
    GitHubEventType type = event.type();
    if (GitHubEventType.FollowEvent.equals(type)) {
        User from = event.actor();
        User to = ((FollowPayload) event.payload()).target();
        if (from != null && to != null) {
            return new UserPair(from, to);
        }
    }
    return null;
}
Also used : User(com.meisolsson.githubsdk.model.User) FollowPayload(com.meisolsson.githubsdk.model.payload.FollowPayload) GitHubEventType(com.meisolsson.githubsdk.model.GitHubEventType)

Example 90 with User

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

the class AssigneeDialogFragment method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    int selected = getArguments().getInt(ARG_SELECTED_CHOICE);
    GroupAdapter adapter = new GroupAdapter();
    for (User user : getChoices()) {
        adapter.add(new AssigneeDialogItem(avatars, user, selected));
    }
    adapter.setOnItemClickListener(this);
    return createDialogBuilder().adapter(adapter, null).negativeText(R.string.cancel).neutralText(R.string.clear).onNeutral((dialog, which) -> onResult(RESULT_OK)).build();
}
Also used : Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) RESULT_OK(android.app.Activity.RESULT_OK) Dialog(android.app.Dialog) GroupAdapter(com.xwray.groupie.GroupAdapter) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) User(com.meisolsson.githubsdk.model.User) BaseActivity(com.github.pockethub.android.ui.base.BaseActivity) Item(com.xwray.groupie.Item) SingleChoiceDialogFragment(com.github.pockethub.android.ui.SingleChoiceDialogFragment) AssigneeDialogItem(com.github.pockethub.android.ui.item.dialog.AssigneeDialogItem) View(android.view.View) R(com.github.pockethub.android.R) AvatarLoader(com.github.pockethub.android.util.AvatarLoader) User(com.meisolsson.githubsdk.model.User) GroupAdapter(com.xwray.groupie.GroupAdapter) AssigneeDialogItem(com.github.pockethub.android.ui.item.dialog.AssigneeDialogItem) NonNull(androidx.annotation.NonNull)

Aggregations

User (com.meisolsson.githubsdk.model.User)97 Repository (com.meisolsson.githubsdk.model.Repository)15 View (android.view.View)14 Intent (android.content.Intent)13 TextView (android.widget.TextView)11 ImageView (android.widget.ImageView)10 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)10 Label (com.meisolsson.githubsdk.model.Label)9 Milestone (com.meisolsson.githubsdk.model.Milestone)8 Bundle (android.os.Bundle)7 ApiHelpers (com.gh4a.utils.ApiHelpers)7 GitHubEvent (com.meisolsson.githubsdk.model.GitHubEvent)7 UserService (com.meisolsson.githubsdk.service.users.UserService)7 SmallTest (androidx.test.filters.SmallTest)6 List (java.util.List)6 ViewGroup (android.view.ViewGroup)5 AvatarHandler (com.gh4a.utils.AvatarHandler)5 UiUtils (com.gh4a.utils.UiUtils)5 Issue (com.meisolsson.githubsdk.model.Issue)5