-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
parkerli
committed
Aug 16, 2024
1 parent
24a8461
commit 3550ce7
Showing
7 changed files
with
234 additions
and
525 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
readerLibrary/src/main/ets/common/helper/NovelChapterOperateHelper.ets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { ReaderChapterItem } from '../entity/ReaderChaptersItem'; | ||
|
||
export class NovelChapterOperateHelper { | ||
static nextPageIndex(chapterList: ReaderChapterItem[], chapterIndex: number, pageIndex: number): number[] | null { | ||
if (chapterIndex >= chapterList.length - 1) { | ||
if (pageIndex >= chapterList[chapterIndex].chapterPageList.length - 1) { | ||
return null; | ||
} else { | ||
return [chapterIndex, pageIndex + 1]; | ||
} | ||
} else { | ||
if (pageIndex >= chapterList[chapterIndex].chapterPageList.length - 1) { | ||
if (chapterList[chapterIndex+1].chapterPageList.length === 0) { | ||
return null; | ||
} | ||
return [chapterIndex + 1, 0]; | ||
} else { | ||
return [chapterIndex, pageIndex + 1]; | ||
} | ||
} | ||
} | ||
|
||
static prePageIndex(chapterList: ReaderChapterItem[], chapterIndex: number, pageIndex: number): number[] | null { | ||
if (chapterIndex <= 0) { | ||
if (pageIndex <= 0) { | ||
return null; | ||
} else { | ||
return [chapterIndex, pageIndex - 1]; | ||
} | ||
} else { | ||
if (pageIndex <= 0) { | ||
if (chapterList[chapterIndex-1].chapterPageList.length === 0) { | ||
return null; | ||
} | ||
return [chapterIndex - 1, chapterList[chapterIndex-1].chapterPageList.length - 1]; | ||
} else { | ||
return [chapterIndex, pageIndex - 1]; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.