|
@@ -1,25 +1,38 @@
|
|
|
package com.cooleshow.institution.stu.ui.main;
|
|
|
|
|
|
+import android.text.TextUtils;
|
|
|
import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
+import android.widget.PopupWindow;
|
|
|
|
|
|
import com.cooleshow.base.ui.fragment.BaseFragment;
|
|
|
import com.cooleshow.base.ui.fragment.BaseMVPFragment;
|
|
|
import com.cooleshow.base.utils.LOG;
|
|
|
+import com.cooleshow.base.utils.PopupUtil;
|
|
|
import com.cooleshow.base.utils.SizeUtils;
|
|
|
import com.cooleshow.base.utils.Utils;
|
|
|
import com.cooleshow.base.utils.helper.QMUIDeviceHelper;
|
|
|
+import com.cooleshow.chatmodule.ui.ContactPersonListFragment;
|
|
|
import com.cooleshow.institution.stu.R;
|
|
|
import com.cooleshow.institution.stu.adapter.HomeCardPageAdapter;
|
|
|
+import com.cooleshow.institution.stu.bean.AlbumDetailBean;
|
|
|
+import com.cooleshow.institution.stu.bean.AlbumListBean;
|
|
|
import com.cooleshow.institution.stu.bean.HomeAlbumListBean;
|
|
|
import com.cooleshow.institution.stu.bean.HomePageMode;
|
|
|
import com.cooleshow.institution.stu.constants.Constants;
|
|
|
import com.cooleshow.institution.stu.constants.HomePageType;
|
|
|
import com.cooleshow.institution.stu.constants.JGWebStartHelper;
|
|
|
+import com.cooleshow.institution.stu.contract.HomeCardContract;
|
|
|
+import com.cooleshow.institution.stu.contract.HomeContract;
|
|
|
import com.cooleshow.institution.stu.databinding.FgHomeCardLayoutBinding;
|
|
|
+import com.cooleshow.institution.stu.presenter.HomeCardPresenter;
|
|
|
import com.cooleshow.institution.stu.presenter.HomePresenter;
|
|
|
import com.cooleshow.institution.stu.viewmodel.HomeViewModel;
|
|
|
+import com.cooleshow.institution.stu.widget.ExpandAndCollapseAnimPopupWindow;
|
|
|
import com.cooleshow.institution.stu.widget.ScaleTransformer;
|
|
|
+import com.cooleshow.institution.stu.widget.SwitchAlbumView;
|
|
|
import com.cooleshow.usercenter.bean.StudentUserInfo;
|
|
|
+import com.cooleshow.usercenter.helper.UserHelper;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
@@ -36,11 +49,10 @@ import androidx.viewpager2.widget.ViewPager2;
|
|
|
/**
|
|
|
* Author by pq, Date on 2023/9/11.
|
|
|
*/
|
|
|
-public class HomeCardFragment extends BaseMVPFragment<FgHomeCardLayoutBinding, HomePresenter> implements View.OnClickListener {
|
|
|
-
|
|
|
-
|
|
|
+public class HomeCardFragment extends BaseMVPFragment<FgHomeCardLayoutBinding, HomeCardPresenter> implements View.OnClickListener, HomeCardContract.HomeContractView {
|
|
|
private HomeCardPageAdapter mCardPageAdapter;
|
|
|
private HomeViewModel mHomeViewModel;
|
|
|
+ private String defaultAlbumId = "";
|
|
|
|
|
|
private ViewPager2.OnPageChangeCallback mPageChangeCallback = new ViewPager2.OnPageChangeCallback() {
|
|
|
@Override
|
|
@@ -59,6 +71,9 @@ public class HomeCardFragment extends BaseMVPFragment<FgHomeCardLayoutBinding, H
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
+ private SwitchAlbumView mSwitchAlbumView;
|
|
|
+
|
|
|
+ private ArrayList<AlbumListBean> allAlbumDatas;
|
|
|
|
|
|
@Override
|
|
|
protected void initView(View rootView) {
|
|
@@ -94,6 +109,7 @@ public class HomeCardFragment extends BaseMVPFragment<FgHomeCardLayoutBinding, H
|
|
|
mViewBinding.viewSearchBg.setOnClickListener(this);
|
|
|
mViewBinding.ivMoreTrack.setOnClickListener(this);
|
|
|
mViewBinding.viewPager.registerOnPageChangeCallback(mPageChangeCallback);
|
|
|
+ mViewBinding.tvSwitchAlbum.setOnClickListener(this);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -102,8 +118,8 @@ public class HomeCardFragment extends BaseMVPFragment<FgHomeCardLayoutBinding, H
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- protected HomePresenter createPresenter() {
|
|
|
- return new HomePresenter();
|
|
|
+ protected HomeCardPresenter createPresenter() {
|
|
|
+ return new HomeCardPresenter();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -123,6 +139,65 @@ public class HomeCardFragment extends BaseMVPFragment<FgHomeCardLayoutBinding, H
|
|
|
JGWebStartHelper.startSearchBlack();
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
+ if (id == R.id.tv_switch_album) {
|
|
|
+ showSelectAlbumView();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showSelectAlbumView() {
|
|
|
+ if (allAlbumDatas == null || allAlbumDatas.size() == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (mSwitchAlbumView == null) {
|
|
|
+ mSwitchAlbumView = new SwitchAlbumView(getContext());
|
|
|
+ }
|
|
|
+ mSwitchAlbumView.setData(defaultAlbumId, allAlbumDatas);
|
|
|
+ ViewGroup parent = (ViewGroup) mSwitchAlbumView.getParent();
|
|
|
+ if (parent != null) {
|
|
|
+ parent.removeView(mSwitchAlbumView);
|
|
|
+ }
|
|
|
+// PopupWindow popupWindow = PopupUtil.showInDropWrapNObg(getContext(), mSwitchAlbumView, mViewBinding.viewSelectAlbumAnchor, new PopupUtil.ShowListener() {
|
|
|
+// @Override
|
|
|
+// public void onShow(View view, PopupWindow popupWindow) {
|
|
|
+// }
|
|
|
+// });
|
|
|
+
|
|
|
+ ExpandAndCollapseAnimPopupWindow popupWindow = new ExpandAndCollapseAnimPopupWindow(mSwitchAlbumView,ViewGroup.LayoutParams.MATCH_PARENT,
|
|
|
+ ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
|
+ popupWindow.setOnEventListener(new ExpandAndCollapseAnimPopupWindow.OnEventListener() {
|
|
|
+ @Override
|
|
|
+ public void preDismiss() {
|
|
|
+ mSwitchAlbumView.showHideAnim();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ popupWindow.showAsDropDown(mViewBinding.viewSelectAlbumAnchor);
|
|
|
+ mSwitchAlbumView.setOnEventListener(new SwitchAlbumView.OnEventListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss(boolean isAnimEnd) {
|
|
|
+ if (popupWindow != null) {
|
|
|
+ popupWindow.setCanDismiss(isAnimEnd);
|
|
|
+ popupWindow.dismiss();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onSelect(AlbumListBean albumListBean) {
|
|
|
+ setDefaultText(albumListBean);
|
|
|
+ //
|
|
|
+ if (popupWindow != null) {
|
|
|
+ popupWindow.dismiss();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss() {
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public void refreshUserInfo(StudentUserInfo data) {
|
|
@@ -135,11 +210,11 @@ public class HomeCardFragment extends BaseMVPFragment<FgHomeCardLayoutBinding, H
|
|
|
mViewBinding.tvName.setText(data.getTenantName());
|
|
|
}
|
|
|
|
|
|
- private int currentStatus = -1;
|
|
|
+ private int currentStatus = Constants.HOME_PAGE_STATUS_EMPTY;
|
|
|
private ArrayList<HomePageType> currentPageTypeList;
|
|
|
|
|
|
- private void load(HomeAlbumListBean data) {
|
|
|
- int tenantAlbumStatus = data.getTenantAlbumStatus();
|
|
|
+ private void load(AlbumDetailBean data) {
|
|
|
+ int tenantAlbumStatus = data.isStatus() ? Constants.HOME_PAGE_STATUS_HASLOCK : Constants.HOME_PAGE_STATUS_UNLOCK;
|
|
|
ArrayList<HomePageType> pageList = new ArrayList<>();
|
|
|
if (data.getSubjectCounts() > 0) {
|
|
|
//声部训练
|
|
@@ -153,6 +228,10 @@ public class HomeCardFragment extends BaseMVPFragment<FgHomeCardLayoutBinding, H
|
|
|
//合奏训练
|
|
|
pageList.add(HomePageType.ALL_PRACTICE);
|
|
|
}
|
|
|
+ if (data.getSubjectCounts() > 0) {
|
|
|
+ //云教程
|
|
|
+ pageList.add(HomePageType.ACCOMPANY_HELP);
|
|
|
+ }
|
|
|
if (!isNeedRefresh(tenantAlbumStatus, pageList)) {
|
|
|
return;
|
|
|
}
|
|
@@ -201,16 +280,15 @@ public class HomeCardFragment extends BaseMVPFragment<FgHomeCardLayoutBinding, H
|
|
|
}
|
|
|
|
|
|
public void refreshAlbumData(HomeAlbumListBean data) {
|
|
|
+ }
|
|
|
+
|
|
|
+ public void refreshAlbumDataV2(AlbumDetailBean data) {
|
|
|
if (isDetached() || mViewBinding == null) {
|
|
|
return;
|
|
|
}
|
|
|
if (data != null) {
|
|
|
int cPos = mViewBinding.viewPager.getCurrentItem();
|
|
|
- if (data.getTenantAlbumStatus() == Constants.HOME_PAGE_STATUS_EMPTY) {
|
|
|
- loadEmpty(data.getTenantAlbumStatus());
|
|
|
- } else {
|
|
|
- load(data);
|
|
|
- }
|
|
|
+ load(data);
|
|
|
if (cPos >= mCardPageAdapter.getFragments().size()) {
|
|
|
cPos = 0;
|
|
|
}
|
|
@@ -219,4 +297,56 @@ public class HomeCardFragment extends BaseMVPFragment<FgHomeCardLayoutBinding, H
|
|
|
loadEmpty(Constants.HOME_PAGE_STATUS_EMPTY);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public void getAllAlbumListSuccess(ArrayList<AlbumListBean> data) {
|
|
|
+ if (data != null && data.size() > 0) {
|
|
|
+ boolean hasMore = data.size() > 1;
|
|
|
+ mViewBinding.tvSwitchAlbum.setVisibility(hasMore ? View.VISIBLE : View.GONE);
|
|
|
+ allAlbumDatas = data;
|
|
|
+ AlbumListBean defaultSelectAlbum = getDefaultSelectAlbum(data);
|
|
|
+ setDefaultText(defaultSelectAlbum);
|
|
|
+ } else {
|
|
|
+ //显示空
|
|
|
+ allAlbumDatas = null;
|
|
|
+ showEmpty();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setDefaultText(AlbumListBean defaultSelectAlbum) {
|
|
|
+ this.defaultAlbumId = defaultSelectAlbum.getId();
|
|
|
+ mViewBinding.tvSwitchAlbum.setText(defaultSelectAlbum.getName());
|
|
|
+ presenter.getAlbumList(defaultAlbumId);
|
|
|
+ }
|
|
|
+
|
|
|
+ private AlbumListBean getDefaultSelectAlbum(ArrayList<AlbumListBean> data) {
|
|
|
+ String defaultAlbumId = UserHelper.getCustomCache(UserHelper.DEFAULT_ALBUM_ID);
|
|
|
+ if (TextUtils.isEmpty(defaultAlbumId)) {
|
|
|
+ return data.get(0);
|
|
|
+ }
|
|
|
+ for (int i = 0; i < data.size(); i++) {
|
|
|
+ AlbumListBean albumListBean = data.get(i);
|
|
|
+ if (TextUtils.equals(defaultAlbumId, albumListBean.getId())) {
|
|
|
+ return albumListBean;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return data.get(0);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void getHomeAlbumDetailSuccess(AlbumDetailBean data) {
|
|
|
+ if (isDetached() || mViewBinding == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (data != null) {
|
|
|
+ refreshAlbumDataV2(data);
|
|
|
+ } else {
|
|
|
+ showEmpty();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showEmpty() {
|
|
|
+ mViewBinding.tvSwitchAlbum.setVisibility(View.GONE);
|
|
|
+ loadEmpty(Constants.HOME_PAGE_STATUS_EMPTY);
|
|
|
+ }
|
|
|
}
|