Now able to infinitely scroll bibles!

Tons of issues outstanding, but this is a huge accomplishment.
This commit is contained in:
Bradlee Speice 2014-09-16 23:37:08 -04:00
parent ef7b8f82fa
commit 918f7688ba
4 changed files with 41 additions and 9223 deletions

View File

@ -1,14 +1,18 @@
<html lang="en" ng-app="bookApp">
<head>
<script type="text/javascript" src="file:///android_asset/dist/book-bundle.js"></script>
<script type="text/javascript" src="file:///android_asset/dist/scroll.js"></script>
<script type="text/javascript" src="file:///android_asset/dist/scroll-jqlite.js"></script>
</head>
<body ng-controller="BookCtrl" id="bookController">
<div ng-repeat="verse in verses">
<div u-scroll-viewport style="height:200px;">
<div ui-scroll="verse in verseSource" style="display: inline;">
<h3 style="display: inline;" ng-show="verse.verseNum === 1">
{{ verse.chapter }}
</h3>
<sup ng-show="verse.verseNum !== 1">{{ verse.verseNum }}</sup>
<sup ng-show="verse.verseNum !== 1 && verse.verseNum !== 0">{{ verse.verseNum }}</sup>
{{ verse.content }}
</div>
</div>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,12 @@
$ = require 'jquery' # For using selectors to access scope
require 'angular'
app = angular.module('bookApp', [])
app = angular.module('bookApp', ['ui.scroll', 'ui.scroll.jqlite'])
app.controller 'BookCtrl', ['$scope', '$filter', ($scope, $filter) ->
$scope.verses = []
$scope.verseSource =
get: (index, count, success) ->
console.log "Calling me with " + index
success angular.fromJson Android.getVerses(index, count)
$scope.order_verses = ->
$scope.verses = $filter('orderBy')($scope.verses, 'id', false)
@ -12,8 +14,6 @@ app.controller 'BookCtrl', ['$scope', '$filter', ($scope, $filter) ->
$scope.appendVerse = (jsonVerseString) ->
$scope.verses.push angular.fromJson jsonVerseString
$scope.order_verses()
$scope.appendVerse Android.getVerse(5)
]
# Due to page initialization, we can only store the controller string.
@ -21,11 +21,11 @@ app.controller 'BookCtrl', ['$scope', '$filter', ($scope, $filter) ->
# etc. to grab the scope ahead of time and re-use it.
controller = "#bookController"
window.appendVerse = (jsonVerseString) ->
scope = angular.element($("#bookController")).scope()
scope.appendVerse jsonVerseString
# Since we're calling outside of angular, we need to manually apply
scope.$apply()
#window.appendVerse = (jsonVerseString) ->
#scope = angular.element($("#bookController")).scope()
#scope.appendVerse jsonVerseString
## Since we're calling outside of angular, we need to manually apply
#scope.$apply()
###
Future reference: Get the controller scope like so:

View File

@ -6,6 +6,8 @@ import android.webkit.WebViewClient
import android.webkit.JavascriptInterface
import org.crosswire.jsword.book.Book
import org.crosswire.jsword.versification.getVersification
import java.util.ArrayList
import android.util.Log
/**
* Created by bspeice on 9/14/14.
@ -20,4 +22,13 @@ class BibleViewClient(b: Book, lookup: VerseLookupService) : WebViewClient() {
val v = Verse(b.getVersification(), ordinal)
return lookup.getJsonVerse(v) as String
}
JavascriptInterface fun getVerses(first: Int, count: Int): String {
Log.e("getVerses", "First: " + first + " count: " + count)
val verses: MutableList<String> = ArrayList<String>()
for (i in first..first + count - 1) {
verses.add(getVerse(i))
}
return verses.toString()
}
}