Search in sources :

Example 36 with User

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

the class AssigneeDialogFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    Activity activity = getActivity();
    Bundle arguments = getArguments();
    final MaterialDialog.Builder dialogBuilder = createDialogBuilder().negativeText(R.string.cancel).onNegative(new MaterialDialog.SingleButtonCallback() {

        @Override
        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
            AssigneeDialogFragment.this.onClick(dialog, BUTTON_NEGATIVE);
        }
    }).neutralText(R.string.clear).onNeutral(new MaterialDialog.SingleButtonCallback() {

        @Override
        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
            AssigneeDialogFragment.this.onClick(dialog, BUTTON_NEUTRAL);
        }
    });
    LayoutInflater inflater = activity.getLayoutInflater();
    ListView view = (ListView) inflater.inflate(R.layout.dialog_list_view, null);
    view.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            onClick(getDialog(), position);
        }
    });
    ArrayList<User> choices = getChoices();
    int selected = arguments.getInt(ARG_SELECTED_CHOICE);
    UserListAdapter adapter = new UserListAdapter(inflater, choices.toArray(new User[choices.size()]), selected, loader);
    view.setAdapter(adapter);
    if (selected >= 0) {
        view.setSelection(selected);
    }
    dialogBuilder.customView(view, false);
    return dialogBuilder.build();
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) User(com.meisolsson.githubsdk.model.User) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) Bundle(android.os.Bundle) BaseActivity(com.github.pockethub.android.ui.BaseActivity) Activity(android.app.Activity) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ListView(android.widget.ListView) DialogAction(com.afollestad.materialdialogs.DialogAction) LayoutInflater(android.view.LayoutInflater)

Example 37 with User

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

the class GistFilesViewActivity method configurePager.

private void configurePager() {
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    User author = gist.owner();
    if (author != null) {
        actionBar.setSubtitle(author.login());
        avatars.bind(actionBar, author);
    } else {
        actionBar.setSubtitle(R.string.anonymous);
    }
    ViewUtils.setGone(loadingBar, true);
    ViewUtils.setGone(pager, false);
    ViewUtils.setGone(tabs, false);
    adapter = new GistFilesPagerAdapter(this, gist);
    pager.setAdapter(adapter);
    tabs.setupWithViewPager(pager);
    if (initialPosition < adapter.getCount()) {
        pager.scheduleSetItem(initialPosition);
        onPageSelected(initialPosition);
    }
}
Also used : User(com.meisolsson.githubsdk.model.User) ActionBar(android.support.v7.app.ActionBar)

Example 38 with User

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

the class GistFragment method isOwner.

private boolean isOwner() {
    if (gist == null) {
        return false;
    }
    User user = gist.owner();
    if (user == null) {
        return false;
    }
    String login = AccountUtils.getLogin(getActivity());
    return login != null && login.equals(user.login());
}
Also used : User(com.meisolsson.githubsdk.model.User)

Example 39 with User

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

the class GistFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    list = finder.find(android.R.id.list);
    progress = finder.find(R.id.pb_loading);
    Activity activity = getActivity();
    User user = gist.owner();
    String userName = null;
    if (user != null) {
        userName = user.login();
    }
    adapter = new HeaderFooterListAdapter<>(list, new CommentListAdapter(activity.getLayoutInflater(), null, avatars, imageGetter, editCommentListener, deleteCommentListener, userName, isOwner(), null));
    list.setAdapter(adapter);
}
Also used : User(com.meisolsson.githubsdk.model.User) FragmentActivity(android.support.v4.app.FragmentActivity) Activity(android.app.Activity) CommentListAdapter(com.github.pockethub.android.ui.comment.CommentListAdapter)

Example 40 with User

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

the class MembersFragment method onCreateLoader.

@Override
public Loader<List<User>> onCreateLoader(int id, Bundle args) {
    return new ThrowableLoader<List<User>>(getActivity(), items) {

        @Override
        public List<User> loadData() throws Exception {
            OrganizationMemberService service = ServiceGenerator.createService(getContext(), OrganizationMemberService.class);
            int current = 1;
            int last = -1;
            List<User> users = new ArrayList<>();
            while (current != last) {
                Page<User> page = service.getMembers(org.login(), current).blockingGet();
                users.addAll(page.items());
                last = page.last() != null ? page.last() : -1;
                current = page.next() != null ? page.next() : -1;
            }
            return users;
        }
    };
}
Also used : OrganizationMemberService(com.meisolsson.githubsdk.service.organizations.OrganizationMemberService) User(com.meisolsson.githubsdk.model.User) ArrayList(java.util.ArrayList) ThrowableLoader(com.github.pockethub.android.ThrowableLoader)

Aggregations

User (com.meisolsson.githubsdk.model.User)61 Repository (com.meisolsson.githubsdk.model.Repository)10 ActionBar (android.support.v7.app.ActionBar)6 ArrayList (java.util.ArrayList)5 Activity (android.app.Activity)4 RecentRepositories (com.github.pockethub.android.ui.repo.RecentRepositories)4 GitHubEvent (com.meisolsson.githubsdk.model.GitHubEvent)4 UserService (com.meisolsson.githubsdk.service.users.UserService)4 Bundle (android.os.Bundle)3 View (android.view.View)3 ListView (android.widget.ListView)3 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)3 ThrowableLoader (com.github.pockethub.android.ThrowableLoader)3 StyledText (com.github.pockethub.android.ui.StyledText)3 Label (com.meisolsson.githubsdk.model.Label)3 Milestone (com.meisolsson.githubsdk.model.Milestone)3 Account (android.accounts.Account)2 ContentValues (android.content.ContentValues)2 UiThreadTest (android.test.UiThreadTest)2 OnClickListener (android.view.View.OnClickListener)2