Android Open Source - AndroidPlugin Plug List View Adapter






From Project

Back to project page AndroidPlugin.

License

The source code is released under:

MIT License

If you think the Android project AndroidPlugin listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package androidx.plmgrdemo;
/*  w  w w.  ja  va 2  s  .  com*/
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.TextUtils.TruncateAt;
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 androidx.pluginmgr.PlugInfo;

class PlugListViewAdapter extends BaseAdapter {

    private LayoutInflater inflater = null;
    private List<PlugInfo> datas;
    private Context mContext;

    public PlugListViewAdapter(Context context, Collection<PlugInfo> datas) {
        mContext = context;
        inflater = LayoutInflater.from(context);
        this.datas = new ArrayList<PlugInfo>(datas);
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return datas.get(position).getId().hashCode();
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder mViewHolder = null;
        if (convertView == null) {
            mViewHolder = new ViewHolder();
            convertView = inflater.inflate(R.layout.plug_item, null);

            mViewHolder.title = (TextView) convertView
                    .findViewById(R.id.plug_title);
            mViewHolder.icon = (ImageView) convertView
                    .findViewById(R.id.plug_icon);
            mViewHolder.description = (TextView) convertView
                    .findViewById(R.id.plug_description);
            mViewHolder.description.setSingleLine(true);
            mViewHolder.description.setTextSize(16.0f);
            mViewHolder.description.setEllipsize(TruncateAt.END);

            convertView.setTag(mViewHolder);
        } else {
            mViewHolder = (ViewHolder) convertView.getTag();
        }
        PlugInfo plug = datas.get(position);
        {
            int labelRes = plug.getPackageInfo().applicationInfo.labelRes;
            if (labelRes != 0) {
                String label = plug.getResources().getString(labelRes);
                mViewHolder.title.setText(label);
            } else {
                CharSequence label = plug.getPackageInfo().applicationInfo
                        .loadLabel(mContext.getPackageManager());
                if (label != null) {
                    mViewHolder.title.setText(label);
                }
            }
        }
        Drawable drawable = plug.getResources().getDrawable(
                plug.getPackageInfo().applicationInfo.icon);
        mViewHolder.icon.setImageDrawable(drawable);
        String descText;
        int descId = plug.getPackageInfo().applicationInfo.descriptionRes;
        if (descId == 0) {
            descText = plug.getId();
        } else {
            descText = plug.getResources().getString(descId);
        }
        mViewHolder.description.setText(descText);
        return convertView;
    }

    static class ViewHolder {
        public TextView title;
        public ImageView icon;
        public TextView description;
    }
}




Java Source Code List

android.widget.ViewStub.java
androidx.plmgrdemo.MainActivity.java
androidx.plmgrdemo.PlugListViewAdapter.java
androidx.pluginmgr.ActivityClassGenerator.java
androidx.pluginmgr.ActivityOverider.java
androidx.pluginmgr.FileUtil.java
androidx.pluginmgr.FrameworkClassLoader.java
androidx.pluginmgr.LayoutInflaterWrapper.java
androidx.pluginmgr.PlugInfo.java
androidx.pluginmgr.PluginActivityLifeCycleCallback.java
androidx.pluginmgr.PluginClassLoader.java
androidx.pluginmgr.PluginContextWrapper.java
androidx.pluginmgr.PluginManager.java
androidx.pluginmgr.PluginManifestUtil.java
androidx.pluginmgr.ReflectionUtils.java
androidx.pluginmgr.XmlManifestReader.java
com.limemobile.app.demo.pluginclienta.ClientABindService.java
com.limemobile.app.demo.pluginclienta.ClientAStartedService.java
com.limemobile.app.demo.pluginclienta.MainActivity.java
com.limemobile.app.demo.pluginclienta.TestButton.java
com.limemobile.app.demo.pluginclienta.TestFragmentActivity.java
com.limemobile.app.demo.pluginclienta.TestFragment.java
com.limemobile.app.demo.pluginclientb.ClientBStartedService.java
com.limemobile.app.demo.pluginclientb.MainActivity.java
com.limemobile.app.demo.pluginhost.HostBindService.java
com.limemobile.app.demo.pluginhost.HostStartedService.java
com.limemobile.app.demo.pluginhost.MainActivity.java
com.limemobile.app.demo.pluginhost.MyApplication.java
com.limemobile.app.demo.pluginhost.TestHostClass.java
com.limemobile.app.plugin.IPluginActivity.java
com.limemobile.app.plugin.IPluginContentProvider.java
com.limemobile.app.plugin.IPluginService.java
com.limemobile.app.plugin.PluginClientActivity.java
com.limemobile.app.plugin.PluginClientFragmentActivity.java
com.limemobile.app.plugin.PluginClientService.java
com.limemobile.app.plugin.PluginHostApplication.java
com.limemobile.app.plugin.PluginHostContentProvider.java
com.limemobile.app.plugin.PluginHostDelegateActivity.java
com.limemobile.app.plugin.PluginHostDelegateContentProvider.java
com.limemobile.app.plugin.PluginHostDelegateFragmentActivity.java
com.limemobile.app.plugin.PluginHostDelegateService.java
com.limemobile.app.plugin.internal.IPluginActivityDelegate.java
com.limemobile.app.plugin.internal.IPluginContentProviderDelegate.java
com.limemobile.app.plugin.internal.IPluginServiceDelegate.java
com.limemobile.app.plugin.internal.PluginClientDexClassLoader.java
com.limemobile.app.plugin.internal.PluginClientInfo.java
com.limemobile.app.plugin.internal.PluginClientManager.java
com.limemobile.app.plugin.internal.PluginDelegateActivityImpl.java
com.limemobile.app.plugin.internal.PluginDelegateContentProviderImpl.java
com.limemobile.app.plugin.internal.PluginDelegateServiceImpl.java
com.limemobile.app.plugin.internal.ReflectFieldAccessor.java