We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KOTLIN:
package com.example.libkeyboard2 import android.content.Intent import android.net.Uri import android.support.v7.app.AppCompatActivity import android.os.Bundle import android.text.method.ScrollingMovementMethod import android.view.View import android.view.WindowManager import android.widget.LinearLayout import android.widget.TextView import com.example.libjson.LibJSON import com.google.gson.* import com.avocarrot.json2view.DynamicView import com.avocarrot.json2view.DynamicViewId import kotlinx.android.synthetic.main.activity_main.view.* import org.json.JSONObject class MainActivity : AppCompatActivity() , View.OnClickListener{ override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // setContentView(R.layout.x) // setContentView(R.layout.activity_main) // val textView = findViewById(R.id.text_view) as TextView // textView.setMovementMethod(ScrollingMovementMethod()) // LibJSON().Test_Lib { x -> textView.setText(textView.text.toString() + x) } // R.layout.activity_main as JSON /* // create core view val VIEW = LibJSON() // create sub view val VIEW_TEXT = LibJSON() // create properties val VIEW_properties1 = LibJSON() val VIEW_properties2 = LibJSON() val VIEW_properties3 = LibJSON() val VIEW_TEXT_properties1 = LibJSON() val VIEW_TEXT_properties2 = LibJSON() val VIEW_TEXT_properties3 = LibJSON() val VIEW_TEXT_properties4 = LibJSON() // assign properties VIEW_properties1.add_value_as_vararg("name", "layout_hight", "type", "dimen", "value", "match_parent") VIEW_properties2.add_value_as_vararg("name", "layout_width", "type", "dimen", "value", "match_parent") VIEW_properties3.add_value_as_vararg("name", "orientation", "type", "string", "value", "vertical") VIEW_TEXT_properties1.add_value_as_vararg("name", "layout_width", "type", "dimen", "value", "match_parent") VIEW_TEXT_properties2.add_value_as_vararg("name", "layout_margin", "type", "dimen", "value", "16p") VIEW_TEXT_properties3.add_value_as_vararg("name", "scrollbars", "type", "string", "value", "vertical") VIEW_TEXT_properties4.add_value_as_vararg("name", "text", "type", "string", "value", "") // assign core view VIEW.add_value_as_vararg("widget", "LinearLayout", "properties") VIEW.add_array(VIEW_properties1, VIEW_properties2, VIEW_properties3) VIEW.add_name("views") VIEW.add_array(VIEW_TEXT) // assign core sub view VIEW_TEXT.add_value_as_vararg("widget", "text_view", "properties") VIEW_TEXT.add_array(VIEW_TEXT_properties1, VIEW_TEXT_properties2, VIEW_TEXT_properties3, VIEW_TEXT_properties4) VIEW_TEXT.add_name("views") VIEW_TEXT.add_array() */ val DEMO = JSONObject(""" { "widget": "android.widget.RelativeLayout", "properties": [{ "name": "background", "type": "color", "value": "#919191" }, { "name": "layout_width", "type": "dimen", "value": "match_parent" }, { "name": "layout_height", "type": "dimen", "value": "match_parent" }, { "name": "padding", "type": "dimen", "value": "10dp" }], "views": [{ "widget": "android.widget.LinearLayout", "properties": [{ "name": "layout_width", "type": "dimen", "value": "90%" }, { "name": "layout_height", "type": "dimen", "value": "wrap_content" }, { "name": "background", "type": "color", "value": "#ffffff" }, { "name": "layout_centerInParent", "type": "boolean", "value": "true" }, { "name": "orientation", "type": "string", "value": "vertical" }], "views": [{ "widget": "android.widget.TextView", "properties": [{ "name": "id", "type": "", "value": "testClick" }, { "name": "layout_width", "type": "dimen", "value": "match_parent" }, { "name": "layout_height", "type": "dimen", "value": "wrap_content" }, { "name": "background", "type": "color", "value": "#ffffff" }, { "name": "gravity", "type": "string", "value": "center" }, { "name": "text", "type": "string", "value": "Try to click" }, { "name": "gravity", "type": "", "value": "center" }, { "name": "padding", "type": "dimen", "value": "5dp" }, { "name": "textColor", "type": "color", "value": "#919191" }] }, { "widget": "android.widget.TextView", "properties": [{ "name": "id", "type": "", "value": "adTitle" }, { "name": "layout_width", "type": "dimen", "value": "wrap_content" }, { "name": "layout_height", "type": "dimen", "value": "wrap_content" }, { "name": "background", "type": "color", "value": "#ffffff" }, { "name": "text", "type": "string", "value": "Hello AVOCARROT!" }, { "name": "layout_gravity", "type": "string", "value": "center" }, { "name": "textSize", "type": "dimen", "value": "16sp" }, { "name": "drawableLeft", "type": "base64", "value": "iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAAAA3NCSVQICAjb4U/gAAAJLklEQVRYhb1YS09d1xX+9us8LvdezCOAgwuBmGCgxZDg4MimTuzKbmZV1WEzi9R/kP6CDjppBx30L3hQyYPESeXYNRJGjo0fwXYbJ4RAhFMRMNyYxz2v/ehg1UdXpBBfFHcPYOvcffb+1lrf+tbahznn8MxDAwlggLIG6D1mteQaloMbOAGWGKcEg0NgAAACYM9+AngdawEGSEABTgIC4ADj9F/rVIEJoCCYABSDs/VBoSHrWi0AARggARyHMpAMzMIDh3ZSwppMJ6kXhICBTSEUmKzLbFZXyOAABzCkTGtnFeNCM+4EGB1qkcXgDtaBaUgJxsG8usyuL2QAYAALT+uCyxQSLjVgwABtYQ1MFdXKk6lLmP8CiB0z9W5fX8jAoAHpgLiKqILGBkgFVYYTTmfMZNiqLH70wVf/fNDY1fVa3+9Sx30RPkdABsgEpLNY+GrjX7cLrUX505+hXWlmpW+xto77t5ZmpgMlfQ5AKVGsNwh1egjIOMJMr81/fvfK5bbm8rAn0FiUQRHbMR4/uvn3j9oKBdnW8vLp0zCCyfoYjT1WO+e01jueZDrzAPC03Nby4ouH2oX34ML7+Pwe0seofD1z8W9Fx+LEvnz85+jug2wwGsaY/HX6u3ca7QqIMSalNMZora219ERJwZBE8aYaffXw6GtrT5Ii5Bfvf4A7N5f/8eHGo68jx46e+SX6XwV8MAHGhBAAjDH5JgCyLNv13N3wWms55zsmlqWGVX0wVGLIAFOTsx9eaGVbrS2Fikm/jnS599WBX/0WzZ1wMKEwgASz2nDOOefOOQK0Hw/lRhAacrVkQsACQGMLvBJOnvnJ6DGjsfnNypNvH3d0dA784ixeOAih4KmNpOpgHByhod3IfvLW/xy7ktr3fWttlmW0HfGJC8adrEZJIWx6srHZeKDY/OvfNOitR/dnVGOp+7Vx9PZlUELDGBiXOkgHnqWZc87zPAqfcy73+vfHXk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n7Qn02lOrm5sbJyYmGCMbW1tTU9Px3Gcr8yXEbjl5eWZmRlrbVtb27FjYwAIEBm2B6P3AkSv1codgMHBwUOHDjHGFhcXl5aWqG7XEiKOYyHEnTt3tre3AYyNjR040EShJPNIivYDiMzNXyaKFAqFN954wzm3sbFx8+ZNzjljjIymDAqC4LvvKtevXxdClEolWpymqRBihyPrBrSjgRJCEMePHz9eLpezLJuZmdnY2CCNpjW04NNPZxcXFznnAwMD3d3dxphcwVHTENcNqNYaYwxNnHMdHR1jY2NCiNXV1ampqR27a62vX7+epmlDQwOJITVVeOrsfKu6AdVmZq2aOedOnDhBpePq1auc8yzLaDFxa35+XinV0tJy9OjRJEl2CM8Pfkr4AQ6RA0haqAwxxl566aUjR44451ZWVm7cuEG8ppMuX75crVallOfOnTPGkJTTu7RJruZ1A9ptbG5u+r5/4sQJwnHt2rU8KKurq7Ozs57ntba29vX1CSH2TqgfBxCZODIy0traaox5+PDhwsICZdmdO3eWl5cBjI6OdnR01CrZcwTk+34URcVicXx8nIrG5OSkEGJzc3NqaqpUKpH/AFBD99wB0XDOTUxMNDU1pWl67969KIoePHjw6NEj59zg4GBvb+8el+UfGVCWZWEYpmna3t4+PDycpmmlUrl06RKJYZIkb731FgDOObXe9Y66P8dQXaScOnny5N27d6lr01p7ntfd3U0JmGvED17md4z9hExrTd30wMBAZ2enlLJSqWxvb6dpeurUKWI9qXa9aPYDiD7TOOfo2n/mzJnNzc1yuSyEaG9vP378+PfF8PkCyk0nnezr6xsaGnr8+PHGxsbw8HBDQwO14VLK/5MOkXtonqZpc3PzyMiI7/vd3d0TExPUZuS+2YeT6iY1nn4VofaeMXb69OlCoVAoFHp6etI09Twv/6SU9//PPur8cA7gaW9Um0d5NmVZRmm4DzrTqDtkVCVIcpxzcRxTqw+AqmntPXAf1tYNKKcFVX66oXLOqS3Mf8rRP3dASqlajaG7uta69hKX/7THhXC38R/7RDCAjCmKfQAAAABJRU5ErkJggg==" }, { "name": "padding", "type": "dimen", "value": "5dp" }, { "name": "gravity", "type": "string", "value": "center" }, { "name": "textColor", "type": "color", "value": "#1f91f7" }] }, { "widget": "android.widget.ImageView", "properties": [{ "name": "id", "type": "", "value": "adImage" }, { "name": "layout_width", "type": "dimen", "value": "wrap_content" }, { "name": "layout_height", "type": "dimen", "value": "wrap_content" }, { "name": "scaleType", "type": "dimen", "value": "fit_Center" }, { "name": "adjustViewBounds", "type": "boolean", "value": "true" }, { "name": "src", "type": "ref", "value": "sample" }, { "name": "background", "type": "color", "value": "#228877" }] }, { "widget": "android.widget.TextView", "properties": [{ "name": "id", "type": "", "value": "adCTA" }, { "name": "layout_width", "type": "dimen", "value": "match_parent" }, { "name": "layout_height", "type": "dimen", "value": "wrap_content" }, { "name": "background", "type": "color", "value": "#ffffff" }, { "name": "text", "type": "string", "value": "LearnMore" }, { "name": "padding", "type": "dimen", "value": "5dp" }, { "name": "textSize", "type": "dimen", "value": "16sp" }, { "name": "padding", "type": "dimen", "value": "7.5dp" }, { "name": "gravity", "type": "string", "value": "center" }, { "name": "textColor", "type": "color", "value": "#1f91f7" }] }] }] } """) // use a static JSON string for now val K = JSONObject(""" { "widget": "android.widget.LinearLayout", "properties": [ { "name": "layout_hight", "type": "dimen", "value": "match_parent" }, { "name": "layout_width", "type": "dimen", "value": "match_parent" }, { "name": "orientation", "type": "string", "value": "vertical" } ], "views": [ { "type": "android.widget.TextView", "properties": [ { "name": "id", "type": "", "value": "text_view" }, { "name": "layout_width", "type": "dimen", "value": "match_parent" }, { "name": "layout_margin", "type": "dimen", "value": "16p" }, { "name": "scrollbars", "type": "string", "value": "vertical" }, { "name": "text", "type": "string", "value": "" } ], "views": [] } ] } """) // MY CODE, FAILS /* create dynamic view and return the view with the holder class attached as tag */ val sampleView : View? = DynamicView.createView(this, K, SampleViewHolder_TextView::class.java) if (sampleView == null) throw Exception("sampleView is null") setContentView(sampleView) val sampleTextView : TextView? = (sampleView.tag as SampleViewHolder_TextView).TEXTVIEW if (sampleTextView == null) throw Exception("sampleTextView is null") // FAILS HERE sampleTextView.setMovementMethod(ScrollingMovementMethod()) // VIEW.print_object_pretty { x -> sampleTextView.setText(sampleTextView.text.toString() + x) } // VIEW.print_object_pretty{x -> throw Exception(x)} /* DEMO CODE, WORKS /* create dynamic view and return the view with the holder class attached as tag */ val sampleView : View? = DynamicView.createView(this, DEMO, SampleViewHolder_View::class.java) if (sampleView == null) throw Exception("sampleView is null") setContentView(sampleView) /* add Layout Parameters in just created view and set as the contentView of the activity */ sampleView.layoutParams = WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT) */ } override fun onClick(v: View) { startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("http://www.avocarrot.com/"))) } /* Constructor must be public */ class SampleViewHolder_TextView { /* we need the View with id testClick */ @DynamicViewId(id = "text_view") var TEXTVIEW: TextView? = null } /* Constructor must be public */ class SampleViewHolder_View { /* we need the View with id testClick */ @DynamicViewId(id = "testClick") var clickableView: View? = null } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
KOTLIN:
The text was updated successfully, but these errors were encountered: