<commit_before>package agilec.ikeaswipe.activities;

import java.util.Arrays;
import java.util.Locale;

import android.support.v4.app.FragmentActivity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.Menu;
import android.view.MenuItem;


import org.json.JSONException;

import agilec.ikeaswipe.R;
import agilec.ikeaswipe.utils.SingleSwipeViewPager;
import agilec.ikeaswipe.utils.SlidingTabLayout;
import agilec.ikeaswipe.views.ArticlesListFragment;
import agilec.ikeaswipe.views.StepByStepFragment;
import agilec.ikeaswipe.views.View3dFragment;


public class SwipeActivity extends FragmentActivity {

  /**
   * The {@link android.support.v4.view.PagerAdapter} that will provide
   * fragments for each of the sections. We use a
   * {@link FragmentPagerAdapter} derivative, which will keep every
   * loaded fragment in memory. If this becomes too memory intensive, it
   * may be best to switch to a
   * {@link android.support.v4.app.FragmentStatePagerAdapter}.
   */

  ArticlesListFragment alf;
  View3dFragment v3DF = new View3dFragment();

  SectionsPagerAdapter mSectionsPagerAdapter;

  /**
   * The {@link agilec.ikeaswipe.views.StepByStepFragment} that is displayed in the second section of the ViewPager.
   */
  StepByStepFragment stepFragment;

  /**
   * int currentStep is used to set and track the current step that is being displayed in
   * stepByStepFragment.
   */
  private int currentStep = 0;

  private int totalNumberOfSteps = 7;
  private boolean[] completedStepsArray;


  /**
   * The {@link Bundle} that is used to initialize stepByStepFragment with the current
   * stepNumber.
   */
  Bundle bundle;

  /**
   * The {@link ViewPager} that will host the section contents.
   */
  SingleSwipeViewPager mViewPager;
  private SlidingTabLayout mSlidingTabLayout;

  /**
   * setStepNumber is called to update the current step number from the StepByStepFragment
   *
   * @param stepNumber
   * @author @emmaforsling @martingrad @byggprojektledarn
   */
  public void setStepNumber(int stepNumber) throws JSONException {
    currentStep = stepNumber;

    // Update the list - Only show articles that belongs to the current step
    alf.updateListWithStep(currentStep);
    v3DF.changeObject(currentStep);
  }

  public void setCompletedStep(int stepNumber, boolean isCompleted) {
    completedStepsArray[stepNumber] = isCompleted;
  }

  public boolean getCompletedStep(int stepNumber) {
    return completedStepsArray[stepNumber];
  }

  /**
   * This function is overridden to save the current step number when the activity is recreated<commit_msg>Running loading of new 3D models on separate thread.<commit_after>package agilec.ikeaswipe.activities;

import java.util.Arrays;
import java.util.Locale;

import android.support.v4.app.FragmentActivity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.Menu;
import android.view.MenuItem;


import org.json.JSONException;

import agilec.ikeaswipe.R;
import agilec.ikeaswipe.utils.SingleSwipeViewPager;
import agilec.ikeaswipe.utils.SlidingTabLayout;
import agilec.ikeaswipe.views.ArticlesListFragment;
import agilec.ikeaswipe.views.StepByStepFragment;
import agilec.ikeaswipe.views.View3dFragment;


public class SwipeActivity extends FragmentActivity {

  /**
   * The {@link android.support.v4.view.PagerAdapter} that will provide
   * fragments for each of the sections. We use a
   * {@link FragmentPagerAdapter} derivative, which will keep every
   * loaded fragment in memory. If this becomes too memory intensive, it
   * may be best to switch to a
   * {@link android.support.v4.app.FragmentStatePagerAdapter}.
   */

  ArticlesListFragment alf;
  View3dFragment v3DF = new View3dFragment();

  SectionsPagerAdapter mSectionsPagerAdapter;

  /**
   * The {@link agilec.ikeaswipe.views.StepByStepFragment} that is displayed in the second section of the ViewPager.
   */
  StepByStepFragment stepFragment;

  /**
   * int currentStep is used to set and track the current step that is being displayed in
   * stepByStepFragment.
   */
  private int currentStep = 0;

  private int totalNumberOfSteps = 7;
  private boolean[] completedStepsArray;


  /**
   * The {@link Bundle} that is used to initialize stepByStepFragment with the current
   * stepNumber.
   */
  Bundle bundle;

  /**
   * The {@link ViewPager} that will host the section contents.
   */
  SingleSwipeViewPager mViewPager;
  private SlidingTabLayout mSlidingTabLayout;

  /**
   * setStepNumber is called to update the current step number from the StepByStepFragment
   *
   * @param stepNumber
   * @author @emmaforsling @martingrad @byggprojektledarn
   */
  public void setStepNumber(int stepNumber) throws JSONException {
    currentStep = stepNumber;

    // Update the list - Only show articles that belongs to the current step
    alf.updateListWithStep(currentStep);

    Thread thread = new Thread(new Runnable(){
      @Override
      public void run(){
        v3DF.changeObject(currentStep);
      }
    });
    thread.start();
  }

  public void setCompletedStep(int stepNumber, boolean isCompleted) {
    completedStepsArray[stepNumber] = isCompleted;
  }

  public boolean getCompletedStep(int stepNumber) {
    return completedStepsArray[stepNumber];
  }

  /**
   * This function is overridden to save the current step number when the activity is recreated
{'fraction_non_alphanumeric': 0.0791974656810982, 'fraction_numerical': 0.0051038366772263285, 'mean_word_length': 4.152311876699909, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1090904', 'n_tokens_mistral': 1725, 'n_tokens_neox': 1673, 'n_words': 481}