Android Open Source - Rhybudd Zenoss Device Adaptor






From Project

Back to project page Rhybudd.

License

The source code is released under:

GNU General Public License

If you think the Android project Rhybudd 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

/*
 * Copyright (C) 2013 - Gareth Llewellyn
 *//w ww.j av  a2  s . c  o  m
 * This file is part of Rhybudd - http://blog.NetworksAreMadeOfString.co.uk/Rhybudd/
 *
 * This program 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.
 *
 * This program 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
 * this program. If not, see <http://www.gnu.org/licenses/>
 */
package net.networksaremadeofstring.rhybudd;

import java.util.List;
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;

public class ZenossDeviceAdaptor extends BaseAdapter
{
  private Context context;
    private List<ZenossDevice> listZenossDevices;
    public static final int EVENTPOSITIONINLIST = 0;
    
    public ZenossDeviceAdaptor(Context context, List<ZenossDevice> _listZenossDevices) 
    {
        this.context = context;
        this.listZenossDevices = _listZenossDevices;
    }
    
  @Override
  public int getCount() 
  {
        if(null != listZenossDevices)
        {
        return listZenossDevices.size();
        }
        else
        {
            return 0;
        }
  }

  @Override
  public Object getItem(int position) 
  {
        if(null != listZenossDevices)
        {
        return listZenossDevices.get(position);
        }
        else
        {
            return null;
        }
  }

  @Override
  public long getItemId(int position)
    {
    return position;
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent) 
  {
        //if(null == listZenossDevices)
        //    return null;
        if(null == listZenossDevices || listZenossDevices.size() < position)
            return null;

    ZenossDevice Device = listZenossDevices.get(position);
        if (convertView == null) 
        {
            LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.zenoss_device_listitem, null);
        }
        TextView DeviceNameTextView = (TextView) convertView.findViewById(R.id.DeviceName);
        DeviceNameTextView.setText(Device.getname());
        
        TextView CriticalTextView = (TextView) convertView.findViewById(R.id.CriticalCount);
        CriticalTextView.setText(Device.getevents().get("critical").toString());
        
        TextView ErrorTextView = (TextView) convertView.findViewById(R.id.ErrorCount);
        ErrorTextView.setText(Device.getevents().get("error").toString());
        
        TextView WarningTextView = (TextView) convertView.findViewById(R.id.WarningCount);
        WarningTextView.setText(Device.getevents().get("warning").toString());

        if (convertView.findViewById(R.id.prodStateTextView) != null)
        {
            ((TextView) convertView.findViewById(R.id.prodStateTextView)).setText(Device.getproductionStateAsString());

            String IPAddress = ZenossAPI.ntoa(Device.getipAddress());
            if(null != IPAddress)
            {
                ((TextView) convertView.findViewById(R.id.IPAddressTextView)).setText(IPAddress);
            }
            else
            {
                ((TextView) convertView.findViewById(R.id.IPAddressTextView)).setText("");
            }
        }

        try
        {
            if(null != Device.getos())
            {
                //Log.e("Adapter", Device.getos());
                if(Device.getos().contains("indows"))
                {
                    ((ImageView) convertView.findViewById(R.id.serverOS)).setImageResource(R.drawable.ic_windows_icon);
                }
                else if(Device.getos().contains("inux") || Device.getos().contains("redhat") || Device.getos().contains("buntu"))
                {
                    ((ImageView) convertView.findViewById(R.id.serverOS)).setImageResource(R.drawable.ic_linux_icon);
                }
                else if(Device.getos().contains("cisco") || Device.getos().contains("IOS"))
                {
                    ((ImageView) convertView.findViewById(R.id.serverOS)).setImageResource(R.drawable.ic_cisco);
                }
                else if(Device.getos().contains("arista") || Device.getos().contains("EOS"))
                {
                    ((ImageView) convertView.findViewById(R.id.serverOS)).setImageResource(R.drawable.ic_arista_icon);
                }
                else
                {
                    ((ImageView) convertView.findViewById(R.id.serverOS)).setImageResource(R.drawable.ic_default_icon);
                }
            }
            else
            {
                ((ImageView) convertView.findViewById(R.id.serverOS)).setImageResource(R.drawable.ic_default_icon);
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }

        convertView.setTag(Device.getuid());
        
        return convertView;
  }
}




Java Source Code List

net.networksaremadeofstring.rhybudd.AddDeviceActivity.java
net.networksaremadeofstring.rhybudd.AddDeviceFragment.java
net.networksaremadeofstring.rhybudd.AuthenticatorService.java
net.networksaremadeofstring.rhybudd.Authenticator.java
net.networksaremadeofstring.rhybudd.CoreSettingsFragment.java
net.networksaremadeofstring.rhybudd.DeviceListWelcomeFragment.java
net.networksaremadeofstring.rhybudd.DeviceList.java
net.networksaremadeofstring.rhybudd.DiagnosticActivity.java
net.networksaremadeofstring.rhybudd.EventsListWelcomeFragment.java
net.networksaremadeofstring.rhybudd.FirstRunSettings.java
net.networksaremadeofstring.rhybudd.GCMIntentService.java
net.networksaremadeofstring.rhybudd.ManageDatabase.java
net.networksaremadeofstring.rhybudd.ManageUpdate.java
net.networksaremadeofstring.rhybudd.MassAcknowledgeReceiver.java
net.networksaremadeofstring.rhybudd.Notifications.java
net.networksaremadeofstring.rhybudd.PushConfigActivity.java
net.networksaremadeofstring.rhybudd.PushSettingsFragment.java
net.networksaremadeofstring.rhybudd.RhybuddBackupAgent.java
net.networksaremadeofstring.rhybudd.RhybuddDataSource.java
net.networksaremadeofstring.rhybudd.RhybuddDock.java
net.networksaremadeofstring.rhybudd.RhybuddDream.java
net.networksaremadeofstring.rhybudd.RhybuddHandlers.java
net.networksaremadeofstring.rhybudd.RhybuddHome.java
net.networksaremadeofstring.rhybudd.RhybuddOpenHelper.java
net.networksaremadeofstring.rhybudd.Search.java
net.networksaremadeofstring.rhybudd.SettingsFragment.java
net.networksaremadeofstring.rhybudd.StubProvider.java
net.networksaremadeofstring.rhybudd.SwipeDismissListViewTouchListener.java
net.networksaremadeofstring.rhybudd.SwipeDismissTouchListener.java
net.networksaremadeofstring.rhybudd.SyncAdapter.java
net.networksaremadeofstring.rhybudd.SyncService.java
net.networksaremadeofstring.rhybudd.TrustAllManager.java
net.networksaremadeofstring.rhybudd.TrustAllSSLSocketFactory.java
net.networksaremadeofstring.rhybudd.URLDrawable.java
net.networksaremadeofstring.rhybudd.URLImageParser.java
net.networksaremadeofstring.rhybudd.ViewEventFragment.java
net.networksaremadeofstring.rhybudd.ViewZenossDeviceActivity.java
net.networksaremadeofstring.rhybudd.ViewZenossDeviceFragment.java
net.networksaremadeofstring.rhybudd.ViewZenossDeviceListActivity.java
net.networksaremadeofstring.rhybudd.ViewZenossDeviceListFragment.java
net.networksaremadeofstring.rhybudd.ViewZenossDevice.java
net.networksaremadeofstring.rhybudd.ViewZenossEventActivity.java
net.networksaremadeofstring.rhybudd.ViewZenossEventFragment.java
net.networksaremadeofstring.rhybudd.ViewZenossEvent.java
net.networksaremadeofstring.rhybudd.ViewZenossEventsListActivity.java
net.networksaremadeofstring.rhybudd.ViewZenossEventsListFragment.java
net.networksaremadeofstring.rhybudd.ViewZenossGroupsActivity.java
net.networksaremadeofstring.rhybudd.ViewZenossGroupsFragment.java
net.networksaremadeofstring.rhybudd.WriteNFCActivity.java
net.networksaremadeofstring.rhybudd.ZaasSettingsFragment.java
net.networksaremadeofstring.rhybudd.ZenPack.java
net.networksaremadeofstring.rhybudd.ZenossAPICore.java
net.networksaremadeofstring.rhybudd.ZenossAPIZaas.java
net.networksaremadeofstring.rhybudd.ZenossAPI.java
net.networksaremadeofstring.rhybudd.ZenossAPIv2.java
net.networksaremadeofstring.rhybudd.ZenossCredentials.java
net.networksaremadeofstring.rhybudd.ZenossDeviceAdaptor.java
net.networksaremadeofstring.rhybudd.ZenossDevice.java
net.networksaremadeofstring.rhybudd.ZenossEvent.java
net.networksaremadeofstring.rhybudd.ZenossEventsAdaptor.java
net.networksaremadeofstring.rhybudd.ZenossGCMBroadcastReceiver.java
net.networksaremadeofstring.rhybudd.ZenossGroupsGridAdapter.java
net.networksaremadeofstring.rhybudd.ZenossPoller.java
net.networksaremadeofstring.rhybudd.ZenossSearchAdaptor.java
net.networksaremadeofstring.rhybudd.ZenossWidgetGraph.java
net.networksaremadeofstring.rhybudd.ZenossWidget.java