|
@@ -0,0 +1,78 @@
|
|
|
+package com.xplora.xpsettings.Adapter;
|
|
|
+
|
|
|
+import android.annotation.SuppressLint;
|
|
|
+import android.content.Context;
|
|
|
+import android.graphics.Color;
|
|
|
+import android.os.Handler;
|
|
|
+import android.os.Message;
|
|
|
+import android.view.LayoutInflater;
|
|
|
+import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
+import android.widget.ArrayAdapter;
|
|
|
+import android.widget.ImageView;
|
|
|
+import android.widget.Switch;
|
|
|
+import android.widget.TextView;
|
|
|
+
|
|
|
+import com.xplora.xpsettings.Activity.TestToolsActivity;
|
|
|
+import com.xplora.xpsettings.Activity.WiFiActivity;
|
|
|
+import com.xplora.xpsettings.Model.WatchModel;
|
|
|
+import com.xplora.xpsettings.R;
|
|
|
+import com.xplora.xpsettings.Utils.ResUtils;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+public class ConnectionsAdapter extends ArrayAdapter<WatchModel> {
|
|
|
+ private final int resourceId;
|
|
|
+ private Handler mHandler = null;
|
|
|
+
|
|
|
+ public ConnectionsAdapter(Context context, int textViewResourceId, List<WatchModel> objects) {
|
|
|
+ super(context, textViewResourceId, objects);
|
|
|
+ resourceId = textViewResourceId;
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressLint("InflateParams")
|
|
|
+ @Override
|
|
|
+ public View getView(int position, View convertView, ViewGroup parent) {
|
|
|
+ View view = LayoutInflater.from(getContext()).inflate(resourceId, null);//实例化一个对象
|
|
|
+ TextView itemTitle = view.findViewById(R.id.item_title);
|
|
|
+ TextView itemDetail = view.findViewById(R.id.item_detail);
|
|
|
+ TextView itemSwitchTV = view.findViewById(R.id.item_switchTV);
|
|
|
+ ImageView itembackground = view.findViewById(R.id.item_background);
|
|
|
+ ImageView itemIcon = view.findViewById(R.id.item_icon);
|
|
|
+
|
|
|
+
|
|
|
+ WatchModel model = getItem(position); // 获取当前项的Fruit实例
|
|
|
+ if (itemTitle != null) {
|
|
|
+ itemTitle.setText(model.title);
|
|
|
+ }
|
|
|
+ if (itembackground != null) {
|
|
|
+ itembackground.setImageResource(R.drawable.settings_bg_default);
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean isOpen = model.isSwitchOn;
|
|
|
+ switch (position) {
|
|
|
+ case 0:
|
|
|
+ if (itemIcon != null) {
|
|
|
+ itemIcon.setImageResource(isOpen ? R.drawable.connections_bt_1 : R.drawable.connections_bt_0);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ if (itemIcon != null) {
|
|
|
+ itemIcon.setImageResource(isOpen ? R.drawable.connections_wifi_1 : R.drawable.connections_wifi_0);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ if (itemIcon != null)
|
|
|
+ itemIcon.setVisibility(View.GONE);
|
|
|
+ if (itemSwitchTV != null) {
|
|
|
+ itemSwitchTV.setVisibility(View.VISIBLE);
|
|
|
+ itemSwitchTV.setText(isOpen ? R.string.data_roaming_on : R.string.data_roaming_off);
|
|
|
+ itemSwitchTV.setTextColor(isOpen ? Color.GREEN : Color.RED);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return view;
|
|
|
+ }
|
|
|
+}
|