-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
357 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
ext.deps = [:] | ||
|
||
deps.android_gradle_plugin = "com.android.tools.build:gradle:3.4.0" | ||
deps.androidx_test_runner = "androidx.test:runner:1.2.0" | ||
|
||
def build_versions = [:] | ||
build_versions.min_sdk = 15 | ||
build_versions.target_sdk = 28 | ||
build_versions.build_tools = "28.0.3" | ||
ext.build_versions = build_versions | ||
|
||
// androidx | ||
def androidx = [:] | ||
|
||
androidx.appcompat = "androidx.appcompat:appcompat:1.0.2" | ||
androidx.googlematerial = "com.google.android.material:material:1.0.0" | ||
androidx.annotation = "androidx.annotation:annotation:1.0.0" | ||
androidx.cardview = "androidx.cardview:cardview:1.0.0" | ||
androidx.drawerlayout = "androidx.drawerlayout:drawerlayout:1.0.0" | ||
androidx.coordinatorlayout = "androidx.coordinatorlayout:coordinatorlayout:1.0.0" | ||
androidx.constraintlayout = "androidx.constraintlayout:constraintlayout:1.1.3" | ||
androidx.recyclerview = "androidx.recyclerview:recyclerview:1.0.0" | ||
androidx.vectordrawable = 'androidx.vectordrawable:vectordrawable:1.0.0' | ||
|
||
def espresso = [:] | ||
espresso.core = "androidx.test.espresso:espresso-core:3.2.0" | ||
|
||
deps.androidx = androidx | ||
deps.espresso = espresso | ||
|
||
ext.deps = deps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
|
||
def toolbox = [:] | ||
toolbox.version_code = 1 | ||
toolbox.version_name = "0.1.0" | ||
toolbox.commons_version = "rc0.1.1" | ||
toolbox.android_version = "rc0.1.0" | ||
toolbox.group = "com.github.aleengo.peachbox" | ||
toolbox.artifact = "peank" | ||
toolbox.description = "Personal dev tools for Android" | ||
ext.toolbox = toolbox | ||
|
||
|
||
deps.android_maven_gradle_plugin = "com.github.dcendents:android-maven-gradle-plugin:2.1" | ||
|
||
deps.junit = "junit:junit:4.12" | ||
deps.lombok = "org.projectlombok:lombok:1.16.20" | ||
deps.gson = "com.google.code.gson:gson:2.8.5" | ||
|
||
def butterknife = [:] | ||
butterknife.runtime = "com.jakewharton:butterknife:10.0.0" | ||
butterknife.compiler = "com.jakewharton:butterknife-compiler:10.0.0" | ||
deps.butterknife = butterknife | ||
|
||
def okhttp = [:] | ||
okhttp.runtime = "com.squareup.okhttp3:okhttp:3.12.0" | ||
deps.okhttp = okhttp | ||
|
||
ext.deps = deps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
include ':box', ':commons', ':peach' | ||
include ':box', ':commons', ':peach', ':ui-adapters' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdkVersion 28 | ||
|
||
|
||
defaultConfig { | ||
minSdkVersion 15 | ||
targetSdkVersion 28 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
|
||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
|
||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
|
||
compileOnly deps.lombok | ||
annotationProcessor deps.lombok | ||
|
||
implementation deps.androidx.appcompat | ||
implementation deps.androidx.recyclerview | ||
|
||
testImplementation deps.junit | ||
androidTestImplementation deps.androidx_test_runner | ||
androidTestImplementation deps.espresso.core | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
27 changes: 27 additions & 0 deletions
27
ui-adapters/src/androidTest/java/com/aleengo/peank/uiadapter/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.aleengo.peank.uiadapter; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.test.InstrumentationRegistry; | ||
import androidx.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getTargetContext(); | ||
|
||
assertEquals("com.aleengo.peank.uiadapter.test", appContext.getPackageName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.aleengo.peank.uiadapter" /> |
8 changes: 8 additions & 0 deletions
8
ui-adapters/src/main/java/com/aleengo/peank/uiadapter/listview/AdapterListView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.aleengo.peank.uiadapter.listview; | ||
|
||
/** | ||
* Copyright Aleengo 2019. All rights reserved. | ||
* Created by bau.cj on 22/06/2019. | ||
*/ | ||
public abstract class AdapterListView { | ||
} |
20 changes: 20 additions & 0 deletions
20
ui-adapters/src/main/java/com/aleengo/peank/uiadapter/recyclerview/AdapterContract.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.aleengo.peank.uiadapter.recyclerview; | ||
|
||
|
||
import java.util.Collection; | ||
|
||
/** | ||
* Copyright Aleengo 2019. All rights reserved. | ||
* Created by bau.cj on 22/06/2019. | ||
*/ | ||
public interface AdapterContract<E> { | ||
|
||
void clear(); | ||
E getItem(int position); | ||
void addItem(E item); | ||
void addItem(int position, E item); | ||
void removeItem(int position); | ||
void updateItem(int position , E item); | ||
void addItems(Collection<E> collection); | ||
|
||
} |
100 changes: 100 additions & 0 deletions
100
ui-adapters/src/main/java/com/aleengo/peank/uiadapter/recyclerview/AdapterRecyclerView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package com.aleengo.peank.uiadapter.recyclerview; | ||
|
||
import android.content.Context; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import java.util.Collection; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
import lombok.Getter; | ||
|
||
/** | ||
* Copyright Aleengo 2019. All rights reserved. | ||
* Created by bau.cj on 22/06/2019. | ||
*/ | ||
public abstract class AdapterRecyclerView<E, ITEMVIEW extends ItemView<E>> | ||
extends RecyclerView.Adapter<AdapterRecyclerView.ViewHolder> | ||
implements AdapterContract<E> { | ||
|
||
@Getter | ||
private Context context; | ||
private final List<E> items; | ||
|
||
public AdapterRecyclerView(Context context) { | ||
this.context = context; | ||
this.items = new LinkedList<>(); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public AdapterRecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | ||
final ITEMVIEW itemview = onCreateItemView(parent, viewType); | ||
return new ViewHolder(itemview); | ||
} | ||
|
||
public abstract ITEMVIEW onCreateItemView(ViewGroup parent, int viewType); | ||
|
||
@Override | ||
public int getItemCount() { | ||
return items.size(); | ||
} | ||
|
||
@Override | ||
public E getItem(int position) { | ||
return items.get(position); | ||
} | ||
|
||
@Override | ||
public void clear() { | ||
final int oldSize = getItemCount(); | ||
items.clear(); | ||
notifyItemRangeChanged(getItemCount(), oldSize); | ||
} | ||
|
||
@Override | ||
public void addItem(E item) { | ||
items.add(item); | ||
notifyItemInserted(getItemCount() - 1); | ||
} | ||
|
||
@Override | ||
public void addItem(int position, E item) { | ||
items.add(position, item); | ||
notifyItemInserted(position); | ||
} | ||
|
||
@Override | ||
public void removeItem(int position) { | ||
items.remove(position); | ||
notifyItemRemoved(position); | ||
} | ||
|
||
@Override | ||
public void updateItem(int position, E item) { | ||
items.set(position, item); | ||
notifyItemChanged(position); | ||
} | ||
|
||
@Override | ||
public void addItems(Collection<E> newItems) { | ||
final int oldSize = getItemCount(); | ||
items.addAll(newItems); | ||
notifyItemRangeChanged(oldSize, newItems.size()); | ||
} | ||
|
||
public static class ViewHolder extends RecyclerView.ViewHolder { | ||
|
||
@Getter | ||
private View itemView; | ||
|
||
public ViewHolder(@NonNull View itemView) { | ||
super(itemView); | ||
this.itemView = itemView; | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
ui-adapters/src/main/java/com/aleengo/peank/uiadapter/recyclerview/ItemView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.aleengo.peank.uiadapter.recyclerview; | ||
|
||
import android.content.Context; | ||
import android.util.AttributeSet; | ||
import android.widget.FrameLayout; | ||
|
||
|
||
/** | ||
* Copyright Aleengo 2019. All rights reserved. | ||
* Created by bau.cj on 22/06/2019. | ||
*/ | ||
|
||
public abstract class ItemView<E> extends FrameLayout { | ||
|
||
public ItemView(Context context) { | ||
this(context, null); | ||
} | ||
|
||
public ItemView(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
} | ||
|
||
public abstract void bind(E item, int position); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<string name="app_name">UiAdapters</string> | ||
</resources> |
17 changes: 17 additions & 0 deletions
17
ui-adapters/src/test/java/com/aleengo/peank/uiadapter/ExampleUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.aleengo.peank.uiadapter; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Example local unit test, which will execute on the development machine (host). | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
public class ExampleUnitTest { | ||
@Test | ||
public void addition_isCorrect() { | ||
assertEquals(4, 2 + 2); | ||
} | ||
} |