From 308672ceeab346b1b866c043166770ebd1a9ccf3 Mon Sep 17 00:00:00 2001 From: sergio-incaser Date: Tue, 27 Jan 2015 09:40:24 +0100 Subject: [PATCH] [DEL] Eliminar dependencias projecto Tools --- .idea/gradle.xml | 1 - .idea/misc.xml | 2 +- .idea/modules.xml | 2 - app/app.iml | 7 +- app/build.gradle | 4 - .../incaser/apps/stockcontrol/DbAdapter.java | 8 +- .../es/incaser/apps/stockcontrol/Tools.java | 131 ++++++++++++++++++ ...xpedicionXX.xml => item_expedicionxxy.xml} | 7 +- app/src/main/res/values/styles.xml | 1 - settings.gradle | 2 +- tools/tools.iml | 92 ------------ 11 files changed, 141 insertions(+), 116 deletions(-) create mode 100644 app/src/main/java/es/incaser/apps/stockcontrol/Tools.java rename app/src/main/res/layout/{item_expedicionXX.xml => item_expedicionxxy.xml} (99%) delete mode 100644 tools/tools.iml diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 1717c95..fe865d3 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -10,7 +10,6 @@ diff --git a/.idea/misc.xml b/.idea/misc.xml index 9076de5..59436c9 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,7 +3,7 @@ - + diff --git a/.idea/modules.xml b/.idea/modules.xml index 78e2444..e588f0d 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -4,8 +4,6 @@ - - diff --git a/app/app.iml b/app/app.iml index 6dcced8..2a72091 100644 --- a/app/app.iml +++ b/app/app.iml @@ -82,11 +82,10 @@ - + - - - + + diff --git a/app/build.gradle b/app/build.gradle index d6064e4..88c393d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -29,8 +29,4 @@ dependencies { compile fileTree(include: ['*.jar', '*.aar'], dir: 'libs') compile 'com.android.support:appcompat-v7:21.0.0' compile 'com.android.support:support-v4:21.0.0' - //compile files('libs/jtds-1.2.7.jar') - //compile 'es.incaser.apps.tools:tools:1.0@aar' - //compile 'be.hcpl.android.appframework:appframework:0.1.0@aar' - compile project(':tools') } diff --git a/app/src/main/java/es/incaser/apps/stockcontrol/DbAdapter.java b/app/src/main/java/es/incaser/apps/stockcontrol/DbAdapter.java index 5cf486c..c143c2a 100644 --- a/app/src/main/java/es/incaser/apps/stockcontrol/DbAdapter.java +++ b/app/src/main/java/es/incaser/apps/stockcontrol/DbAdapter.java @@ -19,10 +19,6 @@ import java.util.Map; import java.util.UUID; -import es.incaser.apps.tools.Tools; - -import static es.incaser.apps.tools.Tools.getToday; - public class DbAdapter extends SQLiteOpenHelper { private static final String DATABASE_NAME = "StockControl"; @@ -364,13 +360,13 @@ public int updateMovimientoStock(String numeroSerie) { public int updateMovimientoStock(String movPosicion) { ContentValues cv = new ContentValues(); - cv.put("FechaRegistro", getToday("yyyy-MM-dd HH:mm:ss.S")); + cv.put("FechaRegistro", Tools.getToday("yyyy-MM-dd HH:mm:ss.S")); return db.update("MovimientoStock", cv, "MovPosicion = ?", new String[]{movPosicion}); } public int updateMovimientoStock(String tipoMov, String serie, String documento, String campo, String valor) { ContentValues cv = new ContentValues(); - cv.put("FechaRegistro", getToday("yyyy-MM-dd HH:mm:ss.S")); + cv.put("FechaRegistro", Tools.getToday("yyyy-MM-dd HH:mm:ss.S")); cv.put(campo, valor); return db.update("MovimientoStock", cv, "TipoMovimiento=? AND Serie=? AND Documento=?", new String[]{tipoMov, serie, documento}); } diff --git a/app/src/main/java/es/incaser/apps/stockcontrol/Tools.java b/app/src/main/java/es/incaser/apps/stockcontrol/Tools.java new file mode 100644 index 0000000..a05a995 --- /dev/null +++ b/app/src/main/java/es/incaser/apps/stockcontrol/Tools.java @@ -0,0 +1,131 @@ +package es.incaser.apps.stockcontrol; + +import android.widget.EditText; + +import java.text.DecimalFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; + +/** + * Created by sergio on 2/10/14. + */ +public class Tools { + public static String UUID_EMPTY = "00000000-0000-0000-0000-000000000000"; + + public static float getNumber(String text) { + if (text == null) { + return 0; + } else if (text.length() == 0) { + return 0; + } else if (text.matches(".*\\\\D+.*")) { + return 0; + } else { + //TODO Controlar separador de miles + return Float.valueOf(text.replace(",", ".")); + } + } + + public static float getNumber(EditText txt) { + return getNumber(txt.getText().toString()); + } + + public static String importeStr(Float importe) { + DecimalFormat nf = new DecimalFormat(); + nf.applyPattern("#0.00"); + return nf.format(importe); + } + + public static String importeStr(String importe) { + return importeStr(getNumber(importe)); + } + + + public static int getInt(String text) { + return Math.round(getNumber(text)); + } + + public static int getInt(EditText txtView) { + return getInt(txtView.getText().toString()); + } + + public static String enteroStr(Integer x) { + return x.toString(); + } + + public static String importeStr(EditText txt) { + return importeStr(txt.getText().toString()); + } + + public static String getToday() { + return getToday("yyyy-MM-dd 00:00:00.0"); + } + + public static String getToday(String format) { + Date date = Calendar.getInstance().getTime(); + SimpleDateFormat sdf = new SimpleDateFormat(format); + return sdf.format(date); + } + + public static String millis2String(Long miliseconds) { + Calendar date = Calendar.getInstance(); + date.setTimeInMillis(miliseconds); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); + return sdf.format(date.getTime()); + } + +// public static String getActualHour(){ +// Date date = Calendar.getInstance().getTime(); +// SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss"); +// return sdf.format(date); +// } + + public static double getActualHour() { + Date date = Calendar.getInstance().getTime(); + return getHourFractionDay(date.getTime()); + } + + public static double getHourFractionDay(long timelong) { + double milisecondsDay = 86400000.00; + return (timelong % (milisecondsDay)) / milisecondsDay; + } + + public static String getTimeStamp() { + Date date = Calendar.getInstance().getTime(); + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.S"); + return sdf.format(date); + } + + public static Date str2date(String myTimestamp, String strFormat) { + SimpleDateFormat formato = new SimpleDateFormat(strFormat); + Date convertedDate = null; + try { + convertedDate = formato.parse(myTimestamp); + } catch (ParseException e) { + e.printStackTrace(); + } + return convertedDate; + } + + public static Date str2date(String myTimestamp) { + return str2date(myTimestamp, "yyyy-MM-dd HH:mm:ss.S"); + } + + public static String date2str(Date date, String strFormat) { + SimpleDateFormat formato = new SimpleDateFormat(strFormat); + return formato.format(date); + } + + public static String date2str(Date date) { + return date2str(date, "dd-MM-yyyy 00:00:00.0"); + } + + public static String dateStr2str(String date) { + return date2str(str2date(date), "dd/MM/yyyy"); + } + + public static String date2Sql(String date){ + return "CONVERT(DATETIME,'" + date + "', 102)"; + } +} diff --git a/app/src/main/res/layout/item_expedicionXX.xml b/app/src/main/res/layout/item_expedicionxxy.xml similarity index 99% rename from app/src/main/res/layout/item_expedicionXX.xml rename to app/src/main/res/layout/item_expedicionxxy.xml index 64c3736..2556ffe 100644 --- a/app/src/main/res/layout/item_expedicionXX.xml +++ b/app/src/main/res/layout/item_expedicionxxy.xml @@ -199,10 +199,9 @@ - - - - \ No newline at end of file + + + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index ad1702f..e7ee63e 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -125,6 +125,5 @@ diff --git a/settings.gradle b/settings.gradle index dfb8c63..e7b4def 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':app',':tools' +include ':app' diff --git a/tools/tools.iml b/tools/tools.iml deleted file mode 100644 index a0f9ac4..0000000 --- a/tools/tools.iml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -