mirror of
https://github.com/russok/FitoTrack.git
synced 2025-10-29 00:32:11 -07:00
Scenes in ShowWorkoutActivity
This commit is contained in:
parent
4f1e84bf02
commit
ec73699411
@ -26,12 +26,15 @@ import android.graphics.Typeface;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.transition.Scene;
|
||||||
|
import android.transition.TransitionManager;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.core.content.FileProvider;
|
import androidx.core.content.FileProvider;
|
||||||
@ -86,6 +89,14 @@ public class ShowWorkoutActivity extends FitoTrackActivity {
|
|||||||
FixedPixelCircle highlightingCircle;
|
FixedPixelCircle highlightingCircle;
|
||||||
Handler mHandler= new Handler();
|
Handler mHandler= new Handler();
|
||||||
|
|
||||||
|
Scene sceneOverview;
|
||||||
|
Scene speedDiagramScene;
|
||||||
|
Scene heightDiagramScene;
|
||||||
|
Scene mapScene;
|
||||||
|
LineChart speedDiagram;
|
||||||
|
LineChart heightDiagram;
|
||||||
|
ViewGroup sceneRoot;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -101,6 +112,9 @@ public class ShowWorkoutActivity extends FitoTrackActivity {
|
|||||||
theme= getTheme();
|
theme= getTheme();
|
||||||
|
|
||||||
root= findViewById(R.id.showWorkoutRoot);
|
root= findViewById(R.id.showWorkoutRoot);
|
||||||
|
sceneRoot= findViewById(R.id.showWorkoutSceneRoot);
|
||||||
|
ViewGroup sceneLayout= findViewById(R.id.showWorkoutDefaultSceneRoot);
|
||||||
|
sceneOverview= new Scene(sceneRoot, sceneLayout);
|
||||||
|
|
||||||
addText(getString(R.string.comment) + ": " + workout.comment).setOnClickListener(v -> {
|
addText(getString(R.string.comment) + ": " + workout.comment).setOnClickListener(v -> {
|
||||||
TextView textView= (TextView)v;
|
TextView textView= (TextView)v;
|
||||||
@ -138,9 +152,24 @@ public class ShowWorkoutActivity extends FitoTrackActivity {
|
|||||||
|
|
||||||
addHeightDiagram();
|
addHeightDiagram();
|
||||||
|
|
||||||
|
createScenes();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void createScenes(){
|
||||||
|
speedDiagramScene= createDiagramScene(speedDiagram);
|
||||||
|
heightDiagramScene= createDiagramScene(heightDiagram);
|
||||||
|
mapScene= new Scene(sceneRoot, map);
|
||||||
|
}
|
||||||
|
|
||||||
|
Scene createDiagramScene(LineChart chart){
|
||||||
|
LinearLayout layout= new LinearLayout(this);
|
||||||
|
layout.setOrientation(LinearLayout.VERTICAL);
|
||||||
|
layout.addView(map, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getMapHeight()));
|
||||||
|
layout.addView(chart, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||||
|
return new Scene(sceneRoot, layout);
|
||||||
|
}
|
||||||
|
|
||||||
void openEditCommentDialog(final TextView change){
|
void openEditCommentDialog(final TextView change){
|
||||||
final EditText editText= new EditText(this);
|
final EditText editText= new EditText(this);
|
||||||
editText.setText(workout.comment);
|
editText.setText(workout.comment);
|
||||||
@ -253,6 +282,8 @@ public class ShowWorkoutActivity extends FitoTrackActivity {
|
|||||||
});
|
});
|
||||||
chart.invalidate();
|
chart.invalidate();
|
||||||
|
|
||||||
|
converter.afterAdd(chart);
|
||||||
|
|
||||||
root.addView(chart, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getWindowManager().getDefaultDisplay().getWidth()*3/4));
|
root.addView(chart, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getWindowManager().getDefaultDisplay().getWidth()*3/4));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,6 +294,7 @@ public class ShowWorkoutActivity extends FitoTrackActivity {
|
|||||||
String getName();
|
String getName();
|
||||||
String getDescription();
|
String getDescription();
|
||||||
boolean compare(WorkoutSample sample, Entry entry);
|
boolean compare(WorkoutSample sample, Entry entry);
|
||||||
|
void afterAdd(LineChart chart);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addHeightDiagram(){
|
void addHeightDiagram(){
|
||||||
@ -294,6 +326,12 @@ public class ShowWorkoutActivity extends FitoTrackActivity {
|
|||||||
public boolean compare(WorkoutSample sample, Entry entry) {
|
public boolean compare(WorkoutSample sample, Entry entry) {
|
||||||
return sample.tmpHeightEntry.equalTo(entry);
|
return sample.tmpHeightEntry.equalTo(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterAdd(LineChart chart) {
|
||||||
|
heightDiagram= chart;
|
||||||
|
heightDiagram.setOnClickListener(v -> TransitionManager.go(heightDiagramScene));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,6 +366,12 @@ public class ShowWorkoutActivity extends FitoTrackActivity {
|
|||||||
public boolean compare(WorkoutSample sample, Entry entry) {
|
public boolean compare(WorkoutSample sample, Entry entry) {
|
||||||
return sample.tmpSpeedEntry.equalTo(entry);
|
return sample.tmpSpeedEntry.equalTo(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterAdd(LineChart chart) {
|
||||||
|
speedDiagram= chart;
|
||||||
|
heightDiagram.setOnClickListener(v -> TransitionManager.go(speedDiagramScene));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,7 +401,7 @@ public class ShowWorkoutActivity extends FitoTrackActivity {
|
|||||||
map.getModel().mapViewPosition.setMapLimit(bounds);
|
map.getModel().mapViewPosition.setMapLimit(bounds);
|
||||||
|
|
||||||
|
|
||||||
root.addView(map, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getWindowManager().getDefaultDisplay().getWidth()*3/4));
|
root.addView(map, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getMapHeight()));
|
||||||
map.setAlpha(0);
|
map.setAlpha(0);
|
||||||
|
|
||||||
|
|
||||||
@ -367,6 +411,24 @@ public class ShowWorkoutActivity extends FitoTrackActivity {
|
|||||||
Paint pRed= AndroidGraphicFactory.INSTANCE.createPaint();
|
Paint pRed= AndroidGraphicFactory.INSTANCE.createPaint();
|
||||||
pRed.setColor(Color.RED);
|
pRed.setColor(Color.RED);
|
||||||
map.addLayer(new FixedPixelCircle(samples.get(samples.size()-1).toLatLong(), 20, pRed, null));
|
map.addLayer(new FixedPixelCircle(samples.get(samples.size()-1).toLatLong(), 20, pRed, null));
|
||||||
|
|
||||||
|
map.setOnClickListener(v -> goToMapScene());
|
||||||
|
|
||||||
|
goToMapScene();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void goToMapScene(){
|
||||||
|
TransitionManager.go(mapScene);
|
||||||
|
map.setOnClickListener(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void leaveMapScene(){
|
||||||
|
TransitionManager.go(sceneOverview);
|
||||||
|
map.setOnClickListener(v -> goToMapScene());
|
||||||
|
}
|
||||||
|
|
||||||
|
int getMapHeight(){
|
||||||
|
return getWindowManager().getDefaultDisplay().getWidth()*3/4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -18,16 +18,25 @@
|
|||||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/showWorkoutSceneRoot"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".activity.ShowWorkoutActivity">
|
tools:context=".activity.ShowWorkoutActivity">
|
||||||
|
|
||||||
<LinearLayout
|
<ScrollView
|
||||||
android:id="@+id/showWorkoutRoot"
|
android:id="@+id/showWorkoutDefaultSceneRoot"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent">
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="20dp"></LinearLayout>
|
<LinearLayout
|
||||||
</ScrollView>
|
android:id="@+id/showWorkoutRoot"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="20dp"></LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
Loading…
x
Reference in New Issue
Block a user