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
import android.os.Parcel; | |
import android.os.Parcelable; | |
public class ParcelableHelper { | |
/** | |
* There is not always a guarantee that Parcelable values will be immediately written out and | |
* read back in. For data data that mutable (its own issue), this can be a problem. This is | |
* for the times when it would be great to have confidence that you will be working with a copy | |
* of that data. |
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 SomeClass { | |
someMethod(String className) { | |
// I see this more often | |
if (!TextUtils.isEmpty(className)) { // We have to ensure that className isn't null before calling equals() | |
if (className.equals(SomeClass.class.getName()) { | |
// do something | |
} | |
} | |
} |
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 com.example.helloworld.ui.adapters; | |
import android.content.Context; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.ImageView; | |
import android.widget.TextView; | |
import com.exacttarget.etpushsdk.adapter.CloudPageListAdapter; |
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 com.sjl.util; | |
import android.app.Activity; | |
import android.app.Application; | |
import android.content.Context; | |
import android.os.Bundle; | |
import android.os.Handler; | |
import android.util.Log; | |
import java.util.List; |
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
class SoccerTeam { | |
private static int numWins; | |
private static int numLosses; | |
private static int numTies; | |
//these 2 variables are for the modified version | |
private static int numGames=0; | |
private static int numGoals=0; |
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
apply plugin: 'com.android.library' | |
android { | |
compileSdkVersion 'Google Inc.:Google APIs:22' | |
Properties localProps = new Properties() | |
localProps.load(new FileInputStream(file('../local.properties'))) | |
def buildToolVer = file("${localProps['sdk.dir']}/build-tools/").listFiles().sort().reverse().first().name; | |
buildToolsVersion buildToolVer; |
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 DupeChecker { | |
public boolean allDuplicateChars(final String input) { | |
if (input == null || input.length() == 0) { | |
return false; | |
} | |
String firstChar = input.substring(0,1); | |
String matchingChars[] = input.split(firstChar + "+"); | |
return matchingChars.length == 0; | |
} | |
} |
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
// annotation processor will generate DevicePhoneNumberSumType (see: 4_DevicePhoneNumberSumType.java) | |
@SumType | |
public interface DevicePhoneNumber { | |
String phoneNumber(); | |
void phoneNumberNotAvailable(); | |
String[] permissionsRequired(); | |
} |
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
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
... | |
BarcodeLoggerActivityPermissionsDispatcher.startBarcodeCaptureWithCheck(this); | |
} | |
@NeedsPermission(Manifest.permission.CAMERA) | |
void startBarcodeCapture() { | |
int orientation = WindowManagerHelper.getCurrentAccurateOrientation(this); | |
Intent intent = CaptureActivity.buildIntent(this, orientation); |
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
import android.app.Activity; | |
import android.support.annotation.CheckResult; | |
import android.support.annotation.NonNull; | |
import android.support.annotation.Size; | |
import android.support.v4.app.ActivityCompat; | |
import static android.content.pm.PackageManager.PERMISSION_GRANTED; | |
public class ActivityPermissionDelegate { | |
public interface PermissionRationaleRetryBehavior { |
NewerOlder