删除社区与话题相关代码
@@ -22,9 +22,9 @@ android {
|
||||
buildConfigField "boolean", "ISOLATION_MODE", "$isolationMode"
|
||||
|
||||
if (isolationMode) {
|
||||
resValue "string", "app_name", "Hi-debug"
|
||||
resValue "string", "app_name", "Mo-debug"
|
||||
} else {
|
||||
resValue "string", "app_name", "Hiyoo"
|
||||
resValue "string", "app_name", "Mo"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,26 +81,26 @@ android {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
|
||||
debug {
|
||||
storeFile file('../app_debug.jks')
|
||||
storePassword "debug2024"
|
||||
keyAlias "debug"
|
||||
keyPassword "debug2024"
|
||||
v2SigningEnabled true
|
||||
v1SigningEnabled true
|
||||
}
|
||||
|
||||
release {
|
||||
storeFile file('../app_release.jks')
|
||||
storePassword "xxxx"
|
||||
keyAlias "xxx"
|
||||
keyPassword "xxxx"
|
||||
v2SigningEnabled true
|
||||
v1SigningEnabled true
|
||||
}
|
||||
}
|
||||
// signingConfigs {
|
||||
//
|
||||
// debug {
|
||||
// storeFile file('../app_debug.jks')
|
||||
// storePassword "debug2024"
|
||||
// keyAlias "debug"
|
||||
// keyPassword "debug2024"
|
||||
// v2SigningEnabled true
|
||||
// v1SigningEnabled true
|
||||
// }
|
||||
//
|
||||
// release {
|
||||
// storeFile file('../app_release.jks')
|
||||
// storePassword "xxxx"
|
||||
// keyAlias "xxx"
|
||||
// keyPassword "xxxx"
|
||||
// v2SigningEnabled true
|
||||
// v1SigningEnabled true
|
||||
// }
|
||||
// }
|
||||
|
||||
sourceSets {
|
||||
|
||||
@@ -114,12 +114,10 @@ android {
|
||||
'src/module_room_chat/java',
|
||||
'src/model_customer_server/java',
|
||||
'src/module_music/java',
|
||||
'src/module_mini_world/java',
|
||||
'src/module_lottery_dialog/java',
|
||||
'src/module_bank_card/java',
|
||||
'src/module_super_admin/java',
|
||||
'src/module_treasure_box/java',
|
||||
'src/module_community/java',
|
||||
'src/module_album/java',
|
||||
|
||||
]
|
||||
@@ -134,12 +132,10 @@ android {
|
||||
'src/module_room_chat/res',
|
||||
'src/model_customer_server/res',
|
||||
'src/module_music/res',
|
||||
'src/module_mini_world/res',
|
||||
'src/module_lottery_dialog/res',
|
||||
'src/module_bank_card/res',
|
||||
'src/module_super_admin/res',
|
||||
'src/module_treasure_box/res',
|
||||
'src/module_community/res',
|
||||
'src/module_album/res',
|
||||
|
||||
]
|
||||
@@ -165,7 +161,7 @@ android {
|
||||
minifyEnabled minify_enabled.toBoolean() // 是否混淆
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
crunchPngs false // 停用 PNG 压缩
|
||||
signingConfig isolationMode ? signingConfigs.debug : signingConfigs.release
|
||||
// signingConfig isolationMode ? signingConfigs.debug : signingConfigs.release
|
||||
gradle.taskGraph.whenReady {
|
||||
tasks.each { task ->
|
||||
if (task.name.contains("Test") || task.name.contains("Lint")) {
|
||||
@@ -191,7 +187,7 @@ android {
|
||||
shrinkResources true // 开了混淆的时候才能开启 是否去除无效的资源文件
|
||||
zipAlignEnabled true // 开了混淆的时候才能开启 是否进行压缩并重排列
|
||||
crunchPngs true // 启用 PNG 压缩
|
||||
signingConfig isolationMode ? signingConfigs.debug : signingConfigs.release
|
||||
// signingConfig isolationMode ? signingConfigs.debug : signingConfigs.release
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
@@ -47,8 +47,6 @@ import com.chwl.app.avroom.activity.AVRoomActivity;
|
||||
import com.chwl.app.base.BaseMvpActivity;
|
||||
import com.chwl.app.common.widget.CircleImageView;
|
||||
import com.chwl.app.common.widget.DragLayout;
|
||||
import com.chwl.app.community.dynamic.view.DynamicDetailActivity;
|
||||
import com.chwl.app.community.publish.view.PublishActivity;
|
||||
import com.chwl.app.family.view.activity.FamilyHomeActivity;
|
||||
import com.chwl.app.home.HomeViewModel;
|
||||
import com.chwl.app.home.dialog.NewUserHelloDialog;
|
||||
@@ -60,7 +58,6 @@ import com.chwl.app.home.presenter.MainPresenter;
|
||||
import com.chwl.app.home.view.IMainView;
|
||||
import com.chwl.app.home.widget.AnchorCardView;
|
||||
import com.chwl.app.main.helper.NoticationsUiHelper;
|
||||
import com.chwl.app.miniworld.activity.MiniWorldGuestPageActivity;
|
||||
import com.chwl.app.module.Extras;
|
||||
import com.chwl.app.module_hall.secretcode.PwdCodeMgr;
|
||||
import com.chwl.app.service.DaemonService;
|
||||
@@ -203,12 +200,12 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
FamilyHomeActivity.start(context, linkedInfo.getFamilyId());
|
||||
} else if (!TextUtils.isEmpty(linkedInfo.getUrl()) && linkedInfo.getType().equals("3")) {
|
||||
CommonWebViewActivity.start(context, UriProvider.getLinkUrl(linkedInfo.getUrl()));
|
||||
} else if (!TextUtils.isEmpty(linkedInfo.getWorldId()) && linkedInfo.getType().equals("5")) {
|
||||
MiniWorldGuestPageActivity.start(context, linkedInfo.getWorldId());
|
||||
} else if (linkedInfo.getType().equals("6") && !TextUtils.isEmpty(linkedInfo.getWorldId()) &&
|
||||
!TextUtils.isEmpty(linkedInfo.getDynamicId())) {
|
||||
DynamicDetailActivity.start(context, JavaUtil.str2long(linkedInfo.getDynamicId()),
|
||||
JavaUtil.str2long(linkedInfo.getWorldId()), 6);
|
||||
// } else if (!TextUtils.isEmpty(linkedInfo.getWorldId()) && linkedInfo.getType().equals("5")) {
|
||||
// MiniWorldGuestPageActivity.start(context, linkedInfo.getWorldId());
|
||||
// } else if (linkedInfo.getType().equals("6") && !TextUtils.isEmpty(linkedInfo.getWorldId()) &&
|
||||
// !TextUtils.isEmpty(linkedInfo.getDynamicId())) {
|
||||
// DynamicDetailActivity.start(context, JavaUtil.str2long(linkedInfo.getDynamicId()),
|
||||
// JavaUtil.str2long(linkedInfo.getWorldId()), 6);
|
||||
} else if (linkedInfo.getType().equals("7") && !TextUtils.isEmpty(linkedInfo.getUid())) {
|
||||
NimP2PMessageActivity.start(context, linkedInfo.getUid());
|
||||
} else {
|
||||
@@ -854,9 +851,6 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void SquarePublish(SquareTaskEvent event) {
|
||||
if (getDialogManager() != null) {
|
||||
PublishActivity.start(getDialogManager());
|
||||
}
|
||||
}
|
||||
|
||||
private void handlePmExitRoom() {
|
||||
|
@@ -13,14 +13,14 @@ import com.chad.library.adapter.base.diff.BaseQuickDiffCallback
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.bean.RoomAlbumPhotoInfo
|
||||
import com.chwl.app.base.BaseViewBindingFragment
|
||||
import com.chwl.app.community.photo.BigPhotoActivity
|
||||
import com.chwl.app.community.photo.PagerOption
|
||||
import com.chwl.app.community.utils.ObjectTypeHelper
|
||||
import com.chwl.app.databinding.FragmentRoomAlbumBinding
|
||||
import com.chwl.app.photo.BigPhotoActivity
|
||||
import com.chwl.app.photo.PagerOption
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils
|
||||
import com.chwl.app.ui.utils.ImageLoadUtilsV2
|
||||
import com.chwl.app.ui.widget.ButtonItem
|
||||
import com.chwl.app.ui.widget.recyclerview.decoration.GridSpacingItemNewDecoration
|
||||
import com.chwl.app.utils.ObjectTypeHelper
|
||||
import com.chwl.core.Constants
|
||||
|
||||
class RoomAlbumFragment : BaseViewBindingFragment<FragmentRoomAlbumBinding>() {
|
||||
|
@@ -56,6 +56,9 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.SimpleItemAnimator;
|
||||
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.chwl.app.photo.BigPhotoActivity;
|
||||
import com.chwl.app.photo.PagerOption;
|
||||
import com.chwl.app.utils.ObjectTypeHelper;
|
||||
import com.chwl.core.monsterhunting.bean.MonsterDataBean;
|
||||
import com.chwl.core.utils.extension.StringExtensionKt;
|
||||
import com.netease.nim.uikit.business.uinfo.UserInfoHelper;
|
||||
@@ -79,9 +82,6 @@ import com.chwl.library.common.util.Utils;
|
||||
import com.chwl.app.common.widget.CustomAutoWidthImageSpan;
|
||||
import com.chwl.app.common.widget.CustomImageSpan;
|
||||
import com.chwl.app.common.widget.OriginalDrawStatusClickSpan;
|
||||
import com.chwl.app.community.photo.BigPhotoActivity;
|
||||
import com.chwl.app.community.photo.PagerOption;
|
||||
import com.chwl.app.community.utils.ObjectTypeHelper;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtilsV2;
|
||||
import com.chwl.app.ui.widget.DividerItemDecoration;
|
||||
|
@@ -1,185 +0,0 @@
|
||||
package com.chwl.app.common.widget.dialog;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatDialogFragment;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.community.publish.view.WorldsChooseFrg;
|
||||
import com.chwl.app.home.adapter.FragmentViewPagerAdapter;
|
||||
import com.chwl.app.ui.widget.magicindicator.MagicIndicator;
|
||||
import com.chwl.app.ui.widget.magicindicator.ViewPagerHelper;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator;
|
||||
import com.chwl.core.Constants;
|
||||
import com.chwl.core.community.bean.MiniWorldChooseInfo;
|
||||
import com.chwl.core.home.bean.TabInfo;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ChooseWorldsDialog extends AppCompatDialogFragment
|
||||
implements ChooseWorldsIndicatorAdapter.OnItemSelectListener, WorldsChooseFrg.ChooseWorldCallback {
|
||||
|
||||
private Context context;
|
||||
private ViewGroup mRootView;
|
||||
|
||||
private FrameLayout flTopButton;
|
||||
private FrameLayout flDialogWorld;
|
||||
private MagicIndicator indicator;
|
||||
private ViewPager viewPager;
|
||||
|
||||
public static ChooseWorldsDialog newInstance(byte type) {
|
||||
ChooseWorldsDialog chooseWorldsDialog = new ChooseWorldsDialog();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putByte("type", type);
|
||||
chooseWorldsDialog.setArguments(bundle);
|
||||
return chooseWorldsDialog;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
|
||||
context = getContext();
|
||||
mRootView = (ViewGroup) View.inflate(getContext(), R.layout.layout_choose_worlds, null);
|
||||
flTopButton = mRootView.findViewById(R.id.fl_top_button);
|
||||
flTopButton.setOnClickListener(v -> {
|
||||
dismissDialog();
|
||||
});
|
||||
flDialogWorld = mRootView.findViewById(R.id.fl_dialog_world);
|
||||
flDialogWorld.setOnClickListener(v -> {
|
||||
dismissDialog();
|
||||
});
|
||||
indicator = mRootView.findViewById(R.id.indicator);
|
||||
viewPager = mRootView.findViewById(R.id.viewpager);
|
||||
|
||||
List<TabInfo> mTabInfoList = new ArrayList<>();
|
||||
// mTabInfoList.add(new TabInfo(1, ResUtil.getString(R.string.widget_dialog_chooseworldsdialog_01)));
|
||||
// mTabInfoList.add(new TabInfo(2, ResUtil.getString(R.string.widget_dialog_chooseworldsdialog_02)));
|
||||
mTabInfoList.add(new TabInfo(3, ResUtil.getString(R.string.widget_dialog_chooseworldsdialog_03)));
|
||||
|
||||
List<Fragment> mTabs = new ArrayList<>();
|
||||
// mTabs.add(WorldsChooseFrg.newInstance(Constants.TYPE_JOINED).setmChooseWorldCallback(this));
|
||||
// mTabs.add(WorldsChooseFrg.newInstance(Constants.TYPE_RECOMMEND).setmChooseWorldCallback(this));
|
||||
mTabs.add(WorldsChooseFrg.newInstance(Constants.TYPE_ALL).setmChooseWorldCallback(this));
|
||||
|
||||
ChooseWorldsIndicatorAdapter topMagicIndicatorAdapter = new ChooseWorldsIndicatorAdapter(context, mTabInfoList, 0);
|
||||
topMagicIndicatorAdapter.setOnItemSelectListener(this);
|
||||
CommonNavigator commonNavigator = new CommonNavigator(getContext());
|
||||
commonNavigator.setAdjustMode(true);
|
||||
commonNavigator.setAdapter(topMagicIndicatorAdapter);
|
||||
indicator.setNavigator(commonNavigator);
|
||||
|
||||
viewPager.setAdapter(new FragmentViewPagerAdapter(getChildFragmentManager(), mTabs));
|
||||
ViewPagerHelper.bind(indicator, viewPager);
|
||||
|
||||
Bundle bundle = getArguments();
|
||||
byte type;
|
||||
if (bundle != null) {
|
||||
type = bundle.getByte("type", Constants.TYPE_JOINED);
|
||||
} else {
|
||||
type = Constants.TYPE_JOINED;
|
||||
}
|
||||
|
||||
// switch (type) {
|
||||
// case Constants.TYPE_ALL:
|
||||
viewPager.setCurrentItem(2);
|
||||
// break;
|
||||
//
|
||||
// case Constants.TYPE_JOINED:
|
||||
// viewPager.setCurrentItem(0);
|
||||
// break;
|
||||
//
|
||||
// case Constants.TYPE_RECOMMEND:
|
||||
// viewPager.setCurrentItem(1);
|
||||
// break;
|
||||
// }
|
||||
|
||||
return mRootView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
if (getActivity() != null) {
|
||||
Dialog dialog = new Dialog(getActivity(), R.style.room_rank_dialog);
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(R.layout.layout_choose_worlds);
|
||||
dialog.setCanceledOnTouchOutside(true);
|
||||
|
||||
// 设置弹出框布局参数,宽度铺满全屏,底部。
|
||||
Window window = dialog.getWindow();
|
||||
if (window != null) {
|
||||
WindowManager.LayoutParams wlp = window.getAttributes();
|
||||
wlp.gravity = Gravity.BOTTOM;
|
||||
wlp.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
wlp.height = ScreenUtil.screenHeight - ScreenUtil.getStatusBarHeight(context);
|
||||
window.setDimAmount(0.3f);
|
||||
window.setAttributes(wlp);
|
||||
window.setBackgroundDrawableResource(R.drawable.bg_audio_party_list_dialog);
|
||||
window.setWindowAnimations(R.style.ErbanCommonWindowAnimationStyle);
|
||||
return dialog;
|
||||
} else {
|
||||
return super.onCreateDialog(savedInstanceState);
|
||||
}
|
||||
} else {
|
||||
return super.onCreateDialog(savedInstanceState);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemSelect(int position) {
|
||||
viewPager.setCurrentItem(position);
|
||||
}
|
||||
|
||||
private WorldsChooseFrg.ChooseWorldCallback mChooseWorldCallback;
|
||||
@Override
|
||||
public void callback(MiniWorldChooseInfo miniWorldChooseInfo) {
|
||||
if (mChooseWorldCallback != null) {
|
||||
mChooseWorldCallback.callback(miniWorldChooseInfo);
|
||||
}
|
||||
|
||||
mChooseWorldCallback = null;
|
||||
dismissDialog();
|
||||
}
|
||||
|
||||
public void setmChooseWorldCallback(WorldsChooseFrg.ChooseWorldCallback chooseWorldCallback) {
|
||||
this.mChooseWorldCallback = chooseWorldCallback;
|
||||
}
|
||||
|
||||
public void dismissDialog() {
|
||||
//注释这个判断,因为不保留活动情况下,((Activity)mContext).isDestroyed() 为true 导致不执行dismiss一个dialog
|
||||
//而mDialog.getWindow()不为null,还是可以dismiss一个dialog的。
|
||||
// if(!checkActivityValid())
|
||||
// return;
|
||||
//加上一个try,强行吞异常
|
||||
try {
|
||||
Context context = getContext();
|
||||
if (getContext() != null) {
|
||||
if (context instanceof Activity) {
|
||||
Activity activity = (Activity) context;
|
||||
if (!activity.isFinishing())//如果dialog在延时比如handler。postDelay中调用,而activity.已经destory,会报异常java.lang.IllegalArgumentException: View not attached to window manager
|
||||
dismiss();
|
||||
} else
|
||||
dismiss();
|
||||
}
|
||||
} catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -14,7 +14,6 @@ import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.base.BaseMvpActivity;
|
||||
import com.chwl.app.base.TitleBar;
|
||||
import com.chwl.app.community.dynamic.view.DynamicDetailActivity;
|
||||
import com.chwl.app.home.adapter.CommunityNoticeAdapter;
|
||||
import com.chwl.app.home.presenter.CommunityNoticePresenter;
|
||||
import com.chwl.app.home.view.ICommunityNoticeAct;
|
||||
@@ -59,23 +58,6 @@ public class CommunityNoticeAct extends BaseMvpActivity<ICommunityNoticeAct, Com
|
||||
mCommunityNoticeAdapter = new CommunityNoticeAdapter();
|
||||
mCommunityNoticeAdapter.setOnLoadMoreListener(() -> getMvpPresenter().loadMore(AuthModel.get().getCurrentUid()), recyclerView);
|
||||
mCommunityNoticeAdapter.setOnItemChildClickListener((adapter, view, position) -> {
|
||||
List<CommunityNoticeInfo> list = adapter.getData();
|
||||
if (list.size() > 0 && position < list.size()) {
|
||||
CommunityNoticeInfo info = list.get(position);
|
||||
|
||||
if (info != null) {
|
||||
switch (view.getId()) {
|
||||
case R.id.cl_community_notice_list:
|
||||
DynamicDetailActivity.start(CommunityNoticeAct.this, info.getDynamicId(), info.getWorldId(), 4);
|
||||
break;
|
||||
|
||||
case R.id.civ_avatar_community_notice_list:
|
||||
UserInfoActivity.Companion.start(context, info.getUid());
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
recyclerView.setAdapter(mCommunityNoticeAdapter);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
|
||||
|
@@ -20,7 +20,6 @@ import com.netease.nim.uikit.StatusBarUtil
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseViewBindingActivity
|
||||
import com.chwl.app.databinding.ActivityGiveGoldToUserBinding
|
||||
import com.chwl.app.miniworld.listener.DoubleClickCheckListener
|
||||
import com.chwl.app.pay.GiveGoldModel
|
||||
import com.chwl.app.pay.adapter.GiveGiftAdapter
|
||||
import com.chwl.app.pay.password.GiveGoldPassWordFragment
|
||||
@@ -32,6 +31,7 @@ import com.chwl.app.ui.widget.dialog.CommonTipDialog
|
||||
import com.chwl.app.ui.widget.dialog.GiveDiamondTipDialog
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil
|
||||
import com.chwl.app.ui.widget.recyclerview.decoration.GridSpacingItemNewDecoration
|
||||
import com.chwl.app.utils.DoubleClickCheckListener
|
||||
import com.chwl.core.DemoCache
|
||||
import com.chwl.core.gift.GiftModel
|
||||
import com.chwl.core.gift.bean.GiftInfo
|
||||
|
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.chwl.app.community.photo;
|
||||
package com.chwl.app.photo;
|
||||
|
||||
import android.view.ViewGroup;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package com.chwl.app.community.photo;
|
||||
package com.chwl.app.photo;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
@@ -6,7 +6,6 @@ import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.base.BaseViewBindingActivity;
|
||||
import com.chwl.app.databinding.ActivityBigPhotoBinding;
|
||||
@@ -16,6 +15,7 @@ import com.chwl.library.common.util.AlbumUtils;
|
||||
import com.chwl.library.common.util.ExecutorCenter;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.example.matisse.internal.entity.CustomItem;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.chwl.app.community.photo;
|
||||
package com.chwl.app.photo;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
@@ -26,13 +26,13 @@ import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.netease.nim.uikit.support.glide.GlideApp;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtilsV2;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.chwl.library.utils.LogUtil;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.example.matisse.internal.entity.CustomItem;
|
||||
import com.netease.nim.uikit.support.glide.GlideApp;
|
||||
|
||||
import it.sephiroth.android.library.imagezoom.ImageViewTouch;
|
||||
import it.sephiroth.android.library.imagezoom.ImageViewTouchBase;
|
@@ -1,4 +1,4 @@
|
||||
package com.chwl.app.community.photo;
|
||||
package com.chwl.app.photo;
|
||||
|
||||
/**
|
||||
* create by lvzebiao @2019/11/20
|
@@ -1,4 +1,4 @@
|
||||
package com.chwl.app.community.photo;
|
||||
package com.chwl.app.photo;
|
||||
|
||||
|
||||
import com.example.matisse.internal.entity.CustomItem;
|
@@ -1,4 +1,4 @@
|
||||
package com.chwl.app.community.photo;
|
||||
package com.chwl.app.photo;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -14,10 +14,8 @@ import com.bumptech.glide.request.target.SimpleTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.netease.nim.uikit.support.glide.GlideApp;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.common.widget.dialog.DialogManager;
|
||||
import com.chwl.app.community.widget.ZoomImageView;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtilsV2;
|
||||
import com.chwl.app.ui.widget.ButtonItem;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
|
||||
@@ -25,6 +23,7 @@ import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
import com.chwl.library.utils.file.JXFileUtils;
|
||||
import com.example.matisse.internal.entity.CustomItem;
|
||||
import com.netease.nim.uikit.support.glide.GlideApp;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
@@ -1,4 +1,4 @@
|
||||
package com.chwl.app.community.photo;
|
||||
package com.chwl.app.photo;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
@@ -9,11 +9,11 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.PagerSnapHelper;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.base.BaseActivity;
|
||||
import com.chwl.app.community.utils.ObjectTypeHelper;
|
||||
import com.chwl.app.utils.ObjectTypeHelper;
|
||||
import com.example.matisse.internal.entity.CustomItem;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package com.chwl.app.community.widget;
|
||||
package com.chwl.app.photo;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
@@ -9,8 +9,6 @@ import com.netease.nim.uikit.api.model.session.SessionEventListener;
|
||||
import com.netease.nim.uikit.business.session.actions.BaseAction;
|
||||
import com.netease.nim.uikit.business.session.actions.ImageAction;
|
||||
import com.netease.nimlib.sdk.msg.model.IMMessage;
|
||||
import com.chwl.app.community.holder.DynamicSysHolder;
|
||||
import com.chwl.app.community.im.WorldDynamicShareViewHolder;
|
||||
import com.chwl.app.luckymoney.viewholder.LuckyMoneyMsgViewHolder;
|
||||
import com.chwl.app.luckymoney.viewholder.LuckyMoneyTipsViewHolder;
|
||||
import com.chwl.app.module_hall.HallDataManager;
|
||||
@@ -29,7 +27,6 @@ import com.chwl.app.ui.im.chat.MsgViewHolderLevel;
|
||||
import com.chwl.app.ui.im.chat.MsgViewHolderLottery;
|
||||
import com.chwl.app.ui.im.chat.MsgViewHolderOnline;
|
||||
import com.chwl.app.ui.im.chat.MsgViewHolderP2PContactRecharge;
|
||||
import com.chwl.app.ui.im.chat.MsgViewHolderRedPackage;
|
||||
import com.chwl.app.ui.im.chat.MsgViewHolderRedPacket;
|
||||
import com.chwl.app.ui.im.chat.MsgViewHolderSkill;
|
||||
import com.chwl.app.ui.im.chat.MsgViewHolderText;
|
||||
@@ -37,8 +34,6 @@ import com.chwl.app.ui.im.chat.SignInNoticeMsgViewHolder;
|
||||
import com.chwl.app.ui.im.chat.SysMsgV2ViewHolder;
|
||||
import com.chwl.app.ui.im.chat.SysMsgViewHolder;
|
||||
import com.chwl.app.ui.user.activity.UserInfoActivity;
|
||||
import com.chwl.core.community.attachment.DynamicSysAttachment;
|
||||
import com.chwl.core.community.im.WorldDynamicAttachment;
|
||||
import com.chwl.core.im.custom.bean.AssistantAttachment;
|
||||
import com.chwl.core.im.custom.bean.CarAttachment;
|
||||
import com.chwl.core.im.custom.bean.CarveUpGoldThirdLevelAttachment;
|
||||
@@ -149,7 +144,6 @@ public class ImInitHelper {
|
||||
NimUIKit.registerMsgItemViewHolder(SysMsgV2Attachment.class, SysMsgV2ViewHolder.class);
|
||||
NimUIKit.registerMsgItemViewHolder(LevelUpAttachment.class, MsgViewHolderLevel.class);
|
||||
NimUIKit.registerMsgItemViewHolder(AitMeAttachment.class, MsgViewHolderAitMe.class);
|
||||
NimUIKit.registerMsgItemViewHolder(RedPackageAttachment.class, MsgViewHolderRedPackage.class);
|
||||
//模厅模块
|
||||
HallDataManager.get().mainNimOnCreate();
|
||||
//公会模块
|
||||
@@ -159,11 +153,6 @@ public class ImInitHelper {
|
||||
//瓜分钻石 三级
|
||||
NimUIKit.registerMsgItemViewHolder(CarveUpGoldThirdLevelAttachment.class, MsgViewHolderText.class);
|
||||
|
||||
// 社区动态
|
||||
NimUIKit.registerMsgItemViewHolder(DynamicSysAttachment.class, DynamicSysHolder.class); // 动态审核, 违规删除
|
||||
//世界动态分享
|
||||
NimUIKit.registerMsgItemViewHolder(WorldDynamicAttachment.class, WorldDynamicShareViewHolder.class);
|
||||
|
||||
NimUIKit.registerMsgItemViewHolder(ChatHintAttachment.class, MsgViewHolderChatHint.class);
|
||||
|
||||
//技能卡
|
||||
|
@@ -22,9 +22,6 @@ import com.chwl.app.fansteam.FansTeamListActivity;
|
||||
import com.chwl.app.home.activity.CollectionRoomActivity;
|
||||
import com.chwl.app.home.activity.VisitorListActivity;
|
||||
import com.chwl.app.home.helper.OpenRoomHelper;
|
||||
import com.chwl.app.miniworld.activity.MiniWorldGuestPageActivity;
|
||||
import com.chwl.app.miniworld.activity.MiniWorldMainActivity;
|
||||
import com.chwl.app.miniworld.activity.TopicMainActivity;
|
||||
import com.chwl.app.module_hall.HallDataManager;
|
||||
import com.chwl.app.module_hall.hall.activity.ModuleClanActivity;
|
||||
import com.chwl.app.module_hall.hall.activity.ModuleHallActivity;
|
||||
@@ -246,13 +243,6 @@ public class RouterHandler {
|
||||
break;
|
||||
case RouterType.GAME_MATCHING:
|
||||
break;
|
||||
case RouterType.MINI_WORLD:
|
||||
MiniWorldMainActivity.start(context);
|
||||
break;
|
||||
case RouterType.MINI_WORLD_DETAIL:
|
||||
MiniWorldGuestPageActivity.start(context, routerValue);
|
||||
break;
|
||||
|
||||
case RouterType.SQUARE_PUBLISH:
|
||||
EventBus.getDefault().post(new SquareTaskEvent());
|
||||
break;
|
||||
@@ -327,9 +317,6 @@ public class RouterHandler {
|
||||
case RouterType.MY_SET:
|
||||
UIHelper.showSettingAct(context);
|
||||
break;
|
||||
case RouterType.TOPIC:
|
||||
TopicMainActivity.start(context, routerValue);
|
||||
break;
|
||||
case RouterType.MY_REVENUE:
|
||||
EarnRecordActivity.start(context);
|
||||
break;
|
||||
|
@@ -1,111 +0,0 @@
|
||||
package com.chwl.app.ui.im.chat;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.coorchice.library.utils.LogUtils;
|
||||
import com.netease.nim.uikit.business.session.viewholder.MsgViewHolderBase;
|
||||
import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.activity.AVRoomActivity;
|
||||
import com.chwl.app.common.widget.dialog.DialogManager;
|
||||
import com.chwl.core.DemoCache;
|
||||
import com.chwl.core.im.custom.bean.RedPackageAttachment;
|
||||
import com.chwl.core.manager.AvRoomDataManager;
|
||||
import com.chwl.core.redpackage.bean.RedPackageNotifyInfo;
|
||||
import com.chwl.core.utils.CurrentTimeUtils;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by zhoujianghua on 2015/8/4.
|
||||
*/
|
||||
public class MsgViewHolderRedPackage extends MsgViewHolderBase {
|
||||
|
||||
public MsgViewHolderRedPackage(BaseMultiItemFetchLoadAdapter adapter) {
|
||||
super(adapter);
|
||||
}
|
||||
|
||||
private TextView tvNickname;
|
||||
private TextView tvAll;
|
||||
private TextView tvTip;
|
||||
@Deprecated(since = "2.2.0版本,红包失效时间是客户端写死的,以后用消息体内的endTime")
|
||||
private int halfHour = 60 * 30 * 1000;
|
||||
|
||||
|
||||
@Override
|
||||
protected int getContentResId() {
|
||||
return R.layout.message_item_red_package;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void inflateContentView() {
|
||||
tvNickname = findViewById(R.id.tv_nickname);
|
||||
tvAll = findViewById(R.id.tv_all);
|
||||
tvTip = findViewById(R.id.tv_tip);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindContentView() {
|
||||
Map<String, Long> map = DemoCache.readRedPackage();
|
||||
RedPackageAttachment attachment = (RedPackageAttachment) message.getAttachment();
|
||||
RedPackageNotifyInfo notifyInfo = attachment.getRedPackageNotifyInfo();
|
||||
String id = notifyInfo.getRedEnvelopeId();
|
||||
LogUtils.d("getTime = " + message.getTime());
|
||||
if (map != null && map.containsKey(id)) { //已领取
|
||||
tvNickname.setText(ResUtil.getString(R.string.im_chat_msgviewholderredpackage_01));
|
||||
tvAll.setVisibility(View.GONE);
|
||||
tvTip.setText(ResUtil.getString(R.string.im_chat_msgviewholderredpackage_02));
|
||||
contentContainer.setAlpha(0.5f);
|
||||
} else{
|
||||
long endTime;
|
||||
notifyInfo.getEndTime();
|
||||
if (notifyInfo.getEndTime() != null) {
|
||||
// 2.2.0版本后 新增动态失效时间
|
||||
endTime = notifyInfo.getEndTime();
|
||||
} else {
|
||||
// 可能是2.2.0版本前:失效时间固定为30分
|
||||
endTime = message.getTime() + halfHour;
|
||||
}
|
||||
if (CurrentTimeUtils.getCurrentTime() < endTime) {
|
||||
tvNickname.setText(notifyInfo.getSendUserNick());
|
||||
tvAll.setText(ResUtil.getString(R.string.im_chat_msgviewholderredpackage_03));
|
||||
tvAll.setVisibility(View.VISIBLE);
|
||||
tvTip.setText(ResUtil.getString(R.string.im_chat_msgviewholderredpackage_04));
|
||||
contentContainer.setAlpha(1f);
|
||||
DialogManager.OkCancelDialogListener listener = () -> AVRoomActivity.start(context, notifyInfo.getRoomUid(),
|
||||
AVRoomActivity.FROM_TYPE_ALL_RED, notifyInfo.getSendUserNick(), notifyInfo);
|
||||
contentContainer.setOnClickListener(v -> {
|
||||
if (AvRoomDataManager.get().isOwnerOnMic() && AvRoomDataManager.get().getRoomId() != notifyInfo.getRoomUid()) {
|
||||
new DialogManager(context).showOkCancelDialog(ResUtil.getString(R.string.im_chat_msgviewholderredpackage_05), true, listener);
|
||||
} else {
|
||||
listener.onOk();
|
||||
}
|
||||
}
|
||||
);
|
||||
} else {
|
||||
//已失效
|
||||
tvNickname.setText(ResUtil.getString(R.string.im_chat_msgviewholderredpackage_06));
|
||||
tvAll.setVisibility(View.GONE);
|
||||
tvTip.setText(ResUtil.getString(R.string.im_chat_msgviewholderredpackage_07));
|
||||
contentContainer.setAlpha(0.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onItemClick() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected int leftBackground() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected int rightBackground() {
|
||||
return 0;
|
||||
}
|
||||
}
|
@@ -27,7 +27,6 @@ import com.netease.nim.uikit.business.session.viewholder.MsgViewHolderBase;
|
||||
import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
|
||||
import com.netease.nimlib.sdk.msg.model.IMMessage;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.miniworld.activity.MiniWorldGuestPageActivity;
|
||||
import com.chwl.app.sys.ErbanSysMsgViewModel;
|
||||
import com.chwl.app.ui.im.RouterHandler;
|
||||
import com.chwl.core.im.custom.bean.SysMsgAttachment;
|
||||
@@ -274,7 +273,6 @@ public class SysMsgViewHolder extends MsgViewHolderBase implements View.OnClickL
|
||||
if (map != null) {
|
||||
String worldId = map.get("worldId");
|
||||
if (!TextUtils.isEmpty(worldId)) {
|
||||
MiniWorldGuestPageActivity.start(context, worldId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,16 +23,11 @@ import com.netease.nimlib.sdk.msg.model.RecentContact;
|
||||
import com.netease.nimlib.sdk.team.model.Team;
|
||||
import com.trello.rxlifecycle3.android.FragmentEvent;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.activity.AVRoomActivity;
|
||||
import com.chwl.app.base.BaseFragment;
|
||||
import com.chwl.app.miniworld.activity.MWTeamRoomMessageAct;
|
||||
import com.chwl.app.miniworld.activity.MiniWorldTeamMessageActivity;
|
||||
import com.chwl.app.module_hall.im.NimHelper;
|
||||
import com.chwl.app.module_hall.team.activity.HallTeamMessageActivity;
|
||||
import com.chwl.app.team.view.NimTeamMessageActivity;
|
||||
import com.chwl.app.ui.im.avtivity.NimP2PMessageActivity;
|
||||
import com.chwl.app.ui.im.recent.adapter.AttentionInRoomAdapter;
|
||||
import com.chwl.app.ui.relation.AttentionListActivity;
|
||||
import com.chwl.app.mentoring_relationship.adapter.GrabApprenticesAdapter;
|
||||
import com.chwl.app.room_chat.activity.NimHallTeamRoomMessageActivity;
|
||||
import com.chwl.app.room_chat.activity.NimRoomP2PMessageActivity;
|
||||
@@ -279,20 +274,6 @@ public class RecentListFragment extends BaseFragment {
|
||||
} else {
|
||||
HallTeamMessageActivity.start(mContext, recent.getContactId());
|
||||
}
|
||||
} else if (type == 2) {
|
||||
|
||||
if (isInRoom) {
|
||||
MWTeamRoomMessageAct.start(mContext, recent.getContactId());
|
||||
} else {
|
||||
Team t = NimUIKit.getTeamProvider().getTeamById(recent.getContactId());
|
||||
if (t != null && t.isMyTeam()) {
|
||||
MiniWorldTeamMessageActivity.start(mContext, recent.getContactId(), true);
|
||||
} else {
|
||||
MiniWorldTeamMessageActivity.start(mContext, recent.getContactId(), false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
toast(ResUtil.getString(R.string.im_recent_recentlistfragment_05));
|
||||
}
|
||||
|
@@ -1,381 +0,0 @@
|
||||
package com.chwl.app.ui.user.adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.netease.nim.uikit.support.glide.GlideApp;
|
||||
import com.chwl.app.BR;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.UIHelper;
|
||||
import com.chwl.app.audio.widget.VoiceLine;
|
||||
import com.chwl.app.bindadapter.BaseAdapter;
|
||||
import com.chwl.app.miniworld.activity.TopicMainActivity;
|
||||
import com.chwl.app.ui.user.activity.ShowPhotoActivity;
|
||||
import com.chwl.app.ui.widget.SquareImageView;
|
||||
import com.chwl.app.ui.widget.recyclerview.decoration.VerticalDecoration;
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
import com.chwl.core.bean.UserInfoItem;
|
||||
import com.chwl.core.family.bean.FamilyInfo;
|
||||
import com.chwl.core.module_hall.hall.bean.HTeamInfo;
|
||||
import com.chwl.core.module_hall.hall.bean.OwnerHallInfo;
|
||||
import com.chwl.core.user.bean.JoinWorldInfo;
|
||||
import com.chwl.core.user.bean.UserGameInfo;
|
||||
import com.chwl.core.user.bean.UserInfo;
|
||||
import com.chwl.core.user.bean.UserPhoto;
|
||||
import com.chwl.core.utils.StringFormatUtils;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SizeUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class UserDesAdapter extends UserTabBaseAdapter implements UserPhotoAdapter.ImageClickListener {
|
||||
public void setUserId(long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
private long userId = 0;
|
||||
private UserInfo userInfo;
|
||||
private boolean isPlaying = false;
|
||||
|
||||
public UserDesAdapter(Context context, List<UserInfoItem> data) {
|
||||
super(context, data);
|
||||
|
||||
addItemType(UserInfoItem.TYPE_DES_PHOTO, R.layout.layout_des_photo);
|
||||
addItemType(UserInfoItem.TYPE_DES_PERSONAL, R.layout.layout_des_personal);
|
||||
addItemType(UserInfoItem.TYPE_DES_VOICE, R.layout.layout_desc_voice);
|
||||
addItemType(UserInfoItem.TYPE_DES_FAMILY, R.layout.layout_user_family);
|
||||
addItemType(UserInfoItem.TYPE_DES_HALL, R.layout.include_user_module_hall);
|
||||
addItemType(UserInfoItem.TYPE_DES_GAME, R.layout.layout_desc_game);
|
||||
addItemType(UserInfoItem.TYPE_DES_JOIN_WORLDS, R.layout.layout_user_join_worlds);
|
||||
}
|
||||
|
||||
public void setPlaying(boolean playing) {
|
||||
isPlaying = playing;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, UserInfoItem item) {
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
super.convert(helper, item);
|
||||
|
||||
switch (item.getItemType()) {
|
||||
case UserInfoItem.TYPE_DES_PHOTO:
|
||||
setPhoto(helper);
|
||||
break;
|
||||
|
||||
case UserInfoItem.TYPE_DES_PERSONAL:
|
||||
setPersonal(helper);
|
||||
break;
|
||||
|
||||
case UserInfoItem.TYPE_DES_VOICE:
|
||||
setVoice(helper);
|
||||
break;
|
||||
|
||||
case UserInfoItem.TYPE_DES_FAMILY:
|
||||
setFamily(helper, item);
|
||||
break;
|
||||
|
||||
case UserInfoItem.TYPE_DES_HALL:
|
||||
setHall(helper, item);
|
||||
break;
|
||||
|
||||
case UserInfoItem.TYPE_DES_GAME:
|
||||
setGame(helper, item);
|
||||
break;
|
||||
|
||||
case UserInfoItem.TYPE_DES_JOIN_WORLDS:
|
||||
setJoinWorlds(helper, item);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private LinearLayoutManager gameManager;
|
||||
|
||||
private void setGame(BaseViewHolder helper, UserInfoItem item) {
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
ArrayList<UserGameInfo> list = (ArrayList<UserGameInfo>) item.getData();
|
||||
|
||||
if (ListUtils.isListEmpty(list)) {
|
||||
helper.setGone(R.id.tv_game, false);
|
||||
helper.setGone(R.id.rv_game, false);
|
||||
|
||||
} else {
|
||||
helper.setGone(R.id.tv_game, true);
|
||||
helper.setGone(R.id.rv_game, true);
|
||||
|
||||
RecyclerView rvGame = helper.itemView.findViewById(R.id.rv_game);
|
||||
|
||||
if (gameManager == null)
|
||||
gameManager = new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false);
|
||||
rvGame.setLayoutManager(gameManager);
|
||||
|
||||
BaseAdapter adapter = new BaseAdapter(R.layout.item_user_game, BR.gameInfo);
|
||||
rvGame.setAdapter(adapter);
|
||||
adapter.setNewData(list);
|
||||
}
|
||||
}
|
||||
|
||||
// 没有模厅不需要展示
|
||||
private void setHall(BaseViewHolder helper, UserInfoItem item) {
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
OwnerHallInfo ownerHallInfo = (OwnerHallInfo) item.getData();
|
||||
if (ownerHallInfo == null) {
|
||||
helper.setGone(R.id.ll_hall_layout, false);
|
||||
|
||||
} else {
|
||||
|
||||
//说明该客态页是厅成员或者没有厅
|
||||
if (ownerHallInfo.getHallId() <= 0) {
|
||||
helper.setGone(R.id.ll_hall_layout, false);
|
||||
} else {
|
||||
helper.setGone(R.id.ll_hall_layout, true);
|
||||
helper.setGone(R.id.stv_apply_hall, false);
|
||||
|
||||
helper.setText(R.id.tv_hall_name, ownerHallInfo.getHallName());
|
||||
//如果不是自己,并且不在厅里,才显示申请按钮
|
||||
if (!ownerHallInfo.isInHall()) {
|
||||
helper.setGone(R.id.stv_apply_hall, true);
|
||||
helper.addOnClickListener(R.id.stv_apply_hall);
|
||||
}
|
||||
|
||||
if (ownerHallInfo.isHasPublicChat()) {
|
||||
helper.setGone(R.id.rl_hall_team_layout, true);
|
||||
helper.addOnClickListener(R.id.rl_hall_team_layout);
|
||||
|
||||
helper.setGone(R.id.stv_apply_team, false);
|
||||
HTeamInfo publicTeam = ownerHallInfo.getPublicChat();
|
||||
if (publicTeam != null) {
|
||||
helper.setText(R.id.tv_public_team_name, publicTeam.getName());
|
||||
if (!publicTeam.isInChat()) {
|
||||
helper.setGone(R.id.stv_apply_team, true);
|
||||
helper.addOnClickListener(R.id.stv_apply_team);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
helper.setGone(R.id.rl_hall_team_layout, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 没有家族不需要展示
|
||||
private void setFamily(BaseViewHolder helper, UserInfoItem item) {
|
||||
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
FamilyInfo familyInfo = (FamilyInfo) item.getData();
|
||||
if (familyInfo == null) {
|
||||
helper.setGone(R.id.ll_my_family_container, false);
|
||||
return;
|
||||
}
|
||||
helper.setGone(R.id.ll_my_family_container, true);
|
||||
|
||||
SquareImageView ivFamilyCover = helper.itemView.findViewById(R.id.iv_family_cover);
|
||||
GlideApp.with(mContext)
|
||||
.load(familyInfo.getFamilyIcon())
|
||||
.dontAnimate()
|
||||
.placeholder(R.drawable.default_cover)
|
||||
.transforms(new CenterCrop(), new RoundedCorners(10))
|
||||
.error(R.drawable.default_cover)
|
||||
.into(ivFamilyCover);
|
||||
|
||||
helper.setText(R.id.tv_family_name, familyInfo.getFamilyName());
|
||||
helper.setText(R.id.tv_family_id, String.format(mContext.getString(R.string.family_id), familyInfo.getFamilyId()));
|
||||
helper.setText(R.id.tv_family_member_count, String.format(mContext.getString(
|
||||
R.string.family_member_count), String.valueOf(familyInfo.getMemberCount())));
|
||||
|
||||
helper.addOnClickListener(R.id.ll_my_family);
|
||||
}
|
||||
|
||||
public void setmVoiceDuration(int mVoiceDuration) {
|
||||
this.mVoiceDuration = mVoiceDuration;
|
||||
}
|
||||
|
||||
private int mVoiceDuration = 0;
|
||||
|
||||
private void setVoice(BaseViewHolder helper) {
|
||||
if (userInfo == null)
|
||||
return;
|
||||
|
||||
if (isOwner()) {// 主态
|
||||
helper.setGone(R.id.layout_voice, true);
|
||||
helper.setGone(R.id.layout_voice_bar, !StringFormatUtils.isEmpty(userInfo.getUserVoice()));
|
||||
helper.setGone(R.id.layout_voice_bar_no_data, StringFormatUtils.isEmpty(userInfo.getUserVoice()));
|
||||
helper.setText(R.id.tv_voice_title, ResUtil.getString(R.string.user_adapter_userdesadapter_01));
|
||||
helper.setGone(R.id.iv_voice_more, true);
|
||||
|
||||
} else {// 客态
|
||||
helper.setGone(R.id.layout_voice, !StringFormatUtils.isEmpty(userInfo.getUserVoice()));
|
||||
helper.setGone(R.id.layout_voice_bar, !StringFormatUtils.isEmpty(userInfo.getUserVoice()));
|
||||
helper.setGone(R.id.layout_voice_bar_no_data, false);
|
||||
helper.setText(R.id.tv_voice_title, ResUtil.getString(R.string.user_adapter_userdesadapter_02));
|
||||
helper.setGone(R.id.iv_voice_more, false);
|
||||
}
|
||||
|
||||
helper.addOnClickListener(R.id.layout_voice_bar);
|
||||
helper.addOnClickListener(R.id.iv_voice_more);
|
||||
helper.addOnClickListener(R.id.layout_voice_bar_no_data);
|
||||
|
||||
VoiceLine voiceLine = helper.itemView.findViewById(R.id.layout_voice_line);
|
||||
if (voiceLine != null) {
|
||||
voiceLine.stopAnim();
|
||||
if (isPlaying) {
|
||||
helper.setImageResource(R.id.iv_voice_bar_play, R.drawable.ic_voice_bar_pause);
|
||||
voiceLine.startAnim();
|
||||
} else {
|
||||
helper.setImageResource(R.id.iv_voice_bar_play, R.drawable.ic_voice_bar_play);
|
||||
voiceLine.stopAnim();
|
||||
}
|
||||
}
|
||||
|
||||
// int duration = mVoiceDuration;
|
||||
// if (duration == 0)
|
||||
// duration = userInfo.getVoiceDura();
|
||||
helper.setText(R.id.tv_voice_duration, String.format(Locale.getDefault(), "%ds", userInfo.getVoiceDura()));
|
||||
}
|
||||
|
||||
private void setPersonal(BaseViewHolder helper) {
|
||||
if (userInfo == null)
|
||||
return;
|
||||
|
||||
String desc = userInfo.getUserDesc();
|
||||
helper.setText(R.id.tv_desc, TextUtils.isEmpty(desc) ? ResUtil.getString(R.string.user_adapter_userdesadapter_03) : desc);
|
||||
}
|
||||
|
||||
private LinearLayoutManager mPhotoLayoutManager;
|
||||
|
||||
private void setPhoto(BaseViewHolder helper) {
|
||||
|
||||
if (userInfo == null)
|
||||
return;
|
||||
|
||||
if (mPhotoLayoutManager == null)
|
||||
mPhotoLayoutManager = new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false);
|
||||
|
||||
RecyclerView photoRecyclerView = helper.itemView.findViewById(R.id.photo_recyclerView);
|
||||
photoRecyclerView.setLayoutManager(mPhotoLayoutManager);
|
||||
|
||||
List<UserPhoto> privatePhoto = userInfo.getPrivatePhoto();
|
||||
|
||||
if (isOwner()) {// 主态
|
||||
helper.setGone(R.id.photo_recyclerView, true);
|
||||
helper.setGone(R.id.tv_empty_photo, false);
|
||||
|
||||
UserPhotoAdapter photoAdapter = new UserPhotoAdapter(privatePhoto, 0, userInfo.getUid());
|
||||
photoRecyclerView.setAdapter(photoAdapter);
|
||||
photoAdapter.setImageClickListener(this);
|
||||
|
||||
} else { // 客态
|
||||
if (ListUtils.isListEmpty(privatePhoto)) {
|
||||
helper.setGone(R.id.photo_recyclerView, false);
|
||||
helper.setGone(R.id.tv_empty_photo, true);
|
||||
|
||||
} else {
|
||||
helper.setGone(R.id.photo_recyclerView, true);
|
||||
helper.setGone(R.id.tv_empty_photo, false);
|
||||
UserPhotoAdapter photoAdapter = new UserPhotoAdapter(privatePhoto, 0, userInfo.getUid());
|
||||
photoRecyclerView.setAdapter(photoAdapter);
|
||||
photoAdapter.setImageClickListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setUserInfo(UserInfo userInfo) {
|
||||
this.userInfo = userInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(int position, UserPhoto userPhoto, boolean isOwner) {
|
||||
if (isOwner) {
|
||||
if (position > 0) {
|
||||
showUserPhoto(position - 1);
|
||||
} else {
|
||||
UIHelper.showModifyPhotosAct((Activity) mContext, userId);
|
||||
}
|
||||
} else {
|
||||
//创建一个集合拿来做用户所有照片信息
|
||||
showUserPhoto(position);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void showUserPhoto(int position) {
|
||||
//创建一个集合拿来做用户所有照片信息
|
||||
ArrayList<UserPhoto> userPhotos = new ArrayList<>();
|
||||
List<UserPhoto> realmList = userInfo.getPrivatePhoto();
|
||||
for (UserPhoto photo : realmList) {
|
||||
UserPhoto newPhoto = new UserPhoto();
|
||||
newPhoto.setPid(photo.getPid());
|
||||
newPhoto.setPhotoUrl(photo.getPhotoUrl());
|
||||
userPhotos.add(newPhoto);
|
||||
}
|
||||
Intent intent = new Intent(mContext, ShowPhotoActivity.class);
|
||||
intent.putExtra("position", position);
|
||||
intent.putExtra("photoList", userPhotos);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
|
||||
private boolean isOwner() {
|
||||
return AuthModel.get().getCurrentUid() == userId && userId != 0;
|
||||
}
|
||||
|
||||
private byte isInitJoinWorlds = 0;
|
||||
private void setJoinWorlds(BaseViewHolder baseViewHolder, UserInfoItem item) {
|
||||
baseViewHolder.setText(R.id.tv_label_user_join_worlds, isOwner() ? ResUtil.getString(R.string.user_adapter_userdesadapter_04) : ResUtil.getString(R.string.user_adapter_userdesadapter_05));
|
||||
ArrayList<JoinWorldInfo> list = (ArrayList<JoinWorldInfo>) item.getData();
|
||||
|
||||
if (list != null && list.size() > 0) {
|
||||
RecyclerView recyclerView = baseViewHolder.getView(R.id.rv_user_join_worlds);
|
||||
recyclerView.getLayoutManager();
|
||||
UserJoinWorldAdapter userJoinWorldAdapter = new UserJoinWorldAdapter();
|
||||
userJoinWorldAdapter.setNewData(list);
|
||||
userJoinWorldAdapter.setOnItemChildClickListener(new OnItemChildClickListener() {
|
||||
@Override
|
||||
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
|
||||
List<JoinWorldInfo> list1 = adapter.getData();
|
||||
if (list1.size() > position) {
|
||||
JoinWorldInfo joinWorldInfo = list1.get(position);
|
||||
if (joinWorldInfo != null) {
|
||||
TopicMainActivity.start(mContext, String.valueOf(joinWorldInfo.getWorldId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
recyclerView.setAdapter(userJoinWorldAdapter);
|
||||
if (isInitJoinWorlds == 0) {
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
|
||||
recyclerView.addItemDecoration(new VerticalDecoration(SizeUtils.dp2px(mContext, 15), true, true));
|
||||
|
||||
isInitJoinWorlds = 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -1,250 +0,0 @@
|
||||
package com.chwl.app.ui.user.adapter;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.util.SparseIntArray;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.community.dynamic.view.DynamicDetailActivity;
|
||||
import com.chwl.app.community.helper.CalcSize;
|
||||
import com.chwl.app.community.helper.DynamicUiHelper;
|
||||
import com.chwl.app.community.helper.ImageUiHelper;
|
||||
import com.chwl.app.community.photo.BigPhotoActivity;
|
||||
import com.chwl.app.community.photo.DynamicImageAdapter;
|
||||
import com.chwl.app.community.photo.PagerOption;
|
||||
import com.chwl.app.community.utils.ObjectTypeHelper;
|
||||
import com.chwl.app.community.widget.ExpandableTextView;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.chwl.app.utils.TimeUiUtils;
|
||||
import com.chwl.core.community.bean.DynamicMedia;
|
||||
import com.chwl.core.community.bean.WorldDynamicBean;
|
||||
import com.chwl.core.community.dynamic.DynamicModel;
|
||||
import com.chwl.core.utils.net.DontWarnObserver;
|
||||
import com.chwl.core.utils.net.RxHelper;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* create by lvzebiao @2019/11/13
|
||||
*/
|
||||
public class UserInfoDynamicAdapter extends BaseQuickAdapter<WorldDynamicBean, BaseViewHolder> {
|
||||
|
||||
private SparseBooleanArray mCollapsedStatus = new SparseBooleanArray();
|
||||
private SparseIntArray mCollapsedHeightStatus = new SparseIntArray(2);
|
||||
|
||||
private Context context;
|
||||
|
||||
private long worldId;
|
||||
|
||||
private int iconWidth;
|
||||
|
||||
private int iconHeight;
|
||||
|
||||
/**
|
||||
* 单图情况下的边界
|
||||
*/
|
||||
private int imageBorder;
|
||||
/**
|
||||
* 图片的边界值
|
||||
*/
|
||||
private int divider;
|
||||
|
||||
|
||||
public UserInfoDynamicAdapter(Context context) {
|
||||
super(R.layout.item_userinfo_dynamic);
|
||||
this.context = context;
|
||||
iconWidth = UIUtil.dip2px(context, 32);
|
||||
iconHeight = UIUtil.dip2px(context, 15);
|
||||
//0.68
|
||||
imageBorder = UIUtil.getScreenWidth(context) * ImageUiHelper.BORDER_MIN / ImageUiHelper.BORDER_MAX;
|
||||
divider = UIUtil.dip2px(context, 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, WorldDynamicBean item) {
|
||||
//这个值,有没有文本UI部分,改变图片部分的margin
|
||||
boolean noTextUi = TextUtils.isEmpty(item.getContent());
|
||||
RecyclerView rvImage = helper.getView(R.id.rv_image);
|
||||
List<DynamicMedia> dynamicMediaList = item.getDynamicResList();
|
||||
if (item.getType() == WorldDynamicBean.TYPE_IMAGE
|
||||
&& dynamicMediaList != null && dynamicMediaList.size() > 0) {
|
||||
rvImage.setVisibility(View.VISIBLE);
|
||||
initRecyclerView(rvImage, dynamicMediaList, noTextUi);
|
||||
} else {
|
||||
rvImage.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
//时间
|
||||
helper.setText(R.id.tv_time, TimeUiUtils.getDynamicUi(item.getPublishTime()));
|
||||
|
||||
ExpandableTextView etvContent = helper.getView(R.id.etv_content);
|
||||
etvContent.setEventType(1);
|
||||
if (noTextUi) {
|
||||
etvContent.setVisibility(View.GONE);
|
||||
} else {
|
||||
etvContent.setVisibility(View.VISIBLE);
|
||||
CharSequence formatText = DynamicUiHelper.formatFirstDynamicContent(
|
||||
item, etvContent.mTv, iconWidth, iconHeight);
|
||||
etvContent.setText(formatText, mCollapsedStatus, helper.getAdapterPosition(), mCollapsedHeightStatus);
|
||||
}
|
||||
|
||||
helper.setGone(R.id.layout_root_mini_world, item.getTag() != null);
|
||||
helper.setText(R.id.tv_mini_world_name, "#" + item.getTag());
|
||||
|
||||
//评论
|
||||
setCommentCount(helper, item.getCommentCount());
|
||||
|
||||
//点赞
|
||||
setLikeCount(helper, item.getLikeCount(), item.isLike(), false);
|
||||
LinearLayout llLike = helper.getView(R.id.ll_like);
|
||||
llLike.setEnabled(true);
|
||||
llLike.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (item.getDynamicId() == 0) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.the_default_dynamic_cannot_be_liked));
|
||||
return;
|
||||
}
|
||||
llLike.setEnabled(false);
|
||||
int status = item.isLike() ? 0 : 1;
|
||||
DynamicModel.get().like(worldId, item.getDynamicId(), item.getUid(), status, 1)
|
||||
.compose(RxHelper.bindContext(context))
|
||||
.subscribe(new DontWarnObserver<String>() {
|
||||
@Override
|
||||
public void accept(String s, String error) {
|
||||
super.accept(s, error);
|
||||
llLike.setEnabled(true);
|
||||
if (error != null) {
|
||||
SingleToastUtil.showToast(error);
|
||||
} else {
|
||||
LogUtil.print(mContext.getString(R.string.me_call_the_like_interface_to_complete));
|
||||
if (status == 1) {
|
||||
item.setLikeCount(item.getLikeCount() + 1);
|
||||
} else {
|
||||
item.setLikeCount(item.getLikeCount() - 1);
|
||||
}
|
||||
item.setLike(status == 1);
|
||||
setLikeCount(helper, item.getLikeCount(), item.isLike(), true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
//评论
|
||||
helper.getView(R.id.ll_comment).setOnClickListener(v -> {
|
||||
if (item.getDynamicId() == 0) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.the_default_dynamic_cannot_be_commented));
|
||||
return;
|
||||
}
|
||||
DynamicDetailActivity.start(context, item.getDynamicId(), worldId,
|
||||
helper.getAdapterPosition(), true, 1);
|
||||
}
|
||||
);
|
||||
helper.setVisible(R.id.iv_more, item.getDynamicId() != 0);
|
||||
if (item.getDynamicId() != 0) {
|
||||
helper.addOnClickListener(R.id.iv_more).addOnClickListener(R.id.ll_share);
|
||||
}
|
||||
|
||||
View.OnClickListener toDetailListener = v -> {
|
||||
if (item.getDynamicId() == 0) {
|
||||
return;
|
||||
}
|
||||
DynamicDetailActivity.start(context, item.getDynamicId(), worldId,
|
||||
helper.getAdapterPosition(), false, 1);
|
||||
};
|
||||
|
||||
if (etvContent.mTv != null) {
|
||||
etvContent.mTv.setOnClickListener(toDetailListener);
|
||||
}
|
||||
//跳转去详情
|
||||
helper.itemView.setOnClickListener(toDetailListener);
|
||||
helper.setGone(R.id.line_bottom, getItemCount() - 1 != helper.getLayoutPosition());
|
||||
}
|
||||
|
||||
private void setLikeCount(BaseViewHolder helper, int likeCount, boolean isLike, boolean isAnim) {
|
||||
TextView tvLike = helper.getView(R.id.tv_like);
|
||||
String likeCountStr;
|
||||
if (likeCount < 0) {
|
||||
likeCountStr = "0";
|
||||
} else if (likeCount >= 1000) {
|
||||
likeCountStr = "999+";
|
||||
} else {
|
||||
likeCountStr = String.valueOf(likeCount);
|
||||
}
|
||||
tvLike.setText(likeCountStr);
|
||||
|
||||
ImageView ivLikeAnim = helper.getView(R.id.iv_like_pic);
|
||||
if (isLike) {
|
||||
ivLikeAnim.setImageResource(R.drawable.icon_dy_list_like);
|
||||
} else {
|
||||
ivLikeAnim.setImageResource(R.drawable.icon_dy_list_like_false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void initRecyclerView(RecyclerView rvImage, List<DynamicMedia> imageUrl, boolean noTextUi) {
|
||||
if (imageUrl == null) {
|
||||
return;
|
||||
}
|
||||
CalcSize calcSize = new CalcSize(imageBorder);
|
||||
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) rvImage.getLayoutParams();
|
||||
if (imageUrl.size() > 1) {
|
||||
params.width = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
} else {
|
||||
//单图的情况,按比例显示
|
||||
DynamicMedia media = null;
|
||||
if (imageUrl.size() > 0) {
|
||||
media = imageUrl.get(0);
|
||||
}
|
||||
if (media == null) {
|
||||
return;
|
||||
}
|
||||
calcSize = ImageUiHelper.calcImage(media, imageBorder);
|
||||
params.width = calcSize.width + divider;
|
||||
params.height = calcSize.height + divider;
|
||||
}
|
||||
rvImage.setLayoutParams(params);
|
||||
rvImage.setNestedScrollingEnabled(false);
|
||||
rvImage.setLayoutManager(new GridLayoutManager(mContext, imageUrl.size() > 2 ? 3 : imageUrl.size()));
|
||||
DynamicImageAdapter adapter = new DynamicImageAdapter(R.layout.item_dynamic_image, imageUrl);
|
||||
adapter.setSingleImageHeight(calcSize.height);
|
||||
adapter.setOnItemClickListener((adapter1, view, position) -> {
|
||||
PagerOption option = new PagerOption().setSave(true);
|
||||
BigPhotoActivity.start((Activity) mContext, ObjectTypeHelper.mediaToCustomList(imageUrl),
|
||||
position, option);
|
||||
}
|
||||
);
|
||||
rvImage.setAdapter(adapter);
|
||||
}
|
||||
|
||||
private void setCommentCount(BaseViewHolder helper, int commentCount) {
|
||||
TextView tvComment = helper.getView(R.id.tv_comment);
|
||||
String commentCountStr;
|
||||
if (commentCount < 0) {
|
||||
commentCountStr = "0";
|
||||
} else if (commentCount >= 1000) {
|
||||
commentCountStr = "999+";
|
||||
} else {
|
||||
commentCountStr = String.valueOf(commentCount);
|
||||
}
|
||||
tvComment.setText(commentCountStr);
|
||||
}
|
||||
|
||||
}
|
@@ -1,169 +0,0 @@
|
||||
package com.chwl.app.ui.user.fragment
|
||||
|
||||
import android.view.View
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.trello.rxlifecycle3.android.FragmentEvent
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.UIHelper
|
||||
import com.chwl.app.avroom.ButtonItemFactory
|
||||
import com.chwl.app.base.BaseViewBindingFragment
|
||||
import com.chwl.app.common.widget.dialog.DialogManager.OkCancelDialogListener
|
||||
import com.chwl.app.community.helper.ShareDynamicHelper
|
||||
import com.chwl.app.databinding.FragmentUserinfoDynamicBinding
|
||||
import com.chwl.app.ui.user.adapter.UserInfoDynamicAdapter
|
||||
import com.chwl.app.ui.user.viewmodel.UserInfoViewModel
|
||||
import com.chwl.app.ui.widget.ButtonItem
|
||||
import com.chwl.app.ui.widget.recyclerview.decoration.HorizontalDecoration
|
||||
import com.chwl.core.XConstants
|
||||
import com.chwl.core.auth.AuthModel
|
||||
import com.chwl.core.community.bean.WorldDynamicBean
|
||||
import com.chwl.core.community.dynamic.DynamicModel
|
||||
import com.chwl.core.community.event.DynamicRefreshEvent
|
||||
import com.chwl.core.user.UserModel
|
||||
import com.chwl.core.user.bean.UserDetailInfo
|
||||
import com.chwl.core.utils.net.BeanObserver
|
||||
import com.chwl.core.utils.net.DontWarnObserver
|
||||
import com.chwl.library.annatation.ActLayoutRes
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import com.chwl.library.utils.SizeUtils
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
@ActLayoutRes(R.layout.fragment_userinfo_dynamic)
|
||||
class UserInfoDynamicFragment : BaseViewBindingFragment<FragmentUserinfoDynamicBinding>() {
|
||||
private val vm by activityViewModels<UserInfoViewModel>()
|
||||
private var dynamicAdapter: UserInfoDynamicAdapter? = null
|
||||
override fun init() {
|
||||
EventBus.getDefault().register(this)
|
||||
vm.userInfoDetailData.observe(this, Observer { dataBean: UserDetailInfo.DataBean ->
|
||||
initDynamicList(dataBean.dynamicInfo)
|
||||
})
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onDynamicRefreshEvent(event: DynamicRefreshEvent?) {
|
||||
if (isResumed) {
|
||||
vm.userInfoDetailData.observe(this, Observer { dataBean: UserDetailInfo.DataBean ->
|
||||
initDynamicList(dataBean.dynamicInfo)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态列表
|
||||
*
|
||||
* @param list
|
||||
*/
|
||||
private fun initDynamicList(list: List<WorldDynamicBean>) {
|
||||
if (dynamicAdapter == null) {
|
||||
binding.rvDynamic.layoutManager = LinearLayoutManager(mContext)
|
||||
binding.rvDynamic.addItemDecoration(HorizontalDecoration(SizeUtils.dp2px(mContext, 12f), false, false))
|
||||
dynamicAdapter = UserInfoDynamicAdapter(mContext)
|
||||
dynamicAdapter?.setEnableLoadMore(false)
|
||||
dynamicAdapter?.setOnItemChildClickListener { _, view: View, pos: Int ->
|
||||
val bean: WorldDynamicBean =
|
||||
dynamicAdapter?.getItem(pos) ?: return@setOnItemChildClickListener
|
||||
if (view.id == R.id.iv_more) {
|
||||
val list: MutableList<ButtonItem> = ArrayList()
|
||||
if (!UserModel.get().isMyseft(bean.uid)) {
|
||||
val item = ButtonItem(
|
||||
getString(R.string.me_shield_dynamic)
|
||||
) {
|
||||
UserModel.get().addReport(bean.dynamicId, 0)
|
||||
.subscribe(object : BeanObserver<String?>() {
|
||||
override fun onErrorMsg(error: String) {
|
||||
dialogManager.dismissDialog()
|
||||
toast(error)
|
||||
}
|
||||
|
||||
override fun onSuccess(s: String) {
|
||||
dialogManager.dismissDialog()
|
||||
toast(ResUtil.getString(R.string.me_shield_success))
|
||||
if (pos < (dynamicAdapter?.data?.size ?: 0)) {
|
||||
if (bean == dynamicAdapter?.getItem(pos)) {
|
||||
dynamicAdapter?.remove(pos)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
list.add(item)
|
||||
}
|
||||
if (!UserModel.get().isMyseft(bean.uid)) {
|
||||
val blackListItem = ButtonItemFactory.createAddToBlackListItem(
|
||||
dialogManager, bean.uid.toString()
|
||||
)
|
||||
list.add(blackListItem)
|
||||
}
|
||||
if (!UserModel.get().isMyseft(bean.uid)) {
|
||||
val item = ButtonItem(
|
||||
getString(R.string.me_report_dynamic)
|
||||
) {
|
||||
UIHelper.showReportPage(
|
||||
mContext, bean.uid,
|
||||
XConstants.REPORT_TYPE_DYNAMIC_SQUARE
|
||||
)
|
||||
}
|
||||
list.add(item)
|
||||
}
|
||||
if (UserModel.get().isMyseft(bean.uid) ||
|
||||
isThisWorldOwner(bean)
|
||||
) {
|
||||
val item = ButtonItem(
|
||||
getString(R.string.me_delete)
|
||||
) { deleteDynamic(pos, dynamicAdapter) }
|
||||
list.add(item)
|
||||
}
|
||||
dialogManager.showCommonPopupDialog(list, getString(R.string.cancel))
|
||||
} else if (view.id == R.id.ll_share) {
|
||||
ShareDynamicHelper(activity).share(bean)
|
||||
}
|
||||
}
|
||||
binding.rvDynamic.adapter = dynamicAdapter
|
||||
}
|
||||
dynamicAdapter?.setNewData(list)
|
||||
}
|
||||
|
||||
|
||||
private fun deleteDynamic(pos: Int, adapter: UserInfoDynamicAdapter?) {
|
||||
dialogManager.showOkCancelWithTitleDialog(getString(R.string.me_cannot_be_restored),
|
||||
OkCancelDialogListener {
|
||||
val bean = adapter?.getItem(pos) ?: return@OkCancelDialogListener
|
||||
DynamicModel.get().delete(bean.worldId, bean.dynamicId)
|
||||
.compose(bindUntilEvent(FragmentEvent.DESTROY_VIEW))
|
||||
.doOnSubscribe { dialogManager.showProgressDialog(mContext) }
|
||||
.subscribe(object : DontWarnObserver<String?>() {
|
||||
override fun accept(s: String?, error: String?) {
|
||||
super.accept(s, error)
|
||||
dialogManager.dismissDialog()
|
||||
if (error != null) {
|
||||
toast(error)
|
||||
} else {
|
||||
toast(getString(R.string.me_successfully_delete))
|
||||
if (pos < adapter.data.size) {
|
||||
if (bean == adapter.getItem(pos)) {
|
||||
adapter.remove(pos)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断自己是不是该世界的创始人
|
||||
*/
|
||||
private fun isThisWorldOwner(bean: WorldDynamicBean?): Boolean {
|
||||
return bean != null && bean.worldUid == AuthModel.get().currentUid
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
EventBus.getDefault().unregister(this)
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
}
|
@@ -454,7 +454,7 @@ public class TuTuGuideHelper {
|
||||
ImageView imageView;
|
||||
imageView = new ImageView(context);
|
||||
imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
imageView.setImageResource(R.drawable.icon_guide_to_add_world_tips);
|
||||
// imageView.setImageResource(R.drawable.icon_guide_to_add_world_tips);
|
||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
|
||||
UIUtil.dip2px(context, 277), UIUtil.dip2px(context, 115)
|
||||
);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package com.chwl.app.miniworld.listener;
|
||||
package com.chwl.app.utils;
|
||||
|
||||
|
||||
import android.view.View;
|
@@ -1,4 +1,4 @@
|
||||
package com.chwl.app.community.utils;
|
||||
package com.chwl.app.utils;
|
||||
|
||||
import com.chwl.core.community.bean.DynamicMedia;
|
||||
import com.example.matisse.internal.entity.CustomItem;
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
BIN
app/src/main/res/drawable-xhdpi/ic_arrow_more_publish.png
Normal file
After Width: | Height: | Size: 259 B |
BIN
app/src/main/res/drawable-xhdpi/ic_arrow_recharge.png
Normal file
After Width: | Height: | Size: 307 B |
BIN
app/src/main/res/drawable-xhdpi/ic_draw_gift_close.png
Normal file
After Width: | Height: | Size: 826 B |
BIN
app/src/main/res/drawable-xhdpi/ic_draw_gift_remove_all.png
Normal file
After Width: | Height: | Size: 966 B |
BIN
app/src/main/res/drawable-xhdpi/ic_draw_gift_remove_last.png
Normal file
After Width: | Height: | Size: 976 B |
BIN
app/src/main/res/drawable-xhdpi/ic_dy_in_room.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 342 B After Width: | Height: | Size: 342 B |
Before Width: | Height: | Size: 160 B After Width: | Height: | Size: 160 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 186 B After Width: | Height: | Size: 186 B |
Before Width: | Height: | Size: 768 B After Width: | Height: | Size: 768 B |
Before Width: | Height: | Size: 782 B After Width: | Height: | Size: 782 B |
Before Width: | Height: | Size: 402 B After Width: | Height: | Size: 402 B |
BIN
app/src/main/res/drawable-xhdpi/icon_dy_delete_pic.png
Normal file
After Width: | Height: | Size: 392 B |
Before Width: | Height: | Size: 204 B After Width: | Height: | Size: 204 B |
Before Width: | Height: | Size: 442 B After Width: | Height: | Size: 442 B |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
@@ -1,100 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar_layout"
|
||||
android:background="@color/transparent"
|
||||
app:elevation="0dp"
|
||||
app:layout_behavior="@string/behavior_fix_app_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_top_group"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp">
|
||||
|
||||
<com.chwl.app.ui.widget.magicindicator.MagicIndicator
|
||||
android:id="@+id/mi_home_indicator"
|
||||
android:layout_width="match_parent"
|
||||
app:layout_scrollFlags="scroll"
|
||||
android:layout_height="48dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:background="@color/white"/>
|
||||
|
||||
</RelativeLayout>
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/main_viewpager"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
<com.chwl.app.common.widget.DragLayout
|
||||
android:id="@+id/iv_square_publish"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:layout_margin="20dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/ic_square_publish"
|
||||
android:text="@string/layout_fragment_find_tab_01" />
|
||||
</com.chwl.app.common.widget.DragLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/fl_contact_list"
|
||||
android:layout_width="41dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true" >
|
||||
|
||||
<ImageView
|
||||
android:layout_width="21dp"
|
||||
android:layout_height="21dp"
|
||||
android:scaleType="center"
|
||||
android:layout_gravity="center_vertical|start"
|
||||
android:src="@drawable/ic_community_notice_rink" />
|
||||
|
||||
<com.netease.nim.uikit.common.ui.draggablebubbles.BubbleView
|
||||
android:id="@+id/msg_number"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="5dp"
|
||||
android:gravity="center"
|
||||
android:visibility="invisible"
|
||||
tools:text="123"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/rv_dynamic"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/dp_14"
|
||||
android:layout_marginBottom="@dimen/dp_14"/>
|
||||
|
||||
</layout>
|
@@ -1,109 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginStart="@dimen/dp_15"
|
||||
android:layout_marginEnd="@dimen/dp_15"
|
||||
android:paddingBottom="13.5dp"
|
||||
android:background="@drawable/shape_add_friends_2a2a39">
|
||||
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_user_info"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="59dp"
|
||||
android:layout_marginTop="@dimen/dp_8"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<com.chwl.app.common.widget.CircleImageView
|
||||
android:id="@+id/iv_avatar"
|
||||
android:layout_width="@dimen/dp_45"
|
||||
android:layout_height="@dimen/dp_45"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/iv_head_wear"
|
||||
app:layout_constraintEnd_toEndOf="@+id/iv_head_wear"
|
||||
app:layout_constraintStart_toStartOf="@+id/iv_head_wear"
|
||||
app:layout_constraintTop_toTopOf="@+id/iv_head_wear" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_head_wear"
|
||||
android:layout_width="59dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="@dimen/dp_8"
|
||||
android:scaleType="centerCrop"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<com.chwl.app.community.widget.DynamicNickDetailWidget
|
||||
android:id="@+id/widget_nick_detail"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_5"
|
||||
app:layout_constraintStart_toEndOf="@id/iv_head_wear"
|
||||
app:layout_constraintTop_toTopOf="@id/iv_avatar"
|
||||
app:layout_constraintBottom_toBottomOf="@id/iv_avatar"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_in_room"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_dy_in_room"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/widget_nick_detail"
|
||||
android:layout_marginEnd="@dimen/dp_8"
|
||||
/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:gravity="bottom"
|
||||
>
|
||||
|
||||
<com.netease.nim.uikit.business.session.widget.NimEmojiTextView
|
||||
android:id="@+id/expandable_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/text_normal_c6c6e9"
|
||||
android:textSize="15sp"
|
||||
android:lines="1"
|
||||
android:layout_marginStart="@dimen/dp_15"
|
||||
/>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_like"
|
||||
android:layout_width="@dimen/dp_60"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="30dp"
|
||||
android:gravity="bottom"
|
||||
>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_like_pic"
|
||||
android:layout_width="@dimen/dp_22"
|
||||
android:layout_height="@dimen/dp_22"
|
||||
android:src="@drawable/icon_dy_list_like_false"
|
||||
android:scaleType="centerInside" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_like"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="2.5dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="bottom"
|
||||
android:gravity="center_vertical"
|
||||
android:textColor="@color/text_normal_c6c6e9"
|
||||
android:textSize="@dimen/sp_15"
|
||||
tools:text="0" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@@ -3,7 +3,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.chwl.app.community.widget.ZoomImageView
|
||||
<com.chwl.app.photo.ZoomImageView
|
||||
android:id="@+id/iv_photo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
@@ -1,44 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/fl_dialog_world"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_gravity="bottom"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/bg_white_top_0_8"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="480dp">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/fl_top_button"
|
||||
android:layout_width="@dimen/dp_18"
|
||||
android:layout_height="@dimen/dp_15"
|
||||
android:layout_gravity="center_horizontal">
|
||||
|
||||
<View
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
android:layout_width="18dp"
|
||||
android:layout_height="5dp"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:background="@drawable/bg_e6e6e6_0_2_5" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<com.chwl.app.ui.widget.magicindicator.MagicIndicator
|
||||
android:id="@+id/indicator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:visibility="gone"
|
||||
android:layout_marginBottom="8dp"/>
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/viewpager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/dp_20"/>
|
||||
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
@@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="15dp"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/common_item_view_margin_left_right"
|
||||
android:paddingRight="@dimen/common_item_view_margin_left_right">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_user_desc_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="13dp"
|
||||
android:text="@string/user_desc_text"
|
||||
android:textColor="@color/color_333333"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_desc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/color_999999"
|
||||
android:textSize="14dp" />
|
||||
|
||||
</LinearLayout>
|
@@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/ll_add_user_album"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="105dp"
|
||||
android:background="@color/white"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingTop="15dp"
|
||||
android:paddingRight="15dp"
|
||||
android:paddingBottom="15dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_empty_photo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@null"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/empty_user_album_text"
|
||||
android:textColor="@color/color_999999"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/photo_recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
@@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_game"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:text="@string/layout_layout_desc_game_01"
|
||||
android:textColor="#ff333333"
|
||||
android:textSize="15sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_game"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
@@ -1,108 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/layout_voice"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="15dp"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingRight="15dp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_voice_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="13dp"
|
||||
android:textColor="#333333"
|
||||
android:textSize="14sp"
|
||||
tools:ignore="RelativeOverlap"
|
||||
tools:text="@string/layout_layout_desc_voice_01" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/layout_voice_info"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/tv_voice_title"
|
||||
android:layout_marginBottom="15dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_voice_bar"
|
||||
android:layout_width="210dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@drawable/bg_voice_bar"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_voice_bar_play"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="7dp"
|
||||
android:layout_marginRight="7dp"
|
||||
android:src="@drawable/ic_voice_bar_play"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<com.chwl.app.audio.widget.VoiceLine
|
||||
android:id="@+id/layout_voice_line"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
app:voice_line_style="voice_corrugated"
|
||||
tools:ignore="RtlHardcoded" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_voice_duration"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginRight="15dp"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="18sp"
|
||||
tools:ignore="RelativeOverlap,RtlHardcoded"
|
||||
tools:text="15s" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/layout_voice_bar_no_data"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@drawable/bg_voice_bar_no_data"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/ic_voice_bar_no_data_add"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_voice_more"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@id/layout_voice_info"
|
||||
android:layout_alignBottom="@id/layout_voice_info"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:paddingStart="10dp"
|
||||
android:src="@mipmap/common_ic_more_arrow"
|
||||
android:visibility="gone"
|
||||
tools:ignore="ContentDescription,RtlSymmetry"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
@@ -1,87 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/ll_my_family_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/color_white"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_family_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/dp_15"
|
||||
android:layout_marginRight="@dimen/dp_15"
|
||||
android:paddingBottom="@dimen/dp_10"
|
||||
android:paddingTop="@dimen/dp_15"
|
||||
android:text="@string/family_user_info_label"
|
||||
android:textColor="@color/color_333333"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_my_family"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:background="@color/transparent"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="@dimen/dp_15"
|
||||
android:paddingRight="@dimen/dp_15">
|
||||
|
||||
<com.chwl.app.ui.widget.SquareImageView
|
||||
android:id="@+id/iv_family_cover"
|
||||
android:layout_width="55dp"
|
||||
android:layout_height="55dp"
|
||||
android:src="@drawable/default_cover" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_family_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/color_333333"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_family_id"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:textColor="@color/color_999999"
|
||||
android:textSize="14sp"
|
||||
tools:text="@string/family_id" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_family_member_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="17dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:textColor="@color/color_999999"
|
||||
android:textSize="14sp"
|
||||
tools:text="@string/family_member_count" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@mipmap/common_ic_more_arrow" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
@@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:id="@+id/tv_label_user_join_worlds"
|
||||
android:textColor="@color/color_333333"
|
||||
android:textSize="15sp"
|
||||
tools:text="@string/layout_layout_user_join_worlds_01"/>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_user_join_worlds"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</LinearLayout>
|
@@ -715,4 +715,6 @@
|
||||
<color name="color_1E1E1F">#1E1E1F</color>
|
||||
<color name="color_84868A">#84868A</color>
|
||||
<color name="color_8E9094">#8E9094</color>
|
||||
<color name="color_262629">#262629</color>
|
||||
<color name="color_FE6974">#FE6974</color>
|
||||
</resources>
|
||||
|
@@ -538,10 +538,6 @@
|
||||
<item name="cursorColor">#30F4F4F4</item>
|
||||
</style>
|
||||
|
||||
<style name="common_login_edit_style" parent="Theme.AppCompat.Light">
|
||||
<item name="android:background">@drawable/shape_trans_radius_10</item>
|
||||
</style>
|
||||
|
||||
<style name="style_login_btn">
|
||||
<item name="android:layout_width">0dp</item>
|
||||
<item name="android:layout_height">43dp</item>
|
||||
|
@@ -1,10 +0,0 @@
|
||||
package com.chwl.app.community;
|
||||
|
||||
/**
|
||||
* create by lvzebiao @2019/11/12
|
||||
*/
|
||||
public class ConstantValue {
|
||||
|
||||
public static final int CODE_CHOOSE_PHOTO = 12;
|
||||
|
||||
}
|
@@ -1,165 +0,0 @@
|
||||
package com.chwl.app.community.dynamic.adapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.UIHelper;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtilsV2;
|
||||
import com.chwl.app.utils.RegexUtil;
|
||||
import com.chwl.app.utils.TimeUiUtils;
|
||||
import com.chwl.app.vip.util.VipHelper;
|
||||
import com.chwl.core.community.bean.Comment;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* create by lvzebiao @2019/11/26
|
||||
*/
|
||||
public class CommentAdapter extends BaseQuickAdapter<Comment, BaseViewHolder> {
|
||||
|
||||
|
||||
public CommentAdapter() {
|
||||
super(R.layout.item_dy_comment);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, Comment item) {
|
||||
ImageLoadUtilsV2.loadAvatar(helper.getView(R.id.iv_avatar), item.getAvatar());
|
||||
TextView tvNick = helper.getView(R.id.tv_nick);
|
||||
tvNick.setText(RegexUtil.getPrintableString(item.getNick()));
|
||||
VipHelper.loadVipIcon(helper.getView(R.id.iv_vip_icon), item.getUserVipInfoVO());
|
||||
int endIcon = 0;
|
||||
if (item.isLandLordFlag()) {
|
||||
endIcon = R.drawable.icon_dy_dynamic_publisher;
|
||||
}
|
||||
tvNick.setCompoundDrawablesWithIntrinsicBounds(0, 0, endIcon, 0);
|
||||
helper.setText(R.id.tv_content, item.getContent());
|
||||
|
||||
helper.getView(R.id.iv_avatar).setOnClickListener(v ->
|
||||
UIHelper.showUserInfoAct(mContext, item.getUid()));
|
||||
|
||||
helper.setText(R.id.tv_time, TimeUiUtils.getDynamicUi(item.getPublishTime()));
|
||||
|
||||
helper.addOnLongClickListener(R.id.tv_content);
|
||||
helper.addOnClickListener(R.id.tv_content);
|
||||
|
||||
|
||||
//===========================回复=========================
|
||||
RecyclerView rvReply = helper.getView(R.id.rv_reply);
|
||||
|
||||
View lineReplyBottom = helper.getView(R.id.line_reply_bottom);
|
||||
if (item.isEmptyReply()) {
|
||||
lineReplyBottom.setVisibility(View.GONE);
|
||||
} else {
|
||||
lineReplyBottom.setVisibility(View.VISIBLE);
|
||||
}
|
||||
CommentReplyAdapter commentReplyAdapter = new CommentReplyAdapter(item.getReplyInfo().getLeftCount() > 0);
|
||||
rvReply.setLayoutManager(new LinearLayoutManager(mContext));
|
||||
rvReply.setAdapter(commentReplyAdapter);
|
||||
|
||||
commentReplyAdapter.setNewData(item.getReplyList());
|
||||
|
||||
commentReplyAdapter.setOnItemChildClickListener(new OnItemChildClickListener() {
|
||||
@Override
|
||||
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
|
||||
if (onCommentReplyItemChildClickListener != null) {
|
||||
onCommentReplyItemChildClickListener.onCommentReplyItemChildClick(view,
|
||||
helper.getAdapterPosition() - 1, position);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
commentReplyAdapter.setOnItemChildLongClickListener(new OnItemChildLongClickListener() {
|
||||
@Override
|
||||
public boolean onItemChildLongClick(BaseQuickAdapter adapter, View view, int position) {
|
||||
if (onCommentReplyItemChildClickListener != null) {
|
||||
onCommentReplyItemChildClickListener.onCommentReplyItemChildLongClick(view,
|
||||
helper.getAdapterPosition() - 1, position);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
View mFooterView = LayoutInflater.from(mContext).inflate(R.layout.item_reply_footer_view, null);
|
||||
|
||||
if (item.getReplyInfo().getLeftCount() > 0) { //剩余回复大于0
|
||||
((TextView) mFooterView).setText(String.format(mContext.getResources().getString(R.string.dy_open_other_number),
|
||||
String.valueOf(item.getReplyInfo().getLeftCount())));
|
||||
commentReplyAdapter.addFooterView(mFooterView);
|
||||
} else {
|
||||
commentReplyAdapter.removeAllFooterView();
|
||||
}
|
||||
|
||||
mFooterView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
onCommentReplyItemChildClickListener.onLoadMoreClick(
|
||||
item.getCommentId(),
|
||||
item.getReplyInfo().getNextTimestamp(),
|
||||
helper.getLayoutPosition() - 1);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private OnCommentReplyItemChildClickListener onCommentReplyItemChildClickListener;
|
||||
|
||||
public interface OnCommentReplyItemChildClickListener {
|
||||
|
||||
void onCommentReplyItemChildClick(View view, int groupPosition, int childPosition);
|
||||
|
||||
void onCommentReplyItemChildLongClick(View view, int groupPosition, int childPosition);
|
||||
|
||||
void onLoadMoreClick(long commentId, long nextReplyId, int groupPosition);
|
||||
|
||||
}
|
||||
|
||||
public void setOnCommentReplyItemChildClickListener(OnCommentReplyItemChildClickListener onCommentReplyItemChildClickListener) {
|
||||
this.onCommentReplyItemChildClickListener = onCommentReplyItemChildClickListener;
|
||||
}
|
||||
|
||||
public long getItemCommentId(int pos) {
|
||||
List<Comment> list = getData();
|
||||
if (ListUtils.isListEmpty(list)) {
|
||||
return 0;
|
||||
}
|
||||
if (pos >= 0 && pos < list.size()) {
|
||||
Comment comment = list.get(pos);
|
||||
if (comment != null) {
|
||||
return comment.getCommentId();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Comment getDataItem(int pos) {
|
||||
List<Comment> list = getData();
|
||||
if (ListUtils.isListEmpty(list)) {
|
||||
return null;
|
||||
}
|
||||
if (pos >= 0 && pos < list.size()) {
|
||||
return list.get(pos);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void safeDelete(int pos) {
|
||||
List<Comment> list = getData();
|
||||
if (pos >= 0 && pos < list.size()) {
|
||||
list.remove(pos);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,74 +0,0 @@
|
||||
package com.chwl.app.community.dynamic.adapter;
|
||||
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.UIHelper;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtilsV2;
|
||||
import com.chwl.app.utils.RegexUtil;
|
||||
import com.chwl.app.utils.SpannableBuilder;
|
||||
import com.chwl.app.utils.TimeUiUtils;
|
||||
import com.chwl.app.vip.util.VipHelper;
|
||||
import com.chwl.core.community.bean.comment.Reply;
|
||||
|
||||
/**
|
||||
* create by lvzebiao @2019/11/27
|
||||
*/
|
||||
public class CommentReplyAdapter extends BaseQuickAdapter<Reply, BaseViewHolder> {
|
||||
|
||||
private boolean hasExpandFooter;
|
||||
|
||||
public CommentReplyAdapter(boolean hasExpandFooter) {
|
||||
super(R.layout.item_dy_reply);
|
||||
this.hasExpandFooter = hasExpandFooter;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, Reply item) {
|
||||
|
||||
ImageLoadUtilsV2.loadAvatar(helper.getView(R.id.iv_avatar), item.getAvatar(), true);
|
||||
TextView tvNick = helper.getView(R.id.tv_nick);
|
||||
tvNick.setText(RegexUtil.getPrintableString(item.getNick()));
|
||||
VipHelper.loadVipIcon(helper.getView(R.id.iv_vip_icon), item.getUserVipInfoVO());
|
||||
int endIcon = 0;
|
||||
if (item.isLandLordFlag()) {
|
||||
endIcon = R.drawable.icon_dy_dynamic_publisher;
|
||||
}
|
||||
tvNick.setCompoundDrawablesWithIntrinsicBounds(0, 0, endIcon, 0);
|
||||
|
||||
SpannableBuilder builder = new SpannableBuilder();
|
||||
builder.append("@" + item.getToNick(),
|
||||
new ForegroundColorSpan(mContext.getResources().getColor(R.color.color_7154EE)))
|
||||
.append(" " + item.getContent(),
|
||||
new ForegroundColorSpan(mContext.getResources().getColor(R.color.text_normal_c6c6e9)));
|
||||
|
||||
helper.setText(R.id.tv_content, builder.build());
|
||||
|
||||
helper.getView(R.id.iv_avatar).setOnClickListener(v ->
|
||||
UIHelper.showUserInfoAct(mContext, item.getUid()));
|
||||
|
||||
helper.setText(R.id.tv_time, TimeUiUtils.getDynamicUi(item.getPublishTime()));
|
||||
|
||||
helper.addOnClickListener(R.id.item_reply_constraintlayout)
|
||||
.addOnClickListener(R.id.tv_content);
|
||||
helper.addOnLongClickListener(R.id.tv_content);
|
||||
|
||||
View line = helper.getView(R.id.view_line_reply);
|
||||
if (hasExpandFooter) {
|
||||
line.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
//没有回复项的时候,最后一项的线隐藏
|
||||
if (helper.getAdapterPosition() == getData().size() - 1) {
|
||||
line.setVisibility(View.GONE);
|
||||
} else {
|
||||
line.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@@ -1,319 +0,0 @@
|
||||
package com.chwl.app.community.dynamic.adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.util.SparseIntArray;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.netease.nim.uikit.support.glide.GlideApp;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.UIHelper;
|
||||
import com.chwl.app.community.dynamic.view.DynamicDetailActivity;
|
||||
import com.chwl.app.community.helper.CalcSize;
|
||||
import com.chwl.app.community.helper.DynamicUiHelper;
|
||||
import com.chwl.app.community.helper.ImageUiHelper;
|
||||
import com.chwl.app.community.photo.BigPhotoActivity;
|
||||
import com.chwl.app.community.photo.DynamicImageAdapter;
|
||||
import com.chwl.app.community.photo.PagerOption;
|
||||
import com.chwl.app.community.utils.ObjectTypeHelper;
|
||||
import com.chwl.app.community.utils.TopicUpTextWrapper;
|
||||
import com.chwl.app.community.widget.DynamicNickDetailWidget;
|
||||
import com.chwl.app.community.widget.ExpandableTextView;
|
||||
import com.chwl.app.community.widget.TopicLabelWidget;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtilsV2;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.chwl.app.utils.TimeUiUtils;
|
||||
import com.chwl.core.community.bean.DynamicMedia;
|
||||
import com.chwl.core.community.bean.WorldDynamicBean;
|
||||
import com.chwl.core.community.dynamic.DynamicModel;
|
||||
import com.chwl.core.noble.NobleUtil;
|
||||
import com.chwl.core.utils.net.DontWarnObserver;
|
||||
import com.chwl.core.utils.net.RxHelper;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* create by lvzebiao @2019/11/13
|
||||
*/
|
||||
public class WorldDynamicAdapter extends BaseQuickAdapter<WorldDynamicBean, BaseViewHolder> {
|
||||
|
||||
private SparseBooleanArray mCollapsedStatus = new SparseBooleanArray();
|
||||
private SparseIntArray mCollapsedHeightStatus = new SparseIntArray(2);
|
||||
|
||||
private Context context;
|
||||
|
||||
private long worldId;
|
||||
|
||||
private int iconWidth;
|
||||
|
||||
private int iconHeight;
|
||||
|
||||
/**
|
||||
* 有文本的图片布局的top-margin
|
||||
*/
|
||||
private int imageTmHasText;
|
||||
/**
|
||||
* 无文本的图片布局的top-margin
|
||||
*/
|
||||
private int imageTmNoText;
|
||||
|
||||
/**
|
||||
* 单图情况下的边界
|
||||
*/
|
||||
private int imageBorder;
|
||||
/**
|
||||
* 图片的边界值
|
||||
*/
|
||||
private int divider;
|
||||
|
||||
public WorldDynamicAdapter(Context context, long worldId) {
|
||||
super(R.layout.item_world_dynamic);
|
||||
this.context = context;
|
||||
this.worldId = worldId;
|
||||
iconWidth = UIUtil.dip2px(context, 32);
|
||||
iconHeight = UIUtil.dip2px(context, 15);
|
||||
imageTmHasText = UIUtil.dip2px(context, 15f);
|
||||
imageTmNoText = UIUtil.dip2px(context, 7.5f);
|
||||
//0.68
|
||||
imageBorder = UIUtil.getScreenWidth(context) * ImageUiHelper.BORDER_MIN / ImageUiHelper.BORDER_MAX;
|
||||
divider = UIUtil.dip2px(context, 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, WorldDynamicBean item) {
|
||||
//这个值,有没有文本UI部分,改变图片部分的margin
|
||||
boolean noTextUi = TextUtils.isEmpty(item.getContent());
|
||||
|
||||
helper.setText(R.id.tv_nick, item.getNick());
|
||||
RecyclerView rvImage = helper.getView(R.id.rv_image);
|
||||
List<DynamicMedia> dynamicMediaList = item.getDynamicResList();
|
||||
if (item.getType() == WorldDynamicBean.TYPE_IMAGE
|
||||
&& dynamicMediaList != null && dynamicMediaList.size() > 0) {
|
||||
rvImage.setVisibility(View.VISIBLE);
|
||||
initRecyclerView(rvImage, dynamicMediaList, noTextUi);
|
||||
} else {
|
||||
rvImage.setVisibility(View.GONE);
|
||||
}
|
||||
//头饰 贵族头饰
|
||||
ImageView ivHeadWear = helper.getView(R.id.iv_head_wear);
|
||||
GlideApp.with(ivHeadWear.getContext()).clear(ivHeadWear);
|
||||
String headwearPic = item.getHeadwearPic();
|
||||
String micDecorate = item.getMicDecorate();
|
||||
if (!TextUtils.isEmpty(headwearPic)) {
|
||||
NobleUtil.loadHeadWear(headwearPic, ivHeadWear);
|
||||
} else if (!TextUtils.isEmpty(micDecorate)) {
|
||||
NobleUtil.loadResource(micDecorate, ivHeadWear);
|
||||
} else {
|
||||
ivHeadWear.setImageDrawable(null);
|
||||
}
|
||||
|
||||
//头像
|
||||
ImageLoadUtilsV2.loadImage(helper.getView(R.id.iv_avatar), item.getAvatar());
|
||||
|
||||
DynamicNickDetailWidget widget = helper.getView(R.id.widget_nick_detail);
|
||||
widget.setData(item);
|
||||
View inOfficialMask = helper.getView(R.id.in_official_mask);
|
||||
if (!TextUtils.isEmpty(item.getNameplateWord()) && !TextUtils.isEmpty(item.getNameplatePic())) {
|
||||
inOfficialMask.setVisibility(View.VISIBLE);
|
||||
TextView tvOfficialMask = inOfficialMask.findViewById(R.id.tv_official_mask);
|
||||
if (tvOfficialMask != null) {
|
||||
tvOfficialMask.setText(item.getNameplateWord());
|
||||
}
|
||||
|
||||
ImageView ivOfficialMask = inOfficialMask.findViewById(R.id.iv_official_mask);
|
||||
if (ivOfficialMask != null) {
|
||||
NobleUtil.loadResource(item.getNameplatePic(), ivOfficialMask);
|
||||
}
|
||||
} else {
|
||||
inOfficialMask.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
//时间
|
||||
final String time = TimeUiUtils.getDynamicUi(item.getPublishTime());
|
||||
helper.setGone(R.id.tv_time, !TextUtils.isEmpty(time));
|
||||
helper.setText(R.id.tv_time, time);
|
||||
|
||||
ExpandableTextView etvContent = helper.getView(R.id.etv_content);
|
||||
etvContent.setEventType(1);
|
||||
if (noTextUi && item.getTopicTop() == 0) {
|
||||
etvContent.setVisibility(View.GONE);
|
||||
} else {
|
||||
etvContent.setVisibility(View.VISIBLE);
|
||||
CharSequence formatText = DynamicUiHelper.formatFirstDynamicContent(
|
||||
item, etvContent.mTv, iconWidth, iconHeight);
|
||||
if (item.getTopicTop() == 1) {
|
||||
//置顶
|
||||
formatText = TopicUpTextWrapper.INSTANCE.wrapUp(formatText, context);
|
||||
}
|
||||
etvContent.setText(formatText, mCollapsedStatus, helper.getAdapterPosition(), mCollapsedHeightStatus);
|
||||
}
|
||||
//标签
|
||||
final List<String> labels = item.getLabelList();
|
||||
if (labels != null) {
|
||||
((TopicLabelWidget) helper.getView(R.id.topicView)).setLabels(labels);
|
||||
}
|
||||
|
||||
final String worldName = item.getWorldName();
|
||||
helper.setText(R.id.tv_mini_world_name, "#" + worldName);
|
||||
helper.setGone(R.id.tv_mini_world_name, !TextUtils.isEmpty(worldName));
|
||||
helper.setGone(R.id.space_view, !TextUtils.isEmpty(time) || !TextUtils.isEmpty(worldName));
|
||||
//评论
|
||||
setCommentCount(helper, item.getCommentCount());
|
||||
|
||||
//点赞
|
||||
setLikeCount(helper, item.getLikeCount(), item.isLike(), false);
|
||||
LinearLayout llLike = helper.getView(R.id.ll_like);
|
||||
llLike.setEnabled(true);
|
||||
llLike.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
llLike.setEnabled(false);
|
||||
int status = item.isLike() ? 0 : 1;
|
||||
DynamicModel.get().like(worldId, item.getDynamicId(), item.getUid(), status, 1)
|
||||
.compose(RxHelper.bindContext(context))
|
||||
.subscribe(new DontWarnObserver<String>() {
|
||||
@Override
|
||||
public void accept(String s, String error) {
|
||||
super.accept(s, error);
|
||||
llLike.setEnabled(true);
|
||||
if (error != null) {
|
||||
SingleToastUtil.showToast(error);
|
||||
} else {
|
||||
LogUtil.print(ResUtil.getString(R.string.dynamic_adapter_worlddynamicadapter_01));
|
||||
if (status == 1) {
|
||||
item.setLikeCount(item.getLikeCount() + 1);
|
||||
} else {
|
||||
item.setLikeCount(item.getLikeCount() - 1);
|
||||
}
|
||||
item.setLike(status == 1);
|
||||
setLikeCount(helper, item.getLikeCount(), item.isLike(), true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
//评论
|
||||
helper.getView(R.id.ll_comment).setOnClickListener(v -> {
|
||||
DynamicDetailActivity.start(context, item.getDynamicId(), worldId,
|
||||
helper.getAdapterPosition(), true, 1);
|
||||
}
|
||||
);
|
||||
|
||||
View.OnClickListener toDetailListener = v ->
|
||||
DynamicDetailActivity.start(context, item.getDynamicId(), worldId,
|
||||
helper.getAdapterPosition(), false, 1);
|
||||
|
||||
if (etvContent.mTv != null) {
|
||||
etvContent.mTv.setOnClickListener(toDetailListener);
|
||||
}
|
||||
|
||||
//跳转去详情
|
||||
helper.itemView.setOnClickListener(toDetailListener);
|
||||
|
||||
helper.addOnClickListener(R.id.iv_more)
|
||||
.addOnClickListener(R.id.ll_share);
|
||||
|
||||
View.OnClickListener userInfoActClick = v -> UIHelper.showUserInfoAct(context, item.getUid());
|
||||
helper.getView(R.id.iv_avatar).setOnClickListener(userInfoActClick);
|
||||
helper.getView(R.id.widget_nick_detail).setOnClickListener(userInfoActClick);
|
||||
|
||||
}
|
||||
|
||||
private void setLikeCount(BaseViewHolder helper, int likeCount, boolean isLike, boolean isAnim) {
|
||||
TextView tvLike = helper.getView(R.id.tv_like);
|
||||
String likeCountStr;
|
||||
if (likeCount < 0) {
|
||||
likeCountStr = "0";
|
||||
} else if (likeCount >= 1000) {
|
||||
likeCountStr = "999+";
|
||||
} else {
|
||||
likeCountStr = String.valueOf(likeCount);
|
||||
}
|
||||
tvLike.setText(likeCountStr);
|
||||
|
||||
ImageView ivLikeAnim = helper.getView(R.id.iv_like_pic);
|
||||
if (isLike) {
|
||||
// if (isAnim) {
|
||||
// AnimationDrawable drawable = (AnimationDrawable) context.getResources()
|
||||
// .getDrawable(R.drawable.anim_list_dy_like);
|
||||
// ivLikeAnim.setImageDrawable(drawable);
|
||||
// drawable.stop();
|
||||
// drawable.start();
|
||||
// } else {
|
||||
ivLikeAnim.setImageResource(R.drawable.icon_dy_list_like);
|
||||
// }
|
||||
} else {
|
||||
ivLikeAnim.setImageResource(R.drawable.icon_dy_list_like_false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void initRecyclerView(RecyclerView rvImage, List<DynamicMedia> imageUrl, boolean noTextUi) {
|
||||
if (imageUrl == null) {
|
||||
return;
|
||||
}
|
||||
CalcSize calcSize = new CalcSize(imageBorder);
|
||||
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) rvImage.getLayoutParams();
|
||||
if (imageUrl.size() > 1) {
|
||||
params.width = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
} else {
|
||||
//单图的情况,按比例显示
|
||||
DynamicMedia media = null;
|
||||
if (imageUrl.size() > 0) {
|
||||
media = imageUrl.get(0);
|
||||
}
|
||||
if (media == null) {
|
||||
return;
|
||||
}
|
||||
calcSize = ImageUiHelper.calcImage(media, imageBorder);
|
||||
params.width = calcSize.width + divider;
|
||||
params.height = calcSize.height + divider;
|
||||
}
|
||||
if (noTextUi) {
|
||||
params.topMargin = imageTmNoText;
|
||||
} else {
|
||||
params.topMargin = imageTmHasText;
|
||||
}
|
||||
rvImage.setLayoutParams(params);
|
||||
rvImage.setNestedScrollingEnabled(false);
|
||||
rvImage.setLayoutManager(new GridLayoutManager(mContext, imageUrl.size() > 2 ? 3 : imageUrl.size()));
|
||||
DynamicImageAdapter adapter = new DynamicImageAdapter(R.layout.item_dynamic_image, imageUrl);
|
||||
adapter.setSingleImageHeight(calcSize.height);
|
||||
adapter.setOnItemClickListener((adapter1, view, position) -> {
|
||||
PagerOption option = new PagerOption().setSave(true);
|
||||
BigPhotoActivity.start((Activity) mContext, ObjectTypeHelper.mediaToCustomList(imageUrl),
|
||||
position, option);
|
||||
}
|
||||
);
|
||||
rvImage.setAdapter(adapter);
|
||||
}
|
||||
|
||||
private void setCommentCount(BaseViewHolder helper, int commentCount) {
|
||||
TextView tvComment = helper.getView(R.id.tv_comment);
|
||||
String commentCountStr;
|
||||
if (commentCount < 0) {
|
||||
commentCountStr = "0";
|
||||
} else if (commentCount >= 1000) {
|
||||
commentCountStr = "999+";
|
||||
} else {
|
||||
commentCountStr = String.valueOf(commentCount);
|
||||
}
|
||||
tvComment.setText(commentCountStr);
|
||||
}
|
||||
|
||||
}
|
@@ -1,13 +0,0 @@
|
||||
package com.chwl.app.community.dynamic.presenter;
|
||||
|
||||
import com.chwl.app.base.BaseMvpPresenter;
|
||||
import com.chwl.app.community.dynamic.view.IWorldDynamicView;
|
||||
|
||||
/**
|
||||
* create by lvzebiao @2019/11/21
|
||||
*/
|
||||
public class WorldDynamicPresenter extends BaseMvpPresenter<IWorldDynamicView> {
|
||||
|
||||
|
||||
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
package com.chwl.app.community.dynamic.view;
|
||||
|
||||
import com.chwl.library.base.IMvpBaseView;
|
||||
|
||||
/**
|
||||
* create by lvzebiao @2019/11/21
|
||||
*/
|
||||
public interface IWorldDynamicView extends IMvpBaseView {
|
||||
}
|
@@ -1,387 +0,0 @@
|
||||
package com.chwl.app.community.dynamic.view;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import com.trello.rxlifecycle3.android.FragmentEvent;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.UIHelper;
|
||||
import com.chwl.app.base.BaseMvpFragment;
|
||||
import com.chwl.app.common.widget.dialog.DialogManager;
|
||||
import com.chwl.app.community.dynamic.adapter.WorldDynamicAdapter;
|
||||
import com.chwl.app.community.dynamic.presenter.WorldDynamicPresenter;
|
||||
import com.chwl.app.community.helper.ShareDynamicHelper;
|
||||
import com.chwl.app.miniworld.activity.MiniWorldGuestPageActivity;
|
||||
import com.chwl.app.ui.widget.ButtonItem;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.chwl.core.XConstants;
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
import com.chwl.core.community.bean.WorldDynamicBean;
|
||||
import com.chwl.core.community.bean.WorldDynamicListResult;
|
||||
import com.chwl.core.community.dynamic.DynamicModel;
|
||||
import com.chwl.core.community.event.DynamicDetailFinishEvent;
|
||||
import com.chwl.core.community.event.DynamicPublishEvent;
|
||||
import com.chwl.core.user.UserModel;
|
||||
import com.chwl.core.utils.net.DontWarnObserver;
|
||||
import com.chwl.library.base.factory.CreatePresenter;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SizeUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* create by lvzebiao @2019/11/13
|
||||
*/
|
||||
@CreatePresenter(WorldDynamicPresenter.class)
|
||||
public class WorldDynamicFragment extends BaseMvpFragment<IWorldDynamicView, WorldDynamicPresenter> implements IWorldDynamicView {
|
||||
|
||||
private RecyclerView rvDynamic;
|
||||
|
||||
private SwipeRefreshLayout refreshLayout;
|
||||
|
||||
private WorldDynamicAdapter adapter;
|
||||
|
||||
private View footerView;
|
||||
|
||||
private long worldId = 0L;
|
||||
|
||||
private int mType = -1;
|
||||
|
||||
private static final int TYPE_DYNAMIC_RECOMMEND = 0;
|
||||
|
||||
private static final int TYPE_DYNAMIC_LATEST = 1;
|
||||
|
||||
private boolean isLoading, noMoreData;
|
||||
/**
|
||||
* 刷新的时候,传null
|
||||
*/
|
||||
private String nextDynamicId;
|
||||
|
||||
private int currentPage = 1;
|
||||
|
||||
public static WorldDynamicFragment newInstance(long worldId, int type) {
|
||||
WorldDynamicFragment fragment = new WorldDynamicFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putLong("worldId", worldId);
|
||||
bundle.putInt("type", type);// 0推荐,1最新
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
EventBus.getDefault().unregister(this);
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRootLayoutId() {
|
||||
return R.layout.fragment_world_dynamic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFindViews() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetListener() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initiate() {
|
||||
if (getArguments() != null) {
|
||||
worldId = getArguments().getLong("worldId");
|
||||
mType = getArguments().getInt("type");
|
||||
}
|
||||
rvDynamic = mView.findViewById(R.id.rv_dynamic);
|
||||
rvDynamic.setLayoutManager(new LinearLayoutManager(mContext));
|
||||
adapter = new WorldDynamicAdapter(getActivity(), worldId);
|
||||
|
||||
footerView = LayoutInflater.from(mContext).inflate(R.layout.dy_footer_loadmore, null);
|
||||
adapter.addFooterView(footerView);
|
||||
|
||||
rvDynamic.setAdapter(adapter);
|
||||
rvDynamic.addItemDecoration(new RecyclerView.ItemDecoration() {
|
||||
|
||||
@Override
|
||||
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
|
||||
super.getItemOffsets(outRect, view, parent, state);
|
||||
int bottom = SizeUtils.dp2px(getContext(), 16);
|
||||
outRect.set(0, 0, 0, bottom);
|
||||
}
|
||||
});
|
||||
|
||||
rvDynamic.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
||||
super.onScrollStateChanged(recyclerView, newState);
|
||||
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
||||
if (isLoading || noMoreData) {
|
||||
return;
|
||||
}
|
||||
LinearLayoutManager manager = (LinearLayoutManager) rvDynamic.getLayoutManager();
|
||||
int lastPos = manager.findLastVisibleItemPosition();
|
||||
if (lastPos >= adapter.getItemCount() - 2) {
|
||||
loadData(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
adapter.setOnItemChildClickListener((baseQuickAdapter, view, pos) -> {
|
||||
WorldDynamicBean bean = adapter.getItem(pos);
|
||||
if (bean == null) {
|
||||
return;
|
||||
}
|
||||
if (view.getId() == R.id.iv_more) {
|
||||
List<ButtonItem> list = new ArrayList<>();
|
||||
if (!UserModel.get().isMyseft(bean.getUid())) {
|
||||
ButtonItem item = new ButtonItem(ResUtil.getString(R.string.dynamic_view_worlddynamicfragment_01), () -> {
|
||||
UIHelper.showReportPage(WorldDynamicFragment.this.getActivity(), bean.getUid(),
|
||||
XConstants.REPORT_TYPE_WORLDDYNAMIC);
|
||||
});
|
||||
list.add(item);
|
||||
}
|
||||
if (UserModel.get().isMyseft(bean.getUid()) ||
|
||||
isThisWorldOwner()) {
|
||||
ButtonItem item = new ButtonItem(ResUtil.getString(R.string.dynamic_view_worlddynamicfragment_03), () -> deleteDynamic(pos));
|
||||
list.add(item);
|
||||
}
|
||||
getDialogManager().showCommonPopupDialog(list, ResUtil.getString(R.string.dynamic_view_worlddynamicfragment_04));
|
||||
} else if (view.getId() == R.id.ll_share) {
|
||||
new ShareDynamicHelper(getActivity()).share(bean, worldId);
|
||||
}
|
||||
});
|
||||
|
||||
refreshLayout = mView.findViewById(R.id.refresh_layout);
|
||||
refreshLayout.setOnRefreshListener(() -> {
|
||||
loadData(true);
|
||||
});
|
||||
|
||||
loadData(true);
|
||||
EventBus.getDefault().register(this);
|
||||
|
||||
}
|
||||
|
||||
private void showLoadmoreView() {
|
||||
ViewGroup.LayoutParams params = footerView.getLayoutParams();
|
||||
params.height = UIUtil.dip2px(mContext, 60);
|
||||
footerView.setLayoutParams(params);
|
||||
}
|
||||
|
||||
private void hideLoadmoreView() {
|
||||
ViewGroup.LayoutParams params = footerView.getLayoutParams();
|
||||
params.height = 0;
|
||||
footerView.setLayoutParams(params);
|
||||
}
|
||||
|
||||
private void loadData(boolean isRefresh) {
|
||||
if (isLoading) {
|
||||
return;
|
||||
}
|
||||
if (isRefresh) {
|
||||
nextDynamicId = null;
|
||||
noMoreData = false;
|
||||
currentPage = 1;
|
||||
}
|
||||
isLoading = true;
|
||||
|
||||
|
||||
if (mType == TYPE_DYNAMIC_RECOMMEND) {
|
||||
DynamicModel.get().getDynamicList(currentPage, worldId, nextDynamicId)
|
||||
.compose(bindUntilEvent(FragmentEvent.DESTROY_VIEW))
|
||||
.subscribe(new DontWarnObserver<WorldDynamicListResult>() {
|
||||
@Override
|
||||
public void accept(WorldDynamicListResult result, String error) {
|
||||
super.accept(result, error);
|
||||
refreshLayout.setRefreshing(false);
|
||||
hideStatus();
|
||||
isLoading = false;
|
||||
currentPage++;
|
||||
if (error != null) {
|
||||
hideLoadmoreView();
|
||||
toast(error);
|
||||
return;
|
||||
}
|
||||
//接口访问正确的处理
|
||||
List<WorldDynamicBean> list = result.getDynamicList();
|
||||
nextDynamicId = String.valueOf(result.getNextDynamicId());
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
if (isRefresh) {
|
||||
adapter.setNewData(list);
|
||||
} else {
|
||||
adapter.addData(list);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
showLoadmoreView();
|
||||
} else {
|
||||
noMoreData = true;
|
||||
hideLoadmoreView();
|
||||
if (isRefresh) {
|
||||
showNoData(R.drawable.icon_common_failure,
|
||||
getString(R.string.dy_world_dynamic_list_empty_tips));
|
||||
}
|
||||
}
|
||||
//如果第一页访问得到的数据特别少,直接加载下一页
|
||||
if (list.size() > 0 && adapter.getItemCount() <= 6) {
|
||||
loadData(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
DynamicModel.get().getLatestDynamicList(worldId, nextDynamicId)
|
||||
.compose(bindUntilEvent(FragmentEvent.DESTROY_VIEW))
|
||||
.subscribe(new DontWarnObserver<WorldDynamicListResult>() {
|
||||
@Override
|
||||
public void accept(WorldDynamicListResult result, String error) {
|
||||
super.accept(result, error);
|
||||
refreshLayout.setRefreshing(false);
|
||||
hideStatus();
|
||||
isLoading = false;
|
||||
currentPage++;
|
||||
if (error != null) {
|
||||
hideLoadmoreView();
|
||||
toast(error);
|
||||
return;
|
||||
}
|
||||
//接口访问正确的处理
|
||||
List<WorldDynamicBean> list = result.getDynamicList();
|
||||
nextDynamicId = String.valueOf(result.getNextDynamicId());
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
if (isRefresh) {
|
||||
adapter.setNewData(list);
|
||||
} else {
|
||||
adapter.addData(list);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
showLoadmoreView();
|
||||
} else {
|
||||
noMoreData = true;
|
||||
hideLoadmoreView();
|
||||
if (isRefresh) {
|
||||
showNoData(R.drawable.icon_common_failure,
|
||||
getString(R.string.dy_world_dynamic_list_empty_tips));
|
||||
}
|
||||
}
|
||||
//如果第一页访问得到的数据特别少,直接加载下一页
|
||||
if (list.size() > 0 && adapter.getItemCount() <= 6) {
|
||||
loadData(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void deleteDynamic(int pos) {
|
||||
getDialogManager().showOkCancelWithTitleDialog(ResUtil.getString(R.string.dynamic_view_worlddynamicfragment_07),
|
||||
new DialogManager.OkCancelDialogListener() {
|
||||
@Override
|
||||
public void onOk() {
|
||||
WorldDynamicBean bean = adapter.getItem(pos);
|
||||
if (bean == null) {
|
||||
return;
|
||||
}
|
||||
DynamicModel.get().delete(worldId, bean.getDynamicId())
|
||||
.compose(bindUntilEvent(FragmentEvent.DESTROY_VIEW))
|
||||
.subscribe(new DontWarnObserver<String>() {
|
||||
@Override
|
||||
public void accept(String s, String error) {
|
||||
super.accept(s, error);
|
||||
if (error != null) {
|
||||
toast(error);
|
||||
} else {
|
||||
toast(ResUtil.getString(R.string.dynamic_view_worlddynamicfragment_08));
|
||||
if (pos < adapter.getData().size()) {
|
||||
if (Objects.equals(bean, adapter.getItem(pos))) {
|
||||
adapter.remove(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断自己是不是该世界的创始人
|
||||
*/
|
||||
private boolean isThisWorldOwner() {
|
||||
if (getActivity() instanceof MiniWorldGuestPageActivity) {
|
||||
MiniWorldGuestPageActivity activity = (MiniWorldGuestPageActivity) getActivity();
|
||||
if (activity.getMvpPresenter() != null) {
|
||||
return activity.getMvpPresenter().getWorldOwnerUid()
|
||||
== AuthModel.get().getCurrentUid();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReloadData() {
|
||||
showLoading();
|
||||
loadData(true);
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onDynamicDetailFinishEvent(DynamicDetailFinishEvent event) {
|
||||
int listPosition = event.getListPosition();
|
||||
List<WorldDynamicBean> list = adapter.getData();
|
||||
if (listPosition >= 0 && listPosition < list.size()) {
|
||||
WorldDynamicBean oldBean = list.get(listPosition);
|
||||
WorldDynamicBean newBean = event.getBean();
|
||||
if (!Objects.equals(oldBean, newBean)) {
|
||||
return;
|
||||
}
|
||||
if (event.isDelete()) {
|
||||
adapter.remove(listPosition);
|
||||
return;
|
||||
}
|
||||
boolean change = false;
|
||||
if (oldBean.isLike() != newBean.isLike()) {
|
||||
oldBean.setLike(newBean.isLike());
|
||||
change = true;
|
||||
}
|
||||
if (oldBean.getLikeCount() != newBean.getLikeCount()) {
|
||||
oldBean.setLikeCount(newBean.getLikeCount());
|
||||
change = true;
|
||||
}
|
||||
if (oldBean.getCommentCount() != newBean.getCommentCount()) {
|
||||
oldBean.setCommentCount(newBean.getCommentCount());
|
||||
change = true;
|
||||
}
|
||||
if (change) {
|
||||
adapter.notifyItemChanged(listPosition);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onDynamicPublishEvent(DynamicPublishEvent event) {
|
||||
loadData(true);
|
||||
}
|
||||
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
package com.chwl.app.community.helper;
|
||||
|
||||
/**
|
||||
* create by lvzebiao @2020/1/3
|
||||
*/
|
||||
public class CalcSize {
|
||||
|
||||
public CalcSize(int size) {
|
||||
width = size;
|
||||
height = size;
|
||||
}
|
||||
|
||||
public CalcSize() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public int width;
|
||||
|
||||
public int height;
|
||||
|
||||
}
|
@@ -1,29 +0,0 @@
|
||||
package com.chwl.app.community.helper;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.chwl.app.avroom.widget.MessageView;
|
||||
import com.chwl.core.community.bean.WorldDynamicBean;
|
||||
|
||||
/**
|
||||
* create by lvzebiao @2019/12/4
|
||||
*/
|
||||
public class DynamicUiHelper {
|
||||
|
||||
public static CharSequence formatFirstDynamicContent(WorldDynamicBean item, TextView textView,
|
||||
int iconWidth, int iconHeight) {
|
||||
MessageView.SpannableBuilder builder = new MessageView.SpannableBuilder(textView);
|
||||
// if (item.isFirstDynamic()) {
|
||||
// builder.append(textView.getResources().getDrawable(R.drawable.icon_dy_first_dynamic), iconWidth,
|
||||
// iconHeight);
|
||||
// }
|
||||
if (!TextUtils.isEmpty(item.getContent())) {
|
||||
builder.append(item.getContent());
|
||||
} else {
|
||||
builder.append(" ");
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
}
|
@@ -1,73 +0,0 @@
|
||||
package com.chwl.app.community.helper;
|
||||
|
||||
import com.chwl.core.community.bean.DynamicMedia;
|
||||
|
||||
/**
|
||||
* create by lvzebiao @2020/1/3
|
||||
*/
|
||||
public class ImageUiHelper {
|
||||
/**
|
||||
* 图片最大宽度和父布局比例
|
||||
* 0.68
|
||||
*/
|
||||
public final static int BORDER_MIN = 68;
|
||||
/**
|
||||
* 图片最大宽度和父布局比例
|
||||
* 0.68
|
||||
*/
|
||||
public final static int BORDER_MAX = 100;
|
||||
|
||||
/**
|
||||
* 比例最大2.5,我们用分子分母来表示
|
||||
*/
|
||||
public final static int OFFSET_MIN = 2;
|
||||
|
||||
/**
|
||||
* 比例最大2.5,我们用分子分母来表示
|
||||
*/
|
||||
public final static int OFFSET_MAX = 5;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param width -
|
||||
* @param height -
|
||||
* @param border 图片展示的最大边界
|
||||
* @return -
|
||||
*/
|
||||
public static CalcSize calcImage(int width, int height, int border) {
|
||||
CalcSize calcSize = new CalcSize();
|
||||
int singleImageWidth = border; //单图宽
|
||||
int singleImageHeight = border; //单图高
|
||||
if (width >= height) {
|
||||
//横图的情况
|
||||
if (height * OFFSET_MAX <= width * OFFSET_MIN) {
|
||||
singleImageHeight = border * OFFSET_MIN / OFFSET_MAX;
|
||||
} else {
|
||||
if (width > 0) {
|
||||
singleImageHeight = border * height / width;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//竖图的情况
|
||||
//判断比例是否超过2.5
|
||||
if (width * OFFSET_MAX <= height * OFFSET_MIN) {
|
||||
singleImageWidth = border * OFFSET_MIN / OFFSET_MAX;
|
||||
} else {
|
||||
if (height > 0) {
|
||||
singleImageWidth = border * width / height;
|
||||
}
|
||||
}
|
||||
}
|
||||
calcSize.width = singleImageWidth;
|
||||
calcSize.height = singleImageHeight;
|
||||
return calcSize;
|
||||
}
|
||||
|
||||
public static CalcSize calcImage(DynamicMedia media, int border) {
|
||||
if (media == null) {
|
||||
return new CalcSize();
|
||||
}
|
||||
return calcImage(media.getWidth(), media.getHeight(), border);
|
||||
}
|
||||
|
||||
}
|
@@ -1,85 +0,0 @@
|
||||
package com.chwl.app.community.helper;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.friend.view.SelectFriendActivity;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtilsV2;
|
||||
import com.chwl.app.ui.widget.ShareDialog;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.chwl.core.XConstants;
|
||||
import com.chwl.core.UriProvider;
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
import com.chwl.core.community.bean.WorldDynamicBean;
|
||||
import com.chwl.core.community.dynamic.DynamicModel;
|
||||
import com.chwl.core.community.im.DynamicImMsg;
|
||||
import com.chwl.core.share.ShareModel;
|
||||
import com.chwl.core.share.bean.ShareCommonInfo;
|
||||
import com.chwl.core.utils.net.RxHelper;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
import com.chwl.library.utils.config.BasicConfig;
|
||||
|
||||
import cn.sharesdk.framework.Platform;
|
||||
|
||||
/**
|
||||
* create by lvzebiao @2019/11/28
|
||||
*/
|
||||
public class ShareDynamicHelper {
|
||||
|
||||
private Activity activity;
|
||||
|
||||
public ShareDynamicHelper(Activity activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
public void share(WorldDynamicBean bean) {
|
||||
share(bean, bean.getWorldId());
|
||||
}
|
||||
|
||||
public void share(WorldDynamicBean bean, long worldId) {
|
||||
if (bean.isChecking()) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.community_helper_sharedynamichelper_01));
|
||||
return;
|
||||
}
|
||||
ShareDialog dialog = new ShareDialog(activity);
|
||||
dialog.setOnShareDialogItemClick(new ShareDialog.OnShareDialogItemClick() {
|
||||
@Override
|
||||
public void onInAppSharingItemClick() {
|
||||
DynamicImMsg dynamicImMsg = DynamicImMsg.beanToMsg(bean, worldId);
|
||||
SelectFriendActivity.startForSharingDynamic(activity, dynamicImMsg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharePlatformClick(Platform platform) {
|
||||
ShareCommonInfo info = dynamicToShareCommonInfo(bean, worldId);
|
||||
ShareModel.get().shareCommon(platform, info, true)
|
||||
.compose(RxHelper.bindContext(activity))
|
||||
.doOnSuccess(s ->
|
||||
DynamicModel.get().reportShare(bean.getUid(), worldId, bean.getDynamicId())
|
||||
.subscribe())
|
||||
.subscribe();
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
private ShareCommonInfo dynamicToShareCommonInfo(WorldDynamicBean bean, long worldId) {
|
||||
String title = bean.getNick() + ResUtil.getString(R.string.community_helper_sharedynamichelper_02);
|
||||
String content = TextUtils.isEmpty(bean.getContent()) ? ResUtil.getString(R.string.community_helper_sharedynamichelper_03) : bean.getContent();
|
||||
String imageUrl = bean.getShareCover();
|
||||
int imageWidth = UIUtil.dip2px(BasicConfig.INSTANCE.getAppContext(), 50);
|
||||
imageUrl = ImageLoadUtilsV2.getSizeUrl(imageUrl, imageWidth);
|
||||
String siteUrl = UriProvider.IM_SERVER_URL + XConstants.SHARE_WORLD_DYNAMIC_URL +
|
||||
"?uid=" + AuthModel.get().getCurrentUid() +
|
||||
"&dynamicId=" + bean.getDynamicId() +
|
||||
"&worldId=" + worldId;
|
||||
return new ShareCommonInfo()
|
||||
.setTitle(title)
|
||||
.setContent(content)
|
||||
.setImageUrl(imageUrl)
|
||||
.setSiteUrl(siteUrl);
|
||||
}
|
||||
|
||||
}
|
@@ -1,130 +0,0 @@
|
||||
package com.chwl.app.community.holder;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextPaint;
|
||||
import android.text.style.AbsoluteSizeSpan;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.text.style.MetricAffectingSpan;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.netease.nim.uikit.business.session.viewholder.MsgViewHolderBase;
|
||||
import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.ui.im.RouterHandler;
|
||||
import com.chwl.core.community.attachment.DynamicSysAttachment;
|
||||
import com.chwl.core.msg.sys.bean.ErbanSysMsgComponent;
|
||||
import com.chwl.core.msg.sys.bean.ErbanSysMsgInfo;
|
||||
import com.chwl.core.msg.sys.ErbanSysMsgLayout;
|
||||
import com.chwl.library.utils.SizeUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class DynamicSysHolder extends MsgViewHolderBase {
|
||||
private TextView tvTime;
|
||||
private TextView tvContent;
|
||||
private TextView tvTitle;
|
||||
|
||||
public DynamicSysHolder(BaseMultiItemFetchLoadAdapter adapter) {
|
||||
super(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getContentResId() {
|
||||
return R.layout.item_dynamic_sys;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void inflateContentView() {
|
||||
tvTitle = findViewById(R.id.tv_notice_label);
|
||||
tvTime = findViewById(R.id.tv_time_dynamic_is_pass);
|
||||
tvContent = findViewById(R.id.tv_content_dynamic_is_pass);
|
||||
}
|
||||
|
||||
private ErbanSysMsgInfo erbanSysMsgInfo;
|
||||
@Override
|
||||
protected void bindContentView() {
|
||||
DynamicSysAttachment dynamicSysAttachment = (DynamicSysAttachment) message.getAttachment();
|
||||
if (dynamicSysAttachment == null) {
|
||||
return;
|
||||
}
|
||||
erbanSysMsgInfo = dynamicSysAttachment.getErbanSysMsgInfo();
|
||||
if (erbanSysMsgInfo == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String layout = erbanSysMsgInfo.getLayout();
|
||||
ErbanSysMsgLayout erbanSysMsgLayout;
|
||||
try {
|
||||
erbanSysMsgLayout = JSON.parseObject(layout, ErbanSysMsgLayout.class);
|
||||
|
||||
} catch (Exception ex) { // json解析出错
|
||||
ex.printStackTrace();
|
||||
return;
|
||||
}
|
||||
// title
|
||||
setupView(tvTitle, erbanSysMsgLayout.getTitle());
|
||||
// timestamp
|
||||
setupView(tvTime, erbanSysMsgLayout.getTime());
|
||||
// content
|
||||
List<ErbanSysMsgComponent> erbanSysMsgLayoutContent = erbanSysMsgLayout.getContents();
|
||||
if (erbanSysMsgLayoutContent != null) {
|
||||
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
|
||||
for (ErbanSysMsgComponent erbanSysMsgComponent : erbanSysMsgLayoutContent) {
|
||||
int start = spannableStringBuilder.length();
|
||||
String msgBody = erbanSysMsgComponent.getContent();
|
||||
if (Objects.equals(msgBody, "/r/n")) {
|
||||
msgBody = "\r\n";
|
||||
spannableStringBuilder.append(msgBody);
|
||||
continue;
|
||||
}
|
||||
spannableStringBuilder.append(msgBody);
|
||||
if (erbanSysMsgComponent.getFontColor() != null) {
|
||||
spannableStringBuilder.setSpan(new ForegroundColorSpan(Color.parseColor(erbanSysMsgComponent.getFontColor())),
|
||||
start, spannableStringBuilder.length(),
|
||||
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
if (erbanSysMsgComponent.getFontSize() > 0) {
|
||||
spannableStringBuilder.setSpan(new AbsoluteSizeSpan(SizeUtils.sp2px(tvContent.getContext(), erbanSysMsgComponent.getFontSize() + 0.5F)),
|
||||
start, spannableStringBuilder.length(),
|
||||
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
spannableStringBuilder.setSpan(
|
||||
new MetricAffectingSpan() {
|
||||
@Override
|
||||
public void updateMeasureState(TextPaint p) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(TextPaint tp) {
|
||||
tp.setFakeBoldText(erbanSysMsgComponent.isFontBold());
|
||||
}
|
||||
},
|
||||
start, spannableStringBuilder.length(),
|
||||
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
tvContent.setText(spannableStringBuilder);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setupView(TextView view, ErbanSysMsgComponent erbanSysMsgComponent) {
|
||||
if (erbanSysMsgComponent != null) {
|
||||
setupComponent(view, erbanSysMsgComponent.getContent(), erbanSysMsgComponent.getFontColor(), erbanSysMsgComponent.getFontSize(),
|
||||
erbanSysMsgComponent.getRouterType(), erbanSysMsgComponent.getRouterValue());
|
||||
}
|
||||
}
|
||||
|
||||
public void setupComponent(TextView view, String text, String textColor, float fontSize, int routerType, int routerValue) {
|
||||
view.setText(text);
|
||||
view.setTextColor(Color.parseColor(textColor));
|
||||
view.setTextSize(fontSize);
|
||||
if (routerType > 0) {
|
||||
view.setOnClickListener(v -> RouterHandler.handle(context, routerType, String.valueOf(routerValue)));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,100 +0,0 @@
|
||||
package com.chwl.app.community.im;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.netease.nim.uikit.business.session.viewholder.MsgViewHolderBase;
|
||||
import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.community.dynamic.view.DynamicDetailActivity;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtilsV2;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.chwl.core.community.im.DynamicImMsg;
|
||||
import com.chwl.core.community.im.WorldDynamicAttachment;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
/**
|
||||
* create by lvzebiao @2019/11/25
|
||||
*/
|
||||
public class WorldDynamicShareViewHolder extends MsgViewHolderBase {
|
||||
|
||||
private ImageView rivCover;
|
||||
|
||||
private TextView tvTitle;
|
||||
|
||||
private TextView tvContent;
|
||||
|
||||
private TextView tvShareText;
|
||||
|
||||
private ViewGroup container;
|
||||
|
||||
public WorldDynamicShareViewHolder(BaseMultiItemFetchLoadAdapter adapter) {
|
||||
super(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getContentResId() {
|
||||
return R.layout.view_holder_world_dynamic_share;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void inflateContentView() {
|
||||
rivCover = findViewById(R.id.riv_cover);
|
||||
tvTitle = findViewById(R.id.tv_title);
|
||||
tvContent = findViewById(R.id.tv_content);
|
||||
tvShareText = findViewById(R.id.tv_share_text);
|
||||
container = findViewById(R.id.cl_container_dynamic);
|
||||
int layoutWidth = UIUtil.getScreenWidth(context) - UIUtil.dip2px(context, 150);
|
||||
ViewGroup.LayoutParams params = container.getLayoutParams();
|
||||
params.width = layoutWidth;
|
||||
container.setLayoutParams(params);
|
||||
if (isReceivedMessage()) {
|
||||
tvTitle.setTextColor(context.getResources().getColor(R.color.color_333333));
|
||||
tvShareText.setTextColor(context.getResources().getColor(R.color.color_333333));
|
||||
tvContent.setTextColor(context.getResources().getColor(R.color.color_9E9E9E));
|
||||
} else {
|
||||
tvTitle.setTextColor(context.getResources().getColor(R.color.white));
|
||||
tvShareText.setTextColor(context.getResources().getColor(R.color.white));
|
||||
tvContent.setTextColor(context.getResources().getColor(R.color.white_transparent_80));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindContentView() {
|
||||
try {
|
||||
if (!(message.getAttachment() instanceof WorldDynamicAttachment)) {
|
||||
return;
|
||||
}
|
||||
WorldDynamicAttachment worldDynamicAttachment = (WorldDynamicAttachment) message.getAttachment();
|
||||
if (worldDynamicAttachment == null) {
|
||||
return;
|
||||
}
|
||||
DynamicImMsg dynamicImMsg = worldDynamicAttachment.getDynamicImMsg();
|
||||
ImageLoadUtilsV2.loadAvatar(rivCover, dynamicImMsg.getImageUrl());
|
||||
|
||||
String nick = dynamicImMsg.getNick();
|
||||
if (TextUtils.isEmpty(nick)) {
|
||||
nick = "";
|
||||
} else if (nick.length() >= 4) {
|
||||
try {
|
||||
nick = nick.substring(0, 2) + "...";
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
tvTitle.setText(nick);
|
||||
String content = dynamicImMsg.getContent();
|
||||
if (TextUtils.isEmpty(dynamicImMsg.getContent())) {
|
||||
content = ResUtil.getString(R.string.community_im_worlddynamicshareviewholder_01);
|
||||
}
|
||||
tvContent.setText(content);
|
||||
container.setOnClickListener(v ->
|
||||
DynamicDetailActivity.start(context, dynamicImMsg.getDynamicId(), dynamicImMsg.getWorldId(), 3));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -1,76 +0,0 @@
|
||||
package com.chwl.app.community.photo;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtilsV2;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.chwl.core.community.bean.DynamicMedia;
|
||||
import com.chwl.library.utils.ScreenUtils;
|
||||
import com.chwl.library.utils.config.BasicConfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Setter;
|
||||
|
||||
public class DynamicImageAdapter extends BaseQuickAdapter<DynamicMedia, BaseViewHolder> {
|
||||
|
||||
private Context context;
|
||||
@Setter
|
||||
private int mTwoImageHeight;
|
||||
@Setter
|
||||
private int mThreeImageHeight;
|
||||
|
||||
private int imageWidth;
|
||||
|
||||
private int bigImageWidth;
|
||||
|
||||
@Setter
|
||||
private int singleImageHeight;
|
||||
|
||||
public DynamicImageAdapter(int layoutResId, @Nullable List<DynamicMedia> data) {
|
||||
super(layoutResId, data);
|
||||
context = BasicConfig.INSTANCE.getAppContext();
|
||||
imageWidth = UIUtil.getScreenWidth(context) * 2 / 5;
|
||||
bigImageWidth = UIUtil.getScreenWidth(context);
|
||||
|
||||
mTwoImageHeight = (ScreenUtils.getScreenWidth(context) - UIUtil.dip2px(context, 50F)) / 2;
|
||||
mThreeImageHeight = (ScreenUtils.getScreenWidth(context) - UIUtil.dip2px(context, 60F)) / 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, DynamicMedia item) {
|
||||
ImageView ivPhoto = helper.getView(R.id.riv_photo);
|
||||
helper.setGone(R.id.iv_gif_tag, item.isGif());
|
||||
ViewGroup.LayoutParams layoutParams = ivPhoto.getLayoutParams();
|
||||
if (helper.itemView instanceof ConstraintLayout && getData().size() > 1) {
|
||||
ImageLoadUtilsV2.loadImage(ivPhoto, item.getResUrl(), imageWidth);
|
||||
} else {
|
||||
switch (getData().size()) {
|
||||
case 1:
|
||||
layoutParams.height = singleImageHeight;
|
||||
ivPhoto.setLayoutParams(layoutParams);
|
||||
ImageLoadUtilsV2.loadImage(ivPhoto, item.getResUrl(), bigImageWidth);
|
||||
break;
|
||||
case 2:
|
||||
layoutParams.height = mTwoImageHeight;
|
||||
ivPhoto.setLayoutParams(layoutParams);
|
||||
ImageLoadUtilsV2.loadImage(ivPhoto, item.getResUrl(), imageWidth);
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
layoutParams.height = mThreeImageHeight;
|
||||
ivPhoto.setLayoutParams(layoutParams);
|
||||
ImageLoadUtilsV2.loadImage(ivPhoto, item.getResUrl(), imageWidth);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,46 +0,0 @@
|
||||
package com.chwl.app.community.publish;
|
||||
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.netease.nim.uikit.support.glide.GlideApp;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.chwl.core.community.bean.PublishItem;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ImageAdapter extends BaseQuickAdapter<PublishItem, BaseViewHolder> {
|
||||
|
||||
|
||||
public ImageAdapter(int layoutResId, @Nullable List<PublishItem> data) {
|
||||
super(layoutResId, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, PublishItem item) {
|
||||
helper.addOnClickListener(R.id.iv_delete);
|
||||
helper.setVisible(R.id.iv_delete, !item.isAddItem());
|
||||
ImageView ivPhoto = helper.getView(R.id.iv_photo);
|
||||
if (item.getButtonType() == PublishItem.BUTTON_TYPE_ADD_ITEM) {
|
||||
ivPhoto.setImageResource(R.drawable.icon_dy_add_image);
|
||||
} else {
|
||||
GlideApp.with(ivPhoto.getContext())
|
||||
.asBitmap()
|
||||
.load(item.getPath())
|
||||
.transform(new CenterCrop(),
|
||||
new RoundedCorners(UIUtil.dip2px(ivPhoto.getContext(), 8)))
|
||||
.placeholder(R.drawable.default_cover)
|
||||
.error(R.drawable.default_cover)
|
||||
.into(ivPhoto);
|
||||
}
|
||||
|
||||
helper.setGone(R.id.iv_gif_tag, item.getFileTag() == 1);
|
||||
|
||||
}
|
||||
}
|
@@ -1,206 +0,0 @@
|
||||
package com.chwl.app.community.publish.presenter;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.base.BaseMvpPresenter;
|
||||
import com.chwl.app.community.publish.view.IPublishView;
|
||||
import com.chwl.core.Constants;
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
import com.chwl.core.community.ImageUploadConfig;
|
||||
import com.chwl.core.community.PublishModel;
|
||||
import com.chwl.core.community.bean.DynamicMedia;
|
||||
import com.chwl.core.community.bean.MiniWorldChooseInfo;
|
||||
import com.chwl.core.community.bean.PublishBody;
|
||||
import com.chwl.core.file.FileModel;
|
||||
import com.chwl.core.utils.DirectoryHelper;
|
||||
import com.chwl.core.utils.net.DontWarnObserver;
|
||||
import com.chwl.core.utils.net.RxHelper;
|
||||
import com.chwl.library.base.PresenterEvent;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.file.JXFileUtils;
|
||||
import com.chwl.library.utils.image.JXImageUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.SingleObserver;
|
||||
import io.reactivex.SingleOnSubscribe;
|
||||
import io.reactivex.SingleSource;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Function;
|
||||
|
||||
/**
|
||||
* create by lvzebiao @2019/11/12
|
||||
*/
|
||||
public class PublishPresenter extends BaseMvpPresenter<IPublishView> {
|
||||
|
||||
private PublishBody publishBody;
|
||||
private Disposable mImageUploadSubscribe;
|
||||
|
||||
private boolean isOriginalImage;
|
||||
|
||||
private MiniWorldChooseInfo miniWorldChooseInfo = new MiniWorldChooseInfo();
|
||||
|
||||
public void publishDy(List<String> list, long worldId, String content, boolean isOriginalImage) {
|
||||
publishBody = new PublishBody();
|
||||
List<String> uploadList = new ArrayList<>(list);
|
||||
int type = ListUtils.isListEmpty(uploadList) ? 0 : 2;
|
||||
publishBody.setType(type);
|
||||
publishBody.setUid(AuthModel.get().getCurrentUid());
|
||||
publishBody.setContent(content);
|
||||
if (worldId > 0) {
|
||||
publishBody.setWorldId(worldId);
|
||||
}
|
||||
this.isOriginalImage = isOriginalImage;
|
||||
uploadImage(uploadList)
|
||||
.flatMap((Function<String, SingleSource<String>>) s ->
|
||||
PublishModel.get().publish(publishBody))
|
||||
.subscribe(new DontWarnObserver<String>() {
|
||||
@Override
|
||||
public void acceptThrowable(String s, Throwable throwable) {
|
||||
super.acceptThrowable(s, throwable);
|
||||
if (throwable != null) {
|
||||
dealUploadFileError(throwable);
|
||||
} else {
|
||||
if (getMvpView() != null) {
|
||||
getMvpView().onPublishSuccess();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Single<String> uploadImage(List<String> imagePaths) {
|
||||
upload(imagePaths);
|
||||
return Single.create(emitter ->
|
||||
mImageUploadSubscribe = Observable.interval(500, TimeUnit.MILLISECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.filter(aLong -> imagePaths != null && imagePaths.size() == 0)
|
||||
.subscribe(aLong -> {
|
||||
emitter.onSuccess("");
|
||||
if (mImageUploadSubscribe != null) {
|
||||
mImageUploadSubscribe.dispose();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private void upload(List<String> imagePaths) {
|
||||
if (imagePaths == null || imagePaths.size() == 0) {
|
||||
return;
|
||||
}
|
||||
String file = imagePaths.get(0);
|
||||
Single.create((SingleOnSubscribe<String>) e -> {
|
||||
long fileLength = JXFileUtils.getFileLength(file);
|
||||
LogUtil.print(ResUtil.getString(R.string.publish_presenter_publishpresenter_01) + fileLength);
|
||||
String compressFile = null;
|
||||
if (!isOriginalImage && fileLength > ImageUploadConfig.MAX_FILE_SIZE) {
|
||||
compressFile = JXImageUtils.compressImagePxAndQuality(
|
||||
file, DirectoryHelper.get().getDynamicDir(),
|
||||
"dynamic_" + System.currentTimeMillis() + ".jpg",
|
||||
ImageUploadConfig.EXPECT_MIN_WIDTH,
|
||||
ImageUploadConfig.EXPECT_COMPRESS_SIZE);
|
||||
|
||||
LogUtil.print(ResUtil.getString(R.string.publish_presenter_publishpresenter_02) + compressFile);
|
||||
}
|
||||
if (!TextUtils.isEmpty(compressFile)) {
|
||||
e.onSuccess(compressFile);
|
||||
} else if (!TextUtils.isEmpty(file)) {
|
||||
e.onSuccess(file);
|
||||
} else {
|
||||
e.onError(new Throwable(ResUtil.getString(R.string.publish_presenter_publishpresenter_03)));
|
||||
}
|
||||
})
|
||||
.compose(RxHelper.handleSchedulers())
|
||||
.flatMap((Function<String, SingleSource<DynamicMedia>>)
|
||||
path -> FileModel.get().uploadFileReturnImageInfo(path))
|
||||
.compose(bindUntilEvent(PresenterEvent.DESTROY))
|
||||
.subscribe(new DontWarnObserver<DynamicMedia>() {
|
||||
@Override
|
||||
public void acceptThrowable(DynamicMedia media, Throwable throwable) {
|
||||
super.acceptThrowable(media, throwable);
|
||||
if (throwable != null) {
|
||||
if (mImageUploadSubscribe != null) {
|
||||
mImageUploadSubscribe.dispose();
|
||||
}
|
||||
dealUploadFileError(throwable);
|
||||
} else {
|
||||
LogUtil.print(ResUtil.getString(R.string.publish_presenter_publishpresenter_04), media);
|
||||
publishBody.addDynamicMedia(media);
|
||||
imagePaths.remove(0);
|
||||
upload(imagePaths);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void recommendWorlds() {
|
||||
PublishModel.get().squareWorld(Constants.TYPE_RECOMMEND, 1, 5)
|
||||
.compose(bindToLifecycle()).subscribe(new SingleObserver<List<MiniWorldChooseInfo>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<MiniWorldChooseInfo> miniWorldChooseInfos) {
|
||||
if (miniWorldChooseInfos != null) {
|
||||
if (mMvpView != null) {
|
||||
mMvpView.recommendWorldsSuccess(miniWorldChooseInfos);
|
||||
}
|
||||
} else {
|
||||
if (mMvpView != null) {
|
||||
mMvpView.recommendWorldsFails(ResUtil.getString(R.string.publish_presenter_publishpresenter_05));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
if (mMvpView != null) {
|
||||
mMvpView.recommendWorldsFails(e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void dealUploadFileError(Throwable e) {
|
||||
if (getMvpView() != null) {
|
||||
getMvpView().onPublishFailed(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void setWorldId(long worldId) {
|
||||
if (miniWorldChooseInfo != null) {
|
||||
miniWorldChooseInfo.setWorldId(worldId);
|
||||
}
|
||||
}
|
||||
|
||||
public void setIsInWorld(boolean isInWorld) {
|
||||
if (miniWorldChooseInfo != null) {
|
||||
miniWorldChooseInfo.setInWorld(isInWorld);
|
||||
}
|
||||
}
|
||||
|
||||
public void setMiniWorldChooseInfo(MiniWorldChooseInfo miniWorldChooseInfo) {
|
||||
this.miniWorldChooseInfo = miniWorldChooseInfo;
|
||||
}
|
||||
|
||||
public long getWorldId() {
|
||||
return miniWorldChooseInfo != null ? miniWorldChooseInfo.getWorldId() : 0;
|
||||
}
|
||||
|
||||
public boolean isInWorld() {
|
||||
return miniWorldChooseInfo != null && miniWorldChooseInfo.isInWorld();
|
||||
}
|
||||
|
||||
}
|
@@ -1,60 +0,0 @@
|
||||
package com.chwl.app.community.publish.presenter;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.base.BaseMvpPresenter;
|
||||
import com.chwl.app.community.publish.view.IWorldsChooseView;
|
||||
import com.chwl.core.Constants;
|
||||
import com.chwl.core.community.PublishModel;
|
||||
import com.chwl.core.community.bean.MiniWorldChooseInfo;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.SingleObserver;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class WorldChoosePresenter extends BaseMvpPresenter<IWorldsChooseView> {
|
||||
|
||||
private int page = 0;
|
||||
|
||||
public void loadData(boolean isRefresh, byte type) {
|
||||
if (isRefresh) {
|
||||
page = 1;
|
||||
} else {
|
||||
page++;
|
||||
}
|
||||
|
||||
PublishModel.get().squareWorld(type, page, Constants.PAGE_SIZE)
|
||||
.compose(bindToLifecycle()).subscribe(new SingleObserver<List<MiniWorldChooseInfo>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<MiniWorldChooseInfo> miniWorldChooseInfos) {
|
||||
if (miniWorldChooseInfos != null) {
|
||||
if (mMvpView != null) {
|
||||
mMvpView.squareWorldsSuccess(miniWorldChooseInfos);
|
||||
}
|
||||
} else {
|
||||
if (mMvpView != null) {
|
||||
mMvpView.squareWorldsFails(ResUtil.getString(R.string.publish_presenter_worldchoosepresenter_01));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
if (mMvpView != null) {
|
||||
mMvpView.squareWorldsFails(e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public int getPage() {
|
||||
return page;
|
||||
}
|
||||
}
|
@@ -1,20 +0,0 @@
|
||||
package com.chwl.app.community.publish.view;
|
||||
|
||||
import com.chwl.core.community.bean.MiniWorldChooseInfo;
|
||||
import com.chwl.library.base.IMvpBaseView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* create by lvzebiao @2019/11/12
|
||||
*/
|
||||
public interface IPublishView extends IMvpBaseView {
|
||||
|
||||
void onPublishSuccess();
|
||||
|
||||
void onPublishFailed(Throwable throwable);
|
||||
|
||||
void recommendWorldsSuccess(List<MiniWorldChooseInfo> list);
|
||||
void recommendWorldsFails(String error);
|
||||
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
package com.chwl.app.community.publish.view;
|
||||
|
||||
import com.chwl.core.community.bean.MiniWorldChooseInfo;
|
||||
import com.chwl.library.base.IMvpBaseView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IWorldsChooseView extends IMvpBaseView {
|
||||
void squareWorldsSuccess(List<MiniWorldChooseInfo> list);
|
||||
void squareWorldsFails(String error);
|
||||
}
|
@@ -1,652 +0,0 @@
|
||||
|
||||
package com.chwl.app.community.publish.view;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chwl.core.utils.CoreTextUtils;
|
||||
import com.google.android.flexbox.FlexboxLayout;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.trello.rxlifecycle3.android.ActivityEvent;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.base.BaseMvpActivity;
|
||||
import com.chwl.app.common.widget.dialog.ChooseWorldsDialog;
|
||||
import com.chwl.app.common.widget.dialog.DialogManager;
|
||||
import com.chwl.app.community.ConstantValue;
|
||||
import com.chwl.app.community.photo.BigPhotoActivity;
|
||||
import com.chwl.app.community.photo.PagerOption;
|
||||
import com.chwl.app.community.publish.ImageAdapter;
|
||||
import com.chwl.app.community.publish.presenter.PublishPresenter;
|
||||
import com.chwl.app.community.utils.ObjectTypeHelper;
|
||||
import com.chwl.app.ui.widget.dialog.CommonTipDialog;
|
||||
import com.chwl.app.ui.widget.recyclerview.decoration.GridSpacingItemDecoration;
|
||||
import com.chwl.core.XConstants;
|
||||
import com.chwl.core.Constants;
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
import com.chwl.core.community.bean.MiniWorldChooseInfo;
|
||||
import com.chwl.core.community.bean.PublishItem;
|
||||
import com.chwl.core.miniworld.model.MiniWorldModel;
|
||||
import com.chwl.core.user.UserModel;
|
||||
import com.chwl.core.user.bean.UserInfo;
|
||||
import com.chwl.core.utils.SharedPreferenceUtils;
|
||||
import com.chwl.core.utils.net.DontWarnObserver;
|
||||
import com.chwl.library.base.factory.CreatePresenter;
|
||||
import com.chwl.library.common.photo.PhotoProvider;
|
||||
import com.chwl.library.common.util.PhotoCompressUtil;
|
||||
import com.chwl.library.common.util.PhotosCompressCallback;
|
||||
import com.chwl.library.easypermisssion.EasyPermissions;
|
||||
import com.chwl.library.easyphoto.utils.settings.SettingsUtils;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
import com.example.matisse.Matisse;
|
||||
import com.example.matisse.internal.entity.CustomItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import kotlinx.coroutines.Job;
|
||||
|
||||
/**
|
||||
* create by lvzebiao @2019/11/11
|
||||
*/
|
||||
@CreatePresenter(PublishPresenter.class)
|
||||
public class PublishActivity extends BaseMvpActivity<IPublishView, PublishPresenter>
|
||||
implements IPublishView, WorldsChooseFrg.ChooseWorldCallback, EasyPermissions.PermissionCallbacks,
|
||||
View.OnClickListener {
|
||||
|
||||
private final static String KEY_SP_ORIGINAL_IMAGE = "key_sp_original_image";
|
||||
private final static int PERMISSION_CODE_STORAGE = 12;
|
||||
private final static int REQUEST_CODE_STORAGE = 42;
|
||||
private final static int REQUEST_CODE_OPEN_PHOTO_PROVIDER = 111; // 从相册中选择
|
||||
private final static int maxSelect = 9;
|
||||
|
||||
private RecyclerView rvImages;
|
||||
private TextView tvPublish;
|
||||
private EditText etContent;
|
||||
private TextView tvMiniWorldName;
|
||||
private TextView tvInputLimit;
|
||||
|
||||
private TextView tvChoose;
|
||||
private LinearLayout llGroupChoose;
|
||||
private TextView tvLabelReChoose;
|
||||
private LinearLayout llMiniWorld;
|
||||
private FlexboxLayout flGroup;
|
||||
private RelativeLayout rlChooseGroup;
|
||||
private ImageView ivClose;
|
||||
|
||||
private ImageAdapter imageAdapter;
|
||||
|
||||
private List<PublishItem> imageShowList = new ArrayList<>();
|
||||
|
||||
private List<CustomItem> uploadList = new ArrayList<>();
|
||||
|
||||
private boolean isOriginalImage;
|
||||
|
||||
// 话题客态页进入(话题进入不让修改话题标签)
|
||||
private boolean fromWorld;
|
||||
|
||||
private Job mJob = null;
|
||||
|
||||
public static void start(DialogManager manager, long worldId) {
|
||||
if (beforeStart(manager)) {
|
||||
return;
|
||||
}
|
||||
Context context = manager.getContext();
|
||||
Intent intent = new Intent(context, PublishActivity.class);
|
||||
intent.putExtra("worldId", worldId);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 非话题页面进入
|
||||
*/
|
||||
public static void start(DialogManager manager) {
|
||||
if (beforeStart(manager)) {
|
||||
return;
|
||||
}
|
||||
Context context = manager.getContext();
|
||||
Intent intent = new Intent(context, PublishActivity.class);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
private static boolean beforeStart(DialogManager manager) {
|
||||
UserInfo userInfo = UserModel.get().getCacheLoginUserInfo();
|
||||
if (userInfo == null) {
|
||||
SingleToastUtil.showToast(XConstants.EMPTY_USER_INFO_TIPS);
|
||||
return true;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_publish);
|
||||
|
||||
findView();
|
||||
initListener();
|
||||
|
||||
long worldId = getIntent().getLongExtra("worldId", 0L);
|
||||
if (worldId > 0) {
|
||||
fromWorld = true;
|
||||
getMvpPresenter().setWorldId(worldId);
|
||||
getMvpPresenter().setIsInWorld(true);
|
||||
}
|
||||
|
||||
isOriginalImage = (boolean) SharedPreferenceUtils.get(KEY_SP_ORIGINAL_IMAGE, false);
|
||||
initWhiteTitleBar(getString(R.string.pic_text_publish));
|
||||
initGridImages();
|
||||
updateImagesData();
|
||||
initEditContent();
|
||||
initOtherView();
|
||||
|
||||
if (!fromWorld) {
|
||||
getMvpPresenter().recommendWorlds();
|
||||
} else { // 话题进入,关闭多余的控件
|
||||
llGroupChoose.setVisibility(View.GONE);
|
||||
tvChoose.setVisibility(View.GONE);
|
||||
ivClose.setVisibility(View.GONE);
|
||||
|
||||
flGroup.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void findView() {
|
||||
rvImages = findViewById(R.id.rv_images);
|
||||
tvPublish = findViewById(R.id.tv_publish);
|
||||
etContent = findViewById(R.id.et_content);
|
||||
tvMiniWorldName = findViewById(R.id.tv_mini_world_name);
|
||||
tvInputLimit = findViewById(R.id.tv_input_limit);
|
||||
tvChoose = findViewById(R.id.tv_choose);
|
||||
llGroupChoose = findViewById(R.id.ll_group_choose);
|
||||
tvLabelReChoose = findViewById(R.id.tv_label_re_choose);
|
||||
llMiniWorld = findViewById(R.id.ll_miniworld);
|
||||
flGroup = findViewById(R.id.fl_group);
|
||||
rlChooseGroup = findViewById(R.id.rl_choose_group);
|
||||
ivClose = findViewById(R.id.iv_close);
|
||||
}
|
||||
|
||||
private void initListener() {
|
||||
tvPublish.setOnClickListener(this);
|
||||
ivClose.setOnClickListener(this);
|
||||
llGroupChoose.setOnClickListener(this);
|
||||
rlChooseGroup.setOnClickListener(this);
|
||||
}
|
||||
|
||||
private void initGridImages() {
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(context, 3);
|
||||
rvImages.setLayoutManager(gridLayoutManager);
|
||||
rvImages.addItemDecoration(new GridSpacingItemDecoration(context, 3, 10));
|
||||
imageAdapter = new ImageAdapter(R.layout.item_publish_image, imageShowList);
|
||||
imageAdapter.setOnItemClickListener((adapter, view, position) -> {
|
||||
PublishItem item = imageShowList.get(position);
|
||||
if (item.isAddItem()) {
|
||||
checkStoragePermission();
|
||||
} else {
|
||||
BigPhotoActivity.startCanDelete(PublishActivity.this, (ArrayList<CustomItem>) uploadList,
|
||||
position, new PagerOption().setDelete(true));
|
||||
}
|
||||
});
|
||||
imageAdapter.setOnItemChildClickListener((adapter, view, position) -> {
|
||||
if (position < uploadList.size()) {
|
||||
getDialogManager().showOkCancelDialog(ResUtil.getString(R.string.publish_view_publishactivity_02), () -> {
|
||||
uploadList.remove(position);
|
||||
updateImagesData();
|
||||
imageAdapter.notifyDataSetChanged();
|
||||
toast(ResUtil.getString(R.string.publish_view_publishactivity_03));
|
||||
});
|
||||
}
|
||||
});
|
||||
rvImages.setAdapter(imageAdapter);
|
||||
updateImagesData();
|
||||
}
|
||||
|
||||
private void updateImagesData() {
|
||||
List<PublishItem> tmp = new ArrayList<>();
|
||||
for (int i = 0; i < uploadList.size(); i++) {
|
||||
CustomItem item = uploadList.get(i);
|
||||
if (item.getFileType() == 0 || item.getFileType() == 1) {
|
||||
PublishItem publishItem = new PublishItem(i, PublishItem.BUTTON_TYPE_SHOW_PIC,
|
||||
item.getPath(), item.isGif() ? 1 : 0);
|
||||
tmp.add(publishItem);
|
||||
}
|
||||
}
|
||||
imageShowList.clear();
|
||||
imageShowList.addAll(tmp);
|
||||
if (uploadList.size() < 9) {
|
||||
imageShowList.add(new PublishItem(-1, PublishItem.BUTTON_TYPE_ADD_ITEM, null, 0));
|
||||
}
|
||||
imageAdapter.notifyDataSetChanged();
|
||||
updatePublishStatus();
|
||||
}
|
||||
|
||||
private void initEditContent() {
|
||||
etContent.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
tvInputLimit.setText(s.length() + "/500");
|
||||
updatePublishStatus();
|
||||
String inputText = s.toString().trim();
|
||||
tvPublish.setTextColor(!TextUtils.isEmpty(inputText) ? getResources().getColor(R.color.color_7154EE) : getResources().getColor(R.color.color_999999));
|
||||
tvPublish.setEnabled(!TextUtils.isEmpty(inputText));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.tv_publish:
|
||||
publish();
|
||||
break;
|
||||
|
||||
case R.id.iv_close:
|
||||
showChooseView();
|
||||
break;
|
||||
|
||||
case R.id.rl_choose_group:
|
||||
case R.id.ll_group_choose:
|
||||
showChooseDialog(Constants.TYPE_ALL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void showChooseDialog(byte type) {
|
||||
ChooseWorldsDialog chooseWorldsDialog = ChooseWorldsDialog.newInstance(type);
|
||||
chooseWorldsDialog.setmChooseWorldCallback(this);
|
||||
chooseWorldsDialog.show(getSupportFragmentManager(), "worlds_choose");
|
||||
}
|
||||
|
||||
private void publish() {
|
||||
tvPublish.setEnabled(false);
|
||||
getDialogManager().showProgressDialog(context);
|
||||
getMvpPresenter().publishDy(
|
||||
ObjectTypeHelper.customToStringList(uploadList),
|
||||
getMvpPresenter().getWorldId(), etContent.getText().toString(), isOriginalImage);
|
||||
}
|
||||
|
||||
private void updatePublishStatus() {
|
||||
tvPublish.setEnabled(!(uploadList.size() == 0 &&
|
||||
CoreTextUtils.isEmptyText(etContent.getText().toString())));
|
||||
}
|
||||
|
||||
private void initOtherView() {
|
||||
//话题名称
|
||||
long worldId = getMvpPresenter().getWorldId();
|
||||
if (worldId > 0) {
|
||||
MiniWorldModel.getInstance().getWorldDetailInfo(String.valueOf(worldId),
|
||||
String.valueOf(AuthModel.get().getCurrentUid()))
|
||||
.compose(bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.doOnSuccess(info -> {
|
||||
if (info != null && !TextUtils.isEmpty(info.getName())) {
|
||||
showReChooseView(info.getName());
|
||||
}
|
||||
})
|
||||
.subscribe();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == REQUEST_CODE_STORAGE) {
|
||||
checkStoragePermission();
|
||||
} else if (resultCode == RESULT_OK) {
|
||||
switch (requestCode) {
|
||||
case REQUEST_CODE_OPEN_PHOTO_PROVIDER:
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
PhotoProvider.getResultPathListAsync(data, new Function1<List<String>, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(List<String> list) {
|
||||
if (list.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
if (mJob != null) {
|
||||
mJob.cancel(null);
|
||||
}
|
||||
mJob = PhotoCompressUtil.compress(PublishActivity.this, list,
|
||||
PhotoCompressUtil.getCompressCachePath("publish")
|
||||
, new PhotosCompressCallback() {
|
||||
@Override
|
||||
public void onSuccess(@NonNull ArrayList<String> compressedImgList) {
|
||||
List<CustomItem> pathResult = new ArrayList<>();
|
||||
for (String path : compressedImgList) {
|
||||
pathResult.add(new CustomItem(path, CustomItem.IMAGE_NORMAL, "jpeg"));
|
||||
}
|
||||
if (pathResult.size() == 0) {
|
||||
return;
|
||||
}
|
||||
LogUtil.print(pathResult);
|
||||
|
||||
uploadList.addAll(pathResult);
|
||||
updateImagesData();
|
||||
|
||||
isOriginalImage = false;
|
||||
LogUtil.print("isOriginalImage:" + isOriginalImage);
|
||||
SharedPreferenceUtils.put(KEY_SP_ORIGINAL_IMAGE, isOriginalImage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(@NonNull Throwable e) {
|
||||
toast(getString(R.string.picker_image_error));
|
||||
}
|
||||
}, 200, false, Constants.UPLOAD_IMAGE_MAX_SIZE, Constants.UPLOAD_IMAGE_MAX_FILE_LENGTH);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
case ConstantValue.CODE_CHOOSE_PHOTO:
|
||||
String mimeType = Matisse.obtainMineResult(data);
|
||||
List<CustomItem> pathResult = Matisse.obtainPathResult(data);
|
||||
if ("video".equals(mimeType)) {
|
||||
toast(ResUtil.getString(R.string.publish_view_publishactivity_04));
|
||||
return;
|
||||
}
|
||||
if (pathResult == null) {
|
||||
return;
|
||||
}
|
||||
LogUtil.print(pathResult);
|
||||
|
||||
uploadList.addAll(pathResult);
|
||||
updateImagesData();
|
||||
|
||||
isOriginalImage = Matisse.obtainOriginalImageResult(data);
|
||||
LogUtil.print("isOriginalImage:" + isOriginalImage);
|
||||
SharedPreferenceUtils.put(KEY_SP_ORIGINAL_IMAGE, isOriginalImage);
|
||||
|
||||
break;
|
||||
|
||||
case BigPhotoActivity.CODE_DELETE_PHOTO:
|
||||
List<CustomItem> newList = data.getParcelableArrayListExtra(
|
||||
BigPhotoActivity.KEY_IMG_URL);
|
||||
uploadList.clear();
|
||||
uploadList.addAll(newList);
|
||||
updateImagesData();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPublishSuccess() {
|
||||
hideIME(etContent);
|
||||
getDialogManager().dismissDialog();
|
||||
tvPublish.setEnabled(true);
|
||||
getDialogManager().showCustomViewDialog(R.layout.dialog_dy_publish_success);
|
||||
getDialogManager().getDialog().setCanceledOnTouchOutside(true);
|
||||
getDialogManager().getDialog().setOnDismissListener(dialog -> finish());
|
||||
getDialogManager().getDialog().setOnKeyListener((dialog, keyCode, event) -> {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0
|
||||
&& event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
hideDialogAndFinish();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
Single.timer(3, TimeUnit.SECONDS, AndroidSchedulers.mainThread())
|
||||
.compose(bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.subscribe(new DontWarnObserver<Long>() {
|
||||
@Override
|
||||
public void accept(Long aLong, String error) {
|
||||
super.accept(aLong, error);
|
||||
if (error == null) {
|
||||
hideDialogAndFinish();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void hideDialogAndFinish() {
|
||||
getDialogManager().dismissDialog();
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPublishFailed(Throwable throwable) {
|
||||
getDialogManager().dismissDialog();
|
||||
toast(throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recommendWorldsSuccess(List<MiniWorldChooseInfo> list) {
|
||||
addMiniWorldList(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recommendWorldsFails(String error) {
|
||||
flGroup.setVisibility(View.GONE);
|
||||
|
||||
toast(error);
|
||||
}
|
||||
|
||||
private void handleFinish() {
|
||||
if (!tvPublish.isEnabled()) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
getDialogManager().showOkCancelWithTitleDialog(ResUtil.getString(R.string.publish_view_publishactivity_06), ResUtil.getString(R.string.publish_view_publishactivity_07),
|
||||
ResUtil.getString(R.string.publish_view_publishactivity_08), ResUtil.getString(R.string.publish_view_publishactivity_09), new DialogManager.OkCancelDialogListener() {
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOk() {
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLeftClickListener() {
|
||||
handleFinish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
handleFinish();
|
||||
}
|
||||
|
||||
private void showChooseView() {
|
||||
rlChooseGroup.setEnabled(true);
|
||||
llGroupChoose.setEnabled(false);
|
||||
|
||||
tvChoose.setVisibility(View.VISIBLE);
|
||||
tvLabelReChoose.setVisibility(View.GONE);
|
||||
|
||||
llMiniWorld.setVisibility(View.GONE);
|
||||
tvMiniWorldName.setText("");
|
||||
|
||||
getMvpPresenter().setMiniWorldChooseInfo(new MiniWorldChooseInfo());
|
||||
}
|
||||
|
||||
private void showReChooseView(String worldName) {
|
||||
rlChooseGroup.setEnabled(false);
|
||||
llGroupChoose.setEnabled(true);
|
||||
|
||||
tvChoose.setVisibility(View.GONE);
|
||||
tvLabelReChoose.setVisibility(View.VISIBLE);
|
||||
tvMiniWorldName.setText("#" + worldName);
|
||||
|
||||
llMiniWorld.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private List<MiniWorldChooseInfo> miniWorldChooseInfoList;
|
||||
|
||||
private void addMiniWorldList(List<MiniWorldChooseInfo> list) {
|
||||
miniWorldChooseInfoList = list;
|
||||
flGroup.removeAllViews();
|
||||
|
||||
if (miniWorldChooseInfoList != null && miniWorldChooseInfoList.size() > 0) {
|
||||
for (MiniWorldChooseInfo item : miniWorldChooseInfoList) {
|
||||
TextView textView = (TextView) LayoutInflater.from(this).inflate(R.layout.item_label_mini_world, flGroup, false);
|
||||
textView.setText(item.getWorldName());
|
||||
textView.setTag(item.getWorldId());
|
||||
textView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
TextView tv = (TextView) v;
|
||||
|
||||
if (miniWorldChooseInfoList != null && tv != null) {
|
||||
for (MiniWorldChooseInfo sub : miniWorldChooseInfoList) {
|
||||
Long tag = (Long) tv.getTag();
|
||||
long worldid = sub.getWorldId();
|
||||
if (worldid == tag) {
|
||||
getMvpPresenter().setMiniWorldChooseInfo(sub);
|
||||
showReChooseView(sub.getWorldName());
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
flGroup.addView(textView);
|
||||
}
|
||||
|
||||
} else {
|
||||
flGroup.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callback(MiniWorldChooseInfo miniWorldChooseInfo) {
|
||||
getMvpPresenter().setMiniWorldChooseInfo(miniWorldChooseInfo);
|
||||
if (miniWorldChooseInfo == null) {
|
||||
showChooseView();
|
||||
} else {
|
||||
showReChooseView(miniWorldChooseInfo.getWorldName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean needSteepStateBar() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setStatusBar() {
|
||||
StatusBarUtil.transparencyBar(this);
|
||||
StatusBarUtil.StatusBarLightMode(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {
|
||||
if (requestCode == PERMISSION_CODE_STORAGE) {
|
||||
checkStoragePermission();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {
|
||||
if (requestCode == PERMISSION_CODE_STORAGE) {
|
||||
String requestTip = getString(R.string.permission_storage_denied);
|
||||
CommonTipDialog mPrivacyDialog = new CommonTipDialog(context);
|
||||
mPrivacyDialog.setTipMsg(requestTip);
|
||||
mPrivacyDialog.setOkText(getString(R.string.room_perform_go_update));
|
||||
mPrivacyDialog.setOnActionListener(new CommonTipDialog.OnActionListener() {
|
||||
@Override
|
||||
public void onOk() {
|
||||
//同意跳到应用详情页面
|
||||
SettingsUtils.startMyApplicationDetailsForResult(PublishActivity.this,
|
||||
getPackageName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
CommonTipDialog.OnActionListener.super.onCancel();
|
||||
//取消跳到应用详情页面
|
||||
ToastUtils.show(getString(R.string.permission_storage_refused));
|
||||
}
|
||||
});
|
||||
mPrivacyDialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkStoragePermission() {
|
||||
if (!EasyPermissions.hasPermissions(
|
||||
this,
|
||||
Build.VERSION.SDK_INT >= 33 ? Manifest.permission.READ_MEDIA_IMAGES : Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
)
|
||||
) {
|
||||
EasyPermissions.requestPermissions(
|
||||
this,
|
||||
getString(R.string.permission_storage_rationale),
|
||||
PERMISSION_CODE_STORAGE,
|
||||
Build.VERSION.SDK_INT >= 33 ? Manifest.permission.READ_MEDIA_IMAGES : Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
);
|
||||
} else {
|
||||
PhotoProvider.photoProvider(
|
||||
this,
|
||||
maxSelect - uploadList.size(),
|
||||
true,
|
||||
REQUEST_CODE_OPEN_PHOTO_PROVIDER,
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mJob != null) {
|
||||
mJob.cancel(null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,31 +0,0 @@
|
||||
package com.chwl.app.community.publish.view;
|
||||
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtilsV2;
|
||||
import com.chwl.core.community.bean.MiniWorldChooseInfo;
|
||||
|
||||
public class WorldChooseAdapter extends BaseQuickAdapter<MiniWorldChooseInfo, BaseViewHolder> {
|
||||
|
||||
public WorldChooseAdapter() {
|
||||
super(R.layout.item_worlds_choose, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, MiniWorldChooseInfo item) {
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
helper.setText(R.id.tv_world_name, item.getWorldName() + "")
|
||||
.setText(R.id.tv_world_desc, item.getDescription() + "");
|
||||
|
||||
ImageView imageView = helper.getView(R.id.rriv_world);
|
||||
ImageLoadUtilsV2.loadImage(imageView, item.getIcon());
|
||||
helper.addOnClickListener(R.id.cl_container);
|
||||
|
||||
}
|
||||
}
|
@@ -1,147 +0,0 @@
|
||||
package com.chwl.app.community.publish.view;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.base.BaseMvpFragment;
|
||||
import com.chwl.app.community.publish.presenter.WorldChoosePresenter;
|
||||
import com.chwl.app.ui.widget.recyclerview.decoration.HorizontalDecoration;
|
||||
import com.chwl.core.Constants;
|
||||
import com.chwl.core.community.bean.MiniWorldChooseInfo;
|
||||
import com.chwl.library.base.factory.CreatePresenter;
|
||||
import com.chwl.library.utils.SizeUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@CreatePresenter(WorldChoosePresenter.class)
|
||||
public class WorldsChooseFrg extends BaseMvpFragment<IWorldsChooseView, WorldChoosePresenter> implements IWorldsChooseView {
|
||||
private SwipeRefreshLayout swipeRefreshLayout;
|
||||
private RecyclerView recyclerView;
|
||||
private WorldChooseAdapter mAdapter;
|
||||
|
||||
private byte mType;
|
||||
|
||||
public static WorldsChooseFrg newInstance(byte type) {
|
||||
WorldsChooseFrg fragment = new WorldsChooseFrg();
|
||||
Bundle args = new Bundle();
|
||||
args.putByte("type", type);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRootLayoutId() {
|
||||
return R.layout.frg_worlds_choose;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFindViews() {
|
||||
swipeRefreshLayout = mView.findViewById(R.id.swipe_refresh);
|
||||
recyclerView = mView.findViewById(R.id.recycler_view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetListener() {
|
||||
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
mAdapter.setEnableLoadMore(true);
|
||||
loadData(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initiate() {
|
||||
Bundle bundle = getArguments();
|
||||
if (bundle != null) {
|
||||
mType = bundle.getByte("type", Constants.TYPE_ALL);
|
||||
} else {
|
||||
mType = Constants.TYPE_ALL;
|
||||
}
|
||||
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
|
||||
mAdapter = new WorldChooseAdapter();
|
||||
mAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
|
||||
@Override
|
||||
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
|
||||
List<MiniWorldChooseInfo> list = adapter.getData();
|
||||
|
||||
if (list.size() > 0 && position < list.size()) {
|
||||
MiniWorldChooseInfo miniWorldChooseInfo = list.get(position);
|
||||
if (mChooseWorldCallback != null) {
|
||||
mChooseWorldCallback.callback(miniWorldChooseInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
recyclerView.setAdapter(mAdapter);
|
||||
recyclerView.addItemDecoration(new HorizontalDecoration(SizeUtils.dp2px(mContext, 25), false, true));
|
||||
|
||||
loadData(true);
|
||||
}
|
||||
|
||||
private void loadData(boolean isRefresh) {
|
||||
getMvpPresenter().loadData(isRefresh, mType);
|
||||
}
|
||||
|
||||
private ChooseWorldCallback mChooseWorldCallback;
|
||||
|
||||
public WorldsChooseFrg setmChooseWorldCallback(ChooseWorldCallback chooseWorldCallback) {
|
||||
this.mChooseWorldCallback = chooseWorldCallback;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void squareWorldsSuccess(List<MiniWorldChooseInfo> list) {
|
||||
hideStatus();
|
||||
|
||||
if (mAdapter != null) {
|
||||
int page = getMvpPresenter().getPage();
|
||||
if (page <= 1) {
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
|
||||
if (list == null || list.size() == 0) {
|
||||
showNoData();
|
||||
} else {
|
||||
mAdapter.setNewData(list);
|
||||
}
|
||||
|
||||
} else {
|
||||
mAdapter.addData(list);
|
||||
|
||||
if (list.size() == 0) {
|
||||
mAdapter.loadMoreComplete();
|
||||
mAdapter.loadMoreEnd();
|
||||
mAdapter.setEnableLoadMore(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReloadData() {
|
||||
super.onReloadData();
|
||||
loadData(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void squareWorldsFails(String error) {
|
||||
hideStatus();
|
||||
|
||||
int page = getMvpPresenter().getPage();
|
||||
if (page <= 1) {
|
||||
showNoData();
|
||||
}
|
||||
}
|
||||
|
||||
public interface ChooseWorldCallback {
|
||||
void callback(MiniWorldChooseInfo miniWorldChooseInfo);
|
||||
}
|
||||
}
|