-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All-Time Stats Preview Elements (#149)
- Loading branch information
Showing
10 changed files
with
312 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import java.time.LocalDate; | ||
|
||
public class UserMaintenanceData { | ||
private int sharpeningInterval; | ||
private double baseAngle; | ||
private double edgeAngle; | ||
private LocalDate lastSharpeningDate; | ||
private int waxingInterval; | ||
private String waxType; | ||
private LocalDate lastWaxingDate; | ||
|
||
// Constructor | ||
public UserMaintenanceData(int sharpeningInterval, double baseAngle, double edgeAngle, LocalDate lastSharpeningDate, int waxingInterval, String waxType, LocalDate lastWaxingDate) { | ||
this.sharpeningInterval = sharpeningInterval; | ||
this.baseAngle = baseAngle; | ||
this.edgeAngle = edgeAngle; | ||
this.lastSharpeningDate = lastSharpeningDate; | ||
this.waxingInterval = waxingInterval; | ||
this.waxType = waxType; | ||
this.lastWaxingDate = lastWaxingDate; | ||
} | ||
|
||
// Getters and Setters | ||
public int getSharpeningInterval() { | ||
return sharpeningInterval; | ||
} | ||
|
||
public void setSharpeningInterval(int sharpeningInterval) { | ||
this.sharpeningInterval = sharpeningInterval; | ||
} | ||
|
||
public double getBaseAngle() { | ||
return baseAngle; | ||
} | ||
|
||
public void setBaseAngle(double baseAngle) { | ||
this.baseAngle = baseAngle; | ||
} | ||
|
||
public double getEdgeAngle() { | ||
return edgeAngle; | ||
} | ||
|
||
public void setEdgeAngle(double edgeAngle) { | ||
this.edgeAngle = edgeAngle; | ||
} | ||
|
||
public LocalDate getLastSharpeningDate() { | ||
return lastSharpeningDate; | ||
} | ||
|
||
public void setLastSharpeningDate(LocalDate lastSharpeningDate) { | ||
this.lastSharpeningDate = lastSharpeningDate; | ||
} | ||
|
||
public int getWaxingInterval() { | ||
return waxingInterval; | ||
} | ||
|
||
public void setWaxingInterval(int waxingInterval) { | ||
this.waxingInterval = waxingInterval; | ||
} | ||
public String getWaxType() { | ||
return waxType; | ||
} | ||
|
||
public void setWaxType(String waxType) { | ||
this.waxType = waxType; | ||
} | ||
|
||
public LocalDate getLastWaxingDate() { | ||
return lastWaxingDate; | ||
} | ||
|
||
public void setLastWaxingDate(LocalDate lastWaxingDate) { | ||
this.lastWaxingDate = lastWaxingDate; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...main/java/de/dennisguse/opentracks/ui/aggregatedStatistics/StatisticsPreviewActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package de.dennisguse.opentracks.ui.aggregatedStatistics; | ||
|
||
import android.os.Bundle; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
import androidx.recyclerview.widget.LinearLayoutManager; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import de.dennisguse.opentracks.R; | ||
import de.dennisguse.opentracks.stats.MockupData; | ||
|
||
public class StatisticsPreviewActivity extends AppCompatActivity { | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.stats_preview); | ||
|
||
MockupData mockupData1 = new MockupData(2022); // example 2022-2023 | ||
MockupData mockupData2 = new MockupData(2023); // example 2023-2024 | ||
|
||
List<MockupData> seasons = new ArrayList<>(); | ||
|
||
RecyclerView previews = findViewById(R.id.seasonPreviews); | ||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); | ||
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); | ||
previews.setLayoutManager(linearLayoutManager); | ||
|
||
StatisticsPreviewAdapter previewAdapter = new StatisticsPreviewAdapter(seasons); | ||
previews.setAdapter(previewAdapter); | ||
|
||
seasons.add(mockupData1); | ||
seasons.add(mockupData2); | ||
|
||
previewAdapter.notifyDataSetChanged(); | ||
|
||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
src/main/java/de/dennisguse/opentracks/ui/aggregatedStatistics/StatisticsPreviewAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package de.dennisguse.opentracks.ui.aggregatedStatistics; | ||
|
||
import android.content.Intent; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.TextView; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import de.dennisguse.opentracks.R; | ||
import de.dennisguse.opentracks.stats.MockupData; | ||
import de.dennisguse.opentracks.stats.TrackStatistics; | ||
public class StatisticsPreviewAdapter extends RecyclerView.Adapter<StatisticsPreviewAdapter.ViewHolder> { | ||
private List<MockupData> list = new ArrayList<>(); | ||
|
||
public StatisticsPreviewAdapter(List<MockupData> mList){ | ||
this.list = mList; | ||
} | ||
|
||
public int getItemCount(){ | ||
return list.size(); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int position){ | ||
|
||
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.stats_preview_item, viewGroup, false); | ||
|
||
v.setOnClickListener(new RecyclerView.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Intent intent = new Intent(v.getContext(), StatisticsActivity.class); | ||
intent.putExtra("data", list.get(position)); | ||
v.getContext().startActivity(intent); | ||
} | ||
}); | ||
|
||
return new ViewHolder(v); | ||
} | ||
|
||
public void onBindViewHolder(@NonNull ViewHolder holder, int i){ | ||
MockupData data = list.get(i); | ||
|
||
int year = data.getSeason(); | ||
List<TrackStatistics> trackStatistics = data.getTrackStatistics(); | ||
TrackStatistics summary = TrackStatistics.sumOfTotalStats(trackStatistics); | ||
|
||
holder.previewInfo.setText(String.valueOf(year) + " - " + String.valueOf(year+1)); // TODO: do this the right way : | | ||
|
||
String days = String.valueOf(summary.getTotalSkiDaysSeason()); | ||
String distance = String.valueOf(summary.getTotalDistance().toM()); | ||
String runs = String.valueOf(summary.getTotalRunsSeason()); | ||
|
||
holder.season.setText(days + " days | " + distance + "m | " + runs + " runs"); | ||
} | ||
|
||
@Override | ||
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) { | ||
super.onAttachedToRecyclerView(recyclerView); | ||
} | ||
|
||
public static class ViewHolder extends RecyclerView.ViewHolder { | ||
TextView season; | ||
TextView previewInfo; | ||
|
||
ViewHolder(@NonNull View itemView) { | ||
super(itemView); | ||
season = itemView.findViewById(R.id.seasonPreview); | ||
previewInfo = itemView.findViewById(R.id.seasonPreviewData); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> | ||
<corners | ||
android:radius="2dp" | ||
android:topRightRadius="0dp" | ||
android:bottomRightRadius="0dp" | ||
android:bottomLeftRadius="0dp" /> | ||
<stroke | ||
android:width="1dp" | ||
android:color="@android:color/darker_gray"/> | ||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:layout_marginTop="50dp" | ||
android:orientation="vertical" | ||
app:layout_constraintTop_toTopOf="parent" | ||
tools:layout_editor_absoluteX="1dp"> | ||
|
||
<androidx.recyclerview.widget.RecyclerView | ||
android:id="@+id/seasonPreviews" | ||
android:layout_width="409dp" | ||
android:layout_height="600dp"> | ||
|
||
</androidx.recyclerview.widget.RecyclerView> | ||
</LinearLayout> | ||
|
||
<TextView | ||
android:id="@+id/SkiTitle" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="129dp" | ||
android:layout_marginTop="16dp" | ||
android:layout_marginEnd="129dp" | ||
android:text="Seasons" | ||
android:textAlignment="center" | ||
android:textColor="#A43F20" | ||
android:textSize="24sp" | ||
android:textStyle="bold" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintHorizontal_bias="0.517" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
tools:text="Ski Season Stats" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/statsPreviewItem" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="-1dp" | ||
android:background="@drawable/stats_item_border" | ||
android:orientation="horizontal" | ||
android:paddingTop="0dp" | ||
android:paddingBottom="0dp"> | ||
|
||
<LinearLayout | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:background="@drawable/stats_item_border" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:id="@+id/seasonPreviewData" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:paddingHorizontal="15dp" | ||
android:text="SEASON" | ||
android:textSize="24sp" /> | ||
|
||
<TextView | ||
android:id="@+id/seasonPreview" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:paddingHorizontal="15dp" | ||
android:text="0 days | 0m | 0 runs" /> | ||
</LinearLayout> | ||
|
||
</LinearLayout> |