Android Open Source - WAIDRecognizer History Selector Adapter






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

/**
 * /*  w  ww  .  jav  a 2s  . co m*/
 */
package it.unibo.cs.jonus.waidrec;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Locale;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

/**
 * @author jei
 * 
 */
public class HistorySelectorAdapter extends ArrayAdapter<File> {

  private LayoutInflater inflater;
  private ArrayList<File> items;

  public HistorySelectorAdapter(Context context, ArrayList<File> objects) {
    super(context, R.layout.history_selector_item, objects);

    this.inflater = LayoutInflater.from(context);
    this.items = objects;
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    // Create a new view of my layout and inflate it in the row
    convertView = (LinearLayout) inflater.inflate(
        R.layout.history_selector_item, parent, false);

    // Extract file name from path
    File file = getItem(position);
    String fileName = file.getName();

    // Set item's name
    TextView fileNameView = (TextView) convertView
        .findViewById(R.id.historyFileName);
    fileNameView.setText(fileName);

    // Set item's date
    TextView dateView = (TextView) convertView
        .findViewById(R.id.historyFileDate);
    // Get human readable date
    SimpleDateFormat sdfDateTime = new SimpleDateFormat(
        "yyyy-MM-dd HH:mm:ss", Locale.getDefault());
    // FIXME extract timestamp from file name
    String humanDate = sdfDateTime.format(new Date(file.lastModified()));
    dateView.setText(humanDate);

    return convertView;
  }

  @Override
  public View getDropDownView(int position, View convertView, ViewGroup parent) {
    // FIXME different view for dropdown items?
    // Create a new view of my layout and inflate it in the row
    convertView = (LinearLayout) inflater.inflate(
        R.layout.history_selector_item, parent, false);

    // Extract file name from path
    File file = getItem(position);
    String fileName = file.getName();

    // Set item's name
    TextView fileNameView = (TextView) convertView
        .findViewById(R.id.historyFileName);
    fileNameView.setText(fileName);

    // Set item's date
    TextView dateView = (TextView) convertView
        .findViewById(R.id.historyFileDate);
    // Get human readable date
    SimpleDateFormat sdfDateTime = new SimpleDateFormat(
        "yyyy-MM-dd HH:mm:ss", Locale.getDefault());
    // FIXME extract timestamp from file name
    String humanDate = sdfDateTime.format(new Date(file.lastModified()));
    dateView.setText(humanDate);

    return convertView;
  }

  @Override
  public File getItem(int position) {
    return items.get(position);
  }

}




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