Android Open Source - android_device Connection Info Adapter






From Project

Back to project page android_device.

License

The source code is released under:

[Apache License](http://www.apache.org/licenses/): Version 2.0, January 2004 =============== ## TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION ## ### 1. Definitions. ### "License" sha...

If you think the Android project android_device 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 - 2014 Martin Albedinsky [Wolf-ITechnologies]
 * =================================================================================================
 *         Licensed under the Apache License, Version 2.0 or later (further "License" only).
 * -------------------------------------------------------------------------------------------------
 * You may use this file only in compliance with the License. More details and copy of this License
 * you may obtain at//  w  w  w.  ja va 2 s.c  om
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * You can redistribute, modify or publish any part of the code written within this file but as it
 * is described in the License, the software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES or CONDITIONS OF ANY KIND.
 *
 * See the License for the specific language governing permissions and limitations under the License.
 * =================================================================================================
 */
package com.wit.android.device.examples.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.wit.android.device.Connection;
import com.wit.android.device.examples.R;
import com.wit.android.device.examples.model.ConnectionInfo;
import com.wit.android.examples.libs.adapter.ExSimpleAdapter;
import com.wit.android.examples.libs.adapter.ExViewHolder;
import com.wit.android.examples.libs.adapter.annotation.ExItemView;
import com.wit.android.examples.libs.adapter.annotation.ExItemViewHolder;

import java.util.ArrayList;

/**
 * <p>
 * Description.
 * </p>
 *
 * @author Martin Albedinsky
 */
@ExItemView(R.layout.item_list_connection_info)
@ExItemViewHolder(ConnectionInfoAdapter.Holder.class)
public class ConnectionInfoAdapter extends ExSimpleAdapter<ConnectionInfo> {

  /**
   * Log TAG.
   */
  // private static final String TAG = ConnectionInfoAdapter.class.getSimpleName();

  /**
   */
  public ConnectionInfoAdapter(Context context) {
    super(context, new ArrayList<ConnectionInfo>(0));
  }

  /**
   *
   * @param info
   */
  public void dispatchNewInfo(ConnectionInfo info) {
    // Add latest info always at the top of the list.
    getItems().add(0, info);
    notifyDataSetChanged();
  }

  /**
   * Battery info adapter's item view holder.
   */
  public static final class Holder implements ExViewHolder<ConnectionInfo, ConnectionInfoAdapter> {

    TextView mTime, mConnected, mType;

    /**
     */
    @Override
    public void create(int position, View view) {
      this.mTime = (TextView) view.findViewById(R.id.item_list_connection_info_text_view_time);
      this.mConnected = (TextView) view.findViewById(R.id.item_list_connection_info_text_view_connected);
      this.mType = (TextView) view.findViewById(R.id.item_list_connection_info_text_view_type);
    }

    /**
     */
    @Override
    public void bind(int position, ConnectionInfo item, ConnectionInfoAdapter adapter) {
      mTime.setText(item.getTime());
      mConnected.setText(Boolean.toString(item.isConnected()));
      if (item.isConnected()) {
        mType.setText(item.getType().name());
      } else {
        final Connection.ConnectionType type = item.getLostType();
        if (type != Connection.ConnectionType.UNAVAILABLE) {
          mType.setText(type.name() + " lost");
        } else {
          mType.setText(type.name() );
        }
      }
    }
  }
}




Java Source Code List

com.wit.android.device.AndroidDevice.java
com.wit.android.device.BatteryImpl.java
com.wit.android.device.Battery.java
com.wit.android.device.ConnectionImpl.java
com.wit.android.device.Connection.java
com.wit.android.device.DeviceConfig.java
com.wit.android.device.ScreenImpl.java
com.wit.android.device.Screen.java
com.wit.android.device.StorageAction.java
com.wit.android.device.StorageImpl.java
com.wit.android.device.Storage.java
com.wit.android.device.examples.HomeActivity.java
com.wit.android.device.examples.adapter.BatteryInfoAdapter.java
com.wit.android.device.examples.adapter.ConnectionInfoAdapter.java
com.wit.android.device.examples.adapter.FilesAdapter.java
com.wit.android.device.examples.adapter.OrientationsAdapter.java
com.wit.android.device.examples.adapter.SimpleInfoAdapter.java
com.wit.android.device.examples.adapter.StorageAdapter.java
com.wit.android.device.examples.dialog.NewFileDialog.java
com.wit.android.device.examples.fragment.BaseDeviceFragment.java
com.wit.android.device.examples.fragment.BatteryInfoFragment.java
com.wit.android.device.examples.fragment.ConnectionInfoFragment.java
com.wit.android.device.examples.fragment.DeviceInfoFragment.java
com.wit.android.device.examples.fragment.FragmentsFactory.java
com.wit.android.device.examples.fragment.ScreenInfoFragment.java
com.wit.android.device.examples.fragment.ScreenInterfaceFragment.java
com.wit.android.device.examples.fragment.StorageFilesFragment.java
com.wit.android.device.examples.fragment.StorageInfoFragment.java
com.wit.android.device.examples.fragment.StorageInterfaceFragment.java
com.wit.android.device.examples.model.BatteryInfo.java
com.wit.android.device.examples.model.ConnectionInfo.java
com.wit.android.device.examples.model.SimpleInfo.java
com.wit.android.device.examples.model.StorageItem.java
com.wit.android.device.examples.module.StorageAssistant.java
com.wit.android.device.receiver.BatteryHealthReceiver.java
com.wit.android.device.receiver.BatteryPluggedStateReceiver.java
com.wit.android.device.receiver.BatteryStatusReceiver.java
com.wit.android.device.receiver.BroadcastProcessor.java
com.wit.android.device.receiver.ConnectionStateReceiver.java
com.wit.android.device.util.ConnectionUtils.java
com.wit.android.device.util.ScreenUtils.java
com.wit.android.device.util.StorageEditor.java
com.wit.android.device.util.StorageUtils.java