refactor: enable social media links and improve visibility logic in MainActivity
- Re-enabled Facebook, Telegram, and WhatsApp click listeners to launch respective apps. - Updated visibility logic for notification items and other app links based on user IDs. - Cleaned up commented-out code and adjusted layout visibility in activity_main2.xml.
This commit is contained in:
@@ -139,15 +139,15 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
activityMain2Binding.backIv.setOnClickListener(view -> onBackPressed());
|
||||
activityMain2Binding.tvLink.setText(Html.fromHtml("MISS<font color = '#e76d92'>AV</font>"));
|
||||
// activityMain2Binding.ivFacebook.setOnClickListener(view -> {
|
||||
// toOtherApp(facebookUrl, "com.facebook.katana", 1);
|
||||
// });
|
||||
// activityMain2Binding.ivTel.setOnClickListener(view -> {
|
||||
// toOtherApp(telegramUrl, "org.telegram.messenger", 2);
|
||||
// });
|
||||
// activityMain2Binding.ivWhatsapp.setOnClickListener(view -> {
|
||||
// toOtherApp(whatsappUrl, "com.whatsapp", 3);
|
||||
// });
|
||||
activityMain2Binding.ivFacebook.setOnClickListener(view -> {
|
||||
toOtherApp(facebookUrl, "com.facebook.katana", 1);
|
||||
});
|
||||
activityMain2Binding.ivTel.setOnClickListener(view -> {
|
||||
toOtherApp(telegramUrl, "org.telegram.messenger", 2);
|
||||
});
|
||||
activityMain2Binding.ivWhatsapp.setOnClickListener(view -> {
|
||||
toOtherApp(whatsappUrl, "com.whatsapp", 3);
|
||||
});
|
||||
|
||||
activityMain2Binding.ivHome.setOnClickListener(view -> {
|
||||
activityMain2Binding.webview.loadUrl(url);
|
||||
@@ -562,22 +562,30 @@ public class MainActivity extends AppCompatActivity {
|
||||
.subscribe(new BaseObserver<>() {
|
||||
@Override
|
||||
public void onSuccess(Result<ResultDataInfo<MessageInfo>> o) {
|
||||
if (o.data != null && o.data.getTotal() > 0) {
|
||||
boolean blockedIds = userId == 112 || userId == 87 || userId == 91 || userId == 93
|
||||
|| userId == 92 || userId == 84 || userId == 120 || userId == 70
|
||||
|| userId == 143 || userId == 149;
|
||||
|
||||
if (blockedIds) {
|
||||
activityMain2Binding.btNotifyitem.setVisibility(View.INVISIBLE);
|
||||
activityMain2Binding.layoutOtherapp.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
|
||||
boolean hasMsgs = o.data != null && o.data.getTotal() > 0;
|
||||
if (hasMsgs) {
|
||||
if (userId == 217 || userId == 211) {
|
||||
activityMain2Binding.btOtherapp.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
activityMain2Binding.btOtherapp.setVisibility(View.INVISIBLE);
|
||||
activityMain2Binding.ivOtherApp.setImageResource(R.mipmap.ic_shousuo);
|
||||
|
||||
}
|
||||
|
||||
activityMain2Binding.btNotifyitem.setVisibility(View.GONE);
|
||||
if (userId == 112 || userId == 87 || userId == 91 || userId == 93
|
||||
|| userId == 92 || userId == 84 || userId == 120 || userId == 70 || userId == 143 || userId == 149) {
|
||||
activityMain2Binding.btNotifyitem.setVisibility(View.INVISIBLE);
|
||||
activityMain2Binding.layoutOtherapp.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
// 右侧信封(bt_notifyitem 在 layout_otherapp 内);217/211 默认把整块侧栏设为 GONE,需一并打开
|
||||
activityMain2Binding.btNotifyitem.setVisibility(View.VISIBLE);
|
||||
if (userId == 217 || userId == 211) {
|
||||
activityMain2Binding.layoutOtherapp.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -665,14 +673,14 @@ public class MainActivity extends AppCompatActivity {
|
||||
whatsappUrl = dataInfo.getWsUrl() == null ? "" : dataInfo.getWsUrl().trim();
|
||||
|
||||
//外链逻辑修改
|
||||
// if (!TextUtils.isEmpty(facebookUrl)) {
|
||||
// if (userId == 217 || userId == 211) {
|
||||
// activityMain2Binding.btOtherapp.setVisibility(View.VISIBLE);
|
||||
// } else {
|
||||
// activityMain2Binding.btOtherapp.setVisibility(View.INVISIBLE);
|
||||
// }
|
||||
// activityMain2Binding.ivFacebook.setVisibility(View.VISIBLE);
|
||||
// }
|
||||
if (!TextUtils.isEmpty(facebookUrl)) {
|
||||
if (userId == 217 || userId == 211) {
|
||||
activityMain2Binding.btOtherapp.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
activityMain2Binding.btOtherapp.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
activityMain2Binding.ivFacebook.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (!TextUtils.isEmpty(telegramUrl)) {
|
||||
if (userId == 217 || userId == 211) {
|
||||
activityMain2Binding.btOtherapp.setVisibility(View.VISIBLE);
|
||||
@@ -689,7 +697,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
if (userId == 143 || userId == 149) {
|
||||
activityMain2Binding.btOtherapp.setVisibility(View.INVISIBLE);
|
||||
// activityMain2Binding.ivFacebook.setVisibility(View.GONE);
|
||||
activityMain2Binding.ivFacebook.setVisibility(View.GONE);
|
||||
activityMain2Binding.ivTel.setVisibility(View.GONE);
|
||||
activityMain2Binding.ivWhatsapp.setVisibility(View.GONE);
|
||||
activityMain2Binding.layoutOtherapp.setVisibility(View.GONE);
|
||||
|
||||
@@ -249,7 +249,6 @@
|
||||
android:textStyle="bold" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<!--
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/iv_facebook"
|
||||
android:layout_width="50dp"
|
||||
@@ -265,7 +264,6 @@
|
||||
android:layout_height="50dp"
|
||||
android:src="@mipmap/ic_facebook" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
-->
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/iv_whatsapp"
|
||||
|
||||
Reference in New Issue
Block a user