Search in sources :

Example 11 with NinjaWebView

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();
        }
    });
}
Also used : KeyEvent(android.view.KeyEvent) NinjaWebView(de.baumann.browser.View.NinjaWebView) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) AutoCompleteTextView(android.widget.AutoCompleteTextView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) NinjaWebView(de.baumann.browser.View.NinjaWebView) AutoCompleteTextView(android.widget.AutoCompleteTextView) DynamicGridView(org.askerov.dynamicgrid.DynamicGridView) View(android.view.View) AdapterView(android.widget.AdapterView) WebView(android.webkit.WebView) TextView(android.widget.TextView) ListView(android.widget.ListView) VideoView(android.widget.VideoView) Paint(android.graphics.Paint)

Example 12 with NinjaWebView

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();
    }
}
Also used : NinjaWebView(de.baumann.browser.View.NinjaWebView) NinjaWebView(de.baumann.browser.View.NinjaWebView) WebView(android.webkit.WebView) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) NinjaWebView(de.baumann.browser.View.NinjaWebView) AutoCompleteTextView(android.widget.AutoCompleteTextView) DynamicGridView(org.askerov.dynamicgrid.DynamicGridView) View(android.view.View) AdapterView(android.widget.AdapterView) WebView(android.webkit.WebView) TextView(android.widget.TextView) ListView(android.widget.ListView) VideoView(android.widget.VideoView) Paint(android.graphics.Paint) LinearLayout(android.widget.LinearLayout)

Aggregations

NinjaWebView (de.baumann.browser.View.NinjaWebView)12 Paint (android.graphics.Paint)7 View (android.view.View)7 WebView (android.webkit.WebView)7 AdapterView (android.widget.AdapterView)7 AutoCompleteTextView (android.widget.AutoCompleteTextView)7 HorizontalScrollView (android.widget.HorizontalScrollView)7 ImageView (android.widget.ImageView)7 ListView (android.widget.ListView)7 TextView (android.widget.TextView)7 VideoView (android.widget.VideoView)7 DynamicGridView (org.askerov.dynamicgrid.DynamicGridView)7 AlbumController (de.baumann.browser.Browser.AlbumController)4 Intent (android.content.Intent)3 PendingIntent (android.app.PendingIntent)2 DialogInterface (android.content.DialogInterface)2 BottomSheetDialog (android.support.design.widget.BottomSheetDialog)2 AlertDialog (android.support.v7.app.AlertDialog)2 KeyEvent (android.view.KeyEvent)2 EditText (android.widget.EditText)2