Notes
March 8
-------
Last time, we were talking about how to store web browser history so we can view it in interesting ways.
class HostPart {
value: String,
expanded: bool,
higher: HostPart?, /* can be undefined */
lower: HostPart?
}
.ca
.carleton .google
www brightspace www mail sheets
class HNTree {
hostComponent: String, /* <-- "carleton" in "www.carleton.ca" */
hostSuffix: String, /* <-- "carleton.ca" in "www.carleton.ca" */
HostName: bool, /* is this part of a hostname, or the whole thing */
hostHistory: hostHistory? /* reference to history associated with this host,
only valid if HostName is true */
expanded: bool,
children: List<<HNTree>>,
parent: HNTree,
peerIndex: int /* to allow fast location of next child */
historyLevel: int /* to determine how to display this relative to other history elements */
fun getValue(): String {
return this.value;
}
fun expanded?() {}
/* want to get a list of host entries that are pruned to the current expanded level*/
fun nextVisibleNode() {
}
fun nextChildNode(child): HNTree? {
/* takes a child node in of this node */
/* get's child's peerIndex and returns peerIndex + 1 entry in children */
/* if child is not a child of this nodee, then return NULL */
}
fun addChild(node);
/* always add at sorted position amongst children */
fun delChild(index);
/* have to update peerIndex of all children with index greater than this */
}
So we could just call listVisibleChildren on the root and we'd get exactly what we want to show. But actually we only want to generate a list of what is visible on the screen, want to use LazyColumn
- also want to be able to handle *lots* of history, that's what would be useful to visualize
Start:
.
.com
.ca
.net
.org
Tap on .ca
.
.com
.ca
.carleton.ca
.net
.org
We need a list of items to be displayed, and we need to be able to say the first item in the list to be displayed. So we'd say VisibleHistoryItems(n, c), and it would return a list of items.
At the top of the screen is always an HNTree. We can just keep calling nextVisibleNode on this element to see what should next be shown. Internally this will use nextChildNode and check whether it is expanded or not, and based on that it will return the next node to be displayed.
How to test?
Start off with constant data, an array of hostnames. Get it from a website or from my own browser history
Then we want to parse it into our data structure, and then build a LazyColumn that displays the data structure
So first
- show you can just make a scrollable list of the hardcoded hostnames using LazyColumn
- make a trivial version of this class that just outputs stuff from the hostnames list, but uses desired API
- make the API do the right thing
You want to get API right before semantics
- because semantics may have to change based on needed API