Android Open Source - sensor-supervisor Media Fragment






From Project

Back to project page sensor-supervisor.

License

The source code is released under:

GNU General Public License

If you think the Android project sensor-supervisor 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.thirdi.sensorsupervisor;
/* www. ja va2s .c  om*/
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

public class MediaFragment extends Fragment {
  /**
   * Media fragment that let's you open either microphone or camera.
   * 
   * mCameraButton : Button to open the camera.
   * mAudioButton : Button to open the microphone.
   * mFragmentManager : FragmentManager to be able to begin fragment transactions.
   * mFragmentTransaction : FragmentTransaction to change the current fragment with camera or audio fragments.
   * 
   */
  
  Button mCameraButton;
    Button mAudioButton;
    AudioFragment mAudioFragment;
    CameraFragment mCameraFragment;
    FragmentManager mFragmentManager;
    FragmentTransaction mFragmentTransaction;
    
    public MediaFragment() {
        // Required empty public constructor
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mAudioFragment = new AudioFragment();
        mCameraFragment = new CameraFragment();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_media, container, false);
    }


    @Override
    public void onStart() {
        super.onStart();
        mFragmentManager=getFragmentManager();

        mCameraButton =(Button)getView().findViewById(R.id.button2);
        mAudioButton =(Button)getView().findViewById(R.id.button);
        mCameraButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              mFragmentTransaction = mFragmentManager.beginTransaction();
              mFragmentTransaction.replace(R.id.container, mCameraFragment);
              mFragmentTransaction.commit();
            }
        });
        mAudioButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mFragmentTransaction = mFragmentManager.beginTransaction();
                mFragmentTransaction.replace(R.id.container,mAudioFragment);
                mFragmentTransaction.commit();
            }
        });

    }
}




Java Source Code List

com.thirdi.sensorsupervisor.AudioFragment.java
com.thirdi.sensorsupervisor.CameraFragment.java
com.thirdi.sensorsupervisor.CameraPreview.java
com.thirdi.sensorsupervisor.DBContract.java
com.thirdi.sensorsupervisor.DBHelper.java
com.thirdi.sensorsupervisor.DatabaseFragment.java
com.thirdi.sensorsupervisor.FileHelper.java
com.thirdi.sensorsupervisor.GPSFragment.java
com.thirdi.sensorsupervisor.MainActivity.java
com.thirdi.sensorsupervisor.MediaFragment.java
com.thirdi.sensorsupervisor.NavigationDrawerFragment.java
com.thirdi.sensorsupervisor.NetworkFragment.java
com.thirdi.sensorsupervisor.SensorFragment.java
com.thirdi.sensorsupervisor.SettingsFragment.java
com.thirdi.sensorsupervisor.WifiAdapter.java
com.thirdi.sensorsupervisor.maps.java