Android Open Source - longhorn Stock Overview Manager






From Project

Back to project page longhorn.

License

The source code is released under:

Apache License

If you think the Android project longhorn 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) 2012 Santiago Valdarrama
 * /*from   w  w w  . java  2 s . co  m*/
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at 
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */
package com.svpino.longhorn.artifacts;

import static com.svpino.longhorn.artifacts.Extensions.toValueOrEmptyString;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.svpino.longhorn.R;
import com.svpino.longhorn.model.Stock;

public class StockOverviewManager {

  private View dividerImageView;
  private TextView priceTextView;
  private TextView symbolTextView;
  private TextView nameTextView;
  private TextView changeTextView;
  private TextView openTextView;
  private TextView marketCapitalTextView;
  private TextView volumeLabelTextView;
  private TextView volumeTextView;
  private TextView rangeTextView;
  private TextView yearRangeTextView;
  private TextView peRatioTextView;
  private TextView epsTextView;
  private TextView dividendTextView;

  public StockOverviewManager(ViewGroup parent) {
    this.dividerImageView = parent.findViewById(R.id.dividerImageView);
    this.priceTextView = (TextView) parent.findViewById(R.id.priceTextView);
    this.symbolTextView = (TextView) parent.findViewById(R.id.symbolTextView);
    this.nameTextView = (TextView) parent.findViewById(R.id.nameTextView);
    this.changeTextView = (TextView) parent.findViewById(R.id.changeTextView);
    this.openTextView = (TextView) parent.findViewById(R.id.openTextView);
    this.marketCapitalTextView = (TextView) parent.findViewById(R.id.marketCapitalTextView);
    this.volumeLabelTextView = (TextView) parent.findViewById(R.id.volumeLabelTextView);
    this.volumeTextView = (TextView) parent.findViewById(R.id.volumeTextView);
    this.rangeTextView = (TextView) parent.findViewById(R.id.rangeTextView);
    this.yearRangeTextView = (TextView) parent.findViewById(R.id.yearRangeTextView);
    this.peRatioTextView = (TextView) parent.findViewById(R.id.peRatioTextView);
    this.epsTextView = (TextView) parent.findViewById(R.id.epsTextView);
    this.dividendTextView = (TextView) parent.findViewById(R.id.dividendTextView);
  }

  public void setStock(Stock stock) {
    if (this.dividerImageView != null) {
      this.dividerImageView.setBackgroundResource(Extensions.dividerLineResourceId(stock));

      this.symbolTextView.setText(stock.isMarketIndex()
        ? stock.getAlias()
        : stock.getSymbol());
      this.nameTextView.setText(stock.getName().toUpperCase());
      this.priceTextView.setText(toValueOrEmptyString(stock.getStringPrice()));
      this.changeTextView.setText(toValueOrEmptyString(stock.getStringChangeAndChangePercentage()));

      this.openTextView.setText(stock.getStringOpen());
      this.marketCapitalTextView.setText(stock.getStringMarketCapital());

      if ((stock.getVolume() != null && stock.getAverageVolume() != null) || (stock.getVolume() == null && stock.getAverageVolume() == null)) {
        this.volumeLabelTextView.setText(R.string.stock_overview_volume_label);
      }
      else if (stock.getVolume() == null) {
        this.volumeLabelTextView.setText(R.string.stock_overview_volume_label_average_volume);
      }
      else if (stock.getAverageVolume() == null) {
        this.volumeLabelTextView.setText(R.string.stock_overview_volume_label_volume);
      }

      this.volumeTextView.setText(stock.getStringVolumeAndAverageVolume());

      this.rangeTextView.setText(stock.getStringDaysPerformance());
      this.yearRangeTextView.setText(stock.getStringYearsPerformance());
      this.peRatioTextView.setText(stock.getStringPERatio());
      this.epsTextView.setText(stock.getStringEPS());
      this.dividendTextView.setText(stock.getStringDividend());
    }
  }

  public void setPrice(String value) {
    this.priceTextView.setText(value);
  }

}




Java Source Code List

com.svpino.longhorn.MarketCollectorService.java
com.svpino.longhorn.activities.DashboardActivity.java
com.svpino.longhorn.artifacts.Constants.java
com.svpino.longhorn.artifacts.Extensions.java
com.svpino.longhorn.artifacts.StockOverviewManager.java
com.svpino.longhorn.artifacts.StockTileProcessor.java
com.svpino.longhorn.artifacts.StockTileViewHolder.java
com.svpino.longhorn.artifacts.TabFragment.java
com.svpino.longhorn.artifacts.back.BackStack.java
com.svpino.longhorn.artifacts.back.StockOverviewBackStackItem.java
com.svpino.longhorn.data.DataProvider.java
com.svpino.longhorn.data.LonghornDatabase.java
com.svpino.longhorn.data.LonghornOpenHelper.java
com.svpino.longhorn.fragments.StockListFragment.java
com.svpino.longhorn.layouts.BorderRelativeLayout.java
com.svpino.longhorn.layouts.StockOverviewLayout.java
com.svpino.longhorn.model.Stock.java
com.svpino.longhorn.providers.SearchContentProvider.java
com.svpino.longhorn.receivers.BatteryBroadcastReceiver.java
com.svpino.longhorn.receivers.ConnectivityBroadcastReceiver.java
com.svpino.longhorn.receivers.MarketCollectionReceiver.java