Skip to content

Commit 3f53b49

Browse files
committed
Initial commit
0 parents  commit 3f53b49

Some content is hidden

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

42 files changed

+989
-0
lines changed

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties

.idea/.gitignore

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

+23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/jarRepositories.xml

+25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/.gitignore

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

app/build.gradle

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
plugins {
2+
id 'com.android.application'
3+
}
4+
5+
android {
6+
compileSdkVersion 30
7+
buildToolsVersion "29.0.3"
8+
9+
defaultConfig {
10+
applicationId "com.test.jondh.auraandroidjava"
11+
minSdkVersion 21
12+
targetSdkVersion 30
13+
versionCode 1
14+
versionName "1.0"
15+
16+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17+
}
18+
19+
buildTypes {
20+
release {
21+
minifyEnabled false
22+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23+
}
24+
}
25+
compileOptions {
26+
sourceCompatibility JavaVersion.VERSION_1_8
27+
targetCompatibility JavaVersion.VERSION_1_8
28+
}
29+
30+
configurations.all {
31+
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
32+
def requested = details.requested
33+
if (requested.group == "androidx.appcompat") {
34+
if (!requested.name.startsWith("multidex")) {
35+
details.useVersion "1.+"
36+
}
37+
}
38+
}
39+
}
40+
}
41+
42+
dependencies {
43+
44+
implementation 'androidx.appcompat:appcompat:1.2.0'
45+
implementation 'com.google.android.material:material:1.2.1'
46+
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
47+
implementation 'com.android.volley:volley:1.1.1'
48+
implementation 'com.google.code.gson:gson:2.8.6'
49+
implementation 'com.github.bumptech.glide:glide:4.11.0'
50+
testImplementation 'junit:junit:4.+'
51+
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
52+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
53+
}

app/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,26 @@
1+
package com.test.jondh.auraandroidjava;
2+
3+
import android.content.Context;
4+
5+
import androidx.test.platform.app.InstrumentationRegistry;
6+
import androidx.test.ext.junit.runners.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.getInstrumentation().getTargetContext();
24+
assertEquals("com.test.jondh.auraandroidjava", appContext.getPackageName());
25+
}
26+
}

app/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.test.jondh.auraandroidjava">
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/Theme.AuraAndroidJava">
14+
<activity android:name=".MainActivity">
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,26 @@
1+
package com.test.jondh.auraandroidjava;
2+
3+
import androidx.appcompat.app.AppCompatActivity;
4+
5+
import android.os.Bundle;
6+
import android.util.Log;
7+
import android.widget.ImageView;
8+
import android.widget.Toast;
9+
10+
import com.android.volley.Response;
11+
import com.android.volley.VolleyError;
12+
import com.bumptech.glide.Glide;
13+
import com.test.jondh.auraandroidjava.network.APIHelper;
14+
import com.test.jondh.auraandroidjava.network.PicsumInfo;
15+
16+
import java.util.List;
17+
18+
public class MainActivity extends AppCompatActivity {
19+
20+
@Override
21+
protected void onCreate(Bundle savedInstanceState) {
22+
super.onCreate(savedInstanceState);
23+
setContentView(R.layout.activity_main);
24+
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.test.jondh.auraandroidjava.network;
2+
3+
import android.content.Context;
4+
5+
import com.android.volley.RequestQueue;
6+
import com.android.volley.Response;
7+
import com.android.volley.toolbox.Volley;
8+
import com.google.gson.Gson;
9+
import com.google.gson.reflect.TypeToken;
10+
11+
import java.lang.reflect.Type;
12+
import java.util.List;
13+
import java.util.Locale;
14+
15+
public class APIHelper {
16+
17+
private static APIHelper instance;
18+
public static APIHelper getInstance(Context context) {
19+
if (instance == null) {
20+
instance = new APIHelper(context);
21+
}
22+
return instance;
23+
}
24+
25+
private final RequestQueue queue;
26+
27+
private APIHelper(Context context) {
28+
queue = Volley.newRequestQueue(context);
29+
}
30+
31+
public void getImageInfo(String imageId, Response.Listener<PicsumInfo> listener, Response.ErrorListener errorListener) {
32+
String url = String.format(Locale.getDefault(), "https://picsum.photos/id/%s/info", imageId);
33+
Gson gson = new Gson();
34+
SimpleVolleyRequest<PicsumInfo> simpleVolleyRequest = new SimpleVolleyRequest<PicsumInfo>(url,null, listener, errorListener) {
35+
36+
@Override
37+
public PicsumInfo get(String json) {
38+
return gson.fromJson(json, PicsumInfo.class);
39+
}
40+
41+
};
42+
queue.add(simpleVolleyRequest);
43+
}
44+
45+
public void getList(Response.Listener<List<PicsumInfo>> listener, Response.ErrorListener errorListener) {
46+
String url = "https://picsum.photos/v2/list";
47+
Gson gson = new Gson();
48+
SimpleVolleyRequest<List<PicsumInfo>> simpleVolleyRequest = new SimpleVolleyRequest<List<PicsumInfo>>(url, null, listener, errorListener) {
49+
50+
@Override
51+
public List<PicsumInfo> get(String json) {
52+
Type collectionType = new TypeToken<List<PicsumInfo>>(){}.getType();
53+
return gson.fromJson(json, collectionType);
54+
}
55+
56+
};
57+
queue.add(simpleVolleyRequest);
58+
}
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.test.jondh.auraandroidjava.network;
2+
3+
public class PicsumInfo {
4+
private String id;
5+
private String author;
6+
private int width;
7+
private int height;
8+
private String url;
9+
private String download_url;
10+
11+
public String getId() {
12+
return id;
13+
}
14+
15+
public String getAuthor() {
16+
return author;
17+
}
18+
19+
public int getWidth() {
20+
return width;
21+
}
22+
23+
public int getHeight() {
24+
return height;
25+
}
26+
27+
public String getUrl() {
28+
return url;
29+
}
30+
31+
public String getDownloadUrl() {
32+
return download_url;
33+
}
34+
35+
@Override
36+
public String toString() {
37+
return "PicsumInfo{" +
38+
"id='" + id + '\'' +
39+
", author='" + author + '\'' +
40+
", width=" + width +
41+
", height=" + height +
42+
", url='" + url + '\'' +
43+
", download_url='" + download_url + '\'' +
44+
'}';
45+
}
46+
}

0 commit comments

Comments
 (0)