{"id":44714088,"url":"https://github.com/sasa-nori/common-ktx","last_synced_at":"2026-02-15T13:16:03.313Z","repository":{"id":41874963,"uuid":"245430303","full_name":"sasa-nori/common-ktx","owner":"sasa-nori","description":"Android Ktx Library","archived":false,"fork":false,"pushed_at":"2025-03-26T05:58:13.000Z","size":1254,"stargazers_count":5,"open_issues_count":4,"forks_count":4,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-03-26T06:29:39.042Z","etag":null,"topics":["android","kotlin","ktx","library"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sasa-nori.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-06T13:44:15.000Z","updated_at":"2025-03-26T05:49:35.000Z","dependencies_parsed_at":"2024-01-15T01:46:29.268Z","dependency_job_id":"0d55be28-ca29-40bc-9de7-51e3d8710307","html_url":"https://github.com/sasa-nori/common-ktx","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/sasa-nori/common-ktx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sasa-nori%2Fcommon-ktx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sasa-nori%2Fcommon-ktx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sasa-nori%2Fcommon-ktx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sasa-nori%2Fcommon-ktx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sasa-nori","download_url":"https://codeload.github.com/sasa-nori/common-ktx/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sasa-nori%2Fcommon-ktx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29479433,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T11:35:25.641Z","status":"ssl_error","status_checked_at":"2026-02-15T11:34:57.128Z","response_time":118,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","kotlin","ktx","library"],"created_at":"2026-02-15T13:15:59.138Z","updated_at":"2026-02-15T13:16:03.308Z","avatar_url":"https://github.com/sasa-nori.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CommonKtx\n\n[![](https://jitpack.io/v/sasa-nori/common-ktx.svg)](https://jitpack.io/#sasa-nori/common-ktx)\n\n## Prerequisites\n\n* must minSdkVersion is  23 over\n\n## install\n\n```build.gradle\nallprojects {\n    repositories {\n        google()\n        mavenCentral()\n        \n        maven { url 'https://jitpack.io' } // add\n        maven { url \"https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven\" }  // add\n    }\n}\n\n```\n```app/build.gradle\ndependencies {\n    implementation \"com.github.sasa-nori:common-ktx:$latestVersion\"\n}\n```\n\n## Kdoc\n\n[Document](https://sasa-nori.github.io/common-ktx/)\n\n## Example\n\n[CommonKtx-Example](https://github.com/sasa-nori/CommonKtx-Example)\n\n## Tips\n\n### Object to JSON String\n\nAdd Moshi codegen\n\n```\nkapt \"com.squareup.moshi:moshi-kotlin-codegen:1.9.2\"\n```\n\nAdded `@JsonClass(generateAdapter = true)` to Class top\n\n```\n@JsonClass(generateAdapter = true)\ndata class Test(val first: String, val second: String)\n```\n\n```\nTest(\"first\", \"second\").toJsonString()\n```\n\n## Usage\n\n### SingleClick\n\ndefault timeout is 500ms\n\n```\nbutton.setOnSingleClickListener {\n    // run\n}\n```\n\nto custom\n\n```\nbutton.setOnSingleClickListener(300, { view-\u003e\n     // run\n})\n```\n\n\n### Check RuntimePermission\n\n```\nval permissions = arrayOf(\n    Manifest.permission.READ_EXTERNAL_STORAGE,\n    Manifest.permission.WRITE_EXTERNAL_STORAGE\n)\nif (hasPermission(permissions)) {\n    // run\n} else {\n    requestPermissions(permissions, REQUEST_CODE)\n}\n```\n\n### SharedPreferences\n\n```\nclass Preferences(context: Context) : SharedPrefDelegated(context) {\n    var isFirstLaunch: Boolean by pref(default = true)\n}\n```\n\n```\nval pref = Preferences(this)\nval isFirstLaunch = when (pref.isFirstLaunch) {\n    true -\u003e {\n        pref.isFirstLaunch = false\n        true\n    }\n    else -\u003e false\n}\n```\n\n### LiveData (One Shot Event)\n\n \n- ViewModel\n\n```\nclass TestViewModel() : ViewModel {\n    private var testData = MutableLiveData\u003cEvent\u003cString\u003e\u003e()\n\n    var testDataLiveData: LiveData\u003cEvent\u003cString\u003e\u003e() = testData\n\n    fun postData() {\n        testData.postValue(Event(\"test\"))\n    }\n\n}\n\n```\n\n- Activity\n\n```\nclass TestActivity(): Activity {\n\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n\n        testViewModel.testDataLiveData.observer(this, EventObserver {\n            Timber.d(it)\n        })\n    }\n}\n\n```\n\n### SoundPool\n\n```\nclass TestActivity(): Activity {\n\n    private var soundPathList: MutableList\u003cInt\u003e = mutableListOf()\n\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n        setContentView(layout.activity_main)\n        setSupportActionBar(toolbar)\n\n        fab.setOnSingleClickListener { view -\u003e\n            view?.let {\n                SoundPool.play(soundPathList.first())\n            }\n        }\n\n        lifecycleScope.launch {\n            soundPathList = loadSoundPool(mutableListOf(R.raw.one))\n        }\n    }\n\n}\n```\n\n### LiveData (Unit Test)\n\nsee [MainViewModelTest.kt](https://github.com/sasa-nori/common-ktx/blob/develop/example/src/test/java/net/newstyleservice/example/MainViewModelTest.kt)\n\n```\n    @Test\n    fun requestApi() = runBlocking {\n        // given\n        val answer = mutableListOf(Shikure(0, \"\", \"\", 0, 0))\n        `when`(apiService.getShikure()).thenReturn(answer)\n        val liveDataTestObserver = target.getShikureList().testObserver()\n\n        // when\n        target.requestApi(apiService)\n\n        // than\n        val result = liveDataTestObserver.observedValues.first()\n        assertThat(result?.getContentIfNotHandled()).isEqualTo(answer)\n    }\n```\n\n# Dependency\n\n* [Android X](https://developer.android.com/jetpack/androidx)\n* [Android Support](https://developer.android.com/topic/libraries/support-library)\n* [Moshi 1.9.2](https://github.com/square/moshi)\n* [OkHttp 3.14.7](https://github.com/square/okhttp/)\n* [Retrofit 2.8.1](https://github.com/square/retrofit)\n* [Kotlin Contributions 1.3.5](https://github.com/Kotlin/kotlinx.coroutines)\n\n# Licence\n\n```\nCopyright 2020 ss-n.app\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsasa-nori%2Fcommon-ktx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsasa-nori%2Fcommon-ktx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsasa-nori%2Fcommon-ktx/lists"}