fbstandbyticker.java

来自「Sony Ericsson手机上的Facebook客户端全套代码」· Java 代码 · 共 637 行 · 第 1/2 页

JAVA
637
字号
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   FbStandByTicker.java

package com.sonyericsson.fb.ui.fbPages;

import com.sonyericsson.fb.api.data.FbStatusItemData;
import com.sonyericsson.fb.api.request.*;
import com.sonyericsson.fb.content.FbStandbyInvocationHandler;
import com.sonyericsson.fb.ui.PageController;
import com.sonyericsson.fb.ui.fbComponents.standbyItems.FbStandByBubble;
import com.sonyericsson.fb.ui.fbComponents.standbyItems.FbStandbyThumbnail;
import com.sonyericsson.fb.utils.FbRecordStore;
import com.sonyericsson.fb.utils.Logger;
import com.sonyericsson.homescreen.Homescreen;
import com.sonyericsson.homescreen.KeyListener;
import java.util.*;
import javax.microedition.lcdui.*;
import se.southend.drops.gui.BitmapSprite;
import se.southend.drops.integeraffector.*;
import se.southend.drops.scene.Group;
import se.southend.drops.scene.Node;
import se.southend.drops.screen.*;
import se.southend.drops.tools.Tools;

// Referenced classes of package com.sonyericsson.fb.ui.fbPages:
//            Page

public class FbStandByTicker extends Page
    implements IFbAPIRequestListener, CommandListener, KeyListener
{

    public FbStandByTicker()
    {
        FbRecordStore rs;
        TICKER_WITH = 180;
        NUM_SLOTS = 5;
        TOTAL_NUMBER_OF_PICTURES = 30;
        OFFSET = 45;
        MOVE_DURATION = 300;
        TUMBNAIL_POSITION_Y = 12800;
        SMALL_ICON_SIZE = 31;
        LARGE_ICON_SIZE = 45;
        RIGHT_ARROW_POSITION_X = 28928;
        RIGHT_ARROW_POSITION_Y = 12800;
        LEFT_ARROW_POSITION_X = -28928;
        LEFT_ARROW_POSITION_Y = 12800;
        TRANSITION_SCALE_STEP = 100;
        UNFOCUSED_MODE_IMAGE_ALPHA = 128;
        FOCUSED_IMAGE_OFFSET_Y = -2;
        NR_VISIBLE_UNFOCUSED_THUMBS_LEFT = 2;
        NR_VISIBLE_UNFOCUSED_THUMBS_RIGHT = 2;
        mIsFocused = false;
        mImages = null;
        mRightArrow = null;
        mLeftArrow = null;
        mFocusedHaloImage = null;
        mCurrentActiveIndex = 0;
        mStatusData = new Vector();
        mHomescreen = ScreenEngine.getInstance().getHomescreen();
        isMoving = false;
        isScaling = false;
        isRefreshing = false;
        dataReady = false;
        mBubbleAnimationInitialized = false;
        mBubbleAnimationInitTime = 0x7fffffffffffffffL;
        mLastUpdateTimeMillis = ScreenEngine.getInstance().getTime();
        mLastStepTimeMillis = ScreenEngine.getInstance().getTime();
        mAutoUpdateIntervalInSeconds = 0L;
        rs = new FbRecordStore();
        rs.open(false);
        mAutoUpdateIntervalInSeconds = rs.getUpdateScheduleInSeconds();
        Exception e;
        try
        {
            rs.close();
        }
        // Misplaced declaration of an exception variable
        catch(Exception e)
        {
            Logger.printErrorln("FbStandByTicker() 2: Caught exception: " + e.toString());
        }
        break MISSING_BLOCK_LABEL_376;
        e;
        Logger.printErrorln("FbStandByTicker() 1: Caught exception: " + e.toString());
        try
        {
            rs.close();
        }
        // Misplaced declaration of an exception variable
        catch(Exception e)
        {
            Logger.printErrorln("FbStandByTicker() 2: Caught exception: " + e.toString());
        }
        break MISSING_BLOCK_LABEL_376;
        Exception exception;
        exception;
        try
        {
            rs.close();
        }
        catch(Exception e)
        {
            Logger.printErrorln("FbStandByTicker() 2: Caught exception: " + e.toString());
        }
        throw exception;
    }

    public void create()
    {
        if((mImages == null || mImages.getChildCount() == 0) && !isRefreshing)
        {
            isRefreshing = true;
            FbAPIRequestWorker.getInstance().addAPIRequest(new FbGetFriendsStatusRequest(this, 30));
        }
        boolean focus = true;
        focus = !ScreenEngine.getInstance().isHomescreenInStandby();
        tickerFocus(focus);
    }

    public void hide()
    {
        tickerFocus(false);
        super.hide();
    }

    private void populateStandbyTicker(Vector statusData)
    {
        mCurrentActiveIndex = 0;
        mCurrentTargetPosition = 0;
        mStatusBubble = new FbStandByBubble();
        add(mStatusBubble);
        mImages = new Group();
        for(int i = 0; i < 30 && i < statusData.size(); i++)
        {
            FbStatusItemData status = (FbStatusItemData)statusData.elementAt(i);
            int slot = i - 0;
            int xPos = slot * 45 << 8;
            FbStandbyThumbnail thumbnail = new FbStandbyThumbnail(status);
            thumbnail.setPosition(xPos, 0);
            thumbnail.setAnchor(3);
            if(i == 0)
            {
                thumbnail.setSize(45, 45, getShadowHeight(45, 0), true, 255);
                setStatusText(thumbnail.getStatusText());
                setFriendNameText(thumbnail.getFriendName());
                setStatusUpdateTime(thumbnail.getStatusUpdateTime());
                setArrowPosition(2);
                mStatusBubble.animateIn(getAffectorHandler());
            } else
            {
                thumbnail.setSize(31, 31, getShadowHeight(31, 0), false, mIsFocused ? 255 : 128);
            }
            thumbnail.setVisible(i < 5);
            mImages.add(thumbnail);
        }

        mImages.setLocalPosition(0, 12800);
        add(mImages);
        if(mImages.getChildCount() > 1)
        {
            boolean arrowsVisible = true;
            arrowsVisible = !ScreenEngine.getInstance().isHomescreenInStandby();
            javax.microedition.lcdui.Image rightArrowImage = Tools.loadImage("/standby_arrow_right.png");
            mRightArrow = new BitmapSprite(rightArrowImage);
            mRightArrow.setLocalPosition(28928, 12800);
            mRightArrow.setVisible(arrowsVisible);
            javax.microedition.lcdui.Image leftArrowImage = Tools.loadImage("/standby_arrow_left.png");
            mLeftArrow = new BitmapSprite(leftArrowImage);
            mLeftArrow.setLocalPosition(-28928, 12800);
            mLeftArrow.setVisible(arrowsVisible);
            mLeftArrow.setVisible(false);
            add(mRightArrow);
            add(mLeftArrow);
        }
        mFocusedHaloImage = new BitmapSprite(Tools.loadImage("/image_effect_big.png"));
        mFocusedHaloImage.setLocalPosition(0, 12288);
        add(mFocusedHaloImage);
    }

    public void next()
    {
        move(1, !mIsFocused);
    }

    public void previous()
    {
        move(-1, !mIsFocused);
    }

    private void move(int direction, boolean wrapAround)
    {
        PageController.getInstance().showHomescreenInfo(!mIsFocused);
        if(mImages.getChildCount() <= 1)
            return;
        int newActiveIndex = mCurrentActiveIndex + direction;
        if(newActiveIndex < 0)
            if(wrapAround)
                newActiveIndex = mImages.getChildCount() - 1;
            else
                return;
        if(newActiveIndex >= mImages.getChildCount())
            if(wrapAround)
                newActiveIndex = 0;
            else
                return;
        if(direction < 0)
            setThumbsVisible(mCurrentActiveIndex - 2 - 1, mCurrentActiveIndex + 2);
        else
            setThumbsVisible(mCurrentActiveIndex - 2, mCurrentActiveIndex + 2 + 1);
        if(mLeftArrow != null)
            mLeftArrow.setVisible(mIsFocused && newActiveIndex > 0);
        if(mRightArrow != null)
            mRightArrow.setVisible(mIsFocused && newActiveIndex + 1 < mImages.getChildCount());
        isMoving = true;
        isScaling = true;
        if(mFocusedHaloImage != null)
            mFocusedHaloImage.setVisible(false);
        FbStandbyThumbnail current = (FbStandbyThumbnail)mImages.getChild(mCurrentActiveIndex);
        FbStandbyThumbnail next = (FbStandbyThumbnail)mImages.getChild(newActiveIndex);
        if(direction == 1 && mCurrentActiveIndex == mImages.getChildCount() - 1 || direction == -1 && mCurrentActiveIndex == 0)
        {
            int oldTargetPosition = mCurrentTargetPosition;
            mCurrentTargetPosition = mCurrentTargetPosition + ((mImages.getChildCount() - 1) * direction * 45 << 8);
            moveThumbnails(oldTargetPosition, mCurrentTargetPosition, 300, 0);
        } else
        {
            int oldTargetPosition = mCurrentTargetPosition;
            mCurrentTargetPosition = mCurrentTargetPosition - (direction * 45 << 8);
            moveThumbnails(oldTargetPosition, mCurrentTargetPosition, 300, 0);
        }
        mCurrentActiveIndex = newActiveIndex;
        setArrowPosition(2);
        mStatusBubble.show(false);
        mBubbleAnimationInitialized = false;
        mPrevScaleValue = 0;
        getAffectorHandler().addAffector(14. new InterpolationAffector(300, 0, current, next) {

            public void run()
            {
                int newValue = getValue();
                if(newValue - mPrevScaleValue > 100)
                {
                    current.setSize(45 - newValue, 45 - newValue, getShadowHeight(45 - newValue, 0), false, mIsFocused ? 255 : 128);
                    next.setSize(31 + newValue, 31 + newValue, getShadowHeight(31 + newValue, 0), false, mIsFocused ? 255 : 128);
                    mPrevScaleValue = newValue;
                }
            }

            public void finish()
            {
                int newValue = getValue();
                current.setSize(45 - newValue, 45 - newValue, getShadowHeight(45 - newValue, 0), false, mIsFocused ? 255 : 128);
                next.setSize(31 + newValue, 31 + newValue, getShadowHeight(31 + newValue, -2), true, 255);
                current.setLocalPosition(current.getLocalX(), 0);
                next.setLocalPosition(current.getLocalX(), -512);
                setStatusText(next.getStatusText());
                setFriendNameText(next.getFriendName());
                setStatusUpdateTime(next.getStatusUpdateTime());
                initializeStatusBubbleAnimation();
                isScaling = false;
                if(mFocusedHaloImage != null && !isMoving)
                    mFocusedHaloImage.setVisible(true);
            }

        });
    }

    private void moveThumbnails(int startPos, int endPos, int duration, int interpolation)
    {
        getAffectorHandler().addAffector(new InterpolationAffector(startPos, endPos, duration, interpolation) {

            public void run()
            {
                mImages.setLocalPosition(getValue(), 12800);
            }

            public void finish()
            {
                mImages.setLocalPosition(getValue(), 12800);
                isMoving = false;
                if(mFocusedHaloImage != null && !isScaling)
                    mFocusedHaloImage.setVisible(true);
                setThumbsVisible(mCurrentActiveIndex - 2, mCurrentActiveIndex + 2);
            }

        });
    }

    private void initializeStatusBubbleAnimation()
    {
        mBubbleAnimationInitTime = ScreenEngine.getInstance().getTime();
        mBubbleAnimationInitialized = true;
    }

    private boolean shouldStartStatusBubbleAnimation()
    {
        if(!mBubbleAnimationInitialized)
            return false;
        else
            return ScreenEngine.getInstance().getTime() - mBubbleAnimationInitTime > 250L;
    }

    private void setStatusText(String status)
    {
        mStatusBubble.setStatusText(status);
    }

    private void setFriendNameText(String friendName)
    {
        mStatusBubble.setFriendName(friendName);
    }

    private void setStatusUpdateTime(long statusUpdateTime)
    {
        mStatusBubble.setTimeStamp(statusUpdateTime);
    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?