1:修改小时榜
This commit is contained in:
@@ -17,6 +17,7 @@ import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.provider.Settings;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
@@ -111,6 +112,7 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
}
|
||||
|
||||
QXGiftDriftView qxGiftDriftView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -153,6 +155,10 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
|
||||
// 启动定时器
|
||||
// startTimer();
|
||||
|
||||
}
|
||||
|
||||
// 在Activity中
|
||||
@@ -208,6 +214,37 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
// 默认实现,子类可以覆盖
|
||||
}
|
||||
|
||||
//在类中添加以下成员变量
|
||||
private Handler timerHandler = new Handler();
|
||||
private Runnable timerRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// 调用你要执行的方法
|
||||
// executePeriodicTask();
|
||||
|
||||
// 每10秒执行一次
|
||||
timerHandler.postDelayed(this, 10000);
|
||||
}
|
||||
};
|
||||
|
||||
// 启动定时器的方法
|
||||
private void startTimer() {
|
||||
timerHandler.postDelayed(timerRunnable, 10000);
|
||||
}
|
||||
|
||||
// 你需要定期执行的方法
|
||||
private void executePeriodicTask() {
|
||||
// 在这里实现你的业务逻辑
|
||||
LogUtils.d("定时任务执行中...");
|
||||
List<HourlyBean> hourlyBeans = new ArrayList<>();
|
||||
HourlyBean hourlyBean = new HourlyBean();
|
||||
hourlyBean.setText("nihao");
|
||||
hourlyBean.setRank_number("1");
|
||||
hourlyBean.setRoom_name("夏末");
|
||||
hourlyBean.setRoom_id("1");
|
||||
hourlyBeans.add(hourlyBean);
|
||||
onMessageReceived(hourlyBeans);
|
||||
}
|
||||
|
||||
protected void loadNetworkBackground() {
|
||||
// 只有当已经有背景URL时才加载
|
||||
@@ -434,7 +471,7 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
processHourlyMessages();
|
||||
}
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
hourlyMessageQueue.clear();
|
||||
clearAllHourlyViews();
|
||||
}
|
||||
@@ -546,12 +583,14 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
ivAvatar.setImageResource(R.mipmap.hourl_top3);
|
||||
break;
|
||||
default:
|
||||
|
||||
tvName.setVisibility(View.GONE);
|
||||
ivAvatar.setVisibility(View.GONE);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 设置带颜色的文本
|
||||
// 设置带颜色的文本
|
||||
private void setColoredText(TextView textView, String prefix, String roomName, String suffix, int colorRes) {
|
||||
@@ -646,10 +685,10 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
mqttMessageQueue.addAll(mqttBean.getList());
|
||||
// if (!isMqttPlaying) {
|
||||
// isMqttPlaying = true;
|
||||
processNextMqttMessage();
|
||||
processNextMqttMessage();
|
||||
// }
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
mqttMessageQueue.clear();
|
||||
}
|
||||
}
|
||||
@@ -706,7 +745,6 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
// QXGiftDriftView.getInstance( this).addGiftModel(mqttBean);
|
||||
|
||||
|
||||
|
||||
try {
|
||||
// 清理之前的视图(如果存在)
|
||||
if (currentMqttView != null && currentMqttView.getParent() != null) {
|
||||
@@ -797,6 +835,7 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void resetAndStartMqttAnimation(View view, Runnable onAnimationEnd) {
|
||||
try {
|
||||
int screenWidth = getScreenWidth();
|
||||
@@ -813,7 +852,8 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
enterAnim.setDuration(1500);
|
||||
enterAnim.setAnimationListener(new Animation.AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {}
|
||||
public void onAnimationStart(Animation animation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
@@ -828,7 +868,8 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
exitAnim.setDuration(2000);
|
||||
exitAnim.setAnimationListener(new Animation.AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {}
|
||||
public void onAnimationStart(Animation animation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
@@ -850,19 +891,20 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {}
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
}
|
||||
});
|
||||
view.startAnimation(exitAnim);
|
||||
}, 3000); // 停留1秒
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {}
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
}
|
||||
});
|
||||
view.startAnimation(enterAnim);
|
||||
|
||||
|
||||
|
||||
// ObjectAnimator animator1 = ObjectAnimator.ofFloat(view, "translationX", view.getWidth(), 0f);
|
||||
// animator1.setDuration(1500);
|
||||
// animator1.setInterpolator(new DecelerateInterpolator(1f));
|
||||
@@ -895,7 +937,8 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
onAnimationEnd.run();
|
||||
}
|
||||
}
|
||||
// 添加获取屏幕宽度的方法
|
||||
|
||||
// 添加获取屏幕宽度的方法
|
||||
private int getScreenWidth() {
|
||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
if (getWindowManager() != null) {
|
||||
@@ -904,6 +947,7 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
}
|
||||
return getResources().getDisplayMetrics().widthPixels;
|
||||
}
|
||||
|
||||
private void resetAndStartXlhAnimation(View view, Runnable onAnimationEnd) {
|
||||
try {
|
||||
view.setTranslationX(view.getWidth());
|
||||
@@ -993,7 +1037,7 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
String id = event.getId().replace("g", "");
|
||||
Intent intent = new Intent(this, WebViewActivity.class);
|
||||
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/union/setGroup?id=" + SpUtil.getToken() + "&guildId=" + id);
|
||||
startActivity( intent);
|
||||
startActivity(intent);
|
||||
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/union/setGroup?id=" + SpUtil.getToken() + "&guildId=" + id).navigation();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user