Просмотр исходного кода

Click behaviour and Navigation

master
Flo Smilari 3 лет назад
Родитель
Сommit
0fddf1f1c8

Двоичные данные
.gradle/7.3.3/executionHistory/executionHistory.bin Просмотреть файл


Двоичные данные
.gradle/7.3.3/executionHistory/executionHistory.lock Просмотреть файл


Двоичные данные
.gradle/7.3.3/fileHashes/fileHashes.bin Просмотреть файл


Двоичные данные
.gradle/7.3.3/fileHashes/fileHashes.lock Просмотреть файл


Двоичные данные
.gradle/7.3.3/fileHashes/resourceHashesCache.bin Просмотреть файл


Двоичные данные
.gradle/buildOutputCleanup/buildOutputCleanup.lock Просмотреть файл


+ 6
- 0
.idea/vcs.xml Просмотреть файл

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="svn" />
</component>
</project>

+ 66
- 6
.idea/workspace.xml Просмотреть файл

@@ -20,7 +20,25 @@
<option name="autoReloadType" value="NONE" />
</component>
<component name="ChangeListManager">
<list default="true" id="41369230-c648-4299-baf3-de5f13bcb18c" name="Changes" comment="" />
<list default="true" id="41369230-c648-4299-baf3-de5f13bcb18c" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gradle/7.3.3/executionHistory/executionHistory.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/7.3.3/executionHistory/executionHistory.bin" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gradle/7.3.3/executionHistory/executionHistory.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/7.3.3/executionHistory/executionHistory.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gradle/7.3.3/fileHashes/fileHashes.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/7.3.3/fileHashes/fileHashes.bin" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gradle/7.3.3/fileHashes/fileHashes.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/7.3.3/fileHashes/fileHashes.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gradle/7.3.3/fileHashes/resourceHashesCache.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/7.3.3/fileHashes/resourceHashesCache.bin" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gradle/buildOutputCleanup/buildOutputCleanup.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/buildOutputCleanup/buildOutputCleanup.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/model/ArcherySetup.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/model/ArcherySetup.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/model/IArcherySetup.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/model/IArcherySetup.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/calcsight/CalculateSightFragment.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/calcsight/CalculateSightFragment.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/calcsight/CalculateSightViewModel.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/calcsight/CalculateSightViewModel.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/equipment/EquipmentRecyclerViewAdapter.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/equipment/EquipmentRecyclerViewAdapter.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/res/layout/fragment_equipment_choose.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/res/layout/fragment_equipment_choose.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/res/values-de/strings.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/res/values-de/strings.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/res/values/dimens.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/res/values/dimens.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/res/values/strings.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/res/values/strings.xml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -53,6 +71,10 @@
<property name="RunOnceActivity.cidr.known.project.marker" value="true" />
<property name="android-custom-viewC:/Users/FSmilari/.gradle/caches/modules-2/files-2.1/androidx.recyclerview/recyclerview/1.2.1/f0f93e67af3f7417bdd560d5142f6dec4fe629c3/recyclerview-1.2.1-sources.jar!/androidx/recyclerview/widget/RecyclerView.java_RecyclerView_DIMENSIONS" value="1080&#10;1920" />
<property name="android-custom-viewC:/Users/FSmilari/.gradle/caches/modules-2/files-2.1/androidx.recyclerview/recyclerview/1.2.1/f0f93e67af3f7417bdd560d5142f6dec4fe629c3/recyclerview-1.2.1-sources.jar!/androidx/recyclerview/widget/RecyclerView.java_SELECTED" value="RecyclerView" />
<property name="android-custom-viewC:/Users/FSmilari/AppData/Local/Android/Sdk/sources/android-32/android/view/View.java_SELECTED" value="View" />
<property name="android-custom-viewC:/Users/FSmilari/AppData/Local/Android/Sdk/sources/android-32/android/view/View.java_View_DIMENSIONS" value="1080&#10;1920" />
<property name="android-custom-viewC:/Users/FSmilari/AppData/Local/Android/Sdk/sources/android-32/android/view/ViewGroup.java_SELECTED" value="ViewGroup" />
<property name="android-custom-viewC:/Users/FSmilari/AppData/Local/Android/Sdk/sources/android-32/android/view/ViewGroup.java_ViewGroup_DIMENSIONS" value="1080&#10;1920" />
<property name="cidr.known.project.marker" value="true" />
<property name="code.cleanup.on.save" value="true" />
<property name="format.on.save" value="true" />
@@ -138,6 +160,28 @@
</configuration>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="SvnConfiguration" cleanupOnStartRun="true">
<configuration>C:\Users\FSmilari\AppData\Roaming\Subversion</configuration>
<supportedVersion>125</supportedVersion>
</component>
<component name="SvnFileUrlMappingImpl">
<option name="myMappingRoots">
<list>
<SvnCopyRootSimple>
<option name="myVcsRoot" value="Z:\Work\Java Projects\Android\RecurveBowSight\V2" />
<option name="myCopyRoot" value="Z:\Work\Java Projects\Android\RecurveBowSight\V2" />
</SvnCopyRootSimple>
</list>
</option>
<option name="myMoreRealMappingRoots">
<list>
<SvnCopyRootSimple>
<option name="myVcsRoot" value="Z:\Work\Java Projects\Android\RecurveBowSight\V2" />
<option name="myCopyRoot" value="Z:\Work\Java Projects\Android\RecurveBowSight\V2" />
</SvnCopyRootSimple>
</list>
</option>
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="41369230-c648-4299-baf3-de5f13bcb18c" name="Changes" comment="" />
@@ -156,17 +200,33 @@
<line>19</line>
<option name="timeStamp" value="2" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="java-line">
<url>file://$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/RBSMainActivity.java</url>
<line>50</line>
<option name="timeStamp" value="3" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="java-line">
<url>file://$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/database/RBSDatabaseHelper.java</url>
<line>99</line>
<option name="timeStamp" value="4" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="java-line">
<url>file://$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/equipment/EquipmentRecyclerViewAdapter.java</url>
<line>73</line>
<option name="timeStamp" value="6" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="java-line">
<url>file://$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/calcsight/CalculateSightFragment.java</url>
<line>25</line>
<option name="timeStamp" value="8" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="java-line">
<url>file://$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/calcsight/CalculateSightViewModel.java</url>
<line>26</line>
<option name="timeStamp" value="9" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
<watches-manager>
<configuration name="app">
<watch expression="getArguments()" />
<watch expression="this.selectedArcherySetup.getName()" language="JAVA" />
</configuration>
</watches-manager>
</component>
</project>

+ 11
- 0
app/src/main/java/ch/spherIC/recurvebowsight/model/ArcherySetup.java Просмотреть файл

@@ -3,6 +3,8 @@
*/
package ch.spherIC.recurvebowsight.model;
import android.os.Parcel;
/**
* @author F. Smilari
*/
@@ -366,4 +368,13 @@ public class ArcherySetup implements IArcherySetup {
public void setBraceHeight(final Double braceHeight) {
this.braceHeight = braceHeight;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
}
}

+ 3
- 1
app/src/main/java/ch/spherIC/recurvebowsight/model/IArcherySetup.java Просмотреть файл

@@ -3,10 +3,12 @@
*/
package ch.spherIC.recurvebowsight.model;
import android.os.Parcelable;
/**
* @author F. Smilari
*/
public interface IArcherySetup extends IEntity {
public interface IArcherySetup extends IEntity, Parcelable {
ISight getSight();

+ 6
- 0
app/src/main/java/ch/spherIC/recurvebowsight/ui/calcsight/CalculateSightFragment.java Просмотреть файл

@@ -10,6 +10,7 @@ import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import ch.spherIC.recurvebowsight.databinding.FragmentCalcsightBinding;
import ch.spherIC.recurvebowsight.model.IArcherySetup;

public class CalculateSightFragment extends Fragment {

@@ -21,6 +22,11 @@ public class CalculateSightFragment extends Fragment {
binding = FragmentCalcsightBinding.inflate(inflater, container, false);
View root = binding.getRoot();

if (getArguments() != null && getArguments().containsKey("setup")) {
IArcherySetup archerySetup = getArguments().getParcelable("setup");
galleryViewModel.setSelectedArcherySetup(archerySetup);
}

final TextView textView = binding.textCalcsight;
galleryViewModel.getText().observe(getViewLifecycleOwner(), textView::setText);
return root;

+ 17
- 1
app/src/main/java/ch/spherIC/recurvebowsight/ui/calcsight/CalculateSightViewModel.java Просмотреть файл

@@ -1,18 +1,34 @@
package ch.spherIC.recurvebowsight.ui.calcsight;

import android.text.TextUtils;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import ch.spherIC.recurvebowsight.model.IArcherySetup;

public class CalculateSightViewModel extends ViewModel {

private final MutableLiveData<String> mText;

private IArcherySetup selectedArcherySetup;

public CalculateSightViewModel() {
mText = new MutableLiveData<>();
mText.setValue("This is the \"Calc Sight\" fragment");
mText.setValue("This is the \"Calc Sight\" fragment for: \n-");
}

public IArcherySetup getSelectedArcherySetup() {
return selectedArcherySetup;
}

public void setSelectedArcherySetup(IArcherySetup selectedArcherySetup) {
this.selectedArcherySetup = selectedArcherySetup;
String setupName = (this.selectedArcherySetup != null && !TextUtils.isEmpty(this.selectedArcherySetup.getName())) ? this.selectedArcherySetup.getName() : "-";
mText.setValue("This is the \"Calc Sight\" fragment for: \n" + setupName);
}


public LiveData<String> getText() {
return mText;
}

+ 41
- 0
app/src/main/java/ch/spherIC/recurvebowsight/ui/equipment/EquipmentRecyclerViewAdapter.java Просмотреть файл

@@ -1,12 +1,18 @@
package ch.spherIC.recurvebowsight.ui.equipment;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import java.util.List;

import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.navigation.Navigation;
import androidx.recyclerview.widget.RecyclerView;
import ch.spherIC.recurvebowsight.R;
import ch.spherIC.recurvebowsight.databinding.FragmentEquipmentChooseBinding;
@@ -39,6 +45,41 @@ public class EquipmentRecyclerViewAdapter extends RecyclerView.Adapter<Equipment
holder.mSetupNameView.setText(getSetupName(archerySetup));
holder.mRiserNameView.setText(getRiserName(archerySetup));
holder.mSightNameView.setText(getSightName(archerySetup));

holder.itemView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
float alpha = 1.0f;
int horzMargin = v.getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin);
int vertMargin = v.getResources().getDimensionPixelSize(R.dimen.activity_vertical_margin);
if (event.getAction() == MotionEvent.ACTION_DOWN) {
alpha = 0.5f;
horzMargin = v.getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin_onclick);
vertMargin = v.getResources().getDimensionPixelSize(R.dimen.activity_vertical_margin_onclick);
}
View setupCardView = ((ConstraintLayout) v).findViewById(R.id.card_view_setup);
setupCardView.setAlpha(alpha);

setupCardView = ((ConstraintLayout) v).findViewById(R.id.card_view_border);
ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) setupCardView.getLayoutParams();
layoutParams.setMargins(horzMargin, vertMargin, horzMargin, vertMargin);
setupCardView.requestLayout();
return false;
}
});

holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(EquipmentRecyclerViewAdapter.this.context,
context.getString(R.string.caption_setup_choosen) + holder.archerySetup,
Toast.LENGTH_SHORT).show();

Bundle bundle = new Bundle();
bundle.putParcelable("setup", holder.archerySetup);
Navigation.findNavController(v).navigate(R.id.nav_calcsight, bundle);
}
});
}

private String getSetupName(IArcherySetup archerySetup) {

+ 9
- 6
app/src/main/res/layout/fragment_equipment_choose.xml Просмотреть файл

@@ -2,14 +2,17 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="144dp"
android:orientation="horizontal">

<androidx.cardview.widget.CardView
android:id="@+id/card_view_border"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/text_margin"
android:layout_marginBottom="@dimen/activity_horizontal_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_horizontal_margin"
android:backgroundTint="#54AAD1"
app:cardCornerRadius="20dp"
app:cardElevation="10dp"
@@ -89,8 +92,8 @@

<androidx.cardview.widget.CardView
android:id="@+id/setup_image_view"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
@@ -104,8 +107,8 @@

<ImageView
android:id="@+id/setup_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="64dp"
android:layout_height="64dp"
android:background="@drawable/side_nav_bar"
android:contentDescription="@string/menu_equipment"
app:layout_constraintStart_toStartOf="parent"

+ 1
- 0
app/src/main/res/values-de/strings.xml Просмотреть файл

@@ -15,4 +15,5 @@
<string name="menu_equipment_choose">Ausrüstung wählen</string>
<string name="menu_calculate_sight">Visiereinstellung berechnen</string>
<string name="caption_NoSelection">Keine Auswahl...</string>
<string name="caption_setup_choosen">"Gewählte Ausrüstung: "</string>
</resources>

+ 2
- 0
app/src/main/res/values/dimens.xml Просмотреть файл

@@ -2,6 +2,8 @@
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="activity_horizontal_margin_onclick">18dp</dimen>
<dimen name="activity_vertical_margin_onclick">18dp</dimen>
<dimen name="nav_header_vertical_spacing">8dp</dimen>
<dimen name="nav_header_height">176dp</dimen>
<dimen name="fab_margin">16dp</dimen>

+ 1
- 0
app/src/main/res/values/strings.xml Просмотреть файл

@@ -14,5 +14,6 @@
<string name="menu_equipment_choose">Choose Equipment</string>
<string name="menu_calculate_sight">Calculate Sight</string>
<string name="caption_NoSelection">No Selection...</string>
<string name="caption_setup_choosen">"Selected Setup: "</string>
<!-- TODO: Remove or change this placeholder text -->
</resources>

Загрузка…
Отмена
Сохранить