Search in sources :

Example 1 with NinjaContextWrapper

use of de.baumann.browser.View.NinjaContextWrapper in project browser by scoute-dich.

the class HolderService method onStartCommand.

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    WebView.enableSlowWholeDocumentDraw();
    NinjaWebView webView = new NinjaWebView(new NinjaContextWrapper(this));
    webView.setBrowserController(this);
    webView.setFlag(BrowserUnit.FLAG_NINJA);
    webView.setAlbumCover(null);
    webView.setAlbumTitle(getString(R.string.album_untitled));
    ViewUnit.bound(this, webView);
    webView.loadUrl(RecordUnit.getHolder().getURL());
    webView.deactivate();
    BrowserContainer.add(webView);
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    if (sp.getBoolean("sp_background", true)) {
        updateNotification();
    } else {
        Intent toActivity = new Intent(HolderService.this, BrowserActivity.class);
        startActivity(toActivity);
    }
    return START_STICKY;
}
Also used : NinjaContextWrapper(de.baumann.browser.View.NinjaContextWrapper) SharedPreferences(android.content.SharedPreferences) NinjaWebView(de.baumann.browser.View.NinjaWebView) Intent(android.content.Intent)

Example 2 with NinjaContextWrapper

use of de.baumann.browser.View.NinjaContextWrapper in project browser by scoute-dich.

the class HolderActivity method showHolderDialog.

private void showHolderDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(new NinjaContextWrapper(this));
    builder.setCancelable(true);
    @SuppressLint("InflateParams") NinjaRelativeLayout linearLayout = (NinjaRelativeLayout) getLayoutInflater().inflate(R.layout.main_home, null, false);
    builder.setView(linearLayout);
    String[] strings = getResources().getStringArray(R.array.holder_menu);
    List<String> list = new ArrayList<>();
    list.addAll(Arrays.asList(strings));
    ListView listView = linearLayout.findViewById(R.id.home_list);
    DialogAdapter adapter = new DialogAdapter(this, list);
    listView.setAdapter(adapter);
    adapter.notifyDataSetChanged();
    final AlertDialog dialog = builder.create();
    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            HolderActivity.this.finish();
        }
    });
    dialog.show();
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch(position) {
                case 0:
                    Intent toActivity = new Intent(HolderActivity.this, BrowserActivity.class);
                    toActivity.putExtra(IntentUnit.OPEN, first.getURL());
                    startActivity(toActivity);
                    break;
                case 1:
                    BrowserUnit.copyURL(HolderActivity.this, first.getURL());
                    break;
                case 2:
                    IntentUnit.share(HolderActivity.this, first.getTitle(), first.getURL());
                    break;
                default:
                    break;
            }
            dialog.hide();
            dialog.dismiss();
            finish();
        }
    });
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) Intent(android.content.Intent) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) SuppressLint(android.annotation.SuppressLint) NinjaContextWrapper(de.baumann.browser.View.NinjaContextWrapper) ListView(android.widget.ListView) NinjaRelativeLayout(de.baumann.browser.View.NinjaRelativeLayout) SuppressLint(android.annotation.SuppressLint) AdapterView(android.widget.AdapterView) DialogAdapter(de.baumann.browser.View.DialogAdapter)

Aggregations

Intent (android.content.Intent)2 NinjaContextWrapper (de.baumann.browser.View.NinjaContextWrapper)2 SuppressLint (android.annotation.SuppressLint)1 AlertDialog (android.app.AlertDialog)1 DialogInterface (android.content.DialogInterface)1 SharedPreferences (android.content.SharedPreferences)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ListView (android.widget.ListView)1 DialogAdapter (de.baumann.browser.View.DialogAdapter)1 NinjaRelativeLayout (de.baumann.browser.View.NinjaRelativeLayout)1 NinjaWebView (de.baumann.browser.View.NinjaWebView)1 ArrayList (java.util.ArrayList)1