You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Kyaml(
activity =this,
yamlFileNameInAssets ="not_found.yaml",
onEachItem = { key, value ->// Error loading YAML file.// contents in onEachItem// will never be called.
},
onError = {
when (it) {
isIllegalArgumentException->// "Could not open not_found.yaml"
it.message
else-> it.message
}
}
)
"not_found.yaml"does not exist in the project.
Syntax
Usage is simply calling Kyaml() passing up to four arguments (3 required and 1 optional) into its constructor. There are 2 public constructors that vary only by 1 argument:
activity - Activity / Required
Active Activity.
yamlResourceIdInRaw or yamlFileNameInAssets - Only 1 Required
yamlResourceIdInRaw - Int (@RawRes) / Required
YAML file located in /res/raw/ to consume.
OR
yamlFileNameInAssets - String / Required
YAML file name located in /assets/ to consume. Optionally the extension can be included with the file name.
onEachItem - (String, Any?) -> Unit / Required
Called on every item parsed from the YAML file. Included will be the key and value. The key is always of type String. The value will be of the detected type when parsed. This may include Int, Long, Float, Double, Boolean, String, or null. The value may also be a List of any of these types.
onError - (Exception) -> Unit / Optional
Any exception caught within Kyaml will stop the process and pass the exception here. An IllegalArgumentException will be thrown if yamlFileNameInAssets contains a file name that could not be found. It is not known if any other exception will be thrown when using Kyaml.
Installation
Install with JitPack
Add JitPack to your project's root build.gradle at the end of repositories:
In the build.gradle of the module(s) you wish to use Kyaml with, add the following to dependencies:
dependencies {
// Required: Installs the .aar without any documentation.
implementation 'com.github.digidemic:kyaml:1.1.0'// Optional: Displays documentation while writing coding.
implementation 'com.github.digidemic:kyaml:1.1.0:javadoc'// Optional: Displays documentation (more comprehensive than javadoc in some cases) and uncompiled code when stepping into library.
implementation 'com.github.digidemic:kyaml:1.1.0:sources'
}
MINOR version - Functionality added in a backwards-compatible manner.
PATCH version - Backwards-compatible bug fixes.
License
Kyaml created by Adam Steinberg of DIGIDEMIC, LLC
Copyright 2024 DIGIDEMIC, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.