This repository has been archived by the owner on Sep 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/list_double_click_back_to_top' into develop
- Loading branch information
Showing
6 changed files
with
82 additions
and
3 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
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
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
22 changes: 22 additions & 0 deletions
22
...ain/java/org/cnodejs/android/md/display/listener/DoubleClickBackToContentTopListener.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,22 @@ | ||
package org.cnodejs.android.md.display.listener; | ||
|
||
import android.support.annotation.NonNull; | ||
import android.view.View; | ||
|
||
import org.cnodejs.android.md.display.view.IBackToContentTopView; | ||
|
||
public class DoubleClickBackToContentTopListener extends OnDoubleClickListener { | ||
|
||
private final IBackToContentTopView backToContentTopView; | ||
|
||
public DoubleClickBackToContentTopListener(@NonNull IBackToContentTopView backToContentTopView) { | ||
super(300); | ||
this.backToContentTopView = backToContentTopView; | ||
} | ||
|
||
@Override | ||
public void onDoubleClick(View v) { | ||
backToContentTopView.backToContentTop(); | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
app/src/main/java/org/cnodejs/android/md/display/listener/OnDoubleClickListener.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,26 @@ | ||
package org.cnodejs.android.md.display.listener; | ||
|
||
import android.view.View; | ||
|
||
public abstract class OnDoubleClickListener implements View.OnClickListener { | ||
|
||
private final long delayTime; | ||
private long lastClickTime = 0; | ||
|
||
public OnDoubleClickListener(long delayTime) { | ||
this.delayTime = delayTime; | ||
} | ||
|
||
@Override | ||
public final void onClick(View v) { | ||
long nowClickTime = System.currentTimeMillis(); | ||
if (nowClickTime - lastClickTime > delayTime) { | ||
lastClickTime = nowClickTime; | ||
} else { | ||
onDoubleClick(v); | ||
} | ||
} | ||
|
||
public abstract void onDoubleClick(View v); | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
app/src/main/java/org/cnodejs/android/md/display/view/IBackToContentTopView.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,7 @@ | ||
package org.cnodejs.android.md.display.view; | ||
|
||
public interface IBackToContentTopView { | ||
|
||
void backToContentTop(); | ||
|
||
} |