txusballesteros / bubbles-for-android

Bubbles for Android is an Android library to provide chat heads capabilities on your apps. With a fast way to integrate with your development.
Apache License 2.0
1.48k stars 281 forks source link

Expanding View on bubble press #53

Closed JakeOrel closed 1 year ago

JakeOrel commented 2 years ago

Howdy yall, I'm working on creating a react native package that utilizes this package. Ive got the bubble showing up and all that works fine. I have created the secondary layout that should show up on bubble press however whenever i try to use the findViewById method in my case since its across a native bridge it's reactContext.getCurrentActivity().findViewById(r.id.layout) it's just returning null. The layout ive added is in the bubble_layout file yet i cant seem to figure out why all im getting is null. any help is appreciated thanks!

heres an example of what im trying to do

update

so i have found out how to add the view on press however the code below is causing a second bubble to pop up which is resulting in a crash :/ on top of that the view only expands while in the app so i i still have some issues im working through if anyone has a tip that would be awesome

private void addNewBubble(int x, int y) {
        this.removeBubble();
        bubbleView =
          (BubbleLayout) LayoutInflater
            .from(reactContext)
            .inflate(R.layout.bubble_layout, null);
        bubbleView.setOnBubbleRemoveListener(
          new BubbleLayout.OnBubbleRemoveListener() {
            @Override
            public void onBubbleRemoved(BubbleLayout bubble) {
              bubbleView = null;
              sendEvent("floating-bubble-remove");
            }
          }
        );
        bubbleView.setOnBubbleClickListener(
          new BubbleLayout.OnBubbleClickListener() {
            @Override
            public void onBubbleClick(BubbleLayout bubble) {

               reactContext.getCurrentActivity().setContentView(R.layout.bubble_layout); <-- this was the only way to get the code below to not return null for notification layout i have found
               notificationLayout = reactContext.getCurrentActivity().findViewById(R.id.notification_layout);

              System.out.println(notificationLayout); <-- this prints null
              System.out.println(bubble);

           if (notificationLayout.getVisibility() == View.GONE) {

                notificationLayout.setVisibility(View.VISIBLE);

              } else {

                notificationLayout.setVisibility(View.GONE);

              }
              sendEvent("floating-bubble-press");
            }
          }
        );
        bubbleView.setShouldStickToWall(true);
        bubblesManager.addBubble(bubbleView, x, y);
      }