Skip to content

Commit b31ab73

Browse files
committed
Add Support for Java Project
0 parents  commit b31ab73

File tree

79 files changed

+2253
-0
lines changed

Some content is hidden

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

79 files changed

+2253
-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

app/.gitignore

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

app/build.gradle

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
plugins {
2+
id 'com.android.application'
3+
}
4+
apply plugin: 'kotlin-android'
5+
6+
android {
7+
compileSdkVersion 30
8+
buildToolsVersion "30.0.3"
9+
10+
defaultConfig {
11+
applicationId "id.indosw.liquidswipesample"
12+
minSdkVersion 21
13+
targetSdkVersion 30
14+
versionCode 1
15+
versionName "1.0"
16+
17+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
18+
}
19+
20+
buildTypes {
21+
release {
22+
minifyEnabled false
23+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
24+
}
25+
}
26+
compileOptions {
27+
sourceCompatibility JavaVersion.VERSION_1_8
28+
targetCompatibility JavaVersion.VERSION_1_8
29+
}
30+
}
31+
32+
dependencies {
33+
34+
implementation 'androidx.appcompat:appcompat:1.2.0'
35+
implementation 'com.google.android.material:material:1.2.1'
36+
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
37+
38+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
39+
implementation 'androidx.core:core-ktx:1.3.2'
40+
41+
implementation project(':liquid-swipe')
42+
43+
testImplementation 'junit:junit:4.13.1'
44+
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
45+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
46+
}

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 id.indosw.liquidswipesample;
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("id.indosw.liquidswipesample", 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+
xmlns:tools="http://schemas.android.com/tools"
4+
package="id.indosw.liquidswipesample">
5+
6+
<application
7+
android:allowBackup="true"
8+
android:icon="@mipmap/ic_launcher"
9+
android:label="@string/app_name"
10+
android:roundIcon="@mipmap/ic_launcher_round"
11+
android:supportsRtl="true"
12+
android:theme="@style/AppTheme"
13+
tools:ignore="AllowBackup">
14+
<activity android:name="id.indosw.liquidswipesample.MainActivityKt">
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,19 @@
1+
package id.indosw.liquidswipesample;
2+
3+
import androidx.appcompat.app.AppCompatActivity;
4+
5+
import android.os.Bundle;
6+
7+
import id.indosw.liquidswipe_lib.LiquidPager;
8+
import id.indosw.liquidswipesample.adapter.AdapterJava;
9+
10+
public class MainActivity extends AppCompatActivity {
11+
12+
@Override
13+
protected void onCreate(Bundle savedInstanceState) {
14+
super.onCreate(savedInstanceState);
15+
setContentView(R.layout.activity_main);
16+
LiquidPager pager = findViewById(R.id.pager);
17+
pager.setAdapter(new AdapterJava(getSupportFragmentManager()));
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package id.indosw.liquidswipesample
2+
3+
import android.os.Bundle
4+
import androidx.appcompat.app.AppCompatActivity
5+
import id.indosw.liquidswipe_lib.LiquidPager
6+
import id.indosw.liquidswipesample.adapter.AdapterKt
7+
8+
class MainActivityKt : AppCompatActivity() {
9+
override fun onCreate(savedInstanceState: Bundle?) {
10+
super.onCreate(savedInstanceState)
11+
setContentView(R.layout.activity_main)
12+
13+
val pager = findViewById<LiquidPager>(R.id.pager)
14+
pager.adapter = AdapterKt(supportFragmentManager)
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package id.indosw.liquidswipesample.adapter;
2+
3+
import android.os.Bundle;
4+
import androidx.fragment.app.Fragment;
5+
import androidx.fragment.app.FragmentManager;
6+
import androidx.fragment.app.FragmentPagerAdapter;
7+
import org.jetbrains.annotations.NotNull;
8+
import java.util.ArrayList;
9+
10+
import id.indosw.liquidswipesample.fragment.PageFragmentJava;
11+
import kotlin.jvm.internal.Intrinsics;
12+
13+
public class AdapterJava extends FragmentPagerAdapter {
14+
15+
private final int total;
16+
private final ArrayList<PageFragmentJava> data;
17+
18+
@NotNull
19+
public Fragment getItem(int position) {
20+
Fragment obj = data.get(position);
21+
Intrinsics.checkNotNullExpressionValue(obj, "data[position]");
22+
return obj;
23+
}
24+
25+
public int getCount() {
26+
return total;
27+
}
28+
29+
public AdapterJava(@NotNull FragmentManager fragmentManager) {
30+
super(fragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
31+
Intrinsics.checkNotNullParameter(fragmentManager, "fragmentManager");
32+
total = 6;
33+
data = new ArrayList<>(total);
34+
int i = 0;
35+
36+
for(; i < total; ++i) {
37+
PageFragmentJava fragment = new PageFragmentJava();
38+
Bundle bundle = new Bundle();
39+
bundle.putInt("POSITION", i + 1);
40+
fragment.setArguments(bundle);
41+
data.add(fragment);
42+
}
43+
44+
}
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package id.indosw.liquidswipesample.adapter
2+
3+
import android.os.Bundle
4+
import androidx.fragment.app.Fragment
5+
import androidx.fragment.app.FragmentManager
6+
import androidx.fragment.app.FragmentPagerAdapter
7+
import id.indosw.liquidswipesample.fragment.PageFragmentKt
8+
9+
class AdapterKt(fragmentManager: FragmentManager) : FragmentPagerAdapter(fragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
10+
private val total: Int = 6
11+
private val data : ArrayList<PageFragmentKt> = ArrayList(total)
12+
13+
init {
14+
for (i in 0 until total) {
15+
val fragment = PageFragmentKt()
16+
val bundle = Bundle()
17+
bundle.putInt("POSITION", i+1)
18+
fragment.arguments = bundle
19+
data.add(fragment)
20+
}
21+
}
22+
23+
24+
override fun getItem(position: Int): Fragment {
25+
return data[position]
26+
}
27+
28+
override fun getCount(): Int {
29+
return total
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package id.indosw.liquidswipesample.fragment;
2+
3+
import android.graphics.Color;
4+
import android.os.Bundle;
5+
import android.view.LayoutInflater;
6+
import android.view.View;
7+
import android.view.ViewGroup;
8+
9+
import androidx.fragment.app.Fragment;
10+
11+
import org.jetbrains.annotations.NotNull;
12+
import org.jetbrains.annotations.Nullable;
13+
14+
import id.indosw.liquidswipesample.R;
15+
import kotlin.jvm.internal.Intrinsics;
16+
17+
public final class PageFragmentJava extends Fragment {
18+
private int position = -1;
19+
20+
@SuppressWarnings("ConstantConditions")
21+
public void onCreate(@Nullable Bundle savedInstanceState) {
22+
super.onCreate(savedInstanceState);
23+
Bundle varBundle = this.getArguments();
24+
Integer intPos = varBundle != null ? varBundle.getInt("POSITION") : null;
25+
Intrinsics.checkNotNull(intPos);
26+
this.position = intPos;
27+
}
28+
29+
@Nullable
30+
public View onCreateView(@NotNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
31+
Intrinsics.checkNotNullParameter(inflater, "inflater");
32+
int viewPos;
33+
if (this.position == 1) {
34+
viewPos = R.layout.first_page;
35+
} else if (this.position == 2) {
36+
viewPos = R.layout.second_page;
37+
} else {
38+
viewPos = R.layout.fragment_page_number;
39+
}
40+
41+
int layoutId = viewPos;
42+
return this.getLayoutInflater().inflate(layoutId, container, false);
43+
}
44+
45+
@SuppressWarnings("UnnecessaryReturnStatement")
46+
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
47+
Intrinsics.checkNotNullParameter(view, "view");
48+
super.onViewCreated(view, savedInstanceState);
49+
if (this.position == 1) {
50+
return;
51+
} else if (this.position == 2) {
52+
return;
53+
} else if (this.position == 3) {
54+
view.setBackgroundColor(
55+
Color.rgb(
56+
(int) 93.000002052D,
57+
(int) 17.0000008857D,
58+
(int) 247.0000004895D)
59+
);
60+
} else if (this.position == 4) {
61+
view.setBackgroundColor(
62+
Color.rgb(255,
63+
(int) 89.99848992300001D,
64+
(int) 59.648553276D)
65+
);
66+
} else if (this.position == 5) {
67+
view.setBackgroundColor(
68+
Color.rgb(
69+
(int) 31.0000000635D,
70+
(int) 3.00000005805D,
71+
(int) 108.0000011565D)
72+
);
73+
} else if (this.position == 6) {
74+
view.setBackgroundColor(
75+
Color.rgb(
76+
(int) 87.0000024255D,
77+
(int) 159.00000572099998D,
78+
(int) 43.000001229D)
79+
);
80+
} else {
81+
view.setBackgroundColor(
82+
Color.rgb(
83+
(int) (Math.random() * (double) 255),
84+
(int) (Math.random() * (double) 255),
85+
(int) (Math.random() * (double) 255))
86+
);
87+
}
88+
89+
}
90+
}

0 commit comments

Comments
 (0)