Android Open Source - sloop Data Record Fragment






From Project

Back to project page sloop.

License

The source code is released under:

NON-LICENSE The Sloop data-browser source code is hereby released into the Public Domain. The original author, David Megginson, Megginson Technologies Ltd., and Acclar Open Ltd. provide no warranty:...

If you think the Android project sloop 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.megginson.sloop.ui;
/*from  w w  w.  j a  v  a2 s.  c o m*/
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;

import com.megginson.sloop.activities.MainActivity;
import com.megginson.sloop.model.DataEntry;
import com.megginson.sloop.model.DataRecord;

/**
 * A view fragment wrapping a data record
 * 
 * @author David Megginson
 * @see DataRecord
 * @see DataCollectionPagerAdapter
 */
public class DataRecordFragment extends Fragment {

  public DataRecordFragment() {
    super();
  }

  @Override
  public View onCreateView(LayoutInflater inflater,
      final ViewGroup container, Bundle savedInstanceState) {
    final DataRecord dataRecord = getArguments()
        .getParcelable("dataRecord");
    ListView listView = new ListView(getActivity());
    listView.setAdapter(new DataRecordListAdapter(getActivity(), dataRecord));

    //
    // Long click on an item means assign a filter
    //
    listView.setOnItemLongClickListener(new ListView.OnItemLongClickListener() {
      @Override
      public boolean onItemLongClick(AdapterView<?> parent, View view,
          int position, long id) {
        doAssignFilter(dataRecord.getEntries().get(position));
        return true;
      }
    });

    return listView;
  }

  /**
   * Send out the intent to create a filter.
   * 
   * This method sends a request to the existing {@link MainActivity} at the
   * top of the stack to start filtering its results.
   * 
   * TODO does this belong here?
   * 
   * @param entry
   *            the data entry to use as a model for the filter.
   */
  private void doAssignFilter(DataEntry entry) {
    Intent intent = new Intent(getActivity(), MainActivity.class);
    intent.setAction(MainActivity.ACTION_FILTER);
    // don't create a new instance of MainActivity
    intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    intent.putExtra(MainActivity.PARAM_ENTRY, entry);
    startActivity(intent);
  }

}




Java Source Code List

com.megginson.sloop.activities.ActivitiesUtil.java
com.megginson.sloop.activities.AddressActionProvider.java
com.megginson.sloop.activities.BookmarkEditActivity.java
com.megginson.sloop.activities.BookmarkListActivity.java
com.megginson.sloop.activities.InfoBarFragment.java
com.megginson.sloop.activities.MainActivity.java
com.megginson.sloop.activities.MainDisplayFragment.java
com.megginson.sloop.activities.TextFilterFragment.java
com.megginson.sloop.activities.package-info.java
com.megginson.sloop.model.Bookmark.java
com.megginson.sloop.model.DataCollection.java
com.megginson.sloop.model.DataEntry.java
com.megginson.sloop.model.DataRecord.java
com.megginson.sloop.model.Util.java
com.megginson.sloop.model.ValueFilter.java
com.megginson.sloop.model.impl.ContainsStringFilter.java
com.megginson.sloop.model.impl.DataCollectionIO.java
com.megginson.sloop.model.impl.DataCollectionImpl.java
com.megginson.sloop.model.impl.DataEntryImpl.java
com.megginson.sloop.model.impl.DataRecordImpl.java
com.megginson.sloop.model.impl.EqualsStringFilter.java
com.megginson.sloop.model.impl.package-info.java
com.megginson.sloop.model.package-info.java
com.megginson.sloop.ui.BookmarkListAdapter.java
com.megginson.sloop.ui.DataCollectionLoader.java
com.megginson.sloop.ui.DataCollectionPagerAdapter.java
com.megginson.sloop.ui.DataCollectionResult.java
com.megginson.sloop.ui.DataRecordFragment.java
com.megginson.sloop.ui.DataRecordListAdapter.java
com.megginson.sloop.ui.package-info.java