Эй ребята я бы хотел вам помочь
я запустил код но у меня есть вот это:
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.intskot, PID: 31012 java.lang.IllegalArgumentException: Path must not be empty. at com.squareup.picasso.Picasso.load(Picasso.java:332) at com.example.intskot.adapter.StoryAdapter$userInfo$1.onDataChange(StoryAdapter.kt:101) at com.google.firebase.database.core.ValueEventRegistration.fireEvent(ValueEventRegistration.java:75) at com.google.firebase.database.core.view.DataEvent.fire(DataEvent.java:63) at com.google.firebase.database.core.view.EventRaiser$1.run(EventRaiser.java:55) at android.os.Handler.handleCallback(Handler.java:907) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7478) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
мой код таков:
package com.example.intskot.adapter import android.content.Context import android.content.Intent import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.ImageView import android.widget.TextView import androidx.annotation.NonNull import androidx.recyclerview.widget.RecyclerView import com.example.intskot.AddStoryActivity import com.example.intskot.R import com.example.intskot.model.Story import com.example.intskot.model.User import com.google.firebase.database.DataSnapshot import com.google.firebase.database.DatabaseError import com.google.firebase.database.FirebaseDatabase import com.google.firebase.database.ValueEventListener import com.squareup.picasso.Picasso import de.hdodenhof.circleimageview.CircleImageView class StoryAdapter(private val mContext: Context, private val mStory: List<Story>): RecyclerView.Adapter<StoryAdapter.ViewHolder>() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { return if (viewType == 0) { val view = LayoutInflater.from(mContext).inflate(R.layout.add_story_item, parent, false) this.ViewHolder(view) } else { val view = LayoutInflater.from(mContext).inflate(R.layout.story_item, parent, false) this.ViewHolder(view) } } override fun getItemCount(): Int { return mStory.size } override fun onBindViewHolder(holder: ViewHolder, position: Int) { val story = mStory[position] userInfo(holder, story.getStoryid(), position) holder.itemView.setOnClickListener { val intent = Intent(mContext, AddStoryActivity::class.java) intent.putExtra("userid", story.getUserid()) mContext.startActivity(intent) } } inner class ViewHolder(@NonNull itemView: View) : RecyclerView.ViewHolder(itemView) { //StoryItem var storyimageseen: CircleImageView? = null var storyimage: CircleImageView? = null var storyusername: TextView? = null //AddStoryItem var storyplusbtn: ImageView? = null var addstorytext: TextView? = null init { //StoryItem storyimageseen = itemView.findViewById(R.id.story_image_seen) storyimage = itemView.findViewById(R.id.story_image) storyusername = itemView.findViewById(R.id.story_user_name) //AddStoryItem storyplusbtn = itemView.findViewById(R.id.story_add) addstorytext = itemView.findViewById(R.id.add_story_text) } } override fun getItemViewType(position: Int): Int { if (position == 0) { return 0 } return 1 } private fun userInfo(viewHolder: ViewHolder, userId: String, position: Int) { val usersRef = FirebaseDatabase.getInstance().reference.child("Users").child(userId) usersRef.addValueEventListener(object : ValueEventListener { override fun onDataChange(p0: DataSnapshot) { if (p0.exists() ) { val user = p0.getValue<User>(User::class.java) Picasso.get().load(user!!.getImage()).placeholder(R.drawable.profile).into(viewHolder.storyimage) if (position != 0) { Picasso.get().load(user.getImage()).placeholder(R.drawable.profile).into(viewHolder.storyimageseen) viewHolder.storyusername!!.text = user.getUsername() } } } override fun onCancelled(p0: DatabaseError) { } }) } }
Что я уже пробовал:
я пытался сделать это ненулевым, но ничего не вышло.
он говорит, что путь не должен быть пустым, но он берет данные из этого:
Picasso.get().load(user.getImage()).placeholder(R.drawable.profile).into(viewHolder.storyimageseen)не так ли?