Ejemplo n.º 1
0
 private void reloadData(int position, int verse) {
   ReadingFragment fragment = (ReadingFragment) mAdapter.instantiateItem(mPager, position);
   if (verse > 0) {
     fragment.setForceVerse(verse);
   }
   Bundle bundle = fragment.getArguments();
   if (bundle != null) {
     bundle.putAll(mAdapter.getData(position));
     fragment.reloadData();
   }
 }
Ejemplo n.º 2
0
 private void refresh() {
   int position = getCurrentPosition();
   String osis = getCurrentOsis();
   mAdapter.setData(position, retrieveOsis(position, osis));
   updateVersion();
   prepare(position);
   reload(position);
 }
Ejemplo n.º 3
0
 private void reload(int position) {
   reloadData(position);
   if (position > 0) {
     reloadData(position - 1);
   }
   if (position < mAdapter.getCount() - 1) {
     reloadData(position + 1);
   }
 }
Ejemplo n.º 4
0
 protected final void prepare(int position) {
   Bundle bundle = mAdapter.getData(position);
   String osis = bundle.getString(OSIS);
   if (!TextUtils.isEmpty(osis)) {
     updateHeader(bundle, osis);
     prepareNext(position, bundle.getString(NEXT));
     preparePrev(position, bundle.getString(PREV));
   }
 }
Ejemplo n.º 5
0
 @Override
 public void onRestart() {
   super.onRestart();
   fontPath = BibleUtils.getFontPath(this);
   if (!ObjectUtils.isIdentical(
       fontPath, mAdapter.getData(getCurrentPosition()).getString(FONT_PATH))) {
     refresh();
   }
 }
Ejemplo n.º 6
0
  private void jump(String osis, String verse) {
    Bundle bundle = retrieveOsis(POSITION_UNKNOWN, osis);
    bundle.putString(VERSE, verse);
    bundle.putString(VERSE_START, verse);
    int oldPosition = getCurrentPosition();
    int position = bundle.getInt(ID) - 1;
    mAdapter.setData(position, bundle);
    prepare(position);

    mPager.setCurrentItem(position);

    // if it's cached, then reloaded
    if (Math.abs(oldPosition - position) <= mPager.getOffscreenPageLimit()) {
      reloadData(position, NumberUtils.parseInt(verse));
    }
  }
Ejemplo n.º 7
0
  protected final void initialize() {
    initializeHeader(mHeader);

    mPager.setAdapter(mAdapter);
    mPager.addOnPageChangeListener(this);

    int position = getInitialPosition();
    String osis = getInitialOsis();
    Bundle bundle = retrieveOsis(position, osis);
    if (position == POSITION_UNKNOWN) {
      position = bundle.getInt(ID) - 1;
    }
    mAdapter.setData(position, bundle);
    updateVersion();
    prepare(position);

    mPager.setCurrentItem(position);
  }
Ejemplo n.º 8
0
 private void prepare(int position, String osis) {
   Bundle bundle = mAdapter.getData(position);
   bundle.putString(OSIS, osis);
   bundle.putAll(retrieveOsis(position, osis));
 }
Ejemplo n.º 9
0
 private void prepareNext(int position, String osis) {
   int nextPosition = position + 1;
   if (nextPosition < mAdapter.getCount()) {
     prepare(nextPosition, osis);
   }
 }
Ejemplo n.º 10
0
 protected final String getCurrentOsis() {
   return mAdapter.getData(getCurrentPosition()).getString(OSIS);
 }