Android Open Source - NerdRoll Die View






From Project

Back to project page NerdRoll.

License

The source code is released under:

Apache License

If you think the Android project NerdRoll 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.bignerdranch.android.nerdroll.view;
/*w w w. j  ava 2  s.  c  o m*/
import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bignerdranch.android.nerdroll.R;
import com.bignerdranch.android.nerdroll.screen.DieScreen;

import java.util.Random;

import javax.inject.Inject;

import butterknife.ButterKnife;
import butterknife.InjectView;
import mortar.Mortar;

public class DieView extends LinearLayout {

    @Inject DieScreen.Presenter presenter;

    @InjectView(R.id.view_die_random) public TextView mRandomTextView;
    @InjectView(R.id.view_die_value) public TextView mValueTextView;

    public DieView(Context context, AttributeSet attrs) {
        super(context, attrs);
        Mortar.inject(context, this);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        ButterKnife.inject(this);
        presenter.takeView(this);
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        presenter.dropView(this);
    }

    public void updateRandomText(CharSequence text) {
        mRandomTextView.setText(text);
    }

    public void updateValueText(CharSequence text) {
        mValueTextView.setText(text);
    }

    public void roll(int sides) {
        Random r = new Random();
        int num = r.nextInt(sides) + 1;
        updateValueText(Integer.toString(num));
    }

}




Java Source Code List

com.bignerdranch.android.nerdroll.ApplicationTest.java
com.bignerdranch.android.nerdroll.ApplicationTest.java
com.bignerdranch.android.nerdroll.MainActivity.java
com.bignerdranch.android.nerdroll.MainActivity.java
com.bignerdranch.android.nerdroll.MainApplicationModule.java
com.bignerdranch.android.nerdroll.MainApplicationModule.java
com.bignerdranch.android.nerdroll.MainApplication.java
com.bignerdranch.android.nerdroll.MainApplication.java
com.bignerdranch.android.nerdroll.android.ActionBarModule.java
com.bignerdranch.android.nerdroll.android.ActionBarOwner.java
com.bignerdranch.android.nerdroll.controller.DieFragment.java
com.bignerdranch.android.nerdroll.controller.DieListFragment.java
com.bignerdranch.android.nerdroll.model.DieList.java
com.bignerdranch.android.nerdroll.model.DieList.java
com.bignerdranch.android.nerdroll.model.Die.java
com.bignerdranch.android.nerdroll.model.Die.java
com.bignerdranch.android.nerdroll.screen.DieListScreen.java
com.bignerdranch.android.nerdroll.screen.DieScreen.java
com.bignerdranch.android.nerdroll.screen.MainScreen.java
com.bignerdranch.android.nerdroll.util.CanShowScreen.java
com.bignerdranch.android.nerdroll.util.FlowOwner.java
com.bignerdranch.android.nerdroll.util.GsonParcer.java
com.bignerdranch.android.nerdroll.util.MainScope.java
com.bignerdranch.android.nerdroll.util.ScreenConductor.java
com.bignerdranch.android.nerdroll.view.DieListView.java
com.bignerdranch.android.nerdroll.view.DieView.java
com.bignerdranch.android.nerdroll.view.MainView.java