Example usage for android.view Gravity LEFT

List of usage examples for android.view Gravity LEFT

Introduction

In this page you can find the example usage for android.view Gravity LEFT.

Prototype

int LEFT

To view the source code for android.view Gravity LEFT.

Click Source Link

Document

Push object to the left of its container, not changing its size.

Usage

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

public void onIRCEvent(int what, Object obj) {
    super.onIRCEvent(what, obj);
    Integer event_bid = 0;//from w w w .j  av  a2 s.c  om
    final IRCCloudJSONObject event;
    final Object o = obj;
    switch (what) {
    case NetworkConnection.EVENT_DEBUG:
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                errorMsg.setVisibility(View.VISIBLE);
                errorMsg.setText(o.toString());
            }
        });
        break;
    case NetworkConnection.EVENT_PROGRESS:
        final float progress = (Float) obj;
        if (progressBar.getProgress() < progress) {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    progressBar.setIndeterminate(false);
                    progressBar.setProgress((int) progress);
                }
            });
        }
        break;
    case NetworkConnection.EVENT_BACKLOG_START:
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                progressBar.setProgress(0);
            }
        });
        break;
    case NetworkConnection.EVENT_RENAMECONVERSATION:
        if (buffer != null && (Integer) obj == buffer.bid) {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    update_subtitle();
                }
            });
        }
        break;
    case NetworkConnection.EVENT_CHANNELTOPICIS:
        event = (IRCCloudJSONObject) obj;
        if (buffer != null && buffer.cid == event.cid()
                && buffer.name.equalsIgnoreCase(event.getString("chan"))) {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    update_subtitle();
                    show_topic_popup();
                }
            });
        }
        break;
    case NetworkConnection.EVENT_LINKCHANNEL:
        event = (IRCCloudJSONObject) obj;
        if (event != null && cidToOpen == event.cid() && event.has("invalid_chan") && event.has("valid_chan")
                && event.getString("invalid_chan").equalsIgnoreCase(bufferToOpen)) {
            bufferToOpen = event.getString("valid_chan");
            obj = BuffersDataSource.getInstance().getBuffer(event.bid());
        } else {
            bufferToOpen = null;
            return;
        }
    case NetworkConnection.EVENT_MAKEBUFFER:
        BuffersDataSource.Buffer b = (BuffersDataSource.Buffer) obj;
        if (cidToOpen == b.cid && (bufferToOpen == null || (b.name.equalsIgnoreCase(bufferToOpen)
                && (buffer == null || !bufferToOpen.equalsIgnoreCase(buffer.name))))) {
            server = null;
            final int bid = b.bid;
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    onBufferSelected(bid);
                }
            });
            bufferToOpen = null;
            cidToOpen = -1;
        }
        break;
    case NetworkConnection.EVENT_OPENBUFFER:
        event = (IRCCloudJSONObject) obj;
        try {
            bufferToOpen = event.getString("name");
            cidToOpen = event.cid();
            b = BuffersDataSource.getInstance().getBufferByName(cidToOpen, bufferToOpen);
            if (b != null && !bufferToOpen.equalsIgnoreCase(buffer.name)) {
                server = null;
                bufferToOpen = null;
                cidToOpen = -1;
                final int bid = b.bid;
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        onBufferSelected(bid);
                    }
                });
            }
        } catch (Exception e2) {
            e2.printStackTrace();
        }
        break;
    case NetworkConnection.EVENT_CONNECTIVITY:
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                updateReconnecting();
            }
        });
        if (conn != null) {
            if (conn.getState() == NetworkConnection.STATE_CONNECTED) {
                for (EventsDataSource.Event e : pendingEvents.values()) {
                    try {
                        e.expiration_timer.cancel();
                    } catch (Exception ex) {
                        //Task already cancellled
                    }
                    e.expiration_timer = null;
                    e.failed = true;
                    e.bg_color = R.color.error;
                }
                if (drawerLayout != null && NetworkConnection.getInstance().ready) {
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
                            getSupportActionBar().setHomeButtonEnabled(true);
                            updateUsersListFragmentVisibility();
                        }
                    });
                }
                if (server != null && messageTxt.getText() != null && messageTxt.getText().length() > 0) {
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            sendBtn.setEnabled(true);
                            if (Build.VERSION.SDK_INT >= 11)
                                sendBtn.setAlpha(1);
                        }
                    });
                }
            } else {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        if (drawerLayout != null && !NetworkConnection.getInstance().ready) {
                            drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
                            getSupportActionBar().setHomeButtonEnabled(false);
                        }
                        sendBtn.setEnabled(false);
                        if (Build.VERSION.SDK_INT >= 11)
                            sendBtn.setAlpha(0.5f);
                        photoBtn.setEnabled(false);
                        if (Build.VERSION.SDK_INT >= 11)
                            photoBtn.setAlpha(0.5f);
                    }
                });
            }
        }
        break;
    case NetworkConnection.EVENT_BANLIST:
        event = (IRCCloudJSONObject) obj;
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (event != null && event.cid() == buffer.cid) {
                    Bundle args = new Bundle();
                    args.putInt("cid", event.cid());
                    BuffersDataSource.Buffer b = BuffersDataSource.getInstance().getBufferByName(event.cid(),
                            event.getString("channel"));
                    if (b != null)
                        args.putInt("bid", b.bid);
                    args.putString("mode", "b");
                    args.putString("placeholder",
                            "No bans in effect.\n\nYou can ban someone by tapping their nickname in the user list, long-pressing a message, or by using /ban.");
                    args.putString("mask", "mask");
                    args.putString("list", "bans");
                    args.putString("title", "Ban list for " + event.getString("channel"));
                    args.putString("event", event.toString());
                    ChannelModeListFragment channelModeList = (ChannelModeListFragment) getSupportFragmentManager()
                            .findFragmentByTag("banlist");
                    if (channelModeList == null) {
                        channelModeList = new ChannelModeListFragment();
                        channelModeList.setArguments(args);
                        try {
                            channelModeList.show(getSupportFragmentManager(), "banlist");
                        } catch (IllegalStateException e) {
                            //App lost focus already
                        }
                    } else {
                        channelModeList.setArguments(args);
                    }
                }
            }
        });
        break;
    case NetworkConnection.EVENT_QUIETLIST:
        event = (IRCCloudJSONObject) obj;
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (event != null && event.cid() == buffer.cid) {
                    Bundle args = new Bundle();
                    args.putInt("cid", event.cid());
                    BuffersDataSource.Buffer b = BuffersDataSource.getInstance().getBufferByName(event.cid(),
                            event.getString("channel"));
                    if (b != null)
                        args.putInt("bid", b.bid);
                    args.putString("mode", "q");
                    args.putString("placeholder", "Empty quiet list.");
                    args.putString("mask", "quiet_mask");
                    args.putString("list", "list");
                    args.putString("title", "Quiet list for " + event.getString("channel"));
                    args.putString("event", event.toString());
                    ChannelModeListFragment channelModeList = (ChannelModeListFragment) getSupportFragmentManager()
                            .findFragmentByTag("quietlist");
                    if (channelModeList == null) {
                        channelModeList = new ChannelModeListFragment();
                        channelModeList.setArguments(args);
                        try {
                            channelModeList.show(getSupportFragmentManager(), "quietlist");
                        } catch (IllegalStateException e) {
                            //App lost focus already
                        }
                    } else {
                        channelModeList.setArguments(args);
                    }
                }
            }
        });
        break;
    case NetworkConnection.EVENT_BANEXCEPTIONLIST:
        event = (IRCCloudJSONObject) obj;
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (event != null && event.cid() == buffer.cid) {
                    Bundle args = new Bundle();
                    args.putInt("cid", event.cid());
                    BuffersDataSource.Buffer b = BuffersDataSource.getInstance().getBufferByName(event.cid(),
                            event.getString("channel"));
                    if (b != null)
                        args.putInt("bid", b.bid);
                    args.putString("mode", "e");
                    args.putString("placeholder", "Empty exception list.");
                    args.putString("mask", "mask");
                    args.putString("list", "exceptions");
                    args.putString("title", "Exception list for " + event.getString("channel"));
                    args.putString("event", event.toString());
                    ChannelModeListFragment channelModeList = (ChannelModeListFragment) getSupportFragmentManager()
                            .findFragmentByTag("exceptionlist");
                    if (channelModeList == null) {
                        channelModeList = new ChannelModeListFragment();
                        channelModeList.setArguments(args);
                        try {
                            channelModeList.show(getSupportFragmentManager(), "exceptionlist");
                        } catch (IllegalStateException e) {
                            //App lost focus already
                        }
                    } else {
                        channelModeList.setArguments(args);
                    }
                }
            }
        });
        break;
    case NetworkConnection.EVENT_INVITELIST:
        event = (IRCCloudJSONObject) obj;
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (event != null && event.cid() == buffer.cid) {
                    Bundle args = new Bundle();
                    args.putInt("cid", event.cid());
                    BuffersDataSource.Buffer b = BuffersDataSource.getInstance().getBufferByName(event.cid(),
                            event.getString("channel"));
                    if (b != null)
                        args.putInt("bid", b.bid);
                    args.putString("mode", "I");
                    args.putString("placeholder", "Empty invite list");
                    args.putString("mask", "mask");
                    args.putString("list", "list");
                    args.putString("title", "Invite list for " + event.getString("channel"));
                    args.putString("event", event.toString());
                    ChannelModeListFragment channelModeList = (ChannelModeListFragment) getSupportFragmentManager()
                            .findFragmentByTag("invitelist");
                    if (channelModeList == null) {
                        channelModeList = new ChannelModeListFragment();
                        channelModeList.setArguments(args);
                        try {
                            channelModeList.show(getSupportFragmentManager(), "invitelist");
                        } catch (IllegalStateException e) {
                            //App lost focus already
                        }
                    } else {
                        channelModeList.setArguments(args);
                    }
                }
            }
        });
        break;
    case NetworkConnection.EVENT_ACCEPTLIST:
        event = (IRCCloudJSONObject) obj;
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (event != null && event.cid() == buffer.cid) {
                    Bundle args = new Bundle();
                    args.putInt("cid", buffer.cid);
                    args.putString("event", event.toString());
                    AcceptListFragment acceptList = (AcceptListFragment) getSupportFragmentManager()
                            .findFragmentByTag("acceptlist");
                    if (acceptList == null) {
                        acceptList = new AcceptListFragment();
                        acceptList.setArguments(args);
                        try {
                            acceptList.show(getSupportFragmentManager(), "acceptlist");
                        } catch (IllegalStateException e) {
                            //App lost focus already
                        }
                    } else {
                        acceptList.setArguments(args);
                    }
                }
            }
        });
        break;
    case NetworkConnection.EVENT_WHOLIST:
        event = (IRCCloudJSONObject) obj;
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Bundle args = new Bundle();
                args.putString("event", event.toString());
                WhoListFragment whoList = (WhoListFragment) getSupportFragmentManager()
                        .findFragmentByTag("wholist");
                if (whoList == null) {
                    whoList = new WhoListFragment();
                    whoList.setArguments(args);
                    try {
                        whoList.show(getSupportFragmentManager(), "wholist");
                    } catch (IllegalStateException e) {
                        //App lost focus already
                    }
                } else {
                    whoList.setArguments(args);
                }
            }
        });
        break;
    case NetworkConnection.EVENT_NAMESLIST:
        event = (IRCCloudJSONObject) obj;
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Bundle args = new Bundle();
                args.putString("event", event.toString());
                NamesListFragment namesList = (NamesListFragment) getSupportFragmentManager()
                        .findFragmentByTag("nameslist");
                if (namesList == null) {
                    namesList = new NamesListFragment();
                    namesList.setArguments(args);
                    try {
                        namesList.show(getSupportFragmentManager(), "nameslist");
                    } catch (IllegalStateException e) {
                        //App lost focus already
                    }
                } else {
                    namesList.setArguments(args);
                }
            }
        });
        break;
    case NetworkConnection.EVENT_SERVERMAPLIST:
        event = (IRCCloudJSONObject) obj;
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Bundle args = new Bundle();
                args.putString("event", event.toString());
                ServerMapListFragment serversList = (ServerMapListFragment) getSupportFragmentManager()
                        .findFragmentByTag("serverslist");
                if (serversList == null) {
                    serversList = new ServerMapListFragment();
                    serversList.setArguments(args);
                    try {
                        serversList.show(getSupportFragmentManager(), "serverslist");
                    } catch (IllegalStateException e) {
                        //App lost focus already
                    }
                } else {
                    serversList.setArguments(args);
                }
            }
        });
        break;
    case NetworkConnection.EVENT_WHOIS:
        event = (IRCCloudJSONObject) obj;
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Bundle args = new Bundle();
                args.putString("event", event.toString());
                WhoisFragment whois = (WhoisFragment) getSupportFragmentManager().findFragmentByTag("whois");
                if (whois == null) {
                    whois = new WhoisFragment();
                    whois.setArguments(args);
                    try {
                        whois.show(getSupportFragmentManager(), "whois");
                    } catch (IllegalStateException e) {
                        //App lost focus already
                    }
                } else {
                    whois.setArguments(args);
                }
            }
        });
        break;
    case NetworkConnection.EVENT_LISTRESPONSEFETCHING:
        event = (IRCCloudJSONObject) obj;
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                String dialogtitle = "List of channels on "
                        + ServersDataSource.getInstance().getServer(event.cid()).hostname;
                if (channelsListDialog == null) {
                    Context ctx = MainActivity.this;
                    final AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
                    builder.setInverseBackgroundForced(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB);
                    builder.setView(getLayoutInflater().inflate(R.layout.dialog_channelslist, null));
                    builder.setTitle(dialogtitle);
                    builder.setNegativeButton("Close", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    });
                    channelsListDialog = builder.create();
                    channelsListDialog.setOwnerActivity(MainActivity.this);
                } else {
                    channelsListDialog.setTitle(dialogtitle);
                }
                try {
                    channelsListDialog.show();
                } catch (IllegalStateException e) {
                    //App lost focus already
                }
                ChannelListFragment channels = (ChannelListFragment) getSupportFragmentManager()
                        .findFragmentById(R.id.channelListFragment);
                Bundle args = new Bundle();
                args.putInt("cid", event.cid());
                channels.setArguments(args);
            }
        });
        break;
    case NetworkConnection.EVENT_USERINFO:
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                updateUsersListFragmentVisibility();
                supportInvalidateOptionsMenu();
                if (refreshUpIndicatorTask != null)
                    refreshUpIndicatorTask.cancel(true);
                refreshUpIndicatorTask = new RefreshUpIndicatorTask();
                refreshUpIndicatorTask.execute((Void) null);
            }
        });
        if (launchBid == -1 && server == null && conn != null && conn.getUserInfo() != null)
            launchBid = conn.getUserInfo().last_selected_bid;
        break;
    case NetworkConnection.EVENT_STATUSCHANGED:
        try {
            event = (IRCCloudJSONObject) obj;
            if (event != null && server != null && event.cid() == server.cid) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        supportInvalidateOptionsMenu();
                    }
                });
            }
        } catch (Exception e1) {
            e1.printStackTrace();
        }
        break;
    case NetworkConnection.EVENT_MAKESERVER:
        ServersDataSource.Server s = (ServersDataSource.Server) obj;
        if (server != null && s != null && s.cid == server.cid) {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    supportInvalidateOptionsMenu();
                    update_subtitle();
                }
            });
        } else {
            cidToOpen = s.cid;
            bufferToOpen = "*";
        }
        break;
    case NetworkConnection.EVENT_BUFFERARCHIVED:
    case NetworkConnection.EVENT_BUFFERUNARCHIVED:
        event_bid = (Integer) obj;
        if (buffer != null && event_bid == buffer.bid) {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    update_subtitle();
                }
            });
        }
        if (refreshUpIndicatorTask != null)
            refreshUpIndicatorTask.cancel(true);
        refreshUpIndicatorTask = new RefreshUpIndicatorTask();
        refreshUpIndicatorTask.execute((Void) null);
        break;
    case NetworkConnection.EVENT_JOIN:
        event = (IRCCloudJSONObject) obj;
        if (event != null && buffer != null && event.bid() == buffer.bid
                && event.type().equals("you_joined_channel")) {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    supportInvalidateOptionsMenu();
                    updateUsersListFragmentVisibility();
                }
            });
        }
        break;
    case NetworkConnection.EVENT_PART:
    case NetworkConnection.EVENT_KICK:
        event = (IRCCloudJSONObject) obj;
        if (event != null && buffer != null && event.bid() == buffer.bid
                && event.type().toLowerCase().startsWith("you_")) {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    supportInvalidateOptionsMenu();
                    updateUsersListFragmentVisibility();
                }
            });
        }
        break;
    case NetworkConnection.EVENT_CHANNELINIT:
        ChannelsDataSource.Channel channel = (ChannelsDataSource.Channel) obj;
        if (channel != null && buffer != null && channel.bid == buffer.bid) {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    update_subtitle();
                    supportInvalidateOptionsMenu();
                    updateUsersListFragmentVisibility();
                }
            });
        }
        break;
    case NetworkConnection.EVENT_BACKLOG_END:
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                errorMsg.setVisibility(View.GONE);
                error = null;
                if (progressBar.getVisibility() == View.VISIBLE) {
                    if (Build.VERSION.SDK_INT >= 16) {
                        progressBar.animate().alpha(0).setDuration(200).withEndAction(new Runnable() {
                            @Override
                            public void run() {
                                progressBar.setVisibility(View.GONE);
                            }
                        });
                    } else {
                        progressBar.setVisibility(View.GONE);
                    }
                }
                getSupportActionBar().setDisplayShowTitleEnabled(false);
                getSupportActionBar().setDisplayShowCustomEnabled(true);
                if (drawerLayout != null) {
                    drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
                    getSupportActionBar().setHomeButtonEnabled(true);
                    updateUsersListFragmentVisibility();
                }
                if (ServersDataSource.getInstance().count() < 1) {
                    Crashlytics.log(Log.DEBUG, "IRCCloud", "No servers configured, launching add dialog");
                    addNetwork();
                } else {
                    if (server == null || launchURI != null || launchBid != -1) {
                        Crashlytics.log(Log.DEBUG, "IRCCloud",
                                "Backlog loaded and we're waiting for a buffer, switching now");
                        if (launchURI == null || !open_uri(launchURI)) {
                            if (launchBid == -1 || !open_bid(launchBid)) {
                                if (conn == null || conn.getUserInfo() == null
                                        || !open_bid(conn.getUserInfo().last_selected_bid)) {
                                    if (!open_bid(BuffersDataSource.getInstance().firstBid())) {
                                        if (drawerLayout != null && NetworkConnection.getInstance().ready
                                                && findViewById(R.id.usersListFragment2) == null) {
                                            drawerLayout.openDrawer(Gravity.LEFT);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    update_subtitle();
                }
                if (refreshUpIndicatorTask != null)
                    refreshUpIndicatorTask.cancel(true);
                refreshUpIndicatorTask = new RefreshUpIndicatorTask();
                refreshUpIndicatorTask.execute((Void) null);
                photoBtn.setEnabled(true);
                if (Build.VERSION.SDK_INT >= 11)
                    photoBtn.setAlpha(1);
            }
        });
        //TODO: prune and pop the back stack if the current BID has disappeared
        break;
    case NetworkConnection.EVENT_CONNECTIONDELETED:
    case NetworkConnection.EVENT_DELETEBUFFER:
        Integer id = (Integer) obj;
        if (what == NetworkConnection.EVENT_DELETEBUFFER) {
            synchronized (backStack) {
                for (int i = 0; i < backStack.size(); i++) {
                    if (backStack.get(i).equals(id)) {
                        backStack.remove(i);
                        i--;
                    }
                }
            }
        }
        if (buffer != null
                && id == ((what == NetworkConnection.EVENT_CONNECTIONDELETED) ? buffer.cid : buffer.bid)) {
            synchronized (backStack) {
                while (backStack != null && backStack.size() > 0) {
                    final Integer bid = backStack.get(0);
                    backStack.remove(0);
                    b = BuffersDataSource.getInstance().getBuffer(bid);
                    if (b != null) {
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                onBufferSelected(bid);
                                if (backStack.size() > 0)
                                    backStack.remove(0);
                            }
                        });
                        return;
                    }
                }
            }
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    if (BuffersDataSource.getInstance().count() == 0) {
                        startActivity(new Intent(MainActivity.this, EditConnectionActivity.class));
                        finish();
                    } else {
                        if ((NetworkConnection.getInstance().getUserInfo() == null
                                || !open_bid(NetworkConnection.getInstance().getUserInfo().last_selected_bid))
                                && !open_bid(BuffersDataSource.getInstance().firstBid()))
                            finish();
                    }
                }
            });
        }
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (refreshUpIndicatorTask != null)
                    refreshUpIndicatorTask.cancel(true);
                refreshUpIndicatorTask = new RefreshUpIndicatorTask();
                refreshUpIndicatorTask.execute((Void) null);
            }
        });
        break;
    case NetworkConnection.EVENT_CHANNELMODE:
    case NetworkConnection.EVENT_CHANNELTOPIC:
        event = (IRCCloudJSONObject) obj;
        if (event != null && buffer != null && event.bid() == buffer.bid) {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    update_subtitle();
                }
            });
        }
        break;
    case NetworkConnection.EVENT_SELFBACK:
    case NetworkConnection.EVENT_AWAY:
        try {
            event = (IRCCloudJSONObject) obj;
            if (event != null && buffer != null && event.cid() == buffer.cid
                    && event.getString("nick").equalsIgnoreCase(buffer.name)) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        update_subtitle();
                    }
                });
            }
        } catch (Exception e1) {
            e1.printStackTrace();
        }
        break;
    case NetworkConnection.EVENT_HEARTBEATECHO:
        boolean shouldRefresh = false;
        event = (IRCCloudJSONObject) obj;
        JsonNode seenEids = event.getJsonNode("seenEids");
        Iterator<Map.Entry<String, JsonNode>> iterator = seenEids.fields();
        while (iterator.hasNext()) {
            Map.Entry<String, JsonNode> entry = iterator.next();
            JsonNode eids = entry.getValue();
            Iterator<Map.Entry<String, JsonNode>> j = eids.fields();
            while (j.hasNext()) {
                Map.Entry<String, JsonNode> eidentry = j.next();
                Integer bid = Integer.valueOf(eidentry.getKey());
                if (buffer != null && bid != buffer.bid) {
                    shouldRefresh = true;
                }
            }
        }
        if (shouldRefresh) {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    if (refreshUpIndicatorTask != null)
                        refreshUpIndicatorTask.cancel(true);
                    refreshUpIndicatorTask = new RefreshUpIndicatorTask();
                    refreshUpIndicatorTask.execute((Void) null);
                }
            });
        }
        break;
    case NetworkConnection.EVENT_FAILURE_MSG:
        event = (IRCCloudJSONObject) obj;
        if (event != null && event.has("_reqid")) {
            int reqid = event.getInt("_reqid");
            if (pendingEvents.containsKey(reqid)) {
                EventsDataSource.Event e = pendingEvents.get(reqid);
                EventsDataSource.getInstance().deleteEvent(e.eid, e.bid);
                pendingEvents.remove(event.getInt("_reqid"));
                e.failed = true;
                e.bg_color = R.color.error;
                if (e.expiration_timer != null)
                    e.expiration_timer.cancel();
                conn.notifyHandlers(NetworkConnection.EVENT_BUFFERMSG, e);
            }
        } else {
            if (event.getString("message").equalsIgnoreCase("auth")) {
                conn.logout();
                Intent i = new Intent(MainActivity.this, LoginActivity.class);
                i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(i);
                finish();
            }
            if (event.getString("message").equalsIgnoreCase("set_shard")) {
                NetworkConnection.getInstance().disconnect();
                NetworkConnection.getInstance().ready = false;
                SharedPreferences.Editor editor = getSharedPreferences("prefs", 0).edit();
                editor.putString("session_key", event.getString("cookie"));
                if (event.has("websocket_host")) {
                    NetworkConnection.IRCCLOUD_HOST = event.getString("websocket_host");
                    NetworkConnection.IRCCLOUD_PATH = event.getString("websocket_path");
                }
                editor.putString("host", NetworkConnection.IRCCLOUD_HOST);
                editor.putString("path", NetworkConnection.IRCCLOUD_PATH);
                editor.commit();
                NetworkConnection.getInstance().connect(event.getString("cookie"));
            }
        }
        try {
            error = event.getString("message");
            if (error.equals("temp_unavailable"))
                error = "Your account is temporarily unavailable";
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    updateReconnecting();
                }
            });
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        break;
    case NetworkConnection.EVENT_BUFFERMSG:
        try {
            EventsDataSource.Event e = (EventsDataSource.Event) obj;
            if (e != null && buffer != null) {
                if (e.bid != buffer.bid && upDrawable != null) {
                    BuffersDataSource.Buffer buf = BuffersDataSource.getInstance().getBuffer(e.bid);
                    if (e.isImportant(buf.type)) {
                        if (upDrawable.getColor() != redColor
                                && (e.highlight || buf.type.equals("conversation"))) {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    upDrawable.setColor(redColor);
                                }
                            });
                        } else if (upDrawable.getColor() == greyColor) {
                            JSONObject channelDisabledMap = null;
                            JSONObject bufferDisabledMap = null;
                            if (NetworkConnection.getInstance().getUserInfo() != null
                                    && NetworkConnection.getInstance().getUserInfo().prefs != null) {
                                try {
                                    if (NetworkConnection.getInstance().getUserInfo().prefs
                                            .has("channel-disableTrackUnread"))
                                        channelDisabledMap = NetworkConnection.getInstance().getUserInfo().prefs
                                                .getJSONObject("channel-disableTrackUnread");
                                    if (NetworkConnection.getInstance().getUserInfo().prefs
                                            .has("buffer-disableTrackUnread"))
                                        bufferDisabledMap = NetworkConnection.getInstance().getUserInfo().prefs
                                                .getJSONObject("buffer-disableTrackUnread");
                                } catch (Exception e1) {
                                    // TODO Auto-generated catch block
                                    e1.printStackTrace();
                                }
                            }
                            if (buf.type.equalsIgnoreCase("channel") && channelDisabledMap != null
                                    && channelDisabledMap.has(String.valueOf(buf.bid))
                                    && channelDisabledMap.getBoolean(String.valueOf(buf.bid)))
                                break;
                            else if (bufferDisabledMap != null && bufferDisabledMap.has(String.valueOf(buf.bid))
                                    && bufferDisabledMap.getBoolean(String.valueOf(buf.bid)))
                                break;
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    upDrawable.setColor(blueColor);
                                }
                            });
                        }
                    }
                }
                if (e.from.equalsIgnoreCase(buffer.name)) {
                    pendingEvents.clear();
                } else if (pendingEvents.containsKey(e.reqid)) {
                    pendingEvents.remove(e.reqid);
                }
            }
        } catch (Exception e1) {
        }
        break;
    }
}

From source file:com.xplink.android.carchecklist.CarCheckListActivity.java

private void SlideInteriorLayout() {
    final SharedPreferences settings = getSharedPreferences("mysettings", 0);
    final SharedPreferences.Editor editor = settings.edit();
    final Dialog interiordialog = new Dialog(CarCheckListActivity.this, R.style.backgrounddialog);
    interiordialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    interiordialog.setContentView(R.layout.interiordialoglayout);
    interiordialog.getWindow().getAttributes().windowAnimations = R.style.InteriorDialogAnimation;
    interiordialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    // make everything around Dialog brightness than default
    WindowManager.LayoutParams lp = interiordialog.getWindow().getAttributes();
    lp.dimAmount = 0f;//w ww .ja v  a  2 s  .  c o m

    final CheckBox chkinside_seat = (CheckBox) interiordialog.getWindow().findViewById(R.id.inside_seat);
    final CheckBox chkinside_console = (CheckBox) interiordialog.getWindow().findViewById(R.id.inside_console);
    final CheckBox chkinside_steeringWheel = (CheckBox) interiordialog.getWindow()
            .findViewById(R.id.inside_steeringWheel);
    final CheckBox chkinside_transmission = (CheckBox) interiordialog.getWindow()
            .findViewById(R.id.inside_transmission);
    final CheckBox chkinside_sideDoors = (CheckBox) interiordialog.getWindow()
            .findViewById(R.id.inside_sideDoors);
    final CheckBox chkinside_dashBoard = (CheckBox) interiordialog.getWindow()
            .findViewById(R.id.inside_dashBoard);
    final CheckBox chkinside_carpet = (CheckBox) interiordialog.getWindow().findViewById(R.id.inside_carpet);
    final CheckBox chkinside_curtain = (CheckBox) interiordialog.getWindow().findViewById(R.id.inside_curtain);
    final CheckBox chkinside_seatBelt = (CheckBox) interiordialog.getWindow()
            .findViewById(R.id.inside_seatBelt);
    final CheckBox chkinside_backDoor = (CheckBox) interiordialog.getWindow()
            .findViewById(R.id.inside_backDoor);
    final CheckBox chkinside_lidOil = (CheckBox) interiordialog.getWindow().findViewById(R.id.inside_lidOil);
    final CheckBox chkinside_setSeat = (CheckBox) interiordialog.getWindow().findViewById(R.id.inside_setSeat);
    final CheckBox chkinside_brakePedal = (CheckBox) interiordialog.getWindow()
            .findViewById(R.id.inside_brakePedal);
    final CheckBox chkinside_accelerator = (CheckBox) interiordialog.getWindow()
            .findViewById(R.id.inside_accelerator);
    final CheckBox chkinside_handBrake = (CheckBox) interiordialog.getWindow()
            .findViewById(R.id.inside_handBrake);

    // Change font
    chkinside_seat.setTypeface(type);
    chkinside_console.setTypeface(type);
    chkinside_steeringWheel.setTypeface(type);
    chkinside_transmission.setTypeface(type);
    chkinside_sideDoors.setTypeface(type);
    chkinside_dashBoard.setTypeface(type);
    chkinside_carpet.setTypeface(type);
    chkinside_curtain.setTypeface(type);
    chkinside_seatBelt.setTypeface(type);
    chkinside_backDoor.setTypeface(type);
    chkinside_lidOil.setTypeface(type);
    chkinside_setSeat.setTypeface(type);
    chkinside_brakePedal.setTypeface(type);
    chkinside_accelerator.setTypeface(type);
    chkinside_handBrake.setTypeface(type);

    interiordialog.setCanceledOnTouchOutside(true);
    interiordialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            headinterior.setVisibility(ImageView.VISIBLE);
            TranslateAnimation slideoutheadinterior = new TranslateAnimation(0, 0, 180, 800);
            slideoutheadinterior.setDuration(500);
            slideoutheadinterior.setFillAfter(true);
            headinterior.startAnimation(slideoutheadinterior);

            Map<String, Boolean> mp = new HashMap<String, Boolean>();

            mp.put("inside_seat", chkinside_seat.isChecked());
            mp.put("inside_console", chkinside_console.isChecked());
            mp.put("inside_steeringWheel", chkinside_steeringWheel.isChecked());
            mp.put("inside_transmission", chkinside_transmission.isChecked());
            mp.put("inside_sideDoors", chkinside_sideDoors.isChecked());
            mp.put("inside_dashBoard", chkinside_dashBoard.isChecked());
            mp.put("inside_carpet", chkinside_carpet.isChecked());
            mp.put("inside_curtain", chkinside_curtain.isChecked());
            mp.put("inside_seatBelt", chkinside_seatBelt.isChecked());
            mp.put("inside_backDoor", chkinside_backDoor.isChecked());
            mp.put("inside_lidOil", chkinside_lidOil.isChecked());
            mp.put("inside_setSeat", chkinside_setSeat.isChecked());
            mp.put("inside_brakePedal", chkinside_brakePedal.isChecked());
            mp.put("inside_accelerator", chkinside_accelerator.isChecked());
            mp.put("inside_handBrake", chkinside_handBrake.isChecked());

            filterStore("interior", mp);
            save(mp);
        }
    });
    TextView interior = (TextView) interiordialog.getWindow().findViewById(R.id.Interior);
    interior.setTypeface(type);
    Button interiorback = (Button) interiordialog.getWindow().findViewById(R.id.Interiorback);
    interiorback.setTypeface(type);
    interiorback.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            interiordialog.dismiss();

            headinterior.setVisibility(ImageView.VISIBLE);
            TranslateAnimation slideoutheadinterior = new TranslateAnimation(0, 0, 180, 800);
            slideoutheadinterior.setDuration(500);
            slideoutheadinterior.setFillAfter(true);
            headinterior.startAnimation(slideoutheadinterior);

            Map<String, Boolean> mp = new HashMap<String, Boolean>();

            mp.put("inside_seat", chkinside_seat.isChecked());
            mp.put("inside_console", chkinside_console.isChecked());
            mp.put("inside_steeringWheel", chkinside_steeringWheel.isChecked());
            mp.put("inside_transmission", chkinside_transmission.isChecked());
            mp.put("inside_sideDoors", chkinside_sideDoors.isChecked());
            mp.put("inside_dashBoard", chkinside_dashBoard.isChecked());
            mp.put("inside_carpet", chkinside_carpet.isChecked());
            mp.put("inside_curtain", chkinside_curtain.isChecked());
            mp.put("inside_seatBelt", chkinside_seatBelt.isChecked());
            mp.put("inside_backDoor", chkinside_backDoor.isChecked());
            mp.put("inside_lidOil", chkinside_lidOil.isChecked());
            mp.put("inside_setSeat", chkinside_setSeat.isChecked());
            mp.put("inside_brakePedal", chkinside_brakePedal.isChecked());
            mp.put("inside_accelerator", chkinside_accelerator.isChecked());
            mp.put("inside_handBrake", chkinside_handBrake.isChecked());

            filterStore("interior", mp);
            save(mp);

        }
    });

    chkinside_seat.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalInterior(increment);
            } else {
                increment = false;
                getTotalInterior(increment);
            }
            InteriorProgress.setProgress(PercenInterior);
            perceninterior.setText("" + PercenInterior + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkinside_console.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalInterior(increment);
            } else {
                increment = false;
                getTotalInterior(increment);
            }
            InteriorProgress.setProgress(PercenInterior);
            perceninterior.setText("" + PercenInterior + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkinside_steeringWheel.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalInterior(increment);
            } else {
                increment = false;
                getTotalInterior(increment);
            }
            InteriorProgress.setProgress(PercenInterior);
            perceninterior.setText("" + PercenInterior + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkinside_transmission.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalInterior(increment);
            } else {
                increment = false;
                getTotalInterior(increment);
            }
            InteriorProgress.setProgress(PercenInterior);
            perceninterior.setText("" + PercenInterior + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkinside_sideDoors.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalInterior(increment);
            } else {
                increment = false;
                getTotalInterior(increment);
            }
            InteriorProgress.setProgress(PercenInterior);
            perceninterior.setText("" + PercenInterior + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkinside_dashBoard.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalInterior(increment);
            } else {
                increment = false;
                getTotalInterior(increment);
            }
            InteriorProgress.setProgress(PercenInterior);
            perceninterior.setText("" + PercenInterior + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkinside_carpet.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalInterior(increment);
            } else {
                increment = false;
                getTotalInterior(increment);
            }
            InteriorProgress.setProgress(PercenInterior);
            perceninterior.setText("" + PercenInterior + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkinside_curtain.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalInterior(increment);
            } else {
                increment = false;
                getTotalInterior(increment);
            }
            InteriorProgress.setProgress(PercenInterior);
            perceninterior.setText("" + PercenInterior + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkinside_seatBelt.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalInterior(increment);
            } else {
                increment = false;
                getTotalInterior(increment);
            }
            InteriorProgress.setProgress(PercenInterior);
            perceninterior.setText("" + PercenInterior + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkinside_backDoor.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalInterior(increment);
            } else {
                increment = false;
                getTotalInterior(increment);
            }
            InteriorProgress.setProgress(PercenInterior);
            perceninterior.setText("" + PercenInterior + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkinside_lidOil.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalInterior(increment);
            } else {
                increment = false;
                getTotalInterior(increment);
            }
            InteriorProgress.setProgress(PercenInterior);
            perceninterior.setText("" + PercenInterior + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkinside_setSeat.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalInterior(increment);
            } else {
                increment = false;
                getTotalInterior(increment);
            }
            InteriorProgress.setProgress(PercenInterior);
            perceninterior.setText("" + PercenInterior + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkinside_brakePedal.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalInterior(increment);
            } else {
                increment = false;
                getTotalInterior(increment);
            }
            InteriorProgress.setProgress(PercenInterior);
            perceninterior.setText("" + PercenInterior + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkinside_accelerator.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalInterior(increment);
            } else {
                increment = false;
                getTotalInterior(increment);
            }
            InteriorProgress.setProgress(PercenInterior);
            perceninterior.setText("" + PercenInterior + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkinside_handBrake.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalInterior(increment);
            } else {
                increment = false;
                getTotalInterior(increment);
            }
            InteriorProgress.setProgress(PercenInterior);
            perceninterior.setText("" + PercenInterior + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    headinterior.setVisibility(ImageView.VISIBLE);
    TranslateAnimation slideheadinterior = new TranslateAnimation(0, 0, 800, 180);
    slideheadinterior.setDuration(500);
    slideheadinterior.setFillAfter(true);
    headinterior.startAnimation(slideheadinterior);

    interiordialog.show();

    WindowManager.LayoutParams params = interiordialog.getWindow().getAttributes();
    params.y = 180;
    params.x = 60;
    params.gravity = Gravity.TOP | Gravity.LEFT;
    interiordialog.getWindow().setAttributes(params);

    chkinside_seat.setChecked(load("inside_seat"));
    chkinside_console.setChecked(load("inside_console"));
    chkinside_steeringWheel.setChecked(load("inside_steeringWheel"));
    chkinside_transmission.setChecked(load("inside_transmission"));
    chkinside_sideDoors.setChecked(load("inside_sideDoors"));
    chkinside_dashBoard.setChecked(load("inside_dashBoard"));
    chkinside_carpet.setChecked(load("inside_carpet"));
    chkinside_curtain.setChecked(load("inside_curtain"));
    chkinside_seatBelt.setChecked(load("inside_seatBelt"));
    chkinside_backDoor.setChecked(load("inside_backDoor"));
    chkinside_lidOil.setChecked(load("inside_lidOil"));
    chkinside_setSeat.setChecked(load("inside_setSeat"));
    chkinside_brakePedal.setChecked(load("inside_brakePedal"));
    chkinside_accelerator.setChecked(load("inside_accelerator"));
    chkinside_handBrake.setChecked(load("inside_handBrake"));

}

From source file:com.xplink.android.carchecklist.CarCheckListActivity.java

private void SlideDocumentLayout() {
    final SharedPreferences settings = getSharedPreferences("mysettings", 0);
    final SharedPreferences.Editor editor = settings.edit();
    final Dialog documentdialog = new Dialog(CarCheckListActivity.this, R.style.backgrounddialog);
    documentdialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    documentdialog.setContentView(R.layout.documentdialoglayout);
    documentdialog.getWindow().getAttributes().windowAnimations = R.style.DocumentDialogAnimation;
    documentdialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    // make everything around Dialog brightness than default
    WindowManager.LayoutParams lp = documentdialog.getWindow().getAttributes();
    lp.dimAmount = 0f;//from   w  ww. ja  va2s  .c  om

    final CheckBox chkinsurance = (CheckBox) documentdialog.getWindow().findViewById(R.id.doc_insurance);
    final CheckBox chkactTaxLabel = (CheckBox) documentdialog.getWindow().findViewById(R.id.doc_actTaxLabel);
    final CheckBox chkbill = (CheckBox) documentdialog.getWindow().findViewById(R.id.doc_bill);
    final CheckBox chklicensePlate = (CheckBox) documentdialog.getWindow().findViewById(R.id.doc_licensePlate);
    final CheckBox chklicenseManual = (CheckBox) documentdialog.getWindow()
            .findViewById(R.id.doc_licenseManual);
    final CheckBox chkcarPartPaper = (CheckBox) documentdialog.getWindow().findViewById(R.id.doc_carPartPaper);
    final CheckBox chkcarManual = (CheckBox) documentdialog.getWindow().findViewById(R.id.doc_carManual);
    final CheckBox chklicenseRegister = (CheckBox) documentdialog.getWindow()
            .findViewById(R.id.doc_licenseRegister);
    final CheckBox chkgift = (CheckBox) documentdialog.getWindow().findViewById(R.id.doc_gift);

    // Change font
    chkinsurance.setTypeface(type);
    chkactTaxLabel.setTypeface(type);
    chkbill.setTypeface(type);
    chklicensePlate.setTypeface(type);
    chklicenseManual.setTypeface(type);
    chkcarPartPaper.setTypeface(type);
    chkcarManual.setTypeface(type);
    chklicenseRegister.setTypeface(type);
    chkgift.setTypeface(type);

    documentdialog.setCanceledOnTouchOutside(true);
    documentdialog.setOnCancelListener(new DialogInterface.OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {

            headdocument.setVisibility(ImageView.VISIBLE);
            TranslateAnimation slideoutheaddocument = new TranslateAnimation(0, 0, 350, 800);
            slideoutheaddocument.setDuration(500);
            slideoutheaddocument.setFillAfter(true);
            headdocument.startAnimation(slideoutheaddocument);

            Map<String, Boolean> mp = new HashMap<String, Boolean>();

            mp.put("doc_insurance", chkinsurance.isChecked());
            mp.put("doc_actTaxLabel", chkactTaxLabel.isChecked());
            mp.put("doc_bill", chkbill.isChecked());
            mp.put("doc_licensePlate", chklicensePlate.isChecked());
            mp.put("doc_licenseManual", chklicenseManual.isChecked());
            mp.put("doc_carPartPaper", chkcarPartPaper.isChecked());
            mp.put("doc_carManual", chkcarManual.isChecked());
            mp.put("doc_licenseRegister", chklicenseRegister.isChecked());
            mp.put("doc_gift", chkgift.isChecked());

            filterStore("document", mp);
            save(mp);

        }
    });

    TextView document = (TextView) documentdialog.getWindow().findViewById(R.id.Document);
    document.setTypeface(type);
    Button documentback = (Button) documentdialog.getWindow().findViewById(R.id.Documentback);
    documentback.setTypeface(type);
    documentback.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            documentdialog.dismiss();

            headdocument.setVisibility(ImageView.VISIBLE);
            TranslateAnimation slideoutheaddocument = new TranslateAnimation(0, 0, 350, 800);
            slideoutheaddocument.setDuration(500);
            slideoutheaddocument.setFillAfter(true);
            headdocument.startAnimation(slideoutheaddocument);

            Map<String, Boolean> mp = new HashMap<String, Boolean>();

            mp.put("doc_insurance", chkinsurance.isChecked());
            mp.put("doc_actTaxLabel", chkactTaxLabel.isChecked());
            mp.put("doc_bill", chkbill.isChecked());
            mp.put("doc_licensePlate", chklicensePlate.isChecked());
            mp.put("doc_licenseManual", chklicenseManual.isChecked());
            mp.put("doc_carPartPaper", chkcarPartPaper.isChecked());
            mp.put("doc_carManual", chkcarManual.isChecked());
            mp.put("doc_licenseRegister", chklicenseRegister.isChecked());
            mp.put("doc_gift", chkgift.isChecked());

            filterStore("document", mp);
            save(mp);

        }

    });

    chkinsurance.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalDocument(increment);
            } else {
                increment = false;
                getTotalDocument(increment);
            }
            DocumentProgress.setProgress(PercenDocument);
            percendocument.setText("" + PercenDocument + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkactTaxLabel.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalDocument(increment);
            } else {
                increment = false;
                getTotalDocument(increment);
            }
            DocumentProgress.setProgress(PercenDocument);
            percendocument.setText("" + PercenDocument + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkbill.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalDocument(increment);
            } else {
                increment = false;
                getTotalDocument(increment);
            }
            DocumentProgress.setProgress(PercenDocument);
            percendocument.setText("" + PercenDocument + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chklicensePlate.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalDocument(increment);
            } else {
                increment = false;
                getTotalDocument(increment);
            }
            DocumentProgress.setProgress(PercenDocument);
            percendocument.setText("" + PercenDocument + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chklicenseManual.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalDocument(increment);
            } else {
                increment = false;
                getTotalDocument(increment);
            }
            DocumentProgress.setProgress(PercenDocument);
            percendocument.setText("" + PercenDocument + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkcarPartPaper.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalDocument(increment);
            } else {
                increment = false;
                getTotalDocument(increment);
            }
            DocumentProgress.setProgress(PercenDocument);
            percendocument.setText("" + PercenDocument + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkcarManual.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalDocument(increment);
            } else {
                increment = false;
                getTotalDocument(increment);
            }
            DocumentProgress.setProgress(PercenDocument);
            percendocument.setText("" + PercenDocument + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chklicenseRegister.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalDocument(increment);
            } else {
                increment = false;
                getTotalDocument(increment);
            }
            DocumentProgress.setProgress(PercenDocument);
            percendocument.setText("" + PercenDocument + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkgift.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalDocument(increment);
            } else {
                increment = false;
                getTotalDocument(increment);
            }
            DocumentProgress.setProgress(PercenDocument);
            percendocument.setText("" + PercenDocument + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    headdocument.setVisibility(ImageView.VISIBLE);
    TranslateAnimation slideheaddocument = new TranslateAnimation(0, 0, 800, 350);
    slideheaddocument.setDuration(500);
    slideheaddocument.setFillAfter(true);
    headdocument.startAnimation(slideheaddocument);

    documentdialog.show();

    WindowManager.LayoutParams params = documentdialog.getWindow().getAttributes();
    params.y = 350;
    params.x = 60;
    params.gravity = Gravity.TOP | Gravity.LEFT;
    documentdialog.getWindow().setAttributes(params);

    chkinsurance.setChecked(load("doc_insurance"));
    chkactTaxLabel.setChecked(load("doc_actTaxLabel"));
    chkbill.setChecked(load("doc_bill"));
    chklicensePlate.setChecked(load("doc_licensePlate"));
    chklicenseManual.setChecked(load("doc_licenseManual"));
    chkcarPartPaper.setChecked(load("doc_carPartPaper"));
    chkcarManual.setChecked(load("doc_carManual"));
    chklicenseRegister.setChecked(load("doc_licenseRegister"));
    chkgift.setChecked(load("doc_gift"));

}

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

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    AlertDialog.Builder builder;//w  w  w.j  av a2  s. c o  m
    AlertDialog dialog;

    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);
}

From source file:com.xplink.android.carchecklist.CarCheckListActivity.java

private void SlideSettingLayout() {

    SharedPreferences mSharedPrefs = getSharedPreferences("mysettings", Context.MODE_PRIVATE);

    // Bundle seek = getIntent().getExtras();
    final Dialog settingdialog = new Dialog(CarCheckListActivity.this, R.style.backgrounddialog);
    settingdialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    settingdialog.setContentView(R.layout.settingdialoglayout);

    final SeekBar powerseekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Powerbar);
    final SeekBar engineseekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Enginebar);
    final SeekBar exteriorseekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Exteriorbar);
    // exteriorseekbar.setIndeterminate(false);
    final SeekBar interiorseekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Interiorbar);
    final SeekBar documentseekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Documentbar);
    // seekbar.putInt("Powerbar", powerseekbarValue).commit();
    // if(seek != null){
    Log.i("insettings", "seekbar : power-> " + mSharedPrefs.getInt("Powerbar", 0));
    Log.i("insettings", "seekbar : engine->" + mSharedPrefs.getInt("Enginebar", 0));
    Log.i("insettings", "seekbar : exterior->" + mSharedPrefs.getInt("Exteriorbar", 0));
    Log.i("insettings", "seekbar : interior->" + mSharedPrefs.getInt("Interiorbar", 0));
    Log.i("insettings", "seekbar : document->" + mSharedPrefs.getInt("Documentbar", 0));
    powerseekbar.setProgress(mSharedPrefs.getInt("Powerbar", 0));
    engineseekbar.setProgress(mSharedPrefs.getInt("Enginebar", 0));
    exteriorseekbar.setProgress(mSharedPrefs.getInt("Exteriorbar", 0));
    interiorseekbar.setProgress(mSharedPrefs.getInt("Interiorbar", 0));
    documentseekbar.setProgress(mSharedPrefs.getInt("Documentbar", 0));

    /*/*from w  w w  .j ava2 s  .  c o  m*/
     * for(Map.Entry<String, Integer> entry : mapSetting.entrySet()){
     * if("interior".equals(entry.getKey())) edit.putInt("Interiorbar",
     * entry.getValue()); else if("power".equals(entry.getKey()))
     * edit.putInt("Powerbar", entry.getValue()); else
     * if("engine".equals(entry.getKey())) edit.putInt("Enginebar",
     * entry.getValue()); else if("exterior".equals(entry.getKey()))
     * edit.putInt("Exteriorbar", entry.getValue()); else
     * edit.putInt("Documentbar", entry.getValue());
     * 
     * //Log.i("checkSettingsName", "checkSettingsName : " +
     * entry.getKey()); }
     */

    // ****************************************************check exist
    // current setting

    int powerBar = mSharedPrefs.getInt("Powerbar", 0);
    int engineBar = mSharedPrefs.getInt("Enginebar", 0);
    int exteriorBar = mSharedPrefs.getInt("Exteriorbar", 0);
    int interiorBar = mSharedPrefs.getInt("Interiorbar", 0);
    int documentBar = mSharedPrefs.getInt("Documentbar", 0);

    Log.i("power_setting", "*****in setting******power setting : " + powerBar);
    Log.i("engine_setting", "engine setting : " + engineBar);
    Log.i("exterior_setting", "exterior setting : " + exteriorBar);
    Log.i("interior_setting", "interior setting : " + interiorBar);
    Log.i("document_setting", "document setting : " + documentBar);

    // }
    TextView setting = (TextView) settingdialog.getWindow().findViewById(R.id.Setting);
    TextView priority = (TextView) settingdialog.getWindow().findViewById(R.id.Priority);
    TextView low = (TextView) settingdialog.getWindow().findViewById(R.id.Low);
    TextView high = (TextView) settingdialog.getWindow().findViewById(R.id.High);
    TextView textexterior = (TextView) settingdialog.getWindow().findViewById(R.id.textexterior);
    TextView textinterior = (TextView) settingdialog.getWindow().findViewById(R.id.textinterior);
    TextView textpower = (TextView) settingdialog.getWindow().findViewById(R.id.textpower);
    TextView textengine = (TextView) settingdialog.getWindow().findViewById(R.id.textengine);
    TextView textdocument = (TextView) settingdialog.getWindow().findViewById(R.id.textdocument);
    TextView one = (TextView) settingdialog.getWindow().findViewById(R.id.one);
    TextView two = (TextView) settingdialog.getWindow().findViewById(R.id.two);
    TextView three = (TextView) settingdialog.getWindow().findViewById(R.id.three);
    TextView four = (TextView) settingdialog.getWindow().findViewById(R.id.four);
    TextView five = (TextView) settingdialog.getWindow().findViewById(R.id.five);

    setting.setTypeface(type);
    priority.setTypeface(type);
    low.setTypeface(type);
    high.setTypeface(type);
    textexterior.setTypeface(type);
    textinterior.setTypeface(type);
    textpower.setTypeface(type);
    textengine.setTypeface(type);
    textdocument.setTypeface(type);
    one.setTypeface(type);
    two.setTypeface(type);
    three.setTypeface(type);
    four.setTypeface(type);
    five.setTypeface(type);

    settingdialog.getWindow().getAttributes().windowAnimations = R.style.SettingDialogAnimation;
    settingdialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    // make everything around Dialog brightness than default
    WindowManager.LayoutParams lp = settingdialog.getWindow().getAttributes();
    lp.dimAmount = 0f;
    settingdialog.setCanceledOnTouchOutside(true);
    settingdialog.setOnCancelListener(new DialogInterface.OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {

            headsetting.setVisibility(ImageView.VISIBLE);
            TranslateAnimation slideoutheadsetting = new TranslateAnimation(0, 0, 0, -468);
            slideoutheadsetting.setDuration(500);
            slideoutheadsetting.setFillAfter(true);
            headsetting.startAnimation(slideoutheadsetting);

        }
    });

    Button btnsave = (Button) settingdialog.getWindow().findViewById(R.id.save);
    btnsave.setTypeface(type);
    btnsave.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            settingdialog.dismiss();

            headsetting.setVisibility(ImageView.VISIBLE);
            TranslateAnimation slideoutheadsetting = new TranslateAnimation(0, 0, 0, -468);
            slideoutheadsetting.setDuration(500);
            slideoutheadsetting.setFillAfter(true);
            headsetting.startAnimation(slideoutheadsetting);

            powerseekbarValue = powerseekbar.getProgress();
            engineseekbarValue = engineseekbar.getProgress();
            exteriorseekbarValue = exteriorseekbar.getProgress();
            interiorseekbarValue = interiorseekbar.getProgress();
            documentseekbarValue = documentseekbar.getProgress();

            Priority();

            SharedPreferences mSharedPrefs = getSharedPreferences("mysettings", Context.MODE_PRIVATE);
            Editor seekbar = mSharedPrefs.edit();
            seekbar.putInt("Powerbar", powerseekbarValue);
            seekbar.putInt("Enginebar", engineseekbarValue);
            seekbar.putInt("Exteriorbar", exteriorseekbarValue);
            seekbar.putInt("Interiorbar", interiorseekbarValue);
            seekbar.putInt("Documentbar", documentseekbarValue);
            seekbar.commit();

            /*
             * int powerBar = shared2.getInt("Powerbar", 0); int engineBar =
             * shared2.getInt("Enginebar", 0); int exteriorBar =
             * shared2.getInt("Exteriorbar", 0); int interiorBar =
             * shared2.getInt("Interiorbar", 0); int documentBar =
             * shared2.getInt("Documentbar", 0);
             */
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    Button btnreset = (Button) settingdialog.getWindow().findViewById(R.id.reset);
    btnreset.setTypeface(type);
    btnreset.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            AlertDialog alertDialog = new AlertDialog.Builder(CarCheckListActivity.this).setTitle("Reset")
                    .setMessage("Do you really want to clear data?")
                    .setPositiveButton("Cancel", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            // do nothing
                        }
                    }).setNegativeButton("OK", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            Intent intent = getIntent();
                            SharedPreferences sharedPreferences = getSharedPreferences("mysettings",
                                    Context.MODE_PRIVATE);
                            sharedPreferences.edit().clear().commit();

                            /*
                             * int CheckDocumentTotal,
                             * CheckPowerTotal, CheckEngineTotal,
                             * CheckExteriorTotal,
                             * CheckInteriorTotal, PercenDocument,
                             * PercenPower, PercenEngine,
                             * PercenExterior, PercenInterior,
                             * PercenRatio, Checknum,
                             * powerseekbarValue,
                             * engineseekbarValue,
                             * exteriorseekbarValue,
                             * interiorseekbarValue,
                             * documentseekbarValue, sumPriority,
                             * PowerPriority, EnginePriority,
                             * ExteriorPriority, InteriorPriority,
                             * DocumentPriority,
                             * documentprogressValue;
                             */

                            /*
                             * Log.i("checkreset",
                             * "BEFORE CLEAR -> CheckDocumentTotal : "
                             * + CheckDocumentTotal);
                             * Log.i("checkreset",
                             * "CheckPowerTotal : " +
                             * CheckPowerTotal); Log.i("checkreset",
                             * "CheckEngineTotal : " +
                             * CheckEngineTotal);
                             * Log.i("checkreset",
                             * "CheckExteriorTotal : " +
                             * CheckExteriorTotal);
                             * Log.i("checkreset",
                             * "CheckInteriorTotal : " +
                             * CheckInteriorTotal);
                             * Log.i("checkreset",
                             * "PercenDocument : " +
                             * PercenDocument); Log.i("checkreset",
                             * "PercenPower : " + PercenPower);
                             * Log.i("checkreset", "PercenEngine : "
                             * + PercenEngine); Log.i("checkreset",
                             * "PercenExterior : " +
                             * PercenExterior); Log.i("checkreset",
                             * "PercenInterior : " +
                             * PercenInterior); Log.i("checkreset",
                             * "PercenRatio : " + PercenRatio);
                             * Log.i("checkreset", "Checknum : " +
                             * Checknum); Log.i("checkreset",
                             * "powerseekbarValue : " +
                             * powerseekbarValue);
                             * Log.i("checkreset",
                             * "engineseekbarValue : " +
                             * engineseekbarValue);
                             * Log.i("checkreset",
                             * "interiorseekbarValue : " +
                             * interiorseekbarValue);
                             * Log.i("checkreset",
                             * "exteriorseekbarValue : " +
                             * exteriorseekbarValue);
                             * Log.i("checkreset",
                             * "documentseekbarValue : " +
                             * documentseekbarValue);
                             * Log.i("checkreset", "sumPriority : "
                             * + sumPriority); Log.i("checkreset",
                             * "PowerPriority : " + PowerPriority);
                             * Log.i("checkreset",
                             * "EnginePriority : " +
                             * EnginePriority); Log.i("checkreset",
                             * "ExteriorPriority : " +
                             * ExteriorPriority);
                             * Log.i("checkreset",
                             * "InteriorPriority : " +
                             * InteriorPriority);
                             * Log.i("checkreset",
                             * "DocumentPriority : " +
                             * DocumentPriority);
                             */

                            getIntent().removeExtra("power");
                            getIntent().removeExtra("engine");
                            getIntent().removeExtra("exterior");
                            getIntent().removeExtra("interior");
                            getIntent().removeExtra("document");
                            //startActivity(intent);
                            Intent ii = new Intent(getApplicationContext(), CarCheckListActivity.class);
                            startActivity(ii);
                            finish();

                        }
                    }).show();
        }
    });

    Button btnChangeLanguage = (Button) settingdialog.getWindow().findViewById(R.id.change_language);
    btnChangeLanguage.setTypeface(type);
    btnChangeLanguage.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            Intent myIntent = new Intent(CarCheckListActivity.this, ChangeLanguage.class);

            // th
            myIntent.putExtra("power", PercenPower);
            myIntent.putExtra("engine", PercenEngine);
            myIntent.putExtra("exterior", PercenExterior);
            myIntent.putExtra("interior", PercenInterior);
            myIntent.putExtra("document", PercenDocument);
            myIntent.putExtra("numpower", CheckPowerTotal);
            myIntent.putExtra("numengine", CheckEngineTotal);
            myIntent.putExtra("numexterior", CheckExteriorTotal);
            myIntent.putExtra("numinterior", CheckInteriorTotal);
            myIntent.putExtra("numdocument", CheckDocumentTotal);

            SharedPreferences shared = getSharedPreferences("mysettings", Context.MODE_PRIVATE);
            Editor editor = shared.edit();
            int powerBar = shared.getInt("Powerbar", 0);
            int engineBar = shared.getInt("Enginebar", 0);
            int exteriorBar = shared.getInt("Exteriorbar", 0);
            int interiorBar = shared.getInt("Interiorbar", 0);
            int documentBar = shared.getInt("Documentbar", 0);

            Log.i("power_setting", "power setting : " + powerBar);
            Log.i("engine_setting", "engine setting : " + engineBar);
            Log.i("exterior_setting", "exterior setting : " + exteriorBar);
            Log.i("interior_setting", "interior setting : " + interiorBar);
            Log.i("document_setting", "document setting : " + documentBar);

            Log.i("checkInList", "Check in List : " + shared.getInt("checknum", 0));
            CarCheckListActivity.this.startActivity(myIntent);
            finish();
        }
    });

    Button btnRecord = (Button) settingdialog.getWindow().findViewById(R.id.record);
    btnRecord.setTypeface(type);

    btnRecord.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.i("record", "record onClick");
            final AlertDialog.Builder adb = new AlertDialog.Builder(getApplicationContext());
            adb.setTitle("Warning Dialog");
            adb.setMessage("you must select more than one checklist.");
            adb.setPositiveButton("Ok", null);

            SharedPreferences shared = getSharedPreferences("mysettings", MODE_PRIVATE);

            powerWeight = shared.getInt("Powerbar", 0);
            engineWeight = shared.getInt("Enginebar", 0);
            exteriorWeight = shared.getInt("Exteriorbar", 0);
            interiorWeight = shared.getInt("Interiorbar", 0);
            documentWeight = shared.getInt("Documentbar", 0);

            String display = "before record activity >> " + powerWeight + "|" + engineWeight + "|"
                    + exteriorWeight + "|" + interiorWeight + "|" + documentWeight;
            Log.i("display", display);

            Log.i("checklist", "" + PercenPower);
            Log.i("checklist", "" + PercenEngine);
            Log.i("checklist", "" + PercenExterior);
            Log.i("checklist", "" + PercenInterior);
            Log.i("checklist", "" + PercenDocument);

            // checking scope
            isSaveCheckBox();
            // progressCheckListLog();
            // checking scope

            CarCheckListActivity.this.startActivity(intent);
            finish();
        }
    });

    Button btnList = (Button) settingdialog.getWindow().findViewById(R.id.list);
    btnList.setTypeface(type);

    btnList.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Checknumcheckbox();

            Intent listSaving = new Intent(getApplicationContext(), ListSaveActivity.class);
            startActivity(listSaving);
            finish();
        }
    });

    headsetting.setVisibility(ImageView.VISIBLE);
    TranslateAnimation slideheadsetting = new TranslateAnimation(0, 0, -468, 0);
    slideheadsetting.setDuration(500);
    slideheadsetting.setFillAfter(true);
    headsetting.startAnimation(slideheadsetting);

    settingdialog.show();

    WindowManager.LayoutParams params = settingdialog.getWindow().getAttributes();
    params.y = 0;
    params.x = 60;
    params.gravity = Gravity.TOP | Gravity.LEFT;
    settingdialog.getWindow().setAttributes(params);

    powerseekbarValue = mSharedPrefs.getInt("Powerbar", 0);
    engineseekbarValue = mSharedPrefs.getInt("Enginebar", 0);
    exteriorseekbarValue = mSharedPrefs.getInt("Exteriorbar", 0);
    interiorseekbarValue = mSharedPrefs.getInt("Interiorbar", 0);
    documentseekbarValue = mSharedPrefs.getInt("Documentbar", 0);

    PowerPriority = powerseekbarValue + 1;
    EnginePriority = engineseekbarValue + 1;
    ExteriorPriority = exteriorseekbarValue + 1;
    InteriorPriority = interiorseekbarValue + 1;
    DocumentPriority = documentseekbarValue + 1;

    /*
     * powerseekbar.setProgress(mSharedPrefs.getInt("Powerbar", 0));
     * engineseekbar.setProgress(mSharedPrefs.getInt("Enginebar", 0));
     * exteriorseekbar.setProgress(mSharedPrefs.getInt("Exteriorbar", 0));
     * interiorseekbar.setProgress(mSharedPrefs.getInt("Interior", 0));
     * documentseekbar.setProgress(mSharedPrefs.getInt("Documentbar", 0));
     */

    powerseekbar.setProgress(powerseekbarValue);
    engineseekbar.setProgress(engineseekbarValue);
    exteriorseekbar.setProgress(exteriorseekbarValue);
    interiorseekbar.setProgress(interiorseekbarValue);
    documentseekbar.setProgress(documentseekbarValue);

}

From source file:com.nttec.everychan.ui.presentation.BoardFragment.java

/**
 *  ?  ? ?//  w ww . ja v a 2 s.co  m
 * @param itemPosition ? ? (?)   listView
 * @param isTablet true, ?   (??   ? ??)
 * @param coordinates   ??
 */
private void showPostPopupDialog(final int itemPosition, final boolean isTablet, final Point coordinates,
        final String refererPost) {
    final int bgShadowResource = ThemeUtils.getThemeResId(activity.getTheme(), R.attr.dialogBackgroundShadow);
    final int bgColor = ThemeUtils.getThemeColor(activity.getTheme(), R.attr.activityRootBackground,
            Color.BLACK);
    final int measuredWidth = isTablet ? adapter.measureViewWidth(itemPosition) : -1; //? ??  ? 
    final View tmpV = new View(activity);
    final Dialog tmpDlg = new Dialog(activity);
    tmpDlg.getWindow().setBackgroundDrawableResource(bgShadowResource);
    tmpDlg.requestWindowFeature(Window.FEATURE_NO_TITLE);
    tmpDlg.setCanceledOnTouchOutside(true);
    tmpDlg.setContentView(tmpV);
    final Rect activityWindowRect;
    final int dlgWindowWidth;
    final int dlgWindowHeight;
    if (isTablet) {
        activityWindowRect = new Rect();
        activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(activityWindowRect);
        dlgWindowWidth = Math.max(coordinates.x, activityWindowRect.width() - coordinates.x);
        dlgWindowHeight = Math.max(coordinates.y, activityWindowRect.height() - coordinates.y);
        tmpDlg.getWindow().setLayout(dlgWindowWidth, dlgWindowHeight);
    } else {
        activityWindowRect = null;
        dlgWindowWidth = -1;
        dlgWindowHeight = -1;
    }
    tmpDlg.show();

    Runnable next = new Runnable() {
        @SuppressLint("RtlHardcoded")
        @Override
        public void run() {
            int dlgWidth = tmpV.getWidth();
            int dlgHeight = tmpV.getHeight();
            tmpDlg.hide();
            tmpDlg.cancel();
            int newWidth = isTablet ? Math.min(measuredWidth, dlgWidth) : dlgWidth;

            View view = adapter.getView(itemPosition, null, null, newWidth, refererPost);
            view.setBackgroundColor(bgColor);
            //Logger.d(TAG, "measured: "+view.findViewById(R.id.post_frame_main).getMeasuredWidth()+
            //        "x"+view.findViewById(R.id.post_frame_main).getMeasuredHeight());

            Dialog dialog = new Dialog(activity);
            dialog.getWindow().setBackgroundDrawableResource(bgShadowResource);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setCanceledOnTouchOutside(true);
            dialog.setContentView(view);
            if (isTablet) {
                view.findViewById(R.id.post_frame_main).measure(
                        MeasureSpec.makeMeasureSpec(newWidth, MeasureSpec.EXACTLY),
                        MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
                int newWindowWidth = dlgWindowWidth - dlgWidth + newWidth;
                int newWindowHeight = dlgWindowHeight - dlgHeight
                        + Math.min(view.findViewById(R.id.post_frame_main).getMeasuredHeight(), dlgHeight);
                dialog.getWindow().setLayout(newWindowWidth, newWindowHeight);
                WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
                if (coordinates.x > activityWindowRect.width() - coordinates.x
                        && coordinates.x + newWindowWidth > activityWindowRect.width()) {
                    params.x = activityWindowRect.width() - coordinates.x;
                    params.gravity = Gravity.RIGHT;
                } else {
                    params.x = coordinates.x;
                    params.gravity = Gravity.LEFT;
                }
                if (coordinates.y > activityWindowRect.height() - coordinates.y
                        && coordinates.y + newWindowHeight > activityWindowRect.height()) {
                    params.y = activityWindowRect.height() - coordinates.y;
                    params.gravity |= Gravity.BOTTOM;
                } else {
                    params.y = coordinates.y;
                    params.gravity |= Gravity.TOP;
                }
                dialog.getWindow().setAttributes(params);

                //     
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    CompatibilityImpl.setDimAmount(dialog.getWindow(), 0.1f);
                } else {
                    dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
                }
            }
            dialog.show();
            dialogs.add(dialog);
        }
    };

    if (tmpV.getWidth() != 0) {
        next.run();
    } else {
        AppearanceUtils.callWhenLoaded(tmpDlg.getWindow().getDecorView(), next);
    }
}

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

@Override
public void onBufferSelected(int bid) {
    launchBid = -1;/*from w  ww  .java  2  s . com*/
    launchURI = null;
    cidToOpen = -1;
    bufferToOpen = null;
    setIntent(new Intent(this, MainActivity.class));

    if (suggestionsTimerTask != null)
        suggestionsTimerTask.cancel();
    sortedChannels = null;
    sortedUsers = null;

    if (drawerLayout != null) {
        drawerLayout.closeDrawers();
    }
    if (bid != -1 && conn != null && conn.getUserInfo() != null) {
        conn.getUserInfo().last_selected_bid = bid;
    }
    for (int i = 0; i < backStack.size(); i++) {
        if (buffer != null && backStack.get(i) == buffer.bid)
            backStack.remove(i);
    }
    if (buffer != null && buffer.bid >= 0 && bid != buffer.bid) {
        backStack.add(0, buffer.bid);
        buffer.draft = messageTxt.getText().toString();
    }
    if (buffer == null || buffer.bid == -1 || buffer.cid == -1 || buffer.bid == bid)
        shouldFadeIn = false;
    else
        shouldFadeIn = true;
    buffer = BuffersDataSource.getInstance().getBuffer(bid);
    if (buffer != null) {
        Crashlytics.log(Log.DEBUG, "IRCCloud",
                "Buffer selected: cid" + buffer.cid + " bid" + bid + " shouldFadeIn: " + shouldFadeIn);
        server = ServersDataSource.getInstance().getServer(buffer.cid);

        try {
            TreeMap<Long, EventsDataSource.Event> events = EventsDataSource.getInstance()
                    .getEventsForBuffer(buffer.bid);
            if (events != null) {
                events = (TreeMap<Long, EventsDataSource.Event>) events.clone();
                for (EventsDataSource.Event e : events.values()) {
                    if (e != null && e.highlight && e.from != null) {
                        UsersDataSource.User u = UsersDataSource.getInstance().getUser(buffer.bid, e.from);
                        if (u != null && u.last_mention < e.eid)
                            u.last_mention = e.eid;
                    }
                }
            }
        } catch (Exception e) {
            Crashlytics.logException(e);
        }

        try {
            if (Build.VERSION.SDK_INT >= 16 && buffer != null && server != null) {
                NfcAdapter nfc = NfcAdapter.getDefaultAdapter(this);
                if (nfc != null) {
                    String uri = "irc";
                    if (server.ssl > 0)
                        uri += "s";
                    uri += "://" + server.hostname + ":" + server.port;
                    if (buffer.type.equals("channel")) {
                        uri += "/" + URLEncoder.encode(buffer.name, "UTF-8");
                        ChannelsDataSource.Channel c = ChannelsDataSource.getInstance()
                                .getChannelForBuffer(buffer.bid);
                        if (c != null && c.hasMode("k"))
                            uri += "," + c.paramForMode("k");
                    }
                    nfc.setNdefPushMessage(new NdefMessage(NdefRecord.createUri(uri)), this);
                }
            }
        } catch (Exception e) {
        }
    } else {
        Crashlytics.log(Log.DEBUG, "IRCCloud",
                "Buffer selected but not found: bid" + bid + " shouldFadeIn: " + shouldFadeIn);
        server = null;
    }
    update_subtitle();
    final Bundle b = new Bundle();
    if (buffer != null)
        b.putInt("cid", buffer.cid);
    b.putInt("bid", bid);
    b.putBoolean("fade", shouldFadeIn);
    BuffersListFragment blf = (BuffersListFragment) getSupportFragmentManager()
            .findFragmentById(R.id.BuffersList);
    final MessageViewFragment mvf = (MessageViewFragment) getSupportFragmentManager()
            .findFragmentById(R.id.messageViewFragment);
    UsersListFragment ulf = (UsersListFragment) getSupportFragmentManager()
            .findFragmentById(R.id.usersListFragment);
    UsersListFragment ulf2 = (UsersListFragment) getSupportFragmentManager()
            .findFragmentById(R.id.usersListFragment2);
    if (mvf != null)
        mvf.ready = false;
    if (blf != null)
        blf.setSelectedBid(bid);
    if (ulf != null)
        ulf.setArguments(b);
    if (ulf2 != null)
        ulf2.setArguments(b);

    if (shouldFadeIn) {
        Crashlytics.log(Log.DEBUG, "IRCCloud", "Fade Out");
        if (Build.VERSION.SDK_INT < 16) {
            AlphaAnimation anim = new AlphaAnimation(1, 0);
            anim.setDuration(150);
            anim.setFillAfter(true);
            anim.setAnimationListener(new Animation.AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {

                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    if (mvf != null)
                        mvf.setArguments(b);
                    messageTxt.setText("");
                    if (buffer != null && buffer.draft != null)
                        messageTxt.append(buffer.draft);
                }

                @Override
                public void onAnimationRepeat(Animation animation) {

                }
            });
            try {
                mvf.getListView().startAnimation(anim);
                ulf.getListView().startAnimation(anim);
            } catch (Exception e) {

            }
        } else {
            mvf.getListView().animate().alpha(0).withEndAction(new Runnable() {
                @Override
                public void run() {
                    if (mvf != null)
                        mvf.setArguments(b);
                    messageTxt.setText("");
                    if (buffer != null && buffer.draft != null)
                        messageTxt.append(buffer.draft);
                }
            });
            ulf.getListView().animate().alpha(0);
        }
        mvf.showSpinner(true);
    } else {
        if (mvf != null)
            mvf.setArguments(b);
        messageTxt.setText("");
        if (buffer != null && buffer.draft != null)
            messageTxt.append(buffer.draft);
    }

    updateUsersListFragmentVisibility();
    supportInvalidateOptionsMenu();
    if (excludeBIDTask != null)
        excludeBIDTask.cancel(true);
    excludeBIDTask = new ExcludeBIDTask();
    excludeBIDTask.execute(bid);
    if (drawerLayout != null)
        new RefreshUpIndicatorTask().execute((Void) null);
    if (buffer != null && buffer.cid != -1) {
        if (drawerLayout != null) {
            drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.LEFT);
            getSupportActionBar().setHomeButtonEnabled(true);
        }
    }
    update_suggestions(false);
}

From source file:com.klinker.android.launcher.launcher3.Launcher.java

private void setupDrawer() {
    mWorkspace.setOnPageChangedListener(new Workspace.OnPageChangeListener() {
        @Override/*from  w w w  . j  a va 2s. com*/
        public void onPageChanged(int page) {
            if (mLauncherDrawer == null) {
                return;
            }

            if (mLauncherDrawer.getDrawerLockMode(Gravity.LEFT) == LauncherDrawerLayout.LOCK_MODE_LOCKED_CLOSED
                    && !mWorkspace.isSmall()) {
                lockLauncherDrawer(false);
            }

            if (page == 0) {
                // on the first page
                mLauncherDrawer.setDrawerLeftEdgeSize(Launcher.this, 1.0f);
            } else {
                // somewhere in the middle
                mLauncherDrawer.setDrawerLeftEdgeSize(Launcher.this, .07f);
            }
        }

        @Override
        public void onScrollStart() {
            lockLauncherDrawer(true);
        }

        @Override
        public void onScrollEnd() {

        }
    });

    mDrawerPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            mLauncherDrawer.setCurrentDrawerPage(position);
        }
    });

    mLauncherDrawer.setDrawerListener(new LauncherDrawerLayout.DrawerListener() {
        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            if (drawerView == mDrawerPager) {
                mDragLayer.setTranslationX(getScreenWidth() * slideOffset);
                ((PagesFragmentAdapter) mDrawerPager.getAdapter())
                        .adjustFragmentBackgroundAlpha(mDrawerPager.getCurrentItem(), slideOffset);
            } else {
                mDragLayer.setTranslationX(getScreenWidth() * slideOffset * -1);
                for (View v : ((BaseLauncherPage) extraFragment).getBackground()) {
                    v.setAlpha(slideOffset);
                }
            }
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            if (drawerView == mDrawerPager) {
                mDragLayer.setTranslationX(getScreenWidth());
            } else {
                mDragLayer.setTranslationX(getScreenWidth() * -1);
            }

            sendBroadcast(new Intent("com.klinker.android.launcher.FRAGMENTS_OPENED"));
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            mDragLayer.setTranslationX(0);
            sendBroadcast(new Intent("com.klinker.android.launcher.FRAGMENTS_CLOSED"));

            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(mLauncherDrawer.getWindowToken(), 0);
        }

        @Override
        public void onDrawerStateChanged(int newState) {
        }

        private int screenWidth = -1;

        private int getScreenWidth() {
            if (screenWidth == -1) {
                Display display = getWindowManager().getDefaultDisplay();
                Point size = new Point();
                display.getSize(size);
                screenWidth = size.x;
            }

            return screenWidth;
        }
    });

}

From source file:com.klinker.android.launcher.launcher3.Launcher.java

public void lockLauncherDrawer(boolean locked) {
    if (locked) {
        mLauncherDrawer.setDrawerLockMode(LauncherDrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.LEFT);
    } else {//  ww w .ja v a 2 s. c om
        mLauncherDrawer.setDrawerLockMode(LauncherDrawerLayout.LOCK_MODE_UNLOCKED, Gravity.LEFT);
    }

    mLauncherDrawer.setDrawerLockMode(LauncherDrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT);
}