Skip to content

Commit

Permalink
refactor(CodeEditor): rewrite in Kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
timschneeb committed Mar 8, 2023
1 parent 4813b1b commit 478731d
Show file tree
Hide file tree
Showing 17 changed files with 1,157 additions and 1,295 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import me.timschneeberger.rootlessjamesdsp.editor.syntax.Function

class CustomCodeViewAdapter(
context: Context,
codes: List<Code?>,
) : CodeViewAdapter(context, R.layout.item_editor_autocomplete, 0, codes) {
codes: List<Code>,
) : CodeViewAdapter(context, R.layout.item_editor_autocomplete, 0, codes.toMutableList()) {

private val layoutInflater = LayoutInflater.from(context)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ package me.timschneeberger.rootlessjamesdsp.editor.syntax

import com.amrdeveloper.codeview.Code

class Constant(private val title: String?, private val prefix: String? = title) : Code {
override fun getCodeTitle(): String? { return title }
override fun getCodePrefix(): String? { return prefix }
override fun getCodeBody(): String? { return prefix }
class Constant(private val title: String, private val prefix: String = title) : Code {
override val codeTitle: String
get() = title
override val codePrefix: String
get() = prefix
override val codeBody: String
get() = prefix
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ package me.timschneeberger.rootlessjamesdsp.editor.syntax

import com.amrdeveloper.codeview.Code

class Function(private val title: String?, private val prefix: String? = title) : Code {
override fun getCodeTitle(): String? { return title }
override fun getCodePrefix(): String? { return prefix }
override fun getCodeBody(): String? { return prefix }
class Function(private val title: String, private val prefix: String = title) : Code {
override val codeTitle: String
get() = title
override val codePrefix: String
get() = prefix
override val codeBody: String
get() = prefix
}
10 changes: 3 additions & 7 deletions codeview/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.library'
apply plugin: 'org.jetbrains.kotlin.android'

android {
compileSdkVersion 31
compileSdk 33

defaultConfig {
minSdkVersion 15
targetSdkVersion 31
targetSdkVersion 33

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}

Expand All @@ -21,9 +21,5 @@ android {
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.6.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,26 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.amrdeveloper.codeview;
package com.amrdeveloper.codeview

/**
* Interface to represent a different types of code such as keywords or snippets
*
* @since 1.1.0
*/
public interface Code {

interface Code {
/**
* @return The title of code
*/
String getCodeTitle();
val codeTitle: String

/**
* @return The prefix value of the code
*/
String getCodePrefix();
val codePrefix: String

/**
* @return The body of the code to insert it
*/
String getCodeBody();
}
val codeBody: String
}
Loading

0 comments on commit 478731d

Please sign in to comment.