-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gui): add manual search, stop and sort actions to search dialog (#…
- Loading branch information
Showing
12 changed files
with
196 additions
and
51 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
29 changes: 29 additions & 0 deletions
29
jadx-gui/src/main/java/jadx/gui/utils/rx/CustomDisposable.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,29 @@ | ||
package jadx.gui.utils.rx; | ||
|
||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
import io.reactivex.disposables.Disposable; | ||
|
||
public class CustomDisposable implements Disposable { | ||
|
||
private final AtomicBoolean disposed = new AtomicBoolean(false); | ||
private final Runnable disposeTask; | ||
|
||
public CustomDisposable(Runnable disposeTask) { | ||
this.disposeTask = disposeTask; | ||
} | ||
|
||
@Override | ||
public void dispose() { | ||
try { | ||
disposeTask.run(); | ||
} finally { | ||
disposed.set(true); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean isDisposed() { | ||
return disposed.get(); | ||
} | ||
} |
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,43 @@ | ||
package jadx.gui.utils.rx; | ||
|
||
import java.awt.event.KeyAdapter; | ||
import java.awt.event.KeyEvent; | ||
import java.awt.event.KeyListener; | ||
|
||
import javax.swing.JTextField; | ||
import javax.swing.event.DocumentListener; | ||
|
||
import io.reactivex.BackpressureStrategy; | ||
import io.reactivex.Flowable; | ||
import io.reactivex.FlowableOnSubscribe; | ||
|
||
import jadx.gui.utils.ui.DocumentUpdateListener; | ||
|
||
public class RxUtils { | ||
|
||
public static Flowable<String> textFieldChanges(final JTextField textField) { | ||
FlowableOnSubscribe<String> source = emitter -> { | ||
DocumentListener listener = new DocumentUpdateListener(ev -> emitter.onNext(textField.getText())); | ||
textField.getDocument().addDocumentListener(listener); | ||
emitter.setDisposable(new CustomDisposable(() -> textField.getDocument().removeDocumentListener(listener))); | ||
}; | ||
return Flowable.create(source, BackpressureStrategy.LATEST).distinctUntilChanged(); | ||
} | ||
|
||
public static Flowable<String> textFieldEnterPress(final JTextField textField) { | ||
FlowableOnSubscribe<String> source = emitter -> { | ||
KeyListener keyListener = new KeyAdapter() { | ||
@Override | ||
public void keyPressed(KeyEvent ev) { | ||
if (ev.getKeyCode() == KeyEvent.VK_ENTER) { | ||
emitter.onNext(textField.getText()); | ||
} | ||
} | ||
}; | ||
textField.addKeyListener(keyListener); | ||
emitter.setDisposable(new CustomDisposable(() -> textField.removeKeyListener(keyListener))); | ||
}; | ||
return Flowable.create(source, BackpressureStrategy.LATEST).distinctUntilChanged(); | ||
} | ||
|
||
} |
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
Oops, something went wrong.