Skip to content

Commit

Permalink
Datas now display how many days between last and first entry
Browse files Browse the repository at this point in the history
  • Loading branch information
lubenard committed Jun 5, 2021
1 parent c6fbb32 commit 66ac169
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
import com.lubenard.oring_reminder.MainActivity;
import com.lubenard.oring_reminder.R;
import com.lubenard.oring_reminder.custom_components.RingModel;
import com.lubenard.oring_reminder.utils.Utils;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.concurrent.TimeUnit;

public class DatasFragment extends Fragment {
@Override
Expand All @@ -40,12 +42,26 @@ public void onViewCreated(View view, Bundle savedInstanceState) {
TextView numberOfEntries = view.findViewById(R.id.number_of_entries);
TextView lastEntry = view.findViewById(R.id.last_entry);
TextView firstEntry = view.findViewById(R.id.first_entry);
TextView timeBetweenLastAndFirst = view.findViewById(R.id.time_between_first_and_last_entries);


numberOfEntries.setText(getString(R.string.number_of_entries)+ datas.size());
String lastEntryData = (datas.size() > 0) ? datas.get(datas.size() - 1).getDatePut().split(" ")[0] : getString(R.string.not_set_yet);
String firstEntryData = (datas.size() > 0) ? datas.get(0).getDatePut().split(" ")[0] : getString(R.string.not_set_yet);
String lastEntryData;
String firstEntryData;
String timeBetweenLastAndFirstData;

if (datas.size() > 0) {
lastEntryData = datas.get(datas.size() - 1).getDatePut().split(" ")[0];
firstEntryData = datas.get(0).getDatePut().split(" ")[0];
timeBetweenLastAndFirstData = String.valueOf(Utils.getDateDiff(datas.get(0).getDatePut(), datas.get(datas.size() - 1).getDatePut(), TimeUnit.DAYS) + 1);
} else {
lastEntryData = getString(R.string.not_set_yet);
firstEntryData = getString(R.string.not_set_yet);
timeBetweenLastAndFirstData = getString(R.string.not_set_yet);
}

lastEntry.setText(getString(R.string.last_entry) + "\n" + lastEntryData);
firstEntry.setText(getString(R.string.first_entry) + "\n" + firstEntryData);
timeBetweenLastAndFirst.setText(getString(R.string.number_of_days_between_entries) + "\n" + timeBetweenLastAndFirstData);
}
}
9 changes: 9 additions & 0 deletions app/src/main/res/layout/datas_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,14 @@
android:layout_marginTop="25dp"
android:textSize="25sp"
android:text="first_entries" />

<TextView
android:id="@+id/time_between_first_and_last_entries"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:layout_marginTop="25dp"
android:textSize="25sp"
android:text="time_between_first_and_last_entries" />
</LinearLayout>
</ScrollView>
1 change: 1 addition & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,5 @@
<string name="settings_other_useful_links_title">Liens utiles</string>
<string name="custom_useful_links">Liens utils :</string>
<string name="settings_other_useful_links_description">Une poignée de liens utils !</string>
<string name="number_of_days_between_entries">Nombre de jours entre la prenière et dernière entrée :</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,5 @@
<string name="settings_other_useful_links_title">Useful links:</string>
<string name="settings_other_useful_links_description">A bunch of useful links!</string>
<string name="custom_useful_links">Useful links</string>
<string name="number_of_days_between_entries">Number of days between the first and last entry:</string>
</resources>

0 comments on commit 66ac169

Please sign in to comment.