<commit_before>package com.shing.aputimetable.model;

import android.content.Context;
import android.support.v4.content.AsyncTaskLoader;
import android.text.TextUtils;

import com.shing.aputimetable.entity.ApuClass;
import com.shing.aputimetable.utils.QueryUtils;

import java.util.List;

/**
 * Created by Shing on 31-Jul-17.
 */

public class ApuClassLoader extends AsyncTaskLoader<List<ApuClass>> {

    private String mIntakeCode;

    public ApuClassLoader(Context context, String intakeCode) {
        super(context);
        mIntakeCode = intakeCode;
    }

    @Override
    protected void onStartLoading() {
        forceLoad();
    }


    @Override
    public List<ApuClass> loadInBackground() {

        if (TextUtils.isEmpty(mIntakeCode)) {
            return null;
        }

        // Perform the network request, parse the response, and extract a list of apu class details.
        return QueryUtils.getAllClass(mIntakeCode);
    }
}<commit_msg>Load class details from SQLite database if have save before<commit_after>package com.shing.aputimetable.model;

import android.content.Context;
import android.database.Cursor;
import android.support.v4.content.AsyncTaskLoader;
import android.text.TextUtils;

import com.shing.aputimetable.entity.ApuClass;
import com.shing.aputimetable.model.ApuClassContract.ApuClassEntry;
import com.shing.aputimetable.utils.QueryUtils;

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

/**
 * Created by Shing on 31-Jul-17.
 */

public class ApuClassLoader extends AsyncTaskLoader<List<ApuClass>> {

    private String mIntakeCode;
    private Context mContext;

    public ApuClassLoader(Context context, String intakeCode) {
        super(context);
        mIntakeCode = intakeCode;
        mContext = context;
    }

    @Override
    protected void onStartLoading() {
        forceLoad();
    }


    @Override
    public List<ApuClass> loadInBackground() {

        if (TextUtils.isEmpty(mIntakeCode)) {
            return null;
        }

        String[] projection = {
                ApuClassEntry._ID,
                ApuClassEntry.COLUMN_CLASS_DAY,
                ApuClassEntry.COLUMN_CLASS_DATE,
                ApuClassEntry.COLUMN_CLASS_TIME,
                ApuClassEntry.COLUMN_CLASS_ROOM,
                ApuClassEntry.COLUMN_CLASS_LOCATION,
                ApuClassEntry.COLUMN_CLASS_SUBJECT,
                ApuClassEntry.COLUMN_CLASS_LECTURER
        };

        Cursor cursor = mContext.getContentResolver().query(ApuClassEntry.CONTENT_URI, projection, null, null, null);

        if (cursor != null && cursor.moveToFirst()) {
            List<ApuClass> classes = new ArrayList<>();
            try {
                while (!cursor.isAfterLast()) {
                    ApuClass c = new ApuClass();
                    c.setDate(cursor.getString(cursor.getColumnIndex(ApuClassEntry.COLUMN_CLASS_DATE)));
                    c.setDay(cursor.getString(cursor.getColumnIndex(ApuClassEntry.COLUMN_CLASS_DAY)));
                    c.setTime(cursor.getString(cursor.getColumnIndex(ApuClassEntry.COLUMN_CLASS_TIME)));
                    c.setRoom(cursor.getString(cursor.getColumnIndex(ApuClassEntry.COLUMN_CLASS_ROOM)));
                    c.setLocation(cursor.getString(cursor.getColumnIndex(ApuClassEntry.COLUMN_CLASS_LOCATION)));
                    c.setSubject(cursor.getString(cursor.getColumnIndex(ApuClassEntry.COLUMN_CLASS_SUBJECT)));
                    c.setLecturer(cursor.getString(cursor.getColumnIndex(ApuClassEntry.COLUMN_CLASS_LECTURER)));
                    classes.add(c);
                    cursor.moveToNext();
                }
                return classes;
            } finally {
                cursor.close();
            }
        }

        if (QueryUtils.isNetworkConnected(mContext)) {
            // Perform the network request, parse the response, and extract a list of apu class details.
            return QueryUtils.getAllClass(mIntakeCode, mContext);
        }


        return null;

    }
}
{'fraction_non_alphanumeric': 0.0902274431392152, 'fraction_numerical': 0.0024993751562109472, 'mean_word_length': 2.5415929203539824, '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': '374948', 'n_tokens_mistral': 1178, 'n_tokens_neox': 1135, 'n_words': 200}