Search in sources :

Example 1 with CommitLinesAdapter

use of com.fastaccess.ui.adapter.CommitLinesAdapter in project FastHub by k0shk0sh.

the class PullRequestFilesViewHolder method onToggle.

private void onToggle(boolean expanded, boolean animate, int position) {
    if (!expanded) {
        patch.swapAdapter(null, true);
        patch.setVisibility(View.GONE);
        name.setMaxLines(2);
        toggle.setRotation(0.0f);
    } else {
        if (adapter != null) {
            CommitFileChanges model = (CommitFileChanges) adapter.getItem(position);
            if (model.getLinesModel() != null && !model.getLinesModel().isEmpty()) {
                if (model.getLinesModel().size() <= 100) {
                    patch.setAdapter(new CommitLinesAdapter(model.getLinesModel(), this));
                    patch.setVisibility(View.VISIBLE);
                } else if (CommitFileChanges.canAttachToBundle(model)) {
                    if (adapter.getListener() != null) {
                        // noinspection unchecked
                        adapter.getListener().onItemClick(position, patch, model);
                    }
                } else {
                    Toasty.warning(itemView.getContext(), itemView.getResources().getString(R.string.too_large_changes)).show();
                    return;
                }
            } else {
                patch.swapAdapter(null, true);
                patch.setVisibility(View.GONE);
            }
        }
        name.setMaxLines(5);
        toggle.setRotation(180f);
    }
}
Also used : CommitFileChanges(com.fastaccess.data.dao.CommitFileChanges) CommitLinesAdapter(com.fastaccess.ui.adapter.CommitLinesAdapter)

Aggregations

CommitFileChanges (com.fastaccess.data.dao.CommitFileChanges)1 CommitLinesAdapter (com.fastaccess.ui.adapter.CommitLinesAdapter)1