<commit_before>package ru.tulupov.nsuconnect.database.loader;


import android.content.Context;
import android.support.v4.content.AsyncTaskLoader;
import android.util.Log;

import com.j256.ormlite.stmt.PreparedQuery;
import com.j256.ormlite.stmt.QueryBuilder;

import java.sql.SQLException;
import java.util.List;

import ru.tulupov.nsuconnect.database.DatabaseContract;
import ru.tulupov.nsuconnect.database.HelperFactory;
import ru.tulupov.nsuconnect.model.Chat;
import ru.tulupov.nsuconnect.model.Message;


public class ChatLoader extends AsyncTaskLoader<List<Chat>> {
    private static final String TAG = ChatLoader.class.getSimpleName();


    public ChatLoader(Context context) {
        super(context);
    }

    @Override
    public List<Chat> loadInBackground() {
        try {
            QueryBuilder<Chat, Integer> queryBuilder = HelperFactory.getHelper().getChatDao().queryBuilder();
            queryBuilder.orderBy(DatabaseContract.Chat.DATE, false);
            PreparedQuery<Chat> preparedQuery = queryBuilder.prepare();
            List<Chat> chats = HelperFactory.getHelper().getChatDao().query(preparedQuery);

            return chats;
        } catch (SQLException e) {
            Log.e(TAG, "Error", e);
        }
        return null;<commit_msg>Change sort order in chat list<commit_after>package ru.tulupov.nsuconnect.database.loader;


import android.content.Context;
import android.support.v4.content.AsyncTaskLoader;
import android.util.Log;

import com.j256.ormlite.stmt.PreparedQuery;
import com.j256.ormlite.stmt.QueryBuilder;

import java.sql.SQLException;
import java.util.List;

import ru.tulupov.nsuconnect.database.DatabaseContract;
import ru.tulupov.nsuconnect.database.HelperFactory;
import ru.tulupov.nsuconnect.model.Chat;
import ru.tulupov.nsuconnect.model.Message;


public class ChatLoader extends AsyncTaskLoader<List<Chat>> {
    private static final String TAG = ChatLoader.class.getSimpleName();


    public ChatLoader(Context context) {
        super(context);
    }

    @Override
    public List<Chat> loadInBackground() {
        try {
            QueryBuilder<Chat, Integer> queryBuilder = HelperFactory.getHelper().getChatDao().queryBuilder();
            queryBuilder.orderBy(DatabaseContract.Chat.DATE, false);
            queryBuilder.orderBy(DatabaseContract.Chat.ACTIVE_FLAG, false);
            PreparedQuery<Chat> preparedQuery = queryBuilder.prepare();
            List<Chat> chats = HelperFactory.getHelper().getChatDao().query(preparedQuery);

            return chats;
        } catch (SQLException e) {
            Log.e(TAG, "Error", e);
        }
        return null;
{'fraction_non_alphanumeric': 0.105721864342554, 'fraction_numerical': 0.005305039787798408, 'mean_word_length': 3.6397188049209137, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '985638', 'n_tokens_mistral': 793, 'n_tokens_neox': 768, 'n_words': 138}