View AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yourpackagename">
<application
android:name=".MainApplication"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name">
<meta-data
android:name="DATABASE"
View BaseActivity.java
@Override
protected void onResume() {
super.onResume();
//noinspection ResourceType
setRequestedOrientation(Setting.get(Enums.Setting.Orientation).getIntValue());
}
View BaseActivity.java
public class BaseActivity extends Activity {
@Override
protected void onResume() {
super.onResume();
MusicHelper.getInstance(this).setMovingInApp(false);
}
@Override
public void onPause() {
super.onPause();
View LanguageHelper.java
public class LanguageHelper {
public static void updateLanguage(Context ctx) {
String lang = PreferenceManager.getDefaultSharedPreferences(ctx).getString("locale", "");
updateLanguage(ctx, lang);
}
public static void updateLanguage(Context context, int language) {
updateLanguage(context, getLocaleById(language));
}
View AlertDialogHelper.java
public class AlertDialogHelper {
private static void displayAlertDialog(Context context, String title, String body, DialogAction... actions) {
LayoutInflater inflater = LayoutInflater.from(context);
final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1);
final View inflatedLayout = inflater.inflate(R.layout.custom_alert_dialog, null);
final AlertDialog dialog = new AlertDialog.Builder(context).create();
dialog.setView(inflatedLayout);
((TextView)inflatedLayout.findViewById(R.id.title)).setText(title);
((TextView)inflatedLayout.findViewById(R.id.body)).setText(body);
View CreatorActivity.java
public void importFromCamera(View v) {
try {
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(intent, INTENT_CAMERA);
} catch (Exception e) {
Toast.makeText(this, "Scanning QR codes requires a barcode reader to be installed!", Toast.LENGTH_SHORT).show();
Uri marketUri = Uri.parse("market://details?id=com.google.zxing.client.android");
Intent marketIntent = new Intent(Intent.ACTION_VIEW, marketUri);
startActivity(marketIntent);
View ExportActivity.java
private void populateCard() {
...
StorageHelper.fillWithQrDrawable((ImageView) findViewById(R.id.puzzleQrCode), exportedText);
}
View LevelHelper.java
public static int convertXpToLevel(int xp) {
// Level = 0.05 * sqrt(xp)
return (int) (Constants.LEVEL_MODIFIER * Math.sqrt(xp));
}
public static int convertLevelToXp(int level) {
// XP = (Level / 0.05) ^ 2
return (int) Math.pow(level / Constants.LEVEL_MODIFIER, 2);
}
View AttackHelper.java
int baseDamage = weapon.getDamage();
int weaponMinDistance = weapon.getWeaponDistance().getMinimum();
int weaponMaxDistance = weapon.getWeaponDistance().getMaximum();
// If in the weapon range, full damage
if (distance >= weaponMinDistance && distance <= weaponMaxDistance) {
return baseDamage;
}
int tilesOutOfRange = distance > weaponMaxDistance ? distance - weaponMaxDistance : weaponMinDistance - distance;
View AnvilActivity.java
SoundHelper.playSound(this, SoundHelper.smithingSounds);