vijayrawatsan / android-json-form-wizard

Android Material Json Form Wizard is a library for creating beautiful form based wizards within your app just by defining json in a particular format.
MIT License
356 stars 98 forks source link

Keyboard error #17

Closed NilakArgento closed 9 years ago

NilakArgento commented 9 years ago

When i try to type something i have app crash In logs :

java.lang.ClassCastException: android.support.v7.internal.view.ContextThemeWrapper cannot be cast to com.vijay.jsonwizard.interfaces.JsonApi
            at com.vijay.jsonwizard.customviews.GenericTextWatcher.afterTextChanged(GenericTextWatcher.java:37)
            at android.widget.TextView.sendAfterTextChanged(TextView.java:7247)
            at android.widget.TextView$ChangeWatcher.afterTextChanged(TextView.java:8891)
            at android.text.SpannableStringBuilder.sendAfterTextChanged(SpannableStringBuilder.java:970)
            at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:497)
            at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:435)
            at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:30)
            at android.text.method.QwertyKeyListener.onKeyDown(QwertyKeyListener.java:222)
            at android.text.method.TextKeyListener.onKeyDown(TextKeyListener.java:136)
            at android.widget.TextView.doKeyDown(TextView.java:5385)
            at android.widget.TextView.onKeyDown(TextView.java:5204)
            at android.view.KeyEvent.dispatch(KeyEvent.java:2609)
            at android.view.View.dispatchKeyEvent(View.java:7205)
            at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
            at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
            at android.widget.ScrollView.dispatchKeyEvent(ScrollView.java:353)
            at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
            at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
            at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
            at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
            at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
            at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
            at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
            at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1920)
            at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1395)
            at android.app.Activity.dispatchKeyEvent(Activity.java:2370)
            at android.support.v7.internal.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:49)
            at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.dispatchKeyEvent(AppCompatDelegateImplBase.java:258)
            at android.support.v7.internal.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:49)
            at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1847)
            at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3701)
            at android.view.ViewRootImpl.handleImeFinishedEvent(ViewRootImpl.java:3651)
            at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:2818)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5041)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
            at dalvik.system.NativeStart.main(Native Method)
NilakArgento commented 9 years ago

I'm using


    compile 'com.github.vijayrawatsan:android-json-form-wizard:+'
vijayrawatsan commented 9 years ago

Can you try latest dependency repositories { maven { url "https://jitpack.io" } } dependencies { compile 'com.github.vijayrawatsan:android-json-form-wizard:1.1.1-SNAPSHOT' }

NilakArgento commented 9 years ago

Doesn't work )

NilakArgento commented 9 years ago

What can be the problem ?!

vijayrawatsan commented 9 years ago

You tried to run the demo and it didnt work?

NilakArgento commented 9 years ago

Demo works fine.

My build

apply plugin: 'com.android.application'

android {
    signingConfigs {
    }
    compileSdkVersion 21
    buildToolsVersion "21.1.2"
    defaultConfig {
        applicationId 'us.ethnicmedia.sevendays'
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 12
        versionName '2.1'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}
repositories {
    maven { url "https://jitpack.io" }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.android.support:cardview-v7:21.+'
    compile 'com.android.support:recyclerview-v7:21.+'
    compile('com.mikepenz.materialdrawer:library:2.0.2@aar') {
        transitive = true
    }
    compile 'com.etsy.android.grid:library:1.0.5'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
    compile files('libs/volley.jar')
    compile 'com.github.vijayrawatsan:android-json-form-wizard:1.1.1-SNAPSHOT'

}
vijayrawatsan commented 9 years ago

Possibly tintContextWrapper.getBaseContext() is returning a ContextWrapper somehow for your case instead of activity(which implements JsonApi)

Change below line api = (JsonApi) tintContextWrapper.getBaseContext();

to

Object obj = tintContextWrapper.getBaseContext(); if( obj instanceof JsonApi) { api= (JsonApi)obj; } if (obj instanceof ContextThemeWrapper) { api = (JsonApi) ((ContextThemeWrapper)obj).getBaseContext(); }

vijayrawatsan commented 9 years ago

@NilakArgento I think this is fixed for you. It would be nice if you could send a pr for the above code.