Skip to content
This repository has been archived by the owner on Nov 15, 2017. It is now read-only.

Commit

Permalink
Merge branch 'release/0.2.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
redwarp committed Sep 2, 2017
2 parents a0d024b + 0b58816 commit 22f7003
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 117 deletions.
18 changes: 11 additions & 7 deletions README.md
Expand Up @@ -3,6 +3,9 @@ A fast way to store POJO in sqlite on an Android device without troubling yourse

[![Build Status](https://travis-ci.org/redwarp/Android-LazyDatabase.svg?branch=develop)](https://travis-ci.org/redwarp/Android-LazyDatabase) [![Download](https://api.bintray.com/packages/redwarp/android/lazy-database/images/download.svg) ](https://bintray.com/redwarp/android/lazy-database/_latestVersion)

# Deprecated
Google introduced [Room](https://developer.android.com/topic/libraries/architecture/room.html) which does the same thing, but better. I thereby deprecate Android-LazyDatabase, it's not useful anymore. It's still a good tutorial about how to upload artifacts to JCenter though.

## What is it?
If you are working on a proof of concept app for Android (you should probably not use it for production in it's current state), and you need to store some good old POJO, this library is there for you.
As the title says, it's a database for lazy people.
Expand All @@ -18,7 +21,7 @@ Seriously, **don't use it for production**, only for proof of concept or stuff l
<dependency>
<groupId>net.redwarp.android.library</groupId>
<artifactId>lazy-database</artifactId>
<version>0.2.2</version>
<version>0.2.3</version>
<type>aar</type>
</dependency>
```
Expand All @@ -27,7 +30,7 @@ Seriously, **don't use it for production**, only for proof of concept or stuff l
### For Gradle

```
compile 'net.redwarp.android.library:lazy-database:0.2.2'
compile 'net.redwarp.android.library:lazy-database:0.2.3'
```

## How to?
Expand Down Expand Up @@ -136,9 +139,10 @@ public class GoodOldPojo {

## What's left to do?

* [ ] A shit load
* [ ] ~~A shit load~~
* [x] Clear should also deleted chain elements
* [ ] Relations of type one to many
* [ ] Benchmarking (I mean, how fast is it compared to an hand written database)
* [ ] Search
* [ ] Unique keyword, etc...
* [ ] ~~Relations of type one to many~~
* [ ] ~~Benchmarking (I mean, how fast is it compared to an hand written database)~~
* [ ] ~~Search~~
* [ ] ~~Unique keyword, etc...~~
* [x] Nothing, it's deprecated
11 changes: 7 additions & 4 deletions build.gradle
Expand Up @@ -7,18 +7,21 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'

classpath 'com.github.ben-manes:gradle-versions-plugin:0.12.0'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.15.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
maven {
url 'https://maven.google.com'
}
jcenter()
}
}
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
#Thu Apr 07 23:40:12 CEST 2016
#Sat Sep 02 13:16:48 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
12 changes: 6 additions & 6 deletions lazy-database/build.gradle
Expand Up @@ -19,14 +19,14 @@ apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
compileSdkVersion 26
buildToolsVersion "26.0.0"

defaultConfig {
minSdkVersion 15
targetSdkVersion 23
targetSdkVersion 26
versionCode 6
versionName '0.2.2'
versionName '0.2.3'
}
buildTypes {
release {
Expand All @@ -43,8 +43,8 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-annotations:23.3.0'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'com.android.support:support-annotations:26.0.2'
compile 'org.apache.commons:commons-lang3:3.6'
}

def siteUrl = 'https://github.com/redwarp/Android-LazyDatabase' // Homepage URL of the library
Expand Down
19 changes: 10 additions & 9 deletions test-application/build.gradle
Expand Up @@ -17,13 +17,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
compileSdkVersion 26
buildToolsVersion "26.0.0"

defaultConfig {
applicationId "net.redwarp.library.testapplication"
minSdkVersion 19
targetSdkVersion 23
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
Expand All @@ -47,12 +47,13 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':lazy-database')
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.android.support:design:23.3.0'
compile 'com.facebook.stetho:stetho:1.3.1'
compile 'com.facebook.stetho:stetho-okhttp:1.3.1'
compile 'com.android.support:appcompat-v7:26.0.2'
compile 'com.android.support:recyclerview-v7:26.0.2'
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
compile 'com.android.support:design:26.0.2'
compile 'com.facebook.stetho:stetho:1.5.0'
compile 'com.facebook.stetho:stetho-okhttp:1.5.0'
}

task pullDatabase(type:Exec){
Expand Down
Expand Up @@ -6,13 +6,13 @@
import android.view.MenuItem;
import android.widget.TextView;

import butterknife.Bind;
import butterknife.BindView;
import butterknife.ButterKnife;


public class DetailActivity extends AppCompatActivity {

@Bind(R.id.text) TextView mTextView;
@BindView(R.id.text) TextView mTextView;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down
Expand Up @@ -34,16 +34,16 @@

import java.util.List;

import butterknife.Bind;
import butterknife.BindView;
import butterknife.ButterKnife;


public class MainActivity extends AppCompatActivity
implements RandomUserAdapter.ItemCountChangedListener {

public static final String EXTRA_USER_ID = "net.redwarp.library.testapplication.extra.EXTRA_USER_ID";
@Bind(R.id.recycler_view) RecyclerView mRecyclerView;
@Bind(R.id.add_button) FloatingActionButton mAddButton;
@BindView(R.id.recycler_view) RecyclerView mRecyclerView;
@BindView(R.id.add_button) FloatingActionButton mAddButton;

private NameGenerator mGenerator;
private RandomUserAdapter mAdapter;
Expand Down
Expand Up @@ -27,117 +27,117 @@
import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.BindView;
import butterknife.ButterKnife;

/**
* Created by Redwarp on 27/05/2015.
*/
public class RandomUserAdapter extends RecyclerView.Adapter<RandomUserAdapter.ViewHolder> {

private final Context mContext;
private List<RandomUser> mStuffList;
private ItemCountChangedListener mCountListener = null;
private final Context mContext;
private List<RandomUser> mStuffList;
private ItemCountChangedListener mCountListener = null;


private OnRandomUserClickedListener mUserClickedListener = null;
private OnRandomUserClickedListener mUserClickedListener = null;

public RandomUserAdapter(Context context, List<RandomUser> stuffList) {
mContext = context;
public RandomUserAdapter(Context context, List<RandomUser> stuffList) {
mContext = context;

if (stuffList != null) {
mStuffList = stuffList;
} else {
mStuffList = new ArrayList<>();
if (stuffList != null) {
mStuffList = stuffList;
} else {
mStuffList = new ArrayList<>();
}
}
}

public void addStuff(RandomUser stuff) {
if (stuff != null) {
mStuffList.add(stuff);
notifyItemInserted(mStuffList.size() - 1);
postCount();
public void addStuff(RandomUser stuff) {
if (stuff != null) {
mStuffList.add(stuff);
notifyItemInserted(mStuffList.size() - 1);
postCount();
}
}
}

public void addAllStuff(List<RandomUser> stuffList) {
if (stuffList != null) {
int startingPoint = mStuffList.size();
mStuffList.addAll(stuffList);
notifyItemRangeInserted(startingPoint, stuffList.size());
postCount();

public void addAllStuff(List<RandomUser> stuffList) {
if (stuffList != null) {
int startingPoint = mStuffList.size();
mStuffList.addAll(stuffList);
notifyItemRangeInserted(startingPoint, stuffList.size());
postCount();
}
}
}

public void clearStuff() {
int numberOfItems = mStuffList.size();
mStuffList.clear();
notifyItemRangeRemoved(0, numberOfItems);
postCount();
}

private void postCount() {
if (mCountListener != null) {
mCountListener.onItemCountChange(mStuffList.size());

public void clearStuff() {
int numberOfItems = mStuffList.size();
mStuffList.clear();
notifyItemRangeRemoved(0, numberOfItems);
postCount();
}
}

public void setOnItemCountChangeListener(ItemCountChangedListener listener) {
mCountListener = listener;
}
private void postCount() {
if (mCountListener != null) {
mCountListener.onItemCountChange(mStuffList.size());
}
}

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(mContext).inflate(R.layout.item_random_stuff, parent, false);
return new ViewHolder(view);
}
public void setOnItemCountChangeListener(ItemCountChangedListener listener) {
mCountListener = listener;
}

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View
view =
LayoutInflater.from(mContext).inflate(R.layout.item_random_stuff, parent, false);
return new ViewHolder(view);
}

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
RandomUser stuff = mStuffList.get(position);
holder.textView.setText(stuff.name);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
RandomUser stuff = mStuffList.get(position);
holder.textView.setText(stuff.name);
}

@Override
public int getItemCount() {
return mStuffList.size();
}
@Override
public int getItemCount() {
return mStuffList.size();
}


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

@Bind(R.id.text)
TextView textView;
@BindView(R.id.text)
TextView textView;

public ViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
itemView.setOnClickListener(this);
}
public ViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
itemView.setOnClickListener(this);
}

@Override
public void onClick(@NonNull final View view) {
if (mUserClickedListener != null) {
assert mStuffList != null;
int position = getLayoutPosition();
if (position < mStuffList.size()) {
mUserClickedListener.onRandomUserClicked(mStuffList.get(position), view, position);
@Override
public void onClick(@NonNull final View view) {
if (mUserClickedListener != null) {
assert mStuffList != null;
int position = getLayoutPosition();
if (position < mStuffList.size()) {
mUserClickedListener
.onRandomUserClicked(mStuffList.get(position), view, position);
}
}
}
}
}
}

public void setOnUserClickedListener(OnRandomUserClickedListener userClickedListener) {
mUserClickedListener = userClickedListener;
}
public void setOnUserClickedListener(OnRandomUserClickedListener userClickedListener) {
mUserClickedListener = userClickedListener;
}

public interface ItemCountChangedListener {
public interface ItemCountChangedListener {

void onItemCountChange(int newCount);
}
void onItemCountChange(int newCount);
}

public interface OnRandomUserClickedListener {
public interface OnRandomUserClickedListener {

void onRandomUserClicked(final RandomUser user, final View view, final int position);
}
void onRandomUserClicked(final RandomUser user, final View view, final int position);
}
}

0 comments on commit 22f7003

Please sign in to comment.