Skip to content

Commit d0012bc

Browse files
Merge pull request #3 from baolanlequang/development
Fixed and release version 0.0.5
2 parents 6f123d7 + 33fe781 commit d0012bc

File tree

4 files changed

+28
-18
lines changed

4 files changed

+28
-18
lines changed

JcampConverter/JcampConverter/src/main/java/com/baolan2005/jcampconverter/Jcamp.kt

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -307,20 +307,17 @@ class Jcamp {
307307
private fun scanner(strVal: String): ArrayList<String> {
308308
var result = ArrayList<String>()
309309

310-
311310
var tmpStr = ""
312-
val scanStr = strVal
313311

314312
var startPoint = -1
315313

316-
for ((idx, c) in scanStr.withIndex()) {
317-
if (idx == startPoint-1) {
314+
for ((idx, c) in strVal.withIndex()) {
315+
if (idx == startPoint - 1) {
318316
continue
319317
}
320318
if (c.isNumberic() || c.equals('.', true)) {
321319
tmpStr = tmpStr.plus(c)
322-
}
323-
else {
320+
} else {
324321
if (tmpStr != "") {
325322
tmpStr = tmpStr.trim()
326323
result.add(tmpStr)
@@ -330,35 +327,33 @@ class Jcamp {
330327
val charString = c.toString()
331328
if (Constants.DUP.containsKey(charString)) {
332329
var nextChars = ""
333-
if (idx < scanStr.length - 1) {
334-
startPoint = idx+1
335-
while (scanStr[startPoint].isNumberic()) {
336-
nextChars = nextChars.plus(scanStr[idx+1])
330+
if (idx < strVal.length - 1) {
331+
startPoint = idx + 1
332+
while (strVal[startPoint].isNumberic()) {
333+
nextChars = nextChars.plus(strVal[idx + 1])
337334
startPoint += 1
338335
}
339336
}
340337
val dupVal: Int = Constants.DUP[charString]!!
341338
val strDupValFull = "%d%s".format(Locale.getDefault(), dupVal, nextChars)
342339
var dupValInt: Int = dupVal
343340
try {
344-
strDupValFull.toInt()
345-
}
346-
catch (e: Exception) {
341+
dupValInt = strDupValFull.toInt()
342+
} catch (e: Exception) {
347343

348344
}
349345
//Check DUP
350346
for (i in 0 until dupValInt-1) {
351347
val lastTmpStr = result.last()
348+
// Log.d("baolanlequang", lastTmpStr)
352349
if (!lastTmpStr.isNullOrEmpty()) {
353350
result.add(lastTmpStr)
354351
}
355352
}
356-
}
357-
else if (Constants.SQZ.containsKey(charString)) {
353+
} else if (Constants.SQZ.containsKey(charString)) {
358354
val sqzVal = Constants.SQZ[charString]
359355
tmpStr = tmpStr.plus(sqzVal)
360-
}
361-
else {
356+
} else {
362357
tmpStr = tmpStr.plus(c)
363358
}
364359
}

JcampConverter/app/src/main/java/com/baolan2005/jcampconverter/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class MainActivity : AppCompatActivity() {
99
super.onCreate(savedInstanceState)
1010
setContentView(R.layout.activity_main)
1111

12-
val input = assets.open("testdata/test_file_10_failed.dx")
12+
val input = assets.open("testdata/test_file_20.dx")
1313

1414
val reader = JcampReader(input)
1515
val jcamp = reader.jcamp

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
11
# jcamp-converter-android
22
Converter jcamp file for android
3+
4+
[![](https://jitpack.io/v/baolanlequang/jcamp-converter-android.svg)](https://jitpack.io/#baolanlequang/jcamp-converter-android)
5+
6+
Add it in your root build.gradle at the end of repositories:
7+
allprojects {
8+
repositories {
9+
...
10+
maven { url 'https://jitpack.io' }
11+
}
12+
}
13+
14+
Add the dependency
15+
dependencies {
16+
implementation 'com.github.baolanlequang:jcamp-converter-android:Tag'
17+
}

0 commit comments

Comments
 (0)