Android Open Source - TextCounter Paranormal Activity






From Project

Back to project page TextCounter.

License

The source code is released under:

MIT License

If you think the Android project TextCounter 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.premnirmal.textcounterdemo;
//  ww w . j a  v  a 2s . c o m
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

import com.github.premnirmal.textcounter.CounterView;
import com.github.premnirmal.textcounter.Formatter;

import java.text.NumberFormat;
import java.util.Locale;


public class ParanormalActivity extends Activity {

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

        final CounterView counterView = (CounterView) findViewById(R.id.secondCounter);
        counterView.setAutoFormat(false);
        counterView.setFormatter(new Formatter() {
            @Override
            public String format(String prefix, String suffix, float value) {
                return prefix + NumberFormat.getNumberInstance(Locale.US).format(value) + suffix;
            }
        });
        counterView.setAutoStart(false);
        counterView.setStartValue(200f);
        counterView.setEndValue(1000f);
        counterView.setIncrement(5f); // the amount the number increments at each time interval
        counterView.setTimeInterval(2); // the time interval (ms) at which the text changes
        counterView.setPrefix("You have ");
        counterView.setSuffix(" points!");
        counterView.start();
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.paranormal, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}




Java Source Code List

com.github.premnirmal.textcounter.CounterType.java
com.github.premnirmal.textcounter.CounterView.java
com.github.premnirmal.textcounter.Counter.java
com.github.premnirmal.textcounter.Formatter.java
com.github.premnirmal.textcounter.formatters.CommaSeparatedDecimalFormatter.java
com.github.premnirmal.textcounter.formatters.DecimalFormatter.java
com.github.premnirmal.textcounter.formatters.IntegerFormatter.java
com.github.premnirmal.textcounter.formatters.NoFormatter.java
com.github.premnirmal.textcounterdemo.ParanormalActivity.java