Skip to content

Commit a96834a

Browse files
author
SamsetDev
committed
Offline data caching
Offline App (or Offline-First App) enables user to seamlessly interact with it by using local device storage and then synchronizing the data with some remote storage (cloud database, etc) later via a background process.
1 parent b8914fe commit a96834a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1274
-0
lines changed

.idea/codeStyles/Project.xml

+29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
apply plugin: 'com.android.application'
2+
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlin-android-extensions'
4+
5+
android {
6+
compileSdkVersion 28
7+
defaultConfig {
8+
applicationId "com.samset.retrooffline"
9+
minSdkVersion 15
10+
targetSdkVersion 28
11+
versionCode 1
12+
versionName "1.0"
13+
multiDexEnabled true
14+
vectorDrawables.useSupportLibrary = true
15+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16+
}
17+
buildTypes {
18+
release {
19+
minifyEnabled false
20+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21+
}
22+
}
23+
compileOptions {
24+
sourceCompatibility = '1.8'
25+
targetCompatibility = '1.8'
26+
}
27+
28+
29+
}
30+
31+
dependencies {
32+
implementation fileTree(dir: 'libs', include: ['*.jar'])
33+
34+
/*
35+
* LIBRARY HEADER 2: ANDROID SUPPORT ************************************************************
36+
*/
37+
38+
implementation "androidx.cardview:cardview:$support"
39+
implementation "androidx.appcompat:appcompat:$support"
40+
//implementation "com.google.android.material:material:$support"
41+
implementation "androidx.constraintlayout:constraintlayout:$constraintlayout"
42+
43+
/*
44+
* LIBRARY HEADER 2: KOTLIN SUPPORT *************************************************************
45+
*/
46+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$rootProject.kotlin_version"
47+
48+
/*
49+
* LIBRARY HEADER 1: JETPACK *******************************************************************
50+
*/
51+
52+
53+
/*
54+
* LIBRARY HEADER 4: OTHER LIBRARIES ************************************************************
55+
*/
56+
implementation 'com.intuit.sdp:sdp-android:1.0.4'
57+
implementation "com.android.support:multidex:$multiDex"
58+
implementation 'com.android.support:recyclerview-v7:28.0.0-alpha1'
59+
implementation 'androidx.legacy:legacy-support-v4:1.0.0-alpha1'
60+
annotationProcessor "com.android.databinding:compiler:$databinding"
61+
62+
63+
/*
64+
* Step 2: Adding image library
65+
*/
66+
implementation "com.squareup.picasso:picasso:$rootProject.picassoVersion"
67+
implementation "de.hdodenhof:circleimageview:$rootProject.circleimageVersion"
68+
implementation "com.jakewharton.picasso:picasso2-okhttp3-downloader:$rootProject.picassodownloaderVersion"
69+
70+
/*
71+
* LIBRARY HEADER 5: RETROFIT ******************************************************************
72+
*/
73+
74+
/*
75+
* Step 1: Adding retrofit library
76+
*/
77+
implementation "com.squareup.retrofit2:retrofit:$rootProject.retrofit"
78+
implementation "com.squareup.retrofit2:converter-gson:$rootProject.retrofit"
79+
implementation "com.squareup.retrofit2:converter-scalars:$rootProject.retrofit"
80+
implementation "com.squareup.retrofit2:adapter-rxjava2:$rootProject.retrofit"
81+
implementation "com.squareup.okhttp3:logging-interceptor:$rootProject.intercepter"
82+
implementation "com.jakewharton.retrofit:retrofit2-rxjava2-adapter:$rootProject.adapter"
83+
84+
/*
85+
* Step 1: Adding volley,Gson and rx library
86+
*/
87+
88+
implementation 'com.google.guava:guava:19.0' // for google caching
89+
// implementation "com.google.code.gson:gson:$rootProject.gson"
90+
implementation "io.reactivex.rxjava2:rxjava:$rootProject.rxjava"
91+
implementation "io.reactivex.rxjava2:rxandroid:$rootProject.rxandroid"
92+
93+
/*
94+
* LIBRARY HEADER 6: DAGGER DEPENDENCY *********************************************************
95+
*/
96+
implementation "com.google.dagger:dagger:$rootProject.dagger"
97+
implementation "com.google.dagger:dagger-android:$rootProject.dagger"
98+
implementation "com.google.dagger:dagger-android-support:$rootProject.dagger"
99+
annotationProcessor "com.google.dagger:dagger-compiler:$rootProject.dagger"
100+
annotationProcessor "com.google.dagger:dagger-android-processor:$rootProject.dagger"
101+
102+
103+
104+
testImplementation 'junit:junit:4.12'
105+
androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'
106+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'
107+
}

app/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.samset.retrooffline;
2+
3+
import android.content.Context;
4+
5+
import androidx.test.InstrumentationRegistry;
6+
import androidx.test.runner.AndroidJUnit4;
7+
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
11+
import static org.junit.Assert.*;
12+
13+
/**
14+
* Instrumented test, which will execute on an Android device.
15+
*
16+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
17+
*/
18+
@RunWith(AndroidJUnit4.class)
19+
public class ExampleInstrumentedTest {
20+
@Test
21+
public void useAppContext() {
22+
// Context of the app under test.
23+
Context appContext = InstrumentationRegistry.getTargetContext();
24+
25+
assertEquals("com.samset.retrooffline", appContext.getPackageName());
26+
}
27+
}

app/src/main/AndroidManifest.xml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.samset.retrooffline">
4+
5+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
6+
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
7+
<uses-permission android:name="android.permission.INTERNET"/>
8+
<application
9+
android:name=".AppApplication"
10+
android:allowBackup="true"
11+
android:icon="@mipmap/ic_launcher"
12+
android:label="@string/app_name"
13+
android:roundIcon="@mipmap/ic_launcher_round"
14+
android:supportsRtl="true"
15+
android:theme="@style/AppTheme">
16+
<activity android:name=".ui.MainActivity">
17+
<intent-filter>
18+
<action android:name="android.intent.action.MAIN" />
19+
20+
<category android:name="android.intent.category.LAUNCHER" />
21+
</intent-filter>
22+
</activity>
23+
</application>
24+
25+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.samset.retrooffline;
2+
3+
import android.app.Application;
4+
5+
import com.squareup.picasso.Picasso;
6+
7+
import javax.inject.Inject;
8+
9+
import androidx.multidex.MultiDex;
10+
11+
/**
12+
* Copyright (C) RetrofitOfflineSample - All Rights Reserved
13+
* Unauthorized copying of this file, via any medium is strictly prohibited Proprietary and confidential.
14+
* <p>
15+
* Created by samset on 15/03/19 at 1:52 PM for RetrofitOfflineSample .
16+
*/
17+
18+
19+
public class AppApplication extends Application {
20+
21+
@Override
22+
public void onCreate() {
23+
super.onCreate();
24+
MultiDex.install(this);
25+
26+
}
27+
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.samset.retrooffline.model;
2+
3+
import java.io.Serializable;
4+
5+
/**
6+
* Copyright (C) RetrofitOfflineSample - All Rights Reserved
7+
* Unauthorized copying of this file, via any medium is strictly prohibited Proprietary and confidential.
8+
* <p>
9+
* Created by samset on 16/03/19 at 12:23 PM for RetrofitOfflineSample .
10+
*/
11+
12+
13+
public class BasicResponse implements Serializable {
14+
private String name;
15+
16+
public String getName() {
17+
return name;
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.samset.retrooffline.model;
2+
3+
import java.io.Serializable;
4+
5+
/**
6+
* Copyright (C) RetrofitOfflineSample - All Rights Reserved
7+
* Unauthorized copying of this file, via any medium is strictly prohibited Proprietary and confidential.
8+
* <p>
9+
* Created by samset on 16/03/19 at 12:24 PM for RetrofitOfflineSample .
10+
*/
11+
12+
13+
public class JSONResponses implements Serializable {
14+
15+
private String id;
16+
private String image;
17+
public String getId() {
18+
return id;
19+
}
20+
21+
public void setId(String id) {
22+
this.id = id;
23+
}
24+
25+
26+
27+
public String getImage() {
28+
return image;
29+
}
30+
31+
public void setImage(String image) {
32+
this.image = image;
33+
}
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.samset.retrooffline.network;
2+
3+
import com.samset.retrooffline.model.BasicResponse;
4+
5+
import java.util.List;
6+
7+
import retrofit2.Call;
8+
import retrofit2.http.GET;
9+
import retrofit2.http.Path;
10+
11+
/**
12+
* Copyright (C) RetrofitOfflineSample - All Rights Reserved
13+
* Unauthorized copying of this file, via any medium is strictly prohibited Proprietary and confidential.
14+
* <p>
15+
* Created by samset on 16/03/19 at 12:18 PM for RetrofitOfflineSample .
16+
*/
17+
18+
19+
public interface ApiService {
20+
21+
@GET("/users/{user}/repos")
22+
Call<List<BasicResponse>> reposForuser(@Path("user") String user);
23+
24+
25+
26+
}

0 commit comments

Comments
 (0)