Skip to content

Commit

Permalink
Merge pull request #3 from baolanlequang/development
Browse files Browse the repository at this point in the history
Fixed and release version 0.0.5
  • Loading branch information
baolanlequang authored Feb 4, 2022
2 parents 6f123d7 + 33fe781 commit d0012bc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -307,20 +307,17 @@ class Jcamp {
private fun scanner(strVal: String): ArrayList<String> {
var result = ArrayList<String>()


var tmpStr = ""
val scanStr = strVal

var startPoint = -1

for ((idx, c) in scanStr.withIndex()) {
if (idx == startPoint-1) {
for ((idx, c) in strVal.withIndex()) {
if (idx == startPoint - 1) {
continue
}
if (c.isNumberic() || c.equals('.', true)) {
tmpStr = tmpStr.plus(c)
}
else {
} else {
if (tmpStr != "") {
tmpStr = tmpStr.trim()
result.add(tmpStr)
Expand All @@ -330,35 +327,33 @@ class Jcamp {
val charString = c.toString()
if (Constants.DUP.containsKey(charString)) {
var nextChars = ""
if (idx < scanStr.length - 1) {
startPoint = idx+1
while (scanStr[startPoint].isNumberic()) {
nextChars = nextChars.plus(scanStr[idx+1])
if (idx < strVal.length - 1) {
startPoint = idx + 1
while (strVal[startPoint].isNumberic()) {
nextChars = nextChars.plus(strVal[idx + 1])
startPoint += 1
}
}
val dupVal: Int = Constants.DUP[charString]!!
val strDupValFull = "%d%s".format(Locale.getDefault(), dupVal, nextChars)
var dupValInt: Int = dupVal
try {
strDupValFull.toInt()
}
catch (e: Exception) {
dupValInt = strDupValFull.toInt()
} catch (e: Exception) {

}
//Check DUP
for (i in 0 until dupValInt-1) {
val lastTmpStr = result.last()
// Log.d("baolanlequang", lastTmpStr)
if (!lastTmpStr.isNullOrEmpty()) {
result.add(lastTmpStr)
}
}
}
else if (Constants.SQZ.containsKey(charString)) {
} else if (Constants.SQZ.containsKey(charString)) {
val sqzVal = Constants.SQZ[charString]
tmpStr = tmpStr.plus(sqzVal)
}
else {
} else {
tmpStr = tmpStr.plus(c)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val input = assets.open("testdata/test_file_10_failed.dx")
val input = assets.open("testdata/test_file_20.dx")

val reader = JcampReader(input)
val jcamp = reader.jcamp
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
# jcamp-converter-android
Converter jcamp file for android

[![](https://jitpack.io/v/baolanlequang/jcamp-converter-android.svg)](https://jitpack.io/#baolanlequang/jcamp-converter-android)

Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}

Add the dependency
dependencies {
implementation 'com.github.baolanlequang:jcamp-converter-android:Tag'
}

0 comments on commit d0012bc

Please sign in to comment.