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
ValueAnimator sizeAnimator = ValueAnimator.ofFloat(1f, 1.2f); | |
sizeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { | |
@Override | |
public void onAnimationUpdate(ValueAnimator valueAnimator) { | |
float animatedValue = (float) valueAnimator.getAnimatedValue(); | |
//something really cool happens here | |
} | |
}); |
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
// A helper class to work with SQLite database | |
public class DatabaseHelper extends SQLiteOpenHelper { | |
// Database version, which should be upgraded each time we made changes in database structure | |
private static final int DATABASE_VERSION = 1; | |
// Database name | |
private static final String DATABASE_NAME = "notes_db"; | |
public DatabaseHelper(Context context) { | |
super(context, DATABASE_NAME, null, DATABASE_VERSION); |
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
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" > | |
<!-- Other components and views --> | |
<android.support.design.bottomappbar.BottomAppBar | |
android:id="@+id/bottomAppBar" | |
android:layout_width="match_parent" |
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 fun onCreate(savedInstanceState: Bundle?) { | |
// some smart stuff here | |
bottomAppBar.replaceMenu(R.menu.menu_wallpaper) | |
bottomAppBar.setNavigationOnClickListener { | |
// do something interesting on navigation click | |
} | |
} |
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 LocationWorker(context: Context, workerParams: WorkerParameters) | |
: Worker(context, workerParams) { | |
... | |
override fun doWork(): Result { | |
val latitude = inputData.getDouble(KEY_LATITUDE, 40.1903484) | |
val longitude = inputData.getDouble(KEY_LONGITUDE, 44.5148367) | |
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
fun createConstraints() = Constraints.Builder() | |
.setRequiredNetworkType(NetworkType.UNMETERED) // if connected to WIFI | |
// other values(NOT_REQUIRED, CONNECTED, NOT_ROAMING, METERED) | |
.setRequiresBatteryNotLow(true) // if the battery is not low | |
.setRequiresStorageNotLow(true) // if the storage is not low | |
.build() | |
fun createWorkRequest(data: Data) = PeriodicWorkRequestBuilder<LocationWorker>(12, TimeUnit.HOURS) // setting period to 12 hours | |
// set input data for the work | |
.setInputData(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
fun chainWorks(filter1: Work, filter2: Work, compress: Work, upload: Work) { | |
WorkManager.getInstance() | |
// Run these works in parallel | |
.beginWith(listOf(filter1, filter2)) | |
// Dependent work (only runs after all previous work in chain) | |
.then(compress) | |
.then(upload) | |
// Don't forget to enqueue() | |
.enqueue() | |
} |
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
<?xml version="1.0" encoding="utf-8"?> | |
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<fragment | |
android:id="@+id/fragmentNavHost" | |
android:name="androidx.navigation.fragment.NavHostFragment" | |
android:layout_width="match_parent" |
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
... | |
//check is there a signed in user and navigate to specific destination | |
if (usersRepositoty.userExists()) | |
Navigation.findNavController(view).navigate(R.id.action_splashFragment_to_messageListFragment) | |
} else { | |
Navigation.findNavController(view).navigate(R.id.action_splashFragment_to_signInFragment) | |
} |
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
... | |
//navigate to Sign Up screen to create a new user | |
buttonSignUp.setOnClickListener { view -> | |
view.findNavController().navigate(R.id.action_signInFragment_to_signUpFragment) | |
} | |
... |
OlderNewer