Search in sources :

Example 1 with CommitFileChanges

use of com.fastaccess.data.dao.CommitFileChanges in project FastHub by k0shk0sh.

the class CommitFilesFragment method onToggle.

@Override
public void onToggle(long position, boolean isCollapsed) {
    CommitFileChanges model = adapter.getItem((int) position);
    if (model == null)
        return;
    if (model.getCommitFileModel().getPatch() == null) {
        if ("renamed".equalsIgnoreCase(model.getCommitFileModel().getStatus())) {
            SchemeParser.launchUri(getContext(), model.getCommitFileModel().getBlobUrl());
            return;
        }
        ActivityHelper.startCustomTab(getActivity(), adapter.getItem((int) position).getCommitFileModel().getBlobUrl());
    }
    toggleMap.put(position, isCollapsed);
}
Also used : CommitFileChanges(com.fastaccess.data.dao.CommitFileChanges)

Example 2 with CommitFileChanges

use of com.fastaccess.data.dao.CommitFileChanges in project FastHub by k0shk0sh.

the class PullRequestFilesFragment method onToggle.

@Override
public void onToggle(long position, boolean isCollapsed) {
    CommitFileChanges model = adapter.getItem((int) position);
    if (model == null)
        return;
    if (model.getCommitFileModel().getPatch() == null) {
        if ("renamed".equalsIgnoreCase(model.getCommitFileModel().getStatus())) {
            SchemeParser.launchUri(getContext(), model.getCommitFileModel().getBlobUrl());
            return;
        }
        ActivityHelper.startCustomTab(getActivity(), adapter.getItem((int) position).getCommitFileModel().getBlobUrl());
    }
    toggleMap.put(position, isCollapsed);
}
Also used : CommitFileChanges(com.fastaccess.data.dao.CommitFileChanges)

Example 3 with CommitFileChanges

use of com.fastaccess.data.dao.CommitFileChanges in project FastHub by k0shk0sh.

the class PullRequestFilesFragment method onCommentAdded.

@Override
public void onCommentAdded(@NonNull String comment, @NonNull CommitLinesModel item, Bundle bundle) {
    if (bundle != null) {
        String path = bundle.getString(BundleConstant.ITEM);
        if (path == null)
            return;
        CommentRequestModel commentRequestModel = new CommentRequestModel();
        commentRequestModel.setBody(comment);
        commentRequestModel.setPath(path);
        commentRequestModel.setPosition(item.getPosition());
        if (viewCallback != null)
            viewCallback.onAddComment(commentRequestModel);
        int groupPosition = bundle.getInt(BundleConstant.EXTRA_TWO);
        int childPosition = bundle.getInt(BundleConstant.EXTRA_THREE);
        CommitFileChanges commitFileChanges = adapter.getItem(groupPosition);
        List<CommitLinesModel> models = commitFileChanges.getLinesModel();
        if (models != null && !models.isEmpty()) {
            CommitLinesModel current = models.get(childPosition);
            if (current != null) {
                current.setHasCommentedOn(true);
            }
            models.set(childPosition, current);
            adapter.notifyItemChanged(groupPosition);
        }
    }
}
Also used : CommentRequestModel(com.fastaccess.data.dao.CommentRequestModel) CommitLinesModel(com.fastaccess.data.dao.CommitLinesModel) CommitFileChanges(com.fastaccess.data.dao.CommitFileChanges)

Example 4 with CommitFileChanges

use of com.fastaccess.data.dao.CommitFileChanges 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)

Example 5 with CommitFileChanges

use of com.fastaccess.data.dao.CommitFileChanges in project FastHub by k0shk0sh.

the class PullRequestFilesViewHolder method onItemLongClick.

@Override
public void onItemLongClick(int position, View v, CommitLinesModel item) {
    if (adapter == null)
        return;
    int groupPosition = getAdapterPosition();
    CommitFileChanges commitFileChanges = (CommitFileChanges) adapter.getItem(groupPosition);
    int lineNo = item.getLeftLineNo() > 0 ? item.getLeftLineNo() : item.getRightLineNo();
    String url = commitFileChanges.getCommitFileModel().getBlobUrl() + "#L" + lineNo;
    AppHelper.copyToClipboard(v.getContext(), url);
}
Also used : BindString(butterknife.BindString) CommitFileChanges(com.fastaccess.data.dao.CommitFileChanges)

Aggregations

CommitFileChanges (com.fastaccess.data.dao.CommitFileChanges)6 BindString (butterknife.BindString)1 CommentRequestModel (com.fastaccess.data.dao.CommentRequestModel)1 CommitLinesModel (com.fastaccess.data.dao.CommitLinesModel)1 CommitLinesAdapter (com.fastaccess.ui.adapter.CommitLinesAdapter)1