Skip to content

Instantly share code, notes, and snippets.

View lawloretienne's full-sized avatar
💭
Check out the surf report app I'm working on https://pitted.app

Etienne Lawlor lawloretienne

💭
Check out the surf report app I'm working on https://pitted.app
View GitHub Profile
This Privacy Policy governs the manner in which our Egg Day Widget application collects, uses, maintains, and discloses information collected from users ("User") of the Home Screen Widget App.
Information Collection and Use
Our Egg Day Widget App does not collect any personally identifiable information from Users. However, it may collect non-personal identification information about Users whenever they interact with the Widget. Non-personal identification information may include the type of device, operating system, and other similar technical information.
Permissions
Our Egg Day Widget App may require certain permissions to function properly, such as access to device storage to save settings or preferences. These permissions are solely used for the intended functionality of the Widget and are not used to collect any personal information.
Data Security
We adopt appropriate data collection, storage, and processing practices and security measures to protect against unauthorized access, alteration, disclosure
import android.Manifest
import android.content.Context
import android.content.pm.PackageManager
import android.location.Location
import android.os.Looper
import androidx.core.app.ActivityCompat
import androidx.lifecycle.LiveData
import com.google.android.gms.common.api.ApiException
import com.google.android.gms.location.*
import com.google.android.gms.maps.model.LatLng
@AndroidEntryPoint
class SettingsFragment : Fragment() {
private val settingsViewModel: SettingsViewModel by viewModels()
// ...
}
class SettingsViewModel @ViewModelInject constructor() : ViewModel() {
// ...
}
class CustomTextView : AppCompatTextView {
constructor(context: Context) : super(context) {
init(context)
}
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
init(context, attrs)
}
@lawloretienne
lawloretienne / RecyclerViewOnScrollListener.java
Created February 29, 2020 17:40
RecyclerViewOnScrollListener
private RecyclerView.OnScrollListener recyclerViewOnScrollListener = new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int visibleItemCount = layoutManager.getChildCount();
@lawloretienne
lawloretienne / FindVideosFirstFetchCallback.java
Created February 29, 2020 17:39
FindVideosFirstFetchCallback
private Callback<VideosCollection> findVideosFirstFetchCallback = new Callback<VideosCollection>() {
@Override
public void onResponse(Call<VideosCollection> call, Response<VideosCollection> response) {
loadingImageView.setVisibility(View.GONE);
isLoading = false;
if (!response.isSuccessful()) {
int responseCode = response.code();
if(responseCode == 504) { // 504 Unsatisfiable Request (only-if-cached)
errorTextView.setText("Can't load data.\nCheck your network connection.");
@lawloretienne
lawloretienne / FindVideosNextFetchCallback.java
Created February 29, 2020 17:38
FindVideosNextFetchCallback
private Callback<VideosCollection> findVideosNextFetchCallback = new Callback<VideosCollection>() {
@Override
public void onResponse(Call<VideosCollection> call, Response<VideosCollection> response) {
videosAdapter.removeFooter();
isLoading = false;
if (!response.isSuccessful()) {
int responseCode = response.code();
switch (responseCode){
case 504: // 504 Unsatisfiable Request (only-if-cached)
@lawloretienne
lawloretienne / SignInFieldsSubscription.java
Created February 29, 2020 17:34
SignInFieldsSubscription
Subscription signInFieldsSubscription =
Observable.combineLatest(emailChangeObservable, passwordChangeObservable,
new Func2<CharSequence, CharSequence, Boolean>() {
@Override
public Boolean call(CharSequence email, CharSequence password) {
boolean isEmailValid = validateEmail(email.toString());
boolean isPasswordValid = validatePassword(password.toString());
return isEmailValid && isPasswordValid;
}
@lawloretienne
lawloretienne / PasswordSubscription.java
Created February 29, 2020 17:32
PasswordChangeObservable
Subscription passwordSubscription =
passwordChangeObservable
.doOnNext(new Action1<CharSequence>() {
@Override
public void call(CharSequence charSequence) {
hidePasswordError();
}
})
.debounce(400, TimeUnit.MILLISECONDS)
.filter(new Func1<CharSequence, Boolean>() {
@lawloretienne
lawloretienne / EmailSubscription.java
Last active February 29, 2020 16:54
EmailChangeObservable
Subscription emailSubscription =
emailChangeObservable
.doOnNext(new Action1<CharSequence>() {
@Override
public void call(CharSequence charSequence) {
hideEmailError();
}
})
.debounce(400, TimeUnit.MILLISECONDS)
.filter(new Func1<CharSequence, Boolean>() {