Beispiel #1
0
 @Override
 protected boolean handleOnBackPressed() {
   Log.e(TAG, "Handleing back press");
   // Return to the FILE_INDEX fragment
   int currentFragmentIndex = mViewPager.getCurrentItem();
   if (currentFragmentIndex == RepcastPageAdapter.TORRENT_INDEX) {
     mViewPager.setCurrentItem(RepcastPageAdapter.FILE_INDEX);
     return true;
   }
   // Clear the selectFileFragment search term
   RepcastFragment selectFileFragment =
       mPagerAdapter.getRegisteredFragment(RepcastPageAdapter.FILE_INDEX);
   if (!TextUtils.isEmpty(selectFileFragment.getResultEmptyString())) {
     selectFileFragment.onQueryChange(null);
     return true;
   }
   RepcastFragment currentFragment = mPagerAdapter.getRegisteredFragment(currentFragmentIndex);
   Parcelable previousFragmentData = removeFragmentFromABackStack(currentFragment.getClass());
   if (previousFragmentData == null) {
     return false;
   }
   mPagerAdapter.updatePageAtIndex(mViewPager.getCurrentItem(), previousFragmentData);
   setTitleBasedOnFragment();
   return true;
 }
Beispiel #2
0
 @Override
 protected boolean onQuerySubmit(String query) {
   // Propagate query submit only to the current fragment.
   RepcastFragment fragment = mPagerAdapter.getRegisteredFragment(mViewPager.getCurrentItem());
   fragment.onQuerySubmit(query);
   return true;
 }
Beispiel #3
0
 @Override
 public void setTitleBasedOnFragment() {
   RepcastFragment frag = mPagerAdapter.getRegisteredFragment(mViewPager.getCurrentItem());
   if (frag != null) {
     String name = frag.getName();
     getSupportActionBar().setTitle(name);
   }
 }
Beispiel #4
0
 @Override
 protected void doShowContent(Parcelable data) {
   int pageIndex = -1;
   if (data instanceof JsonDirectory.JsonFileDir) {
     Log.e(TAG, "Showing File data of:" + ((JsonDirectory.JsonFileDir) data).name);
     pageIndex = RepcastPageAdapter.FILE_INDEX;
   }
   if (data instanceof JsonTorrent.JsonTorrentResult) {
     pageIndex = RepcastPageAdapter.TORRENT_INDEX;
   }
   if (pageIndex == -1) {
     Log.e(TAG, "Unexpected data type. Class:" + data.getClass() + " String:" + data);
   }
   mPagerAdapter.updatePageAtIndex(pageIndex, data);
   addFragmentToABackStack(data);
   setTitleBasedOnFragment();
 }
Beispiel #5
0
 @Override
 protected void onQueryChanged(String query) {
   // Propagate query changed to all fragments.
   RepcastFragment fragment = mPagerAdapter.getRegisteredFragment(mViewPager.getCurrentItem());
   fragment.onQueryChange(query);
 }