package epson.print; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import com.felipecsl.asymmetricgridview.library.widget.AsymmetricGridView; import com.felipecsl.asymmetricgridview.library.widget.AsymmetricGridViewAdapter; import java.util.List; public class IconTextArrayAdapter extends AsymmetricGridViewAdapter { private static float LANDSCAPE_FONTSIZE_RATIO = 4.2f; private static float LANDSCAPE_RATIO = 2.8f; private static float PORTRATE_FONTSIZE_RATIO = 7.5f; private static float PORTRATE_RATIO = 1.0f; private static final String TAG = "IconTextArrayAdapter"; private int height = 0; private LayoutInflater inflater; private List items; private int line = 0; private int textViewResourceId; private ViewGroup viewGroup = null; public IconTextArrayAdapter(Context context, int i, List list, AsymmetricGridView asymmetricGridView) { super(context, asymmetricGridView, list); textViewResourceId = i; items = list; inflater = (LayoutInflater) context.getSystemService(Service.LAYOUT_INFLATER_SERVICE); } public View getActualView(int i, View view, ViewGroup viewGroup2) { if (view == null) { view = inflater.inflate(textViewResourceId, (ViewGroup) null); } switch (line) { case 0: view.setBackgroundColor(view.getContext().getResources().getColor(R.color.home_line1)); break; case 1: view.setBackgroundColor(view.getContext().getResources().getColor(R.color.home_line2)); break; case 2: view.setBackgroundColor(view.getContext().getResources().getColor(R.color.home_line3)); break; case 3: view.setBackgroundColor(view.getContext().getResources().getColor(R.color.home_line4)); break; case 4: view.setBackgroundColor(view.getContext().getResources().getColor(R.color.home_line5)); break; case 5: view.setBackgroundColor(view.getContext().getResources().getColor(R.color.home_line6)); break; } switch (view.getResources().getConfiguration().orientation) { case 2: ((LinearLayout) view).setOrientation(0); View findViewById = view.findViewById(R.id.screen_image); ViewGroup.LayoutParams layoutParams = findViewById.getLayoutParams(); layoutParams.width = 0; layoutParams.height = -1; findViewById.setLayoutParams(layoutParams); findViewById.requestLayout(); View findViewById2 = view.findViewById(R.id.rl_text); ViewGroup.LayoutParams layoutParams2 = findViewById2.getLayoutParams(); layoutParams2.width = 0; layoutParams2.height = -1; findViewById2.setLayoutParams(layoutParams2); findViewById.requestLayout(); break; } IconTextArrayItem iconTextArrayItem = items.get(i); TextView textView = (TextView) view.findViewWithTag("text"); textView.setText(iconTextArrayItem.menuId); switch (view.getResources().getConfiguration().orientation) { case 1: textView.setTextSize(0, ((float) height) / PORTRATE_FONTSIZE_RATIO); break; case 2: textView.setTextSize(0, ((float) height) / LANDSCAPE_FONTSIZE_RATIO); textView.setGravity(19); break; } ((ImageView) view.findViewWithTag("icon")).setImageResource(iconTextArrayItem.imageID); return view; } public View getView(int i, View view, ViewGroup viewGroup2) { line = i; switch (viewGroup2.getResources().getConfiguration().orientation) { case 1: height = (((float) ((AsymmetricGridView) viewGroup2).getColumnWidth()) / PORTRATE_RATIO); break; case 2: height = (((float) ((AsymmetricGridView) viewGroup2).getColumnWidth()) / LANDSCAPE_RATIO); break; } View view2 = super.getView(i, view, viewGroup2); int i2 = 0; while (true) { ViewGroup viewGroup3 = (ViewGroup) view2; if (i2 >= viewGroup3.getChildCount()) { return view2; } ViewGroup viewGroup4 = (ViewGroup) viewGroup3.getChildAt(i2); ViewGroup.LayoutParams layoutParams = viewGroup4.getChildAt(0).getLayoutParams(); layoutParams.height = height; viewGroup4.getChildAt(0).setLayoutParams(layoutParams); viewGroup4.getChildAt(0).requestLayout(); i2++; } } }