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
| object EmailUtils { | |
| fun getEmailIntent(context: Context): Intent { | |
| val intent = Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:")) | |
| val bodyText = getEmailBody(context) | |
| val emailAddy = EMAIL_SUPPORT | |
| val subject = context.resources.getString(R.string.email_subject) | |
| intent.putExtra(Intent.EXTRA_EMAIL, arrayOf(emailAddy)) | |
| intent.putExtra(Intent.EXTRA_SUBJECT, subject) | |
| intent.putExtra(Intent.EXTRA_TEXT, bodyText) | |
| return intent |
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
| Subscription emailSubscription = | |
| emailChangeObservable | |
| .doOnNext(new Action1<CharSequence>() { | |
| @Override | |
| public void call(CharSequence charSequence) { | |
| hideEmailError(); | |
| } | |
| }) | |
| .debounce(400, TimeUnit.MILLISECONDS) | |
| .filter(new Func1<CharSequence, Boolean>() { |
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
| Subscription passwordSubscription = | |
| passwordChangeObservable | |
| .doOnNext(new Action1<CharSequence>() { | |
| @Override | |
| public void call(CharSequence charSequence) { | |
| hidePasswordError(); | |
| } | |
| }) | |
| .debounce(400, TimeUnit.MILLISECONDS) | |
| .filter(new Func1<CharSequence, Boolean>() { |
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
| 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; | |
| } |
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
| 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) |
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
| 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."); |
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
| 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(); |
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 CustomTextView : AppCompatTextView { | |
| constructor(context: Context) : super(context) { | |
| init(context) | |
| } | |
| constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { | |
| init(context, attrs) | |
| } |
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
| @AndroidEntryPoint | |
| class SettingsFragment : Fragment() { | |
| private val settingsViewModel: SettingsViewModel by viewModels() | |
| // ... | |
| } | |
| class SettingsViewModel @ViewModelInject constructor() : ViewModel() { | |
| // ... | |
| } |
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.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 |