diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index feadf90..2d90d8f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -540,6 +540,22 @@ android:name=".wallet.WalletInfoActivity" android:exported="true" android:screenOrientation="portrait" /> + + + + + + listFragment; + + + public CommunityAdapter(@NonNull FragmentActivity fragmentActivity, List listFragment) { + super(fragmentActivity); + this.listFragment = listFragment; + } + + + @NonNull + @Override + public Fragment createFragment(int position) { + return listFragment.get(position); + } + + @Override + public int getItemCount() { + return listFragment.size(); + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/hbl/lewan/main/MainActivity.java b/app/src/main/java/com/hbl/lewan/main/MainActivity.java index ccc96e0..40793c6 100644 --- a/app/src/main/java/com/hbl/lewan/main/MainActivity.java +++ b/app/src/main/java/com/hbl/lewan/main/MainActivity.java @@ -235,7 +235,7 @@ public class MainActivity extends BaseActivity { private ConversationBaseFragment mConversationFragment; // private IndexFragment indexFragment; - private HomeFragment index2Fragment; +// private HomeFragment index2Fragment; private ChatTabFragment chatTabFragment; // private ChatMainFragment chatMainFragment; // private ChatMain2Fragment chatMain2Fragment; @@ -772,11 +772,11 @@ public class MainActivity extends BaseActivity { ALog.d(Constant.PROJECT_TAG, "MainActivity:initView"); loadConfig(); List fragments = new ArrayList<>(); - index2Fragment = new HomeFragment(); +// index2Fragment = new HomeFragment(); chatTabFragment = new ChatTabFragment(); voomFragment = new VoomFragment(); walletFragment = new MineFragment(); - fragments.add(index2Fragment); +// fragments.add(index2Fragment); fragments.add(chatTabFragment); if(ApiService.AREA_CODE.equals("+86")) { fragments.add(voomFragment); @@ -792,7 +792,7 @@ public class MainActivity extends BaseActivity { activityMainBinding.viewPager.setAdapter(fragmentAdapter); activityMainBinding.viewPager.setCurrentItem(START_INDEX, false); activityMainBinding.viewPager.setOffscreenPageLimit(fragments.size()); - mCurrentTab = activityMainBinding.conversationBtnGroup; + mCurrentTab = activityMainBinding.contactBtnGroup; resetTabSkin(isCommonSkin); checkZhiWen(); shareDateUtils = new ShareDateUtils(); @@ -1548,14 +1548,14 @@ public class MainActivity extends BaseActivity { @SuppressLint("UseCompatLoadingForDrawables") private void resetTabSkin(boolean isCommonSkin) { if (mCurrentTab == activityMainBinding.contactBtnGroup) { - activityMainBinding.viewPager.setCurrentItem(1, false); + activityMainBinding.viewPager.setCurrentItem(0, false); activityMainBinding.contact.setTextColor( getResources().getColor(R.color.color_fe6881)); activityMainBinding.contact.setCompoundDrawablesWithIntrinsicBounds( null, getResources().getDrawable(R.mipmap.chat_img_t), null, null); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); } else if (mCurrentTab == activityMainBinding.liveBtnGroup) { - activityMainBinding.viewPager.setCurrentItem(2, false); + activityMainBinding.viewPager.setCurrentItem(1, false); activityMainBinding.live.setTextColor( getResources().getColor(R.color.color_fe6881)); activityMainBinding.live.setCompoundDrawablesWithIntrinsicBounds( @@ -1563,7 +1563,7 @@ public class MainActivity extends BaseActivity { getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); } else if (mCurrentTab == activityMainBinding.myselfBtnGroup) { // if(ApiService.AREA_CODE.equals("+86")) { - activityMainBinding.viewPager.setCurrentItem(3, false); + activityMainBinding.viewPager.setCurrentItem(2, false); // }else{ // activityMainBinding.viewPager.setCurrentItem(1, false); // } diff --git a/app/src/main/java/com/hbl/lewan/main/mine/MineFragment.java b/app/src/main/java/com/hbl/lewan/main/mine/MineFragment.java index e9f69d7..83a2d99 100644 --- a/app/src/main/java/com/hbl/lewan/main/mine/MineFragment.java +++ b/app/src/main/java/com/hbl/lewan/main/mine/MineFragment.java @@ -54,6 +54,7 @@ import com.hbl.lewan.utils.DataUtils; import com.hbl.lewan.utils.GsonUtils; import com.hbl.lewan.utils.LogUtils; import com.hbl.lewan.wallet.GiftInfoActivity; +import com.hbl.lewan.wallet.MyWalletActivity; import com.hbl.lewan.wallet.PaySettingActivity; import com.hbl.lewan.wallet.WalletInfoActivity; import com.hbl.lewan.welcome.WelcomeActivity; @@ -267,7 +268,7 @@ public class MineFragment extends BaseFragment { if (!bindBean.getPhoneBind()) { showDialog(); } else { - Intent intent = new Intent(getActivity(), WalletInfoActivity.class); + Intent intent = new Intent(getActivity(), MyWalletActivity.class); intent.putExtra("isG", b); startActivity(intent); } @@ -518,7 +519,7 @@ public class MineFragment extends BaseFragment { private void changeInfo() { if (walletBean != null) { binding.jinbiTv.setText(AppUtils.getQian(walletBean.getGoldCoin())); - binding.yinbiTv.setText(AppUtils.getQian(walletBean.getSilverCoin())); + binding.yinbiTv.setText(AppUtils.getQian(walletBean.getGoldCoin())); binding.tongbiTv.setText(AppUtils.getQian(walletBean.getGiftCoin() * 100)); } } diff --git a/app/src/main/java/com/hbl/lewan/wallet/MyWalletActivity.java b/app/src/main/java/com/hbl/lewan/wallet/MyWalletActivity.java new file mode 100644 index 0000000..b9b2348 --- /dev/null +++ b/app/src/main/java/com/hbl/lewan/wallet/MyWalletActivity.java @@ -0,0 +1,187 @@ +package com.hbl.lewan.wallet; + +import android.content.Intent; +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.view.View; + +import androidx.annotation.Nullable; +import androidx.core.content.ContextCompat; +import androidx.core.graphics.drawable.DrawableCompat; + +import com.hbl.lewan.R; +import com.hbl.lewan.databinding.ActivityMywalletBinding; +import com.hbl.lewan.databinding.ActivityWalletInfoNewBinding; +import com.hbl.lewan.dialog.ActionConfirmDialog; +import com.hbl.lewan.main.mine.ChangeAccoutActionActivity; +import com.hbl.lewan.model.BindBean; +import com.hbl.lewan.model.WalletBean; +import com.hbl.lewan.network.Api; +import com.hbl.lewan.network.BaseObserver; +import com.hbl.lewan.network.Result; +import com.hbl.lewan.pay.LipinDuiHuanActivity; +import com.hbl.lewan.utils.AnimUtil; +import com.hbl.lewan.utils.AppUtils; +import com.hbl.lewan.utils.GsonUtils; +import com.hbl.lewan.utils.LogUtils; +import com.netease.yunxin.kit.common.ui.activities.BaseActivity; +import com.netease.yunxin.kit.corekit.im.IMKitClient; + +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.schedulers.Schedulers; + +public class MyWalletActivity extends BaseActivity { + boolean isG; + ActivityMywalletBinding viewBinding; + WalletBean walletBean; + BindBean bindBean; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + + + super.onCreate(savedInstanceState); + viewBinding = ActivityMywalletBinding.inflate(getLayoutInflater()); + setContentView(viewBinding.getRoot()); + isG = getIntent().getBooleanExtra("isG", true); + initView(); + getWallet(); + bindInfo(); + } + + + private void bindInfo() { + Api.getInstance().bindInfo(IMKitClient.account()) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new BaseObserver>() { + @Override + public void onSuccess(Result feedbackResp) { + bindBean = feedbackResp.data; + LogUtils.i("获取到的数据:" + GsonUtils.beanToJSONString(bindBean)); + } + + @Override + public void onError(int code, String msg) { + LogUtils.i("获取到的错误:" + code + "" + msg); + } + }); + + } + + protected void initView() { + viewBinding.contactListActivityTitleBar.getBackImageView().setOnClickListener(v -> finish()); + + viewBinding.lqmxBt.setOnClickListener(v -> { + if (bindBean != null) { + if (!bindBean.getPhoneBind()) { + showDialog(); + } else { + Intent intent = new Intent(MyWalletActivity.this, WalletInfoNewActivity.class); + intent.putExtra("isG", true); + startActivity(intent); + } + } + }); + viewBinding.czBt.setOnClickListener(v -> startActivity(new Intent(MyWalletActivity.this, TopUpActivity.class))); + viewBinding.txBt.setOnClickListener(v -> startActivity(new Intent(MyWalletActivity.this, TopUpActivity.class))); + + + viewBinding.hbjlBt.setOnClickListener(v -> { + if (bindBean != null) { + if (!bindBean.getPhoneBind()) { + showDialog(); + } else { + Intent intent = new Intent(MyWalletActivity.this, WalletInfoRedActivity.class); + intent.putExtra("isG", true); + startActivity(intent); + } + } + }); + } + + + private void showDialogPay() { + + com.netease.yunxin.kit.chatkit.ui.dialog.ActionConfirmDialog actionDialog = new com.netease.yunxin.kit.chatkit.ui.dialog.ActionConfirmDialog(MyWalletActivity.this, + getString(com.netease.yunxin.kit.chatkit.ui.R.string.bind_phone_des_txt1), getString(com.netease.yunxin.kit.chatkit.ui.R.string.cancel_txt), getString(com.netease.yunxin.kit.chatkit.ui.R.string.to_sett_txt)); + actionDialog.setOnToActionListener(new com.netease.yunxin.kit.chatkit.ui.dialog.ActionConfirmDialog.OnToActionListener() { + @Override + public void toSumbit() { +// Intent intent = new Intent(getActivity(), ChangeAccoutActionActivity.class); +// intent.putExtra("type", 5); +// startActivity(intent); + Intent intent = new Intent(MyWalletActivity.this, SetPayPasswordActivity.class); + startActivity(intent); + } + + @Override + public void toCancel() { + + } + }); + actionDialog.show(); + } + + + private void showDialog() { + + ActionConfirmDialog actionDialog = new ActionConfirmDialog(MyWalletActivity.this, + getString(R.string.bind_phone_des_txt), getString(R.string.nobind_txt), getString(R.string.tobind_txt)); + actionDialog.setOnToActionListener(new ActionConfirmDialog.OnToActionListener() { + @Override + public void toSumbit() { + Intent intent = new Intent(MyWalletActivity.this, ChangeAccoutActionActivity.class); + intent.putExtra("type", ChangeAccoutActionActivity.TYPE_BIND_PHONE); + startActivity(intent); + } + + @Override + public void toCancel() { + + } + }); + actionDialog.show(); + } + + private void getWallet() { + Api.getInstance().walletInfo(IMKitClient.account()) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new BaseObserver>() { + + @Override + public void onSuccess(Result feedbackResp) { + walletBean = feedbackResp.data; + changeInfo(); + + } + + @Override + public void onError(int code, String msg) { + + } + }); + + + } + + + private void changeInfo() { +// if (walletBean != null) { + viewBinding.jinbiYueTv.setText("¥ "+AppUtils.getQian(walletBean.getGoldCoin())); +// viewBinding.yinbiYueTv.setText(AppUtils.getQian(walletBean.getSilverCoin())); +// +// } + + } + @Override + protected void onStop() { + super.onStop(); + + } + + + + +} diff --git a/app/src/main/java/com/hbl/lewan/wallet/TopUpActivity.java b/app/src/main/java/com/hbl/lewan/wallet/TopUpActivity.java index 795d74e..418bfee 100644 --- a/app/src/main/java/com/hbl/lewan/wallet/TopUpActivity.java +++ b/app/src/main/java/com/hbl/lewan/wallet/TopUpActivity.java @@ -66,9 +66,9 @@ public class TopUpActivity extends BaseActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { - getWindow().setStatusBarColor(getResources().getColor(R.color.color_403d51)); - getWindow().setNavigationBarColor(getResources().getColor(R.color.color_fffbfb)); - getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); +// getWindow().setStatusBarColor(getResources().getColor(R.color.color_403d51)); +// getWindow().setNavigationBarColor(getResources().getColor(R.color.color_fffbfb)); +// getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); super.onCreate(savedInstanceState); viewBinding = ActivityTopupBinding.inflate(getLayoutInflater()); @@ -203,10 +203,10 @@ public class TopUpActivity extends BaseActivity { } protected void initView() { - Drawable drawable = viewBinding.titlebar.getBackImageView().getDrawable().mutate();// - Drawable wrap = DrawableCompat.wrap(drawable); - DrawableCompat.setTint(wrap, ContextCompat.getColor(this, R.color.color_d4ab90)); - viewBinding.titlebar.getBackImageView().setImageDrawable(wrap); +// Drawable drawable = viewBinding.titlebar.getBackImageView().getDrawable().mutate();// +// Drawable wrap = DrawableCompat.wrap(drawable); +// DrawableCompat.setTint(wrap, ContextCompat.getColor(this, R.color.color_d4ab90)); +// viewBinding.titlebar.getBackImageView().setImageDrawable(wrap); viewBinding.titlebar.getBackImageView().setOnClickListener(v -> finish()); iniAdapter(); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(TopUpActivity.this); @@ -479,7 +479,7 @@ public class TopUpActivity extends BaseActivity { private void changeInfo() { - viewBinding.dianshuTv.setText(AppUtils.getQian(walletBean.getGoldCoin())); + viewBinding.dianshuTv.setText("¥ "+AppUtils.getQian(walletBean.getGoldCoin())); } @Override diff --git a/app/src/main/java/com/hbl/lewan/wallet/WalletInfoFragment.java b/app/src/main/java/com/hbl/lewan/wallet/WalletInfoFragment.java index 0a4625d..b6a885a 100644 --- a/app/src/main/java/com/hbl/lewan/wallet/WalletInfoFragment.java +++ b/app/src/main/java/com/hbl/lewan/wallet/WalletInfoFragment.java @@ -880,7 +880,7 @@ public class WalletInfoFragment extends BaseFragment { if (status == 1) { name = DataUtils.get(getActivity(), "wallet_info_s_" + IMKitClient.account(), ""); } - binding.typeTv1.setVisibility(View.GONE); +// binding.typeTv1.setVisibility(View.GONE); if (TextUtils.isEmpty(name)) { binding.refreshLayout.autoRefresh(); diff --git a/app/src/main/java/com/hbl/lewan/wallet/WalletInfoNewActivity.java b/app/src/main/java/com/hbl/lewan/wallet/WalletInfoNewActivity.java new file mode 100644 index 0000000..a0bfe29 --- /dev/null +++ b/app/src/main/java/com/hbl/lewan/wallet/WalletInfoNewActivity.java @@ -0,0 +1,186 @@ +package com.hbl.lewan.wallet; + +import android.content.Intent; +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.view.View; + +import androidx.annotation.Nullable; +import androidx.core.content.ContextCompat; +import androidx.core.graphics.drawable.DrawableCompat; + +import com.hbl.lewan.R; +import com.hbl.lewan.databinding.ActivityWalletInfoNew1Binding; +import com.hbl.lewan.databinding.ActivityWalletInfoNewBinding; +import com.hbl.lewan.dialog.ActionConfirmDialog; +import com.hbl.lewan.main.mine.ChangeAccoutActionActivity; +import com.hbl.lewan.model.BindBean; +import com.hbl.lewan.model.WalletBean; +import com.hbl.lewan.network.Api; +import com.hbl.lewan.network.BaseObserver; +import com.hbl.lewan.network.Result; +import com.hbl.lewan.pay.LipinDuiHuanActivity; +import com.hbl.lewan.utils.AnimUtil; +import com.hbl.lewan.utils.AppUtils; +import com.hbl.lewan.utils.GsonUtils; +import com.hbl.lewan.utils.LogUtils; +import com.netease.yunxin.kit.common.ui.activities.BaseActivity; +import com.netease.yunxin.kit.corekit.im.IMKitClient; + +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.schedulers.Schedulers; + +public class WalletInfoNewActivity extends BaseActivity { + boolean isG; + ActivityWalletInfoNew1Binding viewBinding; + WalletBean walletBean; + BindBean bindBean; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + + + super.onCreate(savedInstanceState); + viewBinding = ActivityWalletInfoNew1Binding.inflate(getLayoutInflater()); + setContentView(viewBinding.getRoot()); + isG = getIntent().getBooleanExtra("isG", true); + initView(); + getWallet(); + bindInfo(); + } + + + private void bindInfo() { + Api.getInstance().bindInfo(IMKitClient.account()) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new BaseObserver>() { + @Override + public void onSuccess(Result feedbackResp) { + bindBean = feedbackResp.data; + LogUtils.i("获取到的数据:" + GsonUtils.beanToJSONString(bindBean)); + } + + @Override + public void onError(int code, String msg) { + LogUtils.i("获取到的错误:" + code + "" + msg); + } + }); + + } + + protected void initView() { + viewBinding.contactListActivityTitleBar.getBackImageView().setOnClickListener(v -> finish()); + if(isG){ + getWindow().setStatusBarColor(getResources().getColor(R.color.white)); + getWindow().setNavigationBarColor(getResources().getColor(R.color.white)); + +// viewBinding.contactListActivityTitleBar.getTitleTextView().setText(getString(R.string.wodejinbi_txt)); + viewBinding.contactListActivityTitleBar.setBackgroundColor(getResources().getColor(R.color.white)); + getSupportFragmentManager().beginTransaction() + .replace(R.id.frameLayout, WalletInfoFragment.newInstance(0,getIntent().getIntExtra("type",-1),null)) + .commit(); + viewBinding.bigBg.setBackgroundResource(R.color.white); + viewBinding.contactListActivityTitleBar.getTitleTextView().setTextColor(getColor(R.color.black)); + getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); + }else{ + getWindow().setStatusBarColor(getResources().getColor(R.color.white)); + getWindow().setNavigationBarColor(getResources().getColor(R.color.white)); + viewBinding.contactListActivityTitleBar.setBackgroundColor(getResources().getColor(R.color.white)); + + +// viewBinding.contactListActivityTitleBar.getTitleTextView().setText(getString(R.string.wodeyinbi_txt)); + getSupportFragmentManager().beginTransaction() + .replace(R.id.frameLayout, WalletInfoFragment.newInstance(1,getIntent().getIntExtra("type",-1),null)) + .commit(); + viewBinding.bigBg.setBackgroundResource(R.color.white); + viewBinding.contactListActivityTitleBar.getTitleTextView().setTextColor(getColor(R.color.black)); + getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); + + } + } + + + private void showDialogPay() { + + com.netease.yunxin.kit.chatkit.ui.dialog.ActionConfirmDialog actionDialog = new com.netease.yunxin.kit.chatkit.ui.dialog.ActionConfirmDialog(WalletInfoNewActivity.this, + getString(com.netease.yunxin.kit.chatkit.ui.R.string.bind_phone_des_txt1), getString(com.netease.yunxin.kit.chatkit.ui.R.string.cancel_txt), getString(com.netease.yunxin.kit.chatkit.ui.R.string.to_sett_txt)); + actionDialog.setOnToActionListener(new com.netease.yunxin.kit.chatkit.ui.dialog.ActionConfirmDialog.OnToActionListener() { + @Override + public void toSumbit() { +// Intent intent = new Intent(getActivity(), ChangeAccoutActionActivity.class); +// intent.putExtra("type", 5); +// startActivity(intent); + Intent intent = new Intent(WalletInfoNewActivity.this, SetPayPasswordActivity.class); + startActivity(intent); + } + + @Override + public void toCancel() { + + } + }); + actionDialog.show(); + } + + + private void showDialog() { + + ActionConfirmDialog actionDialog = new ActionConfirmDialog(WalletInfoNewActivity.this, + getString(R.string.bind_phone_des_txt), getString(R.string.nobind_txt), getString(R.string.tobind_txt)); + actionDialog.setOnToActionListener(new ActionConfirmDialog.OnToActionListener() { + @Override + public void toSumbit() { + Intent intent = new Intent(WalletInfoNewActivity.this, ChangeAccoutActionActivity.class); + intent.putExtra("type", ChangeAccoutActionActivity.TYPE_BIND_PHONE); + startActivity(intent); + } + + @Override + public void toCancel() { + + } + }); + actionDialog.show(); + } + + private void getWallet() { + Api.getInstance().walletInfo(IMKitClient.account()) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new BaseObserver>() { + + @Override + public void onSuccess(Result feedbackResp) { + walletBean = feedbackResp.data; + changeInfo(); + + } + + @Override + public void onError(int code, String msg) { + + } + }); + + + } + + + private void changeInfo() { + if (walletBean != null) { + + + } + + } + @Override + protected void onStop() { + super.onStop(); + + } + + + + +} diff --git a/app/src/main/java/com/hbl/lewan/wallet/WalletInfoRedActivity.java b/app/src/main/java/com/hbl/lewan/wallet/WalletInfoRedActivity.java new file mode 100644 index 0000000..4caf9af --- /dev/null +++ b/app/src/main/java/com/hbl/lewan/wallet/WalletInfoRedActivity.java @@ -0,0 +1,269 @@ +package com.hbl.lewan.wallet; + +import android.content.Intent; +import android.os.Bundle; +import android.text.TextUtils; +import android.view.View; + +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.viewpager2.widget.ViewPager2; + +import com.hbl.lewan.R; +import com.hbl.lewan.adapter.CommunityAdapter; +import com.hbl.lewan.databinding.ActivityWalletInfoNew1Binding; +import com.hbl.lewan.databinding.ActivityWalletInfoRedBinding; +import com.hbl.lewan.dialog.ActionConfirmDialog; +import com.hbl.lewan.main.mine.ChangeAccoutActionActivity; +import com.hbl.lewan.model.BindBean; +import com.hbl.lewan.model.WalletBean; +import com.hbl.lewan.network.Api; +import com.hbl.lewan.network.BaseObserver; +import com.hbl.lewan.network.Result; +import com.hbl.lewan.utils.GsonUtils; +import com.hbl.lewan.utils.LogUtils; +import com.netease.yunxin.kit.common.ui.activities.BaseActivity; +import com.netease.yunxin.kit.common.ui.utils.AvatarColor; +import com.netease.yunxin.kit.common.ui.utils.ToastX; +import com.netease.yunxin.kit.corekit.im.IMKitClient; +import com.netease.yunxin.kit.corekit.im.model.UserInfo; +import com.netease.yunxin.kit.corekit.im.provider.FetchCallback; +import com.netease.yunxin.kit.corekit.im.repo.CommonRepo; + +import java.util.ArrayList; +import java.util.List; + +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.schedulers.Schedulers; + +public class WalletInfoRedActivity extends BaseActivity { + boolean isG; + ActivityWalletInfoRedBinding viewBinding; + WalletBean walletBean; + BindBean bindBean; + List listFragment = new ArrayList<>(); + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + + + super.onCreate(savedInstanceState); + viewBinding = ActivityWalletInfoRedBinding.inflate(getLayoutInflater()); + setContentView(viewBinding.getRoot()); + isG = getIntent().getBooleanExtra("isG", true); + initView(); + getWallet(); + bindInfo(); + + initRightChange(); + initViewPager(); + refrshUser(IMKitClient.account()); + } + + private void initViewPager() { + listFragment.clear(); + listFragment.add(WalletInfoRedFragment.newInstance(0,getIntent().getIntExtra("type",-1),null)); + listFragment.add(WalletInfoRedFragment.newInstance(1,getIntent().getIntExtra("type",-1),null)); + + CommunityAdapter adapter = new CommunityAdapter(WalletInfoRedActivity.this, listFragment); + viewBinding.viewpager.setAdapter(adapter); + viewBinding.viewpager.setOffscreenPageLimit(2); + // 注册页面变化回调 + viewBinding.viewpager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { + @Override + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + + } + + @Override + public void onPageSelected(int position) { + changeType(position); + } + + @Override + public void onPageScrollStateChanged(int state) { + + } + }); + + } + + public void refrshUser(String account) { + CommonRepo.getUserInfo( + account, + new FetchCallback() { + @Override + public void onSuccess(@Nullable UserInfo param) { + if (param != null) { + updateUI(param); + } + } + + @Override + public void onFailed(int code) { + ToastX.showShortToast(R.string.user_fail); + updateUI(new UserInfo(account, account, "")); + } + + @Override + public void onException(@Nullable Throwable exception) { + ToastX.showShortToast(R.string.user_fail); + updateUI(new UserInfo(account, account, "")); + } + }); + } + + private void updateUI(UserInfo userInfo) { + String name = + TextUtils.isEmpty(userInfo.getName()) ? userInfo.getAccount() : userInfo.getName(); + String avaterurl = userInfo.getAvatar(); + if (TextUtils.isEmpty(avaterurl)) { + viewBinding.avIndexfraHead.setData( + R.mipmap.default_head_img, name, AvatarColor.avatarColor(IMKitClient.account())); + } else { + viewBinding.avIndexfraHead.setData( + userInfo.getAvatar(), name, AvatarColor.avatarColor(IMKitClient.account())); + } + + viewBinding.userNameTv.setText(name); + } + + private void initRightChange() { + viewBinding.linelastTv.setOnClickListener(v -> { + viewBinding.viewpager.setCurrentItem(0); + changeType(0); + + }); + viewBinding.linecollectionTv.setOnClickListener(v -> { + viewBinding.viewpager.setCurrentItem(1); + changeType(1); + }); + } + + private void changeType(int i) { + switch (i) { + case 0: + viewBinding.linelastTv.setTextColor(getResources().getColor(R.color.black)); + viewBinding.linecollectionTv.setTextColor(getResources().getColor(R.color.color_7f7b81)); + viewBinding.linelastV.setVisibility(View.VISIBLE); + viewBinding.linecollectionV.setVisibility(View.INVISIBLE); + + break; + case 1: + viewBinding.linecollectionTv.setTextColor(getResources().getColor(R.color.black)); + viewBinding.linelastTv.setTextColor(getResources().getColor(R.color.color_7f7b81)); + viewBinding.linelastV.setVisibility(View.INVISIBLE); + viewBinding.linecollectionV.setVisibility(View.VISIBLE); + + break; + } + } + + private void bindInfo() { + Api.getInstance().bindInfo(IMKitClient.account()) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new BaseObserver>() { + @Override + public void onSuccess(Result feedbackResp) { + bindBean = feedbackResp.data; + LogUtils.i("获取到的数据:" + GsonUtils.beanToJSONString(bindBean)); + } + + @Override + public void onError(int code, String msg) { + LogUtils.i("获取到的错误:" + code + "" + msg); + } + }); + + } + + protected void initView() { + viewBinding.contactListActivityTitleBar.getBackImageView().setOnClickListener(v -> finish()); + + } + + + private void showDialogPay() { + + com.netease.yunxin.kit.chatkit.ui.dialog.ActionConfirmDialog actionDialog = new com.netease.yunxin.kit.chatkit.ui.dialog.ActionConfirmDialog(WalletInfoRedActivity.this, + getString(com.netease.yunxin.kit.chatkit.ui.R.string.bind_phone_des_txt1), getString(com.netease.yunxin.kit.chatkit.ui.R.string.cancel_txt), getString(com.netease.yunxin.kit.chatkit.ui.R.string.to_sett_txt)); + actionDialog.setOnToActionListener(new com.netease.yunxin.kit.chatkit.ui.dialog.ActionConfirmDialog.OnToActionListener() { + @Override + public void toSumbit() { +// Intent intent = new Intent(getActivity(), ChangeAccoutActionActivity.class); +// intent.putExtra("type", 5); +// startActivity(intent); + Intent intent = new Intent(WalletInfoRedActivity.this, SetPayPasswordActivity.class); + startActivity(intent); + } + + @Override + public void toCancel() { + + } + }); + actionDialog.show(); + } + + + private void showDialog() { + + ActionConfirmDialog actionDialog = new ActionConfirmDialog(WalletInfoRedActivity.this, + getString(R.string.bind_phone_des_txt), getString(R.string.nobind_txt), getString(R.string.tobind_txt)); + actionDialog.setOnToActionListener(new ActionConfirmDialog.OnToActionListener() { + @Override + public void toSumbit() { + Intent intent = new Intent(WalletInfoRedActivity.this, ChangeAccoutActionActivity.class); + intent.putExtra("type", ChangeAccoutActionActivity.TYPE_BIND_PHONE); + startActivity(intent); + } + + @Override + public void toCancel() { + + } + }); + actionDialog.show(); + } + + private void getWallet() { + Api.getInstance().walletInfo(IMKitClient.account()) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new BaseObserver>() { + + @Override + public void onSuccess(Result feedbackResp) { + walletBean = feedbackResp.data; + changeInfo(); + + } + + @Override + public void onError(int code, String msg) { + + } + }); + + + } + + + private void changeInfo() { + if (walletBean != null) { + + + } + + } + @Override + protected void onStop() { + super.onStop(); + + } + + + + +} diff --git a/app/src/main/java/com/hbl/lewan/wallet/WalletInfoRedFragment.java b/app/src/main/java/com/hbl/lewan/wallet/WalletInfoRedFragment.java new file mode 100644 index 0000000..7dae454 --- /dev/null +++ b/app/src/main/java/com/hbl/lewan/wallet/WalletInfoRedFragment.java @@ -0,0 +1,1046 @@ +package com.hbl.lewan.wallet; + +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; +import android.os.Bundle; +import android.text.TextUtils; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.WindowManager; +import android.widget.ImageView; +import android.widget.PopupWindow; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.core.text.HtmlCompat; +import androidx.recyclerview.widget.LinearLayoutManager; + +import com.hbl.lewan.IMApplication; +import com.hbl.lewan.IMUIKitConfig; +import com.hbl.lewan.R; +import com.hbl.lewan.adapter.CommonAdapter; +import com.hbl.lewan.adapter.ViewHolder; +import com.hbl.lewan.databinding.FragmentWalletInfoBinding; +import com.hbl.lewan.databinding.FragmentWalletInfoNewBinding; +import com.hbl.lewan.dialog.SelectTypeDialog; +import com.hbl.lewan.model.BillBean; +import com.hbl.lewan.model.ListBeanResult; +import com.hbl.lewan.model.StatisticsBean; +import com.hbl.lewan.model.TaskBean; +import com.hbl.lewan.model.TypeBean; +import com.hbl.lewan.model.WithdrawCashBean; +import com.hbl.lewan.network.Api; +import com.hbl.lewan.network.BaseObserver; +import com.hbl.lewan.network.Result; +import com.hbl.lewan.utils.AppUtils; +import com.hbl.lewan.utils.DataUtils; +import com.hbl.lewan.utils.GsonUtils; +import com.hbl.lewan.utils.LogUtils; +import com.netease.nimlib.sdk.NIMClient; +import com.netease.nimlib.sdk.team.TeamService; +import com.netease.nimlib.sdk.team.model.Team; +import com.netease.nimlib.sdk.uinfo.UserService; +import com.netease.nimlib.sdk.uinfo.model.NimUserInfo; +import com.netease.yunxin.kit.common.ui.fragments.BaseFragment; +import com.netease.yunxin.kit.common.ui.utils.TimeFormatUtils; +import com.netease.yunxin.kit.corekit.im.IMKitClient; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.schedulers.Schedulers; + +//import com.bigkoo.pickerview.builder.TimePickerBuilder; +//import com.bigkoo.pickerview.view.TimePickerView; + +/** + * 主页模块 + * + * @author + */ +public class WalletInfoRedFragment extends BaseFragment { + int status; + + int pageSize = 1; + // private TimePickerView pvTime; + String time = "2022-06"; + int type = -1; + String typeInfo = ""; + String billBean = null; + CommonAdapter commonAdapter; + private ArrayList titles = new ArrayList<>(); + List taskBeans = null; + int loc = 0; + FragmentWalletInfoNewBinding binding; + + public static WalletInfoRedFragment newInstance(int status1, int type, String billBean) { + Bundle bundle = new Bundle(); + bundle.putInt("type", status1); + bundle.putInt("type1", type); + bundle.putString("bean", billBean); + WalletInfoRedFragment view = new WalletInfoRedFragment(); + view.setArguments(bundle); + return view; + } + + + @Nullable + @Override + public View onCreateView( + @NonNull LayoutInflater inflater, + @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { + binding = FragmentWalletInfoNewBinding.inflate(inflater); + return binding.getRoot(); + } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + initViews(); + } + + + protected void initViews() { + this.status = getArguments().getInt("type"); + type = getArguments().getInt("type1"); + billBean = getArguments().getString("bean"); + + if (billBean != null) { + taskBeans = GsonUtils.getListFromJSON(billBean, TaskBean.class); + } + Calendar selectedDate = Calendar.getInstance();//系统当前时间 + time = selectedDate.get(Calendar.YEAR) + "-" + ((selectedDate.get(Calendar.MONTH) + 1) < 10 ? "0" + (selectedDate.get(Calendar.MONTH) + 1) : (selectedDate.get(Calendar.MONTH) + 1)); + + + loc = DataUtils.get(IMApplication.getInstance(), "locale", 1); + + + initList(); + initRefreshLayout(); + + + } + + private void getStatistics() { + Map map = new HashMap<>(); + if (status == 0) { + map.put("coinType", 0); + } else { + map.put("coinType", 1); + + } + if (TextUtils.isEmpty(typeInfo)) { + + } else { + String statTime = time + "-01 00:00:01"; + String endTime = time + "-" + getMonth(time) + " 23:59:59"; + map.put("timeGe", statTime); + map.put("timeLe", endTime); + } + if (!TextUtils.isEmpty(IMUIKitConfig.SUBSTATIONID)) { + map.put("substationId", IMUIKitConfig.SUBSTATIONID); + } + Api.getInstance().statistics(IMKitClient.account(), map) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new BaseObserver>() { + @Override + public void onSuccess(Result feedbackResp) { + if (feedbackResp.data != null) { +// outTv.setText(String.format("%.2f", Math.abs(feedbackResp.data.getOutgoing()) / 100f)); +// incomeTv.setText(String.format("%.2f", feedbackResp.data.getIncoming() / 100f)); + } + } + + @Override + public void onError(int code, String msg) { + + } + }); + + } + + +// private void initCustomTimePicker() { +// /** +// * @description +// * +// * 注意事项: +// * 1.自定义布局中,id为 optionspicker 或者 timepicker 的布局以及其子控件必须要有,否则会报空指针. +// * 具体可参考demo 里面的两个自定义layout布局。 +// * 2.因为系统Calendar的月份是从0-11的,所以如果是调用Calendar的set方法来设置时间,月份的范围也要是从0-11 +// * setRangDate方法控制起始终止时间(如果不设置范围,则使用默认时间1900-2100年,此段代码可注释) +// */ +// Calendar selectedDate = Calendar.getInstance();//系统当前时间 +// Calendar startDate = Calendar.getInstance(); +// startDate.set(2023, 3, 1); +// Calendar endDate = Calendar.getInstance(); +//// endDate.set(selectedDate.get(Calendar.YEAR), selectedDate.get(Calendar.MONTH) , 28); +// //时间选择器 ,自定义布局 +// pvTime = new TimePickerBuilder(getActivity(), (date, v) -> {//选中事件回调 +// binding.dateTv.setText(getTime(date)); +// time = getTime(date); +// typeInfo = time; +// refreshLayout.autoRefresh(); +// getStatistics(); +// +// }).setBgColor(getResources().getColor(R.color.white)) +// .setContentTextSize(18) +// .setTextColorCenter(getResources().getColor(R.color.black)) +// .setTextColorOut(getResources().getColor(R.color.common_list_hint_text)) +// .setDividerColor(getResources().getColor(R.color.color_f7f7fc)) +// .setRangDate(startDate, endDate) +// .setDate(selectedDate) +// .setLayoutRes(R.layout.pickerview_time, v -> { +// final TextView tvSubmit = (TextView) v.findViewById(R.id.btnSubmit); +// tvSubmit.setTextColor(getResources().getColor(R.color.colorAccent)); +// TextView ivCancel = (TextView) v.findViewById(R.id.btnCancel); +// ivCancel.setTextColor(getResources().getColor(R.color.colorAccent)); +// +// ivCancel.setText(getString(R.string.all_time_txt)); +// tvSubmit.setOnClickListener(v12 -> { +// pvTime.returnData(); +// pvTime.dismiss(); +// }); +// ivCancel.setOnClickListener(v1 -> { +// typeInfo = ""; +// dateTv.setText(getString(R.string.all_time_txt)); +// pvTime.dismiss(); +// refreshLayout.autoRefresh(); +// getStatistics(); +// +// }); +// }) +// .setType(new boolean[]{true, true, false, false, false, false}) +// .setLabel(getString(R.string.time_year_txt), getString(R.string.time_month_txt), getString(R.string.time_day_txt), +// getString(R.string.time_shi_txt), getString(R.string.time_fen_txt), getString(R.string.time_miao_txt)) +// .setLineSpacingMultiplier(1.6f) +// .setTextXOffset(0, 0, 0, 40, 0, -40) +// .isCenterLabel(false) //是否只显示中间选中项的label文字,false则每项item全部都带有label。 +// .setDividerColor(0x00000000) +// .build(); +// } + + + private String getTime(Date date) {//可根据需要自行截取数据显示 + Log.d("getTime()", "choice date millis: " + date.getTime()); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM"); + return format.format(date); + } + + + private void initList() { + LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity()); + binding.recyclerview.setLayoutManager(linearLayoutManager); + commonAdapter = new CommonAdapter(getContext(), R.layout.item_bill_list, titles) { + @Override + public void convert(ViewHolder holder, BillBean s, int index) { + boolean isShowRate; +// holder.setText(R.id.price_tv, AppUtils.getQian(s.getAmount()) + (status == 0 ? getString(R.string.species_txt) : +// getString(R.string.silver_coins_txt))); + TextView textView = holder.getView(R.id.price_tv); + textView.setText(AppUtils.getQian(s.getAmount())); + RelativeLayout layoutroot = holder.getView(R.id.big_bg); + if (s.getAmount() < 0) { + textView.setTextColor(getResources().getColor(R.color.black)); + } else { + textView.setTextColor(getResources().getColor(R.color.black)); + } + if (s.getTransferMoneyRecord() != null && s.getTransferMoneyRecord().getFeeAmount() > 0 && s.getAmount()<0) { + isShowRate = true; + textView.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.mipmap.ic_transfer_tips), null, null, null); + } else { + isShowRate = false; + textView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); + } + TextView statusTv = holder.getView(R.id.status_tv); + statusTv.setVisibility(View.GONE); + if (status == 0) { + if (s.getType() == 5) { + if (s.getWithdrawCashRecord() != null) { + statusTv.setVisibility(View.VISIBLE); + statusTv.setText(getStatusTxt(s.getWithdrawCashRecord())); + } + } + } + holder.setText(R.id.balan_tv, getString(R.string.yuee_2f_txt1) + AppUtils.getQian(s.getBalance())); +// holder.setText(R.id.title_tv,getUserInfo(s)+getTypeString(s.getType())); + holder.setText(R.id.title_tv, getTypeNoteString(s)); + + holder.setText(R.id.time_tv, s.getCreateTime()); + if (!TextUtils.isEmpty(s.getCreateTimestamp())) { + holder.setText(R.id.time_tv, TimeFormatUtils.formatMillisecond(getActivity(), Long.parseLong(s.getCreateTimestamp()))); + + } + layoutroot.setOnClickListener(v -> { + //弹窗 + if (isShowRate) { + showPopWindow(textView, s.getTransferMoneyRecord().getFeeAmount(), s.getTransferMoneyRecord().getCoinType()); + } + }); + ((ImageView) holder.getView(R.id.logo_iv)).setImageResource(getTypeRes(s)); + + } + }; + binding.recyclerview.setAdapter(commonAdapter); + } + + private void showPopWindow(TextView itemView, long feeamount, int type) { + View popView = LayoutInflater.from(getContext()).inflate(R.layout.layout_popwindow_feerate, null); + PopupWindow popupWindow = new PopupWindow(popView, + ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.WRAP_CONTENT, + true); + TextView tvValue = popView.findViewById(R.id.tv_transfer_txt); + ImageView ivTop = popView.findViewById(R.id.iv_poptop); + if (type == 0) { + tvValue.setText(HtmlCompat.fromHtml(String.format(getString(R.string.shouxufeitips_jinbi_txt), feeamount / 100), HtmlCompat.FROM_HTML_MODE_LEGACY)); + } else { + tvValue.setText(HtmlCompat.fromHtml(String.format(getString(R.string.shouxufeitips_yinbi_txt), feeamount / 100), HtmlCompat.FROM_HTML_MODE_LEGACY)); + } + RelativeLayout.LayoutParams paramsiv = (RelativeLayout.LayoutParams) ivTop.getLayoutParams(); + paramsiv.setMargins(0, 0, itemView.getWidth(), 0); + ivTop.setLayoutParams(paramsiv); + // 设置背景来实现阴影效果 + popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + // 设置阴影的透明度 + WindowManager.LayoutParams layoutParams = getActivity().getWindow().getAttributes(); + layoutParams.alpha = 0.7f; // 设置背景透明度(0.0到1.0,1.0是完全不透明) + getActivity().getWindow().setAttributes(layoutParams); + +// 添加弹窗关闭时恢复透明度的监听器 + popupWindow.setOnDismissListener(() -> { + WindowManager.LayoutParams params = getActivity().getWindow().getAttributes(); + params.alpha = 1.0f; // 恢复为不透明 + getActivity().getWindow().setAttributes(params); + }); + popupWindow.setOutsideTouchable(true); + popupWindow.showAsDropDown(itemView, 0, 0); + + } + + private String getStatusTxt(WithdrawCashBean withdrawCashRecord) { + //0 未处理,1 客服审核通过,2 已打款,3 拒绝 + switch (withdrawCashRecord.getStatus()) { + case 0: + return getString(R.string.weichuli_txt); + case 1: + return getString(R.string.kefushenhetongguo_txt); + case 2: + return getString(R.string.yidakuan_txt); + case 3: + return getString(R.string.yijujue_txt); + default: + return ""; + } + } + + //赠送给商家 type 31 + private String getAmount(BillBean s, long amount) { + return status == 1 && s.getType() == 31 ? String.valueOf(amount) : AppUtils.getQian(amount); + } + + private String getTypeNoteString(BillBean s) { + //0 群红包,1 私聊红包,2 赠送,3 金币银币互转 + + if (status == 1) { + if (s.getType() == 1) { + + if (s.getIsTimeout() == 1) { + return getString(R.string.yinbi_tuikuan_txt); + } else { + if (s.getAmount() > 0) { + String name = "红包"; +// RosterElementEntity friendInfo = MyApplication.getInstance2().getIMClientManager().getFriendsListProvider().getFriendInfoByUid2(s.getFromUserId() + ""); + NimUserInfo friendInfo = NIMClient.getService(UserService.class).getUserInfo(s.getFromUserId() + ""); + // ** 显示头像和昵称 + if (friendInfo != null) { + name = getString(R.string.yinbihongbao_laizi_txt) + friendInfo.getName(); + } else { + name = getString(R.string.yinbihongbao_laizi_txt) + s.getFromUserId(); + } + return name; + } else { + String name = "红包"; +// RosterElementEntity friendInfo = MyApplication.getInstance2().getIMClientManager().getFriendsListProvider().getFriendInfoByUid2(s.getToUserId() + ""); + NimUserInfo friendInfo = NIMClient.getService(UserService.class).getUserInfo(s.getToUserId() + ""); + + // ** 显示头像和昵称 + if (friendInfo != null) { + name = getString(R.string.yinbihonbao_wofagei_txt) + friendInfo.getName(); + } else { + name = getString(R.string.yinbihonbao_wofagei_txt) + s.getToUserId(); + + } + return name; + } + } + } else if (s.getType() == 2) { + + + if (s.getAmount() > 0) { + if ((s.getFromUserId() + "").equals(IMKitClient.account())) { + return getString(R.string.yinbizhuanzhang_tuikuan_txt); + } + + String name = "赠送"; +// RosterElementEntity friendInfo = MyApplication.getInstance2().getIMClientManager().getFriendsListProvider().getFriendInfoByUid2(s.getFromUserId() + ""); + NimUserInfo friendInfo = NIMClient.getService(UserService.class).getUserInfo(s.getFromUserId() + ""); + + // ** 显示头像和昵称 + if (friendInfo != null) { + name = getString(R.string.yinbizhuanzhang_laizi_txt) + friendInfo.getName(); + } else { + name = getString(R.string.yinbizhuanzhang_laizi_txt) + s.getFromUserId(); + } + return name; + } else { + String name = "红利积分赠送"; + NimUserInfo friendInfo = NIMClient.getService(UserService.class).getUserInfo(s.getToUserId() + ""); + // ** 显示头像和昵称 + if (friendInfo != null) { + name = getString(R.string.yinbizhuanzhang_wofagei_txt) + friendInfo.getName(); + } else { + name = getString(R.string.yinbizhuanzhang_wofagei_txt) + s.getToUserId(); + + } + return name; + } + + } else if (s.getType() == 0) { + if (s.getIsTimeout() != null && s.getIsTimeout() == 1) { + if ((s.getFromUserId() + "").equals(IMKitClient.account())) { + return getString(R.string.yinbiqunhongbao_tuikuan_txt); + } + return getString(R.string.yinbiqunhongbao_txt); + } else { + if (!TextUtils.isEmpty(s.getToGroupId())) { + String name = getString(R.string.yinbiqunhongbao_txt); +// GroupEntity groupEntity = MyApplication.getInstance2().getIMClientManager().getGroupsProvider().getGroupInfoByGid(s.getToGroupId()); + Team groupEntity = NIMClient.getService(TeamService.class).queryTeamBlock(s.getToGroupId() + ""); + if (groupEntity != null) { + name = getString(R.string.ybqhb_wfg_txt) + groupEntity.getName(); + } + return name; + } else { + String name = "群红包"; +// RosterElementEntity friendInfo = MyApplication.getInstance2().getIMClientManager().getFriendsListProvider().getFriendInfoByUid2(s.getFromUserId() + ""); + NimUserInfo friendInfo = NIMClient.getService(UserService.class).getUserInfo(s.getFromUserId() + ""); + + if (friendInfo != null) { + name = getString(R.string.yinbiqhb_laizi_txt) + friendInfo.getName(); + } else { + name = getString(R.string.yinbiqhb_laizi_txt) + s.getFromUserNickname(); + } + return name; + } + } + } else if (s.getType() == 3) { + return s.getAmount() < 0 ? getString(R.string.s_to_g_txt) : getString(R.string.g_to_s_txt); + } else if (s.getType() == 4) { + return getString(R.string.shenqi_topup_txt); + } else if (s.getType() == 5) { + return getString(R.string.shenqi_with_txt); + } else if (s.getType() == 6) { + if (s.getDailyTask() != null) { + switch (loc) { + case 1: + return s.getDailyTask().getTaskNameZhCn() + ""; + case 2: + return s.getDailyTask().getTaskNameEnUs() + ""; + case 3: + return s.getDailyTask().getTaskNameJaJp() + ""; + default: + return s.getDailyTask().getTaskNameZhTw() + ""; + } + + } else { + return getString(R.string.renwujiangli_txt); + } + } else if (s.getType() == 7) { + return getString(R.string.invcode_friend_txt); + } else if (s.getType() == 8) { + return getString(R.string.wawaji_txt); + } else if (s.getType() == 9) { + return getString(R.string.guanliyuanxiugai_txt); + } else if (s.getType() == 11 || s.getType() == 13 || s.getType() == 14) { + return s.getCoinModifyRemark() + ""; + } else if (s.getType() == 12) { + return getString(R.string.caipiaojiduijiang_txt); + } else if (s.getType() == 15) { + return getString(R.string.lipinqiangduihuan_txt); + } else if (s.getType() == 16) { + return getString(R.string.jfscxycj_txt); + } else if (s.getType() == 17) { + return getString(R.string.rgzslpjf_txt); + } else if (s.getType() == 18) { + return s.getCoinModifyRemark() + ""; + } else if (s.getType() == 19) { + return s.getCoinModifyRemark() + ""; + } else if (s.getType() == 20 || s.getType() == 23 || s.getType() == 24) { + return s.getCoinModifyRemark() + ""; + } else if (s.getType() == 22) { + return getString(R.string.lpgdh_txt) + s.getCoinModifyRemark() + ""; + } else if (s.getType() == 28) { + return getString(R.string.xywkcjf_txt); + } else { + return TextUtils.isEmpty(s.getCoinModifyRemark()) ? getString(R.string.weizhi_txt) : s.getCoinModifyRemark() + ""; + } + } else { + if (s.getType() == 1) { + + if (s.getIsTimeout() == 1) { + return getString(R.string.jinbihongbao_tuikuan_txt); + } else { + if (s.getAmount() > 0) { + String name = "红包"; +// RosterElementEntity friendInfo = MyApplication.getInstance2().getIMClientManager().getFriendsListProvider().getFriendInfoByUid2(s.getFromUserId() + ""); + NimUserInfo friendInfo = NIMClient.getService(UserService.class).getUserInfo(s.getFromUserId() + ""); + + // ** 显示头像和昵称 + if (friendInfo != null) { + name = getString(R.string.jinbihongbao_laizi_txt) + friendInfo.getName(); + } else { + name = getString(R.string.jinbihongbao_laizi_txt) + s.getFromUserId(); + } + return name; + } else { + String name = "红包"; +// RosterElementEntity friendInfo = MyApplication.getInstance2().getIMClientManager().getFriendsListProvider().getFriendInfoByUid2(s.getToUserId() + ""); + NimUserInfo friendInfo = NIMClient.getService(UserService.class).getUserInfo(s.getToUserId() + ""); + + // ** 显示头像和昵称 + if (friendInfo != null) { + name = getString(R.string.jinbihongbao_wfg_txt) + friendInfo.getName(); + } else { + name = getString(R.string.jinbihongbao_wfg_txt) + s.getToUserId(); + + } + return name; + } + } + } else if (s.getType() == 2) { + + + if (s.getAmount() > 0) { + if ((s.getFromUserId() + "").equals(IMKitClient.account())) { + return getString(R.string.jinbizhuanzhang_tk_txt); + } + + String name = "赠送"; +// RosterElementEntity friendInfo = MyApplication.getInstance2().getIMClientManager().getFriendsListProvider().getFriendInfoByUid2(s.getFromUserId() + ""); + NimUserInfo friendInfo = NIMClient.getService(UserService.class).getUserInfo(s.getFromUserId() + ""); + + // ** 显示头像和昵称 + if (friendInfo != null) { + name = getString(R.string.jinbizhuanzhang_laizi_txt) + friendInfo.getName(); + } else { + name = getString(R.string.jinbizhuanzhang_laizi_txt) + s.getFromUserId(); + } + return name; + } else { + String name = "赠送"; +// RosterElementEntity friendInfo = MyApplication.getInstance2().getIMClientManager().getFriendsListProvider().getFriendInfoByUid2(s.getToUserId() + ""); + NimUserInfo friendInfo = NIMClient.getService(UserService.class).getUserInfo(s.getToUserId() + ""); + + // ** 显示头像和昵称 + if (friendInfo != null) { + name = getString(R.string.jinbizhuanzhang_wofagei_txt) + friendInfo.getName(); + } else { + name = getString(R.string.jinbizhuanzhang_wofagei_txt) + s.getToUserId(); + + } + return name; + } + + } else if (s.getType() == 0) { + if (s.getIsTimeout() == 1) { + if ((s.getFromUserId() + "").equals(IMKitClient.account())) { + return getString(R.string.jinbiqunhongbao_tuikuan_txt); + } + return getString(R.string.jinbiqunhongbao_txt); + } else { + if (!TextUtils.isEmpty(s.getToGroupId())) { + String name = getString(R.string.jinbiqunhongbao_txt); +// GroupEntity groupEntity = MyApplication.getInstance2().getIMClientManager().getGroupsProvider().getGroupInfoByGid(s.getToGroupId()); + Team groupEntity = NIMClient.getService(TeamService.class).queryTeamBlock(s.getToGroupId() + ""); + + if (groupEntity != null) { + name = getString(R.string.jinbiqunhongbao_wfg_txt) + groupEntity.getName(); + } + return name; + } else { + String name = "群红包"; +// RosterElementEntity friendInfo = MyApplication.getInstance2().getIMClientManager().getFriendsListProvider().getFriendInfoByUid2(s.getFromUserId() + ""); + NimUserInfo friendInfo = NIMClient.getService(UserService.class).getUserInfo(s.getFromUserId() + ""); + + if (friendInfo != null) { + name = getString(R.string.jinbiqunhb_laizi_txt) + friendInfo.getName(); + } else { + name = getString(R.string.jinbiqunhb_laizi_txt) + s.getFromUserNickname(); + } + return name; + } + } + } else if (s.getType() == 3) { + return s.getAmount() < 0 ? getString(R.string.g_to_s_txt) : getString(R.string.s_to_g_txt); + } else if (s.getType() == 4) { + return getString(R.string.jinbichongzhi_f_bank_txt); + } else if (s.getType() == 21) { + return getString(R.string.jinbichongzhi_f_bank_txt1); + } else if (s.getType() == 22) { + return s.getCoinModifyRemark() + ""; + } else if (s.getType() == 5) { + return getString(R.string.jinbitixian_txt); + } else if (s.getType() == 8) { + if (s.getOauthApp() != null) { + return s.getOauthApp().getAppName() + getString(R.string.zhuanchu_txt); + } else { + return getString(R.string.fffcz_txt); + } + } else if (s.getType() == 9) { + if (s.getOauthApp() != null) { + return s.getOauthApp().getAppName() + getString(R.string.zhuanru_txt); + } else { + return getString(R.string.ffftx_txt); + } + } else if (s.getType() == 7) { + if (s.getOauthApp() != null) { + return getString(R.string.laxinsjf_txt); + } else { + return getString(R.string.fffcz_txt); + } + } else if (s.getType() == 10) { + return getString(R.string.wawaji_txt); + } else if (s.getType() == 12) { + return getString(R.string.guanliyuanxiugai_txt); + } else if (s.getType() == 13) { + return getString(R.string.niuniuxiazhudongjie_txt); + } else if (s.getType() == 14) { + return getString(R.string.niuniujiesuan_txt); + } else if (s.getType() == 15) { + return getString(R.string.niuniulingbaofei_txt); + } else if (s.getType() == 16) { + if (s.getAmount() > 0) { + return getString(R.string.erweimashouklaizi_txt1) + s.getFromUserNickname(); + } else { + NimUserInfo nimUserInfo = NIMClient.getService(UserService.class).getUserInfo(s.getToUserId() + ""); + if (nimUserInfo != null) { + return getString(R.string.saomafukuan_txt2) + nimUserInfo.getName(); + } else { + return getString(R.string.saomafukuan_txt1); + } + } + } else if (s.getType() == 18) { + return getString(R.string.erweimashouklaizi_txt1) + s.getFromUserNickname(); + } else if (s.getType() == 19) { + return getString(R.string.saomaduibi_txt); + } else if (s.getType() == 20) { + return getString(R.string.jinbiduihuanlebi_txt); + } else if (s.getType() == 17) { + NimUserInfo nimUserInfo = NIMClient.getService(UserService.class).getUserInfo(s.getToUserId() + ""); + if (nimUserInfo != null) { + return getString(R.string.saomafukuan_txt2) + nimUserInfo.getName(); + } else { + return getString(R.string.saomafukuan_txt1); + } + } else if (s.getType() == 11) { + if (s.getAmount() > 0) { + return "Dream Game " + getString(R.string.zhuanru_txt); + } else { + return "Dream Game " + getString(R.string.zhuanchu_txt); + + } + } else if (s.getType() == 27) { + return getString(R.string.danzhujiduizhu_txt); + } else if (s.getType() == 23 || s.getType() == 24) { + return s.getCoinModifyRemark() + ""; + } else { + return TextUtils.isEmpty(s.getCoinModifyRemark()) ? getString(R.string.weizhi_txt) : s.getCoinModifyRemark() + ""; + } + } + } + + private int getTypeRes(BillBean bean) { + int type = bean.getType(); + switch (type) { + case 0: + return R.mipmap.bill_hongbao_img; + case 1: + return R.mipmap.bill_hongbao_img; + case 2: + return R.mipmap.bill_zhuanzhang_img; + case 3: + return R.mipmap.bill_zhuanhan_img; + case 4: + return R.mipmap.bill_chongzhi_img; + case 21: + return R.mipmap.bill_chongzhi_img1; + case 22: + case 23: + if (status == 1) { + return R.mipmap.duihuan_bill_img; + } else { + return R.mipmap.bill_chongzhi_img; + } + case 24: + if (status == 1) { + return R.mipmap.duihuan_bill_img; + } else { + return R.mipmap.bill_chongzhi_img; + } + case 5: + return R.mipmap.bill_tixian_img; + case 6: + if (status == 1) { + if (bean.getDailyTask() != null) { + if (bean.getDailyTask().getTaskId() == 3) { + return R.mipmap.cir_task_img; + } else if (bean.getDailyTask().getTaskId() == 1) { + return R.mipmap.yaoqing_task_img; + } else { + return R.mipmap.game_task_img; + } + } + } else { + return R.mipmap.default_head_img; + } + case 7: + if (status == 1) { + return R.mipmap.yaoqing_task_img; + } else { + return R.mipmap.default_head_img; + } + case 8: + if (status == 1) { + return R.mipmap.wawaji_img; + } else { + return R.mipmap.bill_chongzhi_img; + } + case 9: + if (status == 1) { + return R.mipmap.guanli_xiugai_img; + } else { + return R.mipmap.bill_tixian_img; + } + case 10: + return R.mipmap.wawaji_img; + case 20: + if (status == 1) { + return R.mipmap.yinbi_type_20; + } else { + return R.mipmap.wawaji_img; + } + + case 12: + if (status == 1) { + return R.mipmap.bill_caipiaoji_duijiang_img; + } else { + return R.mipmap.guanli_xiugai_img; + } + case 11: + if (status == 1) { + + if (bean.getAmount() > 0) { + return R.mipmap.bill_chongzhi_img; + } else { + return R.mipmap.yinbishangcheng_bill_img; + } + } else { + return R.mipmap.bill_tixian_img; + } + case 13: + if (status == 1) { + return R.mipmap.duihuan_bill_img; + } else { + return R.mipmap.niuniu_jilu_img; + + } + case 14: + if (status == 1) { + return R.mipmap.jfcj; + } else { + return R.mipmap.niuniu_jilu_img; + } + case 15: + if (status == 1) { + return R.mipmap.duihuan_bill_img; + } else { + return R.mipmap.niuniu_jilu_img; + } + case 16: + if (status == 1) { + return R.mipmap.jfcj; + + } else { + if (bean.getAmount() > 0) { + return R.mipmap.erweishoukuan_bill_img; + } else { + return R.mipmap.erweifukuan_bill_img; + } + } + case 17: + if (status == 1) { + return R.mipmap.rzzs; + } else { + return R.mipmap.erweifukuan_bill_img; + } + case 18: + if (status == 1) { + return R.mipmap.mojiang_img; + } else { + return R.mipmap.erweishoukuan_bill_img; + } + case 19: + if (status == 1) { + return R.mipmap.duihuan_bill_img; + } else { + return R.mipmap.saomaduibi_img; + } + case 27: + return R.mipmap.type_g_27; + case 29: + if (status == 1) { + return R.mipmap.type_s_24; + + } else { + return R.mipmap.type_g_27; + + } + case 28: + if (status == 1) { + return R.mipmap.duihuan_bill_img; + } else { + return R.mipmap.erweifukuan_bill_img; + } + case 30: + return R.mipmap.type_s_24; + default: + return R.mipmap.guanli_xiugai_img; + } + } + + private void initRefreshLayout() { + binding.refreshLayout.setOnRefreshListener(refreshlayout -> { + pageSize = 1; + binding.refreshLayout.setVisibility(View.VISIBLE); + binding.nodateLy.setVisibility(View.GONE); + binding.refreshLayout.setEnableLoadMore(true); + getDateList(); + + }); + binding.refreshLayout.setOnLoadMoreListener(refreshLayout -> { + pageSize += 1; + getDateList(); + + }); + } + + @Override + public void onResume() { + super.onResume(); + String name = DataUtils.get(getActivity(), "wallet_info_" + IMKitClient.account(), ""); + if (status == 1) { + name = DataUtils.get(getActivity(), "wallet_info_s_" + IMKitClient.account(), ""); + } +// binding.typeTv1.setVisibility(View.GONE); + + if (TextUtils.isEmpty(name)) { + binding.refreshLayout.autoRefresh(); + } else { + titles = (ArrayList) GsonUtils.getListFromJSON(name, BillBean.class); + if (titles != null && titles.size() > 0) { + commonAdapter.setDates(titles); + getDateList(); + } else { + binding.refreshLayout.autoRefresh(); + } + } + } + + private void getDateList() { + + if (status == 0) { + Map map = new HashMap<>(); + if (type == -1) { + if (TextUtils.isEmpty(typeInfo)) { + map.put("page", pageSize); + } else { + String statTime = time + "-01 00:00:01"; + String endTime = time + "-" + getMonth(time) + " 23:59:59"; + map.put("page", pageSize); + map.put("timeGe", statTime); + map.put("timeLe", endTime); + } + } else { + if (TextUtils.isEmpty(typeInfo)) { + map.put("page", pageSize); + map.put("type", type); + + } else { + String statTime = time + "-01 00:00:01"; + String endTime = time + "-" + getMonth(time) + " 23:59:59"; + + map.put("page", pageSize); + map.put("timeGe", statTime); + map.put("timeLe", endTime); + map.put("type", type); + } + } + if (!TextUtils.isEmpty(IMUIKitConfig.SUBSTATIONID)) { + map.put("substationId", IMUIKitConfig.SUBSTATIONID); + } + Api.getInstance().goldDetails(IMKitClient.account(), map) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new BaseObserver>>() { + @Override + public void onSuccess(Result> feedbackResp) { + changeDate(feedbackResp.data); + } + + @Override + public void onError(int code, String msg) { + LogUtils.i("获取到的错误:" + code + "" + msg); + binding.refreshLayout.finishRefresh(); + binding.refreshLayout.finishLoadMore(); + changeView(false); + } + }); + + } else { + Map map = new HashMap<>(); + if (type == -1) { + if (TextUtils.isEmpty(typeInfo)) { + map.put("page", pageSize); + } else { + String statTime = time + "-01 00:00:01"; + String endTime = time + "-" + getMonth(time) + " 23:59:59"; + map.put("page", pageSize); + map.put("timeGe", statTime); + map.put("timeLe", endTime); + } + } else { + if (TextUtils.isEmpty(typeInfo)) { + map.put("page", pageSize); + map.put("type", type); + + } else { + String statTime = time + "-01 00:00:01"; + String endTime = time + "-" + getMonth(time) + " 23:59:59"; + + map.put("page", pageSize); + map.put("timeGe", statTime); + map.put("timeLe", endTime); + map.put("type", type); + } + } + if (!TextUtils.isEmpty(IMUIKitConfig.SUBSTATIONID)) { + map.put("substationId", IMUIKitConfig.SUBSTATIONID); + } + Api.getInstance().silverDetails(IMKitClient.account(), map) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new BaseObserver>>() { + @Override + public void onSuccess(Result> feedbackResp) { + changeDate(feedbackResp.data); + } + + @Override + public void onError(int code, String msg) { + LogUtils.i("获取到的错误:" + code + "" + msg); + binding.refreshLayout.finishRefresh(); + binding.refreshLayout.finishLoadMore(); + changeView(false); + } + }); + } + + + } + + + private String getMonth(String time) { + if (time.endsWith("01") || time.endsWith("03") || time.endsWith("05") || time.endsWith("07") || time.endsWith("08") || time.endsWith("10") || time.endsWith("12")) { + return "31"; + } else if (time.endsWith("02")) { + Calendar selectedDate = Calendar.getInstance();//系统当前时间 + int year = selectedDate.get(Calendar.YEAR); + if (year % 400 == 0) {// 判断能否被400整除 + return "29"; + } else if (year % 100 == 0) {// 判断能否被100整除 + return "28"; + } else if (year % 4 == 0) {// 判断能否被4整除 + return "29"; + } else { + return "28"; + } + + } else { + return "30"; + } + } + + + private void changeDate(ListBeanResult data) { + if (data.getList() != null) { + if (pageSize == 1) { + titles = (ArrayList) data.getList(); + + if (status == 0) { + if (type == -1) + DataUtils.set(getActivity(), "wallet_info_" + IMKitClient.account(), GsonUtils.beanToJSONString(titles)); + } else { + if (type == -1) + DataUtils.set(getActivity(), "wallet_info_s_" + IMKitClient.account(), GsonUtils.beanToJSONString(titles)); + } + commonAdapter.setDates(titles); + } else { + commonAdapter.addDates(data.getList()); + titles = (ArrayList) commonAdapter.getDates(); + } + + } + binding.refreshLayout.finishRefresh(); + binding.refreshLayout.finishLoadMore(); + if (titles.size() == data.getTotal()) { + binding.refreshLayout.finishLoadMoreWithNoMoreData(); + } + changeView(true); + } + + private void changeView(boolean isNodate) { + if (titles == null || (titles.size() == 0)) { + binding.nodateLy.setVisibility(View.VISIBLE); + binding.refreshLayout.setVisibility(View.GONE); + if (isNodate) { + binding.nodateTv.setText(getString(R.string.nodate_txt)); + binding.nodateIv.setImageResource(R.mipmap.pyq_nodate); + } else { + binding.nodateTv.setText(getString(R.string.net_error_txt)); + binding.nodateIv.setImageResource(R.mipmap.pyq_nodate); + + } + + } else { + binding.refreshLayout.setVisibility(View.VISIBLE); + binding.nodateLy.setVisibility(View.GONE); + } + binding.nodateLy.setOnClickListener(view -> { + binding.refreshLayout.autoRefresh(); + }); + } + +} diff --git a/app/src/main/res/drawable/index_user_bg1_line.xml b/app/src/main/res/drawable/index_user_bg1_line.xml new file mode 100644 index 0000000..ebfc876 --- /dev/null +++ b/app/src/main/res/drawable/index_user_bg1_line.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 91e8b61..64c4d92 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -50,7 +50,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" - android:visibility="visible" + android:visibility="gone" android:onClick="tabClick"> + + + + + + + + + + + + + + + + + + + + + +