use of android.support.v4.app.Fragment in project Fragmentation by YoKeyword.
the class SupportFragment method dispatchSupportVisible.
private void dispatchSupportVisible(boolean visible) {
mIsSupportVisible = visible;
if (!mNeedDispatch) {
mNeedDispatch = true;
} else {
FragmentManager fragmentManager = getChildFragmentManager();
if (fragmentManager != null) {
List<Fragment> childFragments = fragmentManager.getFragments();
if (childFragments != null) {
for (Fragment child : childFragments) {
if (child instanceof SupportFragment && !child.isHidden() && child.getUserVisibleHint()) {
((SupportFragment) child).dispatchSupportVisible(visible);
}
}
}
}
}
if (visible) {
if (mIsFirstVisible) {
mIsFirstVisible = false;
onLazyInitView(mSaveInstanceState);
dispatchFragmentLifecycle(LifecycleHelper.LIFECYLCE_ONLAZYINITVIEW, null, false);
}
onSupportVisible();
if (_mActivity != null) {
_mActivity.setFragmentClickable(true);
}
dispatchFragmentLifecycle(LifecycleHelper.LIFECYLCE_ONSUPPORTVISIBLE, null, true);
} else {
onSupportInvisible();
dispatchFragmentLifecycle(LifecycleHelper.LIFECYLCE_ONSUPPORTINVISIBLE, null, false);
}
}
use of android.support.v4.app.Fragment in project remusic by aa112901.
the class NetSearchWordsActivity method onQueryTextSubmit.
@Override
public boolean onQueryTextSubmit(final String query) {
hideInputManager();
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
SearchTabPagerFragment fragment = SearchTabPagerFragment.newInstance(0, query);
ft.replace(R.id.search_frame, fragment).commitAllowingStateLoss();
return true;
}
use of android.support.v4.app.Fragment in project remusic by aa112901.
the class PlayingActivity method updateTrackInfo.
public void updateTrackInfo() {
if (MusicPlayer.getQueueSize() == 0) {
return;
}
Fragment fragment = (RoundFragment) mViewPager.getAdapter().instantiateItem(mViewPager, mViewPager.getCurrentItem());
if (fragment != null) {
View v = fragment.getView();
if (mViewWeakReference.get() != v && v != null) {
((ViewGroup) v).setAnimationCacheEnabled(false);
if (mViewWeakReference != null)
mViewWeakReference.clear();
mViewWeakReference = new WeakReference<View>(v);
mActiveView = mViewWeakReference.get();
}
}
if (mActiveView != null) {
// animatorWeakReference = new WeakReference<>((ObjectAnimator) mActiveView.getTag(R.id.tag_animator));
// mRotateAnim = animatorWeakReference.get();
mRotateAnim = (ObjectAnimator) mActiveView.getTag(R.id.tag_animator);
}
//mProgress.setMax((int) MusicPlayer.mDuration());
mAnimatorSet = new AnimatorSet();
if (MusicPlayer.isPlaying()) {
mProgress.removeCallbacks(mUpdateProgress);
mProgress.postDelayed(mUpdateProgress, 200);
mControl.setImageResource(R.drawable.play_rdi_btn_pause);
if (mAnimatorSet != null && mRotateAnim != null && !mRotateAnim.isRunning()) {
//修复从playactivity回到Main界面null
if (mNeedleAnim == null) {
mNeedleAnim = ObjectAnimator.ofFloat(mNeedle, "rotation", -30, 0);
mNeedleAnim.setDuration(200);
mNeedleAnim.setRepeatMode(0);
mNeedleAnim.setInterpolator(new LinearInterpolator());
}
mAnimatorSet.play(mNeedleAnim).before(mRotateAnim);
mAnimatorSet.start();
}
} else {
mProgress.removeCallbacks(mUpdateProgress);
mControl.setImageResource(R.drawable.play_rdi_btn_play);
if (mNeedleAnim != null) {
mNeedleAnim.reverse();
mNeedleAnim.end();
}
if (mRotateAnim != null && mRotateAnim.isRunning()) {
mRotateAnim.cancel();
float valueAvatar = (float) mRotateAnim.getAnimatedValue();
mRotateAnim.setFloatValues(valueAvatar, 360f + valueAvatar);
}
}
isNextOrPreSetPage = false;
if (MusicPlayer.getQueuePosition() + 1 != mViewPager.getCurrentItem()) {
mViewPager.setCurrentItem(MusicPlayer.getQueuePosition() + 1);
isNextOrPreSetPage = true;
}
}
use of android.support.v4.app.Fragment in project remusic by aa112901.
the class ArtistDetailActivity method onUpOrCancelMotionEvent.
@Override
public void onUpOrCancelMotionEvent(ScrollState scrollState) {
mBaseTranslationY = 0;
Fragment fragment = getCurrentFragment();
if (fragment == null) {
return;
}
View view = fragment.getView();
if (view == null) {
return;
}
int toolbarHeight = mHeaderView.getHeight() - mActionBarSize - mStatusSize - tabLayout.getHeight();
final ObservableRecyclerView listView = (ObservableRecyclerView) view.findViewById(R.id.scroll);
if (listView == null) {
return;
}
int scrollY = listView.getCurrentScrollY();
if (scrollState == ScrollState.DOWN) {
showToolbar();
} else if (scrollState == ScrollState.UP) {
if (toolbarHeight <= scrollY) {
hideToolbar();
} else {
showToolbar();
}
} else {
// Even if onScrollChanged occurs without scrollY changing, toolbar should be adjusted
if (toolbarIsShown() || toolbarIsHidden()) {
// Toolbar is completely moved, so just keep its state
// and propagate it to other pages
propagateToolbarState(toolbarIsShown());
} else {
// Toolbar is moving but doesn't know which to move:
// you can change this to hideToolbar()
showToolbar();
}
}
}
use of android.support.v4.app.Fragment in project remusic by aa112901.
the class ArtistDetailActivity method propagateToolbarState.
private void propagateToolbarState(boolean isShown) {
int toolbarHeight = mHeaderView.getHeight() - mActionBarSize - mStatusSize - tabLayout.getHeight();
// Set scrollY for the fragments that are not created yet
mPagerAdapter.setScrollY(isShown ? 0 : toolbarHeight);
// Set scrollY for the active fragments
for (int i = 0; i < mPagerAdapter.getCount(); i++) {
// Skip current item
if (i == mPager.getCurrentItem()) {
continue;
}
// Skip destroyed or not created item
Fragment f = mPagerAdapter.getItemAt(i);
if (f == null) {
continue;
}
View view = f.getView();
if (view == null) {
continue;
}
ObservableRecyclerView listView = (ObservableRecyclerView) view.findViewById(R.id.scroll);
if (listView == null) {
continue;
}
if (isShown) {
// Scroll up
if (0 < listView.getCurrentScrollY()) {
listView.scrollVerticallyToPosition(0);
}
} else {
// Scroll down (to hide padding)
if (listView.getCurrentScrollY() < toolbarHeight) {
listView.scrollVerticallyToPosition(1);
}
}
}
}
Aggregations