com.chess.genesis.activity.MainMenuTablet.java Source code

Java tutorial

Introduction

Here is the source code for com.chess.genesis.activity.MainMenuTablet.java

Source

/* GenesisChess, an Android chess application
 * Copyright 2014, Justin Madru (justin.jdm64@gmail.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.chess.genesis.activity;

import android.content.*;
import android.content.pm.*;
import android.os.*;
import android.support.v4.app.*;
import com.chess.genesis.*;
import com.chess.genesis.data.*;

public class MainMenuTablet extends BaseActivity {
    @Override
    public void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        setContentView(R.layout.activity_tablet);

        final Bundle bundle = getIntent().getExtras();
        final MenuBarFrag menubar = new MenuBarFrag(this);
        final BaseContentFrag frag = (bundle != null && bundle.getInt("loadFrag") == Enums.ONLINE_LIST)
                ? new GameListOnlineFrag()
                : new MainMenuFrag();

        frag.setMenuBarFrag(menubar);

        getSupportFragmentManager().beginTransaction().replace(R.id.topbar01, menubar)
                .replace(R.id.botbar01, new BotBarFrag()).replace(R.id.topbar02, new TopBarFrag())
                .replace(R.id.botbar02, new BotBarFrag()).replace(R.id.topbar03, new TopBarFrag())
                .replace(R.id.botbar03, new BotBarFrag()).replace(R.id.panel01, frag, frag.getBTag()).commit();
    }

    @Override
    protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
        // BUG: requestCode is wrong
        //   if (requestCode == Enums.IMPORT_GAME) {
        final FragmentManager fragMan = getSupportFragmentManager();
        final GameListLocalFrag frag = (GameListLocalFrag) fragMan.findFragmentByTag(GameListLocalFrag.TAG);

        frag.recieveGame(data);
        //   }
    }
}