From a0a17a8bc87c8e9d4639aa02565183c2c368da98 Mon Sep 17 00:00:00 2001 From: Andrey Butenko Date: Thu, 14 Sep 2017 20:23:39 -0700 Subject: [PATCH] Fixed concurrent access crash --- .../java/ninja/andrey/lyriclink/MainActivity.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/ninja/andrey/lyriclink/MainActivity.java b/app/src/main/java/ninja/andrey/lyriclink/MainActivity.java index 3164961..68fe41c 100644 --- a/app/src/main/java/ninja/andrey/lyriclink/MainActivity.java +++ b/app/src/main/java/ninja/andrey/lyriclink/MainActivity.java @@ -181,8 +181,17 @@ public void onSearchUrlLoaded(String url) { userData.setLatestLyricLookupTime(System.currentTimeMillis()); dismissLoadingDialog(); - Search.removeListener(MainActivity.this); Intent intent = Search.getLyricIntent(url); startActivity(intent); + + Timer timer = new Timer(); + TimerTask timerTask = new TimerTask() { + @Override + public void run() { + Search.removeListener(MainActivity.this); + } + }; + + timer.schedule(timerTask, TIMER_RATE); } }