X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=src%2Fcom%2Fhughes%2Fandroid%2Fdictionary%2FIsoUtils.java;h=ad8808e09407770fa23be7f85bc72791e05aad50;hb=83d497f704ad1f8ba85190255d46a3fbe0e3c353;hp=4cafedc11bee6f049a95b4f42da22a8ee94d2dc4;hpb=01332c7697b595328bbd5397e95341a0dd575493;p=Dictionary.git diff --git a/src/com/hughes/android/dictionary/IsoUtils.java b/src/com/hughes/android/dictionary/IsoUtils.java index 4cafedc..ad8808e 100644 --- a/src/com/hughes/android/dictionary/IsoUtils.java +++ b/src/com/hughes/android/dictionary/IsoUtils.java @@ -36,7 +36,7 @@ public enum IsoUtils { // Useful: // http://www.loc.gov/standards/iso639-2/php/code_list.php private final Map isoCodeToResources = new HashMap(); - private IsoUtils() { + IsoUtils() { isoCodeToResources.put("AF", new LanguageResources("Afrikaans", R.string.AF, R.drawable.flag_of_south_africa)); isoCodeToResources.put("SQ", new LanguageResources("Albanian", R.string.SQ, @@ -234,4 +234,26 @@ public enum IsoUtils { result.setLayoutParams(new LinearLayout.LayoutParams(size, size * 2 / 3)); return result; } + + public View setupButton(Button textButton, ImageButton imageButton, + final DictionaryInfo dictionaryInfo, + final IndexInfo indexInfo, int size) { + LanguageResources languageResources = isoCodeToResources.get(indexInfo.shortName); + View result; + + if (languageResources == null || languageResources.flagId <= 0) { + textButton.setText(indexInfo.shortName); + textButton.setVisibility(View.VISIBLE); + imageButton.setVisibility(View.GONE); + result = textButton; + } else { + imageButton.setImageResource(languageResources.flagId); + imageButton.setScaleType(ImageView.ScaleType.FIT_CENTER); + textButton.setVisibility(View.GONE); + imageButton.setVisibility(View.VISIBLE); + result = imageButton; + } + // Assume dimensions have been set before in Layout + return result; + } }