/android/import-contacts

To get this branch, use:
bzr branch http://bzr.ed.am/android/import-contacts

« back to all changes in this revision

Viewing changes to src/org/waxworlds/edam/importcontacts/FileChooser.java

  • Committer: edam
  • Date: 2010-10-28 16:12:57 UTC
  • Revision ID: edam@waxworlds.org-20101028161257-9stn23tn7tvkkjno
- fixed bug where a file chooser wouldn't know it's context when the context was used

Show diffs side-by-side

added added

removed removed

26
26
import java.io.File;
27
27
import java.io.FileFilter;
28
28
import java.util.ArrayList;
29
 
import java.util.Collections;
30
 
import java.util.Comparator;
31
29
 
32
30
import android.app.AlertDialog;
33
31
import android.app.Dialog;
79
77
        private DialogInterface.OnDismissListener _on_dismiss_listener;
80
78
 
81
79
        // class that represents a row in the list
82
 
        private class RowItem implements Comparable< RowItem >
 
80
        private class RowItem
83
81
        {
84
82
                private String _name;
85
83
                private boolean _directory;
99
97
                {
100
98
                        return _directory;
101
99
                }
102
 
 
103
 
                @Override
104
 
                public int compareTo( RowItem that )
105
 
                {
106
 
                        if( this._directory && !that._directory )
107
 
                                return -1;
108
 
                        else if( !this._directory && that._directory )
109
 
                                return 1;
110
 
                        else
111
 
                                return this._name.compareToIgnoreCase( that._name );
112
 
                }
113
100
        }
114
101
 
115
102
        // class to manage our list of RowItems
143
130
                }
144
131
        }
145
132
 
146
 
        @SuppressWarnings( "serial" )
147
133
        class InvalidPathPrefixException extends RuntimeException
148
134
        {
149
135
        }
193
179
        // set the path prefix
194
180
        public void setPathPrefix( String path_prefix )
195
181
        {
196
 
                // set to cleaned-up path, with trailing '/' removed so that it can be
 
182
                // set to cleaned-up path, with trailaing '/' removed so that it can be
197
183
                // trivially pre-pended to a cleaned-up path
198
184
                _path_prefix = cleanUpPath( path_prefix );
199
185
                _path_prefix = _path_prefix.substring( 0, _path_prefix.length() - 1 );
246
232
        };
247
233
 
248
234
        private OnItemClickListener _fileChooserItemClickListener = new OnItemClickListener() {
249
 
                public void onItemClick( AdapterView< ? > adapter_view, View view, int position, long id )
 
235
                public void onItemClick( AdapterView adapterView, View view, int position, long id )
250
236
                {
251
237
                        RowItem rowitem = _items.get( position );
252
238
 
406
392
                                _items.add( new RowItem( files[ i ].getName(), false ) );
407
393
                }
408
394
 
409
 
                // sort
410
 
                class RowItemSorter implements Comparator< RowItem > {
411
 
                        @Override
412
 
                        public int compare( RowItem lhs, RowItem rhs ) {
413
 
                                return lhs.compareTo( rhs );
414
 
                        }
415
 
                }
416
 
                Collections.sort( _items, new RowItemSorter() );
417
 
 
418
395
                // setup directory list
419
396
                ( (ListView)_dialog.findViewById( R.id.list ) ).setAdapter(
420
397
                        new RowItemAdapter( _context, R.layout.filechooser_row,
432
409
                // enable/disable ok button
433
410
                if( _mode == MODE_FILE )
434
411
                        _dialog.findViewById( R.id.ok ).setEnabled( _filename != "" );
435
 
                else
436
 
                        _dialog.findViewById( R.id.ok ).setEnabled( true );
437
412
        }
438
413
 
439
414
}