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
/** | |
* Shifts all tiles to the left, merging consecutive tiles as necessary. | |
*/ | |
public void moveLeft() { | |
if (mIsGameOver) { | |
return; | |
} | |
final int oldScore = mCurrentScore; | |
boolean moved = false; |
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 boolean canMerge(int t1, int t2) { | |
final int lowFib = Math.min(t1, t2); | |
final int highFib = Math.max(t1, t2); | |
int a = 1, b = 1; | |
while (b < highFib) { | |
int temp = b; | |
b = a + b; | |
a = temp; | |
} |
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 android.app; | |
import android.content.Context; | |
import android.graphics.Matrix; | |
import android.graphics.Rect; | |
import android.graphics.RectF; | |
import android.os.Bundle; | |
import android.os.Handler; | |
import android.os.Parcelable; | |
import android.os.ResultReceiver; |
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 class TextSizeTransition extends Transition { | |
private static final String PROPNAME_TEXT_SIZE = "propname_text_size"; | |
private static final String[] TRANSITION_PROPERTIES = { PROPNAME_TEXT_SIZE }; | |
private static final Property<TextView, Float> TEXT_SIZE = | |
new Property<TextView, Float>(Float.class, "textSize") { | |
@Override | |
public Float get(TextView textView) { | |
return textView.getTextSize(); |
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 class TransitionActivity extends Activity implements View.OnClickListener { | |
private static final Transition TRANSITION = new Fade(); | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
mRootView = findViewById(R.id.root_view); | |
mRootView.setOnClickListener(this); | |
} |
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 | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
android:id="@+id/layout_root_view" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:clipChildren="false"> | |
<RelativeLayout | |
android:layout_width="wrap_content" | |
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
public class MainApplication extends Application { | |
/** | |
* see NotePad tutorial for an example implementation of DataDbAdapter | |
*/ | |
private static DataDbAdapter mDbHelper; | |
/** | |
* Called when the application is starting, before any other | |
* application objects have been created. Implementations |
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
/** | |
* create custom DatabaseHelper class that extends SQLiteOpenHelper | |
*/ | |
public class DatabaseHelper extends SQLiteOpenHelper { | |
private static DatabaseHelper mInstance = null; | |
private static final String DATABASE_NAME = "databaseName"; | |
private static final String DATABASE_TABLE = "tableName"; | |
private static final int DATABASE_VERSION = 1; |
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 class MyFragment { | |
/** | |
* Make the default constructor private to prevent direct | |
* instantiation. Now all instances of this class must be | |
* instantiated with a call to newInstance(). | |
*/ | |
private MyFragment() { } | |
/** |
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 class Singleton { | |
private static final Singleton instance = null; | |
/** | |
* Make the class private to prevent direct instantiation. | |
* this forces clients to call newInstance(), which will | |
* ensure the class' Singleton property. | |
*/ | |
private Singleton() { } |
OlderNewer