-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎉Release 1.3,阅后即焚2.0(BETA),阅后即焚修复倒计时Emoji错误的问题,修复线程问题,调整ChatCore相关代码
- Loading branch information
1 parent
e1884c3
commit 0f82aa3
Showing
5 changed files
with
152 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rlink/nlchat/fun/ChatCore/EmojiClock.java → ...nlchat/fun/ChatCore/Emoji/EmojiClock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...in/java/com/haohanyh/linmengjia/nearlink/nlchat/fun/ChatCore/Emoji/EmojiTimerManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.haohanyh.linmengjia.nearlink.nlchat.fun.ChatCore.Emoji; | ||
|
||
import android.os.CountDownTimer; | ||
import android.widget.TextView; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class EmojiTimerManager { | ||
private Map<TextView, EmojiTimer> activeTimers = new HashMap<>(); | ||
|
||
public void startTimer(TextView textView, long durationInMillis) { | ||
// 停止当前正在textView上运行的计时器(如果有) | ||
if (activeTimers.containsKey(textView)) { | ||
activeTimers.get(textView).stopTimer(); | ||
} | ||
|
||
EmojiTimer timer = new EmojiTimer(textView, this); | ||
activeTimers.put(textView, timer); | ||
timer.startTimer(durationInMillis); | ||
} | ||
|
||
void removeTimer(EmojiTimer timer) { | ||
activeTimers.remove(timer.getTextView()); | ||
} | ||
|
||
public class EmojiTimer { | ||
private TextView textView; | ||
private CountDownTimer countDownTimer; | ||
private EmojiTimerManager manager; | ||
|
||
public EmojiTimer(TextView textView, EmojiTimerManager manager) { | ||
this.textView = textView; | ||
this.manager = manager; | ||
} | ||
|
||
public void startTimer(long durationInMillis) { | ||
countDownTimer = new CountDownTimer(durationInMillis, 1000) { | ||
@Override | ||
public void onTick(long millisUntilFinished) { | ||
updateTextView(millisUntilFinished); | ||
} | ||
|
||
@Override | ||
public void onFinish() { | ||
textView.setText(EmojiClock.getEmojiForMinute(0) + EmojiClock.getEmojiForSecond(0)); | ||
manager.removeTimer(EmojiTimer.this); // 自动从管理器中移除 | ||
} | ||
}; | ||
countDownTimer.start(); | ||
} | ||
|
||
public void stopTimer() { | ||
if (countDownTimer != null) { | ||
countDownTimer.cancel(); | ||
countDownTimer = null; | ||
} | ||
} | ||
|
||
private void updateTextView(long millisUntilFinished) { | ||
int totalSeconds = (int) (millisUntilFinished / 1000); | ||
int minutes = totalSeconds / 60; | ||
int seconds = totalSeconds % 60; | ||
|
||
String minuteEmoji = EmojiClock.getEmojiForMinute(minutes); | ||
String secondEmoji = EmojiClock.getEmojiForSecond(seconds); | ||
|
||
textView.setText(minuteEmoji + secondEmoji); | ||
} | ||
|
||
public TextView getTextView() { | ||
return textView; | ||
} | ||
} | ||
} |
46 changes: 0 additions & 46 deletions
46
app/src/main/java/com/haohanyh/linmengjia/nearlink/nlchat/fun/ChatCore/EmojiTimer.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters