24
24
private final static int DIALOG_CONTINUEORABORT = 1;
25
25
private final static int DIALOG_MERGEPROMPT = 2;
27
public final static int MESSAGE_FINISHED_ALLDONE = 0;
28
public final static int MESSAGE_FINISHED = 1;
29
public final static int MESSAGE_FINISHED_GOBACK = 2;
30
public final static int MESSAGE_ERROR = 3;
31
public final static int MESSAGE_CONTINUEORABORT = 4;
32
public final static int MESSAGE_SETPROGRESSMESSAGE = 5;
33
public final static int MESSAGE_SETMAXPROGRESS = 6;
34
public final static int MESSAGE_SETTMPPROGRESS = 7;
35
public final static int MESSAGE_SETPROGRESS = 8;
36
public final static int MESSAGE_MERGEPROMPT = 9;
37
public final static int MESSAGE_CONTACTOVERWRITTEN = 10;
38
public final static int MESSAGE_CONTACTCREATED = 11;
39
public final static int MESSAGE_CONTACTMERGED = 12;
40
public final static int MESSAGE_CONTACTSKIPPED = 13;
27
42
private boolean _startedProgress;
28
43
private int _maxProgress;
29
44
private int _tmpProgress;
47
62
public void handleMessage( Message msg ) {
50
case Importer.MESSAGE_FINISHED:
65
case MESSAGE_FINISHED_ALLDONE:
66
( (TextView)findViewById( R.id.doit_alldone ) ).
67
setVisibility( View.VISIBLE );
69
case MESSAGE_FINISHED:
51
70
( (LinearLayout)findViewById( R.id.doit_closedisplay ) ).
52
71
setVisibility( View.VISIBLE );
54
case Importer.MESSAGE_FINISHED_BACK:
73
case MESSAGE_FINISHED_GOBACK:
55
74
( (Button)findViewById( R.id.back ) ).setEnabled( true );
57
case Importer.MESSAGE_ERROR:
58
77
Doit.this._dialogMessage = (String)msg.obj;
59
78
showDialog( DIALOG_ERROR );
61
case Importer.MESSAGE_CONTINUEORABORT:
80
case MESSAGE_CONTINUEORABORT:
62
81
Doit.this._dialogMessage = (String)msg.obj;
63
82
showDialog( DIALOG_CONTINUEORABORT );
65
case Importer.MESSAGE_SETPROGRESSMESSAGE:
84
case MESSAGE_SETPROGRESSMESSAGE:
66
85
( (TextView)findViewById( R.id.doit_percentage ) ).
67
86
setText( (String)msg.obj );
69
case Importer.MESSAGE_SETMAXPROGRESS:
88
case MESSAGE_SETMAXPROGRESS:
70
89
if( _maxProgress > 0 ) {
71
90
if( _tmpProgress == _maxProgress )
72
91
_tmpProgress = (Integer)msg.obj;
76
95
_maxProgress = (Integer)msg.obj;
79
case Importer.MESSAGE_SETTMPPROGRESS:
98
case MESSAGE_SETTMPPROGRESS:
80
99
_tmpProgress = (Integer)msg.obj;
83
case Importer.MESSAGE_SETPROGRESS:
102
case MESSAGE_SETPROGRESS:
84
103
_startedProgress = true;
85
104
_progress = (Integer)msg.obj;
88
case Importer.MESSAGE_MERGEPROMPT:
107
case MESSAGE_MERGEPROMPT:
89
108
_dialogMessage = (String)msg.obj;
90
109
showDialog( DIALOG_MERGEPROMPT );
92
case Importer.MESSAGE_CONTACTOVERWRITTEN:
111
case MESSAGE_CONTACTOVERWRITTEN:
93
112
_countOverwrites++;
96
case Importer.MESSAGE_CONTACTCREATED:
115
case MESSAGE_CONTACTCREATED:
100
case Importer.MESSAGE_CONTACTMERGED:
119
case MESSAGE_CONTACTMERGED:
104
case Importer.MESSAGE_CONTACTSKIPPED:
123
case MESSAGE_CONTACTSKIPPED:
339
358
if( _importer != null )
341
_importer.setAbort();
360
// try and flag worker thread - did we need to?
361
if( _importer.setAbort() )
363
// wait for worker thread to end
369
catch( InterruptedException e ) {}
347
catch( InterruptedException e ) {}
373
Toast.makeText( this, R.string.doit_importaborted,
374
Toast.LENGTH_LONG ).show();