Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions src/main/java/pl/fracz/mcr/source/Line.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package pl.fracz.mcr.source;

/*
2013-10-23, fracz, first implementation
2013-10-30, fracz, added syntax highlighting

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Historię można przejrzeć na gicie, komentarze śmiecą

2014-02-26, fracz, added ability to add voice comment
*/

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.text.Html;
import android.widget.LinearLayout;
import android.widget.TextView;
import pl.fracz.mcr.comment.AbstractComment;
import pl.fracz.mcr.comment.Comment;
import pl.fracz.mcr.comment.CommentNotAddedException;

import java.io.File;
import java.io.Serializable;
import java.util.List;

/**
* View that represents one line of code.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bezużyteczny komentarz

*/
@SuppressLint("ViewConstructor")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Złe zastosowanie klasy

public class Line extends LinearLayout implements Serializable {
private static final long serialVersionUID = 3076583280108678995L;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Niepotrzebny typ prymitywny

private static final int TWO = 2;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Niepotrzebna stała


private final int _lineNumber;

private final String _lineOfCode;

// holds the line number

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bezużyteczny komentarz

private TextView lineNumberView;

private TextView lineContent;

private SourceFile sourceFile;

private List<Comment> comments;

public Line(Context context, SourceFile sourceFile, int lineNumber,
String lineOfCode, boolean syntaxColor) {
super(context);
this.sourceFile = sourceFile;
this._lineNumber = lineNumber;
this._lineOfCode = lineOfCode;
setOrientation(LinearLayout.HORIZONTAL);

lineNumberView = new TextView(getContext());
lineNumberView.setText(String.format("%d.", lineNumber););

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brak kompilacji

lineNumberView.setSingleLine();
lineNumberView.setWidth(30);
addView(lineNumberView);

TextView lineContent = new TextView(getContext());
addLineContent(syntaxColor);
}

public int get() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zła nazwa

return _lineNumber;
}

/**
* Adds a text comment.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bezsesowny komentarz

*
* @param comment
* @throws CommentNotAddedException
*/
public void addTextComment(String comment) throws CommentNotAddedException {
Comment textComment = new Comment(AbstractComment.Type.TEXT, this);
textComment.setText(comment);
comments.add(textComment);
if (comments.size() > 0) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Łamie srp

lineNumberView.setBackgroundColor(Color.parseColor("#008000"));
}
}

/**
* Adds a voice comment.
*
* @param recordedFile
* @throws CommentNotAddedException
*/
public void createVoiceComment(File recodedFile) throws CommentNotAddedException {
Comment voiceComment = new Comment(AbstractComment.Type.VOICE, this);
voiceComment.setFile(recodedFile);
comments.add(voiceComment);
if (comments.size() > 0) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Łamie srp

lineNumberView.setBackgroundColor(Color.parseColor("#008000"));
}
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zakomentowany, niewykorzystany kod (pewnie niedokończony albo pozostałość z refaktoryzacji)

// public void addVideoComment(File videoFile) throws CommentNotAddedException {
// }

private void addLineContent(boolean syntaxColor){

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parametr typu boolean

if (!syntaxColor || !SyntaxHighlighter.canBeHighlighted(syntaxColor))

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Można uprościć wyrażenie logiczne

lineContent.setText(Html.fromHtml(lineOfCode));
else

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Godline

lineContent.setText(SyntaxHighlighter.highlight(Html.fromHtml(lineOfCode)));
lineContent.setTypeface(Typeface.MONOSPACE);
addView(lineContent);
}

public List<Comment> getComments(){
return this.comments;
}

public boolean hasConversation() {
sourceFile.markConversation(this);
return getComments().size() > TWO;
}
}