Jak mohu zjednodušit celý tento kód? Vytvářím vyhledávání menu a chci zkontrolovat hodnoty, když uživatel opustí 'Zobrazení Textu' a zobrazit výstup okamžitě jako 'Recyklovat Viewer' níže.
Jeden způsob je udělat to pomocí velmi velké množství investičních fondů. Navrhujete další metodou?
Používám Roon Knihovna pro mé databáze aplikace.
Chtěl jsem použít tento kód pro to, ale viděl jsem, že počet investičních fondů je velmi vysoká.
Přítel navrhl použití v Případě databáze, ale nevím, jak napsat svůj kód!
public void searchHelper() { String sOperationValue = spinnerOperation.getText().toString(); String sTraderValue = spinnerTraderName.getText().toString(); String sSearchByValue = spinnerSearchBy.getText().toString(); long startValue = Long.parseLong(etStartDate.getText().toString()); long endValue = Long.parseLong(etEndDate.getText().toString()); // * * * * * if (!sOperationValue.isEmpty() && !sTraderValue.isEmpty() && !sSearchByValue.isEmpty() && startValue >= 14000000 && endValue <= 15000000) { } // * - * * * if (!sOperationValue.isEmpty() && sTraderValue.isEmpty() && !sSearchByValue.isEmpty() && startValue >= 14000000 && endValue <= 15000000) { } // * - - - - if (!sOperationValue.isEmpty() && sTraderValue.isEmpty() && sSearchByValue.isEmpty() && startValue <= 0 && endValue <= 0) { } // - * * * * if (sOperationValue.isEmpty() && !sTraderValue.isEmpty() && !sSearchByValue.isEmpty() && startValue >= 14000000 && endValue <= 15000000) { } // Here 'Search By' specifies whether the search should be based on the date of registration or on the date of the transaction. // Therefore, when Search By is empty, then the start date and end date values are also empty. // - * - - - if (sOperationValue.isEmpty() && !sTraderValue.isEmpty() && sSearchByValue.isEmpty() && startValue <= 0 && endValue <= 0) { } // - - * * * if (sOperationValue.isEmpty() && sTraderValue.isEmpty() && !sSearchByValue.isEmpty() && startValue >= 14000000 && endValue <= 15000000) { } // - - - - - if (sOperationValue.isEmpty() && sTraderValue.isEmpty() && sSearchByValue.isEmpty() && startValue <= 0 && endValue <= 0) { } }
Také jsem chtěl napsat dotaz pomocí Případu, ale nepodařilo se. To byl ten kód, co jsem napsal
@Query("SELECT * FROM tbl_transaction" + " WHERE CASE WHEN operation='null'" + " THEN CASE WHEN traderName='null'" + " THEN CASE WHEN transactionType ='null'" + " THEN CASE WHEN startDate=14000000" + " THEN CASE WHEN endDate=15000000" ) List<Transaction> getSearchValues(String operation, String traderName, String transactionType, long startDate, long endDate);
I když jsem byl hodně hledat správné řešení, bohužel jsem se nemohl najít.
Děkuji vám předem za vaši pomoc.