-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
95495e8
commit 51d65ed
Showing
4 changed files
with
127 additions
and
14 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
12 changes: 12 additions & 0 deletions
12
click-debounce-gradle-plugin/src/main/groovy/com/smartdengg/plugin/DebounceExtension.groovy
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,12 @@ | ||
package com.smartdengg.plugin | ||
|
||
/** | ||
* 创建时间: 2019/06/03 12:13 <br> | ||
* 作者: SmartDengg <br> | ||
* 描述: | ||
* */ | ||
class DebounceExtension { | ||
static final String NAME = "debounce" | ||
boolean loggable | ||
Map<String, List<String>> exclusion = [:] | ||
} |
40 changes: 40 additions & 0 deletions
40
click-debounce-gradle-plugin/src/main/groovy/com/smartdengg/plugin/ForkJoinExecutor.groovy
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,40 @@ | ||
package com.smartdengg.plugin | ||
|
||
import com.google.common.base.Preconditions | ||
import com.google.common.collect.Sets | ||
|
||
import java.util.concurrent.ForkJoinPool | ||
import java.util.concurrent.ForkJoinTask | ||
|
||
/** | ||
* 创建时间: 2019/06/04 18:43 <br> | ||
* 作者: SmartDengg <br> | ||
* 描述: */ | ||
@Singleton | ||
class ForkJoinExecutor { | ||
|
||
ForkJoinPool forkJoinPool = new ForkJoinPool() | ||
private final Set<ForkJoinTask<?>> futureSet = Sets.newConcurrentHashSet() | ||
|
||
void execute(Closure task) { | ||
ForkJoinTask<?> submitted = forkJoinPool.submit(new Runnable() { | ||
@Override | ||
void run() { | ||
task.call() | ||
} | ||
}) | ||
boolean added = futureSet.add(submitted) | ||
Preconditions.checkState(added, "Failed to add task") | ||
} | ||
|
||
void waitingForAllTasks() { | ||
try { | ||
for (Iterator iterator = futureSet.iterator(); iterator.hasNext();) { | ||
ForkJoinTask<?> task = iterator.next() | ||
task.join() | ||
iterator.remove() | ||
} | ||
} finally { | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
click-debounce-sample/src/main/java/com/smartdengg/clickdebounce/ClickProxy.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,33 @@ | ||
package com.smartdengg.clickdebounce; | ||
|
||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.AdapterView; | ||
|
||
/** | ||
* 创建时间: 2019/06/03 11:58 <br> | ||
* 作者: SmartDengg <br> | ||
* 描述: | ||
*/ | ||
public class ClickProxy implements View.OnClickListener, AdapterView.OnItemClickListener { | ||
|
||
private static final String TAG = ClickProxy.class.getSimpleName(); | ||
private static volatile ClickProxy instance; | ||
|
||
static ClickProxy getInstance() { | ||
synchronized (ClickProxy.class) { | ||
if (instance == null) { | ||
instance = new ClickProxy(); | ||
} | ||
return instance; | ||
} | ||
} | ||
|
||
@Override public void onClick(View v) { | ||
Log.d(TAG, "onClick : " + this.getClass().getName()); | ||
} | ||
|
||
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | ||
Log.d(TAG, "onClick : " + this.getClass().getName()); | ||
} | ||
} |