浏览代码

AutocomleteText view with Spinner behaivour

master
Flo Smilari 3 年前
父节点
当前提交
27e664b5f1
共有 21 个文件被更改,包括 268 次插入123 次删除
  1. 二进制
      .gradle/7.3.3/executionHistory/executionHistory.bin
  2. 二进制
      .gradle/7.3.3/executionHistory/executionHistory.lock
  3. 二进制
      .gradle/7.3.3/fileHashes/fileHashes.bin
  4. 二进制
      .gradle/7.3.3/fileHashes/fileHashes.lock
  5. 二进制
      .gradle/7.3.3/fileHashes/resourceHashesCache.bin
  6. 二进制
      .gradle/buildOutputCleanup/buildOutputCleanup.lock
  7. 29
    29
      .idea/workspace.xml
  8. 79
    27
      app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/ArcherySetupConfigurationActivity.java
  9. 37
    38
      app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/ArcherySetupConfigurationViewModel.java
  10. 9
    8
      app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/RiserConfigurationActivity.java
  11. 12
    10
      app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/SightConfigurationActivity.java
  12. 5
    5
      app/src/main/java/ch/spherIC/recurvebowsight/ui/equipment/EquipmentRecyclerViewAdapter.java
  13. 71
    0
      app/src/main/java/ch/spherIC/recurvebowsight/utilities/NoFilterArrayAdapter.java
  14. 12
    0
      app/src/main/java/ch/spherIC/recurvebowsight/utilities/PlatformUtils.java
  15. 3
    0
      app/src/main/res/layout/activity_equipment_configuration.xml
  16. 1
    0
      app/src/main/res/layout/activity_riser_configuration.xml
  17. 1
    0
      app/src/main/res/layout/activity_sight_configuration.xml
  18. 4
    4
      app/src/main/res/layout/fragment_equipment_choose.xml
  19. 3
    2
      app/src/main/res/layout/fragment_equipment_choose_list.xml
  20. 1
    0
      app/src/main/res/values-de/strings.xml
  21. 1
    0
      app/src/main/res/values/strings.xml

二进制
.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 查看文件


+ 29
- 29
.idea/workspace.xml 查看文件

</component> </component>
<component name="ChangeListManager"> <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$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/ArcherySetupConfigurationViewModel.java" 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 afterPath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/utilities/NoFilterArrayAdapter.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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/AndroidManifest.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/AndroidManifest.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/database/dao/ArcherySetupDao.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/database/dao/ArcherySetupDao.java" 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/CalculateSightParametersFragment.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/calcsight/CalculateSightParametersFragment.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/calcsight/CalculateSightParametersViewModel.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/EquipmentConfigurationActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/ArcherySetupConfigurationActivity.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/ArcherySetupConfigurationActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/ArcherySetupConfigurationActivity.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/ArcherySetupConfigurationViewModel.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/ArcherySetupConfigurationViewModel.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/RiserConfigurationActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/RiserConfigurationActivity.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/RiserConfigurationActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/RiserConfigurationActivity.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/SightConfigurationActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/SightConfigurationActivity.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/SightConfigurationActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/SightConfigurationActivity.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/equipment/AddEquipmentFragment.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/equipment/AddEquipmentFragment.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/java/ch/spherIC/recurvebowsight/utilities/PlatformUtils.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/utilities/PlatformUtils.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/res/layout/activity_equipment_configuration.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/res/layout/activity_equipment_configuration.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/app/src/main/res/layout/activity_equipment_configuration.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/res/layout/activity_equipment_configuration.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/res/layout/activity_riser_configuration.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/res/layout/activity_riser_configuration.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/res/layout/activity_sight_configuration.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/res/layout/activity_sight_configuration.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/app/src/main/res/layout/activity_sight_configuration.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/res/layout/activity_sight_configuration.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/res/layout/fragment_calcsight_parameters.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/res/layout/fragment_calcsight_parameters.xml" 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/layout/fragment_equipment_choose_list.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/res/layout/fragment_equipment_choose_list.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-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/strings.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/res/values/strings.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> </list>
<option name="RECENT_TEMPLATES"> <option name="RECENT_TEMPLATES">
<list> <list>
<option value="resourceFile" /> <option value="resourceFile" />
<option value="Class" />
<option value="valueResourceFile" /> <option value="valueResourceFile" />
<option value="Class" />
</list> </list>
</option> </option>
</component> </component>
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" /> <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" /> <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="RunOnceActivity.cidr.known.project.marker" value="true" /> <property name="RunOnceActivity.cidr.known.project.marker" value="true" />
<property name="android-custom-viewC:/Users/FSmilari/.gradle/caches/modules-2/files-2.1/androidx.appcompat/appcompat/1.4.2/a0a6b931c735952c318e94c90b0239966c500c52/appcompat-1.4.2-sources.jar!/androidx/appcompat/widget/AppCompatEditText.java_AppCompatEditText_DIMENSIONS" value="1080&#10;1920" />
<property name="android-custom-viewC:/Users/FSmilari/.gradle/caches/modules-2/files-2.1/androidx.appcompat/appcompat/1.4.2/a0a6b931c735952c318e94c90b0239966c500c52/appcompat-1.4.2-sources.jar!/androidx/appcompat/widget/AppCompatEditText.java_SELECTED" value="AppCompatEditText" />
<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_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/.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/.gradle/caches/modules-2/files-2.1/androidx.viewpager2/viewpager2/1.0.0/3c3569044e6969f1ee5c3aa03b08e6717a2d782f/viewpager2-1.0.0-sources.jar!/androidx/viewpager2/widget/ViewPager2.java_SELECTED" value="ViewPager2" /> <property name="android-custom-viewC:/Users/FSmilari/.gradle/caches/modules-2/files-2.1/androidx.viewpager2/viewpager2/1.0.0/3c3569044e6969f1ee5c3aa03b08e6717a2d782f/viewpager2-1.0.0-sources.jar!/androidx/viewpager2/widget/ViewPager2.java_SELECTED" value="ViewPager2" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="java-line"> <line-breakpoint enabled="true" suspend="THREAD" type="java-line">
<url>file://$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/RiserConfigurationActivity.java</url> <url>file://$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/RiserConfigurationActivity.java</url>
<line>98</line>
<line>99</line>
<option name="timeStamp" value="37" /> <option name="timeStamp" value="37" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="java-line"> <line-breakpoint enabled="true" suspend="THREAD" type="java-line">
<url>file://$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/RiserConfigurationActivity.java</url> <url>file://$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/RiserConfigurationActivity.java</url>
<line>172</line>
<line>173</line>
<option name="timeStamp" value="40" /> <option name="timeStamp" value="40" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="java-line"> <line-breakpoint enabled="true" suspend="THREAD" type="java-line">
<url>file://$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/RiserConfigurationActivity.java</url> <url>file://$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/RiserConfigurationActivity.java</url>
<line>128</line>
<line>129</line>
<option name="timeStamp" value="42" /> <option name="timeStamp" value="42" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="java-line"> <line-breakpoint enabled="true" suspend="THREAD" type="java-line">
<url>file://$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/SightConfigurationActivity.java</url> <url>file://$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/SightConfigurationActivity.java</url>
<line>73</line>
<line>74</line>
<option name="timeStamp" value="43" /> <option name="timeStamp" value="43" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="java-line"> <line-breakpoint enabled="true" suspend="THREAD" type="java-line">
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="java-line"> <line-breakpoint enabled="true" suspend="THREAD" type="java-line">
<url>file://$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/ArcherySetupConfigurationActivity.java</url> <url>file://$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/ArcherySetupConfigurationActivity.java</url>
<line>94</line>
<option name="timeStamp" value="48" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="java-line">
<url>file://$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/ArcherySetupConfigurationActivity.java</url>
<line>88</line>
<line>92</line>
<option name="timeStamp" value="50" /> <option name="timeStamp" value="50" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="java-line"> <line-breakpoint enabled="true" suspend="THREAD" type="java-line">
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="java-line"> <line-breakpoint enabled="true" suspend="THREAD" type="java-line">
<url>file://$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/ArcherySetupConfigurationActivity.java</url> <url>file://$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/ArcherySetupConfigurationActivity.java</url>
<line>149</line>
<line>186</line>
<option name="timeStamp" value="53" /> <option name="timeStamp" value="53" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="java-line"> <line-breakpoint enabled="true" suspend="THREAD" type="java-line">
<url>file://$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/ArcherySetupConfigurationActivity.java</url> <url>file://$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/ArcherySetupConfigurationActivity.java</url>
<line>156</line>
<line>208</line>
<option name="timeStamp" value="54" /> <option name="timeStamp" value="54" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="java-line">
<url>file://$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/SightConfigurationActivity.java</url>
<line>120</line>
<option name="timeStamp" value="55" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="java-line">
<url>file://$PROJECT_DIR$/app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/ArcherySetupConfigurationActivity.java</url>
<line>190</line>
<option name="timeStamp" value="56" />
</line-breakpoint>
</breakpoints> </breakpoints>
</breakpoint-manager> </breakpoint-manager>
<watches-manager> <watches-manager>
<watch expression="this" /> <watch expression="this" />
<watch expression="aArcherySetup.getRiser()" language="JAVA" /> <watch expression="aArcherySetup.getRiser()" language="JAVA" />
<watch expression="this.mArcherySetup.getValue().getRiserName()" language="JAVA" /> <watch expression="this.mArcherySetup.getValue().getRiserName()" language="JAVA" />
<watch expression="this.binding.asBowPulloutTxt.getText().toString()" language="JAVA" />
</configuration> </configuration>
</watches-manager> </watches-manager>
</component> </component>

+ 79
- 27
app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/ArcherySetupConfigurationActivity.java 查看文件

*/ */
package ch.spherIC.recurvebowsight.ui.configuration; package ch.spherIC.recurvebowsight.ui.configuration;


import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import android.view.MenuItem; import android.view.MenuItem;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import ch.spherIC.recurvebowsight.database.dao.RiserDao; import ch.spherIC.recurvebowsight.database.dao.RiserDao;
import ch.spherIC.recurvebowsight.database.dao.SightDao; import ch.spherIC.recurvebowsight.database.dao.SightDao;
import ch.spherIC.recurvebowsight.databinding.ActivityEquipmentConfigurationBinding; import ch.spherIC.recurvebowsight.databinding.ActivityEquipmentConfigurationBinding;
import ch.spherIC.recurvebowsight.model.ArcherySetup;
import ch.spherIC.recurvebowsight.model.IArcherySetup; import ch.spherIC.recurvebowsight.model.IArcherySetup;
import ch.spherIC.recurvebowsight.model.IRiser; import ch.spherIC.recurvebowsight.model.IRiser;
import ch.spherIC.recurvebowsight.model.ISight; import ch.spherIC.recurvebowsight.model.ISight;
import ch.spherIC.recurvebowsight.utilities.NoFilterArrayAdapter;
import ch.spherIC.recurvebowsight.utilities.PlatformUtils; import ch.spherIC.recurvebowsight.utilities.PlatformUtils;


public class ArcherySetupConfigurationActivity extends AppCompatActivity { public class ArcherySetupConfigurationActivity extends AppCompatActivity {
DecimalFormat dF2 = new DecimalFormat("#.##"); DecimalFormat dF2 = new DecimalFormat("#.##");
DecimalFormat dF3 = new DecimalFormat("#.###"); DecimalFormat dF3 = new DecimalFormat("#.###");
this.archerySetupConfigurationViewModel.getName().observe(this, name -> this.binding.asLabelTxt.setText(name)); this.archerySetupConfigurationViewModel.getName().observe(this, name -> this.binding.asLabelTxt.setText(name));
this.archerySetupConfigurationViewModel.getSight().observe(this, sight -> this.binding.asSightSelectionTxt.setText(sight != null ? sight.toString() : ""));
this.archerySetupConfigurationViewModel.getRiser().observe(this, riser -> this.binding.asRiserSelectionTxt.setText(riser != null ? riser.toString() : ""));
this.archerySetupConfigurationViewModel.getSight().observe(this, sight -> this.binding.asSightSelectionTxt.setText(sight != null ? sight.toString() : "", false));
this.archerySetupConfigurationViewModel.getRiser().observe(this, riser -> this.binding.asRiserSelectionTxt.setText(riser != null ? riser.toString() : "", false));
this.archerySetupConfigurationViewModel.getArrowDiameter().observe(this, arwDiam -> this.binding.asArrowDiameterTxt.setText(arwDiam != null ? dF.format(arwDiam) : "")); this.archerySetupConfigurationViewModel.getArrowDiameter().observe(this, arwDiam -> this.binding.asArrowDiameterTxt.setText(arwDiam != null ? dF.format(arwDiam) : ""));
this.archerySetupConfigurationViewModel.getArrowCw().observe(this, arwCw -> this.binding.asArrowCWTxt.setText(arwCw != null ? dF.format(arwCw) : "")); this.archerySetupConfigurationViewModel.getArrowCw().observe(this, arwCw -> this.binding.asArrowCWTxt.setText(arwCw != null ? dF.format(arwCw) : ""));
this.archerySetupConfigurationViewModel.getArrowWeight().observe(this, arwWeight -> this.binding.asArrowWeightTxt.setText(arwWeight != null ? dF.format(arwWeight) : "")); this.archerySetupConfigurationViewModel.getArrowWeight().observe(this, arwWeight -> this.binding.asArrowWeightTxt.setText(arwWeight != null ? dF.format(arwWeight) : ""));
textViewAS.setOnItemClickListener((parent, view, position, id) -> { textViewAS.setOnItemClickListener((parent, view, position, id) -> {
IArcherySetup selectedArcherySetup = (IArcherySetup) textViewAS.getAdapter().getItem(position); IArcherySetup selectedArcherySetup = (IArcherySetup) textViewAS.getAdapter().getItem(position);
if (selectedArcherySetup != null) { if (selectedArcherySetup != null) {
archerySetupConfigurationViewModel.setEquipment(selectedArcherySetup);
archerySetupConfigurationViewModel.setArcherySetup(selectedArcherySetup);
} }
}); });

/* AutoCompleteTextView textViewSight = findViewById(R.id.asSightSelectionTxt);
textViewAS.setOnItemClickListener((parent, view, position, id) -> {
ISight selectedSight = (ISight) textViewSight.getAdapter().getItem(position);
archerySetupConfigurationViewModel.setSight(selectedSight);
});

AutoCompleteTextView textViewRiser = findViewById(R.id.asRiserSelectionTxt);
textViewAS.setOnItemClickListener((parent, view, position, id) -> {
IRiser selectedRiser = (IRiser) textViewRiser.getAdapter().getItem(position);
if (selectedRiser != null) {
// sightConfigurationViewModel.setSight(selectedRiser);
}
});*/
} }


private void addButtonListeners() { private void addButtonListeners() {
Button newButton = findViewById(R.id.archerystpcfg_button_new); Button newButton = findViewById(R.id.archerystpcfg_button_new);
newButton.setOnClickListener(v -> addNewSight());
newButton.setOnClickListener(v -> addNewArcherySetup());


Button deleteButton = findViewById(R.id.archerystpcfg_button_delete); Button deleteButton = findViewById(R.id.archerystpcfg_button_delete);
deleteButton.setOnClickListener(v -> deleteSight());
deleteButton.setOnClickListener(v -> deleteArcherySetup());


Button saveButton = findViewById(R.id.archerystpcfg_button_save); Button saveButton = findViewById(R.id.archerystpcfg_button_save);
saveButton.setOnClickListener(v -> saveSightConfiguration());
saveButton.setOnClickListener(v -> saveArcherySetupConfiguration());
} }


private void loadSightsAndRisers() { private void loadSightsAndRisers() {
List<ISight> sights = SightDao.getInstance().loadAll(); List<ISight> sights = SightDao.getInstance().loadAll();
this.archerySetupConfigurationViewModel.setAllSights(sights); this.archerySetupConfigurationViewModel.setAllSights(sights);
ArrayAdapter<ISight> sightsAdapter = new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, sights);
ArrayAdapter<ISight> sightsAdapter = new NoFilterArrayAdapter<ISight>(this, android.R.layout.simple_dropdown_item_1line, sights);
AutoCompleteTextView textViewSights = this.binding.asSightSelectionTxt; AutoCompleteTextView textViewSights = this.binding.asSightSelectionTxt;
textViewSights.setAdapter(sightsAdapter); textViewSights.setAdapter(sightsAdapter);
textViewSights.invalidate(); textViewSights.invalidate();


List<IRiser> risers = RiserDao.getInstance().loadAll(); List<IRiser> risers = RiserDao.getInstance().loadAll();
this.archerySetupConfigurationViewModel.setAllRisers(risers); this.archerySetupConfigurationViewModel.setAllRisers(risers);
ArrayAdapter<IRiser> riserAdapter = new ArrayAdapter<IRiser>(this, android.R.layout.simple_dropdown_item_1line, risers);
ArrayAdapter<IRiser> riserAdapter = new NoFilterArrayAdapter<IRiser>(this, android.R.layout.simple_dropdown_item_1line, risers);
AutoCompleteTextView textViewRisers = binding.asRiserSelectionTxt; AutoCompleteTextView textViewRisers = binding.asRiserSelectionTxt;
textViewRisers.setAdapter(riserAdapter); textViewRisers.setAdapter(riserAdapter);
textViewRisers.invalidate(); textViewRisers.invalidate();


private void loadArcherySetups() { private void loadArcherySetups() {
List<IArcherySetup> archerySetups = ArcherySetupDao.getInstance().loadAll(); List<IArcherySetup> archerySetups = ArcherySetupDao.getInstance().loadAll();
ArrayAdapter<IArcherySetup> archerySetupsAdapter = new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, archerySetups);
ArrayAdapter<IArcherySetup> archerySetupsAdapter = new NoFilterArrayAdapter<IArcherySetup>(this, android.R.layout.simple_dropdown_item_1line, archerySetups);
AutoCompleteTextView textViewASs = this.binding.asArcherySetupSelectionTxt; AutoCompleteTextView textViewASs = this.binding.asArcherySetupSelectionTxt;
textViewASs.setAdapter(archerySetupsAdapter); textViewASs.setAdapter(archerySetupsAdapter);
textViewASs.invalidate(); textViewASs.invalidate();
} }


private void addNewSight() {
private void addNewArcherySetup() {
IArcherySetup newArcherySetup = new ArcherySetup(0, "", null, null, null, null,
null, null, null, null, null, null, null,
null, null, null, null, null);
this.archerySetupConfigurationViewModel.setArcherySetup(newArcherySetup);
String strMandatory = getString(R.string.caption_mandatory);
this.binding.asArcherySetupSelectionTxt.setText(null, false);
this.binding.asLabelTxt.setError(strMandatory);
this.binding.asRiserSelectionTxt.setError(strMandatory);
this.binding.asSightSelectionTxt.setError(strMandatory);
this.binding.asArrowCWTxt.setError(strMandatory);
this.binding.asArrowWeightTxt.setError(strMandatory);
this.binding.asArrowV0Txt.setError(strMandatory);
this.binding.asArrowNockHeightTxt.setError(strMandatory);
this.binding.asTargetCenterHeightTxt.setError(strMandatory);
this.binding.asBowPulloutTxt.setError(strMandatory);
this.binding.asHNATxt.setError(strMandatory);
this.binding.asNockRaisingTxt.setError(strMandatory);
this.binding.asBraceHeightTxt.setError(strMandatory);
this.binding.asDeltaTimeTxt.setError(strMandatory);
this.binding.asCalcPrecisionTxt.setError(strMandatory);
this.binding.asSightVertScaleMiddleTxt.setError(strMandatory);
this.binding.asSightHorzSettingTxt.setError(strMandatory);

AutoCompleteTextView textView = binding.asArcherySetupSelectionTxt;
((ArrayAdapter<IArcherySetup>) textView.getAdapter()).insert(newArcherySetup, 0);
textView.setAdapter((ArrayAdapter<IRiser>) textView.getAdapter());
textView.setSelection(0);
} }


private void deleteSight() {
private void deleteArcherySetup() {
IArcherySetup lArcherySetup = this.archerySetupConfigurationViewModel.getArcherySetup().getValue();

if (lArcherySetup != null) {
AlertDialog dlg = PlatformUtils.getDeleteConfirmDialog(this, lArcherySetup.toString(), new DialogInterface.OnClickListener() {
@Override
public void onClick(final DialogInterface dialog, final int which) {
String message = String.format(getString(R.string.caption_Cfg_DeleteSuccessful), lArcherySetup);
try {
ArcherySetupDao.getInstance().delete(lArcherySetup);
loadArcherySetups();
archerySetupConfigurationViewModel.setArcherySetup(null);
binding.asArcherySetupSelectionTxt.setText(null, false);
} catch (Exception e) {
message = getString(R.string.caption_Cfg_DeleteNotPossible);
}
PlatformUtils.toast(ArcherySetupConfigurationActivity.this, message).show();
}
});
dlg.show();
}
} }


private void saveSightConfiguration() {
private void saveArcherySetupConfiguration() {
if (!validateInputs()) { if (!validateInputs()) {
return; return;
} }
this.archerySetupConfigurationViewModel.setName(this.binding.asLabelTxt.getText().toString()); this.archerySetupConfigurationViewModel.setName(this.binding.asLabelTxt.getText().toString());
this.archerySetupConfigurationViewModel.setSight(this.archerySetupConfigurationViewModel.findSightByName(this.binding.asSightSelectionTxt.getText().toString())); this.archerySetupConfigurationViewModel.setSight(this.archerySetupConfigurationViewModel.findSightByName(this.binding.asSightSelectionTxt.getText().toString()));
this.archerySetupConfigurationViewModel.setRiser(this.archerySetupConfigurationViewModel.findRiserByName(this.binding.asRiserSelectionTxt.getText().toString())); this.archerySetupConfigurationViewModel.setRiser(this.archerySetupConfigurationViewModel.findRiserByName(this.binding.asRiserSelectionTxt.getText().toString()));
this.archerySetupConfigurationViewModel.setArrowDiameter(PlatformUtils.parseDouble(this.binding.asArrowDiameterTxt.getText().toString()));
this.archerySetupConfigurationViewModel.setArrowCw(PlatformUtils.parseDouble(this.binding.asArrowCWTxt.getText().toString()));
this.archerySetupConfigurationViewModel.setArrowWeight(PlatformUtils.parseDouble(this.binding.asArrowWeightTxt.getText().toString()));
this.archerySetupConfigurationViewModel.setArrowV0(PlatformUtils.parseDouble(this.binding.asArrowV0Txt.getText().toString()));
this.archerySetupConfigurationViewModel.setArrowNockHeight(PlatformUtils.parseDouble(this.binding.asArrowNockHeightTxt.getText().toString()));
this.archerySetupConfigurationViewModel.setBowPullout(PlatformUtils.parseDouble(this.binding.asBowPulloutTxt.getText().toString()));
this.archerySetupConfigurationViewModel.setHNA(PlatformUtils.parseDouble(this.binding.asHNATxt.getText().toString()));
this.archerySetupConfigurationViewModel.setNockRaising(PlatformUtils.parseDouble(this.binding.asNockRaisingTxt.getText().toString()));
this.archerySetupConfigurationViewModel.setBraceHeight(PlatformUtils.parseDouble(this.binding.asBraceHeightTxt.getText().toString()));
this.archerySetupConfigurationViewModel.setTargetCenterHeight(PlatformUtils.parseDouble(this.binding.asTargetCenterHeightTxt.getText().toString()));
this.archerySetupConfigurationViewModel.setDeltaTime(PlatformUtils.parseDouble(this.binding.asDeltaTimeTxt.getText().toString()));
this.archerySetupConfigurationViewModel.setCalcPrecision(PlatformUtils.parseDouble(this.binding.asCalcPrecisionTxt.getText().toString()));
this.archerySetupConfigurationViewModel.setSightVertSkalaMiddle(PlatformUtils.parseDouble(this.binding.asSightVertScaleMiddleTxt.getText().toString()));
this.archerySetupConfigurationViewModel.setSightHorzSetting(PlatformUtils.parseDouble(this.binding.asSightHorzSettingTxt.getText().toString()));



IArcherySetup lArcherySetup = this.archerySetupConfigurationViewModel.getArcherySetup().getValue(); IArcherySetup lArcherySetup = this.archerySetupConfigurationViewModel.getArcherySetup().getValue();
if (lArcherySetup.getId() > 0) { if (lArcherySetup.getId() > 0) {
ArcherySetupDao.getInstance().update(lArcherySetup); ArcherySetupDao.getInstance().update(lArcherySetup);
//TODO: SHOW UPDATE INFO TOAST
PlatformUtils.toast(ArcherySetupConfigurationActivity.this, String.format(getString(R.string.caption_Cfg_UpdateSuccessful), lArcherySetup)).show();
} else { } else {
lArcherySetup = ArcherySetupDao.getInstance().insert(lArcherySetup); lArcherySetup = ArcherySetupDao.getInstance().insert(lArcherySetup);
loadArcherySetups(); loadArcherySetups();

+ 37
- 38
app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/ArcherySetupConfigurationViewModel.java 查看文件

this.mBraceHeight.setValue(null); this.mBraceHeight.setValue(null);
} }


public void setEquipment(IArcherySetup aArcherySetup) {
public void setArcherySetup(IArcherySetup aArcherySetup) {
this.mArcherySetup.setValue(aArcherySetup); this.mArcherySetup.setValue(aArcherySetup);
this.mName.setValue(aArcherySetup != null ? aArcherySetup.getName() : ""); this.mName.setValue(aArcherySetup != null ? aArcherySetup.getName() : "");
this.mSight.setValue(aArcherySetup != null ? aArcherySetup.getSight() : null); this.mSight.setValue(aArcherySetup != null ? aArcherySetup.getSight() : null);
} }


public void setName(String nameText) { public void setName(String nameText) {
if (this.mName.getValue() != null) {
if (this.mArcherySetup.getValue() != null) {
this.mArcherySetup.getValue().setName(nameText); this.mArcherySetup.getValue().setName(nameText);
} }
this.mName.setValue(nameText); this.mName.setValue(nameText);
} }


public void setSight(ISight aSight) { public void setSight(ISight aSight) {
if (this.mSight.getValue() != null) {
if (this.mArcherySetup.getValue() != null) {
this.mArcherySetup.getValue().setSight(aSight); this.mArcherySetup.getValue().setSight(aSight);
} }
this.mSight.setValue(aSight); this.mSight.setValue(aSight);
} }


public void setRiser(IRiser aRiser) { public void setRiser(IRiser aRiser) {
if (this.mRiser.getValue() != null) {
if (this.mArcherySetup.getValue() != null) {
this.mArcherySetup.getValue().setRiser(aRiser); this.mArcherySetup.getValue().setRiser(aRiser);
} }
this.mRiser.setValue(aRiser); this.mRiser.setValue(aRiser);
} }


public void setArrowDiameter(Double mArrowDiameter) { public void setArrowDiameter(Double mArrowDiameter) {
if (this.mArrowDiameter.getValue() != null) {
if (this.mArcherySetup.getValue() != null) {
this.mArcherySetup.getValue().setArrowDiameter(mArrowDiameter); this.mArcherySetup.getValue().setArrowDiameter(mArrowDiameter);
} }
this.mArrowDiameter.setValue(mArrowDiameter); this.mArrowDiameter.setValue(mArrowDiameter);
} }


public void setArrowCw(Double mArrowCw) { public void setArrowCw(Double mArrowCw) {
if (this.mArrowCw.getValue() != null) {
if (this.mArcherySetup.getValue() != null) {
this.mArcherySetup.getValue().setArrowCw(mArrowCw); this.mArcherySetup.getValue().setArrowCw(mArrowCw);
} }
this.mArrowCw.setValue(mArrowCw); this.mArrowCw.setValue(mArrowCw);
} }


public void setArrowWeight(Double mArrowWeight) { public void setArrowWeight(Double mArrowWeight) {
if (this.mArrowWeight.getValue() != null) {
if (this.mArcherySetup.getValue() != null) {
this.mArcherySetup.getValue().setArrowWeight(mArrowWeight); this.mArcherySetup.getValue().setArrowWeight(mArrowWeight);
} }
this.mArrowWeight.setValue(mArrowWeight); this.mArrowWeight.setValue(mArrowWeight);
} }


public void setArrowV0(Double mArrowV0) { public void setArrowV0(Double mArrowV0) {
if (this.mArrowV0.getValue() != null) {
if (this.mArcherySetup.getValue() != null) {
this.mArcherySetup.getValue().setArrowV0(mArrowV0); this.mArcherySetup.getValue().setArrowV0(mArrowV0);
} }
this.mArrowV0.setValue(mArrowV0); this.mArrowV0.setValue(mArrowV0);
} }


public void setTargetCenterHeight(Double mTargetCenterHeight) { public void setTargetCenterHeight(Double mTargetCenterHeight) {
if (this.mTargetCenterHeight.getValue() != null) {
if (this.mArcherySetup.getValue() != null) {
this.mArcherySetup.getValue().setTargetCenterHeight(mTargetCenterHeight); this.mArcherySetup.getValue().setTargetCenterHeight(mTargetCenterHeight);
} }
this.mTargetCenterHeight.setValue(mTargetCenterHeight); this.mTargetCenterHeight.setValue(mTargetCenterHeight);
} }


public void setArrowNockHeight(Double mArrowNockHeight) { public void setArrowNockHeight(Double mArrowNockHeight) {
if (this.mArrowNockHeight.getValue() != null) {
if (this.mArcherySetup.getValue() != null) {
this.mArcherySetup.getValue().setArrowNockHeight(mArrowNockHeight); this.mArcherySetup.getValue().setArrowNockHeight(mArrowNockHeight);
} }
this.mArrowNockHeight.setValue(mArrowNockHeight); this.mArrowNockHeight.setValue(mArrowNockHeight);
} }


public void setBowPullout(Double mBowPullout) { public void setBowPullout(Double mBowPullout) {
if (this.mBowPullout.getValue() != null) {
if (this.mArcherySetup.getValue() != null) {
this.mArcherySetup.getValue().setBowPullout(mBowPullout); this.mArcherySetup.getValue().setBowPullout(mBowPullout);
} }
this.mBowPullout.setValue(mBowPullout); this.mBowPullout.setValue(mBowPullout);
} }


public void setHNA(Double mHNA) { public void setHNA(Double mHNA) {
if (this.mHNA.getValue() != null) {
if (this.mArcherySetup.getValue() != null) {
this.mArcherySetup.getValue().setHNA(mHNA); this.mArcherySetup.getValue().setHNA(mHNA);
} }
this.mHNA.setValue(mHNA); this.mHNA.setValue(mHNA);
} }


public void setDeltaTime(Double mDeltaTime) { public void setDeltaTime(Double mDeltaTime) {
if (this.mDeltaTime.getValue() != null) {
if (this.mArcherySetup.getValue() != null) {
this.mArcherySetup.getValue().setDeltaTime(mDeltaTime); this.mArcherySetup.getValue().setDeltaTime(mDeltaTime);
} }
this.mDeltaTime.setValue(mDeltaTime); this.mDeltaTime.setValue(mDeltaTime);
} }


public void setCalcPrecision(Double mCalcPrecision) { public void setCalcPrecision(Double mCalcPrecision) {
if (this.mCalcPrecision.getValue() != null) {
if (this.mArcherySetup.getValue() != null) {
this.mArcherySetup.getValue().setCalcPrecision(mCalcPrecision); this.mArcherySetup.getValue().setCalcPrecision(mCalcPrecision);
} }
this.mCalcPrecision.setValue(mCalcPrecision); this.mCalcPrecision.setValue(mCalcPrecision);
} }


public void setSightVertSkalaMiddle(Double mSightVertSkalaMiddle) { public void setSightVertSkalaMiddle(Double mSightVertSkalaMiddle) {
if (this.mSightVertSkalaMiddle.getValue() != null) {
if (this.mArcherySetup.getValue() != null) {
this.mArcherySetup.getValue().setSightVertSkalaMiddle(mSightVertSkalaMiddle); this.mArcherySetup.getValue().setSightVertSkalaMiddle(mSightVertSkalaMiddle);
} }
this.mSightVertSkalaMiddle.setValue(mSightVertSkalaMiddle); this.mSightVertSkalaMiddle.setValue(mSightVertSkalaMiddle);
} }


public void setSightHorzSetting(Double mSightHorzSetting) { public void setSightHorzSetting(Double mSightHorzSetting) {
if (this.mSightHorzSetting.getValue() != null) {
if (this.mArcherySetup.getValue() != null) {
this.mArcherySetup.getValue().setSightHorzSetting(mSightHorzSetting); this.mArcherySetup.getValue().setSightHorzSetting(mSightHorzSetting);
} }
this.mSightHorzSetting.setValue(mSightHorzSetting); this.mSightHorzSetting.setValue(mSightHorzSetting);
} }


public void setNockRaising(Double mNockRaising) { public void setNockRaising(Double mNockRaising) {
if (this.mNockRaising.getValue() != null) {
if (this.mArcherySetup.getValue() != null) {
this.mArcherySetup.getValue().setNockRaising(mNockRaising); this.mArcherySetup.getValue().setNockRaising(mNockRaising);
} }
this.mNockRaising.setValue(mNockRaising); this.mNockRaising.setValue(mNockRaising);
} }


public void setBraceHeight(Double mBraceHeight) { public void setBraceHeight(Double mBraceHeight) {
if (this.mBraceHeight.getValue() != null) {
if (this.mArcherySetup.getValue() != null) {
this.mArcherySetup.getValue().setBraceHeight(mBraceHeight); this.mArcherySetup.getValue().setBraceHeight(mBraceHeight);
} }
this.mBraceHeight.setValue(mBraceHeight); this.mBraceHeight.setValue(mBraceHeight);
this.allRisers = allRisers; this.allRisers = allRisers;
} }


public IRiser findRiserByName(String name) {
for (IRiser riser : this.allRisers) {
if (riser.toString().equals(name)) {
return riser;
}
}
return null;
}

public ISight findSightByName(String name) {
for (ISight sight : this.allSights) {
if (sight.toString().equals(name)) {
return sight;
}
}
return null;
}


public LiveData<Double> getBowPullout() { public LiveData<Double> getBowPullout() {
return mBowPullout; return mBowPullout;
} }
public LiveData<Double> getBraceHeight() { public LiveData<Double> getBraceHeight() {
return mBraceHeight; return mBraceHeight;
} }
}

public IRiser findRiserByName(String name) {
for (IRiser riser : this.allRisers) {
if (riser.toString().equals(name)) {
return riser;
}
}
return null;
}

public ISight findSightByName(String name) {
for (ISight sight : this.allSights) {
if (sight.toString().equals(name)) {
return sight;
}
}
return null;
}
}

+ 9
- 8
app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/RiserConfigurationActivity.java 查看文件

import ch.spherIC.recurvebowsight.databinding.ActivityRiserConfigurationBinding; import ch.spherIC.recurvebowsight.databinding.ActivityRiserConfigurationBinding;
import ch.spherIC.recurvebowsight.model.IRiser; import ch.spherIC.recurvebowsight.model.IRiser;
import ch.spherIC.recurvebowsight.model.Riser; import ch.spherIC.recurvebowsight.model.Riser;
import ch.spherIC.recurvebowsight.utilities.NoFilterArrayAdapter;
import ch.spherIC.recurvebowsight.utilities.PlatformUtils; import ch.spherIC.recurvebowsight.utilities.PlatformUtils;


public class RiserConfigurationActivity extends AppCompatActivity { public class RiserConfigurationActivity extends AppCompatActivity {


private void loadRisers() { private void loadRisers() {
List<IRiser> risers = RiserDao.getInstance().loadAll(); List<IRiser> risers = RiserDao.getInstance().loadAll();
ArrayAdapter<IRiser> adapter = new ArrayAdapter<IRiser>(this, android.R.layout.simple_dropdown_item_1line, risers);
ArrayAdapter<IRiser> adapter = new NoFilterArrayAdapter<IRiser>(this, android.R.layout.simple_dropdown_item_1line, risers);
AutoCompleteTextView textView = binding.riserSelectionTxt; AutoCompleteTextView textView = binding.riserSelectionTxt;
textView.setAdapter(adapter); textView.setAdapter(adapter);
textView.invalidate(); textView.invalidate();
IRiser newRiser = new Riser(0, "", "", null, null, null); IRiser newRiser = new Riser(0, "", "", null, null, null);
this.riserConfigurationViewModel.setRiser(newRiser); this.riserConfigurationViewModel.setRiser(newRiser);
String strMandatory = getString(R.string.caption_mandatory); String strMandatory = getString(R.string.caption_mandatory);
this.binding.riserSelectionTxt.setText(null);
this.binding.riserSelectionTxt.setText(null, false);
this.binding.rcManufacturerTxt.setError(strMandatory); this.binding.rcManufacturerTxt.setError(strMandatory);
this.binding.rcModelTxt.setError(strMandatory); this.binding.rcModelTxt.setError(strMandatory);
this.binding.rcSizeTxt.setError(strMandatory); this.binding.rcSizeTxt.setError(strMandatory);
} }
this.riserConfigurationViewModel.setManufacturerText(this.binding.rcManufacturerTxt.getText().toString()); this.riserConfigurationViewModel.setManufacturerText(this.binding.rcManufacturerTxt.getText().toString());
this.riserConfigurationViewModel.setModelText(this.binding.rcModelTxt.getText().toString()); this.riserConfigurationViewModel.setModelText(this.binding.rcModelTxt.getText().toString());
this.riserConfigurationViewModel.setSize(Double.parseDouble(this.binding.rcSizeTxt.getText().toString()));
this.riserConfigurationViewModel.setVVisH(Double.parseDouble(this.binding.rcVvisHTxt.getText().toString()));
this.riserConfigurationViewModel.setVVisV(Double.parseDouble(this.binding.rcVvisVTxt.getText().toString()));
this.riserConfigurationViewModel.setSize(PlatformUtils.parseDouble(this.binding.rcSizeTxt.getText().toString()));
this.riserConfigurationViewModel.setVVisH(PlatformUtils.parseDouble(this.binding.rcVvisHTxt.getText().toString()));
this.riserConfigurationViewModel.setVVisV(PlatformUtils.parseDouble(this.binding.rcVvisVTxt.getText().toString()));


IRiser lRiser = this.riserConfigurationViewModel.getRiser().getValue(); IRiser lRiser = this.riserConfigurationViewModel.getRiser().getValue();
if (lRiser.getId() > 0) { if (lRiser.getId() > 0) {
RiserDao.getInstance().update(lRiser); RiserDao.getInstance().update(lRiser);
//TODO: SHOW UPDATE INFO TOAST
PlatformUtils.toast(RiserConfigurationActivity.this, String.format(getString(R.string.caption_Cfg_UpdateSuccessful), lRiser)).show();
} else { } else {
lRiser = RiserDao.getInstance().insert(lRiser); lRiser = RiserDao.getInstance().insert(lRiser);
loadRisers(); loadRisers();
AutoCompleteTextView textView = this.binding.riserSelectionTxt; AutoCompleteTextView textView = this.binding.riserSelectionTxt;
final int position = ((ArrayAdapter<IRiser>) textView.getAdapter()).getPosition(lRiser); final int position = ((ArrayAdapter<IRiser>) textView.getAdapter()).getPosition(lRiser);
textView.setListSelection(position); textView.setListSelection(position);
textView.setText(lRiser.toString());
textView.setText(lRiser.toString(), false);
((ArrayAdapter<IRiser>) textView.getAdapter()).getFilter().filter(null); ((ArrayAdapter<IRiser>) textView.getAdapter()).getFilter().filter(null);
PlatformUtils.toast(RiserConfigurationActivity.this, String.format(getString(R.string.caption_Cfg_SaveSuccessful), lRiser)).show(); PlatformUtils.toast(RiserConfigurationActivity.this, String.format(getString(R.string.caption_Cfg_SaveSuccessful), lRiser)).show();
} }
RiserDao.getInstance().delete(lRiser); RiserDao.getInstance().delete(lRiser);
loadRisers(); loadRisers();
riserConfigurationViewModel.setRiser(null); riserConfigurationViewModel.setRiser(null);
binding.riserSelectionTxt.setText(null);
binding.riserSelectionTxt.setText(null, false);
} catch (Exception e) { } catch (Exception e) {
message = getString(R.string.caption_Cfg_DeleteNotPossible); message = getString(R.string.caption_Cfg_DeleteNotPossible);
} }

+ 12
- 10
app/src/main/java/ch/spherIC/recurvebowsight/ui/configuration/SightConfigurationActivity.java 查看文件

import ch.spherIC.recurvebowsight.databinding.ActivitySightConfigurationBinding; import ch.spherIC.recurvebowsight.databinding.ActivitySightConfigurationBinding;
import ch.spherIC.recurvebowsight.model.ISight; import ch.spherIC.recurvebowsight.model.ISight;
import ch.spherIC.recurvebowsight.model.Sight; import ch.spherIC.recurvebowsight.model.Sight;
import ch.spherIC.recurvebowsight.utilities.NoFilterArrayAdapter;
import ch.spherIC.recurvebowsight.utilities.PlatformUtils; import ch.spherIC.recurvebowsight.utilities.PlatformUtils;


public class SightConfigurationActivity extends AppCompatActivity { public class SightConfigurationActivity extends AppCompatActivity {


private void loadSights() { private void loadSights() {
List<ISight> sights = SightDao.getInstance().loadAll(); List<ISight> sights = SightDao.getInstance().loadAll();
ArrayAdapter<ISight> adapter = new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, sights);
ArrayAdapter<ISight> adapter = new NoFilterArrayAdapter<ISight>(this, android.R.layout.simple_dropdown_item_1line, sights);
AutoCompleteTextView textView = this.binding.sightSelectionTxt; AutoCompleteTextView textView = this.binding.sightSelectionTxt;
textView.setAdapter(adapter); textView.setAdapter(adapter);
textView.invalidate(); textView.invalidate();
ISight newSight = new Sight(0, "", "", null, null, null, null, null, null); ISight newSight = new Sight(0, "", "", null, null, null, null, null, null);
this.sightConfigurationViewModel.setSight(newSight); this.sightConfigurationViewModel.setSight(newSight);
String strMandatory = getString(R.string.caption_mandatory); String strMandatory = getString(R.string.caption_mandatory);
this.binding.sightSelectionTxt.setText(null);
this.binding.sightSelectionTxt.setText(null, false);
this.binding.scManufacturerTxt.setError(strMandatory); this.binding.scManufacturerTxt.setError(strMandatory);
this.binding.scModelTxt.setError(strMandatory); this.binding.scModelTxt.setError(strMandatory);
this.binding.scaVTxt.setError(strMandatory); this.binding.scaVTxt.setError(strMandatory);
} }
this.sightConfigurationViewModel.setManufacturerText(this.binding.scManufacturerTxt.getText().toString()); this.sightConfigurationViewModel.setManufacturerText(this.binding.scManufacturerTxt.getText().toString());
this.sightConfigurationViewModel.setModelText(this.binding.scModelTxt.getText().toString()); this.sightConfigurationViewModel.setModelText(this.binding.scModelTxt.getText().toString());
this.sightConfigurationViewModel.setAH(Double.parseDouble(this.binding.scaHTxt.getText().toString()));
this.sightConfigurationViewModel.setAV(Double.parseDouble(this.binding.scaVTxt.getText().toString()));
this.sightConfigurationViewModel.setAH(PlatformUtils.parseDouble(this.binding.scaHTxt.getText().toString()));
this.sightConfigurationViewModel.setAV(PlatformUtils.parseDouble(this.binding.scaVTxt.getText().toString()));
this.sightConfigurationViewModel.setHeVis(this.binding.sccHeVSTxt.getText().toString()); this.sightConfigurationViewModel.setHeVis(this.binding.sccHeVSTxt.getText().toString());
this.sightConfigurationViewModel.setVertSkalaRangMin(Double.parseDouble(this.binding.scVertScaleRngMinTxt.getText().toString()));
this.sightConfigurationViewModel.setVertSkalaRangMax(Double.parseDouble(this.binding.scVertScaleRngMaxTxt.getText().toString()));
this.sightConfigurationViewModel.setPointerOffset(Double.parseDouble(this.binding.scPointerOffsetTxt.getText().toString()));
this.sightConfigurationViewModel.setVertSkalaRangMin(PlatformUtils.parseDouble(this.binding.scVertScaleRngMinTxt.getText().toString()));
this.sightConfigurationViewModel.setVertSkalaRangMax(PlatformUtils.parseDouble(this.binding.scVertScaleRngMaxTxt.getText().toString()));
this.sightConfigurationViewModel.setPointerOffset(PlatformUtils.parseDouble(this.binding.scPointerOffsetTxt.getText().toString()));


ISight lSight = this.sightConfigurationViewModel.getRiser().getValue(); ISight lSight = this.sightConfigurationViewModel.getRiser().getValue();
if (lSight.getId() > 0) { if (lSight.getId() > 0) {
SightDao.getInstance().update(lSight); SightDao.getInstance().update(lSight);
//TODO: SHOW UPDATE INFO TOAST
PlatformUtils.toast(SightConfigurationActivity.this, String.format(getString(R.string.caption_Cfg_UpdateSuccessful), lSight)).show();

} else { } else {
lSight = SightDao.getInstance().insert(lSight); lSight = SightDao.getInstance().insert(lSight);
loadSights(); loadSights();
AutoCompleteTextView textView = this.binding.sightSelectionTxt; AutoCompleteTextView textView = this.binding.sightSelectionTxt;
final int position = ((ArrayAdapter<ISight>) textView.getAdapter()).getPosition(lSight); final int position = ((ArrayAdapter<ISight>) textView.getAdapter()).getPosition(lSight);
textView.setListSelection(position); textView.setListSelection(position);
textView.setText(lSight.toString());
textView.setText(lSight.toString(), false);
((ArrayAdapter<ISight>) textView.getAdapter()).getFilter().filter(null); ((ArrayAdapter<ISight>) textView.getAdapter()).getFilter().filter(null);
PlatformUtils.toast(SightConfigurationActivity.this, String.format(getString(R.string.caption_Cfg_SaveSuccessful), lSight)).show(); PlatformUtils.toast(SightConfigurationActivity.this, String.format(getString(R.string.caption_Cfg_SaveSuccessful), lSight)).show();
} }
SightDao.getInstance().delete(lSight); SightDao.getInstance().delete(lSight);
loadSights(); loadSights();
sightConfigurationViewModel.setSight(null); sightConfigurationViewModel.setSight(null);
binding.sightSelectionTxt.setText(null);
binding.sightSelectionTxt.setText(null, false);
} catch (Exception e) { } catch (Exception e) {
message = getString(R.string.caption_Cfg_DeleteNotPossible); message = getString(R.string.caption_Cfg_DeleteNotPossible);
} }

+ 5
- 5
app/src/main/java/ch/spherIC/recurvebowsight/ui/equipment/EquipmentRecyclerViewAdapter.java 查看文件

@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
float alpha = 1.0f; float alpha = 1.0f;
int horzMargin = v.getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin);
int vertMargin = v.getResources().getDimensionPixelSize(R.dimen.activity_vertical_margin);
int horzMargin = v.getResources().getDimensionPixelSize(R.dimen.nav_header_horizontal_spacing);
int vertMargin = v.getResources().getDimensionPixelSize(R.dimen.nav_header_vertical_spacing);
if (event.getAction() == MotionEvent.ACTION_DOWN) { 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);
alpha = 0.75f;
horzMargin = v.getResources().getDimensionPixelSize(R.dimen.nav_header_horizontal_spacing_onclick);
vertMargin = v.getResources().getDimensionPixelSize(R.dimen.nav_header_vertical_spacing_onclick);
} }
View setupCardView = v.findViewById(R.id.card_view_setup); View setupCardView = v.findViewById(R.id.card_view_setup);
setupCardView.setAlpha(alpha); setupCardView.setAlpha(alpha);

+ 71
- 0
app/src/main/java/ch/spherIC/recurvebowsight/utilities/NoFilterArrayAdapter.java 查看文件

package ch.spherIC.recurvebowsight.utilities;
import android.content.Context;
import android.widget.ArrayAdapter;
import android.widget.Filter;
import java.util.Arrays;
import java.util.List;
import androidx.annotation.NonNull;
/**
* Almost unbelievably, if we want to create a Material Spinner,
* we're forced to subclass ArrayAdapter. That statement alone
* is maddening. The issue is that there's no such thing as a Material
* Spinner. Instead, there's an Exposed Dropdown Menu, which is really
* an AutoCompleteTextView wrapped in a TextInputLayout, which replaces a
* Spinner. The reason we have to subclass ArrayAdapter is because we need
* the AutoCompleteTextView to act like a proper Spinner. Thus we have to
* override the AutoCompleteTextView's Filter so that it NEVER performs
* filtering of the dropdown menu items.
*/
public class NoFilterArrayAdapter<T extends Object> extends ArrayAdapter<T> {
private final List<T> objects;
private final Filter filter_that_does_nothing = new Filter() {
@Override
protected FilterResults performFiltering(CharSequence constraint) {
FilterResults results = new FilterResults();
results.values = NoFilterArrayAdapter.this.objects;
results.count = NoFilterArrayAdapter.this.objects.size();
return results;
}
@Override
protected void publishResults(CharSequence constraint, FilterResults results) {
notifyDataSetChanged();
}
};
/**
* Constructor
*
* @param context the context
* @param resource the resource
* @param objects the list of objects
*/
public NoFilterArrayAdapter(@NonNull Context context, int resource, @NonNull List<T> objects) {
super(context, resource, objects);
this.objects = objects;
}
/**
* Constructor
*
* @param context the context
* @param resource the resource
* @param objects the list of objects
*/
public NoFilterArrayAdapter(@NonNull Context context, int resource, @NonNull T[] objects) {
super(context, resource, objects);
this.objects = Arrays.asList(objects);
}
@NonNull
@Override
public Filter getFilter() {
return filter_that_does_nothing;
}
}

+ 12
- 0
app/src/main/java/ch/spherIC/recurvebowsight/utilities/PlatformUtils.java 查看文件

import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.text.TextUtils;
import android.view.Gravity; import android.view.Gravity;
import android.widget.Toast; import android.widget.Toast;
return 0; return 0;
}*/ }*/
public static Double parseDouble(String doubleVal) {
if (!TextUtils.isEmpty(doubleVal)) {
try {
return Double.parseDouble(doubleVal);
} catch (NumberFormatException e) {
return null;
}
}
return null;
}
public static AlertDialog getDeleteConfirmDialog(final Context context, final String itemToDelete, public static AlertDialog getDeleteConfirmDialog(final Context context, final String itemToDelete,
final DialogInterface.OnClickListener okListener) { final DialogInterface.OnClickListener okListener) {

+ 3
- 0
app/src/main/res/layout/activity_equipment_configuration.xml 查看文件

android:id="@+id/asArcherySetupSelectionTxt" android:id="@+id/asArcherySetupSelectionTxt"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:editable="false"
android:hint="@string/asArcherySetupLbl" android:hint="@string/asArcherySetupLbl"
android:singleLine="true" /> android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
android:id="@+id/asRiserSelectionTxt" android:id="@+id/asRiserSelectionTxt"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:editable="false"
android:hint="@string/rcRiserLbl" android:hint="@string/rcRiserLbl"
android:singleLine="true" /> android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
android:id="@+id/asSightSelectionTxt" android:id="@+id/asSightSelectionTxt"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:editable="false"
android:hint="@string/rcSightLbl" android:hint="@string/rcSightLbl"
android:singleLine="true" /> android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>

+ 1
- 0
app/src/main/res/layout/activity_riser_configuration.xml 查看文件

android:id="@+id/riserSelectionTxt" android:id="@+id/riserSelectionTxt"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:editable="false"
android:hint="@string/rcRiserLbl" android:hint="@string/rcRiserLbl"
android:singleLine="true" /> android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>

+ 1
- 0
app/src/main/res/layout/activity_sight_configuration.xml 查看文件

android:id="@+id/sightSelectionTxt" android:id="@+id/sightSelectionTxt"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:editable="false"
android:hint="@string/rcSightLbl" android:hint="@string/rcSightLbl"
android:singleLine="true" /> android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>

+ 4
- 4
app/src/main/res/layout/fragment_equipment_choose.xml 查看文件

android:id="@+id/card_view_border" android:id="@+id/card_view_border"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
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:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:backgroundTint="#54AAD1" android:backgroundTint="#54AAD1"
app:cardCornerRadius="20dp" app:cardCornerRadius="20dp"
app:cardElevation="10dp" app:cardElevation="10dp"

+ 3
- 2
app/src/main/res/layout/fragment_equipment_choose_list.xml 查看文件

android:name="ch.spherIC.recurvebowsight.EquipmentFragment" android:name="ch.spherIC.recurvebowsight.EquipmentFragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
app:layoutManager="LinearLayoutManager" app:layoutManager="LinearLayoutManager"
tools:context=".ui.equipment.ChooseEquipmentFragment" tools:context=".ui.equipment.ChooseEquipmentFragment"
tools:listitem="@layout/fragment_equipment_choose" /> tools:listitem="@layout/fragment_equipment_choose" />

+ 1
- 0
app/src/main/res/values-de/strings.xml 查看文件

<string name="caption_mandatory">Erforderlich</string> <string name="caption_mandatory">Erforderlich</string>
<string name="caption_Cfg_DeleteSuccessful">\'%s\' erfolgreich gelöscht!</string> <string name="caption_Cfg_DeleteSuccessful">\'%s\' erfolgreich gelöscht!</string>
<string name="caption_Cfg_SaveSuccessful">\'%s\' erfolgreich gespeichert!</string> <string name="caption_Cfg_SaveSuccessful">\'%s\' erfolgreich gespeichert!</string>
<string name="caption_Cfg_UpdateSuccessful">\'%s\' erfolgreich geändert!</string>
</resources> </resources>

+ 1
- 0
app/src/main/res/values/strings.xml 查看文件

<string name="caption_mandatory">Mandatory</string> <string name="caption_mandatory">Mandatory</string>
<string name="caption_Cfg_DeleteSuccessful">\'%s\' was successfully deleted!</string> <string name="caption_Cfg_DeleteSuccessful">\'%s\' was successfully deleted!</string>
<string name="caption_Cfg_SaveSuccessful">\'%s\' was saved successfully!</string> <string name="caption_Cfg_SaveSuccessful">\'%s\' was saved successfully!</string>
<string name="caption_Cfg_UpdateSuccessful">\'%s\' was updated successfully!</string>


</resources> </resources>

正在加载...
取消
保存