<commit_before>package de.xikolo.controller;

import android.content.Context;
import android.content.Intent;
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.FragmentPagerAdapter;
import android.support.v4.app.NavUtils;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPager;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import de.xikolo.GlobalApplication;
import de.xikolo.R;
import de.xikolo.controller.helper.CacheController;
import de.xikolo.controller.helper.ModuleDownloadController;
import de.xikolo.controller.module.VideoFragment;
import de.xikolo.controller.module.WebItemFragment;
import de.xikolo.data.entities.Course;
import de.xikolo.data.entities.Item;
import de.xikolo.data.entities.Module;
import de.xikolo.model.ItemModel;
import de.xikolo.model.Result;
import de.xikolo.model.events.NetworkStateEvent;
import de.xikolo.util.DateUtil;

public class ModuleActivity extends BaseActivity {

    public static final String TAG = ModuleActivity.class.getSimpleName();

    public static final String ARG_COURSE = "arg_course";
    public static final String ARG_MODULE = "arg_module";
    public static final String ARG_ITEM = "arg_item";

    private Course course;
    private Module module;
    private Item item;

    private ItemModel itemModel;
    private Result<Void> progressionResult;

    private ViewPager viewpager;
    private TabLayout tabLayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_blank_tabs);
        setupActionBar();

        Bundle b = getIntent().getExtras();
        if (b == null || !b.containsKey(ARG_COURSE) || !b.containsKey(ARG_MODULE)) {
            CacheController cacheController = new CacheController();
            cacheController.readCachedExtras();
            if (cacheController.getCourse() != null) {
                course = cacheController.getCourse();
            }
            if (cacheController.getModule() != null) {
                module = cacheController.getModule();
            }
            if (cacheController.getItem() != null) {
                item = cacheController.getItem();
            }
            if (course != null && module != null && item != null) {
                Bundle restartBundle = new Bundle();
                restartBundle.putParcelable(ARG_COURSE, course);
                restartBundle.putParcelable(ARG_MODULE, module);
                restartBundle.putParcelable(ARG_ITEM, item);
                Intent restartIntent = new Intent(ModuleActivity.this, ModuleActivity.class);
                restartIntent.putExtras(restartBundle);
                startActivity(restartIntent);
            }
        } else {
            this.course = b.getParcelable(ARG_COURSE);
            this.module = b.getParcelable(ARG_MODULE);
            this.item = b.getParcelable(ARG_ITEM);
        }

        itemModel = new ItemModel(jobManager);
        progressionResult = new Result<Void>() {
        };

        setTitle(module.name);

        // Initialize the ViewPager and set an adapter
        viewpager = (ViewPager) findViewById(R.id.viewpager);<commit_msg>Better Exception logging.<commit_after>package de.xikolo.controller;

import android.content.Context;
import android.content.Intent;
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.FragmentPagerAdapter;
import android.support.v4.app.NavUtils;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPager;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import de.xikolo.GlobalApplication;
import de.xikolo.R;
import de.xikolo.controller.exceptions.WrongParameterException;
import de.xikolo.controller.helper.CacheController;
import de.xikolo.controller.helper.ModuleDownloadController;
import de.xikolo.controller.module.VideoFragment;
import de.xikolo.controller.module.WebItemFragment;
import de.xikolo.data.entities.Course;
import de.xikolo.data.entities.Item;
import de.xikolo.data.entities.Module;
import de.xikolo.model.ItemModel;
import de.xikolo.model.Result;
import de.xikolo.model.events.NetworkStateEvent;
import de.xikolo.util.DateUtil;

public class ModuleActivity extends BaseActivity {

    public static final String TAG = ModuleActivity.class.getSimpleName();

    public static final String ARG_COURSE = "arg_course";
    public static final String ARG_MODULE = "arg_module";
    public static final String ARG_ITEM = "arg_item";

    private Course course;
    private Module module;
    private Item item;

    private ItemModel itemModel;
    private Result<Void> progressionResult;

    private ViewPager viewpager;
    private TabLayout tabLayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_blank_tabs);
        setupActionBar();

        Bundle b = getIntent().getExtras();
        if (b == null || !b.containsKey(ARG_COURSE) || !b.containsKey(ARG_MODULE)) {
            CacheController cacheController = new CacheController();
            cacheController.readCachedExtras();
            if (cacheController.getCourse() != null) {
                course = cacheController.getCourse();
            }
            if (cacheController.getModule() != null) {
                module = cacheController.getModule();
            }
            if (cacheController.getItem() != null) {
                item = cacheController.getItem();
            }
            if (course != null && module != null && item != null) {
                Bundle restartBundle = new Bundle();
                restartBundle.putParcelable(ARG_COURSE, course);
                restartBundle.putParcelable(ARG_MODULE, module);
                restartBundle.putParcelable(ARG_ITEM, item);
                Intent restartIntent = new Intent(ModuleActivity.this, ModuleActivity.class);
                restartIntent.putExtras(restartBundle);
                finish();
                startActivity(restartIntent);
            }
        } else {
            this.course = b.getParcelable(ARG_COURSE);
            this.module = b.getParcelable(ARG_MODULE);
            this.item = b.getParcelable(ARG_ITEM);
        }

        if (course == null) {
            throw new WrongParameterException("Course is null");
        }
        if (module == null) {
            throw new WrongParameterException("Module is null for Course " + course.name + " (" + course.id + ")");
        }
        if (module == null || module.items.size() == 0) {
            throw new WrongParameterException("Module Items are empty for Course " + course.name + " (" + course.id + ")" +
                    " and Module " + module.name + " (" + module.id + ")");
        }

        itemModel = new ItemModel(jobManager);
        progressionResult = new Result<Void>() {
        };

        setTitle(module.name);

        // Initialize the ViewPager and set an adapter
        viewpager = (ViewPager) findViewById(R.id.viewpager);
{'fraction_non_alphanumeric': 0.10145492335671603, 'fraction_numerical': 0.0019485580670303975, 'mean_word_length': 2.9808686659772494, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2401079', 'n_tokens_mistral': 2162, 'n_tokens_neox': 2113, 'n_words': 439}