use of de.baumann.browser.view.NinjaWebView in project browser by scoute-dich.
the class BrowserActivity method initSearchPanel.
private void initSearchPanel() {
searchPanel = findViewById(R.id.main_search_panel);
searchBox = findViewById(R.id.main_search_box);
searchUp = findViewById(R.id.main_search_up);
searchDown = findViewById(R.id.main_search_down);
searchCancel = findViewById(R.id.main_search_cancel);
searchBox.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
if (currentAlbumController != null && currentAlbumController instanceof NinjaWebView) {
((NinjaWebView) currentAlbumController).findAllAsync(s.toString());
}
}
});
searchBox.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId != EditorInfo.IME_ACTION_DONE) {
return false;
}
if (searchBox.getText().toString().isEmpty()) {
NinjaToast.show(BrowserActivity.this, getString(R.string.toast_input_empty));
return true;
}
return false;
}
});
searchUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String query = searchBox.getText().toString();
if (query.isEmpty()) {
NinjaToast.show(BrowserActivity.this, getString(R.string.toast_input_empty));
return;
}
hideSoftInput(searchBox);
if (currentAlbumController instanceof NinjaWebView) {
((NinjaWebView) currentAlbumController).findNext(false);
}
}
});
searchDown.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String query = searchBox.getText().toString();
if (query.isEmpty()) {
NinjaToast.show(BrowserActivity.this, getString(R.string.toast_input_empty));
return;
}
hideSoftInput(searchBox);
if (currentAlbumController instanceof NinjaWebView) {
((NinjaWebView) currentAlbumController).findNext(true);
}
}
});
searchCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
hideSearchPanel();
}
});
}
use of de.baumann.browser.view.NinjaWebView in project browser by scoute-dich.
the class BrowserActivity method addAlbum.
private synchronized void addAlbum(String title, final String url, final boolean foreground, final Message resultMsg) {
showOmnibox();
ninjaWebView = new NinjaWebView(this);
ninjaWebView.setBrowserController(this);
ninjaWebView.setFlag(BrowserUnit.FLAG_NINJA);
ninjaWebView.setAlbumTitle(title);
ViewUnit.bound(this, ninjaWebView);
final View albumView = ninjaWebView.getAlbumView();
if (currentAlbumController != null && (currentAlbumController instanceof NinjaWebView) && resultMsg != null) {
int index = BrowserContainer.indexOf(currentAlbumController) + 1;
BrowserContainer.add(ninjaWebView, index);
switcherContainer.addView(albumView, index, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT));
} else {
BrowserContainer.add(ninjaWebView);
switcherContainer.addView(albumView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
}
if (!foreground) {
ViewUnit.bound(this, ninjaWebView);
ninjaWebView.loadUrl(url);
ninjaWebView.deactivate();
if (currentAlbumController != null) {
switcherScroller.smoothScrollTo(currentAlbumController.getAlbumView().getLeft(), 0);
}
return;
}
showAlbum(ninjaWebView, true);
if (url != null && !url.isEmpty()) {
ninjaWebView.loadUrl(url);
} else if (resultMsg != null) {
WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
transport.setWebView(ninjaWebView);
resultMsg.sendToTarget();
}
}
Aggregations