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
<uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true" /> |
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
<style name="AppTheme.MyRipple"> | |
<item name="colorControlHighlight">@color/your_color</item> | |
<item name="android:background">?selectableItemBackgroundBorderless</item> | |
</style> | |
TypedValue outValue = new TypedValue(); | |
getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); | |
cardView.setBackgroundResource(outValue.resourceId); |
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
package com.example.sellectorsample; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.view.View.OnClickListener; | |
import android.widget.Button; | |
import android.widget.TextView; | |
public class MainActivity extends Activity implements OnClickListener { |
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.arch.lifecycle.ViewModel; | |
import android.arch.lifecycle.ViewModelProvider; | |
/** | |
* A provider factory that persists ViewModels {@link ViewModel}. | |
* Used if the view model has a parameterized constructor. | |
*/ | |
public class ViewModelProviderFactory<V> implements ViewModelProvider.Factory { | |
private V viewModel; |
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 int getScreenWidth(@NonNull Context context) { | |
Point size = new Point(); | |
((Activity) context).getWindowManager().getDefaultDisplay().getSize(size); | |
return size.x; | |
} | |
public static int getScreenHeight(@NonNull Context context) { | |
Point size = new Point(); | |
((Activity) context).getWindowManager().getDefaultDisplay().getSize(size); | |
return size.y; |
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
/* Module level build.gradle */ | |
android { | |
defaultConfig { | |
... | |
flavorDimensions "default" | |
} | |
signingConfigs { |
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
/* | |
* Automates generation of Release APK | |
* ./gradlew assembleRelease | |
* */ | |
Properties props = new Properties() | |
def userHome = Paths.get(System.getProperty('user.home')); | |
def propFile = file(userHome.resolve('PATH_TO_SIGNING_CONFIG_PROPERTIES_FILE.properties')) | |
if (propFile.canRead()) { | |
props.load(new FileInputStream(propFile)) | |
if (props != null && props.containsKey('STORE_FILE') && props.containsKey('KEY_STORE_PASSWORD') |
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
variantFilter { variant -> | |
// 'dev' flavor is only available for debug build | |
if (!variant.buildType.name.equals('debug') && variant.getFlavors().get(0).name.equals("dev")) { | |
variant.setIgnore(true) | |
} | |
// 'prod' flavor is only available for release build | |
if (!(variant.buildType.name.equals('release') || variant.buildType.name.equals('alpha')) && | |
variant.getFlavors().get(0).name.equals("prod")) { | |
variant.setIgnore(true) | |
} |
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
class ArchLifecycleApp : Application(), LifecycleObserver { | |
override fun onCreate() { | |
super.onCreate() | |
ProcessLifecycleOwner.get().lifecycle.addObserver(this) | |
} | |
@OnLifecycleEvent(Lifecycle.Event.ON_STOP) | |
fun onAppBackgrounded() { | |
Log.d("TAG", "App in background") |
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
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { | |
((ViewGroup) findViewById(R.id.llRoot)).getLayoutTransition() | |
.enableTransitionType(LayoutTransition.CHANGING); | |
} |