• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Null Pointer Exception after taking their refrences

Hello Guys
I am stuck at some point in my Android Project.
Java:
 public void initStreamerInfo() {

        ImageView streamerAvatar= findViewById(R.id.livestreamingHeader_streamerImage);
        TextView streamerName = findViewById(R.id.livestreamingHeader_name);
        TextView streamerAge = findViewById(R.id.livestreamingHeader_age);
        followingImg = findViewById(R.id.livestreamingHeader_followedStreamer);
        if (streamerAvatar==null){
            Log.d("statusofimgvw","kuch nhi ho sakta");
        }
        else {
            Log.d("statusofimgvw","Not null");
        }
        User puser=mLiveStreamObject.getAuthor();
        Log.d("checkingvaluel",puser.getProfilePhotos().get(puser.getAvatarPhotoPosition()).getUrl());
        Log.d("checkingvaluel",puser.getColFirstName());
        Log.d("checkingvaluel"," "+mLiveStreamObject.getAuthor().getProfilePhotos());
        QuickHelp.getAvatars(mLiveStreamObject.getAuthor(), streamerAvatar);
        streamerName.setText(String.format("%s, ", mLiveStreamObject.getAuthor().getColFirstName()));

        if (mLiveStreamObject.getAuthor().getBirthDate() != null){
            streamerAge.setText(String.valueOf(QuickHelp.getAgeFromDate(mLiveStreamObject.getAuthor().getBirthDate())));
        }

        setTimer(mLiveStreamObject.getStartedAt());

        FollowModel.queryFollowSingleUser(mLiveStreamObject.getAuthor(), new FollowModel.QueryFollowListener() {
            @Override
            public void onQueryFollowSuccess(boolean isFollowing) {

                if (isFollowing){
                    followingImg.setVisibility(View.VISIBLE);
                    isFollowingUser  = true;
                } else {
                    followingImg.setVisibility(View.GONE);
                    isFollowingUser  = false;
                }
            }

            @Override
            public void onQueryFollowError(ParseException error) {
                followingImg.setVisibility(View.GONE);
                isFollowingUser  = false;
            }
        });
    }


It's my java code where I am initializing the xml components and using them.
Java:
 public static void getAvatars(User user, ImageView imageView){

        ColorDrawable colorDrawable = new ColorDrawable(ContextCompat.getColor(Application.getInstance().getApplicationContext(), R.color.highlight_light_ripple));

        // Load profile Photos
        if (user.getProfilePhotos() != null && user.getProfilePhotos().size() > 0) {

            Glide.with(Application.getInstance().getApplicationContext())
                    .load(user.getProfilePhotos().get(user.getAvatarPhotoPosition()).getUrl())
                    .error(colorDrawable)
                    .centerCrop()
                    .circleCrop()
                    .fitCenter()
                    .placeholder(colorDrawable)
                    .into(imageView);

        } else {

            Glide.with(Application.getInstance().getApplicationContext())
                    .load(colorDrawable)
                    .into(imageView);
        }
    }

It's the method named getAvatars in another class named QuickHelp.
Code:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:aapt="http://schemas.android.com/aapt"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <View
        android:id="@+id/imageCenterView"
        android:layout_width="1dp"
        android:layout_height="1dp"
        app:layout_constraintBottom_toBottomOf="@+id/livestreamingHeader_streamerImage"
        app:layout_constraintEnd_toEndOf="@+id/livestreamingHeader_streamerImage"
        app:layout_constraintStart_toStartOf="@+id/livestreamingHeader_streamerImage"
        app:layout_constraintTop_toTopOf="@+id/livestreamingHeader_streamerImage" />

    <com.sos.GD_Live.modules.circularimageview.CircleImageView
        android:id="@+id/livestreamingHeader_streamerImage"
        android:layout_width="@dimen/icon_xlg"
        android:layout_height="@dimen/icon_xlg"
        android:layout_marginStart="@dimen/spacing_md"
        android:layout_marginTop="@dimen/spacing_md"
        android:layout_marginBottom="@dimen/spacing_md"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginLeft="@dimen/spacing_md" />

    <TextView
        android:id="@+id/livestreamingHeader_status"
        style="?attr/textStyleP3Inverse"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:minWidth="26dp"
        android:padding="1dp"
        android:text="00:00"
        android:background="@drawable/bg_livestreaming_rounded_rect_red_carrot"
        app:layout_constraintBottom_toBottomOf="@+id/livestreamingHeader_streamerImage"
        app:layout_constraintEnd_toEndOf="@+id/imageCenterView"
        app:layout_constraintStart_toStartOf="@+id/imageCenterView"
        app:layout_constraintTop_toBottomOf="@+id/livestreamingHeader_streamerImage" />

    <LinearLayout
        android:id="@+id/livestreamingHeader_streamerInfo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/spacing_sm"
        android:layout_marginEnd="@dimen/spacing_md"
        android:gravity="center_vertical"
        android:orientation="horizontal"
        app:layout_constraintBottom_toTopOf="@+id/livestreamingHeader_subtitle"
        app:layout_constraintStart_toEndOf="@+id/livestreamingHeader_streamerImage"
        app:layout_constraintTop_toTopOf="@+id/livestreamingHeader_streamerImage"
        app:layout_constraintVertical_chainStyle="packed"
        android:layout_marginRight="@dimen/spacing_md"
        android:layout_marginLeft="@dimen/spacing_sm">

        <TextView
            android:id="@+id/livestreamingHeader_name"
            style="?attr/textStyleP2Inverse"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ellipsize="end"
            android:maxWidth="@dimen/streamer_name_max_width"
            android:maxLines="1"
            tools:text="Maravilho, "
            android:singleLine="true" />

        <TextView
            android:id="@+id/livestreamingHeader_age"
            style="?attr/textStyleP2Inverse"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            tools:text="25"
            android:maxLines="1" />

        <ImageView
            android:id="@+id/livestreamingHeader_followedStreamer"
            style="?attr/textStyleP2Inverse"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="4dp"
            android:visibility="gone"
            app:srcCompat="@drawable/ic_livestream_favorites_streamer"
            android:layout_marginLeft="4dp" />
    </LinearLayout>

    <TextView
        android:id="@+id/livestreamingHeader_subtitle"
        style="?attr/textStyleP3Inverse"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="@dimen/spacing_md"
        android:alpha="0.5"
        android:ellipsize="end"
        android:maxWidth="120dp"
        android:maxLines="1"
        android:singleLine="true"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="@+id/livestreamingHeader_streamerImage"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="@+id/livestreamingHeader_streamerInfo"
        app:layout_constraintTop_toBottomOf="@+id/livestreamingHeader_streamerInfo"
        app:layout_constraintVertical_chainStyle="packed"
        android:layout_marginRight="@dimen/spacing_md" />
</merge>

it's my xml code.

The error is that when I executing this code it shows me null pointer exception on accessing each view after taking refrence also.

Thanks in Advance

Fearing the worst: What do I backup in 'master reset' circs?

Thanks for the kind advice ocnbrz, and Hadron (Smoke me a kipper)...I could not agree more with your characterization of "the cloud." Interesting that SMS Backup and Restore is not cloud-based.

I applied the fix I saw at the end of the latest update of the Endgadget piece, so we shall see.

One thing I saw when I was updating Android System WebView that cracked me up was this:

"Join the beta: Try new features before they're officially released and give your feedback to the developer"

I think I am part of the beta already, right? Tried the new features, and I doubt they want my feedback.

otherchuck

Help about to buy s20 ULTRA AGAIN and must know if auto focus is still dead

Did they ever update the camera software to fix the focus issue on the S20 Ultra or is the Note 20 Ultra the better phone to get for cameras?

Check the comparisons between S21 and S20 Ultra. I've seen this before where manufacturers focus on specs to market, taking one step forward on camera specs and 2 steps back on image processing.

https://www.dxomark.com/samsung-gal...a-review-dual-tele-with-room-for-improvement/

Filter

Back
Top Bottom