Comments (11)
@janishar Please help, or guide me how to fix it!
from placeholderview.
@thanhpd-teko Verify
- Check that
@Layout
has 'L' in Caps - import of the
@Layout
and@View
should be from placeholderview package. - 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.
@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.
The error is in TextItemView
can you share that class as well
from placeholderview.
@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.
Everything's appears to be correct. I am not able to find the issue with these references.
from placeholderview.
Thank you. I will investigate, find out more evidence about this issue. I will let you know if i find anything intesting.
from placeholderview.
@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.
@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.
Hi @janishar , please check email. Thanks.
from placeholderview.
@janishar The same thing happened to me. I just had to Clean Project and Build again
from placeholderview.
Related Issues (20)
- SwipeCancelState called when dragging a clickable view..Disables further interaction
- How to make swipe three direction in case i have three button HOT 1
- SwipePlaceHolderView HOT 1
- Card not properly shown if provide width and height match parent HOT 2
- How to add tablayout in ExpandablePlaceHolderView
- Need Support DiffUtil
- Didn't find class "android.support.v7.widget.CardView" on path
- How to set the text based on the position
- has no Pulldown refresh effect? HOT 1
- How to display a fragment inside the view?
- How to load all items under a parent
- Ui freeze when adding view from an asynchronous call
- Cannot load profile pictures for the Tinder like swap pictures.
- How to use PlaceHolderview with android library , i am getting resource not found exception.
- Resource IDs as annotations non-final
- use with private is not supported HOT 1
- Empty method with @Click annotation make app crash: NullPointerException
- How to Expand all items on first load ?
- How to customize category sorting?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from placeholderview.