Search in sources :

Example 21 with SimpleItemAnimator

use of android.support.v7.widget.SimpleItemAnimator in project remusic by aa112901.

the class MainFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_main, container, false);
    swipeRefresh = (SwipeRefreshLayout) view.findViewById(R.id.swiperefresh);
    recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
    layoutManager = new LinearLayoutManager(mContext);
    recyclerView.setLayoutManager(layoutManager);
    // swipeRefresh.setColorSchemeResources(R.color.theme_color_PrimaryAccent);
    swipeRefresh.setColorSchemeColors(ThemeUtils.getColorById(mContext, R.color.theme_color_primary));
    swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            reloadAdapter();
        }
    });
    // 先给adapter设置空数据,异步加载好后更新数据,防止Recyclerview no attach
    mAdapter = new MainFragmentAdapter(mContext);
    recyclerView.setAdapter(mAdapter);
    recyclerView.setHasFixedSize(true);
    recyclerView.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST));
    // 设置没有item动画
    ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    reloadAdapter();
    mContext.getWindow().setBackgroundDrawableResource(R.color.background_material_light_1);
    return view;
}
Also used : SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) MainFragmentAdapter(com.wm.remusic.adapter.MainFragmentAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(com.wm.remusic.widget.DividerItemDecoration) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout)

Example 22 with SimpleItemAnimator

use of android.support.v7.widget.SimpleItemAnimator in project remusic by aa112901.

the class ArtistFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.recylerview, container, false);
    recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
    layoutManager = new LinearLayoutManager(mContext);
    recyclerView.setLayoutManager(layoutManager);
    // fastScroller = (FastScroller) view.findViewById(R.id.fastscroller);
    // new loadArtists().execute("");
    mAdapter = new ArtistAdapter(null);
    recyclerView.setAdapter(mAdapter);
    recyclerView.setHasFixedSize(true);
    ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    setItemDecoration();
    isAZSort = mPreferences.getArtistSortOrder().equals(SortOrder.ArtistSortOrder.ARTIST_A_Z);
    dialogText = (TextView) view.findViewById(R.id.dialog_text);
    sideBar = (SideBar) view.findViewById(R.id.sidebar);
    sideBar.setOnTouchingLetterChangedListener(new SideBar.OnTouchingLetterChangedListener() {

        @Override
        public void onTouchingLetterChanged(String s) {
            dialogText.setText(s);
            sideBar.setView(dialogText);
            Log.e("scrol", "  " + s);
            if (positionMap.get(s) != null) {
                int i = positionMap.get(s);
                Log.e("scrolget", "  " + i);
                ((LinearLayoutManager) recyclerView.getLayoutManager()).scrollToPositionWithOffset(i, 0);
            }
        }
    });
    reloadAdapter();
    return view;
}
Also used : SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) TintImageView(com.bilibili.magicasakura.widgets.TintImageView) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) SideBar(com.wm.remusic.widget.SideBar)

Example 23 with SimpleItemAnimator

use of android.support.v7.widget.SimpleItemAnimator in project ChatExchange by HueToYou.

the class MainActivity method setup.

private void setup() {
    final FloatingActionMenu fam = findViewById(R.id.chat_slide_menu);
    FloatingActionButton floatingActionButton = findViewById(R.id.add_chat_fab);
    floatingActionButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mainActivityUtils.showAddTabDialog();
            fam.close(true);
        }
    });
    FloatingActionButton fab = findViewById(R.id.home_fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            mHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    Log.e("POS", "DEFL");
                    fragStuff.setFragmentByTag("home");
                }
            }, getResources().getInteger(R.integer.animation_duration_ms));
            // doCloseAnimationForDrawerToggle(mDrawerButton);
            mChatroomSlidingMenu.toggle();
            fam.close(false);
        }
    });
    mRequestFactory = new RequestFactory();
    mAccountManager = AccountManager.get(this);
    AccountManagerCallback<Bundle> accountManagerCallback = new AccountManagerCallback<Bundle>() {

        @Override
        public void run(AccountManagerFuture<Bundle> accountManagerFuture) {
            Log.e("AUtH", "AAA");
            String authToken = "";
            try {
                authToken = accountManagerFuture.getResult().getString(AccountManager.KEY_AUTHTOKEN);
                Log.e("Auth", authToken);
            } catch (Exception e) {
                e.printStackTrace();
                Log.e("RI", "P");
            }
            mRequestFactory = new RequestFactory(authToken);
            mCookieString = authToken;
            Log.e("AUTHTOKEN", authToken);
            CookieSyncManager.createInstance(MainActivity.this);
            CookieManager cookieManager = CookieManager.getInstance();
            cookieManager.setAcceptCookie(true);
            if (authToken != null) {
                cookieManager.removeSessionCookie();
                cookieManager.setCookie("https://stackexchange.com", authToken);
                CookieSyncManager.getInstance().sync();
            }
            fragStuff.doFragmentStuff();
        }
    };
    Set<String> seChatsTemp = mSharedPrefs.getStringSet("SEChatIDs", new HashSet<String>());
    Set<String> soChatsTemp = mSharedPrefs.getStringSet("SOChatIDs", new HashSet<String>());
    chatDataBundle.mSOChatIDs = new HashSet<>(soChatsTemp);
    chatDataBundle.mSEChatIDs = new HashSet<>(seChatsTemp);
    if (mSharedPrefs.getBoolean("isFirstRun", true)) {
        Intent intent = new Intent(this, IntroActivity.class);
        startActivity(intent);
        finish();
    } else if (mAccountManager.getAccounts().length < 1) {
        startActivity(new Intent(this, AuthenticatorActivity.class));
        finish();
    } else {
        if (mFragmentManager.findFragmentByTag("home") == null) {
            mFragmentManager.beginTransaction().add(R.id.content_main, new HomeFragment(), "home").commit();
        }
        mAccountManager.getAuthToken(mAccountManager.getAccounts()[0], Authenticator.ACCOUNT_TYPE, null, true, accountManagerCallback, null);
    }
    mainActivityUtils.respondToNotificationClick();
    mainActivityUtils.setupACBR();
    mItemClickedListener = new RecyclerAdapter.OnItemClicked() {

        @Override
        public void onClick(View view, int position) {
            Log.e("CLICKED", position + "");
            mCurrentFragment = mWrappedAdapter.getItemAt(position).getUrl();
            // doCloseAnimationForDrawerToggle(mDrawerButton);
            getmChatroomSlidingMenu().toggle();
            mHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    fragStuff.setFragmentByTag(mCurrentFragment);
                }
            }, getResources().getInteger(R.integer.animation_duration_ms));
        }

        @Override
        public void onCloseClick(View view, int position) {
            mainActivityUtils.confirmClose(position);
        }
    };
    chatroomsList = findViewById(R.id.chatroomsListView);
    mSwipeManager = new RecyclerViewSwipeManager();
    mWrappedAdapter = new RecyclerAdapter(this, mItemClickedListener, mSwipeManager);
    mAdapter = mSwipeManager.createWrappedAdapter(mWrappedAdapter);
    chatroomsList.setAdapter(mAdapter);
    // disable change animations
    ((SimpleItemAnimator) chatroomsList.getItemAnimator()).setSupportsChangeAnimations(false);
    mSwipeManager.attachRecyclerView(chatroomsList);
    DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(chatroomsList.getContext(), DividerItemDecoration.VERTICAL);
    chatroomsList.addItemDecoration(dividerItemDecoration);
    assert getSupportActionBar() != null;
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    drawable = VectorDrawableCompat.create(getResources(), R.drawable.ic_menu_black_24dp, null);
    drawable.setTintList(ColorStateList.valueOf(Color.rgb(255, 255, 255)));
    getSupportActionBar().setHomeAsUpIndicator(drawable);
    fam.hideMenuButton(false);
    mActionBar = (Toolbar) Utils.getActionBar(getWindow().getDecorView());
    assert mActionBar != null;
    Log.e("ACTIONBAR", mActionBar.getClass().toString());
    // mActionBar.removeViewAt(1);
    // mActionBar.addView(newDrawer, 1);
    mDrawerButton = (AppCompatImageButton) mActionBar.getChildAt(1);
    ObjectAnimator closeAnimator = ObjectAnimator.ofFloat(mDrawerButton, "rotation", 180f, 0f);
    mCloseAnimSet.play(closeAnimator);
    mCloseAnimSet.setInterpolator(new AnticipateInterpolator());
    mCloseAnimSet.setDuration((long) Utils.getAnimDuration(getResources().getInteger(R.integer.animation_duration_ms), MainActivity.this));
    ObjectAnimator openAnimator = ObjectAnimator.ofFloat(mDrawerButton, "rotation", -180f, 0f);
    mOpenAnimSet.play(openAnimator);
    mOpenAnimSet.setInterpolator(new OvershootInterpolator());
    mOpenAnimSet.setDuration((long) Utils.getAnimDuration(getResources().getInteger(R.integer.animation_duration_ms), MainActivity.this));
    mDrawerButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Log.e("CLICKED", "CLICKED");
            onSupportNavigateUp();
        }
    });
    mChatroomSlidingMenu.setOnCloseListener(new SlidingMenu.OnCloseListener() {

        @Override
        public void onClose() {
            fam.close(false);
            fam.hideMenuButton(false);
            doCloseAnimationForDrawerToggle(mDrawerButton);
        }
    });
    mChatroomSlidingMenu.setOnOpenListener(new SlidingMenu.OnOpenListener() {

        @Override
        public void onOpen() {
            doOpenAnimationForDrawerToggle(mDrawerButton);
            mHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    fam.showMenuButton(true);
                }
            }, getResources().getInteger(R.integer.animation_duration_ms) - 400);
        }
    });
    mChatroomSlidingMenu.setOnOpenedListener(new SlidingMenu.OnOpenedListener() {

        @Override
        public void onOpened() {
            TutorialStuff.showChatSliderTutorial_MainActivity(MainActivity.this);
        }
    });
    Log.e("FEATURE", String.valueOf(getWindow().hasFeature(Window.FEATURE_OPTIONS_PANEL)));
    mActionMenuView = (ActionMenuView) mActionBar.getChildAt(2);
    oncreatejustcalled = true;
    // forces options menu overflow icon to show on devices with physical menu keys
    try {
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if (menuKeyField != null) {
            menuKeyField.setAccessible(true);
            menuKeyField.setBoolean(config, false);
        }
    } catch (Exception e) {
    // presumably, not relevant
    }
}
Also used : AccountManagerCallback(android.accounts.AccountManagerCallback) AccountManagerFuture(android.accounts.AccountManagerFuture) HomeFragment(com.huetoyou.chatexchange.ui.frags.HomeFragment) FloatingActionMenu(com.github.clans.fab.FloatingActionMenu) SlidingMenu(com.jeremyfeinstein.slidingmenu.lib.SlidingMenu) ViewConfiguration(android.view.ViewConfiguration) Field(java.lang.reflect.Field) RequestFactory(com.huetoyou.chatexchange.net.RequestFactory) FloatingActionButton(com.github.clans.fab.FloatingActionButton) CookieManager(android.webkit.CookieManager) RecyclerViewSwipeManager(com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager) SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) OvershootInterpolator(android.view.animation.OvershootInterpolator) Bundle(android.os.Bundle) ChatDataBundle(com.huetoyou.chatexchange.ui.misc.ChatDataBundle) ObjectAnimator(android.animation.ObjectAnimator) Intent(android.content.Intent) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) View(android.view.View) CustomRecyclerView(com.huetoyou.chatexchange.ui.misc.CustomRecyclerView) ActionMenuView(android.support.v7.widget.ActionMenuView) RecyclerView(android.support.v7.widget.RecyclerView) AnticipateInterpolator(android.view.animation.AnticipateInterpolator) RecyclerAdapter(com.huetoyou.chatexchange.ui.misc.RecyclerAdapter)

Example 24 with SimpleItemAnimator

use of android.support.v7.widget.SimpleItemAnimator in project JustAndroid by chinaltz.

the class PictureSelectorActivity method initView.

/**
 * init views
 */
private void initView(Bundle savedInstanceState) {
    preview_textColor = AttrsUtils.getTypeValueColor(this, R.attr.picture_preview_textColor);
    complete_textColor = AttrsUtils.getTypeValueColor(this, R.attr.picture_complete_textColor);
    rl_picture_title = (RelativeLayout) findViewById(R.id.rl_picture_title);
    picture_left_back = (ImageView) findViewById(R.id.picture_left_back);
    picture_title = (TextView) findViewById(R.id.picture_title);
    picture_right = (TextView) findViewById(R.id.picture_right);
    picture_tv_ok = (TextView) findViewById(R.id.picture_tv_ok);
    picture_id_preview = (TextView) findViewById(R.id.picture_id_preview);
    picture_tv_img_num = (TextView) findViewById(R.id.picture_tv_img_num);
    picture_recycler = (RecyclerView) findViewById(R.id.picture_recycler);
    rl_bottom = (RelativeLayout) findViewById(R.id.rl_bottom);
    id_ll_ok = (LinearLayout) findViewById(R.id.id_ll_ok);
    tv_empty = (TextView) findViewById(R.id.tv_empty);
    rl_bottom.setVisibility(selectionMode == PictureConfig.SINGLE ? View.GONE : View.VISIBLE);
    isNumComplete(numComplete);
    if (mimeType == PictureMimeType.ofAll()) {
        popupWindow = new PhotoPopupWindow(this);
        popupWindow.setOnItemClickListener(this);
    }
    picture_id_preview.setOnClickListener(this);
    picture_id_preview.setVisibility(mimeType == PictureConfig.TYPE_VIDEO ? View.GONE : View.VISIBLE);
    picture_left_back.setOnClickListener(this);
    picture_right.setOnClickListener(this);
    id_ll_ok.setOnClickListener(this);
    picture_title.setOnClickListener(this);
    picture_title.setText(getString(R.string.picture_camera_roll));
    folderWindow = new FolderPopWindow(this);
    folderWindow.setPictureTitleView(picture_title);
    folderWindow.setOnItemClickListener(this);
    picture_recycler.setHasFixedSize(true);
    picture_recycler.addItemDecoration(new GridSpacingItemDecoration(spanCount, ScreenUtils.dip2px(this, 2), false));
    picture_recycler.setLayoutManager(new GridLayoutManager(this, spanCount));
    // 解决调用 notifyItemChanged 闪烁问题,取消默认动画
    ((SimpleItemAnimator) picture_recycler.getItemAnimator()).setSupportsChangeAnimations(false);
    mediaLoader = new LocalMediaLoader(this, mimeType, isGif, videoSecond);
    rxPermissions.request(Manifest.permission.READ_EXTERNAL_STORAGE).subscribe(new Observer<Boolean>() {

        @Override
        public void onSubscribe(Disposable d) {
        }

        @Override
        public void onNext(Boolean aBoolean) {
            showPleaseDialog();
            if (aBoolean) {
                readLocalMedia();
            } else {
                showToast(getString(R.string.picture_jurisdiction));
                dismissDialog();
            }
        }

        @Override
        public void onError(Throwable e) {
        }

        @Override
        public void onComplete() {
        }
    });
    StringUtils.tempTextFont(tv_empty);
    if (savedInstanceState != null) {
        // 防止拍照内存不足时activity被回收,导致拍照后的图片未选中
        selectionMedias = PictureSelector.obtainSelectorList(savedInstanceState);
    }
    adapter = new PictureImageGridAdapter(mContext, config);
    adapter.bindSelectImages(selectionMedias);
    changeImageNumber(selectionMedias);
    picture_recycler.setAdapter(adapter);
    adapter.setOnPhotoSelectChangedListener(PictureSelectorActivity.this);
    String titleText = picture_title.getText().toString().trim();
    if (isCamera) {
        isCamera = StringUtils.isCamera(titleText);
    }
}
Also used : FolderPopWindow(com.ningcui.mylibrary.viewLib.Imagepicker.widget.FolderPopWindow) Disposable(io.reactivex.disposables.Disposable) SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) LocalMediaLoader(com.ningcui.mylibrary.viewLib.Imagepicker.model.LocalMediaLoader) GridLayoutManager(android.support.v7.widget.GridLayoutManager) PictureImageGridAdapter(com.ningcui.mylibrary.viewLib.Imagepicker.adapter.PictureImageGridAdapter) PhotoPopupWindow(com.ningcui.mylibrary.viewLib.Imagepicker.widget.PhotoPopupWindow) GridSpacingItemDecoration(com.ningcui.mylibrary.viewLib.Imagepicker.decoration.GridSpacingItemDecoration)

Example 25 with SimpleItemAnimator

use of android.support.v7.widget.SimpleItemAnimator in project TicktockMusic by Lauzy.

the class PlayQueueBottomSheetFragment method setUpRv.

private void setUpRv(View view) {
    RecyclerView rvPlayQueue = (RecyclerView) view.findViewById(R.id.rv_play_queue);
    rvPlayQueue.setLayoutManager(new LinearLayoutManager(mActivity));
    ((SimpleItemAnimator) rvPlayQueue.getItemAnimator()).setSupportsChangeAnimations(false);
    mAdapter = new PlayQueueAdapter(R.layout.layout_play_queue_item, mSongEntities);
    rvPlayQueue.setAdapter(mAdapter);
    mAdapter.setDeleteQueueItemListener(this);
    String[] curIds = MusicManager.getInstance().getCurIds();
    mQueuePresenter.loadQueueData(curIds);
}
Also used : SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) PlayQueueAdapter(com.freedom.lauzy.ticktockmusic.ui.adapter.PlayQueueAdapter) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Aggregations

SimpleItemAnimator (android.support.v7.widget.SimpleItemAnimator)28 RecyclerView (android.support.v7.widget.RecyclerView)24 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)22 View (android.view.View)16 TextView (android.widget.TextView)8 Toolbar (android.support.v7.widget.Toolbar)7 Nullable (android.support.annotation.Nullable)6 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)6 UIHandler (com.cpjd.roblu.ui.UIHandler)5 Intent (android.content.Intent)4 BindView (butterknife.BindView)4 Context (android.content.Context)3 Bundle (android.os.Bundle)3 GridLayoutManager (android.support.v7.widget.GridLayoutManager)3 IO (com.cpjd.roblu.io.IO)3 DrawableItemDecoration (org.wikipedia.views.DrawableItemDecoration)3 PageItemView (org.wikipedia.views.PageItemView)3 SearchEmptyView (org.wikipedia.views.SearchEmptyView)3 Drawable (android.graphics.drawable.Drawable)2 FloatingActionButton (android.support.design.widget.FloatingActionButton)2