Giter Site home page Giter Site logo

Comments (11)

thanhpd-teko avatar thanhpd-teko commented on June 5, 2024

@janishar Please help, or guide me how to fix it!

from placeholderview.

janishar avatar janishar commented on June 5, 2024

@thanhpd-teko Verify

  1. Check that @Layout has 'L' in Caps
  2. import of the @Layout and @View should be from placeholderview package.
  3. Also, check kapt is used for annotation processing
    apply plugin: 'kotlin-kapt'
    ...
    implementation 'com.mindorks.android:placeholderview:1.0.3'
    kapt 'com.mindorks.android:placeholderview-compiler:1.0.3'

from placeholderview.

thanhpd-teko avatar thanhpd-teko commented on June 5, 2024

@janishar Sorry for late reply. Below is full of my view file.
The problem is that it happened occasionally when developing, not all the time (after cleanup project it works for a while, then the error occured again...)

package com.frovis.vuitro.ui.main.issue.list

import android.content.Context
import android.graphics.drawable.GradientDrawable
import android.widget.TextView
import com.frovis.vuitro.MyAdminIssueQuery
import com.frovis.vuitro.R
import com.frovis.vuitro.utils.CommonUtils
import com.frovis.vuitro.utils.DateTimeUtils
import com.frovis.vuitro.utils.IssueUtils.styleIssueLevel
import com.frovis.vuitro.utils.RoomUtils.getFullRoomName
import com.mindorks.placeholderview.annotations.*

@Layout(R.layout.issue_item)
@NonReusable
class IssueItemView(
    private val context: Context?,
    private val issue: MyAdminIssueQuery.Result,
    private val listener: IssueItemListener
) {
    interface IssueItemListener {
        fun onIssueClick(id: String)

    }

    @View(R.id.tvIssueItemTitle)
    lateinit var tvIssueItemTitle: TextView
    @View(R.id.tvIssueItemRoom)
    lateinit var tvIssueItemRoom: TextView
    @View(R.id.tvIssueItemAddress)
    lateinit var tvIssueItemAddress: TextView
    @View(R.id.tvIssueItemCreator)
    lateinit var tvIssueItemCreator: TextView
    @View(R.id.tvIssueItemCreatedAt)
    lateinit var tvIssueItemCreatedAt: TextView
    @View(R.id.tvIssueItemLevel)
    lateinit var tvIssueItemLevel: TextView

    @Resolve
    fun onResolve() {
        tvIssueItemTitle.text = issue.title()
        tvIssueItemRoom.text = getFullRoomName(
            context,
            issue.room()?.name(),
            issue.room()?.motel()?.name()
        )
        tvIssueItemAddress.text = issue.room()?.motel()?.address() ?: ""
        tvIssueItemCreator.text = issue.creator()?.fullName() ?: ""
        tvIssueItemCreatedAt.text =
            DateTimeUtils.dateTimeUTCToLocalDate(issue.createdAt().toString())
        tvIssueItemLevel.text = CommonUtils.getStringResourceByKey(context, issue.level())
        val drawable = tvIssueItemLevel.background as GradientDrawable
        context?.let { styleIssueLevel(drawable, it, issue.level()) }
    }

    @Click(R.id.llIssueItemContainer)
    fun onContainerClick() {
        listener.onIssueClick(issue.id())
    }
}

Output error:
2020-03-03 06:47:23.975 18043-18043/com.frovis.vuitro.debug E/UncaughtException: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setOnClickListener(android.view.View$OnClickListener)' on a null object reference at com.frovis.vuitro.ui.main.issue.create.dialog.TextItemView$ViewBinder.bindClick(TextItemView$ViewBinder.java:48) at com.frovis.vuitro.ui.main.issue.create.dialog.TextItemView$ViewBinder.bindClick(TextItemView$ViewBinder.java:10)

from placeholderview.

janishar avatar janishar commented on June 5, 2024

The error is in TextItemView can you share that class as well

from placeholderview.

thanhpd-teko avatar thanhpd-teko commented on June 5, 2024

@janishar Here you are.
TextItemView

package com.frovis.vuitro.ui.main.issue.create.dialog

import android.widget.TextView
import com.frovis.vuitro.R
import com.mindorks.placeholderview.annotations.*

@NonReusable
@Layout(R.layout.text_item)
class TextItemView(
    private val id: Int,
    private val text: String,
    private val listener: OnClickListener
) {

    @View(R.id.tv_item_text)
    lateinit var textView: TextView

    @Resolve
    fun onResolve() {
        textView.text = text
    }

    @Click(R.id.tv_item_text)
    fun onClick() {
        listener.onClick(id)
    }

    interface OnClickListener {
        fun onClick(itemId: Int?)
    }
}

text_item.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
		android:layout_width="match_parent"
		android:layout_height="wrap_content"
		android:background="@color/cardview_light_background">
	<TextView
			android:id="@+id/tv_item_text"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:padding="16dp"
			android:ellipsize="end"
			android:maxLines="1"
			android:textAppearance="?attr/textAppearanceSubtitle1"/>

</FrameLayout>

Fragment

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        mViewModel.motelData.observe(viewLifecycleOwner, Observer { motels ->
            if (motels != null) {
                phvMotelList.removeAllViews()
                for (motel in motels) {
                    phvMotelList.addView(motel.id?.let {
                        TextItemView(
                            it,
                            motel.name,
                            this
                        )
                    })
                }
            }
        })

from placeholderview.

janishar avatar janishar commented on June 5, 2024

Everything's appears to be correct. I am not able to find the issue with these references.

from placeholderview.

thanhpd-teko avatar thanhpd-teko commented on June 5, 2024

Thank you. I will investigate, find out more evidence about this issue. I will let you know if i find anything intesting.

from placeholderview.

thanhpd-teko avatar thanhpd-teko commented on June 5, 2024

@janishar
More information about error: E/UncaughtException: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
Below is generated class:

 @Override
  protected void bindClick(final RoomContractItemView resolver, View itemView) {
    itemView.findViewById(R.id.onClick_1).setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
        resolver.onClick();
      }
    });
  }

from placeholderview.

janishar avatar janishar commented on June 5, 2024

@thanhpd-teko If you could send me the zip of your project to my email [email protected] then I will be able to run it and debug.

from placeholderview.

thanhpd-teko avatar thanhpd-teko commented on June 5, 2024

Hi @janishar , please check email. Thanks.

from placeholderview.

hayahyts avatar hayahyts commented on June 5, 2024

@janishar The same thing happened to me. I just had to Clean Project and Build again

from placeholderview.

Related Issues (20)

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.