<commit_before>/*
 * Copyright (c) 2017 大前良介 (OHMAE Ryosuke)
 *
 * This software is released under the MIT License.
 * http://opensource.org/licenses/MIT
 */

package net.mm2d.dmsexplorer.view;

import android.content.res.Configuration;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
import android.view.MotionEvent;

import net.mm2d.dmsexplorer.R;
import net.mm2d.dmsexplorer.Repository;
import net.mm2d.dmsexplorer.databinding.MovieActivityBinding;
import net.mm2d.dmsexplorer.util.FullscreenHelper;
import net.mm2d.dmsexplorer.viewmodel.MovieActivityModel;

/**
 * 動画再生のActivity。
 *
 * @author <a href="mailto:<EMAIL>">大前良介(OHMAE Ryosuke)</a>
 */
public class MovieActivity extends AppCompatActivity {
    private static final String KEY_POSITION = "KEY_POSITION";
    private FullscreenHelper mFullscreenHelper;
    private MovieActivityBinding mBinding;
    private MovieActivityModel mModel;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding = DataBindingUtil.setContentView(this, R.layout.movie_activity);
        final Repository repository = Repository.get();
        mModel = MovieActivityModel.create(this, mBinding.videoView, repository);
        if (mModel == null) {
            finish();
            return;
        }
        mBinding.setModel(mModel);
        mModel.adjustPanel(this);

        mFullscreenHelper = new FullscreenHelper.Builder(mBinding.getRoot())
                .setTopView(mBinding.toolbar)
                .setBottomView(mBinding.controlPanel)
                .build();
        mFullscreenHelper.showNavigation();

        if (savedInstanceState != null) {
            final int progress = savedInstanceState.getInt(KEY_POSITION, 0);
            mModel.restoreSaveProgress(progress);
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mModel.terminate();
        mFullscreenHelper.onDestroy();
    }

    @Override
    public boolean dispatchTouchEvent(final MotionEvent ev) {
        mFullscreenHelper.showNavigation();
        return super.dispatchTouchEvent(ev);
    }

    @Override
    protected void onSaveInstanceState(final Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putInt(KEY_POSITION, mModel.getCurrentProgress());
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        mModel.adjustPanel(this);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        final int id = item.getItemId();
        switch (id) {
            case android.R.id.home:
                onBackPressed();
                return true;
        }
        return super.onOptionsItemSelected(item);
    }
}<commit_msg>change order for avoid misoperation.<commit_after>/*
 * Copyright (c) 2017 大前良介 (<NAME>)
 *
 * This software is released under the MIT License.
 * http://opensource.org/licenses/MIT
 */

package net.mm2d.dmsexplorer.view;

import android.content.res.Configuration;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
import android.view.MotionEvent;

import net.mm2d.dmsexplorer.R;
import net.mm2d.dmsexplorer.Repository;
import net.mm2d.dmsexplorer.databinding.MovieActivityBinding;
import net.mm2d.dmsexplorer.util.FullscreenHelper;
import net.mm2d.dmsexplorer.viewmodel.MovieActivityModel;

/**
 * 動画再生のActivity。
 *
 * @author <a href="mailto:<EMAIL>">大前良介(<NAME>)</a>
 */
public class MovieActivity extends AppCompatActivity {
    private static final String KEY_POSITION = "KEY_POSITION";
    private FullscreenHelper mFullscreenHelper;
    private MovieActivityBinding mBinding;
    private MovieActivityModel mModel;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding = DataBindingUtil.setContentView(this, R.layout.movie_activity);
        final Repository repository = Repository.get();
        mModel = MovieActivityModel.create(this, mBinding.videoView, repository);
        if (mModel == null) {
            finish();
            return;
        }
        mBinding.setModel(mModel);
        mModel.adjustPanel(this);

        mFullscreenHelper = new FullscreenHelper.Builder(mBinding.getRoot())
                .setTopView(mBinding.toolbar)
                .setBottomView(mBinding.controlPanel)
                .build();
        mFullscreenHelper.showNavigation();

        if (savedInstanceState != null) {
            final int progress = savedInstanceState.getInt(KEY_POSITION, 0);
            mModel.restoreSaveProgress(progress);
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mModel.terminate();
        mFullscreenHelper.onDestroy();
    }

    @Override
    public boolean dispatchTouchEvent(final MotionEvent ev) {
        final boolean result = super.dispatchTouchEvent(ev);
        mFullscreenHelper.showNavigation();
        return result;
    }

    @Override
    protected void onSaveInstanceState(final Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putInt(KEY_POSITION, mModel.getCurrentProgress());
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        mModel.adjustPanel(this);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        final int id = item.getItemId();
        switch (id) {
            case android.R.id.home:
                onBackPressed();
                return true;
        }
        return super.onOptionsItemSelected(item);
    }
}
{'fraction_non_alphanumeric': 0.09453496266123558, 'fraction_numerical': 0.004073319755600814, 'mean_word_length': 3.028024606971975, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3522504', 'n_tokens_mistral': 1689, 'n_tokens_neox': 1631, 'n_words': 316}