X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Futils%2FGlobals.java;h=e20e75b9df126b5d23674cc5eb8125d69e03678e;hp=b7fffadf4b0c150153dbaff3df711d707ae22923;hb=4917463f434105756e9cc984eedee64a8f276b2a;hpb=14873dbc3aa249dc5af735c8906be1a19b5f7dda diff --git a/app/src/main/java/net/ktnx/mobileledger/utils/Globals.java b/app/src/main/java/net/ktnx/mobileledger/utils/Globals.java index b7fffadf..e20e75b9 100644 --- a/app/src/main/java/net/ktnx/mobileledger/utils/Globals.java +++ b/app/src/main/java/net/ktnx/mobileledger/utils/Globals.java @@ -1,5 +1,5 @@ /* - * Copyright © 2018 Damyan Ivanov. + * Copyright © 2019 Damyan Ivanov. * This file is part of Mobile-Ledger. * Mobile-Ledger is free software: you can distribute it and/or modify it * under the term of the GNU General Public License as published by @@ -17,14 +17,45 @@ package net.ktnx.mobileledger.utils; +import android.app.Activity; +import android.content.Context; import android.support.annotation.ColorInt; +import android.view.View; +import android.view.inputmethod.InputMethodManager; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; public final class Globals { @ColorInt - public static int table_row_even_bg; + public static int tableRowEvenBG; @ColorInt - public static int table_row_odd_bg; + public static int tableRowOddBG; @ColorInt public static int primaryDark, defaultTextColor; - + public static String[] monthNames; + private static SimpleDateFormat ledgerDateFormatter = + new SimpleDateFormat("yyyy/MM/dd", Locale.US); + public static void hideSoftKeyboard(Activity act) { + // hide the keyboard + View v = act.getCurrentFocus(); + if (v != null) { + InputMethodManager imm = + (InputMethodManager) act.getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(v.getWindowToken(), 0); + } + } + public static Date parseLedgerDate(String dateString) { + try { + return ledgerDateFormatter.parse(dateString); + } + catch (ParseException e) { + throw new RuntimeException(String.format("Error parsing date '%s'", dateString), e); + } + } + public static String formatLedgerDate(Date date) { + return ledgerDateFormatter.format(date); + } } \ No newline at end of file