Android Open Source - legacy_bluetrack Session Fragment






From Project

Back to project page legacy_bluetrack.

License

The source code is released under:

GNU General Public License

If you think the Android project legacy_bluetrack 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

//*****************************************************************************
// This file is part of bluetrack.
////w  w  w .ja  va  2 s.  co m
// bluetrack is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// bluetrack is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with bluetrack.  If not, see <http://www.gnu.org/licenses/>.
//*****************************************************************************

package org.jonblack.bluetrack.activities;

import org.jonblack.bluetrack.R;
import org.jonblack.bluetrack.adapters.SessionCursorAdapter;
import org.jonblack.bluetrack.storage.SessionTable;

import com.actionbarsherlock.app.SherlockListFragment;

import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.database.Cursor;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class SessionFragment extends SherlockListFragment
                             implements LoaderManager.LoaderCallbacks<Cursor>
{
  /**
   * SimpleCursorAdapter used by the list view to get data.
   */
  private SessionCursorAdapter mAdapter;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState)
  {
    super.onCreateView(inflater, container, savedInstanceState);
    
    // Create an return the custom ListView layout which also displays an
    // 'empty list' message.
    return inflater.inflate(R.layout.session_list, null);
  }
  
  @Override
  public void onDestroyView()
  {
    super.onDestroyView();
  }
  
  @Override
  public void onActivityCreated(Bundle savedInstanceState)
  {
    super.onActivityCreated(savedInstanceState);
    
    // Configure the ListView adapter, which will connect to the database.
    mAdapter = new SessionCursorAdapter(getActivity(), null, 0);
    setListAdapter(mAdapter);
    
    // Prepare the loader. Either re-connect with an existing one, or start a
    // new one.
    getLoaderManager().initLoader(0, null, this);
  }
  
  @Override
  public Loader<Cursor> onCreateLoader(int id, Bundle args)
  {
    // Now create and return a CursorLoader that will take care of
    // creating a Cursor for the data being displayed.
    return new CursorLoader(getActivity(), SessionTable.CONTENT_URI,
                            new String[] {SessionTable.COL_ID,
                                          "start_date_time",
                                           "end_date_time"},
                            null, null, null);
  }

  @Override
  public void onLoadFinished(Loader<Cursor> loader, Cursor data)
  {
    // Swap the new cursor in. (The framework will take care of closing the
    // old cursor once we return.)
    mAdapter.swapCursor(data);
  }

  @Override
  public void onLoaderReset(Loader<Cursor> loader)
  {
    // This is called when the last Cursor provided to onLoadFinished()
    // above is about to be closed.  We need to make sure we are no
    // longer using it.
    mAdapter.swapCursor(null);
  }
}




Java Source Code List

org.jonblack.bluetrack.BluetoothClassLookup.java
org.jonblack.bluetrack.BluetrackIdentifiers.java
org.jonblack.bluetrack.DeviceDiscovery.java
org.jonblack.bluetrack.Device.java
org.jonblack.bluetrack.Session.java
org.jonblack.bluetrack.activities.DevicesFragment.java
org.jonblack.bluetrack.activities.LiveTrackingFragment.java
org.jonblack.bluetrack.activities.MainActivity.java
org.jonblack.bluetrack.activities.SessionFragment.java
org.jonblack.bluetrack.activities.SettingsActivity.java
org.jonblack.bluetrack.adapters.DeviceCursorAdapter.java
org.jonblack.bluetrack.adapters.LiveTrackingCursorAdapter.java
org.jonblack.bluetrack.adapters.SessionCursorAdapter.java
org.jonblack.bluetrack.services.BluetoothLogService.java
org.jonblack.bluetrack.storage.BluetrackContentProvider.java
org.jonblack.bluetrack.storage.BluetrackOpenHelper.java
org.jonblack.bluetrack.storage.DeviceDiscoveryTable.java
org.jonblack.bluetrack.storage.DeviceTable.java
org.jonblack.bluetrack.storage.SessionTable.java