Ejemplo n.º 1
0
  public void updateCharts(List<?> statsForApp) {
    Chart chart = new Chart();
    int page = myAdapter.getCurrentPage();
    int column = myAdapter.getCurrentColumn();

    int position = -1;
    List<View> charts = new ArrayList<View>();

    int pos = 0;
    for (int i = 0; i < myAdapter.getNumPages(); i++)
      for (int j = 1; j < myAdapter.getNumCharts(i); j++) {
        int pageColumn[] = new int[3];
        View chartView = myAdapter.buildChart(getActivity(), chart, statsForApp, i, j);
        /*
         * if(chartView==null) {
         * Log.i(LOG_TAG,"Ignoring chart p="+i+" c="+j+"for class="
         * +this.getClass().toString()); continue; }
         */
        Gallery.LayoutParams params =
            new Gallery.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
        chartView.setLayoutParams(params);
        pageColumn[0] = i;
        pageColumn[1] = j;
        pageColumn[2] = myAdapter.getNumCharts(i);
        if (i == page && j == column) position = pos;
        pos++;
        chartView.setTag(pageColumn);
        charts.add(chartView);
      }
    chartGallery.setIgnoreLayoutCalls(false);
    chartGalleryAdapter.setViews(charts);
    if (position >= 0) chartGallery.setSelection(position);
    chartGalleryAdapter.notifyDataSetChanged();
    chartGallery.invalidate();
  }
Ejemplo n.º 2
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.chart_fragment, container, false);

    List<View> extras = getExtraFullViews(view);
    if (extras != null) {
      ViewSwitcher vs = (ViewSwitcher) view.findViewById(R.id.base_chart_viewswitcher_config);
      for (View v : extras) vs.addView(v);
    }

    currentTimeFrame = Preferences.getChartTimeframe(getActivity());

    listViewSwitcher =
        new ViewSwitcher3D((ViewGroup) view.findViewById(R.id.base_chart_bottom_frame));
    listViewSwitcher.setListener(this);

    chartGallery = (ChartGallery) view.findViewById(R.id.base_chart_gallery);
    chartGalleryAdapter = new ChartGalleryAdapter(new ArrayList<View>());
    chartGallery.setAdapter(chartGalleryAdapter);
    chartGallery.setOnItemSelectedListener(
        new OnItemSelectedListener() {

          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

            chartGallery.setIgnoreLayoutCalls(true);

            if (view.getTag() != null) {
              // (page, column, num columns)?
              int pageColumn[] = (int[]) view.getTag();
              int page = pageColumn[0];
              int column = pageColumn[1];
              myAdapter.setCurrentChart(page, column);
              updateChartHeadline();
              myAdapter.notifyDataSetChanged();
              onChartSelected(page, column);
            }
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });

    dataList = (ListView) view.findViewById(R.id.base_chart_list);
    timeframeText = (TextView) view.findViewById(R.id.base_chart_timeframe);
    dataframe = (ViewGroup) view.findViewById(R.id.base_chart_datacontainer);
    chartframe = (ViewGroup) view.findViewById(R.id.base_chart_chartframe);

    return view;
  }
Ejemplo n.º 3
0
  public void setCurrentChart(int page, int column) {
    if (chartGalleryAdapter.getViews().isEmpty()) {
      // chart not initialized yet
      return;
    }

    int pos = 0;
    for (View view : chartGalleryAdapter.getViews()) {
      int pageColumn[] = (int[]) view.getTag();
      if (page == pageColumn[0] && column == pageColumn[1]) {
        chartGallery.setSelection(pos, false);
        myAdapter.setCurrentChart(page, column);
        return;
      }
      pos++;
    }
    throw new IndexOutOfBoundsException("page=" + page + " column=" + column);
  }
Ejemplo n.º 4
0
 protected final void setChartIgnoreCallLayouts(boolean ignoreLayoutCalls) {
   chartGallery.setIgnoreLayoutCalls(ignoreLayoutCalls);
 }
Ejemplo n.º 5
0
 public void setAllowChangePageSliding(boolean allowChangePageSliding) {
   chartGallery.setAllowChangePageSliding(allowChangePageSliding);
 }
Ejemplo n.º 6
0
 @Override
 public void onRender() {
   chartGallery.invalidate();
 }
Ejemplo n.º 7
0
 @Override
 public void onViewChanged(boolean frontsideVisible) {
   chartGallery.setIgnoreLayoutCalls(true);
 }
Ejemplo n.º 8
0
 @Override
 public void onResume() {
   super.onResume();
   chartGallery.setIgnoreLayoutCalls(false);
 }
Ejemplo n.º 9
0
 public int getCurrentChart() {
   return chartGallery.getSelectedItemPosition();
 }