⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pagecontroller.java

📁 Sony Ericsson手机上的Facebook客户端全套代码
💻 JAVA
字号:
// 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:   PageController.java

package com.sonyericsson.fb.ui;

import com.sonyericsson.fb.api.*;
import com.sonyericsson.fb.content.FbStandbyInvocationHandler;
import com.sonyericsson.fb.content.IFbInvocationRequestListener;
import com.sonyericsson.fb.strings.Strings;
import com.sonyericsson.fb.ui.fbPages.FbDialog;
import com.sonyericsson.fb.ui.fbPages.FbLogin;
import com.sonyericsson.fb.ui.fbPages.FbPictureUpload;
import com.sonyericsson.fb.ui.fbPages.FbStandByTicker;
import com.sonyericsson.fb.ui.fbPages.Page;
import com.sonyericsson.fb.utils.FbRecordStore;
import com.sonyericsson.fb.utils.Logger;
import com.sonyericsson.homescreen.Homescreen;
import com.sonyericsson.homescreen.KeyListener;
import se.southend.drops.screen.*;

// Referenced classes of package com.sonyericsson.fb.ui:
//            BGLayer

public class PageController
    implements IFbSessionHandlerStateListener, KeyListener, IFbInvocationRequestListener
{

    public static PageController getInstance()
    {
        if(_instance == null)
            _instance = new PageController();
        return _instance;
    }

    private PageController()
    {
        mStandbyTicker = null;
        mLoginPage = null;
        mDialogPage = null;
        mBGLayer = null;
        mainMidletLoggingIn = false;
        loginComplete = false;
        _tickerSoftkey = -1;
        String softkey = Device.getProperty("Facebook-Ticker-Softkey");
        int i = 0;
        try
        {
            i = Integer.parseInt(softkey);
            if(i == 1)
                _tickerSoftkey = 3;
            else
            if(i == 0)
                _tickerSoftkey = 2;
        }
        catch(Exception e) { }
        FbStandbyInvocationHandler.getInstance().addListener(this);
    }

    public void showPage(int page)
    {
        if(mCurrent != null)
            mCurrent.setInputEnabled(false);
        switch(page)
        {
        case 1: // '\001'
        case 2: // '\002'
        default:
            break;

        case 0: // '\0'
            if(mLoginPage == null)
                mLoginPage = new FbLogin();
            if(mCurrent != null && !(mCurrent instanceof FbLogin))
                mCurrent.hide();
            if(!(mCurrent instanceof FbLogin))
                mLoginPage.open();
            mLoginPage.show();
            mCurrent = mLoginPage;
            break;

        case 5: // '\005'
            if(mDialogPage == null)
                mDialogPage = new FbDialog();
            mDialogPage.open();
            mDialogPage.setText(Strings.get(0));
            mDialogPage.setParentPage(0);
            mDialogPage.show();
            mCurrent.hide();
            mCurrent = mDialogPage;
            break;

        case 3: // '\003'
            FbPictureUpload picUpload = new FbPictureUpload();
            picUpload.open();
            picUpload.show();
            mCurrent.hide();
            mCurrent = picUpload;
            break;

        case 4: // '\004'
            FbStandByTicker standby = new FbStandByTicker();
            if(mCurrent != null)
                mCurrent.hide();
            mCurrent = mStandbyTicker = standby;
            standby.open();
            standby.show();
            break;
        }
    }

    public void startApp()
    {
        ScreenEngine.getInstance().setFullScreenMode(false);
        mBGLayer = new BGLayer();
        FbSessionHandler.getInstance().addObeserver(this);
        if(ScreenEngine.getInstance().isRunningOnHomescreen())
        {
            mHomescreen = ScreenEngine.getInstance().getHomescreen();
            if(_tickerSoftkey != -1)
            {
                mHomescreen.setKey(_tickerSoftkey, "Facebook");
                mHomescreen.addKeyListener(this);
            }
        } else
        {
            mBGLayer.open("bg");
            showPage(0);
        }
    }

    public void onLoginComplete()
    {
        if(_tickerSoftkey != -1)
            mHomescreen.setKey(_tickerSoftkey, Strings.get(48));
        showPage(4);
    }

    public void onLoginFailure()
    {
        Logger.println("Login failed");
        showPage(5);
        if(!mainMidletLoggingIn)
            FbStandbyInvocationHandler.getInstance().sendMessage(10);
    }

    public void logIn(String email, String password, boolean storeSession)
    {
        try
        {
            FbStandbyInvocationHandler.getInstance().sendMessage(9);
            FbSessionHandler.getInstance().startSession(email, password, storeSession);
        }
        catch(InvalidStateException e)
        {
            Logger.printErrorln("Invalid state in session handler when trying to connect: " + e.toString());
            onLoginFailure();
        }
    }

    public boolean FbSessionStateChanged(int newState, int oldState)
    {
        switch(newState)
        {
        case 3: // '\003'
            FbStandbyInvocationHandler.getInstance().sendMessage(0);
            break;

        case 4: // '\004'
            Logger.println("Log in successful");
            onLoginComplete();
            break;

        case 6: // '\006'
            onLoginFailure();
            break;
        }
        return true;
    }

    public void logInWithStoredSession()
    {
        try
        {
            FbSessionHandler.getInstance().startStoredSession();
        }
        catch(InvalidStateException e)
        {
            Logger.printErrorln("Invalid state in session handler when trying to connect: " + e.toString());
            onLoginFailure();
        }
    }

    public void invocationRecieved(int type, String arguments[])
    {
        boolean shouldQuit;
        long updateIntervalInSeconds;
        FbRecordStore rs;
        shouldQuit = false;
        updateIntervalInSeconds = 0L;
        rs = new FbRecordStore();
        rs.open(false);
        shouldQuit = rs.getIsStandbyTickerEnabled() == 0;
        updateIntervalInSeconds = rs.getUpdateScheduleInSeconds();
        Exception e;
        try
        {
            rs.close();
        }
        // Misplaced declaration of an exception variable
        catch(Exception e)
        {
            Logger.printErrorln("Could not close record store in invocationReceivedException=" + e.toString());
        }
        break MISSING_BLOCK_LABEL_200;
        e;
        Logger.printErrorln("Error in invocationRecieved : type=" + String.valueOf(type) + "Exception=" + e.toString());
        try
        {
            rs.close();
        }
        // Misplaced declaration of an exception variable
        catch(Exception e)
        {
            Logger.printErrorln("Could not close record store in invocationReceivedException=" + e.toString());
        }
        break MISSING_BLOCK_LABEL_200;
        Exception exception;
        exception;
        try
        {
            rs.close();
        }
        catch(Exception e)
        {
            Logger.printErrorln("Could not close record store in invocationReceivedException=" + e.toString());
        }
        throw exception;
        if(shouldQuit)
            ScreenMidletHS.getInstance().die();
        if(type == 4 && arguments.length == 4)
        {
            String uid = arguments[1];
            String sessionkey = arguments[2];
            String sessionsecret = arguments[3];
            FbSessionHandler.getInstance().setConnected(uid, sessionkey, sessionsecret);
            mainMidletLoggingIn = false;
            mLoginPage.changeState(3);
        } else
        if(type == 11)
        {
            mainMidletLoggingIn = true;
            mLoginPage.changeState(3);
        } else
        if(type == 12)
        {
            onLoginFailure();
            mainMidletLoggingIn = false;
        } else
        if(type == 7)
        {
            if(mStandbyTicker != null)
                mStandbyTicker.settingsUpdated(updateIntervalInSeconds);
        } else
        if(type == 8)
        {
            if(mStandbyTicker != null && mStandbyTicker.isFocused())
                showHomescreenInfo(false);
        } else
        if(type == 13)
            ScreenMidletHS.getInstance().die();
        return;
    }

    public void showHomescreenInfo(boolean show)
    {
        if(mHomescreen != null)
            mHomescreen.setStandbyInformation(show);
    }

    public void focusStandbyPage()
    {
        if(mCurrent != null && (mCurrent instanceof FbStandByTicker))
        {
            FbStandByTicker tickerPage = (FbStandByTicker)mCurrent;
            tickerPage.tickerFocus(true);
        }
    }

    public void keyPressed(int key)
    {
        if(key == _tickerSoftkey)
        {
            ScreenEngine.getInstance().setHomescreenInStandby(false);
            if(FbSessionHandler.getInstance().isConnected())
                focusStandbyPage();
            else
                showPage(0);
        }
    }

    private Page mCurrent;
    private FbStandByTicker mStandbyTicker;
    private FbLogin mLoginPage;
    private FbDialog mDialogPage;
    private BGLayer mBGLayer;
    private boolean mainMidletLoggingIn;
    private boolean loginComplete;
    private Homescreen mHomescreen;
    public static final int PAGE_LOGIN = 0;
    public static final int PAGE_STATUS = 2;
    public static final int PAGE_UPLOAD = 3;
    public static final int PAGE_STANDBY = 4;
    public static final int PAGE_LOGIN_ERROR = 5;
    private int _tickerSoftkey;
    private static PageController _instance;
}

⌨️ 快捷键说明

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