-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #156 from magicmychal/develop
release 1.4
- Loading branch information
Showing
102 changed files
with
2,300 additions
and
877 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ sc.iml | |
app/app.iml | ||
Fiszki.iml | ||
/app/build | ||
!/app/build/outputs/apk/ | ||
|
||
|
||
|
||
|
||
|
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
Binary file not shown.
Binary file not shown.
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package eu.qm.fiszki; | ||
|
||
import android.content.Context; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Random; | ||
|
||
import eu.qm.fiszki.model.Flashcard; | ||
import eu.qm.fiszki.model.FlashcardRepository; | ||
|
||
/** | ||
* Created by mBoiler on 11.02.2016. | ||
*/ | ||
public class Algorithm { | ||
|
||
FlashcardRepository flashcardRepository; | ||
|
||
public Algorithm(Context context) { | ||
flashcardRepository = new FlashcardRepository(context); | ||
} | ||
|
||
public Flashcard drawCardAlgorithm() { | ||
final int[] points = {25, 20, 15, 10, 5}; | ||
int[] totalPoints = new int[5]; | ||
int[] section = new int[5]; | ||
int drawn = 0; | ||
|
||
Flashcard flashcard = null; | ||
|
||
for (int i = 0; i < 5; i++) { | ||
ArrayList<Flashcard> flashcardsList = flashcardRepository.getFlashcardsByPriority(i + 1); | ||
int count = flashcardsList.size(); | ||
totalPoints[i] = count * points[i]; | ||
if (i <= 0) { | ||
section[i] = totalPoints[i]; | ||
} else { | ||
section[i] = totalPoints[i] + section[i - 1]; | ||
} | ||
} | ||
Random rand = new Random(); | ||
drawn = rand.nextInt(section[4]); | ||
drawn += 1; | ||
|
||
if (drawn <= section[0]) { | ||
flashcard = flashcardRepository.getRandomFlashcardByPririty(1); | ||
} else if (drawn <= section[1]) { | ||
flashcard = flashcardRepository.getRandomFlashcardByPririty(2); | ||
} else if (drawn <= section[2]) { | ||
flashcard = flashcardRepository.getRandomFlashcardByPririty(3); | ||
} else if (drawn <= section[3]) { | ||
flashcard = flashcardRepository.getRandomFlashcardByPririty(4); | ||
} else if (drawn <= section[4] + 1) { | ||
flashcard = flashcardRepository.getRandomFlashcardByPririty(5); | ||
} | ||
|
||
return flashcard; | ||
} | ||
} |
129 changes: 129 additions & 0 deletions
129
app/src/main/java/eu/qm/fiszki/CategorySpinnerRepository.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,129 @@ | ||
package eu.qm.fiszki; | ||
|
||
import android.app.Activity; | ||
import android.app.Dialog; | ||
import android.content.Context; | ||
import android.view.View; | ||
import android.view.WindowManager; | ||
import android.view.inputmethod.InputMethodManager; | ||
import android.widget.AdapterView; | ||
import android.widget.ArrayAdapter; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import android.widget.Spinner; | ||
import android.widget.Toast; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import eu.qm.fiszki.model.Category; | ||
import eu.qm.fiszki.model.CategoryRepository; | ||
|
||
/** | ||
* Created by mBoiler on 19.02.2016. | ||
*/ | ||
public class CategorySpinnerRepository { | ||
|
||
private Spinner spinner; | ||
private Context context; | ||
private CategoryRepository categoryRepository; | ||
private EditText categoryName; | ||
private Button addCategoryButton; | ||
private ArrayAdapter<String> dataAdapter; | ||
|
||
public CategorySpinnerRepository(Spinner spinner, Context context) { | ||
this.spinner = spinner; | ||
this.context = context; | ||
categoryRepository = new CategoryRepository(context); | ||
} | ||
|
||
public int getSelectedCategoryID() { | ||
if (spinner.getSelectedItemPosition() == 0) { | ||
return 1; | ||
} | ||
String categoryNameFromSpinner = spinner.getSelectedItem().toString(); | ||
Category category = categoryRepository.getCategoryByName(categoryNameFromSpinner); | ||
return category.getId(); | ||
} | ||
|
||
public void populate() { | ||
ArrayList<Category> categories = categoryRepository.getAllCategory(); | ||
List<String> list = new ArrayList<String>(); | ||
int x = 0; | ||
do { | ||
if (categories.get(x).getId() == 1) { | ||
list.add(context.getString(R.string.add_new_word_no_category)); | ||
} else if (categories.get(x).getId() == 2) { | ||
list.add(context.getString(R.string.add_new_word_add_category)); | ||
} else { | ||
list.add(categories.get(x).getCategory()); | ||
} | ||
x++; | ||
} while (x != categories.size()); | ||
dataAdapter = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_dropdown_item, list); | ||
spinner.setAdapter(dataAdapter); | ||
} | ||
|
||
public void setSelectedListener(final Activity activity) { | ||
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | ||
@Override | ||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | ||
if (position == 1) { | ||
spinner.setSelection(0); | ||
final Dialog dialog = new Dialog(context); | ||
dialog.setContentView(R.layout.layout_dialog_add_category); | ||
dialog.setTitle(R.string.add_new_word_add_category); | ||
|
||
addCategoryButton = (Button) dialog.findViewById(R.id.addCategoryButton); | ||
categoryName = (EditText) dialog.findViewById(R.id.categoryName); | ||
|
||
categoryName.postDelayed(new Runnable() { | ||
@Override | ||
public void run() { | ||
InputMethodManager keyboard = (InputMethodManager) | ||
activity.getSystemService(Context.INPUT_METHOD_SERVICE); | ||
keyboard.showSoftInput(categoryName, 0); | ||
} | ||
}, 50); | ||
|
||
addCategoryButton.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
if (categoryName.getText().toString().isEmpty()) { | ||
Toast.makeText(context, | ||
context.getString(R.string.alert_message_onEmptyFields), | ||
Toast.LENGTH_LONG).show(); | ||
} else if(categoryRepository.getCategoryByName(categoryName.getText().toString())!=null) { | ||
Toast.makeText(context, | ||
context.getString(R.string.add_new_category_exist), | ||
Toast.LENGTH_LONG).show(); | ||
}else{ | ||
Category category = new Category(categoryName.getText().toString(), true); | ||
categoryRepository.addCategory(category); | ||
Toast.makeText(context, | ||
context.getString(R.string.add_new_category_toast), | ||
Toast.LENGTH_LONG).show(); | ||
dialog.dismiss(); | ||
populate(); | ||
spinner.setSelection(dataAdapter.getPosition(categoryName.getText().toString())); | ||
} | ||
} | ||
}); | ||
|
||
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); | ||
lp.copyFrom(dialog.getWindow().getAttributes()); | ||
lp.width = WindowManager.LayoutParams.MATCH_PARENT; | ||
lp.height = WindowManager.LayoutParams.WRAP_CONTENT; | ||
|
||
dialog.getWindow().setAttributes(lp); | ||
dialog.show(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onNothingSelected(AdapterView<?> parent) { | ||
|
||
} | ||
}); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,9 +1,12 @@ | ||
package eu.qm.fiszki; | ||
|
||
/** | ||
* Created by mBoiler on 28.02.2016. | ||
*/ | ||
public class Checker { | ||
|
||
public Boolean Check(String originalWord,String enteredWord){ | ||
if(originalWord.compareTo(enteredWord)== 0) return true; | ||
public boolean check(String originalWord, String enteredWord) { | ||
if (originalWord.compareTo(enteredWord) == 0) return true; | ||
else return false; | ||
} | ||
} |
Oops, something went wrong.