Android Open Source - ShareManager Company Adapter






From Project

Back to project page ShareManager.

License

The source code is released under:

Copyright (c) 2013, Nelspike All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Red...

If you think the Android project ShareManager 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 share.manager.adapters;
//from   ww  w.  java2 s  . co  m
import share.manager.stock.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class CompanyAdapter extends ArrayAdapter<String> {

  private String[] strings, regions, changes;
  private boolean[] status;
  private Context context;

  public CompanyAdapter(Context context, int textViewResourceId,
      String[] objects, String[] regions, boolean[] status, String[] changes) {
    super(context, textViewResourceId, objects);
    this.context = context;
    this.strings = objects;
    this.regions = regions;
    this.status = status;
    this.changes = changes; // x% (absolute value)
  }

  @Override
  public View getDropDownView(int position, View convertView, ViewGroup parent) {
    return getCustomView(position, convertView, parent);
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    return getCustomView(position, convertView, parent);
  }

  public View getCustomView(int position, View convertView, ViewGroup parent) {

    LayoutInflater inflater = (LayoutInflater) context
        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View row = inflater.inflate(R.layout.company_box, parent, false);

    TextView label = (TextView) row.findViewById(R.id.company_name_box);
    label.setText(strings[position]);

    TextView labelRegion = (TextView) row.findViewById(R.id.company_region_box);
    labelRegion.setText(regions[position]);

    ImageView arrow = (ImageView) row.findViewById(R.id.company_arrow_box);

    if (status != null) {
      if (status[position]) arrow.setImageDrawable(context.getResources()
          .getDrawable(R.drawable.upper_arrow));
      else {
        arrow.setImageDrawable(context.getResources().getDrawable(
            R.drawable.down_arrow));
      }
    }

    if (changes != null) {
      TextView labelChange = (TextView) row
          .findViewById(R.id.company_change_box);
      labelChange.setText(changes[position]);
    }

    return row;
  }
}




Java Source Code List

share.manager.adapters.CompanyAdapter.java
share.manager.adapters.DialogAdapter.java
share.manager.adapters.MainPagerAdapter.java
share.manager.adapters.SharesAdapter.java
share.manager.connection.ConnectionRunnable.java
share.manager.connection.ConnectionThread.java
share.manager.fragments.MineFragment.java
share.manager.fragments.PortfolioFragment.java
share.manager.fragments.SharesFragment.java
share.manager.listeners.ShareTabListener.java
share.manager.listeners.SwipeListener.java
share.manager.stock.CompanyActivity.java
share.manager.stock.MainActivity.java
share.manager.stock.ResultsActivity.java
share.manager.stock.SettingsActivity.java
share.manager.stock.ShareManager.java
share.manager.utils.CompanyGraphicsBuilder.java
share.manager.utils.FileHandler.java
share.manager.utils.GraphType.java
share.manager.utils.RESTFunction.java
share.manager.utils.ShareUtils.java
share.manager.utils.SharesGraphicsBuilder.java