Android Open Source - shareplay List Wrapper






From Project

Back to project page shareplay.

License

The source code is released under:

Copyright (c) 2014, Benjamin Damer All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ...

If you think the Android project shareplay 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.afqa123.shareplay.common;
//from   w  w  w.j ava2 s  .  c o m
import android.database.Cursor;
import android.view.View;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.ListView;

public class ListWrapper {

  private ListView listView;
  private String filter;
  private int index;
  private int pos;
  private boolean stale;
  private Cursor cursor;
  
  public ListWrapper(final View view, final OnItemClickListener clickListener, final OnItemLongClickListener longClickListener) {
    listView = (ListView)view;
    if (clickListener != null)
      listView.setOnItemClickListener(clickListener);
    if (longClickListener != null) 
      listView.setOnItemLongClickListener(longClickListener);
    stale = true;
  }
  
  public void clearFilters() {
    stale = true;
    listView.clearTextFilter();
  }

  public void setFilter(final String aFilter) {
    filter = aFilter;
  }
  
  public String getFilter() {
    String result = null;
    CharSequence tf = listView.getTextFilter();
    if (tf != null) {
      result = tf.toString();
    }
    return result;
  }
  
  public void setPosition(int index, int pos) {
    this.index = index;
    this.pos = pos;
  }
  
  public void restoreState() {
    listView.setFilterText(filter);
    listView.setSelectionFromTop(index, pos);
  }
  
  public void focus() {
    listView.requestFocus();
  }
  
  public ListView getView() {
    return listView;
  }
  
  public void setStale(boolean stale) {
    this.stale = stale;
  }
  
  public boolean isStale() {
    return stale;
  }
  
  public void setCursor(final Cursor c) {
    // close existing cursor
    releaseCursor();
    cursor = c;
  }
  
  public Cursor getCursor() {
    return cursor;
  }
  
  public void releaseCursor() {
    if (cursor != null && !cursor.isClosed()) {
      cursor.close();
    }    
    stale = true;
  }
}




Java Source Code List

com.afqa123.log.DefaultLogger.java
com.afqa123.log.FileLogger.java
com.afqa123.log.LoggerFactory.java
com.afqa123.log.Logger.java
com.afqa123.log.NullLogger.java
com.afqa123.shareplay.DialogFactory.java
com.afqa123.shareplay.MediaPlayerService.java
com.afqa123.shareplay.SelectionActivity.java
com.afqa123.shareplay.SharePlayActivity.java
com.afqa123.shareplay.common.AuthorizationException.java
com.afqa123.shareplay.common.Base64.java
com.afqa123.shareplay.common.Constants.java
com.afqa123.shareplay.common.CustomFeedback.java
com.afqa123.shareplay.common.DAAPException.java
com.afqa123.shareplay.common.DBHelper.java
com.afqa123.shareplay.common.Feedback.java
com.afqa123.shareplay.common.Filename.java
com.afqa123.shareplay.common.ListWrapper.java
com.afqa123.shareplay.common.StoppableThread.java
com.afqa123.shareplay.common.StreamProxy.java
com.afqa123.shareplay.data.ContentCode.java
com.afqa123.shareplay.data.Item.java
com.afqa123.shareplay.data.Playlist.java
com.afqa123.shareplay.impl.Client.java
com.afqa123.shareplay.impl.DatabaseCatalog.java
com.afqa123.shareplay.impl.ServerProvider.java
com.afqa123.shareplay.impl.Server.java
com.afqa123.shareplay.interfaces.Catalog.java
com.afqa123.shareplay.interfaces.IClient.java
com.afqa123.shareplay.interfaces.IServerProvider.java