This file contains hidden or 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
package uk.co.jakelee.cityflow.components; | |
import android.app.Activity; | |
import android.app.Dialog; | |
import android.content.DialogInterface; | |
import android.content.Intent; | |
import android.os.AsyncTask; | |
import android.widget.TextView; | |
import java.util.ArrayList; |
This file contains hidden or 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
public int getTileWidth() { | |
return dpToPixel(Constants.TILE_WIDTH); | |
} | |
public int getTileHeight() { | |
return dpToPixel(Constants.TILE_HEIGHT); | |
} | |
public int dpToPixel(float dp) { | |
Resources resources = context.getResources(); |
This file contains hidden or 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
public TileDisplaySetup setupTileDisplay(PuzzleDisplayer puzzleDisplayer, List<Tile> tiles, ZoomableViewGroup tileContainer, Tile selectedTile, ImageView selectedTileImage, boolean isEditor) { | |
tileContainer.removeAllViews(); | |
Setting minimumMillisForDrag = Setting.get(Constants.SETTING_MINIMUM_MILLIS_DRAG); | |
int dragDelay = minimumMillisForDrag != null ? minimumMillisForDrag.getIntValue() : 200; | |
Pair<Integer, Integer> maxXY = TileHelper.getMaxXY(tiles); | |
DisplayValues displayValues = getDisplayValues(puzzleDisplayer.getActivity(), maxXY.first + 1, maxXY.second + 1); | |
float optimumScale = displayValues.getZoomFactor(); |
This file contains hidden or 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
<RelativeLayout | |
android:id="@+id/progressWrapper" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_below="@id/mainLogo"> | |
<uk.co.jakelee.cityflow.components.TextViewFont | |
android:id="@+id/progressText" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" |
This file contains hidden or 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
private static Visitor_Type selectVisitorType() { | |
Visitor_Type visitor = new Visitor_Type(); | |
List<Visitor_Type> visitorTypes = Visitor_Type.findWithQuery(Visitor_Type.class, | |
"SELECT * FROM VisitorType WHERE visitor_id NOT IN (SELECT type FROM Visitor)"); | |
// Work out the total weighting. | |
double totalWeighting = 0.0; | |
for (Visitor_Type type : visitorTypes) { | |
totalWeighting += type.getWeighting(); |
This file contains hidden or 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
SoundHelper.playSound(this, SoundHelper.smithingSounds); |
This file contains hidden or 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
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; |
This file contains hidden or 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
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); | |
} |
This file contains hidden or 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
private void populateCard() { | |
... | |
StorageHelper.fillWithQrDrawable((ImageView) findViewById(R.id.puzzleQrCode), exportedText); | |
} |
This file contains hidden or 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
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); |
OlderNewer