Android Open Source - retain-android Date View Cursor Binder






From Project

Back to project page retain-android.

License

The source code is released under:

GNU General Public License

If you think the Android project retain-android 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.retain2;
//w  w  w.  java  2  s. co m
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Date;

import android.database.Cursor;
import android.util.Log;
import android.view.View;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;

public class DateViewCursorBinder implements SimpleCursorAdapter.ViewBinder {

  private static final String LOG_TAG = "WebListAdapter";
  private Date mCurrentDate;
  DateViewCursorBinder()
  {
    mCurrentDate = new Date();
  }
  
  public boolean setViewValue (View view, Cursor cursor, int columnIndex)
  {

    switch( columnIndex )
    {
    case WebDbAdapter.COL_TITLE:
      {
        String str = cursor.getString(columnIndex);
        ((TextView) view).setText(str);
        return true;
      }  

    case WebDbAdapter.COL_URL:
      try 
      {
        String str = cursor.getString(columnIndex);
        URI uri = new URI( str );
        String host = uri.getHost();
        host = host.replaceAll("^www\\.", "");
        ((TextView) view).setText(host);
      }
      catch(URISyntaxException urie)
      {
        Log.e(LOG_TAG, urie.getMessage());
      }
      
      return true;
      

    case WebDbAdapter.COL_TIMESTAMP:
      {
        long l = cursor.getLong(columnIndex);
        String str = AppUtils.getDateStr(l, mCurrentDate);
        
        TextView tv = (TextView) view;
        tv.setText( tv.getText() + " - " + str);
        return true;      
      }  
    }
    
    return false;
  }

}




Java Source Code List

com.retain2.AndroidHttpClient.java
com.retain2.AppUtils.java
com.retain2.BrowserActivity.java
com.retain2.ColorPickerDialog.java
com.retain2.DateViewCursorBinder.java
com.retain2.DeleteHandlerInterface.java
com.retain2.DownloadHandler.java
com.retain2.DownloaderActivityProxy.java
com.retain2.DownloaderActivity.java
com.retain2.HelpActivity.java
com.retain2.PageInfo.java
com.retain2.RenameHandlerInterface.java
com.retain2.RetainActivity.java
com.retain2.SettingsManager.java
com.retain2.SmsIntentReceiver.java
com.retain2.ViewController.java
com.retain2.WebDbAdapter.java
com.retain2.WebViewActivity.java
com.retain2.dialog.DeleteDialog.java
com.retain2.dialog.FindDialog.java
com.retain2.dialog.RenameDialog.java