Comments (8)
Thx. Could you be more specific, give a better example. However if you simply refer to the tags and how you could add some more markdown stuff you have to adapt the oldTag
, newTag
method calls. However this only works, if the Android textview supports some kind of css, html or markdown styling. So this should be sufficient regarding to (https://www.myandroidsolutions.com/2017/09/29/android-html-textview/#.Y-K2K3bMJaY).
DiffRowGenerator generator = DiffRowGenerator.create()
.showInlineDiffs(true)
.inlineDiffByWord(true)
.oldTag(f -> "~") //introduce markdown style for strikethrough
.newTag(f -> "**") //introduce markdown style for bold
.build();
The oldTag
, newTag
methods are used to provide a Function<Boolean, String>. This function is called with true
before the changed text and with false
after it. So this should do it:
DiffRowGenerator generator = DiffRowGenerator.create()
.showInlineDiffs(true)
.inlineDiffByWord(true)
.oldTag(f -> f?"<font color='red'>":"</font>") //introduce html style for strikethrough
.newTag(f -> f?"<font color='green'>":"</font>") //introduce html style for bold
.build();
from java-diff-utils.
Thank you sir for your reply..I really very greatful to you.. And it's working...
But one thing, Actually I am trying to make an app that can compare 2 text files.. But in my code
DiffRowGenerator generator = DiffRowGenerator.create() .showInlineDiffs(true) .inlineDiffByWord(true) .oldTag(f -> f?"<font color='red'>":"</font>") .newTag(f -> f?"<font color='green'>":"</font>") .build(); List<DiffRow> rows = generator.generateDiffRows( Arrays.asList(FileUtil.readFile("/storage/emulated/0/Engine.java")), Arrays.asList(FileUtil.readFile("/storage/emulated/0/Engine (1).java"))); for (DiffRow row : rows) { textview1.setText(Html.fromHtml(row.getNewLine(), >Html.FROM_HTML_MODE_COMPACT)); textview2.setText(Html.fromHtml(row.getOldLine(), >Html.FROM_HTML_MODE_COMPACT)); }
``
Here I defined all the requirements but I am confused, after text comparator why textview showing only the text line where the text is deleted or modified ... Just see my image , this portion is modified and it only showing in the textview. not my other text ....How to solve it ..Thanks ❤️
from java-diff-utils.
generator.reportLinesUnchanged(true)
delivers unchanged lines as well.
from java-diff-utils.
Sir giving same result..only one line even the if file have 3 line and 2nd and 3rd line have some text changes..but after text compare only showing the last line modification comparison not the 2nd line
from java-diff-utils.
You overwrite the previous line within your for loop. setText
replaces text and does not append. So no problem with the diff tool.
from java-diff-utils.
@wumpz sir explain more clearly sir I unable to understand...Sir I am new
progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setMessage("Processing...");
progressDialog.show();
final Handler mHandler = new Handler() {
public void handleMessage(Message msg) {
progressDialog.dismiss();
}
};
new Thread() {
public void run() {
Looper.prepare();
try {
DiffRowGenerator generator = DiffRowGenerator.create()
.showInlineDiffs(true)
.inlineDiffByWord(true)
.replaceOriginalLinefeedInChangesWithSpaces(false)
.reportLinesUnchanged(true)
.ignoreWhiteSpaces(false)
.oldTag(f -> f?"":"")
.newTag(f -> f?"":"")
.build();
List rows = generator.generateDiffRows(
Arrays.asList(textview1.getText().toString()),
Arrays.asList(textview2.getText().toString()));
for (DiffRow row : rows) {
textview1.setText(textview1.getText().toString() + Html.fromHtml(row.getNewLine(), Html.FROM_HTML_MODE_COMPACT));
textview2.setText(textview2.getText().toString() + Html.fromHtml(row.getOldLine(), Html.FROM_HTML_MODE_COMPACT));
}
} catch (Exception e) {
SketchwareUtil.showMessage(getApplicationContext(), e.toString());
}
mHandler.sendEmptyMessage(0);
Looper.loop();
} }.start();
``
I have set a loop here but not working...
There is 3 errors but it don't mentioning in comparison
Explain me with this code sir ....for which I can use it in my project thank you
from java-diff-utils.
At first glance, you do not use your original DiffRowGenerator
anymore. Why? It worked. Now you do not include any formatting tags into your found diffs
.oldTag(f -> f?"":"")
.newTag(f -> f?"":"")
What does this do? Nothing. So nothing is hilited in your text.
from java-diff-utils.
Stale issue message
from java-diff-utils.
Related Issues (20)
- DiffUtils#diff(List<String>,List<String) output does not provide too much information HOT 2
- Request: Include simple copy-paste snippets in README.md HOT 2
- Typo in classes Myers vs Meyers HOT 3
- The output is wrong HOT 1
- DiffUtils.diff() need ignoreWhiteSpaces or ignoreBlankLines HOT 2
- Howto: Diff two objects and get the textual differences of its fields HOT 4
- Feature request: Table Diff HOT 6
- Crash on android 6 HOT 2
- Feature Request - To Merge Differences HOT 1
- How to create a storable patch? HOT 2
- Requirement regarding conflict while applying a patch HOT 2
- Add module-info.java to library HOT 7
- Add section heading support to diff parse utils HOT 3
- Migration from 4.0 to 4.4 HOT 1
- 这个太强大了。赞!赞!赞! HOT 3
- this place will throw Exception HOT 3
- Detecting Moved Lines in Diffs HOT 2
- parseUnifiedDiff exception on valid diff (Binary files)
- Simple renames makes diff be parsed incorreclty HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from java-diff-utils.