2015-03-25 22:23:45 +01:00
|
|
|
package nodomain.freeyourgadget.gadgetbridge.adapter;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.widget.ArrayAdapter;
|
2015-03-31 23:34:19 +02:00
|
|
|
import android.widget.ImageView;
|
2015-03-25 22:23:45 +01:00
|
|
|
import android.widget.TextView;
|
|
|
|
|
2015-05-01 01:49:43 +02:00
|
|
|
import java.util.List;
|
|
|
|
|
2015-08-03 23:09:49 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp;
|
2015-05-01 01:49:43 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
|
|
|
|
2015-03-25 22:23:45 +01:00
|
|
|
public class GBDeviceAppAdapter extends ArrayAdapter<GBDeviceApp> {
|
|
|
|
|
|
|
|
private final Context context;
|
|
|
|
|
|
|
|
public GBDeviceAppAdapter(Context context, List<GBDeviceApp> appList) {
|
|
|
|
super(context, 0, appList);
|
|
|
|
|
|
|
|
this.context = context;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public View getView(int position, View view, ViewGroup parent) {
|
|
|
|
GBDeviceApp deviceApp = getItem(position);
|
|
|
|
|
|
|
|
if (view == null) {
|
|
|
|
LayoutInflater inflater = (LayoutInflater) context
|
|
|
|
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
|
|
2015-06-07 22:02:40 +02:00
|
|
|
view = inflater.inflate(R.layout.device_candidate_item, parent, false);
|
2015-03-25 22:23:45 +01:00
|
|
|
}
|
2015-06-07 22:02:40 +02:00
|
|
|
TextView deviceAppVersionAuthorLabel = (TextView) view.findViewById(R.id.device_candidate_address);
|
|
|
|
TextView deviceAppNameLabel = (TextView) view.findViewById(R.id.device_candidate_name);
|
|
|
|
ImageView deviceImageView = (ImageView) view.findViewById(R.id.device_candidate_image);
|
2015-03-31 23:34:19 +02:00
|
|
|
|
2015-06-07 22:02:40 +02:00
|
|
|
deviceAppVersionAuthorLabel.setText(getContext().getString(R.string.appversion_by_creator, deviceApp.getVersion(), deviceApp.getCreator()));
|
|
|
|
deviceAppNameLabel.setText(deviceApp.getName());
|
2015-03-31 23:34:19 +02:00
|
|
|
switch (deviceApp.getType()) {
|
2015-04-10 22:26:52 +02:00
|
|
|
case APP_ACTIVITYTRACKER:
|
|
|
|
deviceImageView.setImageResource(R.drawable.ic_activitytracker);
|
|
|
|
break;
|
2015-03-31 23:34:19 +02:00
|
|
|
case WATCHFACE:
|
|
|
|
deviceImageView.setImageResource(R.drawable.ic_watchface);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
deviceImageView.setImageResource(R.drawable.ic_device_pebble);
|
|
|
|
}
|
2015-03-25 22:23:45 +01:00
|
|
|
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
}
|