Example usage for android.widget AbsoluteLayout setLayoutParams

List of usage examples for android.widget AbsoluteLayout setLayoutParams

Introduction

In this page you can find the example usage for android.widget AbsoluteLayout setLayoutParams.

Prototype

public void setLayoutParams(ViewGroup.LayoutParams params) 

Source Link

Document

Set the layout parameters associated with this view.

Usage

From source file:com.tealeaf.TeaLeaf.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PluginManager.init(this);
    instance = this;
    setFullscreenFlag();//from  w  w w  . j a  v a  2  s .com
    configureActivity();
    String appID = findAppID();
    options = new TeaLeafOptions(this);

    PluginManager.callAll("onCreate", this, savedInstanceState);

    //check intent for test app info
    Bundle bundle = getIntent().getExtras();
    boolean isTestApp = false;
    if (bundle != null) {
        isTestApp = bundle.getBoolean("isTestApp", false);

        if (isTestApp) {
            options.setAppID(appID);
            boolean isPortrait = bundle.getBoolean("isPortrait", false);
            if (isPortrait) {
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            } else {
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            }
            options.setCodeHost(bundle.getString("hostValue"));
            options.setCodePort(bundle.getInt("portValue"));
            String simulateID = bundle.getString("simulateID");
            options.setSimulateID(simulateID);
        }
    }

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

    group = new FrameLayout(this);
    setContentView(group);

    // TextEditViewHandler setup
    textEditView = new TextEditViewHandler(this);

    settings = new Settings(this);
    remoteLogger = (ILogger) getLoggerInstance(this);

    checkUpdate();
    compareVersions();
    setLaunchUri();

    // defer building all of these things until we have the absolutely correct options
    logger.buildLogger(this, remoteLogger);
    resourceManager = new ResourceManager(this, options);
    contactList = new ContactList(this, resourceManager);
    soundQueue = new SoundQueue(this, resourceManager);
    localStorage = new LocalStorage(this, options);

    // start push notifications, but defer for 10 seconds to give us time to start up
    PushBroadcastReceiver.scheduleNext(this, 10);

    glView = new TeaLeafGLSurfaceView(this);
    glViewPaused = false;

    // default screen dimensions
    Display display = getWindow().getWindowManager().getDefaultDisplay();
    int width = display.getWidth();
    int height = display.getHeight();
    int orientation = getRequestedOrientation();

    // gets real screen dimensions without nav bars on recent API versions
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        Point screenSize = new Point();
        try {
            display.getRealSize(screenSize);
            width = screenSize.x;
            height = screenSize.y;
        } catch (NoSuchMethodError e) {
        }
    }

    // flip width and height based on orientation
    if ((orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE && height > width)
            || (orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT && width > height)) {
        int tempWidth = width;
        width = height;
        height = tempWidth;
    }

    final AbsoluteLayout absLayout = new AbsoluteLayout(this);
    absLayout.setLayoutParams(new android.view.ViewGroup.LayoutParams(width, height));
    absLayout.addView(glView, new android.view.ViewGroup.LayoutParams(width, height));

    group.addView(absLayout);
    editText = EditTextView.Init(this);

    if (isTestApp) {
        startGame();
    }

    soundQueue.playSound(SoundQueue.LOADING_SOUND);
    doFirstRun();
    remoteLogger.sendLaunchEvent(this);

    paused = false;
    menuButtonHandler = MenuButtonHandlerFactory.getButtonHandler(this);

    group.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        public void onGlobalLayout() {
            // get visible area of the view
            Rect r = new Rect();
            group.getWindowVisibleDisplayFrame(r);

            int visibleHeight = r.bottom;

            // TODO
            // maybe this should be renamed
            if (visibleHeight != lastVisibleHeight) {
                lastVisibleHeight = visibleHeight;
                EventQueue.pushEvent(new KeyboardScreenResizeEvent(visibleHeight));
            }
        }
    });
}