/[zanavi_public1]/navit/navit/android/src/net/technologichron/manacalc/NumberPicker.java
ZANavi

Diff of /navit/navit/android/src/net/technologichron/manacalc/NumberPicker.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 27 Revision 28
1/* 1/**
2 * 2 *
3 * Enhanced by Zoff (c) 2011 3 * Enhanced by Zoff (c) 2011 - 2012
4 * zoff@zanavi.cc 4 * zoff@zanavi.cc
5 * 5 *
6 */ 6 */
7 7
8/* 8/**
9 * Copyright (c) 2010, Jeffrey F. Cole 9 * Copyright (c) 2010, Jeffrey F. Cole
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met: 13 * modification, are permitted provided that the following conditions are met:
38 38
39package net.technologichron.manacalc; 39package net.technologichron.manacalc;
40 40
41import android.content.Context; 41import android.content.Context;
42import android.os.Handler; 42import android.os.Handler;
43import android.text.Editable;
43import android.text.InputType; 44import android.text.InputType;
45import android.text.TextWatcher;
44import android.util.AttributeSet; 46import android.util.AttributeSet;
45import android.view.Gravity; 47import android.view.Gravity;
46import android.view.KeyEvent; 48import android.view.KeyEvent;
47import android.view.MotionEvent; 49import android.view.MotionEvent;
48import android.view.View; 50import android.view.View;
200 // number 202 // number
201 valueText.setOnKeyListener(new View.OnKeyListener() 203 valueText.setOnKeyListener(new View.OnKeyListener()
202 { 204 {
203 public boolean onKey(View v, int arg1, KeyEvent event) 205 public boolean onKey(View v, int arg1, KeyEvent event)
204 { 206 {
207 //System.out.println("xx222222222222");
205 int backupValue = value; 208 int backupValue = value;
206 try 209 try
207 { 210 {
208 value = Integer.parseInt(((EditText) v).getText().toString()); 211 value = Integer.parseInt(((EditText) v).getText().toString());
209 } 212 }
210 catch (NumberFormatException nfe) 213 catch (NumberFormatException nfe)
211 { 214 {
212 value = backupValue; 215 value = backupValue;
213 } 216 }
214 return false; 217 return false;
218 }
219 });
220
221 valueText.addTextChangedListener(new TextWatcher()
222 {
223 @Override
224 public void afterTextChanged(Editable s)
225 {
226 //System.out.println("xxxxxxxx111");
227 int backupValue = value;
228 try
229 {
230 value = Integer.parseInt(valueText.getText().toString());
231 }
232 catch (NumberFormatException nfe)
233 {
234 value = backupValue;
235 }
236 }
237
238 @Override
239 public void beforeTextChanged(CharSequence s, int start, int count, int after)
240 {
241 }
242
243 @Override
244 public void onTextChanged(CharSequence s, int start, int before, int count)
245 {
215 } 246 }
216 }); 247 });
217 248
218 // Highlight the number when we get focus 249 // Highlight the number when we get focus
219 valueText.setOnFocusChangeListener(new View.OnFocusChangeListener() 250 valueText.setOnFocusChangeListener(new View.OnFocusChangeListener()

Legend:
Removed from v.27  
changed lines
  Added in v.28

   
Visit the ZANavi Wiki