Android Open Source - WAIDRecognizer Vehicles Fragment






From Project

Back to project page WAIDRecognizer.

License

The source code is released under:

GNU General Public License

If you think the Android project WAIDRecognizer 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 it.unibo.cs.jonus.waidrec;
//from   w ww. ja v  a  2 s. c om
import it.unibo.cs.jonus.waidrec.AddVehicleDialog.VehicleDialogListener;

import java.util.ArrayList;

import android.app.DialogFragment;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;

public class VehiclesFragment extends PreferenceFragment {

  private ArrayList<VehicleItem> mItems = new ArrayList<VehicleItem>();
  private VehiclesListAdapter mAdapter;

  @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_vehicles, container,
        false);

    return rootView;
  }

  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    // super.onViewCreated(view, savedInstanceState);

    ListView vehiclesListView = (ListView) view
        .findViewById(R.id.vehicles_listview);
    // Get the list of VehicleItem from the db
    Uri uri = Uri.parse(EvaluationsProvider.VEHICLES_URI
        + EvaluationsProvider.PATH_ALL_VEHICLES);
    Cursor cursor = getActivity().getContentResolver().query(uri,
        MainActivity.vehicleColumnsProjection, null, null, null);
    mItems.addAll(EvaluationsProvider.cursorToVehicleItemArray(cursor));
    cursor.close();
    mAdapter = new VehiclesListAdapter(getActivity(), mItems);
    vehiclesListView.setAdapter(mAdapter);

    // Set the listeners for the buttons
    Button addVehicleBtn = (Button) view
        .findViewById(R.id.add_vehicle_button);
    addVehicleBtn.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        AddVehicleDialog dialog = new AddVehicleDialog();
        dialog.registerListener(new VehicleDialogListener() {

          @Override
          public void onDialogPositiveClick(DialogFragment dialog) {
            // Refresh list of vehicles
            Uri uri = Uri.parse(EvaluationsProvider.VEHICLES_URI
                + EvaluationsProvider.PATH_ALL_VEHICLES);
            Cursor cursor = getActivity().getContentResolver()
                .query(uri,
                    MainActivity.vehicleColumnsProjection,
                    null, null, null);
            mItems.clear();
            mItems.addAll(EvaluationsProvider
                .cursorToVehicleItemArray(cursor));
            cursor.close();
            mAdapter.notifyDataSetChanged();
          }
        });
        dialog.show(getFragmentManager(), null);
      }
    });

  }

  @Override
  public void onResume() {
    super.onResume();
  }

  @Override
  public void onPause() {
    super.onPause();
  }

}




Java Source Code List

it.unibo.cs.jonus.waidrec.AddVehicleDialog.java
it.unibo.cs.jonus.waidrec.DatabaseOpenHelper.java
it.unibo.cs.jonus.waidrec.EvaluationsProvider.java
it.unibo.cs.jonus.waidrec.HistoryFragment.java
it.unibo.cs.jonus.waidrec.HistoryListAdapter.java
it.unibo.cs.jonus.waidrec.HistorySelectorAdapter.java
it.unibo.cs.jonus.waidrec.MagnitudeFeatures.java
it.unibo.cs.jonus.waidrec.MagnitudeListener.java
it.unibo.cs.jonus.waidrec.MainActivity.java
it.unibo.cs.jonus.waidrec.MainPrefsActivity.java
it.unibo.cs.jonus.waidrec.ModelManager.java
it.unibo.cs.jonus.waidrec.RecognizerFragment.java
it.unibo.cs.jonus.waidrec.RecognizerService.java
it.unibo.cs.jonus.waidrec.TrainingFragment.java
it.unibo.cs.jonus.waidrec.TrainingService.java
it.unibo.cs.jonus.waidrec.VIListAdapter.java
it.unibo.cs.jonus.waidrec.VehicleInstance.java
it.unibo.cs.jonus.waidrec.VehicleItem.java
it.unibo.cs.jonus.waidrec.VehicleManager.java
it.unibo.cs.jonus.waidrec.VehicleObserver.java
it.unibo.cs.jonus.waidrec.VehicleRecognizer.java
it.unibo.cs.jonus.waidrec.VehicleTrainer.java
it.unibo.cs.jonus.waidrec.VehiclesFragment.java
it.unibo.cs.jonus.waidrec.VehiclesListAdapter.java