<commit_before>package de.fau.amos.virtualledger.android.views.savings;

import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.Logger;

import de.fau.amos.virtualledger.R;
import de.fau.amos.virtualledger.android.dagger.App;
import de.fau.amos.virtualledger.dtos.Contact;
import de.fau.amos.virtualledger.dtos.SavingsAccount;
import de.fau.amos.virtualledger.android.views.savings.add.AddSavingsAccountActivity;
import de.fau.amos.virtualledger.android.views.shared.transactionList.DataListening;
import de.fau.amos.virtualledger.android.views.shared.transactionList.Supplier;
import de.fau.amos.virtualledger.dtos.SavingsAccountSubGoal;

public class SavingAccountsFragment extends Fragment implements DataListening {
    @SuppressWarnings("unused")
    private final String TAG = this.getClass().getSimpleName();


    private SavingAccountsAdapter adapter;
    private ListView savingsAccountList;
    private Supplier<SavingsAccount> savingsSupplier;

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        ((App) getActivity().getApplication()).getNetComponent().inject(this);

        this.savingsSupplier = new SavingsSupplier(getActivity());
        this.savingsSupplier.addDataListeningObject(this);
        adapter = new SavingAccountsAdapter(getActivity(), R.id.savings_account_list, savingsSupplier.getAll());
        savingsAccountList.setAdapter(adapter);
        this.adapter.sort(new SavingsComparator());
        this.savingsSupplier.onResume();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        setHasOptionsMenu(true);
        View mainView = inflater.inflate(R.layout.saving_accounts_list, container, false);

        this.savingsAccountList = (ListView) mainView.findViewById(R.id.savings_account_list);
        return mainView;
    }

    @Override
    public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
        inflater.inflate(R.menu.saving_accounts_app_bar, menu);
    }

    @Override
    public boolean onOptionsItemSelected(final MenuItem item) {
        switch (item.getItemId()) {
            case R.id.saving_accounts_app_bar_add:
                final Intent addSavingsAccountIntent = new Intent(getActivity(), AddSavingsAccountActivity.class);
                startActivity(addSavingsAccountIntent);
                return true;
        }

        return super.onOptionsItemSelected(item);
    }

    @Override
    public void notifyDataChanged() {
        this.adapter.clear();
        List<SavingsAccount> allSavingAccounts = this.savingsSupplier.getAll();
        logger().info("Refreshing savings overview with " + allSavingAccounts.size() + " accounts from"+this.savingsSupplier);


        allSavingAccounts.add(new SavingsAccount("", "My Goal", 300, 400, new Date(), new Date()));//FIXME delete sample data
        SavingsAccount account = new SavingsAccount("", "My Goal2", 300, 400, new Date(), new Date());
        account.setSubGoals(new ArrayList<SavingsAccountSubGoal>());
        SavingsAccountSubGoal subgoal1 = new SavingsAccountSubGoal();
        subgoal1.setName("TestName");
        subgoal1.setAmount(100.00);
        account.getSubGoals().add(subgoal1);
        SavingsAccountSubGoal subgoal2 = new SavingsAccountSubGoal();
        subgoal2.setName("TestName2");
        subgoal2.setAmount(200.00);
        account.getSubGoals().add(subgoal2);
        account.getAdditionalAssignedUsers().add(new Contact("", "Bernd", "Brot"));
        account.getAdditionalAssignedUsers().add(new Contact("", "Karin", "Kresse"));

        allSavingAccounts.add(account);//FIXME delete sample data

        this.adapter.addAll(allSavingAccounts);
        this.adapter.notifyDataSetChanged();
        this.adapter.sort(new SavingsComparator());
    }

    @Override
    public void onPause() {
        super.onPause();
        this.savingsSupplier.onPause();
    }

    @Override
    public void onResume() {
        super.onResume();
        this.savingsSupplier.onResume();<commit_msg>removed dummy saving accounts that were always there on client<commit_after>package de.fau.amos.virtualledger.android.views.savings;

import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.Logger;

import de.fau.amos.virtualledger.R;
import de.fau.amos.virtualledger.android.dagger.App;
import de.fau.amos.virtualledger.dtos.Contact;
import de.fau.amos.virtualledger.dtos.SavingsAccount;
import de.fau.amos.virtualledger.android.views.savings.add.AddSavingsAccountActivity;
import de.fau.amos.virtualledger.android.views.shared.transactionList.DataListening;
import de.fau.amos.virtualledger.android.views.shared.transactionList.Supplier;
import de.fau.amos.virtualledger.dtos.SavingsAccountSubGoal;

public class SavingAccountsFragment extends Fragment implements DataListening {
    @SuppressWarnings("unused")
    private final String TAG = this.getClass().getSimpleName();


    private SavingAccountsAdapter adapter;
    private ListView savingsAccountList;
    private Supplier<SavingsAccount> savingsSupplier;

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        ((App) getActivity().getApplication()).getNetComponent().inject(this);

        this.savingsSupplier = new SavingsSupplier(getActivity());
        this.savingsSupplier.addDataListeningObject(this);
        adapter = new SavingAccountsAdapter(getActivity(), R.id.savings_account_list, savingsSupplier.getAll());
        savingsAccountList.setAdapter(adapter);
        this.adapter.sort(new SavingsComparator());
        this.savingsSupplier.onResume();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        setHasOptionsMenu(true);
        View mainView = inflater.inflate(R.layout.saving_accounts_list, container, false);

        this.savingsAccountList = (ListView) mainView.findViewById(R.id.savings_account_list);
        return mainView;
    }

    @Override
    public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
        inflater.inflate(R.menu.saving_accounts_app_bar, menu);
    }

    @Override
    public boolean onOptionsItemSelected(final MenuItem item) {
        switch (item.getItemId()) {
            case R.id.saving_accounts_app_bar_add:
                final Intent addSavingsAccountIntent = new Intent(getActivity(), AddSavingsAccountActivity.class);
                startActivity(addSavingsAccountIntent);
                return true;
        }

        return super.onOptionsItemSelected(item);
    }

    @Override
    public void notifyDataChanged() {
        this.adapter.clear();
        List<SavingsAccount> allSavingAccounts = this.savingsSupplier.getAll();
        logger().info("Refreshing savings overview with " + allSavingAccounts.size() + " accounts from"+this.savingsSupplier);

        this.adapter.addAll(allSavingAccounts);
        this.adapter.notifyDataSetChanged();
        this.adapter.sort(new SavingsComparator());
    }

    @Override
    public void onPause() {
        super.onPause();
        this.savingsSupplier.onPause();
    }

    @Override
    public void onResume() {
        super.onResume();
        this.savingsSupplier.onResume();
{'fraction_non_alphanumeric': 0.10231305837718761, 'fraction_numerical': 0.00391628931587321, 'mean_word_length': 3.9527272727272726, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '1224606', 'n_tokens_mistral': 2453, 'n_tokens_neox': 2311, 'n_words': 411}