0

How does one call the information that a card is being displayed and to what height it is being displayed.

I'm working on a balanced ternary clock, and I'd like to resize the face depending on cards.

Edit: I found a solution.

// detect the height of a card. And call resizers.
// baseLedge is the default bottom of the watch
// tallness is the height of the display
// tallable is the portion of the screen height offered to the face.
// ledge is the adjusted bottom of the watch
// ledgeSpace is a desired margin above the ledge
// puff is the ratio of the adjusted display to the standard display
// puffer() is a module (or method or whatever the correct term is) that applies the resizing.
    // no clue what the Override wrapper does or how it work.   
    @Override
    // Rect -> none
    public void onPeekCardPositionUpdate(Rect bounds) {
        super.onPeekCardPositionUpdate(bounds);
        if (!bounds.equals(mCardBounds)) {
            mCardBounds.set(bounds);
            if (bounds.top == 0){bounds.top = (int)tallness;}
            if (bounds.top < baseLedge || ledge != baseLedge) {
                ledge = Math.min(bounds.top, baseLedge);
                puff = (ledge - dispTop -) / tallable; 
                if (puff < (float).25) {puff = (float).25; }
                puffer ();
            }
            invalidate(); // redraw screen without updating time.
        }
    }

note: make a flag and find the height the following code could be placed in onPeekCardPositionUpdate()

yesCard = bounds.top != (int)0; // boolean that will be true if a card is showing.
cardHeight = (float)bounds.top; 
kjl
  • 311
  • 3
  • 13

1 Answers1

0

Are you asking about peek cards? If so, obtaining its dimensions are documented at that link.

Sterling
  • 6,365
  • 2
  • 32
  • 40
  • Thank you, I was asking about peek cards. I'm new to java and android so the developer walk throughs don't help me so much. I wish they offered more code examples, or that I was better at finding the code examples that they do offer. – kjl Jul 17 '16 at 18:24
  • 1
    I did find a sample code which worked for me at https://github.com/googlesamples/android-WatchFace/blob/master/Wearable/src/main/java/com/example/android/wearable/watchface/CardBoundsWatchFaceService.java – kjl Jul 17 '16 at 18:26