Added summary of steps for one page flipping algorithm..

It's a primitive one for paginating an infinite list.
This commit is contained in:
Snowyfox 2021-08-14 14:56:37 -04:00
parent 1704a22847
commit 1fa1f4ea38
2 changed files with 31 additions and 3 deletions

View File

@ -16,9 +16,9 @@ JKomasto {
public
JKomasto()
{
//new TimelineWindow().setVisible(true);
new TimelineWindow().setVisible(true);
//new ComposeWindow().setVisible(true);
new PostWindow().setVisible(true);
//new PostWindow().setVisible(true);
}
// - -%- -

View File

@ -19,6 +19,8 @@ import java.awt.Dimension;
import java.awt.Insets;
import java.util.List;
import java.util.ArrayList;
import java.util.Deque;
import java.util.LinkedList;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
@ -48,6 +50,9 @@ implements ActionListener {
private JMenuItem
flipToNewestPost;
private Deque<Deque<String>>
postIDsSeen;
// ---%-@-%---
public void
@ -69,13 +74,36 @@ implements ActionListener {
public void
nextPage()
{
/*
* uhh, what if the ID we provide is invalid.
* Or does Mastodon keep IDs as 'deleted'? That
* would make things a lot simpler.
*/
}
public void
previousPage()
{
if (postIDsSeen.isEmpty())
{
// Just request the latest first page.
return;
}
Deque<String> lastPagePostIDs = postIDsSeen.pop();
while (!lastPagePostIDs.isEmpty())
{
String idToTry = lastPagePostIDs.pop();
// Fetch page for this ID.
// If successful, render and return.
}
// Didn't return from above. Our current page "replaced"
// the previous page, so the previous page's predecessor
// is our previous page. Try to flip to that.
previousPage();
}
// - -%- -