Skip to content

Instantly share code, notes, and snippets.

👓
Doing Android stuff

Mitch Tabian mitchtabian

👓
Doing Android stuff
Block or report user

Report or block mitchtabian

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View serializers.py
class ChangePasswordSerializer(serializers.Serializer):
old_password = serializers.CharField(required=True)
new_password = serializers.CharField(required=True)
confirm_new_password = serializers.CharField(required=True)
View urls.py
from django.urls import path
from account.api.views import(
registration_view,
ObtainAuthTokenView,
account_properties_view,
update_account_view,
does_account_exist_view,
ChangePasswordView,
)
from rest_framework.authtoken.views import obtain_auth_token
View views.py
from rest_framework.generics import UpdateAPIView
from rest_framework.authentication import TokenAuthentication
from account.api.serializers import ChangePasswordSerializer
@api_view(['GET', ])
@permission_classes([])
@authentication_classes([])
def does_account_exist_view(request):
View settings.py
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.AllowAllUsersModelBackend',
'account.backends.CaseInsensitiveModelBackend',
)
View password_reset_form.html
{% extends 'base.html' %}
{% block content %}
<style type="text/css">
.form-signin {
width: 100%;
max-width: 330px;
padding: 15px;
View SaveAccountProperties.kt
fun saveAccountProperties(authToken: AuthToken, accountProperties: AccountProperties): LiveData<DataState<AccountViewState>> {
return object: NetworkBoundResource<GenericResponse, Any, AccountViewState>(
sessionManager.isConnectedToTheInternet(),
true,
false
){
// not applicable
override suspend fun createCacheRequestAndReturn() {
View GetAccountProperties.kt
fun getAccountProperties(authToken: AuthToken): LiveData<DataState<AccountViewState>> {
return object: NetworkBoundResource<AccountProperties, AccountProperties, AccountViewState>(
sessionManager.isConnectedToTheInternet(),
true,
true
){
// if network is down, view the cache and return
override suspend fun createCacheRequestAndReturn() {
withContext(Dispatchers.Main){
View AccountRepository.kt
class AccountRepository
@Inject
constructor(
val openApiMainService: OpenApiMainService,
val accountPropertiesDao: AccountPropertiesDao,
val sessionManager: SessionManager
)
{
private val TAG: String = "AppDebug"
@mitchtabian
mitchtabian / code_changes.html
Created Oct 1, 2019
Code changes for lecture: "Main Package Fragments and Layouts"
View code_changes.html
<p>There's a ton of code changes in this video. Here are links to all the classes that are changed in case you need to double-check your work.</p>
<p>
<ul>
<li><a href="https://github.com/mitchtabian/Open-API-Android-App/blob/Main-Package-Fragments-and-Layouts/app/src/main/java/com/codingwithmitch/openapi/ui/main/blog/BaseBlogFragment.kt" target="_blank" rel="nofollow">BaseBlogFragment</a></li>
<li><a href="https://github.com/mitchtabian/Open-API-Android-App/blob/Main-Package-Fragments-and-Layouts/app/src/main/java/com/codingwithmitch/openapi/ui/main/blog/BlogFragment.kt" target="_blank" rel="nofollow">BlogFragment</a></li>
<li><a href="https://github.com/mitchtabian/Open-API-Android-App/blob/Main-Package-Fragments-and-Layouts/app/src/main/res/layout/fragment_blog.xml" target="_blank" rel="nofollow">fragment_blog.xml</a></li>
<li><a href="https://github.com/mitchtabian/Open-API-Android-App/blob/Main-Package-Fragments-and-Layouts/app/src/main/java/com/codingwithmitch/openapi/ui/main/blog/ViewBlogFragment.kt" t
View AppComponent.kt
package com.codingwithmitch.openapi.di
import android.app.Application
import com.codingwithmitch.openapi.BaseApplication
import dagger.BindsInstance
import dagger.Component
import dagger.android.AndroidInjectionModule
import dagger.android.AndroidInjector
import javax.inject.Singleton
You can’t perform that action at this time.