Search in sources :

Example 76 with Fragment

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);
    }
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) Fragment(android.support.v4.app.Fragment)

Example 77 with Fragment

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;
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) SearchTabPagerFragment(com.wm.remusic.fragmentnet.SearchTabPagerFragment)

Example 78 with Fragment

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;
    }
}
Also used : RoundFragment(com.wm.remusic.fragment.RoundFragment) LinearInterpolator(android.view.animation.LinearInterpolator) ViewGroup(android.view.ViewGroup) AnimatorSet(android.animation.AnimatorSet) PlayQueueFragment(com.wm.remusic.fragment.PlayQueueFragment) Fragment(android.support.v4.app.Fragment) RoundFragment(com.wm.remusic.fragment.RoundFragment) SimpleMoreFragment(com.wm.remusic.fragment.SimpleMoreFragment) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) LrcView(com.wm.remusic.lrc.LrcView)

Example 79 with Fragment

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();
        }
    }
}
Also used : ObservableRecyclerView(com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView) ArtistInfoFragment(com.wm.remusic.fragmentnet.ArtistInfoFragment) ArtistInfoMusicFragment(com.wm.remusic.fragmentnet.ArtistInfoMusicFragment) Fragment(android.support.v4.app.Fragment) ImageView(android.widget.ImageView) ObservableRecyclerView(com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) TextView(android.widget.TextView)

Example 80 with Fragment

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);
            }
        }
    }
}
Also used : ObservableRecyclerView(com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView) ArtistInfoFragment(com.wm.remusic.fragmentnet.ArtistInfoFragment) ArtistInfoMusicFragment(com.wm.remusic.fragmentnet.ArtistInfoMusicFragment) Fragment(android.support.v4.app.Fragment) ImageView(android.widget.ImageView) ObservableRecyclerView(com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) TextView(android.widget.TextView)

Aggregations

Fragment (android.support.v4.app.Fragment)617 FragmentTransaction (android.support.v4.app.FragmentTransaction)220 Bundle (android.os.Bundle)140 View (android.view.View)129 FragmentManager (android.support.v4.app.FragmentManager)115 DialogFragment (android.support.v4.app.DialogFragment)77 TextView (android.widget.TextView)55 FragmentInstruction (de.madcyph3r.example.example.FragmentInstruction)48 MaterialMenu (de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu)48 MaterialItemSectionFragment (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment)48 FragmentDummy (de.madcyph3r.example.example.FragmentDummy)43 Intent (android.content.Intent)39 ViewPager (android.support.v4.view.ViewPager)35 FragmentActivity (android.support.v4.app.FragmentActivity)34 BaseFragment (com.waz.zclient.pages.BaseFragment)29 ImageView (android.widget.ImageView)27 FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)25 Button (android.widget.Button)24 ArrayList (java.util.ArrayList)24 FragmentStatePagerAdapter (android.support.v4.app.FragmentStatePagerAdapter)21