Example usage for android.app ProgressDialog ProgressDialog

List of usage examples for android.app ProgressDialog ProgressDialog

Introduction

In this page you can find the example usage for android.app ProgressDialog ProgressDialog.

Prototype

public ProgressDialog(Context context) 

Source Link

Document

Creates a Progress dialog.

Usage

From source file:com.ccxt.whl.activity.LoginActivity.java

private void userinfo(String accessToken) {
    final ProgressDialog pd = new ProgressDialog(this);
    pd.setMessage("?...");
    pd.show();//w  ww . j  av a2s  .  c  o  m

    mAuthorization.getUserInfo(accessToken, new UserInfoListener() {

        @Override
        public void onSuccess(FrontiaUser.FrontiaUserDetail result) {
            //if (null != mResultTextView) {
            Log.d("log useid===>" + result.getId());
            Log.d("log AccessToken===>" + result.getAccessToken());
            Log.d("log BaiduAccessToken===>" + result.getBaiduAccessToken());
            Log.d("log MediaUserId===>" + result.getMediaUserId());
            //Log.d("log MediaUserId===>"+result.get);

            String resultStr = "username:" + result.getName() + "\n" + "birthday:" + result.getBirthday() + "\n"
                    + "city:" + result.getCity() + "\n" + "province:" + result.getProvince() + "\n" + "sex:"
                    + result.getSex() + "\n" + "pic url:" + result.getHeadUrl() + "\n";
            Log.d("log userinfo===>" + resultStr);

            sex = "" + result.getSex();
            birthday = result.getBirthday();
            headurl = result.getHeadUrl();
            province = result.getProvince();
            city = result.getCity();

            RequestParams params = new RequestParams();
            params.add("name", name);
            params.add("access_token", access_token);
            params.add("sex", sex);
            params.add("birthday", birthday);
            params.add("headurl", headurl);
            params.add("province", province);
            params.add("city", city);
            params.add("meida_type", "sinaweibo");
            params.add("meida_uid", meida_uid);
            //id
            params.add("uid", uid);

            /*
             //Log.d("log",response);
                  try {
                     Map<String, Object> lm = JsonToMapList.getMap(response);
                       Map<String, Object> result = JsonToMapList.getMap(lm.get("result").toString());
                       String resultStr = "status:" + lm.get("status") + "\n"
                         + "message:" + lm.get("message") + "\n"
                         + "result:" + lm.get("result") + "\n"
                         + "uid:" + result.get("uid") + "\n"
                         + "umd5:" + result.get("umd5") + "\n"
                         + "is_res:" + result.get("is_res") + "\n";
                       Log.d("log",resultStr);
             } catch (Exception e) {
                // TODO: handle exception
             }
                         
                         
                 //String huanxin_username = MD5.MD5Hash(result.getName());
             //String huanxin_pwd = MD5.MD5Hash(result.getName());
             //s_reg_login(huanxin_username, huanxin_pwd);
             */

            HttpRestClient.get(Constant.S_LOGIN_URL, params, new BaseJsonHttpResponseHandler() {

                @Override
                public void onSuccess(int statusCode, Header[] headers, String rawJsonResponse,
                        Object response) {
                    // TODO Auto-generated method stub
                    Log.d("log" + rawJsonResponse);
                    //if(str != null && str.length()!= 0){//?   
                    //}
                    if (!LoginActivity.this.isFinishing())
                        pd.dismiss();

                    if (CommonUtils.isNullOrEmpty(rawJsonResponse)) {
                        Toast.makeText(getApplicationContext(), "?,?", 0)
                                .show();
                        return;
                    }
                    Map<String, Object> lm = JsonToMapList.getMap(rawJsonResponse);

                    if (CommonUtils.isNullOrEmpty(lm.get("result").toString())) {
                        //if(false){

                    } else {
                        Map<String, Object> result = JsonToMapList.getMap(lm.get("result").toString());
                        String resultStr = "status:" + lm.get("status") + "\n" + "message:" + lm.get("message")
                                + "\n" + "result:" + lm.get("result") + "\n" + "uid:" + result.get("uid") + "\n"
                                + "umd5:" + result.get("umd5") + "\n" + "is_res:" + result.get("is_res") + "\n"
                                + "headurl:" + result.get("headurl") + "\n" + "name:" + result.get("name")
                                + "\n" + "sex:" + result.get("sex") + "\n" + "age:" + result.get("age") + "\n"
                                + "province:" + result.get("province") + "\n" + "city:" + result.get("city")
                                + "\n" + "pwd:" + result.get("pwd") + "\n";
                        Log.d("log" + resultStr);
                        //???id nullsaveinfo Preference
                        //DemoApplication.getInstance().setUser(result.get("umd5").toString());
                        //System.out.println("========================"+result.get("umd5").toString());
                        /********/
                        PreferenceUtils.getInstance(getBaseContext())
                                .setSettingUserPic(result.get("headurl").toString());
                        PreferenceUtils.getInstance(getBaseContext())
                                .setSettingUserNickName(result.get("name").toString());
                        PreferenceUtils.getInstance(getBaseContext())
                                .setSettingUserSex(result.get("sex").toString());
                        PreferenceUtils.getInstance(getBaseContext())
                                .setSettingUserAge(result.get("age").toString());
                        PreferenceUtils.getInstance(getBaseContext()).setSettingUserArea(
                                result.get("province").toString() + " " + result.get("city").toString());
                        PreferenceUtils.getInstance(getBaseContext())
                                .setSettingUserZhiye(result.get("zhiye").toString());
                        PreferenceUtils.getInstance(getBaseContext())
                                .setSettingUserQianming(result.get("qianming").toString());

                        String huanxin_username = result.get("umd5").toString();
                        String huanxin_pwd = result.get("pwd").toString();
                        Log.d("log huanxin_username:" + huanxin_username + "|huanxin_pwd:" + huanxin_pwd
                                + "|token:" + access_token);
                        //???
                        if (result.get("is_res").toString().equals("yes")) {
                            login(huanxin_username, huanxin_pwd);
                        } else {
                            s_reg_login(huanxin_username, huanxin_pwd);
                        }

                    }

                }

                @Override
                public void onFailure(int statusCode, Header[] headers, Throwable throwable, String rawJsonData,
                        Object errorResponse) {
                    pd.dismiss();
                    Toast.makeText(getApplicationContext(), ",?", 0).show();
                    return;
                    // TODO Auto-generated method stub

                }

                @Override
                protected Object parseResponse(String rawJsonData, boolean isFailure) throws Throwable {
                    // TODO Auto-generated method stub
                    return null;
                }
            });

        }

        @Override
        public void onFailure(int errCode, String errMsg) {
            Log.d("log nihao ===>" + "errCode:" + errCode + ", errMsg:" + errMsg);
            sex = "";
            birthday = "";
            headurl = "";
            province = "";
            city = "";
            pd.dismiss();
            Toast.makeText(getApplicationContext(), "????", 0).show();
            return;
        }

    });
}

From source file:com.money.manager.ex.sync.SyncManager.java

public void invokeSyncService(String action) {
    // Validation.
    String remoteFile = getRemotePath();
    // We need a value in remote file name preferences.
    if (TextUtils.isEmpty(remoteFile))
        return;/*from ww  w.  j a  va  2 s .c  o m*/

    // Action

    ProgressDialog progressDialog = null;
    // Create progress dialog only if called from the UI.
    if ((getContext() instanceof Activity)) {
        //progress dialog shown only when downloading an updated db file.
        progressDialog = new ProgressDialog(getContext());
        progressDialog.setCancelable(false);
        progressDialog.setMessage(getContext().getString(R.string.syncProgress));
        progressDialog.setIndeterminate(true);
        //            progressDialog.show();
    }
    Messenger messenger = null;
    if (getContext() instanceof Activity) {
        // Messenger handles received messages from the sync service. Can run only in a looper thread.
        messenger = new Messenger(new SyncServiceMessageHandler(getContext(), progressDialog, remoteFile));
    }

    String localFile = getDatabases().getCurrent().localPath;

    Intent syncServiceIntent = IntentFactory.getSyncServiceIntent(getContext(), action, localFile, remoteFile,
            messenger);
    // start service
    getContext().startService(syncServiceIntent);

    // Reset any other scheduled uploads as the current operation will modify the files.
    abortScheduledUpload();

    // The messages from the service are received via messenger.
}

From source file:com.piusvelte.sonet.SonetNotifications.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    final ProgressDialog loadingDialog = new ProgressDialog(this);
    final AsyncTask<Integer, String, Boolean> asyncTask = new AsyncTask<Integer, String, Boolean>() {

        @Override/*from w w  w. jav  a 2s  .  c  o  m*/
        protected Boolean doInBackground(Integer... arg0) {
            if (arg0[0] == R.id.menu_notifications_refresh) {
                // select all accounts with notifications set
                Cursor widgets = getContentResolver().query(
                        Widgets_settings.getDistinctContentUri(SonetNotifications.this),
                        new String[] { Widgets.ACCOUNT }, Widgets.ACCOUNT + "!=-1 and (" + Widgets.LIGHTS
                                + "=1 or " + Widgets.VIBRATE + "=1 or " + Widgets.SOUND + "=1)",
                        null, null);
                if (widgets.moveToFirst()) {
                    mSonetCrypto = SonetCrypto.getInstance(getApplicationContext());
                    HttpClient httpClient = SonetHttpClient.getThreadSafeClient(getApplicationContext());
                    while (!widgets.isAfterLast()) {
                        long accountId = widgets.getLong(0);
                        ArrayList<String> notificationSids = new ArrayList<String>();
                        Cursor account = getContentResolver().query(
                                Accounts.getContentUri(SonetNotifications.this),
                                new String[] { Accounts.TOKEN, Accounts.SECRET, Accounts.SERVICE,
                                        Accounts.SID },
                                Accounts._ID + "=?", new String[] { Long.toString(accountId) }, null);
                        if (account.moveToFirst()) {
                            // for each account, for each notification, check for updates
                            // if there are no updates past 24hrs and cleared, delete
                            String token = mSonetCrypto.Decrypt(account.getString(0));
                            String secret = mSonetCrypto.Decrypt(account.getString(1));
                            int service = account.getInt(2);
                            String accountEsid = mSonetCrypto.Decrypt(account.getString(3));
                            mSimpleDateFormat = null;
                            if (service == TWITTER) {
                                Cursor currentNotifications = getContentResolver().query(
                                        Notifications.getContentUri(SonetNotifications.this),
                                        new String[] { Notifications.SID }, Notifications.ACCOUNT + "=?",
                                        new String[] { Long.toString(accountId) }, null);
                                // loop over notifications
                                if (currentNotifications.moveToFirst()) {
                                    // store sids, to avoid duplicates when requesting the latest feed
                                    String sid = mSonetCrypto.Decrypt(currentNotifications.getString(0));
                                    if (!notificationSids.contains(sid)) {
                                        notificationSids.add(sid);
                                    }
                                }
                                currentNotifications.close();
                                // limit to newest status
                                SonetOAuth sonetOAuth = new SonetOAuth(BuildConfig.TWITTER_KEY,
                                        BuildConfig.TWITTER_SECRET, token, secret);
                                String last_sid = null;
                                Cursor last_status = getContentResolver().query(
                                        Statuses.getContentUri(SonetNotifications.this),
                                        new String[] { Statuses.SID }, Statuses.ACCOUNT + "=?",
                                        new String[] { Long.toString(accountId) },
                                        Statuses.CREATED + " ASC LIMIT 1");
                                if (last_status.moveToFirst()) {
                                    last_sid = mSonetCrypto.Decrypt(last_status.getString(0));
                                }
                                last_status.close();
                                // get all mentions since the oldest status for this account
                                String response = SonetHttpClient.httpResponse(httpClient,
                                        sonetOAuth.getSignedRequest(
                                                new HttpGet(String.format(TWITTER_MENTIONS, TWITTER_BASE_URL,
                                                        last_sid != null
                                                                ? String.format(TWITTER_SINCE_ID, last_sid)
                                                                : ""))));
                                if (response != null) {
                                    try {
                                        JSONArray comments = new JSONArray(response);
                                        for (int i = 0, i2 = comments.length(); i < i2; i++) {
                                            JSONObject comment = comments.getJSONObject(i);
                                            JSONObject user = comment.getJSONObject(Suser);
                                            if (!user.getString(Sid).equals(accountEsid)
                                                    && !notificationSids.contains(comment.getString(Sid))) {
                                                String friend = user.getString(Sname);
                                                addNotification(comment.getString(Sid), user.getString(Sid),
                                                        friend, comment.getString("text"),
                                                        parseDate(comment.getString("created_at"),
                                                                TWITTER_DATE_FORMAT),
                                                        accountId, friend + " mentioned you on Twitter");
                                            }
                                        }
                                    } catch (JSONException e) {
                                        Log.e(TAG, service + ":" + e.toString());
                                    }
                                }
                            } else if (service == IDENTICA) {
                                Cursor currentNotifications = getContentResolver().query(
                                        Notifications.getContentUri(SonetNotifications.this),
                                        new String[] { Notifications.SID }, Notifications.ACCOUNT + "=?",
                                        new String[] { Long.toString(accountId) }, null);
                                // loop over notifications
                                if (currentNotifications.moveToFirst()) {
                                    // store sids, to avoid duplicates when requesting the latest feed
                                    String sid = mSonetCrypto.Decrypt(currentNotifications.getString(0));
                                    if (!notificationSids.contains(sid)) {
                                        notificationSids.add(sid);
                                    }
                                }
                                currentNotifications.close();
                                // limit to newest status
                                SonetOAuth sonetOAuth = new SonetOAuth(BuildConfig.IDENTICA_KEY,
                                        BuildConfig.IDENTICA_SECRET, token, secret);
                                String last_sid = null;
                                Cursor last_status = getContentResolver().query(
                                        Statuses.getContentUri(SonetNotifications.this),
                                        new String[] { Statuses.SID }, Statuses.ACCOUNT + "=?",
                                        new String[] { Long.toString(accountId) },
                                        Statuses.CREATED + " ASC LIMIT 1");
                                if (last_status.moveToFirst()) {
                                    last_sid = mSonetCrypto.Decrypt(last_status.getString(0));
                                }
                                last_status.close();
                                // get all mentions since the oldest status for this account
                                String response = SonetHttpClient.httpResponse(httpClient,
                                        sonetOAuth.getSignedRequest(
                                                new HttpGet(String.format(IDENTICA_MENTIONS, IDENTICA_BASE_URL,
                                                        last_sid != null
                                                                ? String.format(IDENTICA_SINCE_ID, last_sid)
                                                                : ""))));
                                if (response != null) {
                                    try {
                                        JSONArray comments = new JSONArray(response);
                                        for (int i = 0, i2 = comments.length(); i < i2; i++) {
                                            JSONObject comment = comments.getJSONObject(i);
                                            JSONObject user = comment.getJSONObject(Suser);
                                            if (!user.getString(Sid).equals(accountEsid)
                                                    && !notificationSids.contains(comment.getString(Sid))) {
                                                String friend = user.getString(Sname);
                                                addNotification(comment.getString(Sid), user.getString(Sid),
                                                        friend, comment.getString("text"),
                                                        parseDate(comment.getString("created_at"),
                                                                TWITTER_DATE_FORMAT),
                                                        accountId, friend + " mentioned you on Identi.ca");
                                            }
                                        }
                                    } catch (JSONException e) {
                                        Log.e(TAG, service + ":" + e.toString());
                                    }
                                }
                            } else {
                                Cursor currentNotifications = getContentResolver().query(
                                        Notifications.getContentUri(SonetNotifications.this),
                                        new String[] { Notifications._ID, Notifications.SID,
                                                Notifications.UPDATED, Notifications.CLEARED,
                                                Notifications.ESID },
                                        Notifications.ACCOUNT + "=?", new String[] { Long.toString(accountId) },
                                        null);
                                if (currentNotifications.moveToFirst()) {
                                    String response;
                                    SonetOAuth sonetOAuth;
                                    switch (service) {
                                    case FACEBOOK:
                                        // loop over notifications
                                        while (!currentNotifications.isAfterLast()) {
                                            long notificationId = currentNotifications.getLong(0);
                                            String sid = mSonetCrypto
                                                    .Decrypt(currentNotifications.getString(1));
                                            long updated = currentNotifications.getLong(2);
                                            boolean cleared = currentNotifications.getInt(3) == 1;
                                            // store sids, to avoid duplicates when requesting the latest feed
                                            if (!notificationSids.contains(sid)) {
                                                notificationSids.add(sid);
                                            }
                                            // get comments for current notifications
                                            if ((response = SonetHttpClient.httpResponse(httpClient,
                                                    new HttpGet(
                                                            String.format(FACEBOOK_COMMENTS, FACEBOOK_BASE_URL,
                                                                    sid, Saccess_token, token)))) != null) {
                                                // check for a newer post, if it's the user's own, then set CLEARED=0
                                                try {
                                                    JSONArray comments = new JSONObject(response)
                                                            .getJSONArray(Sdata);
                                                    int i2 = comments.length();
                                                    if (i2 > 0) {
                                                        for (int i = 0; i < i2; i++) {
                                                            JSONObject comment = comments.getJSONObject(i);
                                                            long created_time = comment.getLong(Screated_time)
                                                                    * 1000;
                                                            if (created_time > updated) {
                                                                // new comment
                                                                ContentValues values = new ContentValues();
                                                                values.put(Notifications.UPDATED, created_time);
                                                                JSONObject from = comment.getJSONObject(Sfrom);
                                                                if (accountEsid.equals(from.getString(Sid))) {
                                                                    // user's own comment, clear the notification
                                                                    values.put(Notifications.CLEARED, 1);
                                                                } else if (cleared) {
                                                                    values.put(Notifications.NOTIFICATION,
                                                                            String.format(getString(
                                                                                    R.string.friendcommented),
                                                                                    from.getString(Sname)));
                                                                    values.put(Notifications.CLEARED, 0);
                                                                } else {
                                                                    values.put(Notifications.NOTIFICATION,
                                                                            String.format(getString(
                                                                                    R.string.friendcommented),
                                                                                    from.getString(Sname)
                                                                                            + " and others"));
                                                                }
                                                                getContentResolver().update(
                                                                        Notifications.getContentUri(
                                                                                SonetNotifications.this),
                                                                        values, Notifications._ID + "=?",
                                                                        new String[] { Long
                                                                                .toString(notificationId) });
                                                            }
                                                        }
                                                    }
                                                } catch (JSONException e) {
                                                    Log.e(TAG, service + ":" + e.toString());
                                                }
                                            }
                                            currentNotifications.moveToNext();
                                        }
                                        // check the latest feed
                                        if ((response = SonetHttpClient.httpResponse(httpClient,
                                                new HttpGet(String.format(FACEBOOK_HOME, FACEBOOK_BASE_URL,
                                                        Saccess_token, token)))) != null) {
                                            try {
                                                JSONArray jarr = new JSONObject(response).getJSONArray(Sdata);
                                                // if there are updates, clear the cache
                                                int d2 = jarr.length();
                                                if (d2 > 0) {
                                                    for (int d = 0; d < d2; d++) {
                                                        JSONObject o = jarr.getJSONObject(d);
                                                        String sid = o.getString(Sid);
                                                        // if already notified, ignore
                                                        if (!notificationSids.contains(sid)) {
                                                            // only parse status types, not photo, video or link
                                                            if (o.has(Stype) && o.has(Sfrom)) {
                                                                JSONObject f = o.getJSONObject(Sfrom);
                                                                if (f.has(Sname) && f.has(Sid)) {
                                                                    String notification = null;
                                                                    String esid = f.getString(Sid);
                                                                    String friend = f.getString(Sname);
                                                                    if (o.has(Sto)) {
                                                                        // handle wall messages from one friend to another
                                                                        JSONObject t = o.getJSONObject(Sto);
                                                                        if (t.has(Sdata)) {
                                                                            JSONObject n = t.getJSONArray(Sdata)
                                                                                    .getJSONObject(0);
                                                                            if (n.has(Sname)) {
                                                                                if (n.has(Sid) && (n
                                                                                        .getString(Sid)
                                                                                        .equals(accountEsid))) {
                                                                                    notification = String
                                                                                            .format(getString(
                                                                                                    R.string.friendcommented),
                                                                                                    friend);
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                    int commentCount = 0;
                                                                    if (o.has(Scomments)) {
                                                                        JSONObject jo = o
                                                                                .getJSONObject(Scomments);
                                                                        if (jo.has(Sdata)) {
                                                                            JSONArray comments = jo
                                                                                    .getJSONArray(Sdata);
                                                                            commentCount = comments.length();
                                                                            // notifications
                                                                            if ((sid != null)
                                                                                    && (commentCount > 0)) {
                                                                                // default hasCommented to whether or not these comments are for the own user's status
                                                                                boolean hasCommented = notification != null
                                                                                        || esid.equals(
                                                                                                accountEsid);
                                                                                for (int c2 = 0; c2 < commentCount; c2++) {
                                                                                    JSONObject c3 = comments
                                                                                            .getJSONObject(c2);
                                                                                    if (c3.has(Sfrom)) {
                                                                                        JSONObject c4 = c3
                                                                                                .getJSONObject(
                                                                                                        Sfrom);
                                                                                        if (c4.getString(Sid)
                                                                                                .equals(accountEsid)) {
                                                                                            if (!hasCommented) {
                                                                                                // the user has commented on this thread, notify any updates
                                                                                                hasCommented = true;
                                                                                            }
                                                                                            // clear any notifications, as the user is already aware
                                                                                            if (notification != null) {
                                                                                                notification = null;
                                                                                            }
                                                                                        } else if (hasCommented) {
                                                                                            // don't notify about user's own comments
                                                                                            // send the parent comment sid
                                                                                            notification = String
                                                                                                    .format(getString(
                                                                                                            R.string.friendcommented),
                                                                                                            c4.getString(
                                                                                                                    Sname));
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                    if (notification != null) {
                                                                        String message = o.has(Smessage)
                                                                                ? o.getString(Smessage)
                                                                                : null;
                                                                        if (!o.getString(Stype).equals(Sstatus)
                                                                                && o.has(Slink)) {
                                                                            message = message == null
                                                                                    ? "[" + o.getString(Stype)
                                                                                            + "]"
                                                                                    : "[" + o.getString(Stype)
                                                                                            + "]";
                                                                        }
                                                                        // new notification
                                                                        addNotification(sid, esid, friend,
                                                                                message,
                                                                                o.getLong(Screated_time) * 1000,
                                                                                accountId, notification);
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            } catch (JSONException e) {
                                                Log.e(TAG, service + ":" + e.toString());
                                            }
                                        }
                                        break;
                                    case MYSPACE:
                                        sonetOAuth = new SonetOAuth(BuildConfig.MYSPACE_KEY,
                                                BuildConfig.MYSPACE_SECRET, token, secret);
                                        // loop over notifications
                                        while (!currentNotifications.isAfterLast()) {
                                            long notificationId = currentNotifications.getLong(0);
                                            String sid = mSonetCrypto
                                                    .Decrypt(currentNotifications.getString(1));
                                            long updated = currentNotifications.getLong(2);
                                            boolean cleared = currentNotifications.getInt(3) == 1;
                                            String esid = mSonetCrypto
                                                    .Decrypt(currentNotifications.getString(4));
                                            // store sids, to avoid duplicates when requesting the latest feed
                                            if (!notificationSids.contains(sid)) {
                                                notificationSids.add(sid);
                                            }
                                            // get comments for current notifications
                                            if ((response = SonetHttpClient.httpResponse(httpClient,
                                                    sonetOAuth.getSignedRequest(new HttpGet(
                                                            String.format(MYSPACE_URL_STATUSMOODCOMMENTS,
                                                                    MYSPACE_BASE_URL, esid, sid))))) != null) {
                                                // check for a newer post, if it's the user's own, then set CLEARED=0
                                                try {
                                                    JSONArray comments = new JSONObject(response)
                                                            .getJSONArray(Sentry);
                                                    int i2 = comments.length();
                                                    if (i2 > 0) {
                                                        for (int i = 0; i < i2; i++) {
                                                            JSONObject comment = comments.getJSONObject(i);
                                                            long created_time = parseDate(
                                                                    comment.getString(SpostedDate),
                                                                    MYSPACE_DATE_FORMAT);
                                                            if (created_time > updated) {
                                                                // new comment
                                                                ContentValues values = new ContentValues();
                                                                values.put(Notifications.UPDATED, created_time);
                                                                JSONObject author = comment
                                                                        .getJSONObject(Sauthor);
                                                                if (accountEsid.equals(author.getString(Sid))) {
                                                                    // user's own comment, clear the notification
                                                                    values.put(Notifications.CLEARED, 1);
                                                                } else if (cleared) {
                                                                    values.put(Notifications.NOTIFICATION,
                                                                            String.format(getString(
                                                                                    R.string.friendcommented),
                                                                                    comment.getString(
                                                                                            SdisplayName)));
                                                                    values.put(Notifications.CLEARED, 0);
                                                                } else {
                                                                    values.put(Notifications.NOTIFICATION,
                                                                            String.format(getString(
                                                                                    R.string.friendcommented),
                                                                                    comment.getString(
                                                                                            SdisplayName)
                                                                                            + " and others"));
                                                                }
                                                                getContentResolver().update(
                                                                        Notifications.getContentUri(
                                                                                SonetNotifications.this),
                                                                        values, Notifications._ID + "=?",
                                                                        new String[] { Long
                                                                                .toString(notificationId) });
                                                            }
                                                        }
                                                    }
                                                } catch (JSONException e) {
                                                    Log.e(TAG, service + ":" + e.toString());
                                                }
                                            }
                                            currentNotifications.moveToNext();
                                        }
                                        // check the latest feed
                                        if ((response = SonetHttpClient
                                                .httpResponse(httpClient,
                                                        sonetOAuth.getSignedRequest(
                                                                new HttpGet(String.format(MYSPACE_HISTORY,
                                                                        MYSPACE_BASE_URL))))) != null) {
                                            try {
                                                JSONArray jarr = new JSONObject(response).getJSONArray(Sentry);
                                                // if there are updates, clear the cache
                                                int d2 = jarr.length();
                                                if (d2 > 0) {
                                                    for (int d = 0; d < d2; d++) {
                                                        JSONObject o = jarr.getJSONObject(d);
                                                        String sid = o.getString(SstatusId);
                                                        // if already notified, ignore
                                                        if (!notificationSids.contains(sid)) {
                                                            if (o.has(Sauthor) && o.has(SrecentComments)) {
                                                                JSONObject f = o.getJSONObject(Sauthor);
                                                                if (f.has(SdisplayName) && f.has(Sid)) {
                                                                    String notification = null;
                                                                    String esid = f.getString(Sid);
                                                                    String friend = f.getString(SdisplayName);
                                                                    JSONArray comments = o
                                                                            .getJSONArray(SrecentComments);
                                                                    int commentCount = comments.length();
                                                                    // notifications
                                                                    if ((sid != null) && (commentCount > 0)) {
                                                                        // default hasCommented to whether or not these comments are for the own user's status
                                                                        boolean hasCommented = notification != null
                                                                                || esid.equals(accountEsid);
                                                                        for (int c2 = 0; c2 < commentCount; c2++) {
                                                                            JSONObject c3 = comments
                                                                                    .getJSONObject(c2);
                                                                            if (c3.has(Sauthor)) {
                                                                                JSONObject c4 = c3
                                                                                        .getJSONObject(Sauthor);
                                                                                if (c4.getString(Sid)
                                                                                        .equals(accountEsid)) {
                                                                                    if (!hasCommented) {
                                                                                        // the user has commented on this thread, notify any updates
                                                                                        hasCommented = true;
                                                                                    }
                                                                                    // clear any notifications, as the user is already aware
                                                                                    if (notification != null) {
                                                                                        notification = null;
                                                                                    }
                                                                                } else if (hasCommented) {
                                                                                    // don't notify about user's own comments
                                                                                    // send the parent comment sid
                                                                                    notification = String
                                                                                            .format(getString(
                                                                                                    R.string.friendcommented),
                                                                                                    c4.getString(
                                                                                                            SdisplayName));
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                    if (notification != null) {
                                                                        // new notification
                                                                        addNotification(sid, esid, friend,
                                                                                o.getString(Sstatus),
                                                                                parseDate(o.getString(
                                                                                        "moodStatusLastUpdated"),
                                                                                        MYSPACE_DATE_FORMAT),
                                                                                accountId, notification);
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            } catch (JSONException e) {
                                                Log.e(TAG, service + ":" + e.toString());
                                            }
                                        }
                                        break;
                                    case FOURSQUARE:
                                        // loop over notifications
                                        while (!currentNotifications.isAfterLast()) {
                                            long notificationId = currentNotifications.getLong(0);
                                            String sid = mSonetCrypto
                                                    .Decrypt(currentNotifications.getString(1));
                                            long updated = currentNotifications.getLong(2);
                                            boolean cleared = currentNotifications.getInt(3) == 1;
                                            // store sids, to avoid duplicates when requesting the latest feed
                                            if (!notificationSids.contains(sid)) {
                                                notificationSids.add(sid);
                                            }
                                            // get comments for current notifications
                                            if ((response = SonetHttpClient.httpResponse(httpClient,
                                                    new HttpGet(String.format(FOURSQUARE_GET_CHECKIN,
                                                            FOURSQUARE_BASE_URL, sid, token)))) != null) {
                                                // check for a newer post, if it's the user's own, then set CLEARED=0
                                                try {
                                                    JSONArray comments = new JSONObject(response)
                                                            .getJSONObject(Sresponse).getJSONObject(Scheckin)
                                                            .getJSONObject(Scomments).getJSONArray(Sitems);
                                                    int i2 = comments.length();
                                                    if (i2 > 0) {
                                                        for (int i = 0; i < i2; i++) {
                                                            JSONObject comment = comments.getJSONObject(i);
                                                            long created_time = comment.getLong(ScreatedAt)
                                                                    * 1000;
                                                            if (created_time > updated) {
                                                                // new comment
                                                                ContentValues values = new ContentValues();
                                                                values.put(Notifications.UPDATED, created_time);
                                                                JSONObject user = comment.getJSONObject(Suser);
                                                                if (accountEsid.equals(user.getString(Sid))) {
                                                                    // user's own comment, clear the notification
                                                                    values.put(Notifications.CLEARED, 1);
                                                                } else if (cleared) {
                                                                    values.put(Notifications.NOTIFICATION,
                                                                            String.format(getString(
                                                                                    R.string.friendcommented),
                                                                                    user.getString(SfirstName)
                                                                                            + " "
                                                                                            + user.getString(
                                                                                                    SlastName)));
                                                                    values.put(Notifications.CLEARED, 0);
                                                                } else {
                                                                    values.put(Notifications.NOTIFICATION,
                                                                            String.format(getString(
                                                                                    R.string.friendcommented),
                                                                                    user.getString(SfirstName)
                                                                                            + " "
                                                                                            + user.getString(
                                                                                                    SlastName)
                                                                                            + " and others"));
                                                                }
                                                                getContentResolver().update(
                                                                        Notifications.getContentUri(
                                                                                SonetNotifications.this),
                                                                        values, Notifications._ID + "=?",
                                                                        new String[] { Long
                                                                                .toString(notificationId) });
                                                            }
                                                        }
                                                    }
                                                } catch (JSONException e) {
                                                    Log.e(TAG, service + ":" + e.toString());
                                                }
                                            }
                                            currentNotifications.moveToNext();
                                        }
                                        // check the latest feed
                                        if ((response = SonetHttpClient.httpResponse(httpClient,
                                                new HttpGet(String.format(FOURSQUARE_CHECKINS,
                                                        FOURSQUARE_BASE_URL, token)))) != null) {
                                            try {
                                                JSONArray jarr = new JSONObject(response)
                                                        .getJSONObject(Sresponse).getJSONArray(Srecent);
                                                // if there are updates, clear the cache
                                                int d2 = jarr.length();
                                                if (d2 > 0) {
                                                    for (int d = 0; d < d2; d++) {
                                                        JSONObject o = jarr.getJSONObject(d);
                                                        String sid = o.getString(Sid);
                                                        // if already notified, ignore
                                                        if (!notificationSids.contains(sid)) {
                                                            if (o.has(Suser) && o.has(Scomments)) {
                                                                JSONObject f = o.getJSONObject(Suser);
                                                                if (f.has(SfirstName) && f.has(SlastName)
                                                                        && f.has(Sid)) {
                                                                    String notification = null;
                                                                    String esid = f.getString(Sid);
                                                                    String friend = f.getString(SfirstName)
                                                                            + " " + f.getString(SlastName);
                                                                    JSONArray comments = o
                                                                            .getJSONArray(Scomments);
                                                                    int commentCount = comments.length();
                                                                    // notifications
                                                                    if (commentCount > 0) {
                                                                        // default hasCommented to whether or not these comments are for the own user's status
                                                                        boolean hasCommented = notification != null
                                                                                || esid.equals(accountEsid);
                                                                        for (int c2 = 0; c2 < commentCount; c2++) {
                                                                            JSONObject c3 = comments
                                                                                    .getJSONObject(c2);
                                                                            if (c3.has(Suser)) {
                                                                                JSONObject c4 = c3
                                                                                        .getJSONObject(Suser);
                                                                                if (c4.getString(Sid)
                                                                                        .equals(accountEsid)) {
                                                                                    if (!hasCommented) {
                                                                                        // the user has commented on this thread, notify any updates
                                                                                        hasCommented = true;
                                                                                    }
                                                                                    // clear any notifications, as the user is already aware
                                                                                    if (notification != null) {
                                                                                        notification = null;
                                                                                    }
                                                                                } else if (hasCommented) {
                                                                                    // don't notify about user's own comments
                                                                                    // send the parent comment sid
                                                                                    notification = String
                                                                                            .format(getString(
                                                                                                    R.string.friendcommented),
                                                                                                    c4.getString(
                                                                                                            SfirstName)
                                                                                                            + " "
                                                                                                            + c4.getString(
                                                                                                                    SlastName));
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                    if (notification != null) {
                                                                        String message = "";
                                                                        if (o.has(Sshout)) {
                                                                            message = o.getString(Sshout)
                                                                                    + "\n";
                                                                        }
                                                                        if (o.has(Svenue)) {
                                                                            JSONObject venue = o
                                                                                    .getJSONObject(Svenue);
                                                                            if (venue.has(Sname)) {
                                                                                message += "@" + venue
                                                                                        .getString(Sname);
                                                                            }
                                                                        }
                                                                        // new notification
                                                                        addNotification(sid, esid, friend,
                                                                                message,
                                                                                o.getLong(ScreatedAt) * 1000,
                                                                                accountId, notification);
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            } catch (JSONException e) {
                                                Log.e(TAG, service + ":" + e.toString());
                                            }
                                        }
                                        break;
                                    case LINKEDIN:
                                        sonetOAuth = new SonetOAuth(BuildConfig.LINKEDIN_KEY,
                                                BuildConfig.LINKEDIN_SECRET, token, secret);
                                        // loop over notifications
                                        while (!currentNotifications.isAfterLast()) {
                                            long notificationId = currentNotifications.getLong(0);
                                            String sid = mSonetCrypto
                                                    .Decrypt(currentNotifications.getString(1));
                                            long updated = currentNotifications.getLong(2);
                                            boolean cleared = currentNotifications.getInt(3) == 1;
                                            // store sids, to avoid duplicates when requesting the latest feed
                                            if (!notificationSids.contains(sid)) {
                                                notificationSids.add(sid);
                                            }
                                            // get comments for current notifications
                                            HttpGet httpGet = new HttpGet(String
                                                    .format(LINKEDIN_UPDATE_COMMENTS, LINKEDIN_BASE_URL, sid));
                                            for (String[] header : LINKEDIN_HEADERS)
                                                httpGet.setHeader(header[0], header[1]);
                                            if ((response = SonetHttpClient.httpResponse(httpClient,
                                                    sonetOAuth.getSignedRequest(httpGet))) != null) {
                                                // check for a newer post, if it's the user's own, then set CLEARED=0
                                                try {
                                                    JSONObject jsonResponse = new JSONObject(response);
                                                    if (jsonResponse.has(S_total)
                                                            && (jsonResponse.getInt(S_total) != 0)) {
                                                        JSONArray comments = jsonResponse.getJSONArray(Svalues);
                                                        int i2 = comments.length();
                                                        if (i2 > 0) {
                                                            for (int i = 0; i < i2; i++) {
                                                                JSONObject comment = comments.getJSONObject(i);
                                                                long created_time = comment.getLong(Stimestamp);
                                                                if (created_time > updated) {
                                                                    // new comment
                                                                    ContentValues values = new ContentValues();
                                                                    values.put(Notifications.UPDATED,
                                                                            created_time);
                                                                    JSONObject person = comment
                                                                            .getJSONObject(Sperson);
                                                                    if (accountEsid
                                                                            .equals(person.getString(Sid))) {
                                                                        // user's own comment, clear the notification
                                                                        values.put(Notifications.CLEARED, 1);
                                                                    } else if (cleared) {
                                                                        values.put(Notifications.NOTIFICATION,
                                                                                String.format(getString(
                                                                                        R.string.friendcommented),
                                                                                        person.getString(
                                                                                                SfirstName)
                                                                                                + " "
                                                                                                + person.getString(
                                                                                                        SlastName)));
                                                                        values.put(Notifications.CLEARED, 0);
                                                                    } else {
                                                                        values.put(Notifications.NOTIFICATION,
                                                                                String.format(getString(
                                                                                        R.string.friendcommented),
                                                                                        person.getString(
                                                                                                SfirstName)
                                                                                                + " "
                                                                                                + person.getString(
                                                                                                        SlastName)
                                                                                                + " and others"));
                                                                    }
                                                                    getContentResolver().update(
                                                                            Notifications.getContentUri(
                                                                                    SonetNotifications.this),
                                                                            values, Notifications._ID + "=?",
                                                                            new String[] { Long.toString(
                                                                                    notificationId) });
                                                                }
                                                            }
                                                        }
                                                    }
                                                } catch (JSONException e) {
                                                    Log.e(TAG, service + ":" + e.toString());
                                                }
                                            }
                                            currentNotifications.moveToNext();
                                        }
                                        // check the latest feed
                                        HttpGet httpGet = new HttpGet(
                                                String.format(LINKEDIN_UPDATES, LINKEDIN_BASE_URL));
                                        for (String[] header : LINKEDIN_HEADERS) {
                                            httpGet.setHeader(header[0], header[1]);
                                        }
                                        if ((response = SonetHttpClient.httpResponse(httpClient,
                                                sonetOAuth.getSignedRequest(httpGet))) != null) {
                                            try {
                                                JSONArray jarr = new JSONObject(response).getJSONArray(Svalues);
                                                // if there are updates, clear the cache
                                                int d2 = jarr.length();
                                                if (d2 > 0) {
                                                    for (int d = 0; d < d2; d++) {
                                                        JSONObject o = jarr.getJSONObject(d);
                                                        String sid = o.getString(SupdateKey);
                                                        // if already notified, ignore
                                                        if (!notificationSids.contains(sid)) {
                                                            String updateType = o.getString(SupdateType);
                                                            JSONObject updateContent = o
                                                                    .getJSONObject(SupdateContent);
                                                            if (LinkedIn_UpdateTypes.contains(updateType)
                                                                    && updateContent.has(Sperson)) {
                                                                JSONObject f = updateContent
                                                                        .getJSONObject(Sperson);
                                                                if (f.has(SfirstName) && f.has(SlastName)
                                                                        && f.has(Sid)
                                                                        && o.has(SupdateComments)) {
                                                                    JSONObject updateComments = o
                                                                            .getJSONObject(SupdateComments);
                                                                    if (updateComments.has(Svalues)) {
                                                                        String notification = null;
                                                                        String esid = f.getString(Sid);
                                                                        JSONArray comments = updateComments
                                                                                .getJSONArray(Svalues);
                                                                        int commentCount = comments.length();
                                                                        // notifications
                                                                        if (commentCount > 0) {
                                                                            // default hasCommented to whether or not these comments are for the own user's status
                                                                            boolean hasCommented = notification != null
                                                                                    || esid.equals(accountEsid);
                                                                            for (int c2 = 0; c2 < commentCount; c2++) {
                                                                                JSONObject c3 = comments
                                                                                        .getJSONObject(c2);
                                                                                if (c3.has(Sperson)) {
                                                                                    JSONObject c4 = c3
                                                                                            .getJSONObject(
                                                                                                    Sperson);
                                                                                    if (c4.getString(Sid)
                                                                                            .equals(accountEsid)) {
                                                                                        if (!hasCommented) {
                                                                                            // the user has commented on this thread, notify any updates
                                                                                            hasCommented = true;
                                                                                        }
                                                                                        // clear any notifications, as the user is already aware
                                                                                        if (notification != null) {
                                                                                            notification = null;
                                                                                        }
                                                                                    } else if (hasCommented) {
                                                                                        // don't notify about user's own comments
                                                                                        // send the parent comment sid
                                                                                        notification = String
                                                                                                .format(getString(
                                                                                                        R.string.friendcommented),
                                                                                                        c4.getString(
                                                                                                                SfirstName)
                                                                                                                + " "
                                                                                                                + c4.getString(
                                                                                                                        SlastName));
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                        if (notification != null) {
                                                                            String update = LinkedIn_UpdateTypes
                                                                                    .getMessage(updateType);
                                                                            if (LinkedIn_UpdateTypes.APPS.name()
                                                                                    .equals(updateType)) {
                                                                                if (f.has(SpersonActivities)) {
                                                                                    JSONObject personActivities = f
                                                                                            .getJSONObject(
                                                                                                    SpersonActivities);
                                                                                    if (personActivities
                                                                                            .has(Svalues)) {
                                                                                        JSONArray updates = personActivities
                                                                                                .getJSONArray(
                                                                                                        Svalues);
                                                                                        for (int u = 0, u2 = updates
                                                                                                .length(); u < u2; u++) {
                                                                                            update += updates
                                                                                                    .getJSONObject(
                                                                                                            u)
                                                                                                    .getString(
                                                                                                            Sbody);
                                                                                            if (u < (updates
                                                                                                    .length()
                                                                                                    - 1))
                                                                                                update += ", ";
                                                                                        }
                                                                                    }
                                                                                }
                                                                            } else if (LinkedIn_UpdateTypes.CONN
                                                                                    .name()
                                                                                    .equals(updateType)) {
                                                                                if (f.has(Sconnections)) {
                                                                                    JSONObject connections = f
                                                                                            .getJSONObject(
                                                                                                    Sconnections);
                                                                                    if (connections
                                                                                            .has(Svalues)) {
                                                                                        JSONArray updates = connections
                                                                                                .getJSONArray(
                                                                                                        Svalues);
                                                                                        for (int u = 0, u2 = updates
                                                                                                .length(); u < u2; u++) {
                                                                                            update += updates
                                                                                                    .getJSONObject(
                                                                                                            u)
                                                                                                    .getString(
                                                                                                            SfirstName)
                                                                                                    + " "
                                                                                                    + updates
                                                                                                            .getJSONObject(
                                                                                                                    u)
                                                                                                            .getString(
                                                                                                                    SlastName);
                                                                                            if (u < (updates
                                                                                                    .length()
                                                                                                    - 1))
                                                                                                update += ", ";
                                                                                        }
                                                                                    }
                                                                                }
                                                                            } else if (LinkedIn_UpdateTypes.JOBP
                                                                                    .name()
                                                                                    .equals(updateType)) {
                                                                                if (updateContent.has(Sjob)
                                                                                        && updateContent
                                                                                                .getJSONObject(
                                                                                                        Sjob)
                                                                                                .has(Sposition)
                                                                                        && updateContent
                                                                                                .getJSONObject(
                                                                                                        Sjob)
                                                                                                .getJSONObject(
                                                                                                        Sposition)
                                                                                                .has(Stitle))
                                                                                    update += updateContent
                                                                                            .getJSONObject(Sjob)
                                                                                            .getJSONObject(
                                                                                                    Sposition)
                                                                                            .getString(Stitle);
                                                                            } else if (LinkedIn_UpdateTypes.JGRP
                                                                                    .name()
                                                                                    .equals(updateType)) {
                                                                                if (f.has(SmemberGroups)) {
                                                                                    JSONObject memberGroups = f
                                                                                            .getJSONObject(
                                                                                                    SmemberGroups);
                                                                                    if (memberGroups
                                                                                            .has(Svalues)) {
                                                                                        JSONArray updates = memberGroups
                                                                                                .getJSONArray(
                                                                                                        Svalues);
                                                                                        for (int u = 0, u2 = updates
                                                                                                .length(); u < u2; u++) {
                                                                                            update += updates
                                                                                                    .getJSONObject(
                                                                                                            u)
                                                                                                    .getString(
                                                                                                            Sname);
                                                                                            if (u < (updates
                                                                                                    .length()
                                                                                                    - 1))
                                                                                                update += ", ";
                                                                                        }
                                                                                    }
                                                                                }
                                                                            } else if (LinkedIn_UpdateTypes.PREC
                                                                                    .name()
                                                                                    .equals(updateType)) {
                                                                                if (f.has(
                                                                                        SrecommendationsGiven)) {
                                                                                    JSONObject recommendationsGiven = f
                                                                                            .getJSONObject(
                                                                                                    SrecommendationsGiven);
                                                                                    if (recommendationsGiven
                                                                                            .has(Svalues)) {
                                                                                        JSONArray updates = recommendationsGiven
                                                                                                .getJSONArray(
                                                                                                        Svalues);
                                                                                        for (int u = 0, u2 = updates
                                                                                                .length(); u < u2; u++) {
                                                                                            JSONObject recommendation = updates
                                                                                                    .getJSONObject(
                                                                                                            u);
                                                                                            JSONObject recommendee = recommendation
                                                                                                    .getJSONObject(
                                                                                                            Srecommendee);
                                                                                            if (recommendee.has(
                                                                                                    SfirstName))
                                                                                                update += recommendee
                                                                                                        .getString(
                                                                                                                SfirstName);
                                                                                            if (recommendee.has(
                                                                                                    SlastName))
                                                                                                update += recommendee
                                                                                                        .getString(
                                                                                                                SlastName);
                                                                                            if (recommendation
                                                                                                    .has(SrecommendationSnippet))
                                                                                                update += ":"
                                                                                                        + recommendation
                                                                                                                .getString(
                                                                                                                        SrecommendationSnippet);
                                                                                            if (u < (updates
                                                                                                    .length()
                                                                                                    - 1))
                                                                                                update += ", ";
                                                                                        }
                                                                                    }
                                                                                }
                                                                            } else if (LinkedIn_UpdateTypes.SHAR
                                                                                    .name().equals(updateType)
                                                                                    && f.has(ScurrentShare)) {
                                                                                JSONObject currentShare = f
                                                                                        .getJSONObject(
                                                                                                ScurrentShare);
                                                                                if (currentShare.has(Scomment))
                                                                                    update = currentShare
                                                                                            .getString(
                                                                                                    Scomment);
                                                                            }
                                                                            // new notification
                                                                            addNotification(sid, esid,
                                                                                    f.getString(SfirstName)
                                                                                            + " "
                                                                                            + f.getString(
                                                                                                    SlastName),
                                                                                    update,
                                                                                    o.getLong(Stimestamp),
                                                                                    accountId, notification);
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            } catch (JSONException e) {
                                                Log.e(TAG, service + ":" + e.toString());
                                            }
                                        }
                                        break;
                                    case GOOGLEPLUS:
                                        // get new access token, need different request here
                                        HttpPost httpPost = new HttpPost(GOOGLE_ACCESS);
                                        List<NameValuePair> httpParams = new ArrayList<NameValuePair>();
                                        httpParams.add(new BasicNameValuePair("client_id",
                                                BuildConfig.GOOGLECLIENT_ID));
                                        httpParams.add(new BasicNameValuePair("client_secret",
                                                BuildConfig.GOOGLECLIENT_SECRET));
                                        httpParams.add(new BasicNameValuePair("refresh_token", token));
                                        httpParams.add(new BasicNameValuePair("grant_type", "refresh_token"));
                                        try {
                                            httpPost.setEntity(new UrlEncodedFormEntity(httpParams));
                                            if ((response = SonetHttpClient.httpResponse(httpClient,
                                                    httpPost)) != null) {
                                                JSONObject j = new JSONObject(response);
                                                if (j.has(Saccess_token)) {
                                                    String access_token = j.getString(Saccess_token);
                                                    while (!currentNotifications.isAfterLast()) {
                                                        long notificationId = currentNotifications.getLong(0);
                                                        String sid = mSonetCrypto
                                                                .Decrypt(currentNotifications.getString(1));
                                                        long updated = currentNotifications.getLong(2);
                                                        boolean cleared = currentNotifications.getInt(3) == 1;
                                                        // store sids, to avoid duplicates when requesting the latest feed
                                                        if (!notificationSids.contains(sid)) {
                                                            notificationSids.add(sid);
                                                        }
                                                        // get comments for current notifications
                                                        if ((response = SonetHttpClient.httpResponse(httpClient,
                                                                new HttpGet(String.format(GOOGLEPLUS_ACTIVITY,
                                                                        GOOGLEPLUS_BASE_URL, sid,
                                                                        access_token)))) != null) {
                                                            // check for a newer post, if it's the user's own, then set CLEARED=0
                                                            try {
                                                                JSONObject item = new JSONObject(response);
                                                                if (item.has(Sobject)) {
                                                                    JSONObject object = item
                                                                            .getJSONObject(Sobject);
                                                                    if (object.has(Sreplies)) {
                                                                        int commentCount = 0;
                                                                        JSONObject replies = object
                                                                                .getJSONObject(Sreplies);
                                                                        if (replies.has(StotalItems)) {
                                                                            //TODO: notifications
                                                                        }
                                                                    }
                                                                }
                                                            } catch (JSONException e) {
                                                                Log.e(TAG, service + ":" + e.toString());
                                                            }
                                                        }
                                                        currentNotifications.moveToNext();
                                                    }
                                                    // get new feed
                                                    if ((response = SonetHttpClient.httpResponse(httpClient,
                                                            new HttpGet(String.format(GOOGLEPLUS_ACTIVITIES,
                                                                    GOOGLEPLUS_BASE_URL, "me", "public", 20,
                                                                    access_token)))) != null) {
                                                        JSONObject r = new JSONObject(response);
                                                        if (r.has(Sitems)) {
                                                            JSONArray items = r.getJSONArray(Sitems);
                                                            for (int i1 = 0, i2 = items
                                                                    .length(); i1 < i2; i1++) {
                                                                JSONObject item = items.getJSONObject(i1);
                                                                if (item.has(Sactor) && item.has(Sobject)) {
                                                                    JSONObject actor = item
                                                                            .getJSONObject(Sactor);
                                                                    JSONObject object = item
                                                                            .getJSONObject(Sobject);
                                                                    if (item.has(Sid) && actor.has(Sid)
                                                                            && actor.has(SdisplayName)
                                                                            && item.has(Spublished)
                                                                            && object.has(Sreplies)
                                                                            && object.has(SoriginalContent)) {
                                                                        String sid = item.getString(Sid);
                                                                        String esid = actor.getString(Sid);
                                                                        String friend = actor
                                                                                .getString(SdisplayName);
                                                                        String originalContent = object
                                                                                .getString(SoriginalContent);
                                                                        if ((originalContent == null)
                                                                                || (originalContent
                                                                                        .length() == 0)) {
                                                                            originalContent = object
                                                                                    .getString(Scontent);
                                                                        }
                                                                        String photo = null;
                                                                        if (actor.has(Simage)) {
                                                                            JSONObject image = actor
                                                                                    .getJSONObject(Simage);
                                                                            if (image.has(Surl)) {
                                                                                photo = image.getString(Surl);
                                                                            }
                                                                        }
                                                                        long date = parseDate(
                                                                                item.getString(Spublished),
                                                                                GOOGLEPLUS_DATE_FORMAT);
                                                                        int commentCount = 0;
                                                                        JSONObject replies = object
                                                                                .getJSONObject(Sreplies);
                                                                        String notification = null;
                                                                        if (replies.has(StotalItems)) {
                                                                            Log.d(TAG, Sreplies + ":"
                                                                                    + replies.toString());
                                                                            commentCount = replies
                                                                                    .getInt(StotalItems);
                                                                        }
                                                                        if (notification != null) {
                                                                            // new notification
                                                                            addNotification(sid, esid, friend,
                                                                                    originalContent, date,
                                                                                    accountId, notification);
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        } catch (UnsupportedEncodingException e) {
                                            Log.e(TAG, e.toString());
                                        } catch (JSONException e) {
                                            Log.e(TAG, e.toString());
                                        }
                                        break;
                                    }
                                }
                                currentNotifications.close();
                            }
                            // remove old notifications
                            getContentResolver().delete(Notifications.getContentUri(SonetNotifications.this),
                                    Notifications.CLEARED + "=1 and " + Notifications.ACCOUNT + "=? and "
                                            + Notifications.CREATED + "<?",
                                    new String[] { Long.toString(accountId),
                                            Long.toString(System.currentTimeMillis() - 86400000) });
                        }
                        account.close();
                        widgets.moveToNext();
                    }
                } else {
                    publishProgress("No notifications have been set up on any accounts.");
                }
                widgets.close();
                return false;
            } else if (arg0[0] == R.id.menu_notifications_clear_all) {
                // clear all notifications
                ContentValues values = new ContentValues();
                values.put(Notifications.CLEARED, 1);
                SonetNotifications.this.getContentResolver()
                        .update(Notifications.getContentUri(SonetNotifications.this), values, null, null);
                return true;
            }
            return false;
        }

        @Override
        protected void onProgressUpdate(String... messages) {
            (Toast.makeText(SonetNotifications.this, messages[0], Toast.LENGTH_LONG)).show();
        }

        @Override
        protected void onPostExecute(Boolean finish) {
            if (loadingDialog.isShowing()) {
                loadingDialog.dismiss();
            }
            if (finish) {
                SonetNotifications.this.finish();
            }
        }

        private void addNotification(String sid, String esid, String friend, String message, long created,
                long accountId, String notification) {
            ContentValues values = new ContentValues();
            values.put(Notifications.SID, sid);
            values.put(Notifications.ESID, esid);
            values.put(Notifications.FRIEND, friend);
            values.put(Notifications.MESSAGE, message);
            values.put(Notifications.CREATED, created);
            values.put(Notifications.ACCOUNT, accountId);
            values.put(Notifications.NOTIFICATION, notification);
            values.put(Notifications.CLEARED, 0);
            values.put(Notifications.UPDATED, created);
            getContentResolver().insert(Notifications.getContentUri(SonetNotifications.this), values);
        }

        private long parseDate(String date, String format) {
            if (date != null) {
                // hack for the literal 'Z'
                if (date.substring(date.length() - 1).equals("Z")) {
                    date = date.substring(0, date.length() - 2) + "+0000";
                }
                Date created = null;
                if (format != null) {
                    if (mSimpleDateFormat == null) {
                        mSimpleDateFormat = new SimpleDateFormat(format, Locale.ENGLISH);
                        // all dates should be GMT/UTC
                        mSimpleDateFormat.setTimeZone(sTimeZone);
                    }
                    try {
                        created = mSimpleDateFormat.parse(date);
                        return created.getTime();
                    } catch (ParseException e) {
                        Log.e(TAG, e.toString());
                    }
                } else {
                    // attempt to parse RSS date
                    if (mSimpleDateFormat != null) {
                        try {
                            created = mSimpleDateFormat.parse(date);
                            return created.getTime();
                        } catch (ParseException e) {
                            Log.e(TAG, e.toString());
                        }
                    }
                    for (String rfc822 : sRFC822) {
                        mSimpleDateFormat = new SimpleDateFormat(rfc822, Locale.ENGLISH);
                        mSimpleDateFormat.setTimeZone(sTimeZone);
                        try {
                            if ((created = mSimpleDateFormat.parse(date)) != null) {
                                return created.getTime();
                            }
                        } catch (ParseException e) {
                            Log.e(TAG, e.toString());
                        }
                    }
                }
            }
            return System.currentTimeMillis();
        }

    };
    loadingDialog.setMessage(getString(R.string.loading));
    loadingDialog.setCancelable(true);
    loadingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            if (!asyncTask.isCancelled())
                asyncTask.cancel(true);
        }
    });
    loadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
    loadingDialog.show();
    asyncTask.execute(item.getItemId());
    return true;
    //      return super.onOptionsItemSelected(item);
}

From source file:cn.kangeqiu.kq.activity.LoginActivity.java

public void WXLogin(View v) {

    mController.doOauthVerify(this, SHARE_MEDIA.WEIXIN, new UMAuthListener() {
        @Override/*from  w w  w  . j a  v a2  s.  c  o m*/
        public void onStart(SHARE_MEDIA platform) {
        }

        @Override
        public void onError(SocializeException e, SHARE_MEDIA platform) {
            Toast.makeText(LoginActivity.this, "?" + "code:" + e.getErrorCode() + ";msg:"
                    + e.toString() + ";platform:" + platform, Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onComplete(Bundle value, SHARE_MEDIA platform) {

            Toast.makeText(LoginActivity.this, "??", Toast.LENGTH_SHORT).show();
            // ???
            mController.getPlatformInfo(LoginActivity.this, SHARE_MEDIA.WEIXIN, new UMDataListener() {
                @Override
                public void onStart() {
                }

                @Override
                public void onComplete(int status, Map<String, Object> info) {
                    if (status == 200 && info != null) {
                        StringBuilder sb = new StringBuilder();
                        Set<String> keys = info.keySet();

                        uId = info.get("openid").toString();

                        progressShow = true;
                        pd = new ProgressDialog(LoginActivity.this);
                        pd.setCanceledOnTouchOutside(false);
                        pd.setOnCancelListener(new OnCancelListener() {

                            @Override
                            public void onCancel(DialogInterface dialog) {
                                progressShow = false;
                            }
                        });
                        pd.setMessage("??");
                        pd.show();
                        doPullDate("1", "2035", new MCHttpCallBack() {
                            @Override
                            public void onSuccess(MCHttpResp resp) {
                                super.onSuccess(resp);
                                try {
                                    String resultCode = resp.getJson().getString("result_code");
                                    if (resultCode.equals("0")) {
                                        pd.dismiss();
                                        logi("doLoginSuccess():" + resp.getJson().toString());
                                        int playerId = 0;
                                        // state =
                                        // resp
                                        // .getJson()
                                        // .getString(
                                        // "is_first");
                                        @SuppressWarnings("unchecked")
                                        JSONArray list = resp.getJson().getJSONArray("user");
                                        // List<Map<String,
                                        // Object>>
                                        // list =
                                        // (List<Map<String,
                                        // Object>>)
                                        // data
                                        // .get("user");
                                        playerId = Integer.parseInt(list.getJSONObject(0).getString("id"));
                                        String nickname = (String) (list.getJSONObject(0)
                                                .getString("nickname"));
                                        if (nickname.equals(""))
                                            state = "1";
                                        else
                                            state = "0";

                                        AppConfig.getInstance().setPlayerId(playerId);
                                        // doShowTabMenu();
                                        // .
                                        // ????:playerId
                                        // 
                                        BaseApplication.currentUserNick = nickname;
                                        currentUsername = String.valueOf(playerId);
                                        currentPassword = String.valueOf(playerId);

                                        ToolUtil.putValue(String.class, "uid", currentUsername);
                                        if (state.equals("1")) {// 
                                            startActivity(
                                                    new Intent(LoginActivity.this, EditfileActivity1.class));
                                        } else
                                            startActivity(new Intent(LoginActivity.this, MainActivity.class));
                                        finish();
                                        // 
                                        doLoginHuanXin();
                                    } else {
                                        pd.dismiss();
                                        Toast.makeText(getApplicationContext(),
                                                resp.getJson().getString("message"), Toast.LENGTH_SHORT).show();
                                    }
                                } catch (Exception e) {
                                    // TODO
                                    // Auto-generated
                                    // catch block
                                    pd.dismiss();
                                    e.printStackTrace();
                                }
                            }

                            @Override
                            public void onError(MCHttpResp resp) {
                                pd.dismiss();
                                super.onError(resp);
                            }

                        });
                        for (String key : keys) {
                            sb.append(key + "=" + info.get(key).toString() + "\r\n");
                        }
                    } else {
                        pd.dismiss();
                        Log.d("TestData", "?" + status);
                    }
                }
            });
        }

        @Override
        public void onCancel(SHARE_MEDIA platform) {
            Toast.makeText(LoginActivity.this, "??", Toast.LENGTH_SHORT).show();
        }
    });
}

From source file:com.yayandroid.utility.MapHelperFragment.java

private void ShowProgressDialog(String message) {
    if (progressDialog == null) {
        progressDialog = new ProgressDialog(getActivity());
        progressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        progressDialog.setCancelable(progressDialogCancelable);
    }/*from   w  ww.j  av  a 2  s  .c o m*/
    progressDialog.setMessage(message);
    if (getActivity() != null)
        progressDialog.show();
}

From source file:com.piusvelte.sonet.core.SonetNotifications.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    final ProgressDialog loadingDialog = new ProgressDialog(this);
    final AsyncTask<Integer, String, Boolean> asyncTask = new AsyncTask<Integer, String, Boolean>() {

        @Override/*from   ww w  .  jav  a 2  s . co  m*/
        protected Boolean doInBackground(Integer... arg0) {
            if (arg0[0] == R.id.menu_notifications_refresh) {
                // select all accounts with notifications set
                Cursor widgets = getContentResolver().query(
                        Widgets_settings.getDistinctContentUri(SonetNotifications.this),
                        new String[] { Widgets.ACCOUNT }, Widgets.ACCOUNT + "!=-1 and (" + Widgets.LIGHTS
                                + "=1 or " + Widgets.VIBRATE + "=1 or " + Widgets.SOUND + "=1)",
                        null, null);
                if (widgets.moveToFirst()) {
                    mSonetCrypto = SonetCrypto.getInstance(getApplicationContext());
                    HttpClient httpClient = SonetHttpClient.getThreadSafeClient(getApplicationContext());
                    while (!widgets.isAfterLast()) {
                        long accountId = widgets.getLong(0);
                        ArrayList<String> notificationSids = new ArrayList<String>();
                        Cursor account = getContentResolver().query(
                                Accounts.getContentUri(SonetNotifications.this),
                                new String[] { Accounts.TOKEN, Accounts.SECRET, Accounts.SERVICE,
                                        Accounts.SID },
                                Accounts._ID + "=?", new String[] { Long.toString(accountId) }, null);
                        if (account.moveToFirst()) {
                            // for each account, for each notification, check for updates
                            // if there are no updates past 24hrs and cleared, delete
                            String token = mSonetCrypto.Decrypt(account.getString(0));
                            String secret = mSonetCrypto.Decrypt(account.getString(1));
                            int service = account.getInt(2);
                            String accountEsid = mSonetCrypto.Decrypt(account.getString(3));
                            mSimpleDateFormat = null;
                            if (service == TWITTER) {
                                Cursor currentNotifications = getContentResolver().query(
                                        Notifications.getContentUri(SonetNotifications.this),
                                        new String[] { Notifications.SID }, Notifications.ACCOUNT + "=?",
                                        new String[] { Long.toString(accountId) }, null);
                                // loop over notifications
                                if (currentNotifications.moveToFirst()) {
                                    // store sids, to avoid duplicates when requesting the latest feed
                                    String sid = mSonetCrypto.Decrypt(currentNotifications.getString(0));
                                    if (!notificationSids.contains(sid)) {
                                        notificationSids.add(sid);
                                    }
                                }
                                currentNotifications.close();
                                // limit to newest status
                                SonetOAuth sonetOAuth = new SonetOAuth(TWITTER_KEY, TWITTER_SECRET, token,
                                        secret);
                                String last_sid = null;
                                Cursor last_status = getContentResolver().query(
                                        Statuses.getContentUri(SonetNotifications.this),
                                        new String[] { Statuses.SID }, Statuses.ACCOUNT + "=?",
                                        new String[] { Long.toString(accountId) },
                                        Statuses.CREATED + " ASC LIMIT 1");
                                if (last_status.moveToFirst()) {
                                    last_sid = mSonetCrypto.Decrypt(last_status.getString(0));
                                }
                                last_status.close();
                                // get all mentions since the oldest status for this account
                                String response = SonetHttpClient.httpResponse(httpClient,
                                        sonetOAuth.getSignedRequest(
                                                new HttpGet(String.format(TWITTER_MENTIONS, TWITTER_BASE_URL,
                                                        last_sid != null
                                                                ? String.format(TWITTER_SINCE_ID, last_sid)
                                                                : ""))));
                                if (response != null) {
                                    try {
                                        JSONArray comments = new JSONArray(response);
                                        for (int i = 0, i2 = comments.length(); i < i2; i++) {
                                            JSONObject comment = comments.getJSONObject(i);
                                            JSONObject user = comment.getJSONObject(Suser);
                                            if (!user.getString(Sid).equals(accountEsid)
                                                    && !notificationSids.contains(comment.getString(Sid))) {
                                                String friend = user.getString(Sname);
                                                addNotification(comment.getString(Sid), user.getString(Sid),
                                                        friend, comment.getString("text"),
                                                        parseDate(comment.getString("created_at"),
                                                                TWITTER_DATE_FORMAT),
                                                        accountId, friend + " mentioned you on Twitter");
                                            }
                                        }
                                    } catch (JSONException e) {
                                        Log.e(TAG, service + ":" + e.toString());
                                    }
                                }
                            } else if (service == IDENTICA) {
                                Cursor currentNotifications = getContentResolver().query(
                                        Notifications.getContentUri(SonetNotifications.this),
                                        new String[] { Notifications.SID }, Notifications.ACCOUNT + "=?",
                                        new String[] { Long.toString(accountId) }, null);
                                // loop over notifications
                                if (currentNotifications.moveToFirst()) {
                                    // store sids, to avoid duplicates when requesting the latest feed
                                    String sid = mSonetCrypto.Decrypt(currentNotifications.getString(0));
                                    if (!notificationSids.contains(sid)) {
                                        notificationSids.add(sid);
                                    }
                                }
                                currentNotifications.close();
                                // limit to newest status
                                SonetOAuth sonetOAuth = new SonetOAuth(IDENTICA_KEY, IDENTICA_SECRET, token,
                                        secret);
                                String last_sid = null;
                                Cursor last_status = getContentResolver().query(
                                        Statuses.getContentUri(SonetNotifications.this),
                                        new String[] { Statuses.SID }, Statuses.ACCOUNT + "=?",
                                        new String[] { Long.toString(accountId) },
                                        Statuses.CREATED + " ASC LIMIT 1");
                                if (last_status.moveToFirst()) {
                                    last_sid = mSonetCrypto.Decrypt(last_status.getString(0));
                                }
                                last_status.close();
                                // get all mentions since the oldest status for this account
                                String response = SonetHttpClient.httpResponse(httpClient,
                                        sonetOAuth.getSignedRequest(
                                                new HttpGet(String.format(IDENTICA_MENTIONS, IDENTICA_BASE_URL,
                                                        last_sid != null
                                                                ? String.format(IDENTICA_SINCE_ID, last_sid)
                                                                : ""))));
                                if (response != null) {
                                    try {
                                        JSONArray comments = new JSONArray(response);
                                        for (int i = 0, i2 = comments.length(); i < i2; i++) {
                                            JSONObject comment = comments.getJSONObject(i);
                                            JSONObject user = comment.getJSONObject(Suser);
                                            if (!user.getString(Sid).equals(accountEsid)
                                                    && !notificationSids.contains(comment.getString(Sid))) {
                                                String friend = user.getString(Sname);
                                                addNotification(comment.getString(Sid), user.getString(Sid),
                                                        friend, comment.getString("text"),
                                                        parseDate(comment.getString("created_at"),
                                                                TWITTER_DATE_FORMAT),
                                                        accountId, friend + " mentioned you on Identi.ca");
                                            }
                                        }
                                    } catch (JSONException e) {
                                        Log.e(TAG, service + ":" + e.toString());
                                    }
                                }
                            } else {
                                Cursor currentNotifications = getContentResolver().query(
                                        Notifications.getContentUri(SonetNotifications.this),
                                        new String[] { Notifications._ID, Notifications.SID,
                                                Notifications.UPDATED, Notifications.CLEARED,
                                                Notifications.ESID },
                                        Notifications.ACCOUNT + "=?", new String[] { Long.toString(accountId) },
                                        null);
                                if (currentNotifications.moveToFirst()) {
                                    String response;
                                    SonetOAuth sonetOAuth;
                                    switch (service) {
                                    case FACEBOOK:
                                        // loop over notifications
                                        while (!currentNotifications.isAfterLast()) {
                                            long notificationId = currentNotifications.getLong(0);
                                            String sid = mSonetCrypto
                                                    .Decrypt(currentNotifications.getString(1));
                                            long updated = currentNotifications.getLong(2);
                                            boolean cleared = currentNotifications.getInt(3) == 1;
                                            // store sids, to avoid duplicates when requesting the latest feed
                                            if (!notificationSids.contains(sid)) {
                                                notificationSids.add(sid);
                                            }
                                            // get comments for current notifications
                                            if ((response = SonetHttpClient.httpResponse(httpClient,
                                                    new HttpGet(
                                                            String.format(FACEBOOK_COMMENTS, FACEBOOK_BASE_URL,
                                                                    sid, Saccess_token, token)))) != null) {
                                                // check for a newer post, if it's the user's own, then set CLEARED=0
                                                try {
                                                    JSONArray comments = new JSONObject(response)
                                                            .getJSONArray(Sdata);
                                                    int i2 = comments.length();
                                                    if (i2 > 0) {
                                                        for (int i = 0; i < i2; i++) {
                                                            JSONObject comment = comments.getJSONObject(i);
                                                            long created_time = comment.getLong(Screated_time)
                                                                    * 1000;
                                                            if (created_time > updated) {
                                                                // new comment
                                                                ContentValues values = new ContentValues();
                                                                values.put(Notifications.UPDATED, created_time);
                                                                JSONObject from = comment.getJSONObject(Sfrom);
                                                                if (accountEsid.equals(from.getString(Sid))) {
                                                                    // user's own comment, clear the notification
                                                                    values.put(Notifications.CLEARED, 1);
                                                                } else if (cleared) {
                                                                    values.put(Notifications.NOTIFICATION,
                                                                            String.format(getString(
                                                                                    R.string.friendcommented),
                                                                                    from.getString(Sname)));
                                                                    values.put(Notifications.CLEARED, 0);
                                                                } else {
                                                                    values.put(Notifications.NOTIFICATION,
                                                                            String.format(getString(
                                                                                    R.string.friendcommented),
                                                                                    from.getString(Sname)
                                                                                            + " and others"));
                                                                }
                                                                getContentResolver().update(
                                                                        Notifications.getContentUri(
                                                                                SonetNotifications.this),
                                                                        values, Notifications._ID + "=?",
                                                                        new String[] { Long
                                                                                .toString(notificationId) });
                                                            }
                                                        }
                                                    }
                                                } catch (JSONException e) {
                                                    Log.e(TAG, service + ":" + e.toString());
                                                }
                                            }
                                            currentNotifications.moveToNext();
                                        }
                                        // check the latest feed
                                        if ((response = SonetHttpClient.httpResponse(httpClient,
                                                new HttpGet(String.format(FACEBOOK_HOME, FACEBOOK_BASE_URL,
                                                        Saccess_token, token)))) != null) {
                                            try {
                                                JSONArray jarr = new JSONObject(response).getJSONArray(Sdata);
                                                // if there are updates, clear the cache
                                                int d2 = jarr.length();
                                                if (d2 > 0) {
                                                    for (int d = 0; d < d2; d++) {
                                                        JSONObject o = jarr.getJSONObject(d);
                                                        String sid = o.getString(Sid);
                                                        // if already notified, ignore
                                                        if (!notificationSids.contains(sid)) {
                                                            // only parse status types, not photo, video or link
                                                            if (o.has(Stype) && o.has(Sfrom)) {
                                                                JSONObject f = o.getJSONObject(Sfrom);
                                                                if (f.has(Sname) && f.has(Sid)) {
                                                                    String notification = null;
                                                                    String esid = f.getString(Sid);
                                                                    String friend = f.getString(Sname);
                                                                    if (o.has(Sto)) {
                                                                        // handle wall messages from one friend to another
                                                                        JSONObject t = o.getJSONObject(Sto);
                                                                        if (t.has(Sdata)) {
                                                                            JSONObject n = t.getJSONArray(Sdata)
                                                                                    .getJSONObject(0);
                                                                            if (n.has(Sname)) {
                                                                                if (n.has(Sid) && (n
                                                                                        .getString(Sid)
                                                                                        .equals(accountEsid))) {
                                                                                    notification = String
                                                                                            .format(getString(
                                                                                                    R.string.friendcommented),
                                                                                                    friend);
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                    int commentCount = 0;
                                                                    if (o.has(Scomments)) {
                                                                        JSONObject jo = o
                                                                                .getJSONObject(Scomments);
                                                                        if (jo.has(Sdata)) {
                                                                            JSONArray comments = jo
                                                                                    .getJSONArray(Sdata);
                                                                            commentCount = comments.length();
                                                                            // notifications
                                                                            if ((sid != null)
                                                                                    && (commentCount > 0)) {
                                                                                // default hasCommented to whether or not these comments are for the own user's status
                                                                                boolean hasCommented = notification != null
                                                                                        || esid.equals(
                                                                                                accountEsid);
                                                                                for (int c2 = 0; c2 < commentCount; c2++) {
                                                                                    JSONObject c3 = comments
                                                                                            .getJSONObject(c2);
                                                                                    if (c3.has(Sfrom)) {
                                                                                        JSONObject c4 = c3
                                                                                                .getJSONObject(
                                                                                                        Sfrom);
                                                                                        if (c4.getString(Sid)
                                                                                                .equals(accountEsid)) {
                                                                                            if (!hasCommented) {
                                                                                                // the user has commented on this thread, notify any updates
                                                                                                hasCommented = true;
                                                                                            }
                                                                                            // clear any notifications, as the user is already aware
                                                                                            if (notification != null) {
                                                                                                notification = null;
                                                                                            }
                                                                                        } else if (hasCommented) {
                                                                                            // don't notify about user's own comments
                                                                                            // send the parent comment sid
                                                                                            notification = String
                                                                                                    .format(getString(
                                                                                                            R.string.friendcommented),
                                                                                                            c4.getString(
                                                                                                                    Sname));
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                    if (notification != null) {
                                                                        String message = o.has(Smessage)
                                                                                ? o.getString(Smessage)
                                                                                : null;
                                                                        if (!o.getString(Stype).equals(Sstatus)
                                                                                && o.has(Slink)) {
                                                                            message = message == null
                                                                                    ? "[" + o.getString(Stype)
                                                                                            + "]"
                                                                                    : "[" + o.getString(Stype)
                                                                                            + "]";
                                                                        }
                                                                        // new notification
                                                                        addNotification(sid, esid, friend,
                                                                                message,
                                                                                o.getLong(Screated_time) * 1000,
                                                                                accountId, notification);
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            } catch (JSONException e) {
                                                Log.e(TAG, service + ":" + e.toString());
                                            }
                                        }
                                        break;
                                    case MYSPACE:
                                        sonetOAuth = new SonetOAuth(MYSPACE_KEY, MYSPACE_SECRET, token, secret);
                                        // loop over notifications
                                        while (!currentNotifications.isAfterLast()) {
                                            long notificationId = currentNotifications.getLong(0);
                                            String sid = mSonetCrypto
                                                    .Decrypt(currentNotifications.getString(1));
                                            long updated = currentNotifications.getLong(2);
                                            boolean cleared = currentNotifications.getInt(3) == 1;
                                            String esid = mSonetCrypto
                                                    .Decrypt(currentNotifications.getString(4));
                                            // store sids, to avoid duplicates when requesting the latest feed
                                            if (!notificationSids.contains(sid)) {
                                                notificationSids.add(sid);
                                            }
                                            // get comments for current notifications
                                            if ((response = SonetHttpClient.httpResponse(httpClient,
                                                    sonetOAuth.getSignedRequest(new HttpGet(
                                                            String.format(MYSPACE_URL_STATUSMOODCOMMENTS,
                                                                    MYSPACE_BASE_URL, esid, sid))))) != null) {
                                                // check for a newer post, if it's the user's own, then set CLEARED=0
                                                try {
                                                    JSONArray comments = new JSONObject(response)
                                                            .getJSONArray(Sentry);
                                                    int i2 = comments.length();
                                                    if (i2 > 0) {
                                                        for (int i = 0; i < i2; i++) {
                                                            JSONObject comment = comments.getJSONObject(i);
                                                            long created_time = parseDate(
                                                                    comment.getString(SpostedDate),
                                                                    MYSPACE_DATE_FORMAT);
                                                            if (created_time > updated) {
                                                                // new comment
                                                                ContentValues values = new ContentValues();
                                                                values.put(Notifications.UPDATED, created_time);
                                                                JSONObject author = comment
                                                                        .getJSONObject(Sauthor);
                                                                if (accountEsid.equals(author.getString(Sid))) {
                                                                    // user's own comment, clear the notification
                                                                    values.put(Notifications.CLEARED, 1);
                                                                } else if (cleared) {
                                                                    values.put(Notifications.NOTIFICATION,
                                                                            String.format(getString(
                                                                                    R.string.friendcommented),
                                                                                    comment.getString(
                                                                                            SdisplayName)));
                                                                    values.put(Notifications.CLEARED, 0);
                                                                } else {
                                                                    values.put(Notifications.NOTIFICATION,
                                                                            String.format(getString(
                                                                                    R.string.friendcommented),
                                                                                    comment.getString(
                                                                                            SdisplayName)
                                                                                            + " and others"));
                                                                }
                                                                getContentResolver().update(
                                                                        Notifications.getContentUri(
                                                                                SonetNotifications.this),
                                                                        values, Notifications._ID + "=?",
                                                                        new String[] { Long
                                                                                .toString(notificationId) });
                                                            }
                                                        }
                                                    }
                                                } catch (JSONException e) {
                                                    Log.e(TAG, service + ":" + e.toString());
                                                }
                                            }
                                            currentNotifications.moveToNext();
                                        }
                                        // check the latest feed
                                        if ((response = SonetHttpClient
                                                .httpResponse(httpClient,
                                                        sonetOAuth.getSignedRequest(
                                                                new HttpGet(String.format(MYSPACE_HISTORY,
                                                                        MYSPACE_BASE_URL))))) != null) {
                                            try {
                                                JSONArray jarr = new JSONObject(response).getJSONArray(Sentry);
                                                // if there are updates, clear the cache
                                                int d2 = jarr.length();
                                                if (d2 > 0) {
                                                    for (int d = 0; d < d2; d++) {
                                                        JSONObject o = jarr.getJSONObject(d);
                                                        String sid = o.getString(SstatusId);
                                                        // if already notified, ignore
                                                        if (!notificationSids.contains(sid)) {
                                                            if (o.has(Sauthor) && o.has(SrecentComments)) {
                                                                JSONObject f = o.getJSONObject(Sauthor);
                                                                if (f.has(SdisplayName) && f.has(Sid)) {
                                                                    String notification = null;
                                                                    String esid = f.getString(Sid);
                                                                    String friend = f.getString(SdisplayName);
                                                                    JSONArray comments = o
                                                                            .getJSONArray(SrecentComments);
                                                                    int commentCount = comments.length();
                                                                    // notifications
                                                                    if ((sid != null) && (commentCount > 0)) {
                                                                        // default hasCommented to whether or not these comments are for the own user's status
                                                                        boolean hasCommented = notification != null
                                                                                || esid.equals(accountEsid);
                                                                        for (int c2 = 0; c2 < commentCount; c2++) {
                                                                            JSONObject c3 = comments
                                                                                    .getJSONObject(c2);
                                                                            if (c3.has(Sauthor)) {
                                                                                JSONObject c4 = c3
                                                                                        .getJSONObject(Sauthor);
                                                                                if (c4.getString(Sid)
                                                                                        .equals(accountEsid)) {
                                                                                    if (!hasCommented) {
                                                                                        // the user has commented on this thread, notify any updates
                                                                                        hasCommented = true;
                                                                                    }
                                                                                    // clear any notifications, as the user is already aware
                                                                                    if (notification != null) {
                                                                                        notification = null;
                                                                                    }
                                                                                } else if (hasCommented) {
                                                                                    // don't notify about user's own comments
                                                                                    // send the parent comment sid
                                                                                    notification = String
                                                                                            .format(getString(
                                                                                                    R.string.friendcommented),
                                                                                                    c4.getString(
                                                                                                            SdisplayName));
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                    if (notification != null) {
                                                                        // new notification
                                                                        addNotification(sid, esid, friend,
                                                                                o.getString(Sstatus),
                                                                                parseDate(o.getString(
                                                                                        "moodStatusLastUpdated"),
                                                                                        MYSPACE_DATE_FORMAT),
                                                                                accountId, notification);
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            } catch (JSONException e) {
                                                Log.e(TAG, service + ":" + e.toString());
                                            }
                                        }
                                        break;
                                    case FOURSQUARE:
                                        // loop over notifications
                                        while (!currentNotifications.isAfterLast()) {
                                            long notificationId = currentNotifications.getLong(0);
                                            String sid = mSonetCrypto
                                                    .Decrypt(currentNotifications.getString(1));
                                            long updated = currentNotifications.getLong(2);
                                            boolean cleared = currentNotifications.getInt(3) == 1;
                                            // store sids, to avoid duplicates when requesting the latest feed
                                            if (!notificationSids.contains(sid)) {
                                                notificationSids.add(sid);
                                            }
                                            // get comments for current notifications
                                            if ((response = SonetHttpClient.httpResponse(httpClient,
                                                    new HttpGet(String.format(FOURSQUARE_GET_CHECKIN,
                                                            FOURSQUARE_BASE_URL, sid, token)))) != null) {
                                                // check for a newer post, if it's the user's own, then set CLEARED=0
                                                try {
                                                    JSONArray comments = new JSONObject(response)
                                                            .getJSONObject(Sresponse).getJSONObject(Scheckin)
                                                            .getJSONObject(Scomments).getJSONArray(Sitems);
                                                    int i2 = comments.length();
                                                    if (i2 > 0) {
                                                        for (int i = 0; i < i2; i++) {
                                                            JSONObject comment = comments.getJSONObject(i);
                                                            long created_time = comment.getLong(ScreatedAt)
                                                                    * 1000;
                                                            if (created_time > updated) {
                                                                // new comment
                                                                ContentValues values = new ContentValues();
                                                                values.put(Notifications.UPDATED, created_time);
                                                                JSONObject user = comment.getJSONObject(Suser);
                                                                if (accountEsid.equals(user.getString(Sid))) {
                                                                    // user's own comment, clear the notification
                                                                    values.put(Notifications.CLEARED, 1);
                                                                } else if (cleared) {
                                                                    values.put(Notifications.NOTIFICATION,
                                                                            String.format(getString(
                                                                                    R.string.friendcommented),
                                                                                    user.getString(SfirstName)
                                                                                            + " "
                                                                                            + user.getString(
                                                                                                    SlastName)));
                                                                    values.put(Notifications.CLEARED, 0);
                                                                } else {
                                                                    values.put(Notifications.NOTIFICATION,
                                                                            String.format(getString(
                                                                                    R.string.friendcommented),
                                                                                    user.getString(SfirstName)
                                                                                            + " "
                                                                                            + user.getString(
                                                                                                    SlastName)
                                                                                            + " and others"));
                                                                }
                                                                getContentResolver().update(
                                                                        Notifications.getContentUri(
                                                                                SonetNotifications.this),
                                                                        values, Notifications._ID + "=?",
                                                                        new String[] { Long
                                                                                .toString(notificationId) });
                                                            }
                                                        }
                                                    }
                                                } catch (JSONException e) {
                                                    Log.e(TAG, service + ":" + e.toString());
                                                }
                                            }
                                            currentNotifications.moveToNext();
                                        }
                                        // check the latest feed
                                        if ((response = SonetHttpClient.httpResponse(httpClient,
                                                new HttpGet(String.format(FOURSQUARE_CHECKINS,
                                                        FOURSQUARE_BASE_URL, token)))) != null) {
                                            try {
                                                JSONArray jarr = new JSONObject(response)
                                                        .getJSONObject(Sresponse).getJSONArray(Srecent);
                                                // if there are updates, clear the cache
                                                int d2 = jarr.length();
                                                if (d2 > 0) {
                                                    for (int d = 0; d < d2; d++) {
                                                        JSONObject o = jarr.getJSONObject(d);
                                                        String sid = o.getString(Sid);
                                                        // if already notified, ignore
                                                        if (!notificationSids.contains(sid)) {
                                                            if (o.has(Suser) && o.has(Scomments)) {
                                                                JSONObject f = o.getJSONObject(Suser);
                                                                if (f.has(SfirstName) && f.has(SlastName)
                                                                        && f.has(Sid)) {
                                                                    String notification = null;
                                                                    String esid = f.getString(Sid);
                                                                    String friend = f.getString(SfirstName)
                                                                            + " " + f.getString(SlastName);
                                                                    JSONArray comments = o
                                                                            .getJSONArray(Scomments);
                                                                    int commentCount = comments.length();
                                                                    // notifications
                                                                    if (commentCount > 0) {
                                                                        // default hasCommented to whether or not these comments are for the own user's status
                                                                        boolean hasCommented = notification != null
                                                                                || esid.equals(accountEsid);
                                                                        for (int c2 = 0; c2 < commentCount; c2++) {
                                                                            JSONObject c3 = comments
                                                                                    .getJSONObject(c2);
                                                                            if (c3.has(Suser)) {
                                                                                JSONObject c4 = c3
                                                                                        .getJSONObject(Suser);
                                                                                if (c4.getString(Sid)
                                                                                        .equals(accountEsid)) {
                                                                                    if (!hasCommented) {
                                                                                        // the user has commented on this thread, notify any updates
                                                                                        hasCommented = true;
                                                                                    }
                                                                                    // clear any notifications, as the user is already aware
                                                                                    if (notification != null) {
                                                                                        notification = null;
                                                                                    }
                                                                                } else if (hasCommented) {
                                                                                    // don't notify about user's own comments
                                                                                    // send the parent comment sid
                                                                                    notification = String
                                                                                            .format(getString(
                                                                                                    R.string.friendcommented),
                                                                                                    c4.getString(
                                                                                                            SfirstName)
                                                                                                            + " "
                                                                                                            + c4.getString(
                                                                                                                    SlastName));
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                    if (notification != null) {
                                                                        String message = "";
                                                                        if (o.has(Sshout)) {
                                                                            message = o.getString(Sshout)
                                                                                    + "\n";
                                                                        }
                                                                        if (o.has(Svenue)) {
                                                                            JSONObject venue = o
                                                                                    .getJSONObject(Svenue);
                                                                            if (venue.has(Sname)) {
                                                                                message += "@" + venue
                                                                                        .getString(Sname);
                                                                            }
                                                                        }
                                                                        // new notification
                                                                        addNotification(sid, esid, friend,
                                                                                message,
                                                                                o.getLong(ScreatedAt) * 1000,
                                                                                accountId, notification);
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            } catch (JSONException e) {
                                                Log.e(TAG, service + ":" + e.toString());
                                            }
                                        }
                                        break;
                                    case LINKEDIN:
                                        sonetOAuth = new SonetOAuth(LINKEDIN_KEY, LINKEDIN_SECRET, token,
                                                secret);
                                        // loop over notifications
                                        while (!currentNotifications.isAfterLast()) {
                                            long notificationId = currentNotifications.getLong(0);
                                            String sid = mSonetCrypto
                                                    .Decrypt(currentNotifications.getString(1));
                                            long updated = currentNotifications.getLong(2);
                                            boolean cleared = currentNotifications.getInt(3) == 1;
                                            // store sids, to avoid duplicates when requesting the latest feed
                                            if (!notificationSids.contains(sid)) {
                                                notificationSids.add(sid);
                                            }
                                            // get comments for current notifications
                                            HttpGet httpGet = new HttpGet(String
                                                    .format(LINKEDIN_UPDATE_COMMENTS, LINKEDIN_BASE_URL, sid));
                                            for (String[] header : LINKEDIN_HEADERS)
                                                httpGet.setHeader(header[0], header[1]);
                                            if ((response = SonetHttpClient.httpResponse(httpClient,
                                                    sonetOAuth.getSignedRequest(httpGet))) != null) {
                                                // check for a newer post, if it's the user's own, then set CLEARED=0
                                                try {
                                                    JSONObject jsonResponse = new JSONObject(response);
                                                    if (jsonResponse.has(S_total)
                                                            && (jsonResponse.getInt(S_total) != 0)) {
                                                        JSONArray comments = jsonResponse.getJSONArray(Svalues);
                                                        int i2 = comments.length();
                                                        if (i2 > 0) {
                                                            for (int i = 0; i < i2; i++) {
                                                                JSONObject comment = comments.getJSONObject(i);
                                                                long created_time = comment.getLong(Stimestamp);
                                                                if (created_time > updated) {
                                                                    // new comment
                                                                    ContentValues values = new ContentValues();
                                                                    values.put(Notifications.UPDATED,
                                                                            created_time);
                                                                    JSONObject person = comment
                                                                            .getJSONObject(Sperson);
                                                                    if (accountEsid
                                                                            .equals(person.getString(Sid))) {
                                                                        // user's own comment, clear the notification
                                                                        values.put(Notifications.CLEARED, 1);
                                                                    } else if (cleared) {
                                                                        values.put(Notifications.NOTIFICATION,
                                                                                String.format(getString(
                                                                                        R.string.friendcommented),
                                                                                        person.getString(
                                                                                                SfirstName)
                                                                                                + " "
                                                                                                + person.getString(
                                                                                                        SlastName)));
                                                                        values.put(Notifications.CLEARED, 0);
                                                                    } else {
                                                                        values.put(Notifications.NOTIFICATION,
                                                                                String.format(getString(
                                                                                        R.string.friendcommented),
                                                                                        person.getString(
                                                                                                SfirstName)
                                                                                                + " "
                                                                                                + person.getString(
                                                                                                        SlastName)
                                                                                                + " and others"));
                                                                    }
                                                                    getContentResolver().update(
                                                                            Notifications.getContentUri(
                                                                                    SonetNotifications.this),
                                                                            values, Notifications._ID + "=?",
                                                                            new String[] { Long.toString(
                                                                                    notificationId) });
                                                                }
                                                            }
                                                        }
                                                    }
                                                } catch (JSONException e) {
                                                    Log.e(TAG, service + ":" + e.toString());
                                                }
                                            }
                                            currentNotifications.moveToNext();
                                        }
                                        // check the latest feed
                                        HttpGet httpGet = new HttpGet(
                                                String.format(LINKEDIN_UPDATES, LINKEDIN_BASE_URL));
                                        for (String[] header : LINKEDIN_HEADERS) {
                                            httpGet.setHeader(header[0], header[1]);
                                        }
                                        if ((response = SonetHttpClient.httpResponse(httpClient,
                                                sonetOAuth.getSignedRequest(httpGet))) != null) {
                                            try {
                                                JSONArray jarr = new JSONObject(response).getJSONArray(Svalues);
                                                // if there are updates, clear the cache
                                                int d2 = jarr.length();
                                                if (d2 > 0) {
                                                    for (int d = 0; d < d2; d++) {
                                                        JSONObject o = jarr.getJSONObject(d);
                                                        String sid = o.getString(SupdateKey);
                                                        // if already notified, ignore
                                                        if (!notificationSids.contains(sid)) {
                                                            String updateType = o.getString(SupdateType);
                                                            JSONObject updateContent = o
                                                                    .getJSONObject(SupdateContent);
                                                            if (LinkedIn_UpdateTypes.contains(updateType)
                                                                    && updateContent.has(Sperson)) {
                                                                JSONObject f = updateContent
                                                                        .getJSONObject(Sperson);
                                                                if (f.has(SfirstName) && f.has(SlastName)
                                                                        && f.has(Sid)
                                                                        && o.has(SupdateComments)) {
                                                                    JSONObject updateComments = o
                                                                            .getJSONObject(SupdateComments);
                                                                    if (updateComments.has(Svalues)) {
                                                                        String notification = null;
                                                                        String esid = f.getString(Sid);
                                                                        JSONArray comments = updateComments
                                                                                .getJSONArray(Svalues);
                                                                        int commentCount = comments.length();
                                                                        // notifications
                                                                        if (commentCount > 0) {
                                                                            // default hasCommented to whether or not these comments are for the own user's status
                                                                            boolean hasCommented = notification != null
                                                                                    || esid.equals(accountEsid);
                                                                            for (int c2 = 0; c2 < commentCount; c2++) {
                                                                                JSONObject c3 = comments
                                                                                        .getJSONObject(c2);
                                                                                if (c3.has(Sperson)) {
                                                                                    JSONObject c4 = c3
                                                                                            .getJSONObject(
                                                                                                    Sperson);
                                                                                    if (c4.getString(Sid)
                                                                                            .equals(accountEsid)) {
                                                                                        if (!hasCommented) {
                                                                                            // the user has commented on this thread, notify any updates
                                                                                            hasCommented = true;
                                                                                        }
                                                                                        // clear any notifications, as the user is already aware
                                                                                        if (notification != null) {
                                                                                            notification = null;
                                                                                        }
                                                                                    } else if (hasCommented) {
                                                                                        // don't notify about user's own comments
                                                                                        // send the parent comment sid
                                                                                        notification = String
                                                                                                .format(getString(
                                                                                                        R.string.friendcommented),
                                                                                                        c4.getString(
                                                                                                                SfirstName)
                                                                                                                + " "
                                                                                                                + c4.getString(
                                                                                                                        SlastName));
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                        if (notification != null) {
                                                                            String update = LinkedIn_UpdateTypes
                                                                                    .getMessage(updateType);
                                                                            if (LinkedIn_UpdateTypes.APPS.name()
                                                                                    .equals(updateType)) {
                                                                                if (f.has(SpersonActivities)) {
                                                                                    JSONObject personActivities = f
                                                                                            .getJSONObject(
                                                                                                    SpersonActivities);
                                                                                    if (personActivities
                                                                                            .has(Svalues)) {
                                                                                        JSONArray updates = personActivities
                                                                                                .getJSONArray(
                                                                                                        Svalues);
                                                                                        for (int u = 0, u2 = updates
                                                                                                .length(); u < u2; u++) {
                                                                                            update += updates
                                                                                                    .getJSONObject(
                                                                                                            u)
                                                                                                    .getString(
                                                                                                            Sbody);
                                                                                            if (u < (updates
                                                                                                    .length()
                                                                                                    - 1))
                                                                                                update += ", ";
                                                                                        }
                                                                                    }
                                                                                }
                                                                            } else if (LinkedIn_UpdateTypes.CONN
                                                                                    .name()
                                                                                    .equals(updateType)) {
                                                                                if (f.has(Sconnections)) {
                                                                                    JSONObject connections = f
                                                                                            .getJSONObject(
                                                                                                    Sconnections);
                                                                                    if (connections
                                                                                            .has(Svalues)) {
                                                                                        JSONArray updates = connections
                                                                                                .getJSONArray(
                                                                                                        Svalues);
                                                                                        for (int u = 0, u2 = updates
                                                                                                .length(); u < u2; u++) {
                                                                                            update += updates
                                                                                                    .getJSONObject(
                                                                                                            u)
                                                                                                    .getString(
                                                                                                            SfirstName)
                                                                                                    + " "
                                                                                                    + updates
                                                                                                            .getJSONObject(
                                                                                                                    u)
                                                                                                            .getString(
                                                                                                                    SlastName);
                                                                                            if (u < (updates
                                                                                                    .length()
                                                                                                    - 1))
                                                                                                update += ", ";
                                                                                        }
                                                                                    }
                                                                                }
                                                                            } else if (LinkedIn_UpdateTypes.JOBP
                                                                                    .name()
                                                                                    .equals(updateType)) {
                                                                                if (updateContent.has(Sjob)
                                                                                        && updateContent
                                                                                                .getJSONObject(
                                                                                                        Sjob)
                                                                                                .has(Sposition)
                                                                                        && updateContent
                                                                                                .getJSONObject(
                                                                                                        Sjob)
                                                                                                .getJSONObject(
                                                                                                        Sposition)
                                                                                                .has(Stitle))
                                                                                    update += updateContent
                                                                                            .getJSONObject(Sjob)
                                                                                            .getJSONObject(
                                                                                                    Sposition)
                                                                                            .getString(Stitle);
                                                                            } else if (LinkedIn_UpdateTypes.JGRP
                                                                                    .name()
                                                                                    .equals(updateType)) {
                                                                                if (f.has(SmemberGroups)) {
                                                                                    JSONObject memberGroups = f
                                                                                            .getJSONObject(
                                                                                                    SmemberGroups);
                                                                                    if (memberGroups
                                                                                            .has(Svalues)) {
                                                                                        JSONArray updates = memberGroups
                                                                                                .getJSONArray(
                                                                                                        Svalues);
                                                                                        for (int u = 0, u2 = updates
                                                                                                .length(); u < u2; u++) {
                                                                                            update += updates
                                                                                                    .getJSONObject(
                                                                                                            u)
                                                                                                    .getString(
                                                                                                            Sname);
                                                                                            if (u < (updates
                                                                                                    .length()
                                                                                                    - 1))
                                                                                                update += ", ";
                                                                                        }
                                                                                    }
                                                                                }
                                                                            } else if (LinkedIn_UpdateTypes.PREC
                                                                                    .name()
                                                                                    .equals(updateType)) {
                                                                                if (f.has(
                                                                                        SrecommendationsGiven)) {
                                                                                    JSONObject recommendationsGiven = f
                                                                                            .getJSONObject(
                                                                                                    SrecommendationsGiven);
                                                                                    if (recommendationsGiven
                                                                                            .has(Svalues)) {
                                                                                        JSONArray updates = recommendationsGiven
                                                                                                .getJSONArray(
                                                                                                        Svalues);
                                                                                        for (int u = 0, u2 = updates
                                                                                                .length(); u < u2; u++) {
                                                                                            JSONObject recommendation = updates
                                                                                                    .getJSONObject(
                                                                                                            u);
                                                                                            JSONObject recommendee = recommendation
                                                                                                    .getJSONObject(
                                                                                                            Srecommendee);
                                                                                            if (recommendee.has(
                                                                                                    SfirstName))
                                                                                                update += recommendee
                                                                                                        .getString(
                                                                                                                SfirstName);
                                                                                            if (recommendee.has(
                                                                                                    SlastName))
                                                                                                update += recommendee
                                                                                                        .getString(
                                                                                                                SlastName);
                                                                                            if (recommendation
                                                                                                    .has(SrecommendationSnippet))
                                                                                                update += ":"
                                                                                                        + recommendation
                                                                                                                .getString(
                                                                                                                        SrecommendationSnippet);
                                                                                            if (u < (updates
                                                                                                    .length()
                                                                                                    - 1))
                                                                                                update += ", ";
                                                                                        }
                                                                                    }
                                                                                }
                                                                            } else if (LinkedIn_UpdateTypes.SHAR
                                                                                    .name().equals(updateType)
                                                                                    && f.has(ScurrentShare)) {
                                                                                JSONObject currentShare = f
                                                                                        .getJSONObject(
                                                                                                ScurrentShare);
                                                                                if (currentShare.has(Scomment))
                                                                                    update = currentShare
                                                                                            .getString(
                                                                                                    Scomment);
                                                                            }
                                                                            // new notification
                                                                            addNotification(sid, esid,
                                                                                    f.getString(SfirstName)
                                                                                            + " "
                                                                                            + f.getString(
                                                                                                    SlastName),
                                                                                    update,
                                                                                    o.getLong(Stimestamp),
                                                                                    accountId, notification);
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            } catch (JSONException e) {
                                                Log.e(TAG, service + ":" + e.toString());
                                            }
                                        }
                                        break;
                                    case GOOGLEPLUS:
                                        // get new access token, need different request here
                                        HttpPost httpPost = new HttpPost(GOOGLE_ACCESS);
                                        List<NameValuePair> httpParams = new ArrayList<NameValuePair>();
                                        httpParams.add(new BasicNameValuePair("client_id", GOOGLE_CLIENTID));
                                        httpParams.add(
                                                new BasicNameValuePair("client_secret", GOOGLE_CLIENTSECRET));
                                        httpParams.add(new BasicNameValuePair("refresh_token", token));
                                        httpParams.add(new BasicNameValuePair("grant_type", "refresh_token"));
                                        try {
                                            httpPost.setEntity(new UrlEncodedFormEntity(httpParams));
                                            if ((response = SonetHttpClient.httpResponse(httpClient,
                                                    httpPost)) != null) {
                                                JSONObject j = new JSONObject(response);
                                                if (j.has(Saccess_token)) {
                                                    String access_token = j.getString(Saccess_token);
                                                    while (!currentNotifications.isAfterLast()) {
                                                        long notificationId = currentNotifications.getLong(0);
                                                        String sid = mSonetCrypto
                                                                .Decrypt(currentNotifications.getString(1));
                                                        long updated = currentNotifications.getLong(2);
                                                        boolean cleared = currentNotifications.getInt(3) == 1;
                                                        // store sids, to avoid duplicates when requesting the latest feed
                                                        if (!notificationSids.contains(sid)) {
                                                            notificationSids.add(sid);
                                                        }
                                                        // get comments for current notifications
                                                        if ((response = SonetHttpClient.httpResponse(httpClient,
                                                                new HttpGet(String.format(GOOGLEPLUS_ACTIVITY,
                                                                        GOOGLEPLUS_BASE_URL, sid,
                                                                        access_token)))) != null) {
                                                            // check for a newer post, if it's the user's own, then set CLEARED=0
                                                            try {
                                                                JSONObject item = new JSONObject(response);
                                                                if (item.has(Sobject)) {
                                                                    JSONObject object = item
                                                                            .getJSONObject(Sobject);
                                                                    if (object.has(Sreplies)) {
                                                                        int commentCount = 0;
                                                                        JSONObject replies = object
                                                                                .getJSONObject(Sreplies);
                                                                        if (replies.has(StotalItems)) {
                                                                            //TODO: notifications
                                                                        }
                                                                    }
                                                                }
                                                            } catch (JSONException e) {
                                                                Log.e(TAG, service + ":" + e.toString());
                                                            }
                                                        }
                                                        currentNotifications.moveToNext();
                                                    }
                                                    // get new feed
                                                    if ((response = SonetHttpClient.httpResponse(httpClient,
                                                            new HttpGet(String.format(GOOGLEPLUS_ACTIVITIES,
                                                                    GOOGLEPLUS_BASE_URL, "me", "public", 20,
                                                                    access_token)))) != null) {
                                                        JSONObject r = new JSONObject(response);
                                                        if (r.has(Sitems)) {
                                                            JSONArray items = r.getJSONArray(Sitems);
                                                            for (int i1 = 0, i2 = items
                                                                    .length(); i1 < i2; i1++) {
                                                                JSONObject item = items.getJSONObject(i1);
                                                                if (item.has(Sactor) && item.has(Sobject)) {
                                                                    JSONObject actor = item
                                                                            .getJSONObject(Sactor);
                                                                    JSONObject object = item
                                                                            .getJSONObject(Sobject);
                                                                    if (item.has(Sid) && actor.has(Sid)
                                                                            && actor.has(SdisplayName)
                                                                            && item.has(Spublished)
                                                                            && object.has(Sreplies)
                                                                            && object.has(SoriginalContent)) {
                                                                        String sid = item.getString(Sid);
                                                                        String esid = actor.getString(Sid);
                                                                        String friend = actor
                                                                                .getString(SdisplayName);
                                                                        String originalContent = object
                                                                                .getString(SoriginalContent);
                                                                        if ((originalContent == null)
                                                                                || (originalContent
                                                                                        .length() == 0)) {
                                                                            originalContent = object
                                                                                    .getString(Scontent);
                                                                        }
                                                                        String photo = null;
                                                                        if (actor.has(Simage)) {
                                                                            JSONObject image = actor
                                                                                    .getJSONObject(Simage);
                                                                            if (image.has(Surl)) {
                                                                                photo = image.getString(Surl);
                                                                            }
                                                                        }
                                                                        long date = parseDate(
                                                                                item.getString(Spublished),
                                                                                GOOGLEPLUS_DATE_FORMAT);
                                                                        int commentCount = 0;
                                                                        JSONObject replies = object
                                                                                .getJSONObject(Sreplies);
                                                                        String notification = null;
                                                                        if (replies.has(StotalItems)) {
                                                                            Log.d(TAG, Sreplies + ":"
                                                                                    + replies.toString());
                                                                            commentCount = replies
                                                                                    .getInt(StotalItems);
                                                                        }
                                                                        if (notification != null) {
                                                                            // new notification
                                                                            addNotification(sid, esid, friend,
                                                                                    originalContent, date,
                                                                                    accountId, notification);
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        } catch (UnsupportedEncodingException e) {
                                            Log.e(TAG, e.toString());
                                        } catch (JSONException e) {
                                            Log.e(TAG, e.toString());
                                        }
                                        break;
                                    }
                                }
                                currentNotifications.close();
                            }
                            // remove old notifications
                            getContentResolver().delete(Notifications.getContentUri(SonetNotifications.this),
                                    Notifications.CLEARED + "=1 and " + Notifications.ACCOUNT + "=? and "
                                            + Notifications.CREATED + "<?",
                                    new String[] { Long.toString(accountId),
                                            Long.toString(System.currentTimeMillis() - 86400000) });
                        }
                        account.close();
                        widgets.moveToNext();
                    }
                } else {
                    publishProgress("No notifications have been set up on any accounts.");
                }
                widgets.close();
                return false;
            } else if (arg0[0] == R.id.menu_notifications_clear_all) {
                // clear all notifications
                ContentValues values = new ContentValues();
                values.put(Notifications.CLEARED, 1);
                SonetNotifications.this.getContentResolver()
                        .update(Notifications.getContentUri(SonetNotifications.this), values, null, null);
                return true;
            }
            return false;
        }

        @Override
        protected void onProgressUpdate(String... messages) {
            (Toast.makeText(SonetNotifications.this, messages[0], Toast.LENGTH_LONG)).show();
        }

        @Override
        protected void onPostExecute(Boolean finish) {
            if (loadingDialog.isShowing()) {
                loadingDialog.dismiss();
            }
            if (finish) {
                SonetNotifications.this.finish();
            }
        }

        private void addNotification(String sid, String esid, String friend, String message, long created,
                long accountId, String notification) {
            ContentValues values = new ContentValues();
            values.put(Notifications.SID, sid);
            values.put(Notifications.ESID, esid);
            values.put(Notifications.FRIEND, friend);
            values.put(Notifications.MESSAGE, message);
            values.put(Notifications.CREATED, created);
            values.put(Notifications.ACCOUNT, accountId);
            values.put(Notifications.NOTIFICATION, notification);
            values.put(Notifications.CLEARED, 0);
            values.put(Notifications.UPDATED, created);
            getContentResolver().insert(Notifications.getContentUri(SonetNotifications.this), values);
        }

        private long parseDate(String date, String format) {
            if (date != null) {
                // hack for the literal 'Z'
                if (date.substring(date.length() - 1).equals("Z")) {
                    date = date.substring(0, date.length() - 2) + "+0000";
                }
                Date created = null;
                if (format != null) {
                    if (mSimpleDateFormat == null) {
                        mSimpleDateFormat = new SimpleDateFormat(format, Locale.ENGLISH);
                        // all dates should be GMT/UTC
                        mSimpleDateFormat.setTimeZone(sTimeZone);
                    }
                    try {
                        created = mSimpleDateFormat.parse(date);
                        return created.getTime();
                    } catch (ParseException e) {
                        Log.e(TAG, e.toString());
                    }
                } else {
                    // attempt to parse RSS date
                    if (mSimpleDateFormat != null) {
                        try {
                            created = mSimpleDateFormat.parse(date);
                            return created.getTime();
                        } catch (ParseException e) {
                            Log.e(TAG, e.toString());
                        }
                    }
                    for (String rfc822 : sRFC822) {
                        mSimpleDateFormat = new SimpleDateFormat(rfc822, Locale.ENGLISH);
                        mSimpleDateFormat.setTimeZone(sTimeZone);
                        try {
                            if ((created = mSimpleDateFormat.parse(date)) != null) {
                                return created.getTime();
                            }
                        } catch (ParseException e) {
                            Log.e(TAG, e.toString());
                        }
                    }
                }
            }
            return System.currentTimeMillis();
        }

    };
    loadingDialog.setMessage(getString(R.string.loading));
    loadingDialog.setCancelable(true);
    loadingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            if (!asyncTask.isCancelled())
                asyncTask.cancel(true);
        }
    });
    loadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
    loadingDialog.show();
    asyncTask.execute(item.getItemId());
    return true;
    //      return super.onOptionsItemSelected(item);
}

From source file:com.googlecode.CallerLookup.Main.java

@Override
protected Dialog onCreateDialog(int id) {
    if (id != DIALOG_PROGRESS) {
        return super.onCreateDialog(id);
    }/*from w w w  .j a v  a 2  s . com*/

    mProgressDialog = new ProgressDialog(Main.this);
    mProgressDialog.setMessage(getString(R.string.ProgressMessage));
    mProgressDialog.setOnCancelListener(new OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            // TODO: stop mLookupThread instead of doing this ignore-lookup-result hack
            mIgnoreLookupResult = true;
        }
    });
    return mProgressDialog;
}

From source file:com.easemob.chatuidemo.activity.GroupDetailsActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    String st1 = getResources().getString(R.string.being_added);
    String st2 = getResources().getString(R.string.is_quit_the_group_chat);
    String st3 = getResources().getString(R.string.chatting_is_dissolution);
    String st4 = getResources().getString(R.string.are_empty_group_of_news);
    String st5 = getResources().getString(R.string.is_modify_the_group_name);
    final String st6 = getResources().getString(R.string.Modify_the_group_name_successful);
    final String st7 = getResources().getString(R.string.change_the_group_name_failed_please);
    String st8 = getResources().getString(R.string.Are_moving_to_blacklist);
    final String st9 = getResources().getString(R.string.failed_to_move_into);

    final String stsuccess = getResources().getString(R.string.Move_into_blacklist_success);
    if (resultCode == RESULT_OK) {
        if (progressDialog == null) {
            progressDialog = new ProgressDialog(GroupDetailsActivity.this);
            progressDialog.setMessage(st1);
            progressDialog.setCanceledOnTouchOutside(false);
        }//w w w.ja  v a  2s  .c o m
        switch (requestCode) {
        case REQUEST_CODE_ADD_USER:// ?
            final String[] newmembers = data.getStringArrayExtra("newmembers");
            progressDialog.setMessage(st1);
            progressDialog.show();
            addMembersToGroup(newmembers);
            break;
        case REQUEST_CODE_EXIT: // 
            progressDialog.setMessage(st2);
            progressDialog.show();
            exitGrop();
            break;
        case REQUEST_CODE_EXIT_DELETE: // 
            progressDialog.setMessage(st3);
            progressDialog.show();
            deleteGrop();
            break;
        case REQUEST_CODE_CLEAR_ALL_HISTORY:
            // ??
            progressDialog.setMessage(st4);
            progressDialog.show();
            clearGroupHistory();
            break;

        case REQUEST_CODE_EDIT_GROUPNAME: //??
            final String returnData = data.getStringExtra("data");
            if (!TextUtils.isEmpty(returnData)) {
                progressDialog.setMessage(st5);
                progressDialog.show();

                new Thread(new Runnable() {
                    public void run() {
                        try {
                            EMGroupManager.getInstance().changeGroupName(groupId, returnData);
                            runOnUiThread(new Runnable() {
                                public void run() {
                                    ((TextView) findViewById(R.id.group_name))
                                            .setText(returnData + "(" + group.getAffiliationsCount() + st);
                                    progressDialog.dismiss();
                                    Toast.makeText(getApplicationContext(), st6, 0).show();
                                }
                            });

                        } catch (EaseMobException e) {
                            e.printStackTrace();
                            runOnUiThread(new Runnable() {
                                public void run() {
                                    progressDialog.dismiss();
                                    Toast.makeText(getApplicationContext(), st7, 0).show();
                                }
                            });
                        }
                    }
                }).start();
            }
            break;
        case REQUEST_CODE_ADD_TO_BALCKLIST:
            progressDialog.setMessage(st8);
            progressDialog.show();
            new Thread(new Runnable() {
                public void run() {
                    try {
                        EMGroupManager.getInstance().blockUser(groupId, longClickUsername);
                        runOnUiThread(new Runnable() {
                            public void run() {
                                refreshMembers();
                                progressDialog.dismiss();
                                Toast.makeText(getApplicationContext(), stsuccess, 0).show();
                            }
                        });
                    } catch (EaseMobException e) {
                        runOnUiThread(new Runnable() {
                            public void run() {
                                progressDialog.dismiss();
                                Toast.makeText(getApplicationContext(), st9, 0).show();
                            }
                        });
                    }
                }
            }).start();

            break;
        default:
            break;
        }
    }
}

From source file:com.ubuntuone.android.files.activity.StoreActivity.java

/**
 * Builds a simple indeterminate progress dialog.
 * // w  w w .j  a va  2  s .  com
 * @param messageResId
 *            the message resource id to use
 * @return a simple progress dialog
 */
private ProgressDialog buildSimpleProgressDialog(int messageResId) {
    final ProgressDialog dialog = new ProgressDialog(StoreActivity.this);
    dialog.setIcon(android.R.drawable.ic_dialog_info);
    dialog.setIndeterminate(true);
    dialog.setMessage(getText(messageResId));
    return dialog;
}

From source file:com.ccxt.whl.activity.SettingsFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    DeviceUuidFactory uuid = new DeviceUuidFactory(getActivity());
    uid = uuid.getDeviceUuid().toString();
    pd = new ProgressDialog(getActivity());
    pd.setMessage("??...");
    /***************?**************/
    rl_user_pic = (RelativeLayout) getView().findViewById(R.id.rl_user_pic);
    rl_user_nicheng = (RelativeLayout) getView().findViewById(R.id.rl_user_nicheng);
    rl_user_xingbie = (RelativeLayout) getView().findViewById(R.id.rl_user_xingbie);
    rl_user_nianling = (RelativeLayout) getView().findViewById(R.id.rl_user_nianling);
    rl_user_chengshi = (RelativeLayout) getView().findViewById(R.id.rl_user_chengshi);
    rl_user_zainadongtai = (RelativeLayout) getView().findViewById(R.id.rl_user_zainadongtai);
    //---------/*from ww w .j  a v a2s.c  o  m*/
    rl_user_zhiye = (RelativeLayout) getView().findViewById(R.id.rl_user_zhiye);
    rl_user_qianming = (RelativeLayout) getView().findViewById(R.id.rl_user_qianming);

    //?
    iv_user_photo = (ImageView) getView().findViewById(R.id.iv_user_photo);
    tv_user_nicheng = (TextView) getView().findViewById(R.id.tv_user_nicheng);
    tv_user_xingbie = (TextView) getView().findViewById(R.id.tv_user_xingbie);
    tv_user_nianling = (TextView) getView().findViewById(R.id.tv_user_nianling);
    tv_user_chengshi = (TextView) getView().findViewById(R.id.tv_user_chengshi);
    tv_user_zainadongtai = (TextView) getView().findViewById(R.id.tv_user_zainadongtai);
    //--------
    tv_user_zhiye = (TextView) getView().findViewById(R.id.tv_user_zhiye);
    tv_user_qianming = (TextView) getView().findViewById(R.id.tv_user_qianming);

    //??
    UserPic = PreferenceUtils.getInstance(getActivity()).getSettingUserPic();
    UserNickName = PreferenceUtils.getInstance(getActivity()).getSettingUserNickName();
    UserSex = PreferenceUtils.getInstance(getActivity()).getSettingUserSex();
    UserAge = PreferenceUtils.getInstance(getActivity()).getSettingUserAge();
    UserArea = PreferenceUtils.getInstance(getActivity()).getSettingUserArea();
    UserZaina = PreferenceUtils.getInstance(getActivity()).getSettingUserZaina();
    //-----
    UserZhiye = PreferenceUtils.getInstance(getActivity()).getSettingUserZhiye();
    UserQianming = PreferenceUtils.getInstance(getActivity()).getSettingUserQianming();

    //?
    //iv_user_photo
    ImageLoader.getInstance().displayImage(UserPic, iv_user_photo, ImageOptions.getOptions());
    tv_user_nicheng.setText(UserNickName);
    tv_user_xingbie.setText(UserSex);
    tv_user_nianling.setText(UserAge);
    tv_user_chengshi.setText(UserArea);
    tv_user_zhiye.setText(UserZhiye);
    tv_user_qianming.setText(UserQianming);

    if (CommonUtils.isNullOrEmpty(UserZaina)) {
        UserZaina = "???";
    }
    tv_user_zainadongtai.setText(UserZaina);
    /***************?**************/

    rl_switch_notification = (RelativeLayout) getView().findViewById(R.id.rl_switch_notification);
    rl_switch_sound = (RelativeLayout) getView().findViewById(R.id.rl_switch_sound);
    rl_switch_vibrate = (RelativeLayout) getView().findViewById(R.id.rl_switch_vibrate);
    rl_switch_speaker = (RelativeLayout) getView().findViewById(R.id.rl_switch_speaker);

    iv_switch_open_notification = (ImageView) getView().findViewById(R.id.iv_switch_open_notification);
    iv_switch_close_notification = (ImageView) getView().findViewById(R.id.iv_switch_close_notification);
    iv_switch_open_sound = (ImageView) getView().findViewById(R.id.iv_switch_open_sound);
    iv_switch_close_sound = (ImageView) getView().findViewById(R.id.iv_switch_close_sound);
    iv_switch_open_vibrate = (ImageView) getView().findViewById(R.id.iv_switch_open_vibrate);
    iv_switch_close_vibrate = (ImageView) getView().findViewById(R.id.iv_switch_close_vibrate);
    iv_switch_open_speaker = (ImageView) getView().findViewById(R.id.iv_switch_open_speaker);
    iv_switch_close_speaker = (ImageView) getView().findViewById(R.id.iv_switch_close_speaker);
    llDiagnose = (LinearLayout) getView().findViewById(R.id.ll_diagnose);
    logoutBtn = (Button) getView().findViewById(R.id.btn_logout);
    exit = (Button) getView().findViewById(R.id.btn_exit);

    if (!TextUtils.isEmpty(EMChatManager.getInstance().getCurrentUser())) {
        //logoutBtn.setText(getString(R.string.button_logout) + "(" + EMChatManager.getInstance().getCurrentUser() + ")");
        logoutBtn.setText(getString(R.string.button_logout));

    }

    textview1 = (TextView) getView().findViewById(R.id.textview1);
    textview2 = (TextView) getView().findViewById(R.id.textview2);

    blacklistContainer = (LinearLayout) getView().findViewById(R.id.ll_black_list);
    wo_gushi = (LinearLayout) getView().findViewById(R.id.wo_gushi);

    /*********************/
    rl_user_pic.setOnClickListener(this);
    rl_user_nicheng.setOnClickListener(this);
    rl_user_xingbie.setOnClickListener(this);
    rl_user_nianling.setOnClickListener(this);
    rl_user_chengshi.setOnClickListener(this);
    rl_user_zainadongtai.setOnClickListener(this);
    rl_user_zhiye.setOnClickListener(this);
    rl_user_qianming.setOnClickListener(this);
    /*********************/

    blacklistContainer.setOnClickListener(this);
    rl_switch_notification.setOnClickListener(this);
    rl_switch_sound.setOnClickListener(this);
    rl_switch_vibrate.setOnClickListener(this);
    rl_switch_speaker.setOnClickListener(this);
    llDiagnose.setOnClickListener(this);
    logoutBtn.setOnClickListener(this);
    exit.setOnClickListener(this);
    wo_gushi.setOnClickListener(this);

    chatOptions = EMChatManager.getInstance().getChatOptions();
    if (chatOptions.getNotificationEnable()) {
        iv_switch_open_notification.setVisibility(View.VISIBLE);
        iv_switch_close_notification.setVisibility(View.INVISIBLE);
    } else {
        iv_switch_open_notification.setVisibility(View.INVISIBLE);
        iv_switch_close_notification.setVisibility(View.VISIBLE);
    }
    if (chatOptions.getNoticedBySound()) {
        iv_switch_open_sound.setVisibility(View.VISIBLE);
        iv_switch_close_sound.setVisibility(View.INVISIBLE);
    } else {
        iv_switch_open_sound.setVisibility(View.INVISIBLE);
        iv_switch_close_sound.setVisibility(View.VISIBLE);
    }
    if (chatOptions.getNoticedByVibrate()) {
        iv_switch_open_vibrate.setVisibility(View.VISIBLE);
        iv_switch_close_vibrate.setVisibility(View.INVISIBLE);
    } else {
        iv_switch_open_vibrate.setVisibility(View.INVISIBLE);
        iv_switch_close_vibrate.setVisibility(View.VISIBLE);
    }

    if (chatOptions.getUseSpeaker()) {
        iv_switch_open_speaker.setVisibility(View.VISIBLE);
        iv_switch_close_speaker.setVisibility(View.INVISIBLE);
    } else {
        iv_switch_open_speaker.setVisibility(View.INVISIBLE);
        iv_switch_close_speaker.setVisibility(View.VISIBLE);
    }

    /*************************http?***********************/
    responseHandler = new BaseJsonHttpResponseHandler() {

        @Override
        public void onSuccess(int statusCode, Header[] headers, String rawJsonResponse, Object response) {
            // TODO Auto-generated method stub 
            Log.d("setting_qes" + rawJsonResponse);
            pd.dismiss();
            if (CommonUtils.isNullOrEmpty(rawJsonResponse)) {
                Toast.makeText(getActivity(), "?,?", 0).show();
                return;
            }

            Map<String, Object> lm = JsonToMapList.getMap(rawJsonResponse);
            if (lm.get("status").toString() != null && lm.get("status").toString().equals("yes")) {
                Toast.makeText(getActivity(), "?", 0).show();
                Log.d("message==" + lm.get("message").toString());
                if (!CommonUtils.isNullOrEmpty(lm.get("result").toString())) {
                    Map<String, Object> lmres = JsonToMapList.getMap(lm.get("result").toString());
                    String nickname = lmres.get("nickname").toString();
                    String age = lmres.get("age").toString();
                    String sex = lmres.get("sex").toString();
                    String headurl = lmres.get("headurl").toString();
                    String zhiye = lmres.get("zhiye").toString();
                    String qianming = lmres.get("qianming").toString();
                    if (!CommonUtils.isNullOrEmpty(nickname)) {
                        tv_user_nicheng.setText(nickname);
                        PreferenceUtils.getInstance(getActivity()).setSettingUserNickName(nickname);
                    } else if (!CommonUtils.isNullOrEmpty(age)) {
                        tv_user_nianling.setText(age);
                        PreferenceUtils.getInstance(getActivity()).setSettingUserAge(age);
                    } else if (!CommonUtils.isNullOrEmpty(sex)) {
                        tv_user_xingbie.setText(sex);
                        PreferenceUtils.getInstance(getActivity()).setSettingUserSex(age);
                    } else if (!CommonUtils.isNullOrEmpty(headurl)) {
                        //tv_user_xingbie.setText(sex);
                        //?
                        ImageLoader.getInstance().displayImage(headurl, iv_user_photo,
                                ImageOptions.getOptions());
                        //ImageLoader.getInstance().displayImage(headurl, iv_user_photo);
                        //ImageLoader.getInstance().notify();
                        PreferenceUtils.getInstance(getActivity()).setSettingUserPic(headurl);
                    } else if (!CommonUtils.isNullOrEmpty(zhiye)) {//?
                        tv_user_zhiye.setText(zhiye);
                        PreferenceUtils.getInstance(getActivity()).setSettingUserZhiye(zhiye);
                    } else if (!CommonUtils.isNullOrEmpty(qianming)) {//??
                        tv_user_qianming.setText(qianming);
                        PreferenceUtils.getInstance(getActivity()).setSettingUserQianming(qianming);
                    }

                }
            }
        }

        @Override
        public void onFailure(int statusCode, Header[] headers, Throwable throwable, String rawJsonData,
                Object errorResponse) {
            // TODO Auto-generated method stub
            pd.dismiss();
            Toast.makeText(getActivity(), ",?", 0).show();
            return;
        }

        @Override
        protected Object parseResponse(String rawJsonData, boolean isFailure) throws Throwable {
            // TODO Auto-generated method stub
            return null;
        }

    };
}