Android Open Source - RoboSpringExt Robo Spring Example Activity






From Project

Back to project page RoboSpringExt.

License

The source code is released under:

Apache License

If you think the Android project RoboSpringExt 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 org.robospring.ext;
//from   ww w.j a  v  a 2 s .  c om
import android.app.Activity;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import org.robospring.RoboSpring;
import org.robospring.example.R;
import org.robospring.ext.aop.BusinessLogic;
import org.robospring.ext.aop.MyBusinessLogicImpl;
import org.robospring.ext.aop.MyClass;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.AbstractXmlApplicationContext;

import java.net.URL;

import roboguice.inject.InjectView;

public class RoboSpringExampleActivity extends Activity {


    @InjectView
    private TextView textView;

    @InjectView
    private TextView timeView;

    private TextView locationView;

    @InjectView
    private TextView businessLogicOutputView;

    @Autowired
    private Location location;

    @Autowired
    private BusinessLogic businessLogic;
    @Autowired
    private MyBusinessLogicImpl myBusinessLogic;
    @Autowired
    private MyClass myClass;

    @Autowired
    private URL serviceUrl;

    /**
     * @param locationView the locationView to set
     */
    @InjectView
    public void setLocationView(TextView locationView) {
        this.locationView = locationView;
    }

    public RoboSpringExampleActivity() {
        Log.e("RoboSpringService", "<init>");
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        long startTime = System.currentTimeMillis();

        RoboSpring.autowire(this);

        AbstractXmlApplicationContext ctx = RoboSpring.getContext();
        long duration = System.currentTimeMillis() - startTime;

        Person kelly = ctx.getBean("kelly", Person.class);
        textView.setText(kelly.getName() + " -> " + kelly.getFather().getName());
        timeView.setText("Time: " + duration + " ms");

        registerReceiver(new MyBroadcastReceiver(), new IntentFilter("ae"));

    }

    public void onLoadClicked(View view) {

    }

    public void onAutowireClicked(View view) {
        long startTime = System.currentTimeMillis();
        RoboSpring.autowire(this);

        // setLocation(RoboSpring.getDefaultContext().getBean(Location.class));

        long duration = System.currentTimeMillis() - startTime;
        locationView.setText("" + location);
        timeView.setText("Time: " + duration + " ms");

        sendBroadcast(new Intent("ae"));
    }

    public void onStartAop(View view) {
        String string1 = myBusinessLogic.doBusiness(this);
        String string2 = businessLogic.doOtherBusiness(this);
        String string3 = myClass.ae(this);
        businessLogicOutputView.setText("string1 = " + string1
                + " string2 = " + string2 + " string3 = " + string3);
    }
}




Java Source Code List

org.robospring.ext.Location.java
org.robospring.ext.MyApplication.java
org.robospring.ext.MyBroadcastReceiver.java
org.robospring.ext.MyRoboSpringService.java
org.robospring.ext.Person.java
org.robospring.ext.RoboSpringApplication.java
org.robospring.ext.RoboSpringBroadcastReceiver.java
org.robospring.ext.RoboSpringExampleActivity.java
org.robospring.ext.RoboSpringIntentService.java
org.robospring.ext.RoboSpringService.java
org.robospring.ext.aop.BusinessLogicImpl.java
org.robospring.ext.aop.BusinessLogic.java
org.robospring.ext.aop.MyBusinessLogicImpl.java
org.robospring.ext.aop.MyClass.java