diff --git a/Share/src/main/java/com/yunbao/share/adapters/InviteRewardListAdapter.java b/Share/src/main/java/com/yunbao/share/adapters/InviteRewardListAdapter.java index 27f03e25d..8867a1978 100644 --- a/Share/src/main/java/com/yunbao/share/adapters/InviteRewardListAdapter.java +++ b/Share/src/main/java/com/yunbao/share/adapters/InviteRewardListAdapter.java @@ -1,6 +1,8 @@ package com.yunbao.share.adapters; import android.content.Context; +import android.graphics.Color; +import android.graphics.Typeface; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -29,12 +31,12 @@ public class InviteRewardListAdapter extends RecyclerView.Adapter data; private String uid; private String anchorId; private String anchorName; private String anchorAvatar; + private String url; public InvitePopDialog(@NonNull Context context) { super(context); @@ -78,11 +85,9 @@ public class InvitePopDialog extends AbsDialogPopupWindow { super.onCreate(); findViewById(R.id.close).setOnClickListener(v -> dismiss()); findViewById(R.id.share_copy).setOnClickListener(v -> copyLink()); - findViewById(R.id.share_title).setOnClickListener(v -> copyLink()); - findViewById(R.id.share_preview).setVisibility(GONE); + // findViewById(R.id.share_preview).setVisibility(GONE); findViewById(R.id.share_dialog).setBackgroundResource(R.mipmap.bg_dialog_inviet); - ((TextView) findViewById(R.id.share_title)).setText(R.string.dialog_invite_title); - ((TextView) findViewById(R.id.share_title)).setTextColor(R.drawable.bg_invite_title); + title = findViewById(R.id.share_title); list = findViewById(R.id.share_apps_list); avatar = findViewById(R.id.share_avatar); info = findViewById(R.id.share_info); @@ -91,6 +96,28 @@ public class InvitePopDialog extends AbsDialogPopupWindow { list.setLayoutManager(new GridLayoutManager(getContext(), 3)); list.setAdapter(adapter); initData(); + link.setText(url.substring(0, 40)); + info.setText(R.string.dialog_invite_info); + avatar.setImageResource(R.mipmap.ic_launcher); + //title.setTextColor(getContext().getResources().getColorStateList(R.drawable.bg_invite_title)); + title.setText(R.string.dialog_invite_title); + title.setOnClickListener(v -> copyLink()); + title.getViewTreeObserver().addOnGlobalLayoutListener(this::setTitleColor); + } + + private void setTitleColor() { + int[] colors = { + Color.parseColor("#3377FF"), + Color.parseColor("#7F66FF"), + }; + float[] position = { + 0f, + 1.0f + }; + float height = title.getMeasuredHeight(); + LinearGradient mLinearGradient = new LinearGradient(0, 0, 0, height, colors, position, Shader.TileMode.CLAMP); + title.getPaint().setShader(mLinearGradient); + title.invalidate(); } private void initData() { @@ -100,15 +127,15 @@ public class InvitePopDialog extends AbsDialogPopupWindow { data.add(builder(ShareBuilder.APP_TWITTER)); data.add(builder(ShareBuilder.APP_WHATSAPP)); data.add(builder(ShareBuilder.APP_MESSENGER)); - // data.add(builder(ShareBuilder.APP_INSTAGRAM)); + // data.add(builder(ShareBuilder.APP_INSTAGRAM)); adapter.setList(data); } private ShareBuilder builder(int type) { ShareBuilder builder = ShareBuilder.builder(type); - //builder.setText(WordUtil.getString(R.string.dialog_share_info)); - builder.setLink(ShareBuilder.createInviteLink(uid)); + builder.setText(WordUtil.getString(R.string.dialog_share_info)); + builder.setLink(url); builder.setUid(uid); builder.setAnchorId(anchorId); builder.setAnchorName(anchorName); @@ -118,14 +145,19 @@ public class InvitePopDialog extends AbsDialogPopupWindow { private void copyLink() { ClipboardManager cm = (ClipboardManager) getContext().getSystemService(CLIPBOARD_SERVICE); - ClipData clipData = ClipData.newPlainText("text", link.getText().toString()); + ClipData clipData = ClipData.newPlainText("text", url); cm.setPrimaryClip(clipData); ToastUtil.show(WordUtil.getString(com.yunbao.common.R.string.copy_success)); - DialogUitl.showSimpleDialog(getContext(), ShareBuilder.createInviteLink(uid), new DialogUitl.SimpleCallback() { + DialogUitl.showSimpleDialog(getContext(),url, new DialogUitl.SimpleCallback() { @Override public void onConfirmClick(Dialog dialog, String content) { dialog.dismiss(); } }); } + + public InvitePopDialog setUrl(String data) { + this.url = data+"&isGoogle="+ (CommonAppConfig.IS_GOOGLE_PLAY ? "1" : "0"); + return this; + } } diff --git a/Share/src/main/java/com/yunbao/share/ui/InviteRewardPopDialog.java b/Share/src/main/java/com/yunbao/share/ui/InviteRewardPopDialog.java index 1ac8acecc..dd3da1d48 100644 --- a/Share/src/main/java/com/yunbao/share/ui/InviteRewardPopDialog.java +++ b/Share/src/main/java/com/yunbao/share/ui/InviteRewardPopDialog.java @@ -6,6 +6,9 @@ import android.app.Dialog; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; +import android.graphics.Color; +import android.graphics.LinearGradient; +import android.graphics.Shader; import android.widget.TextView; import androidx.annotation.NonNull; @@ -19,6 +22,8 @@ import com.yunbao.common.dialog.AbsDialogPopupWindow; import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; +import com.yunbao.share.adapters.InviteRewardListAdapter; +import com.yunbao.share.bean.InviteRewardBean; import com.yunbao.share.bean.ShareBuilder; import com.yunbao.share.adapters.ShareAppAdapter; @@ -26,13 +31,13 @@ import java.util.ArrayList; import java.util.List; public class InviteRewardPopDialog extends AbsDialogPopupWindow { - private ShareAppAdapter adapter; + private InviteRewardListAdapter adapter; private RecyclerView list; private RoundedImageView avatar; private TextView info; private TextView link; - private List data; - + private List data; + private TextView title; private String uid; private String anchorId; private String anchorName; @@ -78,29 +83,41 @@ public class InviteRewardPopDialog extends AbsDialogPopupWindow { super.onCreate(); findViewById(R.id.close).setOnClickListener(v -> dismiss()); findViewById(R.id.share_copy).setOnClickListener(v -> copyLink()); - findViewById(R.id.share_title).setOnClickListener(v -> copyLink()); findViewById(R.id.share_preview).setVisibility(GONE); findViewById(R.id.share_dialog).setBackgroundResource(R.mipmap.bg_dialog_inviet); - ((TextView) findViewById(R.id.share_title)).setText(R.string.dialog_invite_title); - ((TextView) findViewById(R.id.share_title)).setTextColor(R.drawable.bg_invite_title); + title = findViewById(R.id.share_title); + title.setOnClickListener(v -> copyLink()); + title.setText(R.string.dialog_invite_reward_title); list = findViewById(R.id.share_apps_list); avatar = findViewById(R.id.share_avatar); info = findViewById(R.id.share_info); link = findViewById(R.id.share_link); - adapter = new ShareAppAdapter(getContext()); - list.setLayoutManager(new LinearLayoutManager(getContext(),RecyclerView.VERTICAL,false)); + adapter = new InviteRewardListAdapter(getContext()); + list.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, false)); list.setAdapter(adapter); initData(); + title.getViewTreeObserver().addOnGlobalLayoutListener(this::setTitleColor); + } + private void setTitleColor(){ + int[] colors = { + Color.parseColor("#3377FF"), + Color.parseColor("#7F66FF"), + }; + float[] position = { + 0f, + 1.0f + }; + float height=title.getMeasuredHeight(); + LinearGradient mLinearGradient = new LinearGradient(0, 0, 0, height, colors, position, Shader.TileMode.CLAMP); + title.getPaint().setShader(mLinearGradient); + title.invalidate(); } - private void initData() { data = new ArrayList<>(); - data.add(builder(ShareBuilder.APP_FACEBOOK)); - data.add(builder(ShareBuilder.APP_LINE)); - data.add(builder(ShareBuilder.APP_TWITTER)); - data.add(builder(ShareBuilder.APP_WHATSAPP)); - data.add(builder(ShareBuilder.APP_MESSENGER)); - // data.add(builder(ShareBuilder.APP_INSTAGRAM)); + data.add(new InviteRewardBean("標題", "邀請時間", "用戶等級", "獲得獎勵")); + for (int i = 0; i < 5; i++) { + data.add(new InviteRewardBean("用戶" + 1, "時間" + 1, "等級" + 1, "獎勵" + 1)); + } adapter.setList(data); } diff --git a/Share/src/main/res/layout/item_invite_reward.xml b/Share/src/main/res/layout/item_invite_reward.xml index 55e80f88f..4973964c1 100644 --- a/Share/src/main/res/layout/item_invite_reward.xml +++ b/Share/src/main/res/layout/item_invite_reward.xml @@ -2,7 +2,7 @@ + android:layout_height="wrap_content"> diff --git a/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java b/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java index 0801887be..36bd403cc 100644 --- a/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java +++ b/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java @@ -27,6 +27,7 @@ import com.yunbao.common.Constants; import com.yunbao.common.R; import com.yunbao.common.event.JavascriptInterfaceEvent; import com.yunbao.common.utils.AndroidBug5497Workaround; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DeviceUtils; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.JavascriptInterfaceUtils; @@ -63,6 +64,7 @@ public class WebViewActivity extends AbsActivity { protected void main() { String url = getIntent().getStringExtra(Constants.URL); L.e("H5--->" + url); + Bus.getOn(this); LinearLayout rootView = (LinearLayout) findViewById(R.id.rootView); mProgressBar = (ProgressBar) findViewById(R.id.progressbar); btnEdit = (ImageView) findViewById(R.id.btn_edit); @@ -254,6 +256,7 @@ public class WebViewActivity extends AbsActivity { Constants.myIntoIndex = 0; indexInto = 0; Constants.LoginKefu = true; + Bus.getOff(this); super.onDestroy(); } @@ -309,5 +312,16 @@ public class WebViewActivity extends AbsActivity { @Subscribe(threadMode = ThreadMode.MAIN) public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) { indexInto = event.getIndexInto(); + if (event.getMethod().equals("androidInviteShare")) { + try { + Class clz = mContext.getClassLoader().loadClass("com.yunbao.share.ui.InvitePopDialog"); + Object invite = clz.getConstructor(Context.class).newInstance(mContext); + invite = invite.getClass().getMethod("setUrl", String.class).invoke(invite, event.getData()); + assert invite != null; + invite.getClass().getMethod("showDialog").invoke(invite); + } catch (Exception e) { + throw new RuntimeException(e); + } + } } } diff --git a/common/src/main/java/com/yunbao/common/bean/UserAreaBean.java b/common/src/main/java/com/yunbao/common/bean/UserAreaBean.java new file mode 100644 index 000000000..5ba3baa0e --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/UserAreaBean.java @@ -0,0 +1,16 @@ +package com.yunbao.common.bean; + +public class UserAreaBean extends BaseModel { + private String area; + + public UserAreaBean() { + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } +} diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index 40349b368..f0bb3c90e 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -37,6 +37,7 @@ import com.yunbao.common.bean.SearchModel; import com.yunbao.common.bean.SetAttentsModel; import com.yunbao.common.bean.SlideInBannerModel; import com.yunbao.common.bean.StarChallengeStatusModel; +import com.yunbao.common.bean.UserAreaBean; import com.yunbao.common.bean.VipModel; import com.yunbao.common.bean.WishListGiftConfModel; import com.yunbao.common.bean.WishListModel; @@ -679,4 +680,10 @@ public interface PDLiveApi { Observable>> getDiscountInfo( @Query("type") int type ); + /** + * 获取地区 + */ + @GET("/api/public/?service=User.getUserArea") + Observable> getUserArea(); + } diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index f16633fcc..12e846038 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -34,6 +34,7 @@ import com.yunbao.common.bean.RandomPkUserBean; import com.yunbao.common.bean.RankPkInfoBean; import com.yunbao.common.bean.SetAttentsModel; import com.yunbao.common.bean.StarChallengeStatusModel; +import com.yunbao.common.bean.UserAreaBean; import com.yunbao.common.bean.VipModel; import com.yunbao.common.bean.WishListGiftConfModel; import com.yunbao.common.bean.WishListModel; @@ -1379,6 +1380,27 @@ public class LiveNetManager { } }).isDisposed(); } + public void getUserArea(HttpCallback callback) { + API.get().pdLiveApi(mContext) + .getUserArea() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>() { + @Override + public void accept(ResponseModel wishListGiftConfModelResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(wishListGiftConfModelResponseModel.getData().getInfo()); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(throwable.getMessage()); + } + } + }).isDisposed(); + } /** * 直播间取消网络请求 diff --git a/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java b/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java index 4cefb1f0f..9eb440bc7 100644 --- a/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java +++ b/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java @@ -497,6 +497,12 @@ public class JavascriptInterfaceUtils { mWebView.setVisibility(View.VISIBLE); }); } + + /** + * 社区分享 + * @param avatar 头像 + * @param link 分享连接 + */ @JavascriptInterface public void androidCommunityShare(String avatar,String link){ JSONObject json=new JSONObject(); @@ -506,4 +512,10 @@ public class JavascriptInterfaceUtils { .setMethod("androidCommunityShare") .setData(json.toJSONString())); } + @JavascriptInterface + public void androidInviteShare(String url){ + Bus.get().post(new JavascriptInterfaceEvent() + .setMethod("androidInviteShare") + .setData(url)); + } } diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveAnchorEditCallMeAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveAnchorEditCallMeAdapter.java index 692b24e30..9f8cd1133 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveAnchorEditCallMeAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveAnchorEditCallMeAdapter.java @@ -177,6 +177,7 @@ public class LiveAnchorEditCallMeAdapter extends RecyclerView.Adapter { private ScaleAnimation mAnimation; private View mAnimView; private String mName1, mName2; + boolean isTouch=true; + + public void setTouch(boolean touch) { + isTouch = touch; + } public LiveGiftAdapter(Context context, LayoutInflater inflater, List list, String coinName) { mContext = context; @@ -65,6 +70,9 @@ public class LiveGiftAdapter extends RecyclerView.Adapter { mOnClickListener = new View.OnClickListener() { @Override public void onClick(View v) { + if(!isTouch){ + return; + } Object tag = v.getTag(); if (tag != null) { int position = (int) tag; diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveGiftPagerAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveGiftPagerAdapter.java index 062e6889a..f02e95447 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveGiftPagerAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveGiftPagerAdapter.java @@ -7,6 +7,7 @@ import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; +import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; @@ -83,6 +84,7 @@ public class LiveGiftPagerAdapter extends PagerAdapter { /** * 刷新指定礼物id的item 界面 + * * @param giftId */ public void refreshId(int giftId) { @@ -90,7 +92,7 @@ public class LiveGiftPagerAdapter extends PagerAdapter { RecyclerView.Adapter adapter = recyclerView.getAdapter(); if (adapter instanceof LiveGiftAdapter) { for (int i = 0; i < ((LiveGiftAdapter) adapter).getList().size(); i++) { - if(((LiveGiftAdapter) adapter).getList().get(i).getId()==giftId){ + if (((LiveGiftAdapter) adapter).getList().get(i).getId() == giftId) { adapter.notifyItemChanged(i); return; } @@ -157,6 +159,23 @@ public class LiveGiftPagerAdapter extends PagerAdapter { } } + /** + * 禁止用户点击更换礼物 + */ + public void disTouch(int giftId) { + for (RecyclerView recyclerView : mViewList) { + RecyclerView.Adapter adapter = recyclerView.getAdapter(); + if (adapter instanceof LiveGiftAdapter) { + for (int i = 0; i < ((LiveGiftAdapter) adapter).getList().size(); i++) { + if (((LiveGiftAdapter) adapter).getList().get(i).getId() == giftId) { + ((LiveGiftAdapter) adapter).setTouch(false); + return; + } + } + } + } + } + public interface ActionListener { void onItemChecked(LiveGiftBean bean); } diff --git a/live/src/main/java/com/yunbao/live/custom/GiftViewPager.java b/live/src/main/java/com/yunbao/live/custom/GiftViewPager.java new file mode 100644 index 000000000..e6de7bec5 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/custom/GiftViewPager.java @@ -0,0 +1,40 @@ +package com.yunbao.live.custom; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.MotionEvent; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.viewpager.widget.ViewPager; + +public class GiftViewPager extends ViewPager { + boolean isTouch=true; + public GiftViewPager(@NonNull Context context) { + super(context); + } + + public GiftViewPager(@NonNull Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + } + + public void setTouch(boolean touch) { + isTouch = touch; + } + + @Override + public boolean onTouchEvent(MotionEvent ev) { + if(!isTouch){ + return false; + } + return super.onTouchEvent(ev); + } + + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + if(!isTouch){ + return false; + } + return super.onInterceptTouchEvent(ev); + } +} diff --git a/live/src/main/java/com/yunbao/live/dialog/GiftPopDialog.java b/live/src/main/java/com/yunbao/live/dialog/GiftPopDialog.java index 662e3dcda..6de58b93f 100644 --- a/live/src/main/java/com/yunbao/live/dialog/GiftPopDialog.java +++ b/live/src/main/java/com/yunbao/live/dialog/GiftPopDialog.java @@ -65,6 +65,7 @@ public class GiftPopDialog extends AbsDialogPopupWindow implements ActionListene private View numberView; private String title; private TextView mTitle; + private boolean isOldGiftList = false; public GiftPopDialog(@NonNull Context context) { @@ -159,25 +160,52 @@ public class GiftPopDialog extends AbsDialogPopupWindow implements ActionListene return this; } + public GiftPopDialog setOldGiftList(boolean oldGiftList) { + isOldGiftList = oldGiftList; + return this; + } + private void initDate() { - LiveHttpUtil.getNewGiftList(new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - if (code == 0 && info.length > 0) { - JSONObject obj = JSON.parseObject(info[0]); - JSONArray list = obj.getJSONArray("listarray"); - setDate(list); + if (isOldGiftList) { + LiveHttpUtil.getGiftList(new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + JSONObject obj = JSON.parseObject(info[0]); + obj.put("listarray", obj.getJSONArray("giftlist")); + JSONArray list = obj.getJSONArray("listarray"); + setDate(list); + } } - } - @Override - public void onFinish() { - if (mLoading != null) { - mLoading.setVisibility(View.INVISIBLE); + @Override + public void onFinish() { + if (mLoading != null) { + mLoading.setVisibility(View.INVISIBLE); + } } - } - }); + }); + } else { + LiveHttpUtil.getNewGiftList(new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + JSONObject obj = JSON.parseObject(info[0]); + JSONArray list = obj.getJSONArray("listarray"); + setDate(list); + + } + } + + @Override + public void onFinish() { + if (mLoading != null) { + mLoading.setVisibility(View.INVISIBLE); + } + } + }); + } } private void setDate(JSONArray list) { @@ -190,7 +218,10 @@ public class GiftPopDialog extends AbsDialogPopupWindow implements ActionListene } giftTopAdapter.setList(name); - + if(isOldGiftList){ + showGiftList(JSON.parseArray(list.toJSONString(), LiveGiftBean.class)); + return; + } JSONObject obj2 = list.getJSONObject(type); String giftJson = obj2.getString("giftlist"); @@ -198,7 +229,6 @@ public class GiftPopDialog extends AbsDialogPopupWindow implements ActionListene } private void showGiftList(List list) { - mLiveGiftPagerAdapter = new LiveGiftPagerAdapter(mContext, list); mLiveGiftPagerAdapter.setActionListener(this); diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment.java index 336b4d1b5..d45e056ea 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment.java @@ -26,16 +26,11 @@ import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.TextView; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; -import androidx.fragment.app.FragmentManager; -import androidx.fragment.app.FragmentTransaction; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import androidx.viewpager.widget.ViewPager; - import com.alibaba.android.arouter.launcher.ARouter; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; @@ -54,6 +49,7 @@ import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.GiftCacheUtil; import com.yunbao.common.utils.NobleUtil; +import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; @@ -62,6 +58,7 @@ import com.yunbao.live.adapter.LiveGiftCountAdapter; import com.yunbao.live.adapter.LiveGiftPagerAdapter; import com.yunbao.live.bean.GiftTopBean; import com.yunbao.live.bean.LiveGuardInfo; +import com.yunbao.live.custom.GiftViewPager; import com.yunbao.live.http.LiveHttpConsts; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.utils.ToolsButton; @@ -84,8 +81,8 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On private TextView mCoin; private TextView mTvGoldCoin; private TextView mTvGoCharge; - - private ViewPager mViewPager, mVPWrapList; + private GiftViewPager mViewPager; + private ViewPager mVPWrapList; private RadioGroup mRadioGroup, mRGroupWrap; private View mLoading; private View mArrow; @@ -199,7 +196,7 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On mLianText = (TextView) mRootView.findViewById(R.id.lian_text); mDrawable1 = ContextCompat.getDrawable(mContext, R.drawable.bg_live_gift_send); mDrawable2 = ContextCompat.getDrawable(mContext, R.drawable.bg_live_gift_send_2); - mViewPager = (ViewPager) mRootView.findViewById(R.id.viewPager); + mViewPager = (GiftViewPager) mRootView.findViewById(R.id.viewPager); mVPWrapList = (ViewPager) mRootView.findViewById(R.id.vpWrapList); final LinearLayoutManager manager = new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false); items.setLayoutManager(manager); @@ -303,6 +300,10 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On mWishGiftId = bundle.getString(Constants.LIVE_WISH_GIFTID); by = bundle.getString("by"); isContactGift = bundle.getBoolean("isContactGift", false) ? 1 : 0; + if (isContactGift == 1) { + mViewPager.setTouch(false); + findViewById(R.id.gift_tab_layout).setVisibility(View.GONE); + } } loadGiftListData(); loadUserVip(); @@ -339,7 +340,7 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On //根据变量,判断是否取缓存 if (isGetNewWrap) { isGetNewWrap = false; - } else { + } else if (isContactGift == 0) { String giftListJson = CommonAppConfig.getInstance().getGiftListJson(); if (!TextUtils.isEmpty(giftListJson)) { try { @@ -351,29 +352,56 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On } } if (list == null) { - LiveHttpUtil.getNewGiftList(new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - if (code == 0 && info.length > 0) { - JSONObject obj = JSON.parseObject(info[0]); - list = obj.getJSONArray("listarray"); - Log.i("tttts", obj.getString("listarray") + ""); - CommonAppConfig.getInstance().setGiftListJson(obj.getString("listarray")); - - upData(); - mCoin.setText(obj.getString("coin")); - mTvGoldCoin.setText(obj.getString("gold")); - Bus.getOn(LiveGiftDialogFragment.this); + if (isContactGift == 1) { + LiveHttpUtil.getGiftList(new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + JSONObject obj = JSON.parseObject(info[0]); + obj.put("listarray", obj.getJSONArray("giftlist")); + list = obj.getJSONArray("listarray"); + Log.i("tttts", obj.getString("giftlist") + ""); + List _list = JSON.parseArray(obj.getJSONArray("giftlist").toJSONString(), LiveGiftBean.class); + showGiftList(_list); + mGiftPackage.setTextColor(Color.parseColor("#FFFFFF")); + mCoin.setText(obj.getString("coin")); + mTvGoldCoin.setText(obj.getString("gold")); + Bus.getOn(LiveGiftDialogFragment.this); + } } - } - @Override - public void onFinish() { - if (mLoading != null) { - mLoading.setVisibility(View.INVISIBLE); + @Override + public void onFinish() { + if (mLoading != null) { + mLoading.setVisibility(View.INVISIBLE); + } } - } - }); + }); + } else { + LiveHttpUtil.getNewGiftList(new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + JSONObject obj = JSON.parseObject(info[0]); + list = obj.getJSONArray("listarray"); + Log.i("tttts", obj.getString("listarray") + ""); + CommonAppConfig.getInstance().setGiftListJson(obj.getString("listarray")); + + upData(); + mCoin.setText(obj.getString("coin")); + mTvGoldCoin.setText(obj.getString("gold")); + Bus.getOn(LiveGiftDialogFragment.this); + } + } + + @Override + public void onFinish() { + if (mLoading != null) { + mLoading.setVisibility(View.INVISIBLE); + } + } + }); + } } else { mLoading.setVisibility(View.INVISIBLE); upData(); @@ -467,7 +495,10 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On mBeanFromWish = bean; bean.setChecked(true); itemCheckOp(bean); - mViewPager.setCurrentItem(i / 10); + mViewPager.setCurrentItem(i / 8); + if (isContactGift == 1) { + mLiveGiftPagerAdapter.disTouch(bean.getId()); + } } catch (Exception e) { e.printStackTrace(); } @@ -689,6 +720,9 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On } } SendGiftCallback callback = new SendGiftCallback(mLiveGiftBean); + if (!StringUtil.isEmpty(mWishGiftId) && mLiveGiftBean.getId() != Integer.parseInt(mWishGiftId)) { + isContactGift = 0; + } if (by != null) { LiveHttpUtil.sendGift("1", mLiveUid, mStream, mLiveGiftBean.getId(), mCount, isContactGift, callback); } else { diff --git a/live/src/main/res/layout/dialog_live_gift_wrap.xml b/live/src/main/res/layout/dialog_live_gift_wrap.xml index 6a96b30c4..0a251de81 100644 --- a/live/src/main/res/layout/dialog_live_gift_wrap.xml +++ b/live/src/main/res/layout/dialog_live_gift_wrap.xml @@ -135,7 +135,7 @@ android:gravity="bottom" android:orientation="vertical"> - + android:background="@mipmap/bg_live_user_mailbox" + android:layout_height="235dp"> - + app:layout_constraintEnd_toEndOf="parent" /> \ No newline at end of file diff --git a/live/src/main/res/mipmap-xhdpi/bg_live_user_mailbox.png b/live/src/main/res/mipmap-xxxhdpi/bg_live_user_mailbox.png similarity index 100% rename from live/src/main/res/mipmap-xhdpi/bg_live_user_mailbox.png rename to live/src/main/res/mipmap-xxxhdpi/bg_live_user_mailbox.png diff --git a/live/src/main/res/mipmap-xhdpi/bg_live_user_mailbox_top.png b/live/src/main/res/mipmap-xxxhdpi/bg_live_user_mailbox_top.png similarity index 100% rename from live/src/main/res/mipmap-xhdpi/bg_live_user_mailbox_top.png rename to live/src/main/res/mipmap-xxxhdpi/bg_live_user_mailbox_top.png diff --git a/main/src/main/java/com/yunbao/main/activity/LoginActivity.java b/main/src/main/java/com/yunbao/main/activity/LoginActivity.java index 335212217..95367881c 100644 --- a/main/src/main/java/com/yunbao/main/activity/LoginActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/LoginActivity.java @@ -14,7 +14,6 @@ import android.util.Log; import android.view.View; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; -import android.widget.Toast; import androidx.recyclerview.widget.RecyclerView; @@ -36,12 +35,14 @@ import com.yunbao.common.bean.ConfigBean; import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.LoginData; +import com.yunbao.common.bean.UserAreaBean; import com.yunbao.common.bean.UserBean; import com.yunbao.common.http.CommonHttpConsts; import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; import com.yunbao.common.http.JsonBean; +import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.NoviceInstructorManager; @@ -100,6 +101,7 @@ public class LoginActivity extends AbsActivity { @Override protected void main() { EventBus.getDefault().register(this); + initUserArea(); mRoot = findViewById(R.id.root); Contexts = this; activity = this; @@ -364,6 +366,19 @@ public class LoginActivity extends AbsActivity { mUuidDevice = DeviceUtils.getUniqueDeviceId(); } + private void initUserArea(){ + LiveNetManager.get(mContext).getUserArea(new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(UserAreaBean data) { + IMLoginManager.get(mContext).put("sys_user_area",data.getArea()); + } + + @Override + public void onError(String error) { + } + }); + } + @Override protected void onDestroy() { diff --git a/main/src/main/java/com/yunbao/main/activity/RegisterActivity.java b/main/src/main/java/com/yunbao/main/activity/RegisterActivity.java index 2ccbd912e..032abdc9d 100644 --- a/main/src/main/java/com/yunbao/main/activity/RegisterActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/RegisterActivity.java @@ -192,7 +192,9 @@ public class RegisterActivity extends AbsActivity { allCountries.clear(); allCountries.addAll(Country.getAll(mContext, null)); - String ct = Locale.getDefault().getCountry(); + //String ct = Locale.getDefault().getCountry(); + String ct = IMLoginManager.get(mContext).getString("sys_user_area"); + ToastUtil.show("地区:"+ct); ct = TextUtils.equals("CN", ct) ? "HK" : ct; for (int i = 0; i < allCountries.size(); i++) { if (allCountries.get(i).locale.equals(ct)) {