Skip to content

Code mismatch in Gradle compile line and existing master branch code #54

@sureshlsdj

Description

@sureshlsdj

Hi Team,

I have used "implementation 'com.tenmiles:helpstack:1.2.0'" in gradle,
Actually, in my project, I haven't used Action bar(NoActionbar theme), due to this Im getting crash in HSActivityParent activity.

`public class HSActivityParent extends AppCompatActivity {

private static final String ACTION_BAR_TITLE = "Actionbar_title";

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

	// Handling actionbar title when activity changes so activity does not have to handle it.
	if (savedInstanceState != null) {
        getHelpStackActionBar().setTitle(savedInstanceState.getString(ACTION_BAR_TITLE));
	}
	getSupportActionBar().setHomeButtonEnabled(true);
	getSupportActionBar().setDisplayHomeAsUpEnabled(true);
	configureActionBar(getSupportActionBar());
}

public void configureActionBar(ActionBar actionBar) {
}

// Handling actionbar title when activity changes so activity doesnot have to handle it.
@Override
protected void onSaveInstanceState(Bundle outState) {
	super.onSaveInstanceState(outState);
	outState.putString(ACTION_BAR_TITLE, getHelpStackActionBar().getTitle().toString());
}

public ActionBar getHelpStackActionBar() {
	return getSupportActionBar();
}

}`

But, If I check latest master branch repository for the same class following code is there which is having crash-free code
`public class HSActivityParent extends AppCompatActivity {

private static final String ACTION_BAR_TITLE = "Actionbar_title";
private Toolbar mToolbar;

// Handling actionbar title when activity changes so activity doesn't have to handle it.
@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    if(getSupportActionBar() != null)
    outState.putString(ACTION_BAR_TITLE, getSupportActionBar().getTitle().toString());
}

protected void setContentView(int layoutResId, Bundle savedInstanceState, int title) {
    super.setContentView(R.layout.hs_activity_base);
    mToolbar =  (Toolbar)findViewById(R.id.toolbar);

    LayoutInflater layoutInflater = LayoutInflater.from(this);
    LinearLayout lLayout = (LinearLayout) findViewById(R.id.lyt_base);
    View view = layoutInflater.inflate(layoutResId, null);

    if(getSupportActionBar() != null){
        ActionBar actionbar = getSupportActionBar();
        setTitle(savedInstanceState, title);
        actionbar.setHomeButtonEnabled(true);
        actionbar.setDisplayHomeAsUpEnabled(true);
    } else{
        mToolbar.setVisibility(View.VISIBLE);
        setSupportActionBar(mToolbar);
        setTitle(savedInstanceState, title);
    }

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);

    lLayout.addView(view);
}

private void setTitle(Bundle savedInstanceState, int title) {
    ActionBar actionbar = getSupportActionBar();
    if (savedInstanceState != null) {
        actionbar.setTitle(savedInstanceState.getString(ACTION_BAR_TITLE));
    } else if(title != 0){
        actionbar.setTitle(getString(title));
    } else{
        actionbar.setTitle(getString(R.string.hs_help_title));
    }
}

}`

Please let me know latest gradle compile line 1.2.0 is latest or not?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions