update
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package com.shayu.onetoone.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
|
||||
@Route(path = RouteManager.ACTIVITY_HOME_SEARCH)
|
||||
public class HomeSearchActivity extends AbsOTOActivity {
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_search;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main(Bundle savedInstanceState) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,6 @@ package com.shayu.onetoone.activity;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
|
||||
@@ -13,20 +11,24 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.angcyo.tablayout.DslTabLayout;
|
||||
import com.angcyo.tablayout.delegate2.ViewPager2Delegate;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.fragments.home.HomeRankFragment;
|
||||
import com.shayu.onetoone.listener.OnAppbarListener;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Route(path = RouteManager.ACTIVITY_HOME_RANK)
|
||||
public class HomepageRankingActivity extends AbsOTOActivity {
|
||||
ViewPager2 viewPager;
|
||||
DslTabLayout dslTabLayout;
|
||||
RadioButton mDay, mWeek;
|
||||
private RadioGroup radioGroup;
|
||||
private ViewPagerChangeCallback viewPagerChangeCallback;
|
||||
List<HomeRankFragment> fragments = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -43,6 +45,7 @@ public class HomepageRankingActivity extends AbsOTOActivity {
|
||||
dslTabLayout = findViewById(R.id.dslTabLayout);
|
||||
radioGroup = findViewById(R.id.radioGroup);
|
||||
|
||||
viewPagerChangeCallback = new ViewPagerChangeCallback();
|
||||
ViewPager2Delegate.Companion.install(viewPager, dslTabLayout, false);
|
||||
|
||||
fragments.add(new HomeRankFragment(HomeRankFragment.TYPE_CHARM));//魅力
|
||||
@@ -71,10 +74,19 @@ public class HomepageRankingActivity extends AbsOTOActivity {
|
||||
});
|
||||
mDay.setOnClickListener(v -> {
|
||||
setRadioColor(mDay, mWeek);
|
||||
fragments.get(viewPager.getCurrentItem()).setDate(HomeRankFragment.DATE_DAY);
|
||||
});
|
||||
mWeek.setOnClickListener(v -> {
|
||||
setRadioColor(mWeek, mDay);
|
||||
fragments.get(viewPager.getCurrentItem()).setDate(HomeRankFragment.DATE_WEEK);
|
||||
});
|
||||
viewPager.registerOnPageChangeCallback(viewPagerChangeCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
viewPager.unregisterOnPageChangeCallback(viewPagerChangeCallback);
|
||||
}
|
||||
|
||||
private void setRadioColor(RadioButton select, RadioButton unSelect) {
|
||||
@@ -83,4 +95,12 @@ public class HomepageRankingActivity extends AbsOTOActivity {
|
||||
select.setBackgroundResource(R.drawable.bg_home_rank_day_select);
|
||||
unSelect.setBackgroundResource(R.drawable.bg_home_rank_day);
|
||||
}
|
||||
|
||||
private class ViewPagerChangeCallback extends ViewPager2.OnPageChangeCallback {
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
super.onPageSelected(position);
|
||||
fragments.get(position).setDate(mDay.isChecked()?HomeRankFragment.DATE_DAY:HomeRankFragment.DATE_WEEK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,7 @@ import com.angcyo.tablayout.delegate2.ViewPager2Delegate;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.fragments.home.HotFragment;
|
||||
import com.shayu.onetoone.activity.fragments.home.RecommendFragment;
|
||||
import com.shayu.onetoone.activity.fragments.message.MsgFriendFragment;
|
||||
import com.shayu.onetoone.activity.fragments.message.MsgMessageFragment;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -47,6 +46,10 @@ public class FriendsFragment extends BaseFragment {
|
||||
return fragments.size();
|
||||
}
|
||||
});
|
||||
findViewById(R.id.btn_top).setOnClickListener(v ->{
|
||||
RouteManager.forwardActivity(RouteManager.ACTIVITY_HOME_RANK);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.shayu.onetoone.activity.fragments.home;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -9,56 +8,89 @@ import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.fragments.BaseFragment;
|
||||
import com.shayu.onetoone.adapter.HomeRecommendListAdapter;
|
||||
import com.shayu.onetoone.adapter.HomeRankListAdapter;
|
||||
import com.shayu.onetoone.bean.HomeRankBean;
|
||||
import com.shayu.onetoone.bean.UserBean;
|
||||
import com.shayu.onetoone.listener.OnAppbarListener;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
import com.yanzhenjie.recyclerview.SwipeRecyclerView;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.custom.CommonRefreshView;
|
||||
import com.yunbao.common.custom.MyRadioButton;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.rong.imkit.widget.refresh.SmartRefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.api.RefreshLayout;
|
||||
import io.rong.imkit.widget.refresh.listener.OnLoadMoreListener;
|
||||
import io.rong.imkit.widget.refresh.listener.OnRefreshListener;
|
||||
import io.rong.imkit.widget.refresh.wrapper.RongRefreshHeader;
|
||||
import pl.droidsonroids.gif.GifImageView;
|
||||
|
||||
public class HomeRankFragment extends BaseFragment {
|
||||
public static final int TYPE_CHARM = 0;
|
||||
public static final int TYPE_WEALTH = 1;
|
||||
public static final int TYPE_CHARM = 1;
|
||||
public static final int TYPE_WEALTH = 2;
|
||||
public static final int DATE_DAY = 1;
|
||||
public static final int DATE_WEEK = 2;
|
||||
private AppBarLayout rootView;
|
||||
private OnAppbarListener appbarListener;
|
||||
private SwipeRecyclerView mRecyclerView;
|
||||
HomeRecommendListAdapter adapter;
|
||||
HomeRankListAdapter adapter;
|
||||
SmartRefreshLayout mRefreshLayout;
|
||||
private HeadView hv;
|
||||
private int type;
|
||||
private int date;
|
||||
|
||||
public HomeRankFragment(int type) {
|
||||
super();
|
||||
this.type = type;
|
||||
this.date = DATE_DAY;
|
||||
}
|
||||
|
||||
public void setAppbarListener(OnAppbarListener appbarListener) {
|
||||
this.appbarListener = appbarListener;
|
||||
}
|
||||
|
||||
public void setDate(int date) {
|
||||
this.date = date;
|
||||
updateData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView(View itemView) {
|
||||
rootView = findViewById(R.id.rootView);
|
||||
mRecyclerView = findViewById(R.id.recyclerView);
|
||||
adapter = new HomeRecommendListAdapter(getContext());
|
||||
mRefreshLayout = findViewById(R.id.swipeRefreshLayout);
|
||||
adapter = new HomeRankListAdapter(getContext());
|
||||
hv = new HeadView(rootView);
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
|
||||
rootView.addOnOffsetChangedListener(new AppBarLayout.BaseOnOffsetChangedListener() {
|
||||
mRefreshLayout.setRefreshHeader(new RongRefreshHeader(this.getContext()));
|
||||
mRefreshLayout.setRefreshFooter(new RongRefreshHeader(this.getContext()));
|
||||
mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
||||
@Override
|
||||
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
|
||||
if (appbarListener != null) {
|
||||
if (verticalOffset == 0) {
|
||||
appbarListener.onShow(true);
|
||||
} else if (Math.abs(verticalOffset) >= appBarLayout.getTotalScrollRange()) {
|
||||
appbarListener.onShow(false);
|
||||
}
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
updateData();
|
||||
mRefreshLayout.finishRefresh();
|
||||
}
|
||||
});
|
||||
mRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
refreshLayout.finishLoadMore();
|
||||
}
|
||||
});
|
||||
rootView.addOnOffsetChangedListener((AppBarLayout.BaseOnOffsetChangedListener) (appBarLayout, verticalOffset) -> {
|
||||
if (appbarListener != null) {
|
||||
if (verticalOffset == 0) {
|
||||
appbarListener.onShow(true);
|
||||
} else if (Math.abs(verticalOffset) >= appBarLayout.getTotalScrollRange()) {
|
||||
appbarListener.onShow(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -68,8 +100,33 @@ public class HomeRankFragment extends BaseFragment {
|
||||
public View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_home_ranking, container, false);
|
||||
}
|
||||
private void initData(){
|
||||
|
||||
public void updateData() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getHomeRank(type + "", date + "", new HttpCallback<List<HomeRankBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<HomeRankBean> tmp) {
|
||||
List<HomeRankBean> data = new ArrayList<>();
|
||||
for (int i = 0; i < 1; i++) {
|
||||
data.addAll(tmp);
|
||||
}
|
||||
adapter.clear();
|
||||
hv.clear();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
if (i < 3) {
|
||||
hv.setData(data.get(i), i);
|
||||
continue;
|
||||
}
|
||||
adapter.add(data.get(i));
|
||||
}
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
class HeadView {
|
||||
@@ -117,33 +174,35 @@ public class HomeRankFragment extends BaseFragment {
|
||||
mVotes1 = itemView.findViewById(R.id.votes_1);
|
||||
mVotes2 = itemView.findViewById(R.id.votes_2);
|
||||
mVotes3 = itemView.findViewById(R.id.votes_3);
|
||||
mSex1 = itemView.findViewById(R.id.sex_1);
|
||||
mSex2 = itemView.findViewById(R.id.sex_2);
|
||||
mSex3 = itemView.findViewById(R.id.sex_3);
|
||||
diamond1 = itemView.findViewById(R.id.diamond1);
|
||||
diamond2 = itemView.findViewById(R.id.diamond2);
|
||||
diamond3 = itemView.findViewById(R.id.diamond3);
|
||||
mBtnFollow1 = itemView.findViewById(R.id.btn_follow_1);
|
||||
mBtnFollow2 = itemView.findViewById(R.id.btn_follow_2);
|
||||
mBtnFollow3 = itemView.findViewById(R.id.btn_follow_3);
|
||||
mSex1 = itemView.findViewById(R.id.sex_1);
|
||||
mSex2 = itemView.findViewById(R.id.sex_2);
|
||||
mSex3 = itemView.findViewById(R.id.sex_3);
|
||||
diamond1 = itemView.findViewById(R.id.diamond1);
|
||||
diamond2 = itemView.findViewById(R.id.diamond2);
|
||||
diamond3 = itemView.findViewById(R.id.diamond3);
|
||||
mBtnFollow1 = itemView.findViewById(R.id.btn_follow_1);
|
||||
mBtnFollow2 = itemView.findViewById(R.id.btn_follow_2);
|
||||
mBtnFollow3 = itemView.findViewById(R.id.btn_follow_3);
|
||||
svga1 = itemView.findViewById(R.id.svga1);
|
||||
svga2 = itemView.findViewById(R.id.svga2);
|
||||
svga3 = itemView.findViewById(R.id.svga3);
|
||||
}
|
||||
void setData(HomeRankBean user, int position){
|
||||
getItem(position,mName1,mName2,mName3).setText(user.getUserNicename());
|
||||
getItem(position,mVotes1,mVotes2,mVotes3).setText(user.getMoney());
|
||||
if(user.isFollow()){
|
||||
getItem(position,mBtnFollow1,mBtnFollow2,mBtnFollow3).setVisibility(View.GONE);
|
||||
}else{
|
||||
getItem(position,mBtnFollow1,mBtnFollow2,mBtnFollow3).setVisibility(View.VISIBLE);
|
||||
|
||||
void setData(HomeRankBean user, int position) {
|
||||
getItem(position,mItem1,mItem2,mItem3).setVisibility(View.VISIBLE);
|
||||
getItem(position, mName1, mName2, mName3).setText(user.getUserNicename());
|
||||
getItem(position, mVotes1, mVotes2, mVotes3).setText(user.getMoney());
|
||||
if (user.isFollow()) {
|
||||
getItem(position, mBtnFollow1, mBtnFollow2, mBtnFollow3).setVisibility(View.GONE);
|
||||
} else {
|
||||
getItem(position, mBtnFollow1, mBtnFollow2, mBtnFollow3).setVisibility(View.VISIBLE);
|
||||
}
|
||||
if(user.getSex()==1) {
|
||||
if (user.getSex() == 1) {
|
||||
getItem(position, mSex1, mSex2, mSex3).setImageResource(R.mipmap.ic_message_tab_man);
|
||||
}else{
|
||||
} else {
|
||||
getItem(position, mSex1, mSex2, mSex3).setImageResource(R.mipmap.ic_message_tab_woman);
|
||||
}
|
||||
switch (position){
|
||||
switch (position) {
|
||||
case 0:
|
||||
svga1.setImageResource(R.mipmap.ic_home_rank_top_1);
|
||||
break;
|
||||
@@ -154,8 +213,9 @@ public class HomeRankFragment extends BaseFragment {
|
||||
svga3.setImageResource(R.mipmap.ic_home_rank_top_3);
|
||||
break;
|
||||
}
|
||||
|
||||
ImgLoader.display(mContext, user.getAvatar(), getItem(position, mAvatar1, mAvatar2, mAvatar3));
|
||||
}
|
||||
|
||||
private <T> T getItem(int position, T... views) {
|
||||
return views[position];
|
||||
}
|
||||
@@ -170,5 +230,8 @@ public class HomeRankFragment extends BaseFragment {
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
setVisibility(View.INVISIBLE,-1,mItem1,mItem2,mItem3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.HomeSearchActivity;
|
||||
import com.shayu.onetoone.activity.fragments.BaseFragment;
|
||||
import com.shayu.onetoone.activity.HomepageRankingActivity;
|
||||
import com.shayu.onetoone.adapter.HomeRecommendListAdapter;
|
||||
@@ -52,8 +53,8 @@ public class RecommendFragment extends BaseFragment {
|
||||
}
|
||||
});
|
||||
top.setOnClickListener(view -> {
|
||||
// recyclerView.scrollToPosition(0);
|
||||
startActivity(new Intent(getContext(), HomepageRankingActivity.class));
|
||||
// recyclerView.scrollToPosition(0);
|
||||
startActivity(new Intent(getContext(), HomeSearchActivity.class));
|
||||
});
|
||||
initData();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import static android.content.Context.CLIPBOARD_SERVICE;
|
||||
import android.app.Dialog;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
@@ -53,10 +54,15 @@ import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import io.rong.imkit.IMCenter;
|
||||
import io.rong.imkit.conversation.MessageListAdapter;
|
||||
import io.rong.imkit.conversation.extension.component.plugin.IPluginModule;
|
||||
import io.rong.imkit.conversation.extension.component.plugin.ImagePlugin;
|
||||
import io.rong.imkit.model.UiMessage;
|
||||
import io.rong.imkit.picture.PictureSelector;
|
||||
import io.rong.imkit.picture.config.PictureMimeType;
|
||||
import io.rong.imlib.IRongCallback;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
@@ -98,7 +104,7 @@ public class ChatMessageFragment extends AbsConversationFragment {
|
||||
cameraUtil = new ProcessImageUtil(getActivity(), "com.shayu.onetoone.fileprovider");
|
||||
|
||||
mRongExtension.setVisibility(View.VISIBLE);
|
||||
img.setOnClickListener(v -> cameraUtil.getImageByCamera());
|
||||
// img.setOnClickListener(v -> cameraUtil.getImageByCamera());
|
||||
initCamera();
|
||||
|
||||
mSendBtn.setOnClickListener(v -> {
|
||||
@@ -231,6 +237,43 @@ public class ChatMessageFragment extends AbsConversationFragment {
|
||||
}
|
||||
});
|
||||
});
|
||||
img.setOnClickListener(v -> {
|
||||
new BottomListDialog(mContext)
|
||||
.setStrings(Arrays.asList("相册", "拍照"))
|
||||
.setSelect(new OnItemClickListener<String>() {
|
||||
@Override
|
||||
public void onItemClick(String bean, int position) {
|
||||
boolean isCamera = position == 1;
|
||||
|
||||
SendMessageManager.sendMessageForText(targetId, "图片信息", new OnSendMessageListener() {
|
||||
// PictureSelector.create(currentFragment)
|
||||
// .openGallery(RongConfigCenter.conversationConfig().rc_media_selector_contain_video ? PictureMimeType.ofAll() : PictureMimeType.ofImage())
|
||||
// .loadImageEngine(RongConfigCenter.featureConfig().getKitImageEngine())
|
||||
// .setRequestedOrientation(1)
|
||||
// .videoDurationLimit(RongIMClient.getInstance().getVideoLimitTime())
|
||||
// .maxSelectNum(9)
|
||||
// .imageSpanCount(3)
|
||||
// .isGif(true)
|
||||
// .forResult(this.mRequestCode);
|
||||
@Override
|
||||
public void onSuccess(String token) {
|
||||
super.onSuccess(token);
|
||||
if (isCamera) {
|
||||
PictureSelector.create(ChatMessageFragment.this).openCamera(PictureMimeType.ofImage());
|
||||
} else {
|
||||
PictureSelector.create(ChatMessageFragment.this).openGallery(PictureMimeType.ofImage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int status, String msg) {
|
||||
super.onError(status, msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
}).showDialog();
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
@@ -238,10 +281,6 @@ public class ChatMessageFragment extends AbsConversationFragment {
|
||||
}
|
||||
|
||||
private void checkAuth(OnSendMessageListener listener) {
|
||||
if (true) {
|
||||
listener.onSuccess("");
|
||||
return;
|
||||
}
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getTargetUserInfo(Integer.parseInt(targetId), new HttpCallback<UserBean>() {
|
||||
@Override
|
||||
@@ -517,4 +556,10 @@ public class ChatMessageFragment extends AbsConversationFragment {
|
||||
protected MessageListAdapter onResolveAdapter() {
|
||||
return new MsgChatMessageListAdapter(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
ToastUtil.show("收到回调");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user