Skip to content

Commit cc5492d

Browse files
author
Roger Hu
committed
first stab at example and library
0 parents  commit cc5492d

Some content is hidden

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

44 files changed

+1089
-0
lines changed

.gitignore

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Source: https://gist.github.com/nesquena/5617544/raw/53710b374e7df3302df43b552488d876040ada3d/.gitignore
2+
3+
# built application files
4+
*.apk
5+
*.ap_
6+
7+
# files for the dex VM
8+
*.dex
9+
10+
# Java class files
11+
*.class
12+
13+
# generated files
14+
bin/
15+
gen/
16+
17+
# Local configuration file (sdk path, etc)
18+
local.properties
19+
20+
# Eclipse project files
21+
.classpath
22+
.project
23+
24+
# Proguard folder generated by Eclipse
25+
proguard/
26+
27+
# Intellij project files
28+
*.iml
29+
*.ipr
30+
*.iws
31+
.idea/
32+
33+
*.pydevproject
34+
.project
35+
.metadata
36+
bin/**
37+
tmp/**
38+
tmp/**/*
39+
*.tmp
40+
*.bak
41+
*.swp
42+
*~.nib
43+
local.properties
44+
.classpath
45+
.settings/
46+
.loadpath
47+
48+
# External tool builders
49+
.externalToolBuilders/
50+
51+
# Locally stored "Eclipse launch configurations"
52+
*.launch
53+
54+
# CDT-specific
55+
.cproject
56+
57+
# PDT-specific
58+
.buildpath
59+
60+
# Android Studio project files
61+
*.iml
62+
.gradle
63+
.idea
64+
build
65+
import-summary.txt

build.gradle

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
3+
buildscript {
4+
repositories {
5+
google()
6+
jcenter()
7+
8+
}
9+
dependencies {
10+
classpath 'com.android.tools.build:gradle:3.4.1'
11+
12+
// NOTE: Do not place your application dependencies here; they belong
13+
// in the individual module build.gradle files
14+
}
15+
}
16+
17+
allprojects {
18+
repositories {
19+
google()
20+
jcenter()
21+
22+
}
23+
}
24+
25+
task clean(type: Delete) {
26+
delete rootProject.buildDir
27+
}

example/.gitignore

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

example/build.gradle

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 29
5+
defaultConfig {
6+
applicationId "com.codepath.cpasynchttpclient"
7+
minSdkVersion 21
8+
targetSdkVersion 29
9+
versionCode 1
10+
versionName "1.0"
11+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
12+
}
13+
buildTypes {
14+
release {
15+
minifyEnabled false
16+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
17+
}
18+
}
19+
}
20+
21+
dependencies {
22+
implementation fileTree(dir: 'libs', include: ['*.jar'])
23+
implementation 'androidx.appcompat:appcompat:1.0.2'
24+
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
25+
testImplementation 'junit:junit:4.12'
26+
androidTestImplementation 'androidx.test:runner:1.2.0'
27+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
28+
implementation project(':library')
29+
}

example/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.codepath.example;
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.codepath.cpasynchttpclient", appContext.getPackageName());
26+
}
27+
}

example/src/main/AndroidManifest.xml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.codepath.example">
4+
5+
<uses-permission android:name="android.permission.INTERNET" />
6+
7+
<application
8+
android:allowBackup="true"
9+
android:icon="@mipmap/ic_launcher"
10+
android:label="@string/app_name"
11+
android:roundIcon="@mipmap/ic_launcher_round"
12+
android:supportsRtl="true"
13+
android:theme="@style/AppTheme">
14+
<activity android:name="com.codepath.example.TestActivity">
15+
<intent-filter>
16+
<action android:name="android.intent.action.MAIN" />
17+
18+
<category android:name="android.intent.category.LAUNCHER" />
19+
</intent-filter>
20+
</activity>
21+
</application>
22+
23+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.codepath.example;
2+
3+
import androidx.appcompat.app.AppCompatActivity;
4+
5+
import android.os.Bundle;
6+
import android.util.Log;
7+
import android.view.View;
8+
9+
import com.codepath.asynchttpclient.CPAsyncHttpClient;
10+
import com.codepath.asynchttpclient.callback.CPAsyncJsonCallback;
11+
import com.codepath.asynchttpclient.callback.CPAsyncTextCallback;
12+
13+
import okhttp3.Headers;
14+
import okhttp3.ResponseBody;
15+
16+
public class TestActivity extends AppCompatActivity {
17+
18+
@Override
19+
protected void onCreate(Bundle savedInstanceState) {
20+
super.onCreate(savedInstanceState);
21+
setContentView(R.layout.activity_test);
22+
}
23+
24+
public void onTest(View view) {
25+
CPAsyncHttpClient cp = new CPAsyncHttpClient();
26+
cp.get("https://api.thecatapi.com/v1/images/search", new CPAsyncTextCallback() {
27+
@Override
28+
public void onSuccess(int statusCode, Headers headers, String response) {
29+
Log.d("DEBUG", response);
30+
}
31+
32+
@Override
33+
public void onFailure(int statusCode, Headers headers, ResponseBody errorResponse) {
34+
35+
}
36+
});
37+
38+
cp.get("https://api.thecatapi.com/v1/images/search", new CPAsyncJsonCallback() {
39+
@Override
40+
public void onSuccess(int statusCode, Headers headers, JSON json) {
41+
Log.d("DEBUG", json.toString());
42+
43+
}
44+
45+
@Override
46+
public void onFailure(int statusCode, Headers headers, Throwable errorResponse) {
47+
48+
}
49+
});
50+
}
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:aapt="http://schemas.android.com/aapt"
3+
android:width="108dp"
4+
android:height="108dp"
5+
android:viewportWidth="108"
6+
android:viewportHeight="108">
7+
<path
8+
android:fillType="evenOdd"
9+
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
10+
android:strokeWidth="1"
11+
android:strokeColor="#00000000">
12+
<aapt:attr name="android:fillColor">
13+
<gradient
14+
android:endX="78.5885"
15+
android:endY="90.9159"
16+
android:startX="48.7653"
17+
android:startY="61.0927"
18+
android:type="linear">
19+
<item
20+
android:color="#44000000"
21+
android:offset="0.0"/>
22+
<item
23+
android:color="#00000000"
24+
android:offset="1.0"/>
25+
</gradient>
26+
</aapt:attr>
27+
</path>
28+
<path
29+
android:fillColor="#FFFFFF"
30+
android:fillType="nonZero"
31+
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
32+
android:strokeWidth="1"
33+
android:strokeColor="#00000000"/>
34+
</vector>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<vector
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:width="108dp"
5+
android:height="108dp"
6+
android:viewportWidth="108"
7+
android:viewportHeight="108">
8+
<path android:fillColor="#008577"
9+
android:pathData="M0,0h108v108h-108z"/>
10+
<path android:fillColor="#00000000" android:pathData="M9,0L9,108"
11+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
12+
<path android:fillColor="#00000000" android:pathData="M19,0L19,108"
13+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
14+
<path android:fillColor="#00000000" android:pathData="M29,0L29,108"
15+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
16+
<path android:fillColor="#00000000" android:pathData="M39,0L39,108"
17+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
18+
<path android:fillColor="#00000000" android:pathData="M49,0L49,108"
19+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
20+
<path android:fillColor="#00000000" android:pathData="M59,0L59,108"
21+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
22+
<path android:fillColor="#00000000" android:pathData="M69,0L69,108"
23+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
24+
<path android:fillColor="#00000000" android:pathData="M79,0L79,108"
25+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
26+
<path android:fillColor="#00000000" android:pathData="M89,0L89,108"
27+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
28+
<path android:fillColor="#00000000" android:pathData="M99,0L99,108"
29+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
30+
<path android:fillColor="#00000000" android:pathData="M0,9L108,9"
31+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
32+
<path android:fillColor="#00000000" android:pathData="M0,19L108,19"
33+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
34+
<path android:fillColor="#00000000" android:pathData="M0,29L108,29"
35+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
36+
<path android:fillColor="#00000000" android:pathData="M0,39L108,39"
37+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
38+
<path android:fillColor="#00000000" android:pathData="M0,49L108,49"
39+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
40+
<path android:fillColor="#00000000" android:pathData="M0,59L108,59"
41+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
42+
<path android:fillColor="#00000000" android:pathData="M0,69L108,69"
43+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
44+
<path android:fillColor="#00000000" android:pathData="M0,79L108,79"
45+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
46+
<path android:fillColor="#00000000" android:pathData="M0,89L108,89"
47+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
48+
<path android:fillColor="#00000000" android:pathData="M0,99L108,99"
49+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
50+
<path android:fillColor="#00000000" android:pathData="M19,29L89,29"
51+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
52+
<path android:fillColor="#00000000" android:pathData="M19,39L89,39"
53+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
54+
<path android:fillColor="#00000000" android:pathData="M19,49L89,49"
55+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
56+
<path android:fillColor="#00000000" android:pathData="M19,59L89,59"
57+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
58+
<path android:fillColor="#00000000" android:pathData="M19,69L89,69"
59+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
60+
<path android:fillColor="#00000000" android:pathData="M19,79L89,79"
61+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
62+
<path android:fillColor="#00000000" android:pathData="M29,19L29,89"
63+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
64+
<path android:fillColor="#00000000" android:pathData="M39,19L39,89"
65+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
66+
<path android:fillColor="#00000000" android:pathData="M49,19L49,89"
67+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
68+
<path android:fillColor="#00000000" android:pathData="M59,19L59,89"
69+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
70+
<path android:fillColor="#00000000" android:pathData="M69,19L69,89"
71+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
72+
<path android:fillColor="#00000000" android:pathData="M79,19L79,89"
73+
android:strokeWidth="0.8" android:strokeColor="#33FFFFFF"/>
74+
</vector>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:app="http://schemas.android.com/apk/res-auto"
5+
xmlns:tools="http://schemas.android.com/tools"
6+
android:layout_width="match_parent"
7+
android:layout_height="match_parent"
8+
tools:context=".TestActivity">
9+
10+
<Button
11+
android:id="@+id/button"
12+
android:layout_width="wrap_content"
13+
android:layout_height="wrap_content" android:layout_marginStart="8dp"
14+
android:layout_marginTop="8dp" android:layout_marginEnd="8dp"
15+
android:layout_marginBottom="8dp" android:onClick="onTest"
16+
android:text="API Test" app:layout_constraintBottom_toBottomOf="parent"
17+
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"
18+
app:layout_constraintTop_toTopOf="parent"/>
19+
</androidx.constraintlayout.widget.ConstraintLayout>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3+
<background android:drawable="@drawable/ic_launcher_background"/>
4+
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
5+
</adaptive-icon>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3+
<background android:drawable="@drawable/ic_launcher_background"/>
4+
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
5+
</adaptive-icon>
2.89 KB
Loading
Loading
2.01 KB
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)