Android Open Source - GPSDataCollector Display Fragment






From Project

Back to project page GPSDataCollector.

License

The source code is released under:

GNU General Public License

If you think the Android project GPSDataCollector 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.ymelo.gpsdatacollector.app;
//w w w .  j a  v a 2  s. c  o  m
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.ymelo.gpsdatacollector.app.utils.FragmentFix;

/**
 * Created by yohann on 10/01/15.
 */
public class DisplayFragment extends FragmentFix implements TripListFragment.OnItemClickedListener{

    public static final String TAG = "DisplayFragment";

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

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_map, container, false);
        if(savedInstanceState == null) {
            FragmentManager manager = getFragmentManager();
            Fragment fr = manager.findFragmentByTag(TripListFragment.TAG);
            if(fr == null) {
                fr = new TripListFragment();
                ((TripListFragment)fr).listener = this;
                fr.setRetainInstance(true);

            }
            manager.beginTransaction().add(R.id.container, fr, TripListFragment.TAG).commit();
        }
        return rootView;
    }

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);

    }

    public void replaceMap(String dataFilename) {
        FragmentManager fragmentManager = getFragmentManager();
        MapFragment fragment;
        fragment = (MapFragment) fragmentManager.findFragmentByTag(MapFragment.TAG);
        if(fragment == null) {
            fragment = MapFragment.newInstance(dataFilename);
            fragment.setRetainInstance(true);
            fragmentManager.beginTransaction().add(R.id.container, fragment, MapFragment.TAG)
                    .addToBackStack(null)
                    .commit();
        } else {

        }


    }

    @Override
    public void onFileClicked(String filePath) {
        replaceMap(filePath);
    }

//    @Override
//    public void onDetach() {
//        super.onDetach();
//        FragmentManager manager = getFragmentManager();
//        Fragment fr = manager.findFragmentByTag(TripListFragment.TAG);
//        if(fr == null) {
//            manager.beginTransaction().remove(fr).commit();
//        }
//    }
}




Java Source Code List

com.ymelo.gpsdatacollector.app.ApplicationTest.java
com.ymelo.gpsdatacollector.app.Config.java
com.ymelo.gpsdatacollector.app.DisplayFragment.java
com.ymelo.gpsdatacollector.app.GetAddressTask.java
com.ymelo.gpsdatacollector.app.LocationServiceErrorMessages.java
com.ymelo.gpsdatacollector.app.MainActivity.java
com.ymelo.gpsdatacollector.app.MapFragment.java
com.ymelo.gpsdatacollector.app.NavigationDrawerFragment.java
com.ymelo.gpsdatacollector.app.RecordFragment.java
com.ymelo.gpsdatacollector.app.TaskUpdater.java
com.ymelo.gpsdatacollector.app.TripListFragment.java
com.ymelo.gpsdatacollector.app.utils.FileUtils.java
com.ymelo.gpsdatacollector.app.utils.FragmentFix.java
com.ymelo.gpsdatacollector.app.utils.LocationUtils.java