mirror of
https://github.com/MinimalBible/MinimalBible
synced 2024-11-21 23:48:18 -05:00
Seek-to working!
For some reason, things at 1st Timothy onward don't work, but everything up to that point does. I'll call that enough for now. PLEASE NOTE: This code needs serious refactoring and testing, dependencies are all over the place. Functionally it's OK for now though.
This commit is contained in:
parent
23f992505c
commit
96c5c895e9
@ -17,6 +17,7 @@ import dagger.Provides;
|
|||||||
import de.devland.esperandro.Esperandro;
|
import de.devland.esperandro.Esperandro;
|
||||||
import rx.functions.Action1;
|
import rx.functions.Action1;
|
||||||
import rx.functions.Func1;
|
import rx.functions.Func1;
|
||||||
|
import rx.subjects.PublishSubject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modules used for the BibleViewer activity
|
* Modules used for the BibleViewer activity
|
||||||
@ -101,4 +102,10 @@ public class BibleViewerModules {
|
|||||||
VerseLookup verseLookup(@Named("MainBook") Book b) {
|
VerseLookup verseLookup(@Named("MainBook") Book b) {
|
||||||
return new VerseLookup(b);
|
return new VerseLookup(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
PublishSubject<BookScrollEvent> scrollEventProvider() {
|
||||||
|
return PublishSubject.create();
|
||||||
|
}
|
||||||
}
|
}
|
@ -14,6 +14,8 @@ import org.crosswire.jsword.book.Book;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import rx.subjects.PublishSubject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ExpandableListView for managing books of the Bible.
|
* ExpandableListView for managing books of the Bible.
|
||||||
* We extend from @link{BaseNavigationDrawerFragment} so we can inherit some of the lifecycle
|
* We extend from @link{BaseNavigationDrawerFragment} so we can inherit some of the lifecycle
|
||||||
@ -27,6 +29,9 @@ public class BookChapterNavFragment extends NavDrawerFragment {
|
|||||||
@Inject @Named("MainBook")
|
@Inject @Named("MainBook")
|
||||||
Book mainBook;
|
Book mainBook;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
PublishSubject<BookScrollEvent> scrollListener;
|
||||||
|
|
||||||
ExpandableListView mActualListView;
|
ExpandableListView mActualListView;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -35,9 +40,11 @@ public class BookChapterNavFragment extends NavDrawerFragment {
|
|||||||
Injector i = (Injector) getActivity();
|
Injector i = (Injector) getActivity();
|
||||||
i.inject(this);
|
i.inject(this);
|
||||||
|
|
||||||
|
BibleMenu menu = new BibleMenu(mainBook);
|
||||||
mActualListView = (ExpandableListView) inflater.inflate(
|
mActualListView = (ExpandableListView) inflater.inflate(
|
||||||
R.layout.fragment_expandable_navigation_drawer, container, false);
|
R.layout.fragment_expandable_navigation_drawer, container, false);
|
||||||
mActualListView.setAdapter(new BibleMenu(mainBook));
|
mActualListView.setAdapter(menu);
|
||||||
|
mActualListView.setOnChildClickListener(menu.getMenuClickListener(scrollListener));
|
||||||
|
|
||||||
mActualListView.setItemChecked(mCurrentSelectedPosition, true);
|
mActualListView.setItemChecked(mCurrentSelectedPosition, true);
|
||||||
return mActualListView;
|
return mActualListView;
|
||||||
|
@ -1,20 +1,17 @@
|
|||||||
package org.bspeice.minimalbible.activity.viewer;
|
package org.bspeice.minimalbible.activity.viewer;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
|
|
||||||
import org.bspeice.minimalbible.Injector;
|
import org.bspeice.minimalbible.Injector;
|
||||||
import org.bspeice.minimalbible.R;
|
import org.bspeice.minimalbible.R;
|
||||||
import org.bspeice.minimalbible.activity.BaseFragment;
|
import org.bspeice.minimalbible.activity.BaseFragment;
|
||||||
import org.bspeice.minimalbible.service.lookup.VerseLookup;
|
|
||||||
import org.crosswire.jsword.book.Book;
|
import org.crosswire.jsword.book.Book;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@ -22,10 +19,6 @@ import javax.inject.Named;
|
|||||||
|
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import butterknife.InjectView;
|
import butterknife.InjectView;
|
||||||
import rx.Observable;
|
|
||||||
import rx.android.schedulers.AndroidSchedulers;
|
|
||||||
import rx.functions.Action1;
|
|
||||||
import rx.schedulers.Schedulers;
|
|
||||||
import rx.subjects.PublishSubject;
|
import rx.subjects.PublishSubject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,14 +33,11 @@ public class BookFragment extends BaseFragment {
|
|||||||
@Named("MainBook")
|
@Named("MainBook")
|
||||||
Book mBook;
|
Book mBook;
|
||||||
@Inject
|
@Inject
|
||||||
VerseLookup verseLookup;
|
PublishSubject<BookScrollEvent> scrollEventProvider;
|
||||||
|
|
||||||
@InjectView(R.id.book_content)
|
@InjectView(R.id.book_content)
|
||||||
RecyclerView bookContent;
|
RecyclerView bookContent;
|
||||||
|
|
||||||
|
|
||||||
PublishSubject<String> titleReceiver = PublishSubject.create();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new instance of this fragment for the given book.
|
* Returns a new instance of this fragment for the given book.
|
||||||
*/
|
*/
|
||||||
@ -101,7 +91,10 @@ public class BookFragment extends BaseFragment {
|
|||||||
((BibleViewer)getActivity()).setActionBarTitle(b.getInitials());
|
((BibleViewer)getActivity()).setActionBarTitle(b.getInitials());
|
||||||
|
|
||||||
final RecyclerView.LayoutManager manager = new LinearLayoutManager(getActivity());
|
final RecyclerView.LayoutManager manager = new LinearLayoutManager(getActivity());
|
||||||
|
BookAdapter adapter = new BookAdapter(b);
|
||||||
bookContent.setLayoutManager(manager);
|
bookContent.setLayoutManager(manager);
|
||||||
bookContent.setAdapter(new BookAdapter(b));
|
bookContent.setAdapter(adapter);
|
||||||
|
|
||||||
|
adapter.bindScrollHandler(scrollEventProvider, manager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,8 @@ import android.content.Context
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.support.annotation.IdRes
|
import android.support.annotation.IdRes
|
||||||
|
import android.widget.ExpandableListView
|
||||||
|
import rx.subjects.PublishSubject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by bspeice on 10/24/14.
|
* Created by bspeice on 10/24/14.
|
||||||
@ -25,6 +27,22 @@ class BibleMenu(val b: Book) : BaseExpandableListAdapter() {
|
|||||||
Pair(it, b.getVersification().getLastChapter(it))
|
Pair(it, b.getVersification().getLastChapter(it))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The listener that should be registered to receive click events
|
||||||
|
* It's created here because we need access to the menuMappings
|
||||||
|
*/
|
||||||
|
fun getMenuClickListener(listener: PublishSubject<BookScrollEvent>) =
|
||||||
|
object : ExpandableListView.OnChildClickListener {
|
||||||
|
override fun onChildClick(listView: ExpandableListView?, childView: View?,
|
||||||
|
groupPosition: Int, childPosition: Int, id: Long): Boolean {
|
||||||
|
|
||||||
|
val map = menuMappings[groupPosition]
|
||||||
|
listener onNext BookScrollEvent(map.first, map.second)
|
||||||
|
|
||||||
|
return true; // Event was handled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var groupHighlighted: Int = 0
|
var groupHighlighted: Int = 0
|
||||||
var childHighlighted: Int = 0
|
var childHighlighted: Int = 0
|
||||||
|
|
||||||
@ -82,4 +100,4 @@ class BibleMenu(val b: Book) : BaseExpandableListAdapter() {
|
|||||||
content setTextColor getHighlightedColor(highlighted)
|
content setTextColor getHighlightedColor(highlighted)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,6 @@ package org.bspeice.minimalbible.activity.viewer
|
|||||||
import android.support.v7.widget.RecyclerView
|
import android.support.v7.widget.RecyclerView
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import org.crosswire.jsword.book.Book
|
import org.crosswire.jsword.book.Book
|
||||||
import org.crosswire.jsword.passage.Verse
|
|
||||||
import android.view.View
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import org.bspeice.minimalbible.R
|
import org.bspeice.minimalbible.R
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
@ -13,14 +11,15 @@ import org.crosswire.jsword.book.getVersification
|
|||||||
import org.crosswire.jsword.versification.getBooks
|
import org.crosswire.jsword.versification.getBooks
|
||||||
import org.crosswire.jsword.versification.BibleBook
|
import org.crosswire.jsword.versification.BibleBook
|
||||||
import org.bspeice.minimalbible.activity.viewer.BookAdapter.ChapterInfo
|
import org.bspeice.minimalbible.activity.viewer.BookAdapter.ChapterInfo
|
||||||
import android.util.Log
|
import rx.subjects.PublishSubject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapter used for displaying a book
|
* Adapter used for displaying a book
|
||||||
* Displays one chapter at a time,
|
* Displays one chapter at a time,
|
||||||
* as each TextView widget is it's own line break
|
* as each TextView widget is it's own line break
|
||||||
*/
|
*/
|
||||||
class BookAdapter(val b: Book) : RecyclerView.Adapter<PassageView>() {
|
class BookAdapter(val b: Book)
|
||||||
|
: RecyclerView.Adapter<PassageView>() {
|
||||||
|
|
||||||
val versification = b.getVersification()
|
val versification = b.getVersification()
|
||||||
val bookList = versification.getBooks()
|
val bookList = versification.getBooks()
|
||||||
@ -48,7 +47,7 @@ class BookAdapter(val b: Book) : RecyclerView.Adapter<PassageView>() {
|
|||||||
val verseCount = versification.getLastVerse(currentBook, it)
|
val verseCount = versification.getLastVerse(currentBook, it)
|
||||||
ChapterInfo(b, it, currentBook, firstVerse, firstVerse + verseCount)
|
ChapterInfo(b, it, currentBook, firstVerse, firstVerse + verseCount)
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* I'm not sure what the position argument actually represents,
|
* I'm not sure what the position argument actually represents,
|
||||||
@ -73,6 +72,19 @@ class BookAdapter(val b: Book) : RecyclerView.Adapter<PassageView>() {
|
|||||||
* Get the number of chapters in the book
|
* Get the number of chapters in the book
|
||||||
*/
|
*/
|
||||||
override fun getItemCount(): Int = chapterCount
|
override fun getItemCount(): Int = chapterCount
|
||||||
|
|
||||||
|
fun bindScrollHandler(provider: PublishSubject<BookScrollEvent>,
|
||||||
|
lM: RecyclerView.LayoutManager) {
|
||||||
|
provider subscribe {
|
||||||
|
val event = it
|
||||||
|
chapterList.withIndices()
|
||||||
|
.filter {
|
||||||
|
event.b == it.second.bibleBook &&
|
||||||
|
event.chapter == it.second.chapter
|
||||||
|
}
|
||||||
|
.forEach { lM scrollToPosition it.first }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PassageView(val v: TextView) : RecyclerView.ViewHolder(v) {
|
class PassageView(val v: TextView) : RecyclerView.ViewHolder(v) {
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
package org.bspeice.minimalbible.activity.viewer
|
||||||
|
|
||||||
|
import org.crosswire.jsword.versification.BibleBook
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by bspeice on 11/26/14.
|
||||||
|
*/
|
||||||
|
data class BookScrollEvent(val b: BibleBook, val chapter: Int) {}
|
Loading…
Reference in New Issue
Block a user