Search in sources :

Example 6 with FlexboxLayoutManager

use of com.google.android.flexbox.FlexboxLayoutManager in project wanandroid by KnightAndroid.

the class ItemHeaderDecoration method onDrawOver.

@Override
public void onDrawOver(Canvas canvas, final RecyclerView parent, RecyclerView.State state) {
    FlexboxLayoutManager manager = (FlexboxLayoutManager) parent.getLayoutManager();
    int pos = ((FlexboxLayoutManager) (parent.getLayoutManager())).findFirstVisibleItemPosition();
    String tag = mDatas.get(pos).getTag();
    View child = parent.findViewHolderForLayoutPosition(pos).itemView;
    // canvas是否平移的标志
    boolean isTranslate = false;
    if (!TextUtils.equals(mDatas.get(pos).getTag(), mDatas.get(pos + 1).getTag())) {
        tag = mDatas.get(pos).getTag();
        int i = child.getHeight() + child.getTop();
        if (mDatas.get(pos).isTitle()) {
            // body 才平移
            if (child.getHeight() + child.getTop() < mTitleHeight) {
                canvas.save();
                isTranslate = true;
                int height = child.getHeight() + child.getTop() - mTitleHeight;
                canvas.translate(0, height);
            }
        }
    }
    drawHeader(parent, pos, canvas);
    if (isTranslate) {
        canvas.restore();
    }
    if (!TextUtils.equals(tag, currentTag)) {
        currentTag = tag;
        Integer integer = Integer.valueOf(tag);
        if (mCheckListener != null) {
            mCheckListener.check(integer, false);
        }
    }
}
Also used : FlexboxLayoutManager(com.google.android.flexbox.FlexboxLayoutManager) TextView(android.widget.TextView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) SuppressLint(android.annotation.SuppressLint) Paint(android.graphics.Paint)

Example 7 with FlexboxLayoutManager

use of com.google.android.flexbox.FlexboxLayoutManager in project wanandroid by KnightAndroid.

the class SquareFragment method initView.

@Override
protected void initView(Bundle savedInstanceState) {
    mDatabind.setClick(new ProcyClick());
    loadLoading(mDatabind.squareSharearticleFreshlayout);
    mHotKeyAdapter = new HotKeyAdapter(new ArrayList<SearchHotKeyEntity>());
    mSquareArticleAdapter = new SquareArticleAdapter(new ArrayList<SquareArticleEntity>());
    initListener();
    FlexboxLayoutManager flexboxLayoutManager = new FlexboxLayoutManager(getActivity());
    // 方向 主轴为水平方向,起点在左端
    flexboxLayoutManager.setFlexDirection(FlexDirection.ROW);
    // 左对齐
    flexboxLayoutManager.setJustifyContent(JustifyContent.FLEX_START);
    // flexboxLayoutManager.setAlignItems(AlignItems.CENTER);
    SetInitCustomView.initSwipeRecycleview(mDatabind.squareSearchhotRv, flexboxLayoutManager, mHotKeyAdapter, false);
    SetInitCustomView.initSwipeRecycleview(mDatabind.squareArticleRv, new LinearLayoutManager(getActivity()), mSquareArticleAdapter, true);
    mDatabind.squareSharearticleFreshlayout.setOnRefreshListener(this);
    mDatabind.squareSharearticleFreshlayout.setOnLoadMoreListener(this);
    EventBus.getDefault().register(this);
    View QuestionMenu = LayoutInflater.from(getActivity()).inflate(R.layout.square_question_activity, null);
    mSquareQuestionAdapter = new SquareQuestionAdapter(new ArrayList<>());
    initAdapterListener();
    baserecycleview = QuestionMenu.findViewById(R.id.base_body_rv);
    smartRefreshLayout = (SmartRefreshLayout) QuestionMenu.findViewById(R.id.include_square_question);
    tv_question_title = ((TextView) QuestionMenu.findViewById(R.id.square_question_tv_title));
    tv_question_title.setText(getString(R.string.square_question));
    smartRefreshLayout.setOnRefreshListener(refreshLayout -> {
        questionPage = 1;
        mPresenter.requestSquareQuestion(questionPage);
    });
    smartRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {

        @Override
        public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
            mPresenter.requestSquareQuestion(questionPage);
        }
    });
    SetInitCustomView.initSwipeRecycleview(baserecycleview, new LinearLayoutManager(getActivity()), mSquareQuestionAdapter, true);
    mDatabind.squareRoot.addView(QuestionMenu);
    LoadSir loadSir = LoadSir.getDefault();
    mViewLoadService = loadSir.register(QuestionMenu.findViewById(R.id.include_square_question), new Callback.OnReloadListener() {

        @Override
        public void onReload(View v) {
            mViewLoadService.showCallback(LoadCallBack.class);
        }
    });
    mViewLoadService.showCallback(LoadCallBack.class);
    mRightLottieAnimation = new RightLottieAnimation.GuillotineBuilder(QuestionMenu, QuestionMenu.findViewById(R.id.square_question_lefticon), mDatabind.squareIvQuestion, mSquareQuestionAdapter).setStartDelay(RIPPLE_DURATION).setActionBarViewForAnimation(mDatabind.squareToolbar).setClosedOnStart(true).setGuillotineListener(new RightLottieListener() {

        @Override
        public void onRightLottieOpened() {
            mDatabind.squareFabUp.setVisibility(View.GONE);
            mViewLoadService.showCallback(LoadCallBack.class);
            mPresenter.requestSquareQuestion(questionPage);
        }

        @Override
        public void onRightLottieClosed() {
            questionPage = 1;
            mDatabind.squareFabUp.setVisibility(View.VISIBLE);
        }
    }).build();
}
Also used : OnLoadMoreListener(com.scwang.smart.refresh.layout.listener.OnLoadMoreListener) RightLottieListener(com.knight.wanandroid.library_widget.lottie.RightLottieListener) HotKeyAdapter(com.knight.wanandroid.module_square.module_adapter.HotKeyAdapter) SquareArticleAdapter(com.knight.wanandroid.module_square.module_adapter.SquareArticleAdapter) FlexboxLayoutManager(com.google.android.flexbox.FlexboxLayoutManager) ArrayList(java.util.ArrayList) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) TextView(android.widget.TextView) SetInitCustomView(com.knight.wanandroid.library_widget.SetInitCustomView) SwipeRecyclerView(com.yanzhenjie.recyclerview.SwipeRecyclerView) SquareQuestionAdapter(com.knight.wanandroid.module_square.module_adapter.SquareQuestionAdapter) RefreshLayout(com.scwang.smart.refresh.layout.api.RefreshLayout) SmartRefreshLayout(com.scwang.smart.refresh.layout.SmartRefreshLayout) LoadCallBack(com.knight.wanandroid.library_base.loadsir.LoadCallBack) TextView(android.widget.TextView) LoadSir(com.kingja.loadsir.core.LoadSir)

Example 8 with FlexboxLayoutManager

use of com.google.android.flexbox.FlexboxLayoutManager in project android-chat by wildfirechat.

the class MultiCallIncomingFragment method init.

private void init() {
    AVEngineKit.CallSession session = AVEngineKit.Instance().getCurrentSession();
    if (session == null || session.getState() == AVEngineKit.CallState.Idle) {
        getActivity().finish();
        return;
    }
    if (session.isAudioOnly()) {
        acceptImageView.setImageResource(R.drawable.av_voice_answer_selector);
    }
    UserViewModel userViewModel = ViewModelProviders.of(this).get(UserViewModel.class);
    UserInfo invitor = userViewModel.getUserInfo(session.initiator, false);
    invitorTextView.setText(invitor.displayName);
    GlideApp.with(this).load(invitor.portrait).placeholder(R.mipmap.avatar_def).into(invitorImageView);
    List<String> participants = session.getParticipantIds();
    participants.remove(invitor.uid);
    // 把自己也加入到用户列表中
    participants.add(ChatManager.Instance().getUserId());
    List<UserInfo> participantUserInfos = userViewModel.getUserInfos(participants);
    FlexboxLayoutManager manager = new FlexboxLayoutManager(getActivity(), FlexDirection.ROW);
    manager.setJustifyContent(JustifyContent.CENTER);
    MultiCallParticipantAdapter adapter = new MultiCallParticipantAdapter();
    adapter.setParticipants(participantUserInfos);
    participantRecyclerView.setLayoutManager(manager);
    participantRecyclerView.setAdapter(adapter);
}
Also used : AVEngineKit(cn.wildfirechat.avenginekit.AVEngineKit) UserViewModel(cn.wildfire.chat.kit.user.UserViewModel) FlexboxLayoutManager(com.google.android.flexbox.FlexboxLayoutManager) UserInfo(cn.wildfirechat.model.UserInfo)

Example 9 with FlexboxLayoutManager

use of com.google.android.flexbox.FlexboxLayoutManager in project lnch by italankin.

the class AppsFragment method setLayout.

private void setLayout(Preferences.HomeLayout layout, Preferences.HomeAlignment homeAlignment) {
    if (layout != this.layout) {
        this.layout = layout;
        list.setLayoutManager(new FlexboxLayoutManager(requireContext(), FlexDirection.ROW));
    }
    if (list.getLayoutManager() instanceof FlexboxLayoutManager) {
        FlexboxLayoutManager lm = (FlexboxLayoutManager) list.getLayoutManager();
        switch(homeAlignment) {
            case START:
                lm.setJustifyContent(JustifyContent.FLEX_START);
                break;
            case CENTER:
                lm.setJustifyContent(JustifyContent.CENTER);
                break;
            case END:
                lm.setJustifyContent(JustifyContent.FLEX_END);
                break;
        }
    }
}
Also used : FlexboxLayoutManager(com.google.android.flexbox.FlexboxLayoutManager)

Example 10 with FlexboxLayoutManager

use of com.google.android.flexbox.FlexboxLayoutManager in project dynamic-support by pranavpandey.

the class DynamicLayoutUtils method getFlexboxLayoutManager.

/**
 * Returns the {@link FlexboxLayoutManager} object for the given context.
 *
 * @param context The context to instantiate the layout manager.
 * @param flexDirection The flex direction attribute to the flex container.
 * @param justifyContent The justify content attribute to the flex container.
 * @param alignItems The align items attribute to the flex container.
 *
 * @return The {@link FlexboxLayoutManager} object for the given context.
 */
@NonNull
public static FlexboxLayoutManager getFlexboxLayoutManager(@NonNull Context context, @FlexDirection int flexDirection, @JustifyContent int justifyContent, @AlignItems int alignItems) {
    FlexboxLayoutManager layoutManager = new FlexboxLayoutManager(context);
    layoutManager.setFlexDirection(flexDirection);
    layoutManager.setJustifyContent(justifyContent);
    layoutManager.setAlignItems(alignItems);
    return layoutManager;
}
Also used : FlexboxLayoutManager(com.google.android.flexbox.FlexboxLayoutManager) NonNull(androidx.annotation.NonNull)

Aggregations

FlexboxLayoutManager (com.google.android.flexbox.FlexboxLayoutManager)20 View (android.view.View)8 RecyclerView (androidx.recyclerview.widget.RecyclerView)8 TextView (android.widget.TextView)7 ImageView (android.widget.ImageView)5 ArrayList (java.util.ArrayList)5 Context (android.content.Context)4 TagListAdapter (com.odysee.app.adapter.TagListAdapter)4 NestedScrollView (androidx.core.widget.NestedScrollView)3 SuppressLint (android.annotation.SuppressLint)2 Editable (android.text.Editable)2 TextWatcher (android.text.TextWatcher)2 AdapterView (android.widget.AdapterView)2 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)2 MaterialButton (com.google.android.material.button.MaterialButton)2 MainActivity (com.odysee.app.MainActivity)2 Claim (com.odysee.app.model.Claim)2 Intent (android.content.Intent)1 PackageManager (android.content.pm.PackageManager)1 Paint (android.graphics.Paint)1