Skip to content

Commit

Permalink
Update Gradle version; update demo app dependencies; demo app update …
Browse files Browse the repository at this point in the history
…a bit
  • Loading branch information
solkin committed Apr 17, 2022
1 parent a574f3d commit f08b49b
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 40 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Disk LRU Cache [![Build Status](https://travis-ci.com/solkin/disk-lru-cache.svg?branch=master)](https://travis-ci.com/solkin/disk-lru-cache) [![](https://jitpack.io/v/solkin/disk-lru-cache.svg)](https://jitpack.io/#solkin/disk-lru-cache) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/4321989fecfe44eab37ef08a057442d9)](https://app.codacy.com/app/solkin/disk-lru-cache?utm_source=github.com&utm_medium=referral&utm_content=solkin/disk-lru-cache&utm_campaign=Badge_Grade_Dashboard) [![Android Arsenal]( https://img.shields.io/badge/Android%20Arsenal-Disk%20LRU%20Cache-green.svg?style=flat )]( https://android-arsenal.com/details/1/7454 )
# Disk LRU Cache [![](https://jitpack.io/v/solkin/disk-lru-cache.svg)](https://jitpack.io/#solkin/disk-lru-cache) [![Android Arsenal]( https://img.shields.io/badge/Android%20Arsenal-Disk%20LRU%20Cache-green.svg?style=flat )]( https://android-arsenal.com/details/1/7454 )

Disk LRU (least recently used) cache with persisted journal.
This cache has specific capacity and location.
Expand Down Expand Up @@ -99,7 +99,7 @@ cache.getJournalSize(); // Internal cache journal size in bytes.
### License
MIT License

Copyright (c) 2021 Igor Solkin
Copyright (c) 2022 Igor Solkin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 30
compileSdkVersion 32
defaultConfig {
applicationId "com.tomclaw.cache.demo"
minSdkVersion 16
targetSdkVersion 30
targetSdkVersion 32
versionCode 1
versionName "1.0"
}
Expand All @@ -18,8 +18,8 @@ android {
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation project(path: ':cache')
}
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".MainActivity">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
17 changes: 1 addition & 16 deletions app/src/main/java/com/tomclaw/cache/demo/CacheAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class CacheAdapter extends RecyclerView.Adapter<CacheAdapter.ViewHolder>

private final List<CacheItem> cacheItems;
private final LayoutInflater inflater;
private ItemClickListener clickListener;

CacheAdapter(Context context) {
this.inflater = LayoutInflater.from(context);
Expand Down Expand Up @@ -46,13 +45,7 @@ void setCacheItems(List<CacheItem> cacheItems) {
this.cacheItems.addAll(cacheItems);
}

public interface ItemClickListener {

void onItemClick(View view, int position);

}

public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public static class ViewHolder extends RecyclerView.ViewHolder {

private final TextView title;
private final TextView subtitle;
Expand All @@ -61,14 +54,6 @@ public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickL
super(itemView);
title = itemView.findViewById(R.id.title);
subtitle = itemView.findViewById(R.id.subtitle);
itemView.setOnClickListener(this);
}

@Override
public void onClick(View view) {
if (clickListener != null) {
clickListener.onItemClick(view, getAdapterPosition());
}
}

void bindCacheItem(CacheItem item) {
Expand Down
20 changes: 8 additions & 12 deletions app/src/main/java/com/tomclaw/cache/demo/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tomclaw.cache.demo;

import android.annotation.SuppressLint;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
Expand Down Expand Up @@ -47,18 +48,12 @@ protected void onCreate(Bundle savedInstanceState) {
filesCountView = findViewById(R.id.files_count);
View createFileButton = findViewById(R.id.create_file_button);
View clearCacheButton = findViewById(R.id.clear_cache_button);
createFileButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TaskExecutor.getInstance().execute(new CreateFileTask(MainActivity.this));
}
});
clearCacheButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TaskExecutor.getInstance().execute(new ClearCacheTask(MainActivity.this));
}
});
createFileButton.setOnClickListener(v ->
TaskExecutor.getInstance().execute(new CreateFileTask(MainActivity.this))
);
clearCacheButton.setOnClickListener(v ->
TaskExecutor.getInstance().execute(new ClearCacheTask(MainActivity.this))
);

RecyclerView recyclerView = findViewById(R.id.recycler);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
Expand All @@ -68,6 +63,7 @@ public void onClick(View v) {
bindViews();
}

@SuppressLint("NotifyDataSetChanged")
public void bindViews() {
DiskLruCache cache = cache();
cacheSizeView.setText(formatBytes(cache.getCacheSize()));
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
android:id="@+id/cache_usage"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="4dp"
android:layout_height="wrap_content"
android:max="100"
tools:progress="25" />

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3c6382</color>
<color name="colorPrimaryDark">#0a3d62</color>
<color name="colorAccent">#eb2f06</color>
<color name="colorPrimaryDark">#2d4a66</color>
<color name="colorAccent">#823c40</color>
</resources>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.3'
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip

0 comments on commit f08b49b

Please sign in to comment.