X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=src%2Fcom%2Fhughes%2Fandroid%2Fdictionary%2FIsoUtils.java;h=9b381fbb456384ec28aacc3d891487ead984cd88;hb=410c02edf6fc556e906428da40ea13f3b0f30a81;hp=4cafedc11bee6f049a95b4f42da22a8ee94d2dc4;hpb=be6ef0a43f51df4ea0d0f1547e06a17ea0e90e2e;p=Dictionary.git diff --git a/src/com/hughes/android/dictionary/IsoUtils.java b/src/com/hughes/android/dictionary/IsoUtils.java index 4cafedc..9b381fb 100644 --- a/src/com/hughes/android/dictionary/IsoUtils.java +++ b/src/com/hughes/android/dictionary/IsoUtils.java @@ -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; + } }