This file contains 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 | |
public void onActivityResult(int requestCode, int resultCode, Intent data) { | |
super.onActivityResult(requestCode, resultCode, data); | |
// notifying nested fragments (support library bug fix) | |
final FragmentManager childFragmentManager = getChildFragmentManager(); | |
if (childFragmentManager != null) { | |
final List<Fragment> nestedFragments = childFragmentManager.getFragments(); |
This file contains 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 MyApp extends Application { | |
@Override | |
public void onCreate() { | |
TypefaceUtil.overrideFont(getApplicationContext(), "SERIF", "fonts/Roboto-Regular.ttf"); // font from assets: "assets/fonts/Roboto-Regular.ttf | |
} | |
} |
This file contains 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.content.Context; | |
import android.content.SharedPreferences; | |
import android.content.pm.PackageInfo; | |
import android.content.pm.PackageManager; | |
import android.os.AsyncTask; | |
import com.google.android.gms.common.ConnectionResult; | |
import com.google.android.gms.common.GooglePlayServicesUtil; | |
import com.google.android.gms.gcm.GoogleCloudMessaging; |
This file contains 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 App : Application | |
{ | |
// ... bla bla | |
// when app is launching, we should set its language to previous saved or best for user's system language or default for application | |
private void Application_Launching(object sender, LaunchingEventArgs e) | |
{ | |
LocalizationManager.ChangeAppLanguage(LocalizationManager.GetCurrentAppLang()); | |
} | |
} |
This file contains 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 String getIntentExtrasAsString(Intent intent) { | |
if (intent == null || intent.getExtras() == null || intent.getExtras().isEmpty()) return "no extras or null intent"; | |
StringBuilder stringBuilder = new StringBuilder(); | |
for (String key : intent.getExtras().keySet()) { | |
stringBuilder.append("(" + key + ", " + intent.getExtras().get(key) + ")") | |
.append(", "); | |
} |
This file contains 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
// add this to the general build.gradle, not in the subproject's build.gradle | |
// improved version of Xavier's tip http://tools.android.com/tech-docs/new-build-system/tips#TOC-Improving-Build-Server-performance. | |
// usage example default, preDex will be enabled: gradle clean build | |
// usage example disabling preDex: gradle clean build -PpreDexEnable=false | |
// preDexEnable parameter's value can be set as property of Continuous Integration build config | |
// this is the main difference from Xavier's workaround where he doing only hasProperty check | |
project.ext { | |
if (project.hasProperty('preDexEnable')) { |
This file contains 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
Collection<String> stringsCollection = new ArrayList<String>() { | |
{ | |
add("1"); | |
add("2"); | |
add("3"); | |
} | |
}; |
This file contains 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 java.lang.annotation.ElementType; | |
import java.lang.annotation.Retention; | |
import java.lang.annotation.RetentionPolicy; | |
import java.lang.annotation.Target; | |
/** | |
* Annotation to mark code as dangerous | |
* | |
* @author Artem Zinnatullin [artem.zinnatullin@gmail.com] | |
*/ |
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<ripple xmlns:android="http://schemas.android.com/apk/res/android" | |
android:color="@color/bg_item_ripple"> | |
<item> | |
<selector> | |
<item android:state_pressed="true" android:drawable="@color/bg_item_pressed"/> | |
<item android:state_focused="true" android:drawable="@color/bg_item_focused"/> | |
<item android:drawable="@color/bg_item_normal"/> | |
</selector> | |
</item> |
This file contains 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
buildscript { | |
repositories { | |
jcenter() // or use mavenCentral() repo | |
} | |
// Please visit http://search.maven.org | |
// or https://bintray.com to find newest versions of dependencies | |
dependencies { | |
// Android Gradle plugin | |
classpath 'com.android.tools.build:gradle:1.0.1' |
OlderNewer