-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added SpinnerFragment. Added abil. 2 switch between 2 themes. still b…
…uggy.
- Loading branch information
1 parent
75589b4
commit e653853
Showing
9 changed files
with
175 additions
and
4 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
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
114 changes: 114 additions & 0 deletions
114
app/src/main/java/com/luxlunaris/noadpadlight/ui/SpinnerFragment.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,114 @@ | ||
package com.luxlunaris.noadpadlight.ui; | ||
|
||
import android.os.Bundle; | ||
|
||
import androidx.fragment.app.Fragment; | ||
|
||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.AdapterView; | ||
import android.widget.ArrayAdapter; | ||
import android.widget.Spinner; | ||
import android.widget.TextView; | ||
|
||
import com.luxlunaris.noadpadlight.R; | ||
import com.luxlunaris.noadpadlight.control.classes.SETTINGS_TAGS; | ||
import com.luxlunaris.noadpadlight.control.classes.Settings; | ||
|
||
|
||
public class SpinnerFragment extends Fragment { | ||
|
||
|
||
/** | ||
* Defines the options that will be displayed by the spinner | ||
*/ | ||
Enum[] optionsEnum; | ||
|
||
/** | ||
* Specifies the setting to be changed | ||
*/ | ||
SETTINGS_TAGS settingTag; | ||
|
||
/** | ||
* Text to be displayed to the user. | ||
*/ | ||
String text; | ||
|
||
/** | ||
* The spinner view itself. | ||
*/ | ||
Spinner spinner; | ||
|
||
|
||
public SpinnerFragment() { | ||
// Required empty public constructor | ||
} | ||
|
||
|
||
public static SpinnerFragment newInstance(SETTINGS_TAGS settingTag, Enum[] optionsEnum, String text) { | ||
SpinnerFragment fragment = new SpinnerFragment(); | ||
fragment.optionsEnum = optionsEnum; | ||
fragment.settingTag = settingTag; | ||
fragment.text = text; | ||
return fragment; | ||
} | ||
|
||
|
||
@Override | ||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | ||
|
||
View view = inflater.inflate(R.layout.fragment_spinner, container, false); | ||
|
||
|
||
//set the text that outlines the spinner's purpose | ||
((TextView)(view.findViewById(R.id.spinner_text))).setText(text); | ||
|
||
|
||
spinner = view.findViewById(R.id.spinner); | ||
spinner.setAdapter(new ArrayAdapter<Enum>(this.getContext(), R.layout.support_simple_spinner_dropdown_item, optionsEnum ) ); | ||
|
||
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | ||
@Override | ||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | ||
Settings.setTagValue(settingTag, optionsEnum[position].toString()); | ||
} | ||
|
||
@Override | ||
public void onNothingSelected(AdapterView<?> parent) { | ||
|
||
} | ||
}); | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
return view; | ||
|
||
} | ||
|
||
|
||
@Override | ||
public void onResume() { | ||
super.onResume(); | ||
|
||
String tagValue = Settings.getString(settingTag); | ||
|
||
int i; | ||
for(i =0; i<optionsEnum.length; i++){ | ||
if(tagValue.equals(optionsEnum[i].toString())){ | ||
break; | ||
} | ||
} | ||
|
||
|
||
spinner.setSelection(i); | ||
} | ||
|
||
|
||
|
||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,32 @@ | ||
<?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:id="@+id/frameLayout" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".ui.SpinnerFragment"> | ||
|
||
<!-- TODO: Update blank fragment layout --> | ||
|
||
<Spinner | ||
android:id="@+id/spinner" | ||
android:layout_width="274dp" | ||
android:layout_height="44dp" | ||
android:layout_marginTop="8dp" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintHorizontal_bias="0.306" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/spinner_text" /> | ||
|
||
<TextView | ||
android:id="@+id/spinner_text" | ||
android:layout_width="257dp" | ||
android:layout_height="72dp" | ||
android:layout_marginTop="24dp" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintHorizontal_bias="0.272" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
</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
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