Android Open Source - droidling Interpersonal Stats






From Project

Back to project page droidling.

License

The source code is released under:

Copyright (c) 2012 Keith Trnka Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Softwa...

If you think the Android project droidling listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.github.ktrnka.droidling;
//  w  w  w.ja va  2  s .c  o  m
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;

import android.content.Context;

/**
 * Wrapper around the stats from InterpersonalActivity to load/save.
 */
public class InterpersonalStats {
    ArrayList<Item> list;

    public InterpersonalStats() {
        list = new ArrayList<Item>();
    }

    public InterpersonalStats(FileInputStream in) throws IOException {
        readFrom(in);
    }

    public void cacheStrings(Context context) {
        for (Item item : list)
            item.details.buildFormattedString(context);
    }

    private void readFrom(FileInputStream in) throws IOException {
        DataInputStream dataIn = new DataInputStream(new BufferedInputStream(in));

        int numItems = dataIn.readInt();
        int version = dataIn.readInt();
        if (version != InterpersonalSingleStats.seralizationVersion)
            throw new IOException("Stored file doesn't match serialization version.");

        list = new ArrayList<Item>(numItems);

        for (int i = 0; i < numItems; i++) {
            add(dataIn.readUTF(), InterpersonalSingleStats.deserialize(dataIn));
        }

        dataIn.close();
    }

    public void writeTo(FileOutputStream out) throws IOException {
        DataOutputStream dataOut = new DataOutputStream(new BufferedOutputStream(out));

        dataOut.writeInt(list.size());
        dataOut.writeInt(InterpersonalSingleStats.seralizationVersion);

        for (Item item : list) {
            dataOut.writeUTF(item.name.toString());
            item.details.serialize(dataOut);
        }

        dataOut.close();
    }

    public void add(CharSequence name, InterpersonalSingleStats details) {
        list.add(new Item(name, details));
    }

    public static class Item {
        CharSequence name;
        InterpersonalSingleStats details;

        public Item(CharSequence name, InterpersonalSingleStats details) {
            this.name = name;
            this.details = details;
        }
    }
}




Java Source Code List

com.github.ktrnka.droidling.AboutActivity.java
com.github.ktrnka.droidling.AboutInterpersonalActivity.java
com.github.ktrnka.droidling.AboutLangIDActivity.java
com.github.ktrnka.droidling.AboutPersonalActivity.java
com.github.ktrnka.droidling.CorpusStats.java
com.github.ktrnka.droidling.DateDistribution.java
com.github.ktrnka.droidling.DiagnosticActivity.java
com.github.ktrnka.droidling.ExtendedApplication.java
com.github.ktrnka.droidling.GraphCard.java
com.github.ktrnka.droidling.ImageAdapter.java
com.github.ktrnka.droidling.InterpersonalActivity.java
com.github.ktrnka.droidling.InterpersonalCard.java
com.github.ktrnka.droidling.InterpersonalSingleStats.java
com.github.ktrnka.droidling.InterpersonalStats.java
com.github.ktrnka.droidling.LIDStats.java
com.github.ktrnka.droidling.LanguageIdentificationActivity.java
com.github.ktrnka.droidling.LanguageIdentifier.java
com.github.ktrnka.droidling.MainActivity.java
com.github.ktrnka.droidling.PersonalActivity.java
com.github.ktrnka.droidling.PersonalStats.java
com.github.ktrnka.droidling.RefreshableActivity.java
com.github.ktrnka.droidling.ShareableCard.java
com.github.ktrnka.droidling.Sms.java
com.github.ktrnka.droidling.Tokenizer.java
com.github.ktrnka.droidling.WordDistribution.java
com.github.ktrnka.droidling.helpers.AsyncDrawable.java
com.github.ktrnka.droidling.helpers.BitmapLoaderTask.java
com.github.ktrnka.droidling.helpers.Util.java