├── .idea ├── .name ├── .gitignore ├── compiler.xml ├── vcs.xml ├── misc.xml └── gradle.xml ├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── themes.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── drawable │ │ │ │ ├── rect_4dp_solid.xml │ │ │ │ ├── rect_4dp.xml │ │ │ │ ├── ic_baseline_send_100.xml │ │ │ │ ├── ic_baseline_arrow_back_100.xml │ │ │ │ ├── ic_baseline_cleaning_services_100.xml │ │ │ │ └── ic_launcher_background.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── layout │ │ │ │ ├── activity_main.xml │ │ │ │ ├── holder_talk_answer.xml │ │ │ │ ├── holder_talk_question.xml │ │ │ │ ├── fragment_main.xml │ │ │ │ ├── fragment_write.xml │ │ │ │ ├── fragment_answer.xml │ │ │ │ └── include_header.xml │ │ │ ├── xml │ │ │ │ ├── backup_rules.xml │ │ │ │ └── data_extraction_rules.xml │ │ │ ├── values-night │ │ │ │ └── themes.xml │ │ │ └── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── litesnap │ │ │ │ └── open │ │ │ │ └── rwkv │ │ │ │ ├── GptTokenizer.java │ │ │ │ ├── Atts.java │ │ │ │ ├── PathManager.java │ │ │ │ ├── App.java │ │ │ │ ├── MyRunnable.java │ │ │ │ ├── HexUtils.java │ │ │ │ ├── Vocab.java │ │ │ │ ├── GptModel.java │ │ │ │ ├── Talk.java │ │ │ │ ├── PreferencesManager.java │ │ │ │ ├── MainActivity.java │ │ │ │ ├── Pair.java │ │ │ │ ├── StringUtils.java │ │ │ │ ├── FileUtils.java │ │ │ │ ├── MyAdapter.java │ │ │ │ ├── WorldTokenizerImp.java │ │ │ │ ├── MainFragment.java │ │ │ │ ├── PreferencesUtils.java │ │ │ │ ├── SampleLogits.java │ │ │ │ ├── GptTokenizerImp.java │ │ │ │ ├── WriteFragment.java │ │ │ │ ├── GPTByteUtils.java │ │ │ │ ├── OnnxModelImp.java │ │ │ │ └── TalkFragment.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── litesnap │ │ │ └── open │ │ │ └── rwkv │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── litesnap │ │ └── open │ │ └── rwkv │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── 5.jpg ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── settings.gradle ├── gradle.properties ├── README.md ├── gradlew.bat └── gradlew /.idea/.name: -------------------------------------------------------------------------------- 1 | RWKV-Android -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTMIDGO/RWKV-Android/HEAD/5.jpg -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | RWKV-Android 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTMIDGO/RWKV-Android/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTMIDGO/RWKV-Android/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTMIDGO/RWKV-Android/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTMIDGO/RWKV-Android/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTMIDGO/RWKV-Android/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTMIDGO/RWKV-Android/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTMIDGO/RWKV-Android/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTMIDGO/RWKV-Android/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTMIDGO/RWKV-Android/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTMIDGO/RWKV-Android/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTMIDGO/RWKV-Android/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/rect_4dp_solid.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/rect_4dp.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Jun 08 12:55:17 CST 2023 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /app/src/main/java/com/litesnap/open/rwkv/GptTokenizer.java: -------------------------------------------------------------------------------- 1 | package com.litesnap.open.rwkv; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by ZTMIDGO 2022/9/9 7 | */ 8 | public abstract interface GptTokenizer { 9 | List encode(String text); 10 | String decode(List tokens); 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/java/com/litesnap/open/rwkv/Atts.java: -------------------------------------------------------------------------------- 1 | package com.litesnap.open.rwkv; 2 | 3 | /** 4 | * Created by ZTMIDGO 2023/6/20 5 | */ 6 | public interface Atts { 7 | String TOP_K = "top_k"; 8 | String LEN = "len"; 9 | String P1 = "p1"; 10 | String P2 = "p2"; 11 | String TEMP = "temp"; 12 | String TOP_P = "top_p"; 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/litesnap/open/rwkv/PathManager.java: -------------------------------------------------------------------------------- 1 | package com.litesnap.open.rwkv; 2 | 3 | import android.content.Context; 4 | 5 | /** 6 | * Created by ZTMIDGO 2023/6/8 7 | */ 8 | public class PathManager { 9 | public static String getModelPath(Context context){ 10 | return context.getFilesDir().getAbsolutePath() + "/model"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/litesnap/open/rwkv/App.java: -------------------------------------------------------------------------------- 1 | package com.litesnap.open.rwkv; 2 | 3 | import android.app.Application; 4 | 5 | /** 6 | * Created by ZTMIDGO 2023/6/20 7 | */ 8 | public class App extends Application { 9 | 10 | @Override 11 | public void onCreate() { 12 | super.onCreate(); 13 | PreferencesUtils.init(this); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/java/com/litesnap/open/rwkv/MyRunnable.java: -------------------------------------------------------------------------------- 1 | package com.litesnap.open.rwkv; 2 | 3 | public abstract class MyRunnable implements Runnable { 4 | private boolean isCancel; 5 | 6 | public boolean isCancel() { 7 | return isCancel; 8 | } 9 | 10 | public void setCancel(boolean cancel) { 11 | isCancel = cancel; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_baseline_send_100.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | google() 5 | mavenCentral() 6 | } 7 | } 8 | dependencyResolutionManagement { 9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 10 | repositories { 11 | google() 12 | mavenCentral() 13 | } 14 | } 15 | rootProject.name = "RWKV-Android" 16 | include ':app' 17 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_baseline_arrow_back_100.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | -------------------------------------------------------------------------------- /app/src/test/java/com/litesnap/open/rwkv/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.litesnap.open.rwkv; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/java/com/litesnap/open/rwkv/HexUtils.java: -------------------------------------------------------------------------------- 1 | package com.litesnap.open.rwkv; 2 | 3 | /** 4 | * Created by ZTMIDGO 2023/7/21 5 | */ 6 | public class HexUtils { 7 | public static String charsToHex(char[] chars){ 8 | StringBuilder sb = new StringBuilder(); 9 | for (int i = 0; i < chars.length; i++) { 10 | String hex = Integer.toHexString(chars[i]); 11 | if (hex.length() % 2 != 0) hex = 0 + hex; 12 | sb.append(hex); 13 | } 14 | return sb.toString(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/res/xml/backup_rules.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/litesnap/open/rwkv/Vocab.java: -------------------------------------------------------------------------------- 1 | package com.litesnap.open.rwkv; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * Created by ZTMIDGO 2023/6/8 7 | */ 8 | public class Vocab { 9 | private Inner model; 10 | 11 | public Inner getModel() { 12 | return model; 13 | } 14 | 15 | public class Inner{ 16 | private Map vocab; 17 | private String[] merges; 18 | 19 | public Map getVocab() { 20 | return vocab; 21 | } 22 | 23 | public String[] getMerges() { 24 | return merges; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_baseline_cleaning_services_100.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/xml/data_extraction_rules.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 12 | 13 | 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/litesnap/open/rwkv/GptModel.java: -------------------------------------------------------------------------------- 1 | package com.litesnap.open.rwkv; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by ZTMIDGO 2022/9/9 7 | */ 8 | public interface GptModel { 9 | void generate(List arrays, int maxCount, Callback callback); 10 | int sample(List indexes, List probs); 11 | void close(); 12 | void cancel(); 13 | void setTop(float temp, float topp, int topk); 14 | void setPenalty(float v1, float v2); 15 | void clean(); 16 | boolean isRunning(); 17 | interface Callback{ 18 | void callback(int token, int index, int maxCount, boolean isEnd); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/litesnap/open/rwkv/Talk.java: -------------------------------------------------------------------------------- 1 | package com.litesnap.open.rwkv; 2 | 3 | /** 4 | * Created by ZTMIDGO 2023/6/20 5 | */ 6 | public class Talk { 7 | public static final int TYPE_QUESTION = 0; 8 | public static final int TYPE_ANSWER = 1; 9 | 10 | private int type; 11 | private String text; 12 | 13 | public Talk(int type, String text) { 14 | this.type = type; 15 | this.text = text; 16 | } 17 | 18 | public int getType() { 19 | return type; 20 | } 21 | 22 | public void setType(int type) { 23 | this.type = type; 24 | } 25 | 26 | public String getText() { 27 | return text; 28 | } 29 | 30 | public void setText(String text) { 31 | this.text = text; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/main/java/com/litesnap/open/rwkv/PreferencesManager.java: -------------------------------------------------------------------------------- 1 | package com.litesnap.open.rwkv; 2 | 3 | /** 4 | * Created by ZTMIDGO 2023/6/20 5 | */ 6 | public class PreferencesManager { 7 | public static int getTopK(){ 8 | return PreferencesUtils.getInt(Atts.TOP_K, 0); 9 | } 10 | 11 | public static int getLen(){ 12 | return PreferencesUtils.getInt(Atts.LEN, 512); 13 | } 14 | 15 | public static float getP1(){ 16 | return PreferencesUtils.getFloat(Atts.P1, 0.7f); 17 | } 18 | 19 | public static float getP2(){ 20 | return PreferencesUtils.getFloat(Atts.P2, 0.4f); 21 | } 22 | 23 | public static float getTemp(){ 24 | return PreferencesUtils.getFloat(Atts.TEMP, 1.0f); 25 | } 26 | 27 | public static float getTopp(){ 28 | return PreferencesUtils.getFloat(Atts.TOP_P, 0.1f); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/main/java/com/litesnap/open/rwkv/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.litesnap.open.rwkv; 2 | 3 | import android.app.ProgressDialog; 4 | import android.os.Bundle; 5 | import android.view.View; 6 | import android.widget.EditText; 7 | import android.widget.TextView; 8 | 9 | import androidx.annotation.Nullable; 10 | import androidx.appcompat.app.AppCompatActivity; 11 | 12 | import java.io.File; 13 | import java.util.concurrent.ExecutorService; 14 | import java.util.concurrent.Executors; 15 | 16 | import ai.onnxruntime.OrtSession; 17 | 18 | public class MainActivity extends AppCompatActivity { 19 | @Override 20 | protected void onCreate(@Nullable Bundle savedInstanceState) { 21 | super.onCreate(savedInstanceState); 22 | setContentView(R.layout.activity_main); 23 | getSupportFragmentManager().beginTransaction().replace(R.id.container, MainFragment.newInstance()).commit(); 24 | } 25 | } -------------------------------------------------------------------------------- /app/src/androidTest/java/com/litesnap/open/rwkv/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.litesnap.open.rwkv; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.platform.app.InstrumentationRegistry; 6 | import androidx.test.ext.junit.runners.AndroidJUnit4; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 24 | assertEquals("com.litesnap.open.rwkv", appContext.getPackageName()); 25 | } 26 | } -------------------------------------------------------------------------------- /app/src/main/java/com/litesnap/open/rwkv/Pair.java: -------------------------------------------------------------------------------- 1 | package com.litesnap.open.rwkv; 2 | 3 | import java.util.Objects; 4 | 5 | /** 6 | * Created by ZTMIDGO 2022/9/9 7 | */ 8 | public class Pair { 9 | public A first; 10 | public B second; 11 | 12 | public Pair(A first, B second) { 13 | this.first = first; 14 | this.second = second; 15 | } 16 | 17 | @Override 18 | public boolean equals(Object o) { 19 | if (this == o) return true; 20 | if (o == null || getClass() != o.getClass()) return false; 21 | Pair pair = (Pair) o; 22 | return pair.first.equals(first) && pair.second.equals(second); 23 | } 24 | 25 | @Override 26 | public int hashCode() { 27 | return Objects.hash(first, second); 28 | } 29 | 30 | @Override 31 | public String toString() { 32 | return String.format("("+ first+", "+ second+")"); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/res/layout/holder_talk_answer.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/layout/holder_talk_question.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 24 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/litesnap/open/rwkv/StringUtils.java: -------------------------------------------------------------------------------- 1 | package com.litesnap.open.rwkv; 2 | 3 | import android.text.TextUtils; 4 | 5 | import java.math.BigDecimal; 6 | import java.math.RoundingMode; 7 | 8 | public class StringUtils { 9 | public static boolean isEmpty(String...strings){ 10 | for (String string : strings){ 11 | if (TextUtils.isEmpty(string)){ 12 | return true; 13 | } 14 | } 15 | 16 | return false; 17 | } 18 | 19 | public static String[] toArrays(String text){ 20 | int[] codePoints = text.codePoints().toArray(); 21 | String[] words = new String[codePoints.length]; 22 | for (int i = 0; i < codePoints.length; i++){ 23 | int code = codePoints[i]; 24 | words[i] = new String(Character.toChars(code)); 25 | } 26 | return words; 27 | } 28 | 29 | public static double round(double value, int places) { 30 | if (places < 0) { 31 | throw new IllegalArgumentException(); 32 | } 33 | BigDecimal bd = new BigDecimal(value); 34 | bd = bd.setScale(places, RoundingMode.HALF_UP); 35 | return bd.doubleValue(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx8048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Enables namespacing of each library's R class so that its R class includes only the 19 | # resources declared in the library itself and none from the library's dependencies, 20 | # thereby reducing the size of the R class for that library 21 | android.nonTransitiveRClass=true -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 |