2 * Copyright © 2013 Mike Beattie <mike@ethernal.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
18 package org.altusmetrum.AltosDroid;
20 import org.altusmetrum.altoslib_6.*;
21 import android.location.Location;
22 import android.app.Activity;
23 import android.graphics.Color;
24 import android.os.Bundle;
25 import android.support.v4.app.Fragment;
26 import android.support.v4.app.FragmentTransaction;
27 import android.support.v4.app.FragmentManager;
28 import android.location.Location;
29 import android.util.Log;
30 import android.widget.TextView;
32 public abstract class AltosDroidTab extends Fragment implements AltosUnitsListener {
33 AltosState last_state;
34 AltosGreatCircle last_from_receiver;
35 Location last_receiver;
37 public abstract void show(AltosState state, AltosGreatCircle from_receiver, Location receiver);
39 public abstract String tab_name();
41 public void units_changed(boolean imperial_units) {
42 if (!isHidden() && last_state != null)
43 show(last_state, last_from_receiver, last_receiver);
46 public void set_value(TextView text_view,
50 if (value == AltosLib.MISSING)
51 text_view.setText("");
53 text_view.setText(units.show(width, value));
56 public void set_visible(boolean visible) {
57 FragmentTransaction ft = AltosDroid.fm.beginTransaction();
59 AltosState state = last_state;
60 AltosGreatCircle from_receiver = last_from_receiver;
61 Location receiver = last_receiver;
63 show(state, from_receiver, receiver);
70 public void update_ui(AltosState state, AltosGreatCircle from_receiver, Location receiver, boolean is_current) {
72 last_from_receiver = from_receiver;
73 last_receiver = receiver;
75 show(state, from_receiver, receiver);