Skip to content

Commit

Permalink
don't auto-paste same url again
Browse files Browse the repository at this point in the history
  • Loading branch information
autoandshare committed May 6, 2021
1 parent e74c738 commit 0f740a1
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -53,14 +53,17 @@ public void onActivityCreated(Bundle savedInstanceState) {
initUI(getView());
}

private String pastedUrl = null;

@Override
public void onResume() {
super.onResume();
ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
try {
CharSequence text = clipboard.getPrimaryClip().getItemAt(0).getText();
if (URLUtil.isValidUrl(text.toString())) {
String text = clipboard.getPrimaryClip().getItemAt(0).getText().toString();
if (URLUtil.isValidUrl(text) && !text.equals(pastedUrl)) {
setUrlText(text);
pastedUrl = text;
}
} catch (Exception e) {
}
@@ -106,7 +109,7 @@ public void onClick(View v) {

}

private void setUrlText(CharSequence text) {
private void setUrlText(String text) {
urlText.setText(text);
urlText.selectAll();
}

0 comments on commit 0f740a1

Please sign in to comment.