<commit_before>/**
 * Copyright (c) 2014 <NAME>
 * <p/>
 * 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
 * <p/>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * 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.roryhool.videoinfoviewer;

import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.animation.TranslateAnimation;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import android.widget.Toast;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.analytics.HitBuilders;
import com.roryhool.videoinfoviewer.data.Video;
import com.roryhool.videoinfoviewer.utils.UriHelper;
import com.roryhool.videoinfoviewer.utils.VideoCache;
import com.roryhool.videoinfoviewer.utils.ViewUtils;
import com.roryhool.videoinfoviewer.views.VideoPlayerView.OnFullscreenListener;

import java.util.HashMap;
import java.util.Stack;

import rx.Observable;
import rx.Observable.OnSubscribe;
import rx.Subscriber;
import rx.android.app.AppObservable;
import rx.schedulers.Schedulers;

public class VideoActivity extends AppCompatActivity implements OnFullscreenListener, OnPageChangeListener {

   public static class CancelFullscreenEvent {
   }

   protected Toolbar        mToolbar;
   protected RelativeLayout mRootLayout;
   protected FrameLayout    mAdFrame;
   protected AdView         mAdView;
   protected ViewPager      mViewPager;
   protected TabLayout      mTabLayout;

   protected VideoFragmentAdapter mPagerAdapter;

   protected int mBaseSystemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;

   protected boolean mFullscreen;

   @Override
   public void onCreate( Bundle savedInstanceState ) {
      super.onCreate( savedInstanceState );

      setContentView( R.layout.activity_video );
      getWindow().getDecorView().setSystemUiVisibility( mBaseSystemUiVisibility );
      mRootLayout = (RelativeLayout) findViewById( R.id.root_layout );

      mToolbar = (Toolbar) findViewById( R.id.toolbar );
      mTabLayout = (TabLayout) findViewById( R.id.tab_layout );
      mTabLayout.setTabMode( TabLayout.MODE_SCROLLABLE );

      setSupportActionBar( mToolbar );
      getSupportActionBar().setDisplayHomeAsUpEnabled( true );
      getSupportActionBar().setDisplayShowHomeEnabled( true );

      mAdFrame = (FrameLayout) findViewById( R.id.ad_frame );

      mRootLayout.setPadding( 0, ViewUtils.GetStatusBarHeight( VideoActivity.this ), 0, 0 );

      Bundle extras = getIntent().getExtras();

      mViewPager = (ViewPager) findViewById( R.id.view_pager );
      mViewPager.setOffscreenPageLimit( 5 );
      mViewPager.addOnPageChangeListener( this );

      if ( extras != null && extras.containsKey( Extras.EXTRA_VIDEO_CACHE_ID ) ) {
         setCurrentVideo( VideoCache.Instance().getVideoById( extras.getInt( Extras.EXTRA_VIDEO_CACHE_ID ) ) );
      } else {
         Uri videoUri = getIntent().getData();
         AppObservable.bindActivity( this, Observable.create( new RetrieveVideoDetailsTask( videoUri ) ) )
                      .subscribeOn( Schedulers.io() )
                      .subscribe(
                         new Subscriber<Video>() {
                            @Override
                            public void onCompleted() {}
                            @Override
                            public void onError( Throwable e ) {
                               Toast.makeText( VideoActivity.this, R.string.failed_to_open_video, Toast.LENGTH_LONG ).show();
                               finish();
                            }
                            @Override
                            public void onNext( Video video ) {
                               setCurrentVideo( video );<commit_msg>Check for EXTRA_STREAM, if Intent getData() returns null<commit_after>/**
 * Copyright (c) 2014 <NAME>
 * <p/>
 * 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
 * <p/>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * 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.roryhool.videoinfoviewer;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.animation.TranslateAnimation;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import android.widget.Toast;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.analytics.HitBuilders;
import com.roryhool.videoinfoviewer.data.Video;
import com.roryhool.videoinfoviewer.utils.UriHelper;
import com.roryhool.videoinfoviewer.utils.VideoCache;
import com.roryhool.videoinfoviewer.utils.ViewUtils;
import com.roryhool.videoinfoviewer.views.VideoPlayerView.OnFullscreenListener;

import java.util.HashMap;
import java.util.Stack;

import rx.Observable;
import rx.Observable.OnSubscribe;
import rx.Subscriber;
import rx.android.app.AppObservable;
import rx.schedulers.Schedulers;

public class VideoActivity extends AppCompatActivity implements OnFullscreenListener, OnPageChangeListener {

   public static class CancelFullscreenEvent {
   }

   protected Toolbar        mToolbar;
   protected RelativeLayout mRootLayout;
   protected FrameLayout    mAdFrame;
   protected AdView         mAdView;
   protected ViewPager      mViewPager;
   protected TabLayout      mTabLayout;

   protected VideoFragmentAdapter mPagerAdapter;

   protected int mBaseSystemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;

   protected boolean mFullscreen;

   @Override
   public void onCreate( Bundle savedInstanceState ) {
      super.onCreate( savedInstanceState );

      setContentView( R.layout.activity_video );
      getWindow().getDecorView().setSystemUiVisibility( mBaseSystemUiVisibility );
      mRootLayout = (RelativeLayout) findViewById( R.id.root_layout );

      mToolbar = (Toolbar) findViewById( R.id.toolbar );
      mTabLayout = (TabLayout) findViewById( R.id.tab_layout );
      mTabLayout.setTabMode( TabLayout.MODE_SCROLLABLE );

      setSupportActionBar( mToolbar );
      getSupportActionBar().setDisplayHomeAsUpEnabled( true );
      getSupportActionBar().setDisplayShowHomeEnabled( true );

      mAdFrame = (FrameLayout) findViewById( R.id.ad_frame );

      mRootLayout.setPadding( 0, ViewUtils.GetStatusBarHeight( VideoActivity.this ), 0, 0 );

      Bundle extras = getIntent().getExtras();

      mViewPager = (ViewPager) findViewById( R.id.view_pager );
      mViewPager.setOffscreenPageLimit( 5 );
      mViewPager.addOnPageChangeListener( this );

      if ( extras != null && extras.containsKey( Extras.EXTRA_VIDEO_CACHE_ID ) ) {
         setCurrentVideo( VideoCache.Instance().getVideoById( extras.getInt( Extras.EXTRA_VIDEO_CACHE_ID ) ) );
      } else {
         Uri videoUri = getIntent().getData();
         if ( videoUri == null && getIntent().hasExtra( Intent.EXTRA_STREAM ) ) {
            videoUri = getIntent().getParcelableExtra( Intent.EXTRA_STREAM );
         }
         AppObservable.bindActivity( this, Observable.create( new RetrieveVideoDetailsTask( videoUri ) ) )
                      .subscribeOn( Schedulers.io() )
                      .subscribe(
                         new Subscriber<Video>() {
                            @Override
                            public void onCompleted() {
                            }

                            @Override
                            public void onError( Throwable e ) {
                               Toast.makeText( VideoActivity.this, R.string.failed_to_open_video, Toast.LENGTH_LONG ).show();
                               finish();
                            }

                            @Override
                            public void onNext( Video video ) {
                               setCurrentVideo( video );
{'fraction_non_alphanumeric': 0.0884283955683217, 'fraction_numerical': 0.0038982355354944603, 'mean_word_length': 3.141461342395922, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7391461', 'n_tokens_mistral': 2782, 'n_tokens_neox': 2693, 'n_words': 613}