Esempio n. 1
0
void RequestList::downloadNextPhoto()
{
    if (mPhotoLoadIndex > 0)
    {
        mPhotoLoadIndex--;
        int index = mPhotoLoadIndex;
        EziFBIncomingRequest* incomingRequest = NULL;
        EziFacebookFriend *friendObject = NULL;
        
        incomingRequest = (EziFBIncomingRequest*)_fbIncomingRequestList->objectAtIndex(index);
                
        friendObject = incomingRequest->getSender();
        
        unsigned int size = 200;
        
        if (PHOTO_SCALE <= 0.5 && PHOTO_SCALE > 0.25)
        {
            size = 100;
        }
        else if (PHOTO_SCALE < 0.25)
        {
            size = 50;
        }
        
        EziSocialObject::sharedObject()->getProfilePicForID(friendObject->getFBID(),
                                                            size, size, false);
    }
    else
    {
        this->unscheduleUpdate();
        ALL_DOWNLOAD_COMPLETE = true;
        this->hideLoadingAction();
    }
}
Esempio n. 2
0
void FriendList::downloadNextPhoto()
{
    if (mPhotoLoadIndex > 0)
    {
        mPhotoLoadIndex--;
        EziFacebookFriend* friendDetails = (EziFacebookFriend*)mFriendList->objectAtIndex(mPhotoLoadIndex);
        
        unsigned int size = 200;
        
        if (PHOTO_SCALE <= 0.5 && PHOTO_SCALE > 0.25)
        {
            size = 100;
        }
        else if (PHOTO_SCALE < 0.25)
        {
            size = 50;
        }
        
        EziSocialObject::sharedObject()->getProfilePicForID(friendDetails->getFBID(),
                                                            size, size, false);
    }
    else
    {
        this->unscheduleUpdate();
        ALL_DOWNLOAD_COMPLETE = true;
        this->hideLoadingAction();
    }
}
Esempio n. 3
0
CCTableViewCell* FriendList::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
    EziFacebookFriend* friendDetails = (EziFacebookFriend*)mFriendList->objectAtIndex(idx);
    std::string friendID            = friendDetails->getFBID();
    std::string friendName          = friendDetails->getName();
    std::string installed           = "";
    std::string score               = "";
    CCSprite* profilePic            = NULL;
    
    // Set the score.
    long mylong = friendDetails->getScore();
    std::stringstream mystream;
    mystream << mylong;
    score = mystream.str();
    
    // Set the install status
    if (friendDetails->isInstalled())
    {
        installed = "Installed";
    }
    else
    {
        installed = "Not Installed";
    }
    
    
    CCTableViewCell *cell = table->dequeueCell();
    
    
    if (!cell) // Creation of Cell.
    {
        cell = new CCTableViewCell();
        cell->autorelease();
        
        CCLayerColor* colorLayer = CCLayerColor::create(ccc4(20, 0, 40, 255), SCREEN_WIDTH, CELL_HEIGHT);
        cell->addChild(colorLayer);
        
        CCSprite *sprite = NULL;
        
        if (strcmp(friendDetails->getPhotoPath(), "") != 0)
        {
            const char*  picPath = friendDetails->getPhotoPath();
            sprite = CCSprite::create(picPath);
        }
        else
        {
            sprite = CCSprite::create(FB_DEFAULT_PHOTO);
        }
        
        if (sprite == NULL)
        {
            CCLOG("Sprite is NULL");
        }
        
        sprite->setAnchorPoint(ccp(0, 0.5));
        sprite->setPosition(ccp(20, CELL_HEIGHT/2));
        cell->addChild(sprite);
        //sprite->setScale(0.9);
        sprite->setTag(FRIEND_PHOTO_TAG);
        
        // Friend Facebook ID
        CCLabelTTF *friendIDLabel = CCLabelTTF::create(friendID.c_str(), "Helvetica", 20.0 * MENU_FONT_SCALE);
        
        float gapY =  (CELL_HEIGHT - (friendIDLabel->getContentSize().height * 2)) / 3;
        
        if (sprite)
        {
            friendIDLabel->setPosition(ccp(sprite->getPositionX() + sprite->getContentSize().width + 20, CELL_HEIGHT - gapY));
        }
        
		friendIDLabel->setAnchorPoint(ccp(0, 1));
        friendIDLabel->setTag(FRIEND_ID_LABEL_TAG);
        cell->addChild(friendIDLabel);
        
        // Friend Facebook Name
        CCLabelTTF *friendNameLabel = CCLabelTTF::create(friendName.c_str(), "Helvetica", 20.0 * MENU_FONT_SCALE);
        friendNameLabel->setPosition(ccp(friendIDLabel->getPositionX(),
                                         friendIDLabel->getPositionY() - friendIDLabel->getContentSize().height - gapY));
        
		friendNameLabel->setAnchorPoint(ccp(0, 1));
        friendNameLabel->setTag(FRIEND_NAME_LABEL_TAG);
        cell->addChild(friendNameLabel);
        
        
        // High Score
        CCLabelTTF *scoreLabel = CCLabelTTF::create(score.c_str(), "Helvetica", 20.0 * MENU_FONT_SCALE);
        scoreLabel->setPosition(ccp(SCREEN_WIDTH - 20, friendIDLabel->getPositionY()));
        
        scoreLabel->setAnchorPoint(ccp(1, 1));
        scoreLabel->setTag(FRIEND_SCORE_LABEL_TAG);
        cell->addChild(scoreLabel);
        
        // Installed String
        CCLabelTTF *installedLabel = CCLabelTTF::create(installed.c_str(), "Helvetica", 20.0 * MENU_FONT_SCALE);
        installedLabel->setPosition(ccp(SCREEN_WIDTH - 20, friendNameLabel->getPositionY()));
        
        installedLabel->setAnchorPoint(ccp(1, 1));
        installedLabel->setTag(FRIEND_INSTALLED_LABEL_TAG);
        cell->addChild(installedLabel);
        
    }
    else
    {
        
        // Set the Friend ID
        CCLabelTTF *friendIDLabel = (CCLabelTTF*)cell->getChildByTag(FRIEND_ID_LABEL_TAG);
        friendIDLabel->setString(friendID.c_str());
        
        // Set the Friend Name
        CCLabelTTF *friendNameLabel = (CCLabelTTF*)cell->getChildByTag(FRIEND_NAME_LABEL_TAG);
        friendNameLabel->setString(friendName.c_str());
        
        
        CCLabelTTF *highScoreLabel = (CCLabelTTF*)cell->getChildByTag(FRIEND_SCORE_LABEL_TAG);
        if (highScoreLabel != NULL)
        {
            highScoreLabel->setString(score.c_str());
        }
        
        highScoreLabel->setVisible(mEnableHighScoreDisplay);
        
        
        CCLabelTTF *installedLabel = (CCLabelTTF*)cell->getChildByTag(FRIEND_INSTALLED_LABEL_TAG);
        if (installedLabel != NULL)
        {
            installedLabel->setString(installed.c_str());
        }
        installedLabel->setVisible(mEnableInstalledDisplay);
        
        
        CCSprite* cellProfilePic = (CCSprite*)cell->getChildByTag(FRIEND_PHOTO_TAG);
        
        if (strcmp("", friendDetails->getPhotoPath()) != 0 )
        {
            const char*  picPath = friendDetails->getPhotoPath();
            profilePic = CCSprite::create(picPath);
            
        }
        else
        {
            profilePic = CCSprite::create(FB_DEFAULT_PHOTO);
        }
        
        
        cellProfilePic->setTexture(profilePic->getTexture());
    }
    
    
    return cell;
}
Esempio n. 4
0
void BaseScene::fbFriendsCallback(int responseCode, const char* responseMessage, cocos2d::CCArray* friends)
{
    if (responseCode == EziSocialWrapperNS::RESPONSE_CODE::FB_FRIEND_GET_SUCCESS)
    {
        for (int i=0; i<friends->count(); i++)
        {
            EziFacebookFriend* myFriend = (EziFacebookFriend*)(friends->objectAtIndex(i));
            CCString* friendKey = CCString::createWithFormat("Friend_ID_%d", (i+1), NULL);
            CCUserDefault::sharedUserDefault()->setStringForKey(friendKey->getCString(), myFriend->getFBID());
        }
        
        if (friends->count() > 0)
        {
            CCLOG("[EziSocial Log]: %d friends saved in DB for future use.", friends->count());
            CCUserDefault::sharedUserDefault()->setIntegerForKey("FRIENDS_COUNT", friends->count());
            
            // Save these friends for future use ;)
            CCUserDefault::sharedUserDefault()->flush();
        }
    }
}