コード例 #1
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      if (convertView == null) {
        convertView = mInflater.inflate(R.layout.split_aggregate_list_item, parent, false);
      }

      SplitAggregateItemCache cache = (SplitAggregateItemCache) convertView.getTag();
      if (cache == null) {
        cache = new SplitAggregateItemCache();
        cache.name = (TextView) convertView.findViewById(R.id.name);
        cache.additionalData = (TextView) convertView.findViewById(R.id.additionalData);
        cache.sourceIcon = (ImageView) convertView.findViewById(R.id.sourceIcon);
        convertView.setTag(cache);
      }

      final RawContactInfo info = getItem(position);
      cache.name.setText(info.name);
      cache.additionalData.setText(info.getAdditionalData());

      Drawable icon = null;
      AccountType accountType = mAccountTypes.getAccountType(info.accountType, info.dataSet);
      if (accountType != null) {
        icon = accountType.getDisplayIcon(getContext());
      }
      if (icon != null) {
        cache.sourceIcon.setImageDrawable(icon);
      } else {
        cache.sourceIcon.setImageResource(R.drawable.unknown_source);
      }
      return convertView;
    }
コード例 #2
0
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    mMockContext = new ContactsMockContext(getContext());
    mContactsProvider = mMockContext.getContactsProvider();

    InjectedServices services = new InjectedServices();
    AccountType accountType =
        new BaseAccountType() {
          @Override
          public boolean areContactsWritable() {
            return false;
          }
        };
    accountType.accountType = "mockAccountType";

    AccountWithDataSet account = new AccountWithDataSet("mockAccountName", "mockAccountType", null);

    mMockContext.setMockAccountTypeManager(
        new MockAccountTypeManager(
            new AccountType[] {accountType}, new AccountWithDataSet[] {account}));
  }