Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

guillotine activity #12

Closed
curliq opened this issue Mar 14, 2016 · 3 comments
Closed

guillotine activity #12

curliq opened this issue Mar 14, 2016 · 3 comments

Comments

@curliq
Copy link

curliq commented Mar 14, 2016

Hi, I'm implementing your beautiful menu is a way that the guillotine layout will be full of interactions, and they don't seem to react at all, I've create a GuillotineActivity.java for it, and can't change simple things like the backgroundColor programmatically, how do I do it ?
Thanks

@dmytroDenysenko
Copy link
Contributor

Hey @joaosardinha
Can you provide some code example of your GuillotineActivity implementation and details of problem? So I can help you solve this.

@curliq
Copy link
Author

curliq commented Mar 24, 2016

Hey absolutely!

MainActivity.java:

//No changes from the original sample
     //@InjectView...
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity);
        ButterKnife.inject(this);


        if (toolbar != null) {
            setSupportActionBar(toolbar);
            getSupportActionBar().setTitle(null);
        }

        View guillotineMenu = LayoutInflater.from(this).inflate(R.layout.guillotine, null);
        root.addView(guillotineMenu);

        new GuillotineAnimation.GuillotineBuilder(guillotineMenu, guillotineMenu.findViewById(R.id.guillotine_hamburger), contentHamburger)
                .setStartDelay(RIPPLE_DURATION)
                .setActionBarViewForAnimation(toolbar)
                .setClosedOnStart(true)
                .build();

    }

The guillotine.xml and activity.xml layouts are just like in the original sample, with the hamburgers in the right side of the ActionBar and the GUILLOTINE_CLOSED_ANGLE as 90f.

I created an activity class for the guillotine.xml layout:

public class GuillotineActivity extends AppCompatActivity {

    @InjectView(R.id.button1)
    Button button;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.guillotine);
        ButterKnife.inject(this);

        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(GuillotineActivity.this, MainActivity.class));
            }
        });
    }
}

My problem is, simple things as a button calling startActivity won't work inside the Guillotine activity making it nothing more than a layout instead of an activity.
I haven't change anything in the library expect the GUILLOTINE_CLOSED_ANGLE float.
Any thoughts of how to turn it into a real activity?

@dmytroDenysenko
Copy link
Contributor

Well, if I understand correctly, what you want is to encapsulate some logic inside class of navigation menu, so it won't be just a layout. If this is the case, then you can extend View, use this layout and put all the logic you need inside. Then add your custom View to your MainActivity instead of inflating layout.

But if you want both elements to be activities and have this kind of animation, then this lib won't satisfy your needs completely. You can look into http://developer.android.com/training/material/animations.html to achieve similar behaviour

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants