Search in sources :

Example 1 with ViewFinder

use of com.github.kevinsawicki.wishlist.ViewFinder in project PocketHub by pockethub.

the class BaseActivity method onCreate.

@CallSuper
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    lifecycleSubject.onNext(ActivityEvent.CREATE);
    finder = new ViewFinder(this);
}
Also used : ViewFinder(com.github.kevinsawicki.wishlist.ViewFinder) CallSuper(android.support.annotation.CallSuper)

Example 2 with ViewFinder

use of com.github.kevinsawicki.wishlist.ViewFinder in project PocketHub by pockethub.

the class DialogFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    finder = new ViewFinder(view);
}
Also used : ViewFinder(com.github.kevinsawicki.wishlist.ViewFinder)

Example 3 with ViewFinder

use of com.github.kevinsawicki.wishlist.ViewFinder in project PocketHub by pockethub.

the class RepositoryListFragment method onListItemLongClick.

@Override
public boolean onListItemLongClick(ListView list, View v, int position, long itemId) {
    if (!isUsable()) {
        return false;
    }
    final Repository repo = (Repository) list.getItemAtPosition(position);
    if (repo == null) {
        return false;
    }
    MaterialDialog.Builder builder = new MaterialDialog.Builder(getActivity()).title(InfoUtils.createRepoId(repo));
    final MaterialDialog[] dialogHolder = new MaterialDialog[1];
    View view = getActivity().getLayoutInflater().inflate(R.layout.repo_dialog, null);
    ViewFinder finder = new ViewFinder(view);
    final User owner = repo.owner();
    avatars.bind(finder.imageView(R.id.iv_owner_avatar), owner);
    finder.setText(R.id.tv_owner_name, getString(R.string.navigate_to_user, owner.login()));
    finder.onClick(R.id.ll_owner_area, new OnClickListener() {

        @Override
        public void onClick(View v) {
            dialogHolder[0].dismiss();
            viewUser(owner);
        }
    });
    if ((recentRepos != null) && (recentRepos.contains(repo))) {
        finder.find(R.id.divider).setVisibility(View.VISIBLE);
        finder.find(R.id.ll_recent_repo_area).setVisibility(View.VISIBLE);
        finder.onClick(R.id.ll_recent_repo_area, new OnClickListener() {

            @Override
            public void onClick(View v) {
                dialogHolder[0].dismiss();
                recentRepos.remove(repo);
                refresh();
            }
        });
    }
    builder.customView(view, false);
    MaterialDialog dialog = builder.build();
    dialogHolder[0] = dialog;
    dialog.setCanceledOnTouchOutside(true);
    dialog.show();
    return true;
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) ViewFinder(com.github.kevinsawicki.wishlist.ViewFinder) User(com.meisolsson.githubsdk.model.User) OnClickListener(android.view.View.OnClickListener) View(android.view.View) ListView(android.widget.ListView)

Example 4 with ViewFinder

use of com.github.kevinsawicki.wishlist.ViewFinder in project PocketHub by pockethub.

the class NewsFragment method onListItemLongClick.

@Override
public boolean onListItemLongClick(ListView l, View v, int position, long itemId) {
    if (!isUsable()) {
        return false;
    }
    final GitHubEvent event = (GitHubEvent) l.getItemAtPosition(position);
    final Repository repo = ConvertUtils.eventRepoToRepo(event.repo());
    final User user = event.actor();
    if (repo != null && user != null) {
        final MaterialDialog.Builder builder = new MaterialDialog.Builder(getActivity()).title(R.string.navigate_to);
        // Hacky but necessary since material dialogs has a different API
        final MaterialDialog[] dialogHolder = new MaterialDialog[1];
        View view = getActivity().getLayoutInflater().inflate(R.layout.nav_dialog, null);
        ViewFinder finder = new ViewFinder(view);
        avatars.bind(finder.imageView(R.id.iv_user_avatar), user);
        avatars.bind(finder.imageView(R.id.iv_repo_avatar), repo.owner());
        finder.setText(R.id.tv_login, user.login());
        finder.setText(R.id.tv_repo_name, InfoUtils.createRepoId(repo));
        finder.onClick(R.id.ll_user_area, new OnClickListener() {

            @Override
            public void onClick(View v) {
                dialogHolder[0].dismiss();
                viewUser(user);
            }
        });
        finder.onClick(R.id.ll_repo_area, new OnClickListener() {

            @Override
            public void onClick(View v) {
                dialogHolder[0].dismiss();
                viewRepository(repo);
            }
        });
        builder.customView(view, false);
        MaterialDialog dialog = builder.build();
        dialogHolder[0] = dialog;
        dialog.setCanceledOnTouchOutside(true);
        dialog.show();
        return true;
    }
    return false;
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) User(com.meisolsson.githubsdk.model.User) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) ViewFinder(com.github.kevinsawicki.wishlist.ViewFinder) OnClickListener(android.view.View.OnClickListener) GitHubEvent(com.meisolsson.githubsdk.model.GitHubEvent) View(android.view.View) ListView(android.widget.ListView)

Aggregations

ViewFinder (com.github.kevinsawicki.wishlist.ViewFinder)4 View (android.view.View)2 OnClickListener (android.view.View.OnClickListener)2 ListView (android.widget.ListView)2 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)2 Repository (com.meisolsson.githubsdk.model.Repository)2 User (com.meisolsson.githubsdk.model.User)2 CallSuper (android.support.annotation.CallSuper)1 GitHubEvent (com.meisolsson.githubsdk.model.GitHubEvent)1