Example usage for android.support.v4.app FragmentManager findFragmentById

List of usage examples for android.support.v4.app FragmentManager findFragmentById

Introduction

In this page you can find the example usage for android.support.v4.app FragmentManager findFragmentById.

Prototype

public abstract Fragment findFragmentById(int id);

Source Link

Document

Finds a fragment that was identified by the given id either when inflated from XML or as the container ID when added in a transaction.

Usage

From source file:net.lp.hivawareness.v4.HIVAwarenessActivity.java

/**
 * Make transaction to "started" fragment because the form was filled.
 *//*from  w w  w  . ja va 2  s.co  m*/
protected void goToStartedFragment() {
    if (!(DEBUG && mNfcAdapter == null)) {
        mNfcAdapter.disableForegroundNdefPush(this);
        mNfcAdapter.enableForegroundNdefPush(this, createNdefMessage());
    }

    FragmentManager fragmentManager = getSupportFragmentManager();
    android.support.v4.app.FragmentTransaction transaction = fragmentManager.beginTransaction();

    StartedFragment sf = new StartedFragment();
    // Replace whatever is in the fragment_container view with this
    // fragment,
    // and add the transaction to the back stack
    transaction.remove(fragmentManager.findFragmentById(R.id.start_fragment));
    transaction.add(R.id.fragment_container, sf);
    transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE);
    transaction.addToBackStack("started");

    // Commit the transaction
    transaction.commit();
}

From source file:br.com.split.activities.PickFriendsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_escolher_amigos_facebook);

    FragmentManager fm = getSupportFragmentManager();

    if (savedInstanceState == null) {
        // First time through, we create our fragment programmatically.
        final Bundle args = getIntent().getExtras();
        friendPickerFragment = new FriendPickerFragment(args);
        friendPickerFragment.setFriendPickerType(FriendPickerType.TAGGABLE_FRIENDS);
        friendPickerFragment.setDoneButtonText(getResources().getString(R.string.acao_feito));
        friendPickerFragment.setTitleText(getResources().getString(R.string.title_activity_facebook_amigos));
        fm.beginTransaction().add(R.id.friend_picker_fragment, friendPickerFragment).commit();
    } else {// w ww  .j  a v  a 2s. co  m
        // Subsequent times, our fragment is recreated by the framework and already has saved and
        // restored its state, so we don't need to specify args again. (In fact, this might be
        // incorrect if the fragment was modified programmatically since it was created.)
        friendPickerFragment = (FriendPickerFragment) fm.findFragmentById(R.id.friend_picker_fragment);
    }

    friendPickerFragment.setOnErrorListener(new PickerFragment.OnErrorListener() {
        @Override
        public void onError(PickerFragment<?> fragment, FacebookException error) {
            PickFriendsActivity.this.onError(error);
        }
    });

    friendPickerFragment.setOnDoneButtonClickedListener(new PickerFragment.OnDoneButtonClickedListener() {
        @Override
        public void onDoneButtonClicked(PickerFragment<?> fragment) {
            if (friendPickerFragment.getSelection().size() != 0) {
                SplitApplication application = (SplitApplication) getApplication();
                // TODO: Aqui nao devemos desmarcar os amigos ja adicionados ao evento.
                application.setSelectedUsers(friendPickerFragment.getSelection());
                setResult(RESULT_OK);
                finish();
            } else {
                setResult(RESULT_CANCELED);
                finish();
            }

        }
    });
}

From source file:com.dwdesign.tweetings.activity.HomeActivity.java

@Override
public void onBackStackChanged() {
    super.onBackStackChanged();
    if (!isDualPaneMode())
        return;// ww  w . ja  va 2 s  . co m
    final FragmentManager fm = getSupportFragmentManager();
    final Fragment left_pane_fragment = fm.findFragmentById(PANE_LEFT);
    final boolean left_pane_used = left_pane_fragment != null && left_pane_fragment.isAdded();
    setPagingEnabled(!left_pane_used);
    final int count = fm.getBackStackEntryCount();
    if (count == 0) {
        bringLeftPaneToFront();
    }
    invalidateSupportOptionsMenu();
}

From source file:com.guldencoin.androidwallet.nlg.ui.AddressBookActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.address_book_content);

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    final ViewPager pager = (ViewPager) findViewById(R.id.address_book_pager);

    final FragmentManager fm = getSupportFragmentManager();

    if (pager != null) {
        final ViewPagerTabs pagerTabs = (ViewPagerTabs) findViewById(R.id.address_book_pager_tabs);
        pagerTabs.addTabLabels(R.string.address_book_list_receiving_title,
                R.string.address_book_list_sending_title);

        final PagerAdapter pagerAdapter = new PagerAdapter(fm);

        pager.setAdapter(pagerAdapter);//from   w  w w  .j ava 2s  .  c  o  m
        pager.setOnPageChangeListener(pagerTabs);
        final int position = getIntent().getBooleanExtra(EXTRA_SENDING, true) == true ? 1 : 0;
        pager.setCurrentItem(position);
        pager.setPageMargin(2);
        pager.setPageMarginDrawable(R.color.bg_less_bright);

        pagerTabs.onPageSelected(position);
        pagerTabs.onPageScrolled(position, 0, 0);

        walletAddressesFragment = new WalletAddressesFragment();
        sendingAddressesFragment = new SendingAddressesFragment();
    } else {
        walletAddressesFragment = (WalletAddressesFragment) fm.findFragmentById(R.id.wallet_addresses_fragment);
        sendingAddressesFragment = (SendingAddressesFragment) fm
                .findFragmentById(R.id.sending_addresses_fragment);
    }

    updateFragments();
}

From source file:com.wearapp.PickFriendsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.pick_friends_activity);
    newPermissionsRequest = new NewPermissionsRequest(this, Arrays.asList("xmpp_login"));
    FragmentManager fm = getSupportFragmentManager();

    if (savedInstanceState == null) {
        // First time through, we create our fragment programmatically.
        final Bundle args = getIntent().getExtras();
        friendPickerFragment = new FriendPickerFragment(args);
        fm.beginTransaction().add(R.id.friend_picker_fragment, friendPickerFragment).commit();
    } else {/*from   ww w  . ja  v  a 2 s.  c  o  m*/
        // Subsequent times, our fragment is recreated by the framework and
        // already has saved and
        // restored its state, so we don't need to specify args again. (In
        // fact, this might be
        // incorrect if the fragment was modified programmatically since it
        // was created.)
        friendPickerFragment = (FriendPickerFragment) fm.findFragmentById(R.id.friend_picker_fragment);
    }

    friendPickerFragment.setOnErrorListener(new PickerFragment.OnErrorListener() {
        @Override
        public void onError(PickerFragment<?> fragment, FacebookException error) {
            PickFriendsActivity.this.onError(error);
        }
    });

    friendPickerFragment.setOnSelectionChangedListener(new OnSelectionChangedListener() {
        @Override
        public void onSelectionChanged(PickerFragment<?> fragment) {
            // TODO Auto-generated method stub

            selectedUsers_temp1 = friendPickerFragment.getSelection();

            /*tempselectedUsers = friendPickerFragment.getSelection();
                    
            if (selectedUsers.size()==0)
            {
               selectedUsers = tempselectedUsers;
            }
                    
                    
            for (GraphUser u :tempselectedUsers)
            {                              
               if (!selectedUsers.contains(u))
               {
             selectedUsers.add(u);
             System.out.println("XX-add"+u.getName());
               }
                       
            }
                    
                    
            Iterator<GraphUser> it = selectedUsers.iterator();
               while(it.hasNext()) {
                     
             GraphUser u = it.next();
             if (!tempselectedUsers.contains(u))
             {                                        
                it.remove();
                selectedUsers.remove(u);
                System.out.println("XX-remove"+u.getName());
             }
               }
                    
                    
            System.out.println("XX===="+selectedUsers.size()+"====");
            for (GraphUser u :selectedUsers)
            {
               System.out.println("XX"+u.getName());
            }
            System.out.println("XX========");*/

        }
    });

    friendPickerFragment.setOnDoneButtonClickedListener(new PickerFragment.OnDoneButtonClickedListener() {
        @Override
        public void onDoneButtonClicked(PickerFragment<?> fragment) {
            // We just store our selection in the Application for other
            // activities to look at.
            // FriendPickerApplication application =
            // (FriendPickerApplication) getApplication();

            // if No friends selected , show the dialog
            if ((selectedUsers.size() == 0) && (selectedUsers_temp1.size() == 0)) {
                Toast.makeText(getApplicationContext(), "No selected users, Message not sent",
                        Toast.LENGTH_LONG).show();

            } else if ((selectedUsers.size() == 0) && (selectedUsers_temp1.size() != 0)) // if the friend list not been filtered by keywords, initiate the selectedUsers list
            {
                selectedUsers = selectedUsers_temp1;
            }

            //remove duplicated friends in the selected friend list
            for (int i = 0; i < selectedUsers.size() - 1; i++) {
                for (int j = selectedUsers.size() - 1; j > i; j--) {
                    if (selectedUsers.get(j).getId().equals(selectedUsers.get(i).getId()))
                        selectedUsers.remove(j);
                }
            }

            Session session = Session.getActiveSession();

            editDialog = new EditText(PickFriendsActivity.this);
            editDialog.setRawInputType(Configuration.KEYBOARD_QWERTY);
            editDialog.setInputType(InputType.TYPE_CLASS_TEXT);

            if (session.isOpened()) {
                session.requestNewReadPermissions(newPermissionsRequest);

                for (GraphUser selectedUser : selectedUsers) {
                    if (selectedUsers.size() - 1 != selectedUsers.indexOf(selectedUser))
                        friendslist_selected.append(selectedUser.getName() + ",");
                    else
                        friendslist_selected.append(selectedUser.getName());
                }

                new AlertDialog.Builder(PickFriendsActivity.this)
                        .setMessage("Please edit the messages to send to " + friendslist_selected + " in "
                                + LocationUtil.selectedlocation.getName() + " ?")
                        .setView(editDialog).setPositiveButton("YES", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                // TODO Auto-generated method stub                                       
                                sendMessage();
                                finishActivity();
                            }
                        }).setNegativeButton("NO", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                // TODO Auto-generated method stub
                                Toast.makeText(getApplicationContext(), "Message not sent", Toast.LENGTH_LONG)
                                        .show();
                                finishActivity();
                            }
                        }).show();
            }
        }
    });
}

From source file:com.example.zoetablet.BasicFragmentActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //Set the orientation
    //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    //Shapes and Coredx DDS Initialization
    // magic to enable WiFi multicast to work on some android platforms:
    WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    mcastLock = wifi.createMulticastLock("Tablet");
    mcastLock.acquire();//from  w  ww  .ja  va2s.  c  o  m

    //Tablet variables
    tablet = new Vector<TabletWriter>();

    // open CoreDX DDS license file:
    BufferedReader br = null;
    String license = new String("<");
    try {
        Log.i("Debug", "...Opening License");
        br = new BufferedReader(new InputStreamReader(this.getAssets().open("coredx_dds.lic")));
    } catch (IOException e) {
        Log.i("Debug", "...License did not open");
        Log.e("Tablet", e.getMessage());
    }
    if (br != null) {
        String ln;
        try {
            while ((ln = br.readLine()) != null) {
                license = new String(license + ln + "\n");
            }
        } catch (IOException e) {
            //  Log.e("Tablet", e.getMessage());
        }
    }
    license = new String(license + ">");
    Log.i("Tablet", "...License seems to be good");

    //Initialize Variables
    XVel = 1;
    YVel = 2;
    CompassDir = 3;
    GPS_LN = 4;
    GPS_LT = 5;
    Log_DDS = DateFormat.getDateTimeInstance().format(new Date());

    //For the Image, use current image display and 
    String fileName = "/storage/sdcard0/DCIM/no_video.jpg";
    Bitmap bmp;
    bmp = BitmapFactory.decodeFile(fileName);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bmp.compress(Bitmap.CompressFormat.JPEG, 40, baos);
    buffer = baos.toByteArray();
    data_image_DDS = buffer;

    Log.i("Tablet", "Creating Subscriber");
    class TestDataReaderListener implements DataReaderListener {

        @Override
        public long get_nil_mask() {
            return 0;
        }

        @Override
        public void on_requested_deadline_missed(DataReader dr, RequestedDeadlineMissedStatus status) {
            System.out.println(" @@@@@@@@@@@     REQUESTED DEADLINE MISSED    @@@@@");
            System.out.println(" @@@@@@@@@@@                                  @@@@@");
            System.out.println(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
        };

        @Override
        public void on_requested_incompatible_qos(DataReader dr, RequestedIncompatibleQosStatus status) {
            System.out.println(" @@@@@@@@@@@     REQUESTED INCOMPAT QOS    @@@@@@@@");
            System.out.println(" @@@@@@@@@@@        dr      = " + dr);
            System.out.println(" @@@@@@@@@@@                               @@@@@@@@");
            System.out.println(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
        };

        @Override
        public void on_sample_rejected(DataReader dr, SampleRejectedStatus status) {
        };

        @Override
        public void on_liveliness_changed(DataReader dr, LivelinessChangedStatus status) {
            TopicDescription td = dr.get_topicdescription();
            System.out.println(" @@@@@@@@@@@     LIVELINESS CHANGED  " + td.get_name() + " @@@@@@@@@@");
        }

        @Override
        public void on_subscription_matched(DataReader dr, SubscriptionMatchedStatus status) {
            TopicDescription td = dr.get_topicdescription();
            System.out.println(" @@@@@@@@@@@     SUBSCRIPTION MATCHED    @@@@@@@@@@");
            System.out.println(
                    " @@@@@@@@@@@        topic   = " + td.get_name() + " (type: " + td.get_type_name() + ")");
            System.out.println(" @@@@@@@@@@@        current = " + status.get_current_count());
            System.out.println(" @@@@@@@@@@@                             @@@@@@@@@@");
            System.out.println(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
        }

        @Override
        public void on_sample_lost(DataReader dr, SampleLostStatus status) {
            System.out.println(" @@@@@@@@@@@   SAMPLE LOST    @@@@@@@@@@");
        };

        @Override
        public void on_data_available(DataReader dr) {

            TopicDescription td = dr.get_topicdescription();
            dataDDSDataReader data_message = (dataDDSDataReader) dr;
            System.out.println(" @@@@@@@@@@@     DATA AVAILABLE          @@@@@@@@@@");
            System.out.println(
                    " @@@@@@@@@@@        topic = " + td.get_name() + " (type: " + td.get_type_name() + ")");

            samples = new dataDDSSeq();
            SampleInfoSeq si = new SampleInfoSeq();

            ReturnCode_t retval = data_message.take(samples, si, 100, coredxConstants.DDS_ANY_SAMPLE_STATE,
                    coredxConstants.DDS_ANY_VIEW_STATE, coredxConstants.DDS_ANY_INSTANCE_STATE);
            System.out.println(" @@@@@@@@@@@        DR.read() ===> " + retval);

            if (retval == ReturnCode_t.RETCODE_OK) {
                if (samples.value == null)
                    System.out.println(" @@@@@@@@@@@        samples.value = null");
                else {
                    System.out.println(" @@@@@@@@@@@        samples.value.length= " + samples.value.length);
                    for (int i = 0; i < samples.value.length; i++) {
                        System.out.println("    State       : "
                                + (si.value[i].instance_state == coredxConstants.DDS_ALIVE_INSTANCE_STATE
                                        ? "ALIVE"
                                        : "NOT ALIVE"));
                        System.out.println("    TimeStamp   : " + si.value[i].source_timestamp.sec + "."
                                + si.value[i].source_timestamp.nanosec);
                        System.out.println("    Handle      : " + si.value[i].instance_handle.value);
                        System.out.println("    WriterHandle: " + si.value[i].publication_handle.value);
                        System.out.println("    SampleRank  : " + si.value[i].sample_rank);
                        if (si.value[i].valid_data)
                            System.out.println("       XVel: " + samples.value[i].XVel_DDS);
                        System.out.println("       YVel: " + samples.value[i].YVel_DDS);
                        System.out.println(" CompassDir: " + samples.value[i].CompassDir_DDS);
                        System.out.println("     GPS_LT: " + samples.value[i].GPS_LT_DDS);
                        System.out.println("     GPS_LN: " + samples.value[i].GPS_LN_DDS);
                        System.out.println("     Log_DDS: " + samples.value[i].Log_DDS);

                        //Capture data values for display
                        BasicFragmentActivity.XVel = samples.value[i].XVel_DDS;
                        BasicFragmentActivity.YVel = samples.value[i].YVel_DDS;
                        BasicFragmentActivity.CompassDir = samples.value[i].CompassDir_DDS;
                        BasicFragmentActivity.GPS_LT = samples.value[i].GPS_LT_DDS;
                        BasicFragmentActivity.GPS_LN = samples.value[i].GPS_LN_DDS;
                        BasicFragmentActivity.Log_DDS = samples.value[i].Log_DDS;
                        BasicFragmentActivity.data_image_DDS = samples.value[i].data_image_DDS;
                    }
                }
                data_message.return_loan(samples, si);
            } else {
            }
            System.out.println(" @@@@@@@@@@@                             @@@@@@@@@@");
            System.out.println(" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
        };
    }
    ;

    System.out.println("STARTING -------------------------");
    DomainParticipantFactory dpf = DomainParticipantFactory.get_instance();
    dpf.set_license(license);
    dpf.get_default_participant_qos(dp_qos_tablet);
    DomainParticipant dp = null;

    System.out.println("CREATE PARTICIPANT ---------------");
    dp = dpf.create_participant(0, /* domain Id   */
            dp_qos_tablet,
            //null, /* default qos */
            null, /* no listener */
            0);

    if (dp == null) {
        //failed to create DomainParticipant -- bad license
        android.util.Log.e("CoreDX DDS", "Unable to create Tablet DomainParticipant.");
    }

    SubscriberQos sub_qos_tablet = new SubscriberQos();
    Log.i("Tablet", "creating publisher/subscriber");
    sub_tablet = dp.create_subscriber(sub_qos_tablet, null, 0);

    System.out.println("REGISTERING TYPE -----------------");
    dataDDSTypeSupport ts = new dataDDSTypeSupport();
    ReturnCode_t returnValue = ts.register_type(dp, null);

    if (returnValue != ReturnCode_t.RETCODE_OK) {
        System.out.println("ERROR registering type\n");
        return;
    }

    System.out.println("CREATE TOPIC ---------------------");

    /* create a DDS Topic with the FilterMsg data type. */
    Topic topics = dp.create_topic("dataDDS", ts.get_type_name(), DDS.TOPIC_QOS_DEFAULT, null, 0);

    if (topics == null) {
        System.out.println("Error creating topic");
        return;
    }

    System.out.println("CREATE SUBSCRIBER ----------------");
    SubscriberQos sub_qos = null;
    SubscriberListener sub_listener = null;
    Subscriber sub = dp.create_subscriber(sub_qos, sub_listener, 0);

    System.out.println("READER VARIABLES ----------------");
    DataReaderQos dr_qos = new DataReaderQos();
    sub.get_default_datareader_qos(dr_qos);
    dr_qos.entity_name.value = "JAVA_DR";
    dr_qos.history.depth = 10;
    DataReaderListener dr_listener = new TestDataReaderListener();

    System.out.println("CREATE DATAREADER ----------------");

    //Create DDS Data reader
    dataDDSDataReader dr = (dataDDSDataReader) sub.create_datareader(topics, DDS.DATAREADER_QOS_DEFAULT,
            dr_listener, DDS.DATA_AVAILABLE_STATUS);

    System.out.println("DATAREADER CREATED ----------------");

    //Cheack to see if DDS Data Reader worked 
    if (dr == null) {
        System.out.println("ERROR creating data reader\n");
        //return;
    }

    // We default to building our Fragment at runtime, but you can switch the layout here
    // to R.layout.activity_fragment_xml in order to have the Fragment added during the
    // Activity's layout inflation.

    setContentView(R.layout.holygrail);
    Log.i("Tablet", "called set content view");

    FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(R.id.center_pane_top); // You can find Fragments just like you would with a 
    // View by using FragmentManager.

    Log.i("Tablet", "...declare fragment");

    // If wLog.ie are using activity_fragment_xml.xml then this the fragment will not be
    // null, otherwise it will be.
    if (fragment == null) {

        //Image View Fragment
        Log.i("Debug", "...calling fragment center pane");
        FragmentTransaction ft = fm.beginTransaction();
        ft.add(R.id.center_pane_top, new BasicFragment());
        ft.addToBackStack(null);

        //Logging Fragment
        Log.i("Debug", "...calling fragment left pane top");
        //ft.add(R.id.left_pane_top, new LoggingFragment());
        ft.add(R.id.left_pane_top, new LoggingFragment());
        ft.addToBackStack(null);

        //Connecting Fragment
        Log.i("Debug", "...calling fragment left pane bottom");
        //ft.add(R.id.left_pane_bottom,new ControllerFragment());
        ft.add(R.id.left_pane_bottom, new ConnectionFragment());
        ft.addToBackStack(null);

        //Compass Fragment
        Log.i("Debug", "...calling fragment right pane top");
        //ft.add(R.id.right_pane_top,new BasicFragment2());
        ft.add(R.id.right_pane_top, new BasicFragment2());
        ft.addToBackStack(null);

        //Navigation Fragment
        Log.i("Debug", "...calling fragment right pane bottom");
        //ft.add(R.id.center_pane_bottom,new NavigationFragment());
        ft.add(R.id.center_pane_bottom, new DualJoystickActivity());
        ft.addToBackStack(null);

        //Datalog Fragment
        Log.i("Debug", "...calling fragment middle pane bottom");
        //ft.add(R.id.right_pane_bottom,new DatalogFragment());
        ft.add(R.id.right_pane_bottom, new DatalogFragment());
        ft.addToBackStack(null);

        //Commit the fragment or it will not be added
        Log.i("Debug", "...comitting");
        ft.commit();
    }

    //Joystick variables
    txtX1 = (TextView) this.findViewById(R.id.TextViewX1);
    txtY1 = (TextView) this.findViewById(R.id.TextViewY1);
    txtX2 = (TextView) this.findViewById(R.id.TextViewX2);
    txtY2 = (TextView) this.findViewById(R.id.TextViewY2);
    joystick = (DualJoystickView) this.findViewById(R.id.dualjoystickView);

    JoystickMovedListener _listenerLeft = new JoystickMovedListener() {

        @Override
        public void OnMoved(int pan, int tilt) {
            txtX1.setText(Integer.toString(pan));
            txtY1.setText(Integer.toString(tilt));
        }

        @Override
        public void OnReleased() {
            txtX1.setText("released");
            txtY1.setText("released");
        }

        @Override
        public void OnReturnedToCenter() {
            txtX1.setText("stopped");
            txtY1.setText("stopped");
        };
    };

    JoystickMovedListener _listenerRight = new JoystickMovedListener() {

        @Override
        public void OnMoved(int pan, int tilt) {
            txtX2.setText(Integer.toString(pan));
            txtY2.setText(Integer.toString(tilt));
        }

        @Override
        public void OnReleased() {
            txtX2.setText("released");
            txtY2.setText("released");
        }

        @Override
        public void OnReturnedToCenter() {
            txtX2.setText("stopped");
            txtY2.setText("stopped");
        };
    };

    joystick.setOnJostickMovedListener(_listenerLeft, _listenerRight);

    //Compass Activities
    compassView = (CompassView) this.findViewById(R.id.compassView);
    sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    //  updateOrientation(new float[] {0, 0, 0});
    //  updateOrientation(calculateOrientation());

    // Hook up button presses to the appropriate event handler.
    // Quit Button -- not really necessary: The 'Back' button does 
    //   the same thing, but we create this just for fun..
    ((Button) findViewById(R.id.quitButton)).setOnClickListener(mQuitListener);

    tv_myAddr = (TextView) findViewById(R.id.myAddress);
    if (tv_myAddr != null)
        tv_myAddr.setText("<detecting>");
    mHandler.postDelayed(mUpdateMyAddress, 1000); // every 10 sec */

    //Updating Datalog fragment view
    tv_XVel = (TextView) findViewById(R.id.XVel);
    if (tv_XVel != null)
        tv_XVel.setText("<detecting>");

    tv_YVel = (TextView) findViewById(R.id.YVel);
    if (tv_YVel != null)
        tv_YVel.setText("<detecting>");

    tv_CompassDir = (TextView) findViewById(R.id.CompassDir);
    if (tv_CompassDir != null)
        tv_CompassDir.setText("<detecting>");

    tv_GPSLocation = (TextView) findViewById(R.id.GPSLocation);
    if (tv_GPSLocation != null)
        tv_GPSLocation.setText("<detecting>");

    tv_Log_DDS = (TextView) findViewById(R.id.loggingMessage);
    if (tv_Log_DDS != null)
        tv_Log_DDS.setText("<detecting>");

    mHandler.postDelayed(mUpdateDatalog, 500); // every 1 sec */
}

From source file:com.example.aula20141117.util.AmUtil.java

public GoogleMap obterGoogleMapViaResourceId(int idDoMapa, FragmentActivity geradoraDoPedido) {
    //ateno no confundir com android.app.FragmentManager
    //este  android.support.v4.app.FragmentManager;
    android.support.v4.app.FragmentManager mFragmentManager; //gestor de fragmentos na library v4
    android.support.v4.app.Fragment mMapFragment; //tipo de Fragment na library v4
    com.google.android.gms.maps.SupportMapFragment mSupportMapFragment; //transformador de fragmentos em mapas
    com.google.android.gms.maps.GoogleMap mMap; //mapas na Maps API V2

    GoogleMap ret = null;/*w  w  w  . j  av  a  2  s .c o  m*/

    String resultado = testarSuporteGooglePlayServicesNoDispositivo(geradoraDoPedido);
    mUltimoErro = resultado;
    //mostrarMensagem (resultado);

    if (resultado.equals("SUCCESS")) {
        //android.support.v4.app.FragmentManager;
        mFragmentManager = geradoraDoPedido.getSupportFragmentManager();
        if (mFragmentManager == null)
            mUltimoErro = "ERRO : no foi possvel obter um objeto FragmentManager";
        else
            mUltimoErro = "SUCESSO: foi possvel obter um objeto FragmentManager";

        //GoogleMap implica import com.google.android.gms.maps.GoogleMap;
        mMapFragment = mFragmentManager.findFragmentById(idDoMapa);
        if (mMapFragment == null)
            mUltimoErro = "ERRO : no foi possvel obter um MapFragment via um FragmentManager";
        else
            mUltimoErro = "SUCESSO: foi possvel obter um MapFragment via um FragmentManager";

        //SupportMapFragment implica import com.google.android.gms.maps.SupportMapFragment;
        mSupportMapFragment = (SupportMapFragment) mMapFragment;
        if (mSupportMapFragment == null)
            mUltimoErro = "ERRO : no foi possvel fazer um cast para SupportMapFragment a partir de um MapFragment";
        else
            mUltimoErro = "SUCESSO: foi possvel fazer um cast para SupportMapFragment a partir de um MapFragment";

        //finalmente o mapa
        ret = mMap = mSupportMapFragment.getMap();
        if (mMap == null)
            mUltimoErro = "ERRO : no foi possvel um GoogleMap a partir de um objeto SupportMapFragment via chamada a getMap()";
        else
            mUltimoErro = "SUCESSO: foi possvel um GoogleMap a partir de um objeto SupportMapFragment via chamada a getMap()";

    } //if

    return ret;
}

From source file:com.xandy.calendar.AllInOneActivity.java

@Override
public void onSaveInstanceState(Bundle outState) {
    mOnSaveInstanceStateCalled = true;/*  w  w  w  .  ja  va2  s.  c om*/
    super.onSaveInstanceState(outState);
    outState.putLong(BUNDLE_KEY_RESTORE_TIME, mController.getTime());
    outState.putInt(BUNDLE_KEY_RESTORE_VIEW, mCurrentView);
    if (mCurrentView == ViewType.EDIT) {
        outState.putLong(BUNDLE_KEY_EVENT_ID, mController.getEventId());
    } else if (mCurrentView == ViewType.AGENDA) {
        //            FragmentManager fm = getFragmentManager();
        FragmentManager fm = getSupportFragmentManager();
        Fragment f = fm.findFragmentById(R.id.main_pane);
        if (f instanceof AgendaFragment) {
            outState.putLong(BUNDLE_KEY_EVENT_ID, ((AgendaFragment) f).getLastShowEventId());
        }
    }
    outState.putBoolean(BUNDLE_KEY_CHECK_ACCOUNTS, mCheckForAccounts);
}

From source file:it.iziozi.iziozi.gui.IOBoardActivity.java

private void refreshView(int index) {

    FragmentManager fm = getSupportFragmentManager();

    IOPaginatedBoardFragment fragment = (IOPaginatedBoardFragment) fm.findFragmentById(mFrameLayout.getId());

    fragment.refreshView(index);// w w w.ja va 2  s .  c  o  m

    if (getSupportFragmentManager().getBackStackEntryCount() > 0) {
        mCenterBackButton.setVisibility(View.VISIBLE);
        mCenterHomeButton.setVisibility(View.VISIBLE);
    } else {
        mCenterBackButton.setVisibility(View.GONE);
        mCenterHomeButton.setVisibility(View.GONE);

    }

}

From source file:com.groupon.sthaleeya.osm.PickFriendsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.pick_friends);

    FragmentManager fm = getSupportFragmentManager();

    Bundle extras = getIntent().getExtras();
    if (extras != null && extras.containsKey(Constants.FRIENDS_ID_KEY)) {
        long[] friends_ids = extras.getLongArray(Constants.FRIENDS_ID_KEY);
        if (friends_ids != null) {
            friendsMap = new HashMap<Long, Boolean>();
            for (int i = 0; i < friends_ids.length; i++) {
                friendsMap.put(friends_ids[i], true);
            }/* w  w w. jav  a 2  s.co m*/
        }
    }
    if (savedInstanceState == null) {
        // First time through, we create our fragment programmatically.
        final Bundle args = getIntent().getExtras();
        friendPickerFragment = new FriendPickerFragment(args);
        fm.beginTransaction().add(R.id.friend_picker_fragment, friendPickerFragment).commit();
    } else {
        // Subsequent times, our fragment is recreated by the framework and already has saved and
        // restored its state, so we don't need to specify args again. (In fact, this might be
        // incorrect if the fragment was modified programmatically since it was created.)
        friendPickerFragment = (FriendPickerFragment) fm.findFragmentById(R.id.friend_picker_fragment);
    }

    friendPickerFragment.setOnErrorListener(new PickerFragment.OnErrorListener() {
        @Override
        public void onError(PickerFragment<?> fragment, FacebookException error) {
            PickFriendsActivity.this.onError(error);
        }
    });

    friendPickerFragment.setOnDoneButtonClickedListener(new PickerFragment.OnDoneButtonClickedListener() {
        @Override
        public void onDoneButtonClicked(PickerFragment<?> fragment) {
            List<GraphUser> friends = friendPickerFragment.getSelection();
            String[] friends_ids = new String[friends.size()];
            for (int i = 0; i < friends.size(); i++) {
                friends_ids[i] = friends.get(i).getId();
            }
            Intent intent = new Intent();
            intent.putExtra(Constants.FRIENDS_ID_KEY, friends_ids);
            setResult(RESULT_OK, intent);
            finish();
        }
    });
    friendPickerFragment.setFilter(new GraphObjectFilter<GraphUser>() {

        @Override
        public boolean includeItem(GraphUser graphObject) {
            if ((friendsMap != null) && friendsMap.containsKey(Long.parseLong(graphObject.getId())))
                return false;
            return true;
        }
    });
}