Skip to content

Commit

Permalink
Show and sort by missions' stars, use prefs to change language in Eve…
Browse files Browse the repository at this point in the history
…ntsFragment
  • Loading branch information
Vieja committed Jun 25, 2021
1 parent 793c5a0 commit 29b7a49
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 111 deletions.
80 changes: 40 additions & 40 deletions app/src/main/java/com/vieja/crownhunter/EventDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public static void populateEventDatabase() {
))),
new EventInfo(R.string.usj_blazing, 7,
false, false, new ArrayList<>(Arrays.asList(
new CrownInfo(R.drawable.m_azure_rathalos, false, 100),
new CrownInfo(R.drawable.m_dodogama, true, 100)
new CrownInfo(R.drawable.m_dodogama, true, 100),
new CrownInfo(R.drawable.m_azure_rathalos, false, 100)
))),
new EventInfo(R.string.egg_lovers, 6,
false, false, new ArrayList<>(Arrays.asList(
Expand All @@ -29,62 +29,62 @@ public static void populateEventDatabase() {
))),
new EventInfo(R.string.deep_green, 7,
false, false, new ArrayList<>(Arrays.asList(
new CrownInfo(R.drawable.m_anjanath, false, 12),
new CrownInfo(R.drawable.m_great_jagras, false, 12),
new CrownInfo(R.drawable.m_pukei_pukei, false, 12),
new CrownInfo(R.drawable.m_rathalos, false, 12),
new CrownInfo(R.drawable.m_tobi_kadachi, false, 12),
new CrownInfo(R.drawable.m_anjanath, true, 12),
new CrownInfo(R.drawable.m_anjanath, false, 12),
new CrownInfo(R.drawable.m_rathalos, false, 12),
new CrownInfo(R.drawable.m_great_jagras, true, 12),
new CrownInfo(R.drawable.m_pukei_pukei, true, 12),
new CrownInfo(R.drawable.m_rathalos, true, 12),
new CrownInfo(R.drawable.m_tobi_kadachi, true, 12)
new CrownInfo(R.drawable.m_tobi_kadachi, true, 12),
new CrownInfo(R.drawable.m_anjanath, true, 12),
new CrownInfo(R.drawable.m_rathalos, true, 12)
))),
new EventInfo(R.string.wildspire_bolero, 7,
false, false, new ArrayList<>(Arrays.asList(
new CrownInfo(R.drawable.m_diablos, false, 12),
new CrownInfo(R.drawable.m_kulu_ya_ku, false, 12),
new CrownInfo(R.drawable.m_barroth, false, 12),
new CrownInfo(R.drawable.m_jyuratodus, false, 12),
new CrownInfo(R.drawable.m_kulu_ya_ku, false, 12),
new CrownInfo(R.drawable.m_rathian, false, 12),
new CrownInfo(R.drawable.m_diablos, true, 12),
new CrownInfo(R.drawable.m_diablos, false, 12),
new CrownInfo(R.drawable.m_kulu_ya_ku, true, 12),
new CrownInfo(R.drawable.m_barroth, true, 12),
new CrownInfo(R.drawable.m_jyuratodus, true, 12),
new CrownInfo(R.drawable.m_kulu_ya_ku, true, 12),
new CrownInfo(R.drawable.m_rathian, true, 12)
new CrownInfo(R.drawable.m_rathian, true, 12),
new CrownInfo(R.drawable.m_diablos, true, 12)
))),
new EventInfo(R.string.coral_waltz, 7,
false, false, new ArrayList<>(Arrays.asList(
new CrownInfo(R.drawable.m_legiana, false, 12),
new CrownInfo(R.drawable.m_tzitzi_ya_ku, false, 12),
new CrownInfo(R.drawable.m_paolumu, false, 12),
new CrownInfo(R.drawable.m_pink_rathian, false, 12),
new CrownInfo(R.drawable.m_tzitzi_ya_ku, false, 12),
new CrownInfo(R.drawable.m_legiana, true, 12),
new CrownInfo(R.drawable.m_legiana, false, 12),
new CrownInfo(R.drawable.m_tzitzi_ya_ku, true, 12),
new CrownInfo(R.drawable.m_paolumu, true, 12),
new CrownInfo(R.drawable.m_pink_rathian, true, 12),
new CrownInfo(R.drawable.m_tzitzi_ya_ku, true, 12)
new CrownInfo(R.drawable.m_legiana, true, 12)
))),
new EventInfo(R.string.effluvial_opera, 7,
false, false, new ArrayList<>(Arrays.asList(
new CrownInfo(R.drawable.m_bazelgeuse, false, 12),
new CrownInfo(R.drawable.m_great_girros, false, 12),
new CrownInfo(R.drawable.m_odogaron, false, 12),
new CrownInfo(R.drawable.m_radobaan, false, 12),
new CrownInfo(R.drawable.m_bazelgeuse, true, 12),
new CrownInfo(R.drawable.m_odogaron, false, 12),
new CrownInfo(R.drawable.m_bazelgeuse, false, 12),
new CrownInfo(R.drawable.m_great_girros, true, 12),
new CrownInfo(R.drawable.m_radobaan, true, 12),
new CrownInfo(R.drawable.m_odogaron, true, 12),
new CrownInfo(R.drawable.m_radobaan, true, 12)
new CrownInfo(R.drawable.m_bazelgeuse, true, 12)
))),
new EventInfo(R.string.rock_n_roll, 7,
false, false, new ArrayList<>(Arrays.asList(
new CrownInfo(R.drawable.m_azure_rathalos, false, 12),
new CrownInfo(R.drawable.m_dodogama, false, 12),
new CrownInfo(R.drawable.m_lavasioth, false, 12),
new CrownInfo(R.drawable.m_uragaan, false, 12),
new CrownInfo(R.drawable.m_azure_rathalos, true, 12),
new CrownInfo(R.drawable.m_lavasioth, false, 12),
new CrownInfo(R.drawable.m_azure_rathalos, false, 12),
new CrownInfo(R.drawable.m_dodogama, true, 12),
new CrownInfo(R.drawable.m_uragaan, true, 12),
new CrownInfo(R.drawable.m_lavasioth, true, 12),
new CrownInfo(R.drawable.m_uragaan, true, 12)
new CrownInfo(R.drawable.m_azure_rathalos, true, 12)
))),
new EventInfo(R.string.greatest_jagras, 9,
false, false, new ArrayList<>(Arrays.asList(
Expand All @@ -99,15 +99,15 @@ public static void populateEventDatabase() {
false, false, new ArrayList<>(Arrays.asList(
new CrownInfo(R.drawable.m_barroth, true, 100)
))),
new EventInfo(R.string.paolumu_lullabies, 2,
new EventInfo(R.string.paolumu_lullabies, 12,
true, false, new ArrayList<>(Arrays.asList(
new CrownInfo(R.drawable.m_nightshade_paolumu, false, 100)
))),
new EventInfo(R.string.blazing_sun, 8,
false, false, new ArrayList<>(Arrays.asList(
new CrownInfo(R.drawable.m_teostra, true, 100)
))),
new EventInfo(R.string.yodeling_in_forest, 6,
new EventInfo(R.string.yodeling_in_forest, 16,
true, false, new ArrayList<>(Arrays.asList(
new CrownInfo(R.drawable.m_anjanath, false, 12),
new CrownInfo(R.drawable.m_rathalos, false, 12),
Expand All @@ -120,7 +120,7 @@ public static void populateEventDatabase() {
new CrownInfo(R.drawable.m_yian_garuga, true, 12),
new CrownInfo(R.drawable.m_rajang, true, 12)
))),
new EventInfo(R.string.heavy_metal, 6,
new EventInfo(R.string.heavy_metal, 16,
true, false, new ArrayList<>(Arrays.asList(
new CrownInfo(R.drawable.m_jyuratodus, false, 12),
new CrownInfo(R.drawable.m_nightshade_paolumu, false, 12),
Expand All @@ -133,7 +133,7 @@ public static void populateEventDatabase() {
new CrownInfo(R.drawable.m_black_diablos, true, 12),
new CrownInfo(R.drawable.m_savage_deviljho, true, 12)
))),
new EventInfo(R.string.symphony_of_coral, 6,
new EventInfo(R.string.symphony_of_coral, 16,
true, false, new ArrayList<>(Arrays.asList(
new CrownInfo(R.drawable.m_paolumu, false, 12),
new CrownInfo(R.drawable.m_legiana, false, 12),
Expand All @@ -146,7 +146,7 @@ public static void populateEventDatabase() {
new CrownInfo(R.drawable.m_ebony_odogaron, true, 12),
new CrownInfo(R.drawable.m_zinogre, true, 12)
))),
new EventInfo(R.string.rotten_canzone, 6,
new EventInfo(R.string.rotten_canzone, 16,
true, false, new ArrayList<>(Arrays.asList(
new CrownInfo(R.drawable.m_great_girros, false, 12),
new CrownInfo(R.drawable.m_odogaron, false, 12),
Expand All @@ -159,20 +159,20 @@ public static void populateEventDatabase() {
new CrownInfo(R.drawable.m_fulgur_anjanath, true, 12),
new CrownInfo(R.drawable.m_acidic_glavenus, true, 12)
))),
new EventInfo(R.string.alt_rock_recess, 6,
new EventInfo(R.string.alt_rock_recess, 16,
true, false, new ArrayList<>(Arrays.asList(
new CrownInfo(R.drawable.m_banbaro, false, 12),
new CrownInfo(R.drawable.m_uragaan, false, 12),
new CrownInfo(R.drawable.m_azure_rathalos, false, 12),
new CrownInfo(R.drawable.m_brachydios, false, 12),
new CrownInfo(R.drawable.m_azure_rathalos, false, 12),
new CrownInfo(R.drawable.m_seething_bazelgeuse, false, 12),
new CrownInfo(R.drawable.m_banbaro, true, 12),
new CrownInfo(R.drawable.m_uragaan, true, 12),
new CrownInfo(R.drawable.m_azure_rathalos, true, 12),
new CrownInfo(R.drawable.m_brachydios, true, 12),
new CrownInfo(R.drawable.m_azure_rathalos, true, 12),
new CrownInfo(R.drawable.m_seething_bazelgeuse, true, 12)
))),
new EventInfo(R.string.ballad_of_hoarfrost, 6,
new EventInfo(R.string.ballad_of_hoarfrost, 16,
true, false, new ArrayList<>(Arrays.asList(
new CrownInfo(R.drawable.m_beotodus, false, 12),
new CrownInfo(R.drawable.m_viper_tobi_kadachi, false, 12),
Expand All @@ -185,33 +185,33 @@ public static void populateEventDatabase() {
new CrownInfo(R.drawable.m_shrieking_legiana, true, 12),
new CrownInfo(R.drawable.m_stygian_zinogre, true, 12)
))),
new EventInfo(R.string.seeing_is_believing, 3,
new EventInfo(R.string.seeing_is_believing, 13,
true, false, new ArrayList<>(Arrays.asList(
new CrownInfo(R.drawable.m_tigrex, true, 100)
))),
new EventInfo(R.string.dont_forget_earplugs, 6,
new EventInfo(R.string.dont_forget_earplugs, 16,
true, false, new ArrayList<>(Arrays.asList(
new CrownInfo(R.drawable.m_yian_garuga, false, 100)
))),
new EventInfo(R.string.monkey_business, 6,
new EventInfo(R.string.monkey_business, 16,
true, true, new ArrayList<>(Arrays.asList(
new CrownInfo(R.drawable.m_furious_rajang, false, 100)
))),
new EventInfo(R.string.mighty_muscle_monkey_business, 6,
new EventInfo(R.string.mighty_muscle_monkey_business, 16,
true, true, new ArrayList<>(Arrays.asList(
new CrownInfo(R.drawable.m_furious_rajang, true, 100)
))),
new EventInfo(R.string.kadachi_twins, 2,
new EventInfo(R.string.kadachi_twins, 12,
true, false, new ArrayList<>(Arrays.asList(
new CrownInfo(R.drawable.m_tobi_kadachi, false, 100),
new CrownInfo(R.drawable.m_viper_tobi_kadachi, true, 100)
))),
new EventInfo(R.string.farawell_to_zinogre, 6,
new EventInfo(R.string.farawell_to_zinogre, 16,
true, false, new ArrayList<>(Arrays.asList(
new CrownInfo(R.drawable.m_zinogre, false, 50),
new CrownInfo(R.drawable.m_zinogre, true, 50)
))),
new EventInfo(R.string.brand_new_brute, 6,
new EventInfo(R.string.brand_new_brute, 16,
true, false, new ArrayList<>(Arrays.asList(
new CrownInfo(R.drawable.m_brute_tigrex, false, 50),
new CrownInfo(R.drawable.m_brute_tigrex, true, 50)
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/com/vieja/crownhunter/activity/EventCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
public class EventCard implements Comparable{
private final String name;
private int chances;
private final int stars;
private final int monsterIcon1;
private final int monsterIcon2;
private final int monsterIcon3;
private final int monsterIcon4;
private final int monsterIcon5;

public EventCard(String name, int chances, int monsterIcon1, int monsterIcon2, int monsterIcon3, int monsterIcon4, int monsterIcon5) {
public EventCard(String name, int chances, int stars, int monsterIcon1, int monsterIcon2, int monsterIcon3, int monsterIcon4, int monsterIcon5) {
this.name = name;
this.chances = chances;
this.stars = stars;
this.monsterIcon1 = monsterIcon1;
this.monsterIcon2 = monsterIcon2;
this.monsterIcon3 = monsterIcon3;
Expand All @@ -27,10 +29,6 @@ public int getChances() {
return chances;
}

public void setChances(int chances) {
this.chances = chances;
}

public int getMonsterIcon1() {
return monsterIcon1;
}
Expand All @@ -53,6 +51,8 @@ public int getMonsterIcon5() {

@Override
public int compareTo(Object o) {
return ((EventCard)o).chances-this.chances;
if (((EventCard)o).chances == this.chances)
return (this.stars - ((EventCard)o).stars);
else return ((EventCard)o).chances-this.chances;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.vieja.crownhunter.activity;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.LayoutInflater;
Expand All @@ -25,8 +27,8 @@
import com.vieja.crownhunter.R;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Locale;

public class EventsFragment extends Fragment {

Expand Down Expand Up @@ -57,7 +59,10 @@ public void populateEventCardList() {
boolean hide_iceborne = prefs.getBoolean("hide_iceborne", false);
boolean hide_optional = prefs.getBoolean("hide_optional", false);

Resources resources = getContext().getResources();
Resources resources;
if (prefs.getBoolean("names_english", false)) {
resources = getLocalizedResources(getContext(), new Locale("en"));
} else resources = getContext().getResources();

StringBuilder sb = FileIO.load(getContext());
String[] lines = sb.toString().split("\n");
Expand All @@ -78,7 +83,7 @@ public void populateEventCardList() {

if (!hide_iceborne || !info.isIceborne()) {
if (!hide_optional || !info.isOptional())
eventCardsList.add(new EventCard(resources.getString(info.getNameRes()), chance, monsters.get(0), monsters.get(1), monsters.get(2), monsters.get(3), monsters.get(4)));
eventCardsList.add(new EventCard(resources.getString(info.getNameRes()), chance, info.getStars(), monsters.get(0), monsters.get(1), monsters.get(2), monsters.get(3), monsters.get(4)));
}
}
}
Expand All @@ -104,4 +109,13 @@ private int getChanceForThatMonster(CrownInfo info) {
}
return 0;
}

@NonNull
private Resources getLocalizedResources(Context context, Locale desiredLocale) {
Configuration conf = context.getResources().getConfiguration();
conf = new Configuration(conf);
conf.setLocale(desiredLocale);
Context localizedContext = context.createConfigurationContext(conf);
return localizedContext.getResources();
}
}
20 changes: 17 additions & 3 deletions app/src/main/java/com/vieja/crownhunter/activity/HomeFragment.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.vieja.crownhunter.activity;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.LayoutInflater;
Expand All @@ -11,7 +13,6 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.cardview.widget.CardView;
import androidx.fragment.app.Fragment;
import androidx.preference.PreferenceManager;

Expand All @@ -27,6 +28,7 @@

import java.util.ArrayList;
import java.util.Collections;
import java.util.Locale;

public class HomeFragment extends Fragment {

Expand Down Expand Up @@ -105,7 +107,10 @@ public void populateEventCardList() {
boolean hide_iceborne = prefs.getBoolean("hide_iceborne", false);
boolean hide_optional = prefs.getBoolean("hide_optional", false);

Resources resources = getContext().getResources();
Resources resources;
if (prefs.getBoolean("names_english", false)) {
resources = getLocalizedResources(getContext(), new Locale("en"));
} else resources = getContext().getResources();

StringBuilder sb = FileIO.load(getContext());
String[] lines = sb.toString().split("\n");
Expand All @@ -126,7 +131,7 @@ public void populateEventCardList() {
for (EventInfo info: EventDatabase.list){
ArrayList<Integer> monsters = info.getFiveMostersRes();
int chance = getOverallChanceForCrown(info.getCrownChances());
if (chance>0) eventCardsList.add(new EventCard(resources.getString(info.getNameRes()), chance, monsters.get(0), monsters.get(1), monsters.get(2), monsters.get(3), monsters.get(4)));
if (chance>0) eventCardsList.add(new EventCard(resources.getString(info.getNameRes()), chance, info.getStars(), monsters.get(0), monsters.get(1), monsters.get(2), monsters.get(3), monsters.get(4)));
}
Collections.sort(eventCardsList);
}
Expand All @@ -150,4 +155,13 @@ private int getChanceForThatMonster(CrownInfo info) {
}
return 0;
}

@NonNull
private Resources getLocalizedResources(Context context, Locale desiredLocale) {
Configuration conf = context.getResources().getConfiguration();
conf = new Configuration(conf);
conf.setLocale(desiredLocale);
Context localizedContext = context.createConfigurationContext(conf);
return localizedContext.getResources();
}
}
Loading

0 comments on commit 29b7a49

Please sign in to comment.