// Path: app/src/main/java/wseemann/media/romote/utils/PreferenceUtils.java
// public class PreferenceUtils {
// 
//     private PreferenceUtils() {
// 
//     }
// 
//     public static void setConnectedDevice(Context context, String serialNumber) {
//         SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
// 
//         SharedPreferences.Editor editor = prefs.edit();
//         editor.putString("serial_number", serialNumber);
//         editor.commit();
//     }
// 
//     public static Device getConnectedDevice(Context context) throws Exception {
//         Device device;
// 
//         SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
//         String serialNumber = prefs.getString("serial_number", null);
// 
//         device = DBUtils.getDevice(context, serialNumber);
// 
//         if (device == null) {
//             throw new Exception("Device not connected");
//         }
// 
//         return device;
//     }
// 
//     public static boolean shouldProvideHapticFeedback(Context context) {
//         SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
//         return prefs.getBoolean("haptic_feedback_preference", false);
//     }
// }


import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
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.TextView;
import androidx.core.graphics.drawable.RoundedBitmapDrawable;
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory;
import java.util.List;
import wseemann.media.romote.R;
import wseemann.media.romote.model.Device;
import wseemann.media.romote.utils.PreferenceUtils;
        ImageView mIcon;
        TextView mText1;
        TextView mText2;
        TextView mText3;
        ImageView mImageButton;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        LayoutInflater mInflater = (LayoutInflater)
                mContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.device, null);
            holder = new ViewHolder();
            holder.mIcon = (ImageView) convertView.findViewById(android.R.id.icon);
            holder.mText1 = (TextView) convertView.findViewById(android.R.id.text1);
            holder.mText2 = (TextView) convertView.findViewById(android.R.id.text2);
            holder.mText3 = (TextView) convertView.findViewById(R.id.text3);
            holder.mImageButton = (ImageView) convertView.findViewById(R.id.overflow_button);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        final Device device = (Device) getItem(position);

        Device connectedDevice = null;

        try {
// Path: app/src/main/java/wseemann/media/romote/utils/PreferenceUtils.java
// public class PreferenceUtils {
// 
//     private PreferenceUtils() {
// 
//     }
// 
//     public static void setConnectedDevice(Context context, String serialNumber) {
//         SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
// 
//         SharedPreferences.Editor editor = prefs.edit();
//         editor.putString("serial_number", serialNumber);
//         editor.commit();
//     }
// 
//     public static Device getConnectedDevice(Context context) throws Exception {
//         Device device;
// 
//         SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
//         String serialNumber = prefs.getString("serial_number", null);
// 
//         device = DBUtils.getDevice(context, serialNumber);
// 
//         if (device == null) {
//             throw new Exception("Device not connected");
//         }
// 
//         return device;
//     }
// 
//     public static boolean shouldProvideHapticFeedback(Context context) {
//         SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
//         return prefs.getBoolean("haptic_feedback_preference", false);
//     }
// }


// Path: app/src/main/java/wseemann/media/romote/adapter/DeviceAdapter.java
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
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.TextView;
import androidx.core.graphics.drawable.RoundedBitmapDrawable;
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory;
import java.util.List;
import wseemann.media.romote.R;
import wseemann.media.romote.model.Device;
import wseemann.media.romote.utils.PreferenceUtils;

        ImageView mIcon;
        TextView mText1;
        TextView mText2;
        TextView mText3;
        ImageView mImageButton;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        LayoutInflater mInflater = (LayoutInflater)
                mContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.device, null);
            holder = new ViewHolder();
            holder.mIcon = (ImageView) convertView.findViewById(android.R.id.icon);
            holder.mText1 = (TextView) convertView.findViewById(android.R.id.text1);
            holder.mText2 = (TextView) convertView.findViewById(android.R.id.text2);
            holder.mText3 = (TextView) convertView.findViewById(R.id.text3);
            holder.mImageButton = (ImageView) convertView.findViewById(R.id.overflow_button);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        final Device device = (Device) getItem(position);

        Device connectedDevice = null;

        try {
            connectedDevice = PreferenceUtils.getConnectedDevice(mContext);