Android Open Source - physics Astroboy Remote Control






From Project

Back to project page physics.

License

The source code is released under:

GNU General Public License

If you think the Android project physics 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.nuaavee.physics.app.controller;
/*from  www  .ja v a2s  .c o m*/
import android.app.Activity;
import android.widget.Toast;
import com.google.inject.Inject;
import roboguice.inject.ContextSingleton;
import roboguice.util.Ln;

/**
 * A class to control Astroboy remotely.
 *
 * This class uses the current context, so we must make it @ContextSingleton.
 * This means that there will be one AstroboyRemoteControl for every activity or
 * service that requires one.
 * Note that we actually ask for the Activity, rather than the Context (which is
 * the same thing), because we need access to some activity-related methods and this
 * saves us from having to downcast to an Activity manually.
 *
 * It also asks RoboGuice to inject the Astroboy instance so we can control him.
 *
 * What you'll learn in this class
 *   - What @ContextScope means and when to use it
 *   - How to inject an Activity instead of a Context (which is really the same thing)
 *   - How to use RoboGuice's convenient and flexible logging facility, Ln.
 */
@ContextSingleton
public class AstroboyRemoteControl {


    // The Astroboy class has been decorated with @Singleton, so this instance of
    // Astroboy will be the same instance used elsewhere in our app.
    // Injecting an Activity is basically equivalent to "@Inject Context context",
    // and thus also requires @ContextScope. If you wanted, you could also
    // @Inject Application, Service, etc. wherever appropriate.
    @Inject
    Astroboy astroboy;
    @Inject
    Activity activity;



    public void brushTeeth() {
        // More info about logging available here: http://code.google.com/p/roboguice/wiki/Logging
        Ln.d("Sent brushTeeth command to Astroboy");
        astroboy.brushTeeth();
    }

    public void say( String something ) {
        Ln.d("Sent say(%s) command to Astroboy",something);
        astroboy.say(something);
    }

    public void selfDestruct() {
        Toast.makeText(activity, "Your evil remote control has exploded! Now Astroboy is FREEEEEEEEEE!", Toast.LENGTH_LONG).show();
        activity.finish();
    }
}




Java Source Code List

com.nuaavee.physics.app.AstroboyMasterConsole.java
com.nuaavee.physics.app.FightForcesOfEvilActivity.java
com.nuaavee.physics.app.MainActivity.java
com.nuaavee.physics.app.MainView.java
com.nuaavee.physics.app.controller.AstroboyRemoteControl.java
com.nuaavee.physics.app.controller.Astroboy.java
com.nuaavee.physics.circle.CircleModule.java
com.nuaavee.physics.circle.Circle.java
com.nuaavee.physics.core.CoreModule.java
com.nuaavee.physics.core.EventProcessor.java
com.nuaavee.physics.core.InjectorHelper.java
com.nuaavee.physics.core.Shell.java
com.nuaavee.physics.core.action.ActionEventFactory.java
com.nuaavee.physics.core.impl.EventProcessorImpl.java
com.nuaavee.physics.core.impl.ShellImpl.java
com.nuaavee.physics.core.layer.LayerManager.java
com.nuaavee.physics.core.layer.impl.LayerManagerImpl.java
com.nuaavee.physics.model.Coordinate.java
com.nuaavee.physics.model.ModelModule.java
com.nuaavee.physics.model.PhysicalObject.java
com.nuaavee.physics.model.action.ActionEventType.java
com.nuaavee.physics.model.action.ActionEvent.java
com.nuaavee.physics.model.action.Actionable.java
com.nuaavee.physics.model.action.listener.AbstractActionListener.java
com.nuaavee.physics.model.action.listener.ActionListener.java
com.nuaavee.physics.model.action.listener.BackgroundActionListener.java
com.nuaavee.physics.model.action.listener.ChildrenActionListener.java
com.nuaavee.physics.model.action.listener.PhysicalObjectActionListener.java
com.nuaavee.physics.model.layer.BackgroundLayer.java
com.nuaavee.physics.model.layer.DaynamicLayer.java
com.nuaavee.physics.model.layer.Layer.java