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);
}
}
}
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();
}
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);
}
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;
}
}
}
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;
}
Aggregations