Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
  
  This file is part of Roboject
  
  Copyright (c) 2010-2011 akquinet A.G.
  
  Contact:  http://www.akquinet.de/en
  
  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
 
    http://www.apache.org/licenses/LICENSE-2.0
 
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
  */
 package de.akquinet.android.roboject;
 
 import  android.support.v4.app.Fragment;
 
 
 
 public class RobojectSupportFragment extends Fragment implements RobojectLifecycleServiceConnection {
     private Container container;
 
     @Override
     public void onActivityCreated(Bundle savedInstanceState) {
         super.onActivityCreated(savedInstanceState);
         onSetContentView();
     }

    
Contract for subclasses: You need to call super before relying on injections in onCreate(android.os.Bundle).
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         createContainer();
 
         this..invokeCreatePhase();
     }
 
     @Override
     public void onResume() {
         super.onResume();
         this..invokeResumePhase();
     }
 
     @Override
     public void onStop() {
         super.onStop();
         this..invokeStopPhase();
     }
 
     @Override
     public void onServicesConnected() {
     }
 
     @Override
     public void onReady() {
     }

    
Attaches an arbitrary object to an android.content.Intent. This works like an intent extra, but does not require the object to be serializable or parcellable. The object is injected to the activity matching the intent, if that activity uses a matching de.akquinet.android.roboject.annotations.InjectObject annotation.

Parameters:
intent the intent matching the target activity to which we want to pass the object
key an arbitrary String used as the intent extra key
value
 
     protected void putObjectIntentExtra(Intent intentString keyObject value) {
         .putObjectIntentExtra(intentkeyvalue);
     }
 
     @Override
     public void onServiceConnected(ComponentName nameIBinder serviceObject) {
     }
 
     @Override
     public void onServiceDisconnected(ComponentName name) {
    }
    private void onSetContentView() {
        createContainer();
        this..invokeSetContentView();
    }
    private void createContainer() {
        if (this. == null) {
            try {
                // Both the Android Support Library and ActionbarSherlock define
                // getActivity() inside Fragment, but with different return types
                // (FragmentActivity vs. Activity).
                // That's why we call the method by reflection and cast the result to Activity.
                Method getActivity = getClass().getMethod("getActivity"new Class[0]);
                Object activity = getActivity.invoke(thisnew Object[0]);
                if (!(activity instanceof Activity)) {
                    throw new RuntimeException("getActivity() returned null");
                }
                this. = new Container((ActivityactivitythisgetClass());
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
New to GrepCode? Check out our FAQ X