PCAPdroid/app/src/main/java/com/emanuelef/remote_capture/AppAdapter.java
2019-09-08 22:09:03 +02:00

84 lines
2.7 KiB
Java

/*
This file is part of RemoteCapture.
RemoteCapture is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
RemoteCapture is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with RemoteCapture. If not, see <http://www.gnu.org/licenses/>.
Copyright 2019 by Emanuele Faranda
*/
package com.emanuelef.remote_capture;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.List;
public class AppAdapter extends BaseAdapter {
private LayoutInflater layoutInflater;
private List<AppDescriptor> listStorage;
AppAdapter(Context context, List<AppDescriptor> customizedListView) {
layoutInflater =(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
listStorage = customizedListView;
}
@Override
public int getCount() {
return listStorage.size();
}
@Override
public Object getItem(int position) {
return listStorage.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder listViewHolder;
if(convertView == null){
listViewHolder = new ViewHolder();
convertView = layoutInflater.inflate(R.layout.installed_app_list, parent, false);
listViewHolder.textInListView = convertView.findViewById(R.id.list_app_name);
listViewHolder.imageInListView = convertView.findViewById(R.id.app_icon);
listViewHolder.packageInListView= convertView.findViewById(R.id.app_package);
convertView.setTag(listViewHolder);
}else{
listViewHolder = (ViewHolder)convertView.getTag();
}
listViewHolder.textInListView.setText(listStorage.get(position).getName());
listViewHolder.imageInListView.setImageDrawable(listStorage.get(position).getIcon());
listViewHolder.packageInListView.setText(listStorage.get(position).getPackages());
return convertView;
}
class ViewHolder{
TextView textInListView;
ImageView imageInListView;
TextView packageInListView;
}
}