Created
March 30, 2017 08:03
-
-
Save enq3/19d29251afd43b11193b8d85403f77eb to your computer and use it in GitHub Desktop.
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
public class Test { | |
private Timer timer; | |
private LoadTimerTask task; | |
//выполняется после ввода нового символа в поиске | |
void onSearch(String text) { | |
//отменяем предыдущую задачу таймера | |
if (timer != null) { | |
timer.cancel(); | |
} | |
timer = new Timer(); | |
task = new LoadTimerTask(text); | |
//запуститься через 1000мс, если не введен еще символ | |
timer.schedule(task, 1000); | |
} | |
} | |
class LoadTimerTask extends TimerTask { | |
private String searchText; | |
public LoadTimerTask(String text) { | |
searchText = text; | |
} | |
@Override | |
public void run() { | |
//поиск searchText | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment