GithubHelp home page GithubHelp logo

mflisar / materialpreferences Goto Github PK

View Code? Open in Web Editor NEW
20.0 3.0 4.0 1.07 MB

Preference via delegates (Flow, Coroutines) + JetPack DataStore Storage + DSL for RecyclerView based preference screens

License: Apache License 2.0

Kotlin 100.00%
preference-screen dsl jetpack-datastore

materialpreferences's People

Contributors

amrg101 avatar mflisar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

materialpreferences's Issues

crash when upgrade to v1.0.4

opened settings screen and boom runtime crash at my face

java.lang.NullPointerException: Attempt to invoke interface method 'int java.lang.CharSequence.length()' on a null object reference
                                                            	at android.text.StaticLayout.<init>(StaticLayout.java:455)
                                                            	at androidx.appcompat.widget.SwitchCompat.makeLayout(SwitchCompat.java:995)
                                                            	at androidx.appcompat.widget.SwitchCompat.onMeasure(SwitchCompat.java:916)
                                                            	at android.view.View.measure(View.java:25833)
                                                            	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6980)
                                                            	at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552)
                                                            	at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1204)
                                                            	at android.widget.LinearLayout.onMeasure(LinearLayout.java:723)
                                                            	at android.view.View.measure(View.java:25833)
                                                              .......

log of catched exception

java.lang.UnsupportedOperationException: Failed to resolve attribute at index 0: TypedValue{t=0x2/d=0x7f040107 a=-1}
                                                            	at android.content.res.TypedArray.getColor(TypedArray.java:529)
                                                            	at androidx.core.content.res.ColorStateListInflaterCompat.inflate(ColorStateListInflaterCompat.java:160)
                                                            	at androidx.core.content.res.ColorStateListInflaterCompat.createFromXmlInner(ColorStateListInflaterCompat.java:125)
                                                            	at androidx.core.content.res.ColorStateListInflaterCompat.createFromXml(ColorStateListInflaterCompat.java:104)
                                                            	at androidx.core.content.res.ResourcesCompat.inflateColorStateList(ResourcesCompat.java:262)
                                                            	at androidx.core.content.res.ResourcesCompat.getColorStateList(ResourcesCompat.java:236)
                                                            	at androidx.core.content.ContextCompat.getColorStateList(ContextCompat.java:558)
                                                            	at androidx.appcompat.content.res.AppCompatResources.getColorStateList(AppCompatResources.java:48)
                                                            	at androidx.appcompat.widget.TintTypedArray.getColorStateList(TintTypedArray.java:179)
                                                            	at com.google.android.material.materialswitch.MaterialSwitch.<init>(MaterialSwitch.java:101)
                                                            	at com.google.android.material.materialswitch.MaterialSwitch.<init>(MaterialSwitch.java:72)
                                                            	at java.lang.reflect.Constructor.newInstance0(Native Method)
                                                            	at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
                                                            	at android.view.LayoutInflater.createView(LayoutInflater.java:858)
                                                            	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1010)
                                                            	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965)
                                                            	at android.view.LayoutInflater.inflate(LayoutInflater.java:663)
                                                            	at android.view.LayoutInflater.inflate(LayoutInflater.java:538)
                                                            	at com.michaelflisar.materialpreferences.preferencescreen.bool.databinding.WidgetSwitchBinding.inflate(WidgetSwitchBinding.java:42)
                                                            	at com.michaelflisar.materialpreferences.preferencescreen.bool.switches.SwitchViewHolder.createSubBinding(SwitchViewHolder.kt:23)
                                                            	at com.michaelflisar.materialpreferences.preferencescreen.bool.switches.SwitchViewHolder.createSubBinding(SwitchViewHolder.kt:12)
                                                            	at com.michaelflisar.materialpreferences.preferencescreen.recyclerview.viewholders.base.BaseViewHolderWithWidget$subBinding$2.invoke(BaseViewHolderWithWidget.kt:31)
                                                            	at com.michaelflisar.materialpreferences.preferencescreen.recyclerview.viewholders.base.BaseViewHolderWithWidget$subBinding$2.invoke(BaseViewHolderWithWidget.kt:31)
                                                            	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
                                                            	at com.michaelflisar.materialpreferences.preferencescreen.recyclerview.viewholders.base.BaseViewHolderWithWidget.getSubBinding(BaseViewHolderWithWidget.kt:31)
                                                            	at com.michaelflisar.materialpreferences.preferencescreen.bool.switches.SwitchViewHolder.bindWidget(SwitchViewHolder.kt:26)
                                                            	at com.michaelflisar.materialpreferences.preferencescreen.bool.switches.SwitchViewHolder.bindWidget(SwitchViewHolder.kt:12)
                                                            	at com.michaelflisar.materialpreferences.preferencescreen.recyclerview.viewholders.base.BaseViewHolderWithWidget.rebind(BaseViewHolderWithWidget.kt:92)
                                                            	at com.michaelflisar.materialpreferences.preferencescreen.recyclerview.viewholders.base.BaseViewHolderWithWidget$bind$1$1.invokeSuspend(BaseViewHolderWithWidget.kt:70)

Unresolved reference IScreenCreator when using screen module

I am following the example with the built-in settings activity to build a quick prototype, but I am surely missing something pretty basic.

Here I get these errors on Android Studio, Unresolved reference: IScreenCreator and No 'Parcelable' supertype for ScreenCreator itself.

object UserSettingsModel : SettingsModel(DataStoreStorage(name = "user")) {

    // main data types
    val baseVideoUri by stringPref("rtsp://10.0.0.10:8554")
}

@Parcelize
object ScreenCreator : SettingsActivity.IScreenCreator {
    override fun createScreen(
        activity: AppCompatActivity,
        savedInstanceState: Bundle?,
        updateTitle: (title: String) -> Unit
    ): PreferenceScreen {
        return screen {
            state = savedInstanceState
            input(UserSettingsModel.baseVideoUri) {
                title = "Video URL".asText()
            }

        }
    }
}

class MainActivity : AppCompatActivity() {
 (rest of the activity)

I think I am just using it wrong, I've been looking at the example app but I didn't find anything.
In any case, thanks a lot for the library, it seems to save a lot of time when dealing with prefs. The automagic settings activity would just be the icing on the cake.

settings items aren't displayed.

I investigated it and found the source of the problem, fixed it myself until I found this good-looking comment, uncomment it and bug was fixed.


the only way to update rv adapter was to add a visibilityDependsOn with Dependency object which was triggering updateCurrentFilteredItems(true) that updated the adapter list, also I found out that the object is leaking when in fragment, so I hope you investigate and fix it.

Keep up the good work!

memory leak when switch app theme

when switching between fragment no leak as before but got 3 leaks if I switched app theme in the settings fragment
as the parent activity is recreated and the pervious instance is not cleared as settingsview is holding a reference to its context.
and i really suggest that you setup a settings fragment in the test app so you catch errors and leaks that will only show in fragment as
it has some differences than activity.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.