Back to project page android_device.
The source code is released under:
[Apache License](http://www.apache.org/licenses/): Version 2.0, January 2004 =============== ## TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION ## ### 1. Definitions. ### "License" sha...
If you think the Android project android_device listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * ================================================================================================= * Copyright (C) 2014 Martin Albedinsky [Wolf-ITechnologies] * ================================================================================================= * Licensed under the Apache License, Version 2.0 or later (further "License" only). * ------------------------------------------------------------------------------------------------- * You may use this file only in compliance with the License. More details and copy of this License * you may obtain at/*from w ww . ja va2s.co m*/ * * http://www.apache.org/licenses/LICENSE-2.0 * * You can redistribute, modify or publish any part of the code written within this file but as it * is described in the License, the software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES or CONDITIONS OF ANY KIND. * * See the License for the specific language governing permissions and limitations under the License. * ================================================================================================= */ package com.wit.android.device.examples.adapter; import android.content.Context; import android.view.View; import android.widget.RadioButton; import android.widget.TextView; import com.wit.android.device.Screen; import com.wit.android.device.examples.R; import com.wit.android.examples.libs.adapter.ExSimpleSpinnerAdapter; import com.wit.android.examples.libs.adapter.ExViewHolder; import com.wit.android.examples.libs.adapter.annotation.ExDropDownView; import com.wit.android.examples.libs.adapter.annotation.ExDropDownViewHolder; import com.wit.android.examples.libs.adapter.annotation.ExItemView; /** * <p> * Description. * </p> * * @author Martin Albedinsky */ @ExItemView(R.layout.item_spinner_orientation) @ExDropDownView(R.layout.item_spinner_dropdown_orientation) @ExDropDownViewHolder(OrientationsAdapter.DropDownHolder.class) public class OrientationsAdapter extends ExSimpleSpinnerAdapter<Screen.ScreenOrientation> { /** * Log TAG. */ // private static final String TAG = OrientationsAdapter.class.getSimpleName(); /** */ public OrientationsAdapter(Context context) { super(context, new Screen.ScreenOrientation[] { Screen.ScreenOrientation.FULL_SENSOR, Screen.ScreenOrientation.USER, Screen.ScreenOrientation.PORTRAIT, Screen.ScreenOrientation.LANDSCAPE, Screen.ScreenOrientation.REVERSE_PORTRAIT, Screen.ScreenOrientation.REVERSE_LANDSCAPE, Screen.ScreenOrientation.SENSOR, Screen.ScreenOrientation.SENSOR_PORTRAIT }); } /** */ @Override protected void onUpdateView(int position, Screen.ScreenOrientation orientation, Object viewHolder) { if (viewHolder instanceof DropDownHolder) { super.onUpdateView(position, orientation, viewHolder); } else if (viewHolder instanceof TextView) { ((TextView) viewHolder).setText(orientation.name()); } } /** * */ public static final class DropDownHolder implements ExViewHolder<Screen.ScreenOrientation, OrientationsAdapter> { TextView textView; RadioButton radioButton; /** */ @Override public void create(int position, View itemView) { this.radioButton = (RadioButton) itemView.findViewById(R.id.item_spinner_dropdown_orientation_radio_button); this.textView = (TextView) itemView.findViewById(R.id.item_spinner_dropdown_orientation_text_view); } /** */ @Override public void bind(int position, Screen.ScreenOrientation item, OrientationsAdapter adapter) { textView.setText(item.name()); radioButton.setChecked(adapter.getSelectedPosition() == position); } } }