package com.sheep.gamegroup.view.activity;

import android.content.res.Configuration;
import android.support.v4.app.Fragment;
import android.view.KeyEvent;
import android.view.WindowManager;

import com.sheep.gamegroup.absBase.BaseContainerActivity;
import com.sheep.gamegroup.util.DataUtil;
import com.sheep.gamegroup.view.fragment.FgtArticleComment;

/**
 * Created by realicing on 2018/11/7.
 * realicing@sina.com
 * 游戏资讯的评论列表界面
 */
public class ActArticleComment extends BaseContainerActivity {
    @Override
    protected Fragment initFragment() {
        int article_id = DataUtil.getObject(getIntent(), Integer.class);
        FgtArticleComment fragment = new FgtArticleComment();
        fragment.setArticle_id(article_id);
        return fragment;
    }
    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_BACK:
                if(fragment instanceof FgtArticleComment)
                    ((FgtArticleComment) fragment).onBackUp();
                return true;
            default:
                return super.onKeyUp(keyCode, event);
        }
    }
    @Override
    public void onBackPressed() {
        if(fragment instanceof FgtArticleComment && ((FgtArticleComment) fragment).onBackPressed()){
            return;
        }
        super.onBackPressed();
    }
    @Override
    public void onConfigurationChanged(Configuration config) {
        super.onConfigurationChanged(config);
        switch (config.orientation) {
            case Configuration.ORIENTATION_LANDSCAPE:
                getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
                getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
                break;
            case Configuration.ORIENTATION_PORTRAIT:
                getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
                getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
                break;
        }
    }
}
