Example usage for android.app AlertDialog.Builder setInverseBackgroundForced

List of usage examples for android.app AlertDialog.Builder setInverseBackgroundForced

Introduction

In this page you can find the example usage for android.app AlertDialog.Builder setInverseBackgroundForced.

Prototype

public void setInverseBackgroundForced(boolean forceInverseBackground) 

Source Link

Usage

From source file:com.irccloud.android.activity.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    AlertDialog.Builder builder;
    AlertDialog dialog;//from w w  w. j  ava  2 s .  co  m

    switch (item.getItemId()) {
    case android.R.id.home:
        if (drawerLayout != null && findViewById(R.id.usersListFragment2) == null) {
            if (drawerLayout.isDrawerOpen(Gravity.LEFT))
                drawerLayout.closeDrawer(Gravity.LEFT);
            else if (drawerLayout.getDrawerLockMode(Gravity.LEFT) == DrawerLayout.LOCK_MODE_UNLOCKED)
                drawerLayout.openDrawer(Gravity.LEFT);
            drawerLayout.closeDrawer(Gravity.RIGHT);
        }
        break;
    case R.id.menu_whois:
        NetworkConnection.getInstance().whois(buffer.cid, buffer.name, null);
        break;
    case R.id.menu_identify:
        NickservFragment nsFragment = new NickservFragment();
        nsFragment.setCid(buffer.cid);
        nsFragment.show(getSupportFragmentManager(), "nickserv");
        break;
    case R.id.menu_add_network:
        addNetwork();
        break;
    case R.id.menu_channel_options:
        ChannelOptionsFragment newFragment = new ChannelOptionsFragment(buffer.cid, buffer.bid);
        newFragment.show(getSupportFragmentManager(), "channeloptions");
        break;
    case R.id.menu_buffer_options:
        BufferOptionsFragment bufferFragment = new BufferOptionsFragment(buffer.cid, buffer.bid, buffer.type);
        bufferFragment.show(getSupportFragmentManager(), "bufferoptions");
        break;
    case R.id.menu_userlist:
        if (drawerLayout != null) {
            if (drawerLayout.isDrawerOpen(Gravity.RIGHT)) {
                drawerLayout.closeDrawers();
            } else {
                if (findViewById(R.id.usersListFragment2) == null)
                    drawerLayout.closeDrawer(Gravity.LEFT);
                drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT);
                drawerLayout.openDrawer(Gravity.RIGHT);
            }
            if (!getSharedPreferences("prefs", 0).getBoolean("userSwipeTip", false)) {
                Toast.makeText(this, "Drag from the edge of the screen to quickly open and close the user list",
                        Toast.LENGTH_LONG).show();
                SharedPreferences.Editor editor = getSharedPreferences("prefs", 0).edit();
                editor.putBoolean("userSwipeTip", true);
                editor.commit();
            }
        }
        return true;
    case R.id.menu_ignore_list:
        Bundle args = new Bundle();
        args.putInt("cid", buffer.cid);
        IgnoreListFragment ignoreList = new IgnoreListFragment();
        ignoreList.setArguments(args);
        ignoreList.show(getSupportFragmentManager(), "ignorelist");
        return true;
    case R.id.menu_ban_list:
        NetworkConnection.getInstance().mode(buffer.cid, buffer.name, "b");
        return true;
    case R.id.menu_leave:
        if (ChannelsDataSource.getInstance().getChannelForBuffer(buffer.bid) == null)
            NetworkConnection.getInstance().join(buffer.cid, buffer.name, null);
        else
            NetworkConnection.getInstance().part(buffer.cid, buffer.name, null);
        return true;
    case R.id.menu_archive:
        if (buffer.archived == 0)
            NetworkConnection.getInstance().archiveBuffer(buffer.cid, buffer.bid);
        else
            NetworkConnection.getInstance().unarchiveBuffer(buffer.cid, buffer.bid);
        return true;
    case R.id.menu_delete:
        builder = new AlertDialog.Builder(MainActivity.this);
        builder.setInverseBackgroundForced(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB);

        if (buffer.type.equals("console"))
            builder.setTitle("Delete Connection");
        else
            builder.setTitle("Delete History");

        if (buffer.type.equalsIgnoreCase("console"))
            builder.setMessage("Are you sure you want to remove this connection?");
        else if (buffer.type.equalsIgnoreCase("channel"))
            builder.setMessage("Are you sure you want to clear your history in " + buffer.name + "?");
        else
            builder.setMessage("Are you sure you want to clear your history with " + buffer.name + "?");

        builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        builder.setPositiveButton("Delete", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                if (buffer.type.equals("console")) {
                    NetworkConnection.getInstance().deleteServer(buffer.cid);
                } else {
                    NetworkConnection.getInstance().deleteBuffer(buffer.cid, buffer.bid);
                }
                dialog.dismiss();
            }
        });
        dialog = builder.create();
        dialog.setOwnerActivity(MainActivity.this);
        dialog.show();
        return true;
    case R.id.menu_editconnection:
        if (!getResources().getBoolean(R.bool.isTablet)) {
            Intent i = new Intent(this, EditConnectionActivity.class);
            i.putExtra("cid", buffer.cid);
            startActivity(i);
        } else {
            EditConnectionFragment editFragment = new EditConnectionFragment();
            editFragment.setCid(buffer.cid);
            editFragment.show(getSupportFragmentManager(), "editconnection");
        }
        return true;
    case R.id.menu_disconnect:
        if (server != null && server.status != null && (server.status.equalsIgnoreCase("waiting_to_retry"))
                || (server.status.contains("connected") && !server.status.startsWith("dis"))) {
            NetworkConnection.getInstance().disconnect(buffer.cid, null);
        } else {
            NetworkConnection.getInstance().reconnect(buffer.cid);
        }
        return true;
    }
    return super.onOptionsItemSelected(item);
}