ManuelPeinado / FadingActionBar

Android library implementing a fading effect for the action bar, similar to the one found in the Play Music app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I keep getting the same error. Not sure what the issues is?

phillwiggins opened this issue · comments

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.app.ActionBar.setBackgroundDrawable(android.graphics.drawable.Drawable)' on a null object reference
at com.manuelpeinado.fadingactionbar.extras.actionbarcompat.FadingActionBarHelper.setActionBarBackgroundDrawable(FadingActionBarHelper.java:59)
at com.manuelpeinado.fadingactionbar.FadingActionBarHelperBase.initActionBar(FadingActionBarHelperBase.java:173)
at com.manuelpeinado.fadingactionbar.extras.actionbarcompat.FadingActionBarHelper.initActionBar(FadingActionBarHelper.java:32)
at com.purewow.myapplication.Recipe.onCreate(Recipe.java:20)

Is this a common problem?

Thanks in advance!

I have the same error, how solved this?
Thanks!

I have managed to solve this one. I can send some code for you later. See if yours differs? @panche14

Thank You! It would be helpful to me @phillwiggins

Try this, it seemed to work for me when I overwrote the FadingActionBarHelper class ...

package com.purewow.myapplication.Utils;

import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;

import com.manuelpeinado.fadingactionbar.FadingActionBarHelperBase;

public class FadingActionBarHelper extends FadingActionBarHelperBase {

private ActionBar mActionBar;

@Override
protected int getActionBarHeight() {
    return mActionBar.getHeight();
}

@Override
protected boolean isActionBarNull() {
    return mActionBar == null;
}

@Override
protected void setActionBarBackgroundDrawable(Drawable drawable) {
    mActionBar.setBackgroundDrawable(drawable);
}

@Override
public void initActionBar(Activity activity) {
    mActionBar = ((ActionBarActivity) activity).getSupportActionBar();
    super.initActionBar(activity);
}
}

Create this class and replace the import to your class's path...

thanks for the help, but I could not fix the error, I'll keep investigating

@panche14 @ManuelPeinado
Same issue not any solution find for this ?

I have the same problem...

commented

Make sure you styles.xml, themes.xml, and manifest are up to date with the sample. I had the same problem when I tried implementing the solution without them.

The Problem is that FadingActionBar does not work with ActionBarCombat.
Am 08.08.2015 17:04 schrieb "leef3" notifications@github.com:

Make sure you styles.xml, themes.xml, and manifest are up to date with the
sample. I had the same problem when I tried implementing the solution
without them.


Reply to this email directly or view it on GitHub
#98 (comment)
.

did anyone found a solution for this?

commented

Same problem

MyFadingActionBarHelper.java

import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import com.manuelpeinado.fadingactionbar.FadingActionBarHelperBase;

public class MyFadingActionBarHelper extends FadingActionBarHelperBase {
    private ActionBar mActionBar;

    @Override
    protected int getActionBarHeight() {
        return mActionBar.getHeight();
    }

    @Override
    protected boolean isActionBarNull() {
        return mActionBar == null;
    }

    @Override
    protected void setActionBarBackgroundDrawable(Drawable drawable) {
        mActionBar.setBackgroundDrawable(drawable);
    }


    @Override
    public void initActionBar(Activity activity) {
        mActionBar = ((AppCompatActivity) activity).getSupportActionBar();
        super.initActionBar(activity);
        }
}

MainActivity.java

 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        MyFadingActionBarHelper helper = new MyFadingActionBarHelper()
                .actionBarBackground(R.color.colorPrimary)
                .headerLayout(R.layout.activity_introduction_header_image)
                .contentLayout(R.layout.activity_introduction);
        setContentView(helper.createView(this));
        helper.initActionBar(HomeActivity.this);

This works for me!!