Skip to content

Commit 54231d4

Browse files
author
crypticminds
committed
@loadcache example
1 parent 517837d commit 54231d4

12 files changed

Lines changed: 164 additions & 8 deletions

File tree

app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ dependencies {
3535
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
3636
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
3737

38-
implementation "com.github.crypticminds.ColdStorage:coldstoragecache:3.0.2"
39-
kapt "com.github.crypticminds.ColdStorage:coldstoragecompiler:3.0.2"
40-
implementation "com.github.crypticminds.ColdStorage:coldstorageannotation:3.0.2"
38+
implementation "com.github.crypticminds.ColdStorage:coldstoragecache:4.0.0"
39+
kapt "com.github.crypticminds.ColdStorage:coldstoragecompiler:4.0.0"
40+
implementation "com.github.crypticminds.ColdStorage:coldstorageannotation:4.0.0"
4141
}

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
android:roundIcon="@mipmap/ic_launcher_round"
1212
android:supportsRtl="true"
1313
android:theme="@style/AppTheme">
14-
<activity android:name=".MainActivity">
14+
<activity android:name=".activity.LoadImageExampleActivity">
1515
<intent-filter>
1616
<action android:name="android.intent.action.MAIN" />
1717

1818
<category android:name="android.intent.category.LAUNCHER" />
1919
</intent-filter>
2020
</activity>
21-
<activity android:name=".FreezeCacheActivity" />
21+
<activity android:name=".activity.FreezeCacheActivity" />
22+
<activity android:name=".activity.LandingPageActivity" />
2223
</application>
2324

2425
</manifest>

app/src/main/java/com/arcane/coldstorageexamples/FreezeCacheActivity.kt renamed to app/src/main/java/com/arcane/coldstorageexamples/activity/FreezeCacheActivity.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
package com.arcane.coldstorageexamples
1+
package com.arcane.coldstorageexamples.activity
22

33
import android.os.Bundle
44
import android.widget.Button
55
import android.widget.TextView
66
import androidx.appcompat.app.AppCompatActivity
77
import com.arcane.coldstoragecache.callback.OnOperationSuccessfulCallback
8+
import com.arcane.coldstorageexamples.R
89
import com.arcane.generated.MyBeautifulCacheLayer
910

1011
class FreezeCacheActivity : AppCompatActivity(), OnOperationSuccessfulCallback<String?> {
@@ -20,6 +21,7 @@ class FreezeCacheActivity : AppCompatActivity(), OnOperationSuccessfulCallback<S
2021
private val cacheLayer: MyBeautifulCacheLayer = MyBeautifulCacheLayer()
2122
//
2223
private var counter = 1
24+
2325

2426
override fun onCreate(savedInstanceState: Bundle?) {
2527
super.onCreate(savedInstanceState)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.arcane.coldstorageexamples.activity
2+
3+
import androidx.appcompat.app.AppCompatActivity
4+
5+
class LandingPageActivity : AppCompatActivity() {
6+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.arcane.coldstorageexamples.activity
2+
3+
import android.os.Bundle
4+
import android.widget.ImageView
5+
import androidx.appcompat.app.AppCompatActivity
6+
import com.arcane.coldstorageannotation.LoadImage
7+
import com.arcane.coldstoragecache.cache.Cache
8+
import com.arcane.coldstorageexamples.R
9+
10+
class LoadImageExampleActivity : AppCompatActivity() {
11+
12+
@LoadImage(
13+
R.id.image_1,
14+
"https://images.unsplash.com/photo-1549740425-5e9ed4d8cd34?ixlib=rb-1.2.1&w=1000&q=80",
15+
placeHolder = R.drawable.loading, enableLoadingAnimation = true
16+
)
17+
lateinit var imageWithAnimation: ImageView
18+
19+
override fun onCreate(savedInstanceState: Bundle?) {
20+
super.onCreate(savedInstanceState)
21+
setContentView(R.layout.load_image_example)
22+
Cache.bind(this)
23+
}
24+
}

app/src/main/java/com/arcane/coldstorageexamples/MainActivity.kt renamed to app/src/main/java/com/arcane/coldstorageexamples/activity/MainActivity.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
package com.arcane.coldstorageexamples
1+
package com.arcane.coldstorageexamples.activity
22

33
import android.os.Bundle
44
import android.widget.Button
55
import android.widget.TextView
66
import androidx.appcompat.app.AppCompatActivity
77
import com.arcane.coldstoragecache.callback.OnOperationSuccessfulCallback
8+
import com.arcane.coldstorageexamples.R
89
import com.arcane.coldstorageexamples.remotecall.MakeRemoteCall
910
import com.arcane.generated.GeneratedCacheLayer
1011

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.arcane.coldstorageexamples.fragment
2+
3+
import android.os.Bundle
4+
import android.view.LayoutInflater
5+
import android.view.View
6+
import android.view.ViewGroup
7+
import android.widget.ImageView
8+
import androidx.fragment.app.Fragment
9+
import com.arcane.coldstorageannotation.LoadImage
10+
import com.arcane.coldstoragecache.cache.Cache
11+
import com.arcane.coldstorageexamples.R
12+
13+
class LoadImageFragment : Fragment() {
14+
15+
@LoadImage(
16+
R.id.image_1,
17+
"https://i.ytimg.com/vi/kYnx7nPw-xo/maxresdefault.jpg"
18+
)
19+
lateinit var imageView1: ImageView
20+
21+
@LoadImage(
22+
R.id.image_2,
23+
"https://lh3.googleusercontent.com/proxy/JEPQhC8cm7lhnoW56CYbNzS0pHnv08mUNA67AoBknPh-4spJGdIcH0UBwdUewqa1cBd-ESqTdTeqSYiXFT6yzjFgohYzxclpllJq3r3_JOjWSQs",
24+
placeHolder = R.drawable.loading_2, enableLoadingAnimation = true
25+
)
26+
lateinit var imageView2: ImageView
27+
28+
override fun onCreateView(
29+
inflater: LayoutInflater,
30+
container: ViewGroup?,
31+
savedInstanceState: Bundle?
32+
): View? {
33+
return inflater.inflate(R.layout.load_image_example_fragment, container)
34+
}
35+
36+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
37+
super.onViewCreated(view, savedInstanceState)
38+
Cache.bind(this)
39+
}
40+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:height="24dp" android:tint="#640000"
2+
android:viewportHeight="24.0" android:viewportWidth="24.0"
3+
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="#FF000000" android:pathData="M12,6v3l4,-4 -4,-4v3c-4.42,0 -8,3.58 -8,8 0,1.57 0.46,3.03 1.24,4.26L6.7,14.8c-0.45,-0.83 -0.7,-1.79 -0.7,-2.8 0,-3.31 2.69,-6 6,-6zM18.76,7.74L17.3,9.2c0.44,0.84 0.7,1.79 0.7,2.8 0,3.31 -2.69,6 -6,6v-3l-4,4 4,4v-3c4.42,0 8,-3.58 8,-8 0,-1.57 -0.46,-3.03 -1.24,-4.26z"/>
5+
</vector>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:height="24dp" android:tint="#3D5AC8"
2+
android:viewportHeight="24.0" android:viewportWidth="24.0"
3+
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="#FF000000" android:pathData="M3,5v4h2L5,5h4L9,3L5,3c-1.1,0 -2,0.9 -2,2zM5,15L3,15v4c0,1.1 0.9,2 2,2h4v-2L5,19v-4zM19,19h-4v2h4c1.1,0 2,-0.9 2,-2v-4h-2v4zM19,3h-4v2h4v4h2L21,5c0,-1.1 -0.9,-2 -2,-2z"/>
5+
</vector>

app/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xmlns:tools="http://schemas.android.com/tools"
55
android:layout_width="match_parent"
66
android:layout_height="match_parent"
7-
tools:context=".MainActivity">
7+
tools:context=".activity.MainActivity">
88

99
<TextView
1010
android:id="@+id/remotecall1"

0 commit comments

Comments
 (0)