Skip to content

Commit

Permalink
release 1.9.2: convert from java to kotlin (some source code)
Browse files Browse the repository at this point in the history
- apply ktlint
  • Loading branch information
JellyBrick committed Jun 18, 2021
1 parent 6059854 commit 9362a97
Show file tree
Hide file tree
Showing 87 changed files with 234 additions and 232 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[*.{kt, kts}]
disabled_rules = no-wildcard-imports
2 changes: 0 additions & 2 deletions .idea/KotlinInside.iml

This file was deleted.

2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
### Gradle

```gradle
compile 'be.zvz:KotlinInside:1.9.1'
compile 'be.zvz:KotlinInside:1.9.2'
```

### Maven
Expand All @@ -17,7 +17,7 @@ compile 'be.zvz:KotlinInside:1.9.1'
<dependency>
<groupId>be.zvz</groupId>
<artifactId>KotlinInside</artifactId>
<version>1.9.1</version>
<version>1.9.2</version>
</dependency>
```

Expand Down
15 changes: 14 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import org.jmailen.gradle.kotlinter.tasks.*

plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.5.10'
id 'org.jetbrains.dokka' version '1.4.32'
id 'maven-publish'
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
id 'signing'
id 'org.jmailen.kotlinter' version '3.4.5'
}

def libName = 'KotlinInside'
def libDevVersion = ''
def libVersion = "1.9.1$libDevVersion"
def libVersion = "1.9.2$libDevVersion"
def libDesc = 'Unofficial DCInside API written in Kotlin'

group = 'be.zvz'
Expand Down Expand Up @@ -88,6 +91,16 @@ task sourcesJar(type: Jar, dependsOn: classes) {
from sourceSets.main.allSource
}

task ktLint(type: LintTask, group: 'verification') {
source files('src')
}

task ktFormat(type: FormatTask, group: 'formatting') {
source files('src')
report = file('build/format-report.txt')
disabledRules = ["import-ordering"]
}

signing {
useGpgCmd()
sign publishing.publications
Expand Down
78 changes: 0 additions & 78 deletions src/main/java/be/zvz/kotlininside/value/ApiUrl.java

This file was deleted.

17 changes: 0 additions & 17 deletions src/main/java/be/zvz/kotlininside/value/Const.java

This file was deleted.

24 changes: 13 additions & 11 deletions src/main/kotlin/be/zvz/kotlininside/KotlinInside.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,21 @@ class KotlinInside private constructor(
if (sessionAutoRefresh) {
val timer = Timer()

timer.schedule(object : TimerTask() {
override fun run() {
if (user is LoginUser) {
synchronized(instance) {
instance.hashedAppKey = instance.auth.generateHashedAppKey()
instance.app =
App(instance.hashedAppKey, instance.auth.fetchAppId(getInstance().hashedAppKey))
instance.session = instance.auth.login(user)
timer.schedule(
object : TimerTask() {
override fun run() {
if (user is LoginUser) {
synchronized(instance) {
instance.hashedAppKey = instance.auth.generateHashedAppKey()
instance.app =
App(instance.hashedAppKey, instance.auth.fetchAppId(getInstance().hashedAppKey))
instance.session = instance.auth.login(user)
}
}
}
}
}, 43200 * 1000, 43200 * 1000)
},
43200 * 1000, 43200 * 1000
)
}
}

Expand Down Expand Up @@ -69,5 +72,4 @@ class KotlinInside private constructor(
return instance
}
}

}
34 changes: 17 additions & 17 deletions src/main/kotlin/be/zvz/kotlininside/api/article/ArticleList.kt
Original file line number Diff line number Diff line change
Expand Up @@ -120,24 +120,24 @@ class ArticleList @JvmOverloads constructor(
@Throws(HttpException::class)
fun request() {
val url = "${ApiUrl.Article.LIST}?id=$gallId&page=$page&app_id=${KotlinInside.getInstance().auth.getAppId()}" +
StringBuilder().apply {
if (searchKeyword.isNotEmpty()) {
append("&s_type=")
append(searchType.type)
append("&serVal=").append(URLEncoder.encode(searchKeyword, "UTF-8").replace("+", "%20"))
}
if (recommend)
append("&recommend=1")
if (notice)
append("&notice=1")
if (headId > 0)
append("&headid=").append(headId)
session?.let {
if (it.user !is Anonymous) {
append("&confirm_id=").append(it.detail!!.userId)
}
StringBuilder().apply {
if (searchKeyword.isNotEmpty()) {
append("&s_type=")
append(searchType.type)
append("&serVal=").append(URLEncoder.encode(searchKeyword, "UTF-8").replace("+", "%20"))
}
if (recommend)
append("&recommend=1")
if (notice)
append("&notice=1")
if (headId > 0)
append("&headid=").append(headId)
session?.let {
if (it.user !is Anonymous) {
append("&confirm_id=").append(it.detail!!.userId)
}
}.toString()
}
}.toString()
json = KotlinInside.getInstance().httpInterface.get(Request.redirectUrl(url), Request.getDefaultOption())!!
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import org.apache.commons.text.StringEscapeUtils
import java.io.BufferedInputStream
import java.net.URL


class ArticleModify(
private val gallId: String,
private val articleId: Int,
Expand Down Expand Up @@ -154,4 +153,4 @@ class ArticleModify(

return articleWrite.write()
}
}
}
12 changes: 6 additions & 6 deletions src/main/kotlin/be/zvz/kotlininside/api/article/ArticleRead.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ class ArticleRead @JvmOverloads constructor(
fun request() {
val url =
"${ApiUrl.Article.READ}?id=$gallId&no=$articleId&app_id=${KotlinInside.getInstance().auth.getAppId()}" +
StringBuilder().apply {
session?.let {
if (it.user !is Anonymous) {
append("&confirm_id=").append(it.detail!!.userId)
}
StringBuilder().apply {
session?.let {
if (it.user !is Anonymous) {
append("&confirm_id=").append(it.detail!!.userId)
}
}.toString()
}
}.toString()

json = KotlinInside.getInstance().httpInterface.get(Request.redirectUrl(url), Request.getDefaultOption())!!
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ class ArticleWrite internal constructor(
option
)!!.index(0)


return WriteResult(
result = json.get("result").asBoolean(),
articleId = json.get("cause").asNullableInteger(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ class AsyncArticleDelete @JvmOverloads constructor(
articleDelete.delete()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ class AsyncArticleHitUpvote(
articleHitUpvote.upvote()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ class AsyncArticleList @JvmOverloads constructor(
articleList.getGallList()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ class AsyncArticleModify(
articleModify.modify(article, fcmToken)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ class AsyncArticleRead @JvmOverloads constructor(
articleRead.getViewMain()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ class AsyncArticleReport(
articleReport.getLink()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ class AsyncArticleVote(
articleVote.downvote()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ class AsyncArticleWrite @JvmOverloads constructor(
articleWrite.write()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ class AsyncCommentDelete @JvmOverloads constructor(
commentDelete.delete()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ class AsyncCommentRead(
commentRead.request()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ class AsyncCommentWrite @JvmOverloads constructor(
commentWrite.reply(commentId)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ class AsyncDCConBuy(
dcConBuy.buy()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ class AsyncDCConDetail(
dcConDetail.request()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ class AsyncDCConList(
dcConList.request()
}
}
}
}
Loading

0 comments on commit 9362a97

Please sign in to comment.