initial
This commit is contained in:
9
OnTime_User_live/.gitignore
vendored
Normal file
9
OnTime_User_live/.gitignore
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/workspace.xml
|
||||
/.idea/libraries
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
1
OnTime_User_live/app/.gitignore
vendored
Normal file
1
OnTime_User_live/app/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
107
OnTime_User_live/app/build.gradle
Normal file
107
OnTime_User_live/app/build.gradle
Normal file
@@ -0,0 +1,107 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'realm-android'
|
||||
apply plugin: 'kotlin-android'
|
||||
//apply plugin: 'kotlin-android-extensions'
|
||||
|
||||
android {
|
||||
namespace "id.ontime.customer"
|
||||
signingConfigs {
|
||||
debug {
|
||||
// Use local ontime keystore (make sure this file exists in the app module)
|
||||
storeFile file('ontimekeystore.jks')
|
||||
storePassword '123456@ontime'
|
||||
keyAlias 'ontimekeystore'
|
||||
keyPassword '123456@ontime'
|
||||
}
|
||||
}
|
||||
compileSdk 33
|
||||
|
||||
defaultConfig {
|
||||
applicationId "id.ontime.customer"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 33
|
||||
versionCode 10
|
||||
versionName '1.1.0'
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
multiDexEnabled true
|
||||
}
|
||||
productFlavors {
|
||||
//
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
checkReleaseBuilds false
|
||||
abortOnError false
|
||||
}
|
||||
buildTypes {
|
||||
debug {
|
||||
signingConfig signingConfigs.debug
|
||||
}
|
||||
release {
|
||||
// For now sign release with the debug config so the build works locally
|
||||
signingConfig signingConfigs.debug
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
})
|
||||
implementation('com.mikepenz:fastadapter:2.0.0@aar') {
|
||||
transitive = true
|
||||
}
|
||||
|
||||
//noinspection GradleCompatible
|
||||
implementation 'com.google.android.gms:play-services-location:19.0.1'
|
||||
implementation 'com.google.android.libraries.places:places:2.5.0'
|
||||
implementation 'com.google.android.gms:play-services-maps:18.0.2'
|
||||
implementation 'com.google.android.gms:play-services-auth:20.1.0'
|
||||
implementation 'com.google.firebase:firebase-database:20.0.3'
|
||||
implementation 'com.google.firebase:firebase-storage:20.0.0'
|
||||
implementation 'com.google.firebase:firebase-core:20.1.0'
|
||||
implementation 'com.google.firebase:firebase-messaging:20.2.0'
|
||||
implementation 'com.google.firebase:firebase-auth:19.3.1'
|
||||
implementation 'com.google.firebase:firebase-appcheck-playintegrity:16.1.0'
|
||||
implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
||||
implementation 'com.google.android.material:material:1.5.0'
|
||||
implementation 'androidx.multidex:multidex:2.0.1'
|
||||
implementation 'com.facebook.shimmer:shimmer:0.1.0@aar'
|
||||
implementation 'com.google.guava:guava:25.0-android'
|
||||
implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
|
||||
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
|
||||
implementation 'me.relex:circleindicator:1.2.1@aar'
|
||||
implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.2'
|
||||
implementation 'com.facebook.shimmer:shimmer:0.1.0@aar'
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.2'
|
||||
implementation 'com.mobsandgeeks:android-saripaar:2.0.3'
|
||||
implementation 'net.the4thdimension:audio-wife:1.0.3'
|
||||
implementation 'org.greenrobot:eventbus:3.0.0'
|
||||
implementation 'com.makeramen:roundedimageview:2.2.1'
|
||||
implementation 'com.squareup.picasso:picasso:2.5.2'
|
||||
implementation 'com.github.siyamed:android-shape-imageview:0.9.3'
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'de.hdodenhof:circleimageview:3.1.0'
|
||||
implementation 'com.github.yesterselga:country-picker-android:1.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
|
||||
implementation 'com.wdullaer:materialdatetimepicker:3.2.0'
|
||||
implementation 'org.jsoup:jsoup:1.11.3'
|
||||
implementation "androidx.exifinterface:exifinterface:1.3.3"
|
||||
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
// implementation "org.jetbrains.kotlin:kotlin-stdlib:1.6.10"
|
||||
implementation 'com.google.android.material:material:1.7.0-alpha01'
|
||||
implementation 'androidx.preference:preference-ktx:1.2.0'
|
||||
implementation 'com.google.android.play:core:1.10.3'
|
||||
|
||||
}
|
||||
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
10
OnTime_User_live/app/butterknife-proguard-rules.pro
Normal file
10
OnTime_User_live/app/butterknife-proguard-rules.pro
Normal file
@@ -0,0 +1,10 @@
|
||||
# ButterKnife config start
|
||||
# Retain generated class which implement Unbinder.
|
||||
-keep public class * implements butterknife.Unbinder { public <init>(...); }
|
||||
|
||||
# Prevent obfuscation of types which use ButterKnife annotations since the simple name
|
||||
# is used to reflectively look up the generated ViewBinding.
|
||||
-keep class butterknife.*
|
||||
-keepclasseswithmembernames class * { @butterknife.* <methods>; }
|
||||
-keepclasseswithmembernames class * { @butterknife.* <fields>; }
|
||||
# ButterKnife config end
|
||||
122
OnTime_User_live/app/google-services.json.old
Normal file
122
OnTime_User_live/app/google-services.json.old
Normal file
@@ -0,0 +1,122 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "1047116828676",
|
||||
"firebase_url": "https://project-on-time-apps-default-rtdb.firebaseio.com",
|
||||
"project_id": "project-on-time-apps",
|
||||
"storage_bucket": "project-on-time-apps.appspot.com"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:1047116828676:android:001e55471b22df4c7de551",
|
||||
"android_client_info": {
|
||||
"package_name": "id.ontime.customer"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "1047116828676-3vfdl09rkd6431rmj2uuq470jgt0iarv.apps.googleusercontent.com",
|
||||
"client_type": 1,
|
||||
"android_info": {
|
||||
"package_name": "id.ontime.customer",
|
||||
"certificate_hash": "dc13dadc9f5fa8ad3a6cf71c5c9455bbad2ef610"
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_id": "1047116828676-1gsik6mhdcagnotnc9sfsf9a0ru6h16m.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "YOUR_FIREBASE_API_KEY"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "1047116828676-1gsik6mhdcagnotnc9sfsf9a0ru6h16m.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:1047116828676:android:4dfd895c7938898c7de551",
|
||||
"android_client_info": {
|
||||
"package_name": "id.ontime.driver"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "1047116828676-n0vvok0isnc1fceat8iphu0q46bdkrp7.apps.googleusercontent.com",
|
||||
"client_type": 1,
|
||||
"android_info": {
|
||||
"package_name": "id.ontime.driver",
|
||||
"certificate_hash": "dc13dadc9f5fa8ad3a6cf71c5c9455bbad2ef610"
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_id": "1047116828676-1gsik6mhdcagnotnc9sfsf9a0ru6h16m.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "YOUR_FIREBASE_API_KEY"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "1047116828676-1gsik6mhdcagnotnc9sfsf9a0ru6h16m.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:1047116828676:android:d259e2a7556d25487de551",
|
||||
"android_client_info": {
|
||||
"package_name": "id.ontime.merchant"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "1047116828676-kbnbu8d3s1b5mive9oc6ij5h0cfvfpvv.apps.googleusercontent.com",
|
||||
"client_type": 1,
|
||||
"android_info": {
|
||||
"package_name": "id.ontime.merchant",
|
||||
"certificate_hash": "dc13dadc9f5fa8ad3a6cf71c5c9455bbad2ef610"
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_id": "1047116828676-1gsik6mhdcagnotnc9sfsf9a0ru6h16m.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "YOUR_FIREBASE_API_KEY"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "1047116828676-1gsik6mhdcagnotnc9sfsf9a0ru6h16m.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
||||
31
OnTime_User_live/app/guava-proguard-rules.pro
Normal file
31
OnTime_User_live/app/guava-proguard-rules.pro
Normal file
@@ -0,0 +1,31 @@
|
||||
# Configuration for Guava 18.0
|
||||
#
|
||||
# disagrees with instructions provided by Guava project: https://code.google.com/p/guava-libraries/wiki/UsingProGuardWithGuava
|
||||
|
||||
-keep class com.google.common.io.Resources {
|
||||
public static <methods>;
|
||||
}
|
||||
-keep class com.google.common.collect.Lists {
|
||||
public static ** reverse(**);
|
||||
}
|
||||
-keep class com.google.common.base.Charsets {
|
||||
public static <fields>;
|
||||
}
|
||||
|
||||
-keep class com.google.common.base.Joiner {
|
||||
public static com.google.common.base.Joiner on(java.lang.String);
|
||||
public ** join(...);
|
||||
}
|
||||
|
||||
-keep class com.google.common.collect.MapMakerInternalMap$ReferenceEntry
|
||||
-keep class com.google.common.cache.LocalCache$ReferenceEntry
|
||||
|
||||
# http://stackoverflow.com/questions/9120338/proguard-configuration-for-guava-with-obfuscation-and-optimization
|
||||
-dontwarn javax.annotation.**
|
||||
-dontwarn javax.inject.**
|
||||
-dontwarn sun.misc.Unsafe
|
||||
|
||||
# Guava 19.0
|
||||
-dontwarn java.lang.ClassValue
|
||||
-dontwarn com.google.j2objc.annotations.Weak
|
||||
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
|
||||
7
OnTime_User_live/app/okhttp3-proguard-rules.pro
Normal file
7
OnTime_User_live/app/okhttp3-proguard-rules.pro
Normal file
@@ -0,0 +1,7 @@
|
||||
# OkHttp
|
||||
-keepattributes Signature
|
||||
-keepattributes *Annotation*
|
||||
-keep class okhttp3.** { *; }
|
||||
-keep interface okhttp3.** { *; }
|
||||
-dontwarn okhttp3.**
|
||||
-dontwarn okio.**
|
||||
141
OnTime_User_live/app/proguard-rules.pro
vendored
Normal file
141
OnTime_User_live/app/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,141 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in D:\bradhawk\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# 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 *;
|
||||
#}
|
||||
#-dontwarn ourdevelopsgoeks.**
|
||||
|
||||
# This is a configuration file for ProGuard.
|
||||
# http://proguard.sourceforge.net/index.html#manual/usage.html
|
||||
-dontusemixedcaseclassnames
|
||||
-dontskipnonpubliclibraryclasses
|
||||
-verbose
|
||||
|
||||
#-dontwarn retrofit2.**
|
||||
#-keep class retrofit2.** { *; }
|
||||
#-keepattributes Signature
|
||||
#-keepattributes Exceptions
|
||||
#
|
||||
-dontwarn com.squareup.picasso.**
|
||||
#-keep class com.squareup.picasso.** { *; }
|
||||
#
|
||||
#-dontwarn com.google.common.**
|
||||
#-keep class com.google.common.** { *; }
|
||||
#
|
||||
#-dontwarn okio.**
|
||||
#-keep class okio.** { *; }
|
||||
#
|
||||
#-dontwarn android.**
|
||||
#-keep class android.** { *; }
|
||||
#
|
||||
#-dontwarn android.content.**
|
||||
#-keep class android.content.** { *; }
|
||||
##
|
||||
#-dontwarn android.graphics.**
|
||||
#-keep class android.graphics.** { *; }
|
||||
##
|
||||
#-dontwarn android.util.**
|
||||
#-keep class android.util.** { *; }
|
||||
##
|
||||
#-dontwarn android.view.**
|
||||
#-keep class android.view.** { *; }
|
||||
#
|
||||
-dontwarn com.balqisstuido.goeks.**
|
||||
-keep class ourdevelops.goeks.** { *; }
|
||||
|
||||
|
||||
|
||||
|
||||
#
|
||||
## Optimization is turned off by default. Dex does not like code run
|
||||
## through the ProGuard optimize and preverify steps (and performs some
|
||||
## of these optimizations on its own).
|
||||
##-dontoptimize
|
||||
##-dontpreverify
|
||||
#
|
||||
## If you want to enable optimization, you should include the
|
||||
## following:
|
||||
#-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
|
||||
#-optimizationpasses 5
|
||||
#-allowaccessmodification
|
||||
##
|
||||
## Note that you cannot just include these flags in your own
|
||||
## configuration file; if you are including this file, optimization
|
||||
## will be turned off. You'll need to either edit this file, or
|
||||
## duplicate the contents of this file and remove the include of this
|
||||
## file from your project's proguard.config path property.
|
||||
#
|
||||
#-keep public class * extends android.app.Activity
|
||||
#-keep public class * extends android.app.Application
|
||||
#-keep public class * extends android.app.Service
|
||||
#-keep public class * extends android.content.BroadcastReceiver
|
||||
#-keep public class * extends android.content.ContentProvider
|
||||
#-keep public class * extends android.app.backup.BackupAgent
|
||||
#-keep public class * extends android.preference.Preference
|
||||
#-keep public class * extends android.support.v4.app.Fragment
|
||||
#-keep public class * extends android.support.v4.app.DialogFragment
|
||||
#-keep public class * extends com.actionbarsherlock.app.SherlockListFragment
|
||||
#-keep public class * extends com.actionbarsherlock.app.SherlockFragment
|
||||
#-keep public class * extends com.actionbarsherlock.app.SherlockFragmentActivity
|
||||
#-keep public class * extends android.app.Fragment
|
||||
#-keep public class com.android.vending.licensing.ILicensingService
|
||||
#
|
||||
## For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
|
||||
#-keepclasseswithmembernames class * {
|
||||
# native <methods>;
|
||||
#}
|
||||
#
|
||||
#-keep public class * extends android.view.View {
|
||||
# public <init>(android.content.Context);
|
||||
# public <init>(android.content.Context, android.util.AttributeSet);
|
||||
# public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
# public void set*(...);
|
||||
#}
|
||||
#
|
||||
#-keepclasseswithmembers class * {
|
||||
# public <init>(android.content.Context, android.util.AttributeSet);
|
||||
#}
|
||||
#
|
||||
#-keepclasseswithmembers class * {
|
||||
# public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
#}
|
||||
#
|
||||
#-keepclassmembers class * extends android.app.Activity {
|
||||
# public void *(android.view.View);
|
||||
#}
|
||||
#
|
||||
## For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
|
||||
#-keepclassmembers enum * {
|
||||
# public static **[] values();
|
||||
# public static ** valueOf(java.lang.String);
|
||||
#}
|
||||
#
|
||||
#-keep class * implements android.os.Parcelable {
|
||||
# public static final android.os.Parcelable$Creator *;
|
||||
#}
|
||||
#
|
||||
#-keepclassmembers class **.R$* {
|
||||
# public static <fields>;
|
||||
#}
|
||||
#
|
||||
#-keep class android.support.v4.app.** { *; }
|
||||
#-keep interface android.support.v4.app.** { *; }
|
||||
#-keep class com.actionbarsherlock.** { *; }
|
||||
#-keep interface com.actionbarsherlock.** { *; }
|
||||
## The support library contains references to newer platform versions.
|
||||
## Don't warn about those in case this app is linking against an older
|
||||
## platform version. We know about them, and they are safe.
|
||||
#-dontwarn android.support.**
|
||||
#-dontwarn com.google.ads.**
|
||||
20
OnTime_User_live/app/release/output-metadata.json
Normal file
20
OnTime_User_live/app/release/output-metadata.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"version": 3,
|
||||
"artifactType": {
|
||||
"type": "APK",
|
||||
"kind": "Directory"
|
||||
},
|
||||
"applicationId": "id.ontime.customer",
|
||||
"variantName": "release",
|
||||
"elements": [
|
||||
{
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 10,
|
||||
"versionName": "1.1.0",
|
||||
"outputFile": "app-release.apk"
|
||||
}
|
||||
],
|
||||
"elementType": "File"
|
||||
}
|
||||
10
OnTime_User_live/app/retrofit-proguard-rules.pro
Normal file
10
OnTime_User_live/app/retrofit-proguard-rules.pro
Normal file
@@ -0,0 +1,10 @@
|
||||
# Platform calls Class.forName on types which do not exist on Android to determine platform.
|
||||
-dontnote retrofit2.Platform
|
||||
# Platform used when running on RoboVM on iOS. Will not be used at runtime.
|
||||
-dontnote retrofit2.Platform$IOS$MainThreadExecutor
|
||||
# Platform used when running on Java 8 VMs. Will not be used at runtime.
|
||||
-dontwarn retrofit2.Platform$Java8
|
||||
# Retain generic type information for use by reflection by converters and adapters.
|
||||
-keepattributes Signature
|
||||
# Retain declared checked exceptions for use by a Proxy instance.
|
||||
-keepattributes Exceptions
|
||||
2
OnTime_User_live/app/saripaar-proguard-rules.pro
Normal file
2
OnTime_User_live/app/saripaar-proguard-rules.pro
Normal file
@@ -0,0 +1,2 @@
|
||||
-keep class com.mobsandgeeks.saripaar.** {*;}
|
||||
-keep @com.mobsandgeeks.saripaar.annotation.ValidateUsing class * {*;}
|
||||
315
OnTime_User_live/app/src/main/AndroidManifest.xml
Normal file
315
OnTime_User_live/app/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,315 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="id.ontime.customer"
|
||||
android:installLocation="auto">
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.CALL_PHONE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
tools:ignore="ScopedStorage" />
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" /> <!-- <uses-permission android:name="android.permission.GET_TASKS" /> -->
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
|
||||
<uses-feature android:name="android.hardware.camera" />
|
||||
<uses-feature android:name="android.hardware.camera.autofocus" />
|
||||
|
||||
<application
|
||||
android:name="id.ontime.customer.constants.BaseApp"
|
||||
android:allowBackup="false"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:fullBackupContent="@xml/backup_descriptor"
|
||||
android:label="@string/app_name"
|
||||
android:largeHeap="true"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
tools:replace="android:allowBackup"
|
||||
tools:targetApi="s"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules">
|
||||
<activity
|
||||
android:name=".activity.FavoriteNewsActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/noActionBar"/>
|
||||
<activity
|
||||
android:name=".activity.SplashActivity"
|
||||
android:exported="true"
|
||||
android:noHistory="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name="id.ontime.customer.panicbutton.SettingsMenuActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity
|
||||
android:name="id.ontime.customer.panicbutton.RegisterPanicActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity
|
||||
android:name="id.ontime.customer.panicbutton.ProfileMenuActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity
|
||||
android:name="id.ontime.customer.panicbutton.PanicButtonActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity
|
||||
android:name="id.ontime.customer.panicbutton.LoginPanicActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity
|
||||
android:name="id.ontime.customer.panicbutton.InfoPanicActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity
|
||||
android:name="id.ontime.customer.panicbutton.ChangePasswordPanicActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/noActionBar" />
|
||||
<activity
|
||||
android:name="id.ontime.customer.panicbutton.ActiveButtonActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity
|
||||
android:name=".activity.ConfirmWAActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_confirm_w_a"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity
|
||||
android:name=".activity.PromoActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".activity.DetailOrderActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".activity.MapsMerchantActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".activity.DetailMerchantActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".activity.PicklocationActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".activity.AllMerchantActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".activity.AllBeritaActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/noActionBar"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".activity.WalletActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".activity.PpobActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".activity.OngkirActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".activity.ChatActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<service
|
||||
android:name="id.ontime.customer.utils.api.service.MessagingService"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="com.google.firebase.MESSAGING_EVENT" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<activity
|
||||
android:name=".activity.RateActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Login_phone"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".activity.WithdrawActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Login_phone"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".activity.TopUpPulsaActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Login_phone"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".activity.TopUpPlnActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Login_phone"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".activity.TopUpBpjsActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Login_phone"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".activity.OperatorProviderListActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Login_phone"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".activity.TopupviewActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Login_phone"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".activity.IntroActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.BeritaDetailActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.TopupSaldoActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".activity.RideCarActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.RentCarActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.SendActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.SendDetailActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.ProgressActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.PrivacyActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/noActionBar" />
|
||||
<activity
|
||||
android:name=".activity.RegisterActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/noActionBar" />
|
||||
<activity
|
||||
android:name=".activity.EditProfileActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/noActionBar" />
|
||||
<activity
|
||||
android:name=".activity.LoginActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".activity.LupapassActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/noActionBar"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".activity.ChangepassActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
|
||||
<activity
|
||||
android:name=".activity.MainActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.google.firebase.auth.internal.FederatedSignInActivity"
|
||||
android:excludeFromRecents="true"
|
||||
android:exported="true"
|
||||
android:launchMode="singleInstance"
|
||||
android:permission="com.google.firebase.auth.api.gms.permission.LAUNCH_FEDERATED_SIGN_IN"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar"
|
||||
tools:replace="android:launchMode" />
|
||||
|
||||
<service android:name="com.google.firebase.components.ComponentDiscoveryService" />
|
||||
|
||||
<meta-data
|
||||
android:name="com.google.firebase.components:com.google.firebase.auth.FirebaseAuthRegistrar"
|
||||
android:value="com.google.firebase.components.ComponentRegistrar" />
|
||||
<meta-data
|
||||
android:name="com.google.firebase.components:com.google.firebase.analytics.connector.internal.AnalyticsConnectorRegistrar"
|
||||
android:value="com.google.firebase.components.ComponentRegistrar" />
|
||||
<meta-data
|
||||
android:name="com.google.firebase.components:com.google.firebase.iid.Registrar"
|
||||
android:value="com.google.firebase.components.ComponentRegistrar" />
|
||||
<meta-data
|
||||
android:name="com.google.android.geo.API_KEY"
|
||||
android:value="@string/google_maps_key" />
|
||||
<meta-data
|
||||
android:name="com.google.android.gms.ads.APPLICATION_ID"
|
||||
android:value="ca-app-pub-3940256099942544~3347511713" />
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
|
||||
<uses-library
|
||||
android:name="org.apache.http.legacy"
|
||||
android:required="false" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
BIN
OnTime_User_live/app/src/main/assets/fonts/Montserrat_Bold.ttf
Normal file
BIN
OnTime_User_live/app/src/main/assets/fonts/Montserrat_Bold.ttf
Normal file
Binary file not shown.
BIN
OnTime_User_live/app/src/main/assets/fonts/Montserrat_Medium.ttf
Normal file
BIN
OnTime_User_live/app/src/main/assets/fonts/Montserrat_Medium.ttf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
OnTime_User_live/app/src/main/assets/fonts/NeoSansPro_Medium.ttf
Normal file
BIN
OnTime_User_live/app/src/main/assets/fonts/NeoSansPro_Medium.ttf
Normal file
Binary file not shown.
Binary file not shown.
BIN
OnTime_User_live/app/src/main/assets/fonts/OpenSans-Bold.ttf
Normal file
BIN
OnTime_User_live/app/src/main/assets/fonts/OpenSans-Bold.ttf
Normal file
Binary file not shown.
BIN
OnTime_User_live/app/src/main/assets/fonts/OpenSans-Light.ttf
Normal file
BIN
OnTime_User_live/app/src/main/assets/fonts/OpenSans-Light.ttf
Normal file
Binary file not shown.
BIN
OnTime_User_live/app/src/main/assets/fonts/OpenSans-Regular.ttf
Normal file
BIN
OnTime_User_live/app/src/main/assets/fonts/OpenSans-Regular.ttf
Normal file
Binary file not shown.
Binary file not shown.
BIN
OnTime_User_live/app/src/main/ic_launcher-playstore.png
Normal file
BIN
OnTime_User_live/app/src/main/ic_launcher-playstore.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
@@ -0,0 +1,79 @@
|
||||
package
|
||||
customfonts;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
public
|
||||
class
|
||||
AutoCompleteTextViewSFProDisplayRegular
|
||||
extends
|
||||
androidx.appcompat.widget.AppCompatAutoCompleteTextView {
|
||||
|
||||
|
||||
public AutoCompleteTextViewSFProDisplayRegular(Context
|
||||
context,
|
||||
AttributeSet
|
||||
attrs,
|
||||
int
|
||||
defStyle) {
|
||||
|
||||
|
||||
super(context,
|
||||
attrs,
|
||||
defStyle);
|
||||
|
||||
|
||||
init();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public AutoCompleteTextViewSFProDisplayRegular(Context
|
||||
context,
|
||||
AttributeSet
|
||||
attrs) {
|
||||
|
||||
|
||||
super(context,
|
||||
attrs);
|
||||
|
||||
|
||||
init();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public AutoCompleteTextViewSFProDisplayRegular(Context
|
||||
context) {
|
||||
|
||||
|
||||
super(context);
|
||||
|
||||
|
||||
init();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void
|
||||
init() {
|
||||
|
||||
|
||||
if
|
||||
(!isInEditMode()) {
|
||||
|
||||
|
||||
setTypeface(Typeface.createFromAsset(getContext().getAssets(),
|
||||
"fonts/Montserrat_SemiBold.ttf"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package
|
||||
customfonts;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
public
|
||||
class
|
||||
Button_SF_Pro_Display_Medium
|
||||
extends
|
||||
androidx.appcompat.widget.AppCompatButton {
|
||||
|
||||
|
||||
public Button_SF_Pro_Display_Medium(Context
|
||||
context,
|
||||
AttributeSet
|
||||
attrs,
|
||||
int
|
||||
defStyle) {
|
||||
|
||||
|
||||
super(context,
|
||||
attrs,
|
||||
defStyle);
|
||||
|
||||
|
||||
init();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Button_SF_Pro_Display_Medium(Context
|
||||
context,
|
||||
AttributeSet
|
||||
attrs) {
|
||||
|
||||
|
||||
super(context,
|
||||
attrs);
|
||||
|
||||
|
||||
init();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Button_SF_Pro_Display_Medium(Context
|
||||
context) {
|
||||
|
||||
|
||||
super(context);
|
||||
|
||||
|
||||
init();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void
|
||||
init() {
|
||||
|
||||
|
||||
if
|
||||
(!isInEditMode()) {
|
||||
|
||||
|
||||
setTypeface(Typeface.createFromAsset(getContext().getAssets(),
|
||||
"fonts/Montserrat_Bold.ttf"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package
|
||||
customfonts;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
public
|
||||
class
|
||||
EditTextSFProDisplayMedium
|
||||
extends
|
||||
androidx.appcompat.widget.AppCompatEditText {
|
||||
|
||||
|
||||
public EditTextSFProDisplayMedium(Context
|
||||
context,
|
||||
AttributeSet
|
||||
attrs,
|
||||
int
|
||||
defStyle) {
|
||||
|
||||
|
||||
super(context,
|
||||
attrs,
|
||||
defStyle);
|
||||
|
||||
|
||||
init();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public EditTextSFProDisplayMedium(Context
|
||||
context,
|
||||
AttributeSet
|
||||
attrs) {
|
||||
|
||||
|
||||
super(context,
|
||||
attrs);
|
||||
|
||||
|
||||
init();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public EditTextSFProDisplayMedium(Context
|
||||
context) {
|
||||
|
||||
|
||||
super(context);
|
||||
|
||||
|
||||
init();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void
|
||||
init() {
|
||||
|
||||
|
||||
if
|
||||
(!isInEditMode()) {
|
||||
|
||||
|
||||
setTypeface(Typeface.createFromAsset(getContext().getAssets(),
|
||||
"fonts/Montserrat_Bold.ttf"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package
|
||||
customfonts;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
public
|
||||
class
|
||||
EditTextSFProDisplayRegular
|
||||
extends
|
||||
androidx.appcompat.widget.AppCompatEditText {
|
||||
|
||||
|
||||
public EditTextSFProDisplayRegular(Context
|
||||
context,
|
||||
AttributeSet
|
||||
attrs,
|
||||
int
|
||||
defStyle) {
|
||||
|
||||
|
||||
super(context,
|
||||
attrs,
|
||||
defStyle);
|
||||
|
||||
|
||||
init();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public EditTextSFProDisplayRegular(Context
|
||||
context,
|
||||
AttributeSet
|
||||
attrs) {
|
||||
|
||||
|
||||
super(context,
|
||||
attrs);
|
||||
|
||||
|
||||
init();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public EditTextSFProDisplayRegular(Context
|
||||
context) {
|
||||
|
||||
|
||||
super(context);
|
||||
|
||||
|
||||
init();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void
|
||||
init() {
|
||||
|
||||
|
||||
if
|
||||
(!isInEditMode()) {
|
||||
|
||||
|
||||
setTypeface(Typeface.createFromAsset(getContext().getAssets(),
|
||||
"fonts/Montserrat_SemiBold.ttf"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package
|
||||
customfonts;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.RadioButton;
|
||||
|
||||
@SuppressLint("AppCompatCustomView")
|
||||
public
|
||||
class
|
||||
RadioButton_SF_Pro_Display_Medium
|
||||
extends
|
||||
RadioButton {
|
||||
|
||||
|
||||
public RadioButton_SF_Pro_Display_Medium(Context
|
||||
context,
|
||||
AttributeSet
|
||||
attrs,
|
||||
int
|
||||
defStyle) {
|
||||
|
||||
|
||||
super(context,
|
||||
attrs,
|
||||
defStyle);
|
||||
|
||||
|
||||
init();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public RadioButton_SF_Pro_Display_Medium(Context
|
||||
context,
|
||||
AttributeSet
|
||||
attrs) {
|
||||
|
||||
|
||||
super(context,
|
||||
attrs);
|
||||
|
||||
|
||||
init();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public RadioButton_SF_Pro_Display_Medium(Context
|
||||
context) {
|
||||
|
||||
|
||||
super(context);
|
||||
|
||||
|
||||
init();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void
|
||||
init() {
|
||||
|
||||
|
||||
if
|
||||
(!isInEditMode()) {
|
||||
|
||||
|
||||
setTypeface(Typeface.createFromAsset(getContext().getAssets(),
|
||||
"fonts/Montserrat_Bold.ttf"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package
|
||||
customfonts;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
public
|
||||
class
|
||||
TextViewSFProDisplayMedium
|
||||
extends
|
||||
androidx.appcompat.widget.AppCompatTextView {
|
||||
|
||||
|
||||
public TextViewSFProDisplayMedium(Context
|
||||
context,
|
||||
AttributeSet
|
||||
attrs,
|
||||
int
|
||||
defStyle) {
|
||||
|
||||
|
||||
super(context,
|
||||
attrs,
|
||||
defStyle);
|
||||
|
||||
|
||||
init();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public TextViewSFProDisplayMedium(Context
|
||||
context,
|
||||
AttributeSet
|
||||
attrs) {
|
||||
|
||||
|
||||
super(context,
|
||||
attrs);
|
||||
|
||||
|
||||
init();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public TextViewSFProDisplayMedium(Context
|
||||
context) {
|
||||
|
||||
|
||||
super(context);
|
||||
|
||||
|
||||
init();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void
|
||||
init() {
|
||||
|
||||
|
||||
if
|
||||
(!isInEditMode()) {
|
||||
|
||||
|
||||
setTypeface(Typeface.createFromAsset(getContext().getAssets(),
|
||||
"fonts/Montserrat_Bold.ttf"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package
|
||||
customfonts;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
public class TextViewSFProDisplayRegular extends androidx.appcompat.widget.AppCompatTextView {
|
||||
|
||||
public TextViewSFProDisplayRegular(Context context, AttributeSet attrs, int defStyle) {
|
||||
|
||||
super(context, attrs, defStyle);
|
||||
init();
|
||||
}
|
||||
|
||||
public TextViewSFProDisplayRegular(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public TextViewSFProDisplayRegular(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if (!isInEditMode()) {
|
||||
setTypeface(Typeface.createFromAsset(getContext().getAssets(), "fonts/Montserrat_SemiBold.ttf"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.item.BeritaItem;
|
||||
import id.ontime.customer.json.BeritaDetailRequestJson;
|
||||
import id.ontime.customer.json.BeritaDetailResponseJson;
|
||||
import id.ontime.customer.json.SearchBeritaRequestJson;
|
||||
import id.ontime.customer.models.BeritaModel;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.utils.api.ServiceGenerator;
|
||||
import id.ontime.customer.utils.api.service.UserService;
|
||||
import com.facebook.shimmer.ShimmerFrameLayout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class AllBeritaActivity extends AppCompatActivity {
|
||||
ShimmerFrameLayout shimmer;
|
||||
RecyclerView recycle;
|
||||
BeritaItem beritaItem;
|
||||
RelativeLayout rlnodata;
|
||||
RelativeLayout rlnodata2;
|
||||
EditText searchBerita;
|
||||
TextView nodataberita;
|
||||
List<BeritaModel> clickBerita;
|
||||
ImageView backButton, clearText, btnFav, ivRefresh;
|
||||
SwipeRefreshLayout swipeRefreshLayout;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_all_berita);
|
||||
shimmer = findViewById(R.id.shimmer);
|
||||
recycle = findViewById(R.id.inboxlist);
|
||||
rlnodata = findViewById(R.id.rlnodata);
|
||||
rlnodata2 = findViewById(R.id.rlnodata2);
|
||||
btnFav = findViewById(R.id.btn_fav);
|
||||
ivRefresh = findViewById(R.id.iv_refresh);
|
||||
clearText = findViewById(R.id.clear_text);
|
||||
backButton = findViewById(R.id.back_btn);
|
||||
nodataberita = findViewById(R.id.nodataberita);
|
||||
searchBerita = findViewById(R.id.search_text);
|
||||
swipeRefreshLayout = findViewById(R.id.swipe_refresh);
|
||||
|
||||
recycle.setHasFixedSize(true);
|
||||
recycle.setNestedScrollingEnabled(false);
|
||||
recycle.setLayoutManager(new GridLayoutManager(this, 1));
|
||||
backButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
getData();
|
||||
|
||||
clickBerita = new ArrayList<>();
|
||||
beritaItem = new BeritaItem(clickBerita);
|
||||
|
||||
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
onResume();
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
}
|
||||
});
|
||||
|
||||
ivRefresh.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onResume();
|
||||
}
|
||||
});
|
||||
|
||||
btnFav.setOnClickListener(view -> {
|
||||
Intent i = new Intent(AllBeritaActivity.this, FavoriteNewsActivity.class);
|
||||
// Bundle b= ActivityOptions.makeSceneTransitionAnimation(this).toBundle();
|
||||
startActivity(i);
|
||||
|
||||
});
|
||||
|
||||
clearText.setOnClickListener(view -> {
|
||||
searchBerita.setText("");
|
||||
getData();
|
||||
clearText.setVisibility(View.GONE);
|
||||
rlnodata2.setVisibility(View.GONE);
|
||||
rlnodata.setVisibility(View.GONE);
|
||||
});
|
||||
|
||||
searchBerita.setOnEditorActionListener((v, actionId, event) -> {
|
||||
if (clickBerita != null) {
|
||||
clickBerita.clear();
|
||||
}
|
||||
shimmertutup();
|
||||
|
||||
String sSearch = searchBerita.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(sSearch)) {
|
||||
getData();
|
||||
clearText.setVisibility(View.GONE);
|
||||
rlnodata2.setVisibility(View.GONE);
|
||||
} else {
|
||||
searchAllBerita(searchBerita.getText().toString());
|
||||
clearText.setVisibility(View.VISIBLE);
|
||||
rlnodata2.setVisibility(View.GONE);
|
||||
rlnodata.setVisibility(View.GONE);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void shimmershow() {
|
||||
recycle.setVisibility(View.GONE);
|
||||
shimmer.setVisibility(View.VISIBLE);
|
||||
shimmer.startShimmerAnimation();
|
||||
}
|
||||
|
||||
private void shimmertutup() {
|
||||
nodataberita.setVisibility(View.GONE);
|
||||
recycle.setVisibility(View.VISIBLE);
|
||||
shimmer.setVisibility(View.GONE);
|
||||
shimmer.stopShimmerAnimation();
|
||||
}
|
||||
|
||||
private void getData() {
|
||||
shimmershow();
|
||||
User loginUser = BaseApp.getInstance(this).getLoginUser();
|
||||
UserService service = ServiceGenerator.createService(UserService.class, loginUser.getEmail(), loginUser.getPassword());
|
||||
BeritaDetailRequestJson param = new BeritaDetailRequestJson();
|
||||
|
||||
service.allberita(param).enqueue(new Callback<BeritaDetailResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<BeritaDetailResponseJson> call, @NonNull Response<BeritaDetailResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
shimmertutup();
|
||||
if (Objects.requireNonNull(response.body()).getData().isEmpty()) {
|
||||
rlnodata.setVisibility(View.VISIBLE);
|
||||
recycle.setVisibility(View.GONE);
|
||||
} else {
|
||||
rlnodata.setVisibility(View.GONE);
|
||||
beritaItem = new BeritaItem(AllBeritaActivity.this, response.body().getData(), R.layout.item_grid_full);
|
||||
recycle.setAdapter(beritaItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull retrofit2.Call<BeritaDetailResponseJson> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void searchAllBerita(String like) {
|
||||
shimmershow();
|
||||
User loginUser = BaseApp.getInstance(this).getLoginUser();
|
||||
UserService service = ServiceGenerator.createService(UserService.class, loginUser.getEmail(), loginUser.getPassword());
|
||||
SearchBeritaRequestJson param = new SearchBeritaRequestJson();
|
||||
param.setLike(like);
|
||||
|
||||
service.searchberita(param).enqueue(new Callback<BeritaDetailResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<BeritaDetailResponseJson> call, @NonNull Response<BeritaDetailResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
shimmertutup();
|
||||
if (Objects.requireNonNull(response.body()).getData().isEmpty()) {
|
||||
rlnodata2.setVisibility(View.VISIBLE);
|
||||
recycle.setVisibility(View.GONE);
|
||||
} else {
|
||||
rlnodata.setVisibility(View.GONE);
|
||||
beritaItem = new BeritaItem(AllBeritaActivity.this, response.body().getData(), R.layout.item_grid_full);
|
||||
recycle.setAdapter(beritaItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull retrofit2.Call<BeritaDetailResponseJson> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getData();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.item.AllMerchantNearItem;
|
||||
import id.ontime.customer.item.CatMerchantNearItem;
|
||||
import id.ontime.customer.json.AllMerchantByNearResponseJson;
|
||||
import id.ontime.customer.json.AllMerchantbyCatRequestJson;
|
||||
import id.ontime.customer.json.GetAllMerchantbyCatRequestJson;
|
||||
import id.ontime.customer.json.SearchMerchantbyCatRequestJson;
|
||||
import id.ontime.customer.models.CatMerchantModel;
|
||||
import id.ontime.customer.models.MerchantNearModel;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.utils.api.MapDirectionAPI;
|
||||
import id.ontime.customer.utils.api.ServiceGenerator;
|
||||
import id.ontime.customer.utils.api.service.UserService;
|
||||
import com.facebook.shimmer.ShimmerFrameLayout;
|
||||
import com.google.android.gms.location.FusedLocationProviderClient;
|
||||
import com.google.android.gms.location.LocationServices;
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.google.android.gms.tasks.OnSuccessListener;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class AllMerchantActivity extends AppCompatActivity {
|
||||
ImageView backbtn;
|
||||
TextView address;
|
||||
EditText search;
|
||||
ShimmerFrameLayout shimmerchantnear;
|
||||
RecyclerView rvcatmerchantnear, rvmerchantnear;
|
||||
AllMerchantNearItem merchantNearItem;
|
||||
CatMerchantNearItem catMerchantNearItem;
|
||||
List<MerchantNearModel> clicknear;
|
||||
LinearLayout llmerchantnear, shimlistnear, shimlistcatnear;
|
||||
RelativeLayout nodatanear;
|
||||
int fiturId;
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_all_merchant);
|
||||
|
||||
Intent intent = getIntent();
|
||||
fiturId = intent.getIntExtra("FiturKey", -1);
|
||||
|
||||
backbtn = findViewById(R.id.Goback);
|
||||
address = findViewById(R.id.address);
|
||||
shimmerchantnear = findViewById(R.id.shimmerchantnear);
|
||||
rvcatmerchantnear = findViewById(R.id.catmerchantnear);
|
||||
rvmerchantnear = findViewById(R.id.merchantnear);
|
||||
llmerchantnear = findViewById(R.id.llmerchantnear);
|
||||
shimlistnear = findViewById(R.id.shimlistnear);
|
||||
shimlistcatnear = findViewById(R.id.shimlistcatnear);
|
||||
nodatanear = findViewById(R.id.rlnodata);
|
||||
search = findViewById(R.id.searchtext);
|
||||
TextView rate_merchant = findViewById(R.id.rate_merchant);
|
||||
|
||||
|
||||
address.setSelected(true);
|
||||
rvcatmerchantnear.setHasFixedSize(true);
|
||||
rvcatmerchantnear.setNestedScrollingEnabled(false);
|
||||
rvcatmerchantnear.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
|
||||
|
||||
rvmerchantnear.setHasFixedSize(true);
|
||||
rvmerchantnear.setNestedScrollingEnabled(false);
|
||||
rvmerchantnear.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
|
||||
|
||||
backbtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
FusedLocationProviderClient mFusedLocation = LocationServices.getFusedLocationProviderClient(this);
|
||||
mFusedLocation.getLastLocation().addOnSuccessListener(this, new OnSuccessListener<Location>() {
|
||||
@Override
|
||||
public void onSuccess(final Location location) {
|
||||
if (location != null) {
|
||||
LatLng centerPos = new LatLng(location.getLatitude(), location.getLongitude());
|
||||
requestAddress(centerPos, address);
|
||||
getdata(location);
|
||||
search.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
if (clicknear != null) {
|
||||
clicknear.clear();
|
||||
}
|
||||
shimlistnear.setVisibility(View.VISIBLE);
|
||||
shimmerchantnear.setVisibility(View.VISIBLE);
|
||||
shimlistcatnear.setVisibility(View.GONE);
|
||||
rvmerchantnear.setVisibility(View.GONE);
|
||||
nodatanear.setVisibility(View.GONE);
|
||||
shimmerchantnear.startShimmerAnimation();
|
||||
String sSearch = search.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(sSearch)) {
|
||||
getmerchntbycatnear(location, "1");
|
||||
} else {
|
||||
searchmerchant(location, search.getText().toString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
shimmershow();
|
||||
}
|
||||
|
||||
private void shimmershow() {
|
||||
rvmerchantnear.setVisibility(View.GONE);
|
||||
shimmerchantnear.startShimmerAnimation();
|
||||
}
|
||||
|
||||
private void shimmertutup() {
|
||||
rvcatmerchantnear.setVisibility(View.VISIBLE);
|
||||
rvmerchantnear.setVisibility(View.VISIBLE);
|
||||
shimmerchantnear.stopShimmerAnimation();
|
||||
shimmerchantnear.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void requestAddress(LatLng latlang, final TextView textView) {
|
||||
if (latlang != null) {
|
||||
MapDirectionAPI.getAddress(AllMerchantActivity.this, latlang).enqueue(new okhttp3.Callback() {
|
||||
@Override
|
||||
public void onFailure(@NonNull okhttp3.Call call, @NonNull IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull okhttp3.Call call, @NonNull final okhttp3.Response response) throws IOException {
|
||||
if (response.isSuccessful()) {
|
||||
final String json = Objects.requireNonNull(response.body()).string();
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
JSONObject Jobject = new JSONObject(json);
|
||||
JSONArray Jarray = Jobject.getJSONArray("results");
|
||||
JSONObject userdata = Jarray.getJSONObject(0);
|
||||
String address = userdata.getString("formatted_address");
|
||||
textView.setText(address);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void getdata(final Location location) {
|
||||
User loginUser = BaseApp.getInstance(this).getLoginUser();
|
||||
UserService userService = ServiceGenerator.createService(
|
||||
UserService.class, loginUser.getNoTelepon(), loginUser.getPassword());
|
||||
AllMerchantbyCatRequestJson param = new AllMerchantbyCatRequestJson();
|
||||
param.setId(loginUser.getId());
|
||||
param.setLat(String.valueOf(location.getLatitude()));
|
||||
param.setLon(String.valueOf(location.getLongitude()));
|
||||
param.setPhone(loginUser.getNoTelepon());
|
||||
param.setKategori(String.valueOf(fiturId));
|
||||
userService.allmerchant(param).enqueue(new Callback<AllMerchantByNearResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<AllMerchantByNearResponseJson> call, @NonNull Response<AllMerchantByNearResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
if (Objects.requireNonNull(response.body()).getMessage().equalsIgnoreCase("success")) {
|
||||
shimmertutup();
|
||||
|
||||
if (response.body().getData().isEmpty()) {
|
||||
rvmerchantnear.setVisibility(View.GONE);
|
||||
nodatanear.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
clicknear = response.body().getData();
|
||||
merchantNearItem = new AllMerchantNearItem(AllMerchantActivity.this, clicknear, R.layout.item_merchant_list);
|
||||
rvmerchantnear.setAdapter(merchantNearItem);
|
||||
|
||||
catMerchantNearItem = new CatMerchantNearItem(AllMerchantActivity.this, response.body().getKategori(), R.layout.item_cat_merchant, new CatMerchantNearItem.OnItemClickListener() {
|
||||
@SuppressLint("MissingPermission")
|
||||
@Override
|
||||
public void onItemClick(final CatMerchantModel item) {
|
||||
clicknear.clear();
|
||||
shimlistnear.setVisibility(View.VISIBLE);
|
||||
shimmerchantnear.setVisibility(View.VISIBLE);
|
||||
shimlistcatnear.setVisibility(View.GONE);
|
||||
rvmerchantnear.setVisibility(View.GONE);
|
||||
nodatanear.setVisibility(View.GONE);
|
||||
shimmerchantnear.startShimmerAnimation();
|
||||
FusedLocationProviderClient mFusedLocation = LocationServices.getFusedLocationProviderClient(AllMerchantActivity.this);
|
||||
mFusedLocation.getLastLocation().addOnSuccessListener(AllMerchantActivity.this, new OnSuccessListener<Location>() {
|
||||
@Override
|
||||
public void onSuccess(Location location) {
|
||||
if (location != null) {
|
||||
getmerchntbycatnear(location, item.getId_kategori_merchant());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
rvcatmerchantnear.setAdapter(catMerchantNearItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<AllMerchantByNearResponseJson> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getmerchntbycatnear(final Location location, String cat) {
|
||||
User loginUser = BaseApp.getInstance(this).getLoginUser();
|
||||
UserService userService = ServiceGenerator.createService(
|
||||
UserService.class, loginUser.getNoTelepon(), loginUser.getPassword());
|
||||
GetAllMerchantbyCatRequestJson param = new GetAllMerchantbyCatRequestJson();
|
||||
param.setId(loginUser.getId());
|
||||
param.setLat(String.valueOf(location.getLatitude()));
|
||||
param.setLon(String.valueOf(location.getLongitude()));
|
||||
param.setPhone(loginUser.getNoTelepon());
|
||||
param.setKategori(cat);
|
||||
param.setFitur(String.valueOf(fiturId));
|
||||
userService.getallmerchanbynear(param).enqueue(new Callback<AllMerchantByNearResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<AllMerchantByNearResponseJson> call, @NonNull Response<AllMerchantByNearResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
if (Objects.requireNonNull(response.body()).getMessage().equalsIgnoreCase("success")) {
|
||||
clicknear = response.body().getData();
|
||||
shimmerchantnear.setVisibility(View.GONE);
|
||||
rvmerchantnear.setVisibility(View.VISIBLE);
|
||||
shimmerchantnear.stopShimmerAnimation();
|
||||
if (response.body().getData().isEmpty()) {
|
||||
nodatanear.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
nodatanear.setVisibility(View.GONE);
|
||||
merchantNearItem = new AllMerchantNearItem(AllMerchantActivity.this, clicknear, R.layout.item_merchant_list);
|
||||
rvmerchantnear.setAdapter(merchantNearItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<AllMerchantByNearResponseJson> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void searchmerchant(final Location location, String like) {
|
||||
User loginUser = BaseApp.getInstance(this).getLoginUser();
|
||||
UserService userService = ServiceGenerator.createService(
|
||||
UserService.class, loginUser.getNoTelepon(), loginUser.getPassword());
|
||||
SearchMerchantbyCatRequestJson param = new SearchMerchantbyCatRequestJson();
|
||||
param.setId(loginUser.getId());
|
||||
param.setLat(String.valueOf(location.getLatitude()));
|
||||
param.setLon(String.valueOf(location.getLongitude()));
|
||||
param.setPhone(loginUser.getNoTelepon());
|
||||
param.setFitur(String.valueOf(fiturId));
|
||||
param.setLike(like);
|
||||
userService.searchmerchant(param).enqueue(new Callback<AllMerchantByNearResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<AllMerchantByNearResponseJson> call, @NonNull Response<AllMerchantByNearResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
if (Objects.requireNonNull(response.body()).getMessage().equalsIgnoreCase("success")) {
|
||||
clicknear = response.body().getData();
|
||||
shimmerchantnear.setVisibility(View.GONE);
|
||||
rvmerchantnear.setVisibility(View.VISIBLE);
|
||||
shimmerchantnear.stopShimmerAnimation();
|
||||
if (response.body().getData().isEmpty()) {
|
||||
nodatanear.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
nodatanear.setVisibility(View.GONE);
|
||||
merchantNearItem = new AllMerchantNearItem(AllMerchantActivity.this, clicknear, R.layout.item_merchant_list);
|
||||
rvmerchantnear.setAdapter(merchantNearItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<AllMerchantByNearResponseJson> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.json.BeritaDetailRequestJson;
|
||||
import id.ontime.customer.json.BeritaDetailResponseJson;
|
||||
import id.ontime.customer.models.BeritaModel;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.utils.DatabaseHelper;
|
||||
import id.ontime.customer.utils.PicassoTrustAll;
|
||||
import id.ontime.customer.utils.api.ServiceGenerator;
|
||||
import id.ontime.customer.utils.api.service.UserService;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
|
||||
public class BeritaDetailActivity extends AppCompatActivity {
|
||||
|
||||
TextView title, tanggal, kategori;
|
||||
String Id;
|
||||
WebView description;
|
||||
ImageView backButton, images, favourite;
|
||||
RelativeLayout rlprogress;
|
||||
private DatabaseHelper databaseHelper;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_beritadetail);
|
||||
databaseHelper = new DatabaseHelper(this);
|
||||
Intent i = getIntent();
|
||||
Id = i.getStringExtra("id");
|
||||
title = findViewById(R.id.title);
|
||||
tanggal = findViewById(R.id.tanggal);
|
||||
|
||||
images = findViewById(R.id.image);
|
||||
backButton = findViewById(R.id.back_btn);
|
||||
kategori = findViewById(R.id.kategori);
|
||||
description = findViewById(R.id.description);
|
||||
rlprogress = findViewById(R.id.rlprogress);
|
||||
favourite = findViewById(R.id.favourite);
|
||||
|
||||
backButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
getData();
|
||||
|
||||
}
|
||||
|
||||
private void getData() {
|
||||
rlprogress.setVisibility(View.VISIBLE);
|
||||
User loginUser = BaseApp.getInstance(this).getLoginUser();
|
||||
UserService service = ServiceGenerator.createService(UserService.class, loginUser.getEmail(), loginUser.getPassword());
|
||||
BeritaDetailRequestJson param = new BeritaDetailRequestJson();
|
||||
param.setId(Id);
|
||||
|
||||
service.beritadetail(param).enqueue(new Callback<BeritaDetailResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<BeritaDetailResponseJson> call, @NonNull Response<BeritaDetailResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
rlprogress.setVisibility(View.GONE);
|
||||
final BeritaModel berita = Objects.requireNonNull(response.body()).getData().get(0);
|
||||
title.setText(berita.getTitle());
|
||||
|
||||
if (!berita.getFotoberita().isEmpty()) {
|
||||
PicassoTrustAll.getInstance(BeritaDetailActivity.this)
|
||||
.load(Constants.IMAGESBERITA + berita.getFotoberita())
|
||||
// .resize(250, 250)
|
||||
.into(images);
|
||||
}
|
||||
Date myDate = null;
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm", Locale.US);
|
||||
try {
|
||||
myDate = dateFormat.parse(berita.getCreatedberita());
|
||||
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
SimpleDateFormat timeFormat = new SimpleDateFormat("dd MMM yyyy", Locale.US);
|
||||
String finalDate = timeFormat.format(Objects.requireNonNull(myDate));
|
||||
tanggal.setText(finalDate);
|
||||
|
||||
String mimeType = "text/html";
|
||||
String encoding = "utf-8";
|
||||
String htmlText = berita.getContent();
|
||||
|
||||
String text = "<html dir=" + "><head>"
|
||||
+ "<style type=\"text/css\">@font-face {font-family: MyFont;src: url(\"file:///android_asset/fonts/Montserrat_Medium.ttf\")}body{font-family: MyFont;color: #000000;text-align:justify;line-height:1.2}"
|
||||
+ "</style></head>"
|
||||
+ "<body>"
|
||||
+ htmlText
|
||||
+ "</body></html>";
|
||||
description.loadDataWithBaseURL(null, text, mimeType, encoding, null);
|
||||
kategori.setText(berita.getKategori());
|
||||
|
||||
final User loginUser = BaseApp.getInstance(BeritaDetailActivity.this).getLoginUser();
|
||||
favourite.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
ContentValues fav = new ContentValues();
|
||||
if (databaseHelper.getFavouriteById(String.valueOf(berita.getIdberita()))) {
|
||||
databaseHelper.removeFavouriteById(String.valueOf(berita.getIdberita()));
|
||||
favourite.setColorFilter(getResources().getColor(R.color.gray));
|
||||
Toast.makeText(BeritaDetailActivity.this, "Dihapus dari daftar Bookmark", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
fav.put(DatabaseHelper.KEY_ID, berita.getIdberita());
|
||||
fav.put(DatabaseHelper.KEY_USERID, loginUser.getId());
|
||||
fav.put(DatabaseHelper.KEY_TITLE, berita.getTitle());
|
||||
fav.put(DatabaseHelper.KEY_CONTENT, berita.getContent());
|
||||
fav.put(DatabaseHelper.KEY_KATEGORI, berita.getKategori());
|
||||
fav.put(DatabaseHelper.KEY_IMAGE, berita.getFotoberita());
|
||||
databaseHelper.addFavourite(DatabaseHelper.TABLE_FAVOURITE_NAME, fav, null);
|
||||
favourite.setColorFilter(getResources().getColor(R.color.red));
|
||||
Toast.makeText(BeritaDetailActivity.this, "Ditambahkan ke Bookmark", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
if (databaseHelper.getFavouriteById(String.valueOf(berita.getIdberita()))) {
|
||||
favourite.setColorFilter(getResources().getColor(R.color.red));
|
||||
} else {
|
||||
favourite.setColorFilter(getResources().getColor(R.color.gray));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull retrofit2.Call<BeritaDetailResponseJson> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,255 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.json.ChangePassRequestJson;
|
||||
import id.ontime.customer.json.LoginResponseJson;
|
||||
import id.ontime.customer.models.FirebaseToken;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.panicbutton.api.ChangePasswordAPI;
|
||||
import id.ontime.customer.panicbutton.model.Value;
|
||||
import id.ontime.customer.utils.api.ServiceGenerator;
|
||||
import id.ontime.customer.utils.api.service.UserService;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import io.realm.Realm;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
|
||||
public class ChangepassActivity extends AppCompatActivity {
|
||||
|
||||
ImageView backbtn;
|
||||
Button submit, buttonSimpan;
|
||||
EditText pass, passbaru;
|
||||
TextView notiftext;
|
||||
RelativeLayout rlnotif, rlprogress;
|
||||
String disableback;
|
||||
String passwordLama, password;
|
||||
// public static final String URL = "http://peci.semestaterpadu.my.id/";
|
||||
TextInputLayout validasiPasswordLama, validasiPassword;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_changepassword);
|
||||
|
||||
backbtn = findViewById(R.id.back_btn_verify);
|
||||
submit = findViewById(R.id.buttonconfirm);
|
||||
buttonSimpan = findViewById(R.id.buttonSimpan);
|
||||
pass = findViewById(R.id.password);
|
||||
validasiPasswordLama = findViewById(R.id.validasiPasswordLama);
|
||||
validasiPassword = findViewById(R.id.validasiPassword);
|
||||
passbaru = findViewById(R.id.newpassword);
|
||||
notiftext = findViewById(R.id.textnotif2);
|
||||
rlnotif = findViewById(R.id.rlnotif2);
|
||||
rlprogress = findViewById(R.id.rlprogress);
|
||||
|
||||
SharedPreferences sharedPreferences =
|
||||
PreferenceManager.getDefaultSharedPreferences(ChangepassActivity.this);
|
||||
String statusLogin = sharedPreferences.getString("status", "Logged Out");
|
||||
if (!statusLogin.equals("Logged In")) {
|
||||
finish();
|
||||
}
|
||||
|
||||
disableback = "false";
|
||||
|
||||
backbtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
buttonSimpan.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (pass.getText().toString().isEmpty()) {
|
||||
notif("Password lama tidak boleh kosong!");
|
||||
} else if (passbaru.getText().toString().isEmpty()) {
|
||||
notif("Masukan password baru!");
|
||||
} else {
|
||||
changePassword();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void get() {
|
||||
progressshow();
|
||||
ChangePassRequestJson request = new ChangePassRequestJson();
|
||||
User loginuser = BaseApp.getInstance(ChangepassActivity.this).getLoginUser();
|
||||
request.setNotelepon(loginuser.getNoTelepon());
|
||||
request.setPassword(pass.getText().toString());
|
||||
request.setNewPassword(passbaru.getText().toString());
|
||||
|
||||
UserService service = ServiceGenerator.createService(UserService.class, request.getNotelepon(), request.getPassword());
|
||||
service.changepass(request).enqueue(new Callback<LoginResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<LoginResponseJson> call, @NonNull Response<LoginResponseJson> response) {
|
||||
progresshide();
|
||||
if (response.isSuccessful()) {
|
||||
if (Objects.requireNonNull(response.body()).getMessage().equalsIgnoreCase("found")) {
|
||||
|
||||
User user = response.body().getData().get(0);
|
||||
saveUser(user);
|
||||
// finish();
|
||||
|
||||
} else {
|
||||
notif(response.body().getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<LoginResponseJson> call, @NonNull Throwable t) {
|
||||
progresshide();
|
||||
t.printStackTrace();
|
||||
notif("error");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void progressshow() {
|
||||
rlprogress.setVisibility(View.VISIBLE);
|
||||
disableback = "true";
|
||||
}
|
||||
|
||||
public void progresshide() {
|
||||
rlprogress.setVisibility(View.GONE);
|
||||
disableback = "false";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (!disableback.equals("true")) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
public void notif(String text) {
|
||||
rlnotif.setVisibility(View.VISIBLE);
|
||||
notiftext.setText(text);
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
rlnotif.setVisibility(View.GONE);
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
private void saveUser(User user) {
|
||||
Realm realm = Realm.getDefaultInstance();
|
||||
realm.beginTransaction();
|
||||
realm.delete(User.class);
|
||||
realm.copyToRealm(user);
|
||||
realm.commitTransaction();
|
||||
BaseApp.getInstance(ChangepassActivity.this).setLoginUser(user);
|
||||
}
|
||||
|
||||
private void changePassword() {
|
||||
passwordLama = pass.getText().toString();
|
||||
password = passbaru.getText().toString();
|
||||
if (passwordLama.isEmpty()) {
|
||||
validasiPasswordLama.setError("Password lama harus diisi");
|
||||
} else {
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
|
||||
alertDialogBuilder.setTitle("Konfirmasi");
|
||||
alertDialogBuilder.setMessage("Simpan perubahan?");
|
||||
alertDialogBuilder.setPositiveButton("Ya", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
ProgressDialog progressDialog = new ProgressDialog(ChangepassActivity.this);
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.setMessage("Tunggu sebentar...");
|
||||
progressDialog.show();
|
||||
SharedPreferences sharedPreferences =
|
||||
PreferenceManager.getDefaultSharedPreferences(ChangepassActivity.this);
|
||||
String idUser = sharedPreferences.getString("idUser", "kosong");
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl(Constants.URL)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.build();
|
||||
ChangePasswordAPI changePasswordAPI = retrofit.create(ChangePasswordAPI.class);
|
||||
Call<Value> call = changePasswordAPI.change(idUser, passwordLama, password);
|
||||
call.enqueue(new Callback<Value>() {
|
||||
@Override
|
||||
public void onResponse(Call<Value> call, Response<Value> response) {
|
||||
get();
|
||||
String value = response.body().getValue();
|
||||
String message = response.body().getMessage();
|
||||
progressDialog.dismiss();
|
||||
if (value.equals("1")) {
|
||||
Toast.makeText(ChangepassActivity.this, message,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
|
||||
finish();
|
||||
} else {
|
||||
Toast.makeText(ChangepassActivity.this, message,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Value> call, Throwable t) {
|
||||
progressDialog.dismiss();
|
||||
Toast.makeText(ChangepassActivity.this,
|
||||
"Gagal menghubungkan ke server", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
alertDialogBuilder.setNegativeButton("Tidak", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
AlertDialog alert = alertDialogBuilder.create();
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
|
||||
public void onMessageEvent(FirebaseToken response) {
|
||||
Realm realm = Realm.getDefaultInstance();
|
||||
realm.beginTransaction();
|
||||
realm.delete(FirebaseToken.class);
|
||||
realm.copyToRealm(response);
|
||||
realm.commitTransaction();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,6 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
public class Config {
|
||||
public static final String CLIENT_KEY = "SB-Mid-client-vQqppQezsNX1Helt";
|
||||
public static final String BASE_URL = "https://apitest.semestaterpadu.my.id/api/midtrans/";
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.utils.SettingPreference;
|
||||
|
||||
public class ConfirmWAActivity extends AppCompatActivity {
|
||||
|
||||
EditText nominaltopup, namabank, norekening, nama, nohp;
|
||||
Button submit;
|
||||
TextView notif;
|
||||
ImageView backbtn, images;
|
||||
RelativeLayout rlnotif, rlprogress;
|
||||
String disableback;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_confirm_wa);
|
||||
disableback = "false";
|
||||
nominaltopup = findViewById(R.id.nominaltopup);
|
||||
namabank = findViewById(R.id.namabank);
|
||||
norekening = findViewById(R.id.norekening);
|
||||
nama = findViewById(R.id.nama);
|
||||
nohp = findViewById(R.id.nohp);
|
||||
backbtn = findViewById(R.id.back_btn);
|
||||
submit = findViewById(R.id.submit);
|
||||
rlnotif = findViewById(R.id.rlnotif);
|
||||
notif = findViewById(R.id.textnotif);
|
||||
rlprogress = findViewById(R.id.rlprogress);
|
||||
images = findViewById(R.id.imagebackground);
|
||||
|
||||
submit.setOnClickListener(v -> {
|
||||
String isinominal = nominaltopup.getText().toString();
|
||||
String isinamabank = namabank.getText().toString();
|
||||
String isinorekening = norekening.getText().toString();
|
||||
String isinama = nama.getText().toString();
|
||||
String isinohp = nohp.getText().toString();
|
||||
|
||||
// boolean installed = appInstalledOrNot("com.whatsapp");
|
||||
// if (installed) {
|
||||
SettingPreference sp = new SettingPreference(v.getContext());
|
||||
String phoneNumber = sp.getSetting()[3];
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse("https://api.whatsapp.com/send?phone=" + "+62" + phoneNumber + "&text=Hai admin, Saya mau Konfirmasi TOPUP saldo Customer %0A%0AJumlah Topup : " + isinominal + "%0ANama Bank : " + isinamabank +"%0ANo. Rekening saya: " + isinorekening + " %0AAtas Nama : " + isinama + " %0ANo. HP terdaftar : " +isinohp));
|
||||
startActivity(intent);
|
||||
// }else{
|
||||
// Toast.makeText( ConfirmWAActivity.this, "install whatsapp agar bisa menghubungi team admin", Toast.LENGTH_SHORT).show();
|
||||
// }
|
||||
|
||||
});
|
||||
backbtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
/* private boolean appInstalledOrNot(String url) {
|
||||
PackageManager packageManager = getPackageManager();
|
||||
boolean app_installed;
|
||||
try {
|
||||
packageManager.getPackageInfo(url, packageManager.GET_ACTIVITIES);
|
||||
app_installed = true;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
app_installed = false;
|
||||
}
|
||||
return app_installed;
|
||||
} */
|
||||
|
||||
public void onBackPressed() {
|
||||
if (!disableback.equals("true")) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
public void progressshow() {
|
||||
rlprogress.setVisibility(View.VISIBLE);
|
||||
disableback = "true";
|
||||
}
|
||||
|
||||
public void progresshide() {
|
||||
rlprogress.setVisibility(View.GONE);
|
||||
disableback = "false";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,633 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Paint;
|
||||
import android.location.Location;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.item.CatItemItem;
|
||||
import id.ontime.customer.item.ItemItem;
|
||||
import id.ontime.customer.json.GetAllMerchantbyCatRequestJson;
|
||||
import id.ontime.customer.json.MerchantByIdResponseJson;
|
||||
import id.ontime.customer.json.MerchantbyIdRequestJson;
|
||||
import id.ontime.customer.models.CatItemModel;
|
||||
import id.ontime.customer.models.ItemModel;
|
||||
import id.ontime.customer.models.PesananMerchant;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.utils.PicassoTrustAll;
|
||||
import id.ontime.customer.utils.Utility;
|
||||
import id.ontime.customer.utils.api.MapDirectionAPI;
|
||||
import id.ontime.customer.utils.api.ServiceGenerator;
|
||||
import id.ontime.customer.utils.api.service.UserService;
|
||||
import com.facebook.shimmer.ShimmerFrameLayout;
|
||||
import com.google.android.gms.location.FusedLocationProviderClient;
|
||||
import com.google.android.gms.location.LocationServices;
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.google.android.gms.tasks.OnSuccessListener;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.mikepenz.fastadapter.FastAdapter;
|
||||
import com.mikepenz.fastadapter.adapters.FastItemAdapter;
|
||||
import com.mikepenz.fastadapter.listeners.ClickEventHook;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import io.realm.Realm;
|
||||
import io.realm.RealmResults;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class DetailMerchantActivity extends AppCompatActivity implements ItemItem.OnCalculatePrice {
|
||||
ImageView fotomerchant, partner, promo, backbtn, partnershim, promoshim;
|
||||
TextView tutup;
|
||||
TextView nama;
|
||||
TextView kategori;
|
||||
TextView hours;
|
||||
TextView rate_merchant;
|
||||
TextView qtytext;
|
||||
TextView costtext;
|
||||
FloatingActionButton maps;
|
||||
String id, resume, alamat, tutupki, lat, lon, idresto, alamatresto;
|
||||
double merlat, merlon, distance;
|
||||
int idfitur;
|
||||
LatLng lokasi;
|
||||
|
||||
FrameLayout rlnotif;
|
||||
TextView textnotif;
|
||||
|
||||
CardView pricecountainer;
|
||||
|
||||
ShimmerFrameLayout shimmerchantnear, shimmerbadge, shimmerdetail, shimmerbadgepromo;
|
||||
RecyclerView rvcatmerchantnear, rvmerchantnear;
|
||||
CatItemItem catMerchantNearItem;
|
||||
LinearLayout llmerchantnear, shimlistnear, shimlistcatnear, lldetail;
|
||||
RelativeLayout nodatanear;
|
||||
int[] exiF;
|
||||
private BottomSheetDialog mBottomSheetDialog;
|
||||
private View bottom_sheet;
|
||||
private FastItemAdapter<ItemItem> itemAdapter;
|
||||
private List<ItemModel> itemRealmResults;
|
||||
private Realm realm;
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_detail_merchant);
|
||||
realm = Realm.getDefaultInstance();
|
||||
|
||||
bottom_sheet = findViewById(R.id.bottom_sheet);
|
||||
BottomSheetBehavior.from(bottom_sheet);
|
||||
|
||||
Intent intent = getIntent();
|
||||
id = intent.getStringExtra("id");
|
||||
lat = intent.getStringExtra("lat");
|
||||
lon = intent.getStringExtra("lon");
|
||||
|
||||
fotomerchant = findViewById(R.id.image);
|
||||
partner = findViewById(R.id.partner);
|
||||
promo = findViewById(R.id.promo);
|
||||
backbtn = findViewById(R.id.back_btn);
|
||||
tutup = findViewById(R.id.tutup);
|
||||
textnotif = findViewById(R.id.textnotif);
|
||||
rlnotif = findViewById(R.id.rlnotif);
|
||||
nama = findViewById(R.id.nama);
|
||||
kategori = findViewById(R.id.kategoridistance);
|
||||
rate_merchant = findViewById(R.id.rate_merchant);
|
||||
hours = findViewById(R.id.hours);
|
||||
pricecountainer = findViewById(R.id.price_container);
|
||||
qtytext = findViewById(R.id.qty_text);
|
||||
costtext = findViewById(R.id.cost_text);
|
||||
maps = findViewById(R.id.fab);
|
||||
|
||||
shimmerbadge = findViewById(R.id.shimmerbadge);
|
||||
promoshim = findViewById(R.id.promoshim);
|
||||
partnershim = findViewById(R.id.partnershim);
|
||||
shimmerdetail = findViewById(R.id.shimmerdetail);
|
||||
lldetail = findViewById(R.id.lldetail);
|
||||
|
||||
shimmerchantnear = findViewById(R.id.shimmerchantnear);
|
||||
rvcatmerchantnear = findViewById(R.id.catmerchantnear);
|
||||
rvmerchantnear = findViewById(R.id.merchantnear);
|
||||
llmerchantnear = findViewById(R.id.llmerchantnear);
|
||||
shimlistnear = findViewById(R.id.shimlistnear);
|
||||
shimlistcatnear = findViewById(R.id.shimlistcatnear);
|
||||
nodatanear = findViewById(R.id.rlnodata);
|
||||
shimmerbadgepromo = findViewById(R.id.shimmerbadgepromo);
|
||||
|
||||
resume = "0";
|
||||
rvcatmerchantnear.setHasFixedSize(true);
|
||||
rvcatmerchantnear.setNestedScrollingEnabled(false);
|
||||
rvcatmerchantnear.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
|
||||
|
||||
backbtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
FusedLocationProviderClient mFusedLocation = LocationServices.getFusedLocationProviderClient(this);
|
||||
mFusedLocation.getLastLocation().addOnSuccessListener(this, new OnSuccessListener<Location>() {
|
||||
@Override
|
||||
public void onSuccess(Location location) {
|
||||
if (location != null) {
|
||||
LatLng centerPos = new LatLng(location.getLatitude(), location.getLongitude());
|
||||
requestAddress(centerPos);
|
||||
lokasi = centerPos;
|
||||
getdata(location);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
itemAdapter = new FastItemAdapter<>();
|
||||
rvmerchantnear.setLayoutManager(new LinearLayoutManager(this));
|
||||
DeletePesanan();
|
||||
shimmershow();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void requestAddress(LatLng latlang) {
|
||||
if (latlang != null) {
|
||||
MapDirectionAPI.getAddress(DetailMerchantActivity.this, latlang).enqueue(new okhttp3.Callback() {
|
||||
@Override
|
||||
public void onFailure(@NonNull okhttp3.Call call, @NonNull IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull okhttp3.Call call, @NonNull final okhttp3.Response response) throws IOException {
|
||||
if (response.isSuccessful()) {
|
||||
final String json = Objects.requireNonNull(response.body()).string();
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
JSONObject Jobject = new JSONObject(json);
|
||||
JSONArray Jarray = Jobject.getJSONArray("results");
|
||||
JSONObject userdata = Jarray.getJSONObject(0);
|
||||
alamat = userdata.getString("formatted_address");
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void notif(String text) {
|
||||
rlnotif.setVisibility(View.VISIBLE);
|
||||
textnotif.setText(text);
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
rlnotif.setVisibility(View.GONE);
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void calculatePrice() {
|
||||
List<PesananMerchant> existingFood = realm.where(PesananMerchant.class).findAll();
|
||||
|
||||
int quantity = 0;
|
||||
long cost = 0;
|
||||
for (int p = 0; p < existingFood.size(); p++) {
|
||||
quantity += Objects.requireNonNull(existingFood.get(p)).getQty();
|
||||
cost += Objects.requireNonNull(existingFood.get(p)).getTotalHarga();
|
||||
}
|
||||
|
||||
if (quantity > 0) {
|
||||
pricecountainer.setVisibility(View.VISIBLE);
|
||||
pricecountainer.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (tutupki.equals("0")) {
|
||||
Intent i = new Intent(DetailMerchantActivity.this, DetailOrderActivity.class);
|
||||
i.putExtra("lat", lokasi.latitude);
|
||||
i.putExtra("lon", lokasi.longitude);
|
||||
i.putExtra("merlat", merlat);
|
||||
i.putExtra("merlon", merlon);
|
||||
i.putExtra("alamat", alamat);
|
||||
i.putExtra("FiturKey", idfitur);
|
||||
i.putExtra("distance", distance);
|
||||
i.putExtra("alamatresto", alamatresto);
|
||||
i.putExtra("idresto", idresto);
|
||||
i.putExtra("namamerchant", nama.getText().toString());
|
||||
i.putExtra("rate_merchant", rate_merchant.getText().toString());
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
} else {
|
||||
notif("merchant are closing!");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
pricecountainer.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
qtytext.setText("" + quantity + " Item");
|
||||
Utility.currencyTXT(costtext, String.valueOf(cost), this);
|
||||
}
|
||||
|
||||
private void getdata(Location location) {
|
||||
User loginUser = BaseApp.getInstance(this).getLoginUser();
|
||||
UserService userService = ServiceGenerator.createService(
|
||||
UserService.class, loginUser.getNoTelepon(), loginUser.getPassword());
|
||||
MerchantbyIdRequestJson param = new MerchantbyIdRequestJson();
|
||||
param.setId(id);
|
||||
param.setLat(String.valueOf(location.getLatitude()));
|
||||
param.setLon(String.valueOf(location.getLongitude()));
|
||||
param.setPhone(loginUser.getNoTelepon());
|
||||
userService.merchantbyid(param).enqueue(new Callback<MerchantByIdResponseJson>() {
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<MerchantByIdResponseJson> call, @NonNull final Response<MerchantByIdResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
if (Objects.requireNonNull(response.body()).getMessage().equalsIgnoreCase("success")) {
|
||||
shimmertutup();
|
||||
|
||||
if (!response.body().getFotomerchant().isEmpty()) {
|
||||
PicassoTrustAll.getInstance(DetailMerchantActivity.this)
|
||||
.load(Constants.IMAGESMERCHANT + response.body().getFotomerchant())
|
||||
// .resize(250, 250)
|
||||
.into(fotomerchant);
|
||||
}
|
||||
|
||||
merlat = Double.parseDouble(response.body().getLatmerchant());
|
||||
merlon = Double.parseDouble(response.body().getLongmerchant());
|
||||
idfitur = Integer.parseInt(response.body().getIdfitur());
|
||||
idresto = response.body().getIdmerchant();
|
||||
alamatresto = response.body().getAlamatmerchant();
|
||||
|
||||
float km = Float.parseFloat(response.body().getDistance());
|
||||
String format = String.format(Locale.US, "%.1f", km);
|
||||
distance = Double.parseDouble(format);
|
||||
|
||||
String[] parsedJamBuka = response.body().getBukamerchant().split(":");
|
||||
String[] parsedJamTutup = response.body().getTutupmerchant().split(":");
|
||||
|
||||
int jamBuka = Integer.parseInt(parsedJamBuka[0]), menitBuka = Integer.parseInt(parsedJamBuka[1]);
|
||||
int jamTutup = Integer.parseInt(parsedJamTutup[0]), menitTutup = Integer.parseInt(parsedJamTutup[1]);
|
||||
|
||||
int totalMenitBuka = (jamBuka * 60) + menitBuka;
|
||||
int totalMenitTutup = (jamTutup * 60) + menitTutup;
|
||||
|
||||
Calendar now = Calendar.getInstance();
|
||||
int totalMenitNow = (now.get(Calendar.HOUR_OF_DAY) * 60) + now.get(Calendar.MINUTE);
|
||||
|
||||
if (totalMenitNow <= totalMenitTutup && totalMenitNow >= totalMenitBuka) {
|
||||
tutup.setVisibility(View.GONE);
|
||||
tutupki = "0";
|
||||
} else {
|
||||
tutup.setVisibility(View.VISIBLE);
|
||||
tutupki = "1";
|
||||
}
|
||||
|
||||
nama.setText(response.body().getNamamerchant());
|
||||
|
||||
float rate = Float.parseFloat(response.body().getRate_merchant());
|
||||
String format1 = String.format(Locale.US, "%.1f",rate );
|
||||
rate_merchant.setText(format1);
|
||||
|
||||
maps.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(DetailMerchantActivity.this, MapsMerchantActivity.class);
|
||||
i.putExtra("lat", lat);
|
||||
i.putExtra("lon", lon);
|
||||
i.putExtra("name", response.body().getNamamerchant());
|
||||
// i.putExtra(String.valueOf(rate_merchant),response.body().getRate_merchant());
|
||||
startActivity(i);
|
||||
}
|
||||
});
|
||||
hours.setText("Open Hours: " + Objects.requireNonNull(response.body()).getBukamerchant() + "-" + response.body().getTutupmerchant());
|
||||
kategori.setText(response.body().getKategorimerchant() + " " + getString(R.string.text_with_bullet) + " " + distance + "Km");
|
||||
|
||||
|
||||
if (response.body().getPromo().equals("1")) {
|
||||
promo.setVisibility(View.VISIBLE);
|
||||
promoshim.setVisibility(View.VISIBLE);
|
||||
shimmerbadgepromo.startShimmerAnimation();
|
||||
} else {
|
||||
promo.setVisibility(View.GONE);
|
||||
promoshim.setVisibility(View.GONE);
|
||||
shimmerbadgepromo.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (response.body().getPartner().equals("1")) {
|
||||
partner.setVisibility(View.VISIBLE);
|
||||
partnershim.setVisibility(View.VISIBLE);
|
||||
shimmerbadge.startShimmerAnimation();
|
||||
} else {
|
||||
partner.setVisibility(View.GONE);
|
||||
partnershim.setVisibility(View.GONE);
|
||||
shimmerbadge.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
itemRealmResults = response.body().getData();
|
||||
resume = "1";
|
||||
LoadItem();
|
||||
Realm realm = BaseApp.getInstance(DetailMerchantActivity.this).getRealmInstance();
|
||||
realm.beginTransaction();
|
||||
realm.delete(ItemModel.class);
|
||||
realm.copyToRealm(response.body().getData());
|
||||
realm.commitTransaction();
|
||||
itemAdapter.notifyDataSetChanged();
|
||||
itemAdapter.withSelectable(true);
|
||||
itemAdapter.withItemEvent(new ClickEventHook<ItemItem>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public View onBind(@NonNull RecyclerView.ViewHolder viewHolder) {
|
||||
if (viewHolder instanceof ItemItem.ViewHolder) {
|
||||
return ((ItemItem.ViewHolder) viewHolder).itemView;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v, int position, FastAdapter<ItemItem> fastAdapter, ItemItem item) {
|
||||
sheetlist(position);
|
||||
}
|
||||
});
|
||||
catMerchantNearItem = new CatItemItem(DetailMerchantActivity.this, response.body().getKategori(), R.layout.item_cat_merchant, new CatItemItem.OnItemClickListener() {
|
||||
@SuppressLint("MissingPermission")
|
||||
@Override
|
||||
public void onItemClick(final CatItemModel item) {
|
||||
//clicknear.clear();
|
||||
shimlistnear.setVisibility(View.VISIBLE);
|
||||
shimmerchantnear.setVisibility(View.VISIBLE);
|
||||
shimlistcatnear.setVisibility(View.GONE);
|
||||
rvmerchantnear.setVisibility(View.GONE);
|
||||
nodatanear.setVisibility(View.GONE);
|
||||
shimmerchantnear.startShimmerAnimation();
|
||||
FusedLocationProviderClient mFusedLocation = LocationServices.getFusedLocationProviderClient(DetailMerchantActivity.this);
|
||||
mFusedLocation.getLastLocation().addOnSuccessListener(DetailMerchantActivity.this, new OnSuccessListener<Location>() {
|
||||
@Override
|
||||
public void onSuccess(Location location) {
|
||||
if (location != null) {
|
||||
|
||||
getmerchntbycatnear(location, item.getId_kategori_item());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
rvcatmerchantnear.setAdapter(catMerchantNearItem);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<MerchantByIdResponseJson> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getmerchntbycatnear(final Location location, String cat) {
|
||||
User loginUser = BaseApp.getInstance(this).getLoginUser();
|
||||
UserService userService = ServiceGenerator.createService(
|
||||
UserService.class, loginUser.getNoTelepon(), loginUser.getPassword());
|
||||
GetAllMerchantbyCatRequestJson param = new GetAllMerchantbyCatRequestJson();
|
||||
param.setId(id);
|
||||
param.setLat(String.valueOf(location.getLatitude()));
|
||||
param.setLon(String.valueOf(location.getLongitude()));
|
||||
param.setPhone(loginUser.getNoTelepon());
|
||||
param.setKategori(cat);
|
||||
userService.getitembycat(param).enqueue(new Callback<MerchantByIdResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<MerchantByIdResponseJson> call, @NonNull Response<MerchantByIdResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
if (Objects.requireNonNull(response.body()).getMessage().equalsIgnoreCase("success")) {
|
||||
itemAdapter.clear();
|
||||
shimmerchantnear.setVisibility(View.GONE);
|
||||
rvmerchantnear.setVisibility(View.VISIBLE);
|
||||
shimmerchantnear.stopShimmerAnimation();
|
||||
if (response.body().getData().isEmpty()) {
|
||||
nodatanear.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
nodatanear.setVisibility(View.GONE);
|
||||
itemRealmResults = response.body().getData();
|
||||
LoadItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<MerchantByIdResponseJson> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void DeletePesanan() {
|
||||
RealmResults<PesananMerchant> deleteFood = realm.where(PesananMerchant.class).findAll();
|
||||
realm.beginTransaction();
|
||||
deleteFood.deleteAllFromRealm();
|
||||
realm.commitTransaction();
|
||||
}
|
||||
|
||||
private void LoadItem() {
|
||||
itemAdapter.clear();
|
||||
RealmResults<PesananMerchant> existingItemMenu = realm.where(PesananMerchant.class).findAll();
|
||||
|
||||
|
||||
exiF = new int[itemRealmResults.size()];
|
||||
|
||||
for (int i = 0; i < itemRealmResults.size(); i++) {
|
||||
ItemItem itemMenuItem = new ItemItem(DetailMerchantActivity.this, this);
|
||||
|
||||
itemMenuItem.quantity = 0;
|
||||
for (int j = 0; j < existingItemMenu.size(); j++) {
|
||||
if (Objects.requireNonNull(existingItemMenu.get(j)).getIdItem() == itemRealmResults.get(i).getId_item()) {
|
||||
itemMenuItem.quantity = Objects.requireNonNull(existingItemMenu.get(j)).getQty();
|
||||
itemMenuItem.catatan = Objects.requireNonNull(existingItemMenu.get(j)).getCatatan();
|
||||
exiF[i] = Objects.requireNonNull(existingItemMenu.get(j)).getQty();
|
||||
}
|
||||
}
|
||||
|
||||
itemMenuItem.id = itemRealmResults.get(i).getId_item();
|
||||
itemMenuItem.namaMenu = itemRealmResults.get(i).getNama_item();
|
||||
itemMenuItem.deskripsiMenu = itemRealmResults.get(i).getDeskripsi_item();
|
||||
itemMenuItem.foto = itemRealmResults.get(i).getFoto_item();
|
||||
itemMenuItem.harga = Long.parseLong(itemRealmResults.get(i).getHarga_item());
|
||||
itemMenuItem.promo = itemRealmResults.get(i).getStatus_promo();
|
||||
if (itemRealmResults.get(i).getHarga_promo().isEmpty()) {
|
||||
itemMenuItem.hargapromo = 0;
|
||||
} else {
|
||||
itemMenuItem.hargapromo = Long.parseLong(itemRealmResults.get(i).getHarga_promo());
|
||||
}
|
||||
itemAdapter.add(itemMenuItem);
|
||||
}
|
||||
|
||||
itemAdapter.notifyDataSetChanged();
|
||||
rvmerchantnear.setAdapter(itemAdapter);
|
||||
}
|
||||
|
||||
private void shimmershow() {
|
||||
shimmerdetail.startShimmerAnimation();
|
||||
rvmerchantnear.setVisibility(View.GONE);
|
||||
shimmerchantnear.startShimmerAnimation();
|
||||
}
|
||||
|
||||
private void shimmertutup() {
|
||||
shimmerdetail.stopShimmerAnimation();
|
||||
shimmerdetail.setVisibility(View.GONE);
|
||||
lldetail.setVisibility(View.VISIBLE);
|
||||
rvcatmerchantnear.setVisibility(View.VISIBLE);
|
||||
rvmerchantnear.setVisibility(View.VISIBLE);
|
||||
shimmerchantnear.stopShimmerAnimation();
|
||||
shimmerchantnear.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
DeletePesanan();
|
||||
realm.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
calculatePrice();
|
||||
if (resume.equals("1")) {
|
||||
LoadItem();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
List<PesananMerchant> existingItem = realm.where(PesananMerchant.class).findAll();
|
||||
|
||||
int quantity = 0;
|
||||
for (int p = 0; p < existingItem.size(); p++) {
|
||||
quantity += Objects.requireNonNull(existingItem.get(p)).getQty();
|
||||
}
|
||||
|
||||
if (quantity > 0) {
|
||||
new AlertDialog.Builder(this, R.style.DialogStyle)
|
||||
.setTitle("Hapus Pesanan Anda?")
|
||||
.setMessage("Meninggalkan halaman ini akan menghapus semua pesanan yang dibuat. Lanjutkan?")
|
||||
.setPositiveButton("Ya", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
DeletePesanan();
|
||||
finish();
|
||||
}
|
||||
})
|
||||
.setNegativeButton("Tidak", null)
|
||||
.show();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private void sheetlist(int position) {
|
||||
BottomSheetBehavior behavior = BottomSheetBehavior.from(bottom_sheet);
|
||||
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||
|
||||
ItemModel selectedItem = realm.where(ItemModel.class).equalTo("id_item", itemAdapter.getAdapterItem(position).id).findFirst();
|
||||
@SuppressLint("InflateParams") final View mDialog = getLayoutInflater().inflate(R.layout.sheet_detail_item, null);
|
||||
TextView text = mDialog.findViewById(R.id.title);
|
||||
ImageView imageView = mDialog.findViewById(R.id.imageview);
|
||||
WebView content = mDialog.findViewById(R.id.content);
|
||||
TextView kategori = mDialog.findViewById(R.id.kategori);
|
||||
TextView hargapromo = mDialog.findViewById(R.id.hargapromo);
|
||||
TextView harga = mDialog.findViewById(R.id.harga);
|
||||
|
||||
PicassoTrustAll.getInstance(this)
|
||||
.load(Constants.IMAGESITEM + Objects.requireNonNull(selectedItem).getFoto_item())
|
||||
// .resize(250, 250)
|
||||
.into(imageView);
|
||||
|
||||
if (selectedItem.getStatus_promo().equals("1")) {
|
||||
hargapromo.setVisibility(View.VISIBLE);
|
||||
Utility.currencyTXT(harga, selectedItem.getHarga_promo(), this);
|
||||
Utility.currencyTXT(hargapromo, selectedItem.getHarga_item(), this);
|
||||
hargapromo.setPaintFlags(hargapromo.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
|
||||
} else {
|
||||
hargapromo.setVisibility(View.GONE);
|
||||
Utility.currencyTXT(harga, selectedItem.getHarga_item(), this);
|
||||
|
||||
}
|
||||
|
||||
kategori.setText(selectedItem.getKategori_item());
|
||||
|
||||
|
||||
String mimeType = "text/html";
|
||||
String encoding = "utf-8";
|
||||
String htmlText = selectedItem.getDeskripsi_item();
|
||||
|
||||
String textcontent = "<html dir=" + "><head>"
|
||||
+ "<style type=\"text/css\">@font-face {font-family: MyFont;src: url(\"file:///android_asset/fonts/Montserrat_Regular.ttf\")}body{font-family: MyFont;color: #000000;text-align:justify;line-height:1.2}"
|
||||
+ "</style></head>"
|
||||
+ "<body>"
|
||||
+ htmlText
|
||||
+ "</body></html>";
|
||||
content.loadDataWithBaseURL(null, textcontent, mimeType, encoding, null);
|
||||
|
||||
text.setText(selectedItem.getNama_item());
|
||||
|
||||
|
||||
mBottomSheetDialog = new BottomSheetDialog(this);
|
||||
mBottomSheetDialog.setContentView(mDialog);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
Objects.requireNonNull(mBottomSheetDialog.getWindow()).addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
}
|
||||
|
||||
mBottomSheetDialog.show();
|
||||
mBottomSheetDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
mBottomSheetDialog = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,874 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.item.ItemItem;
|
||||
import id.ontime.customer.json.CheckStatusTransaksiRequest;
|
||||
import id.ontime.customer.json.CheckStatusTransaksiResponse;
|
||||
import id.ontime.customer.json.GetNearRideCarRequestJson;
|
||||
import id.ontime.customer.json.GetNearRideCarResponseJson;
|
||||
import id.ontime.customer.json.ItemRequestJson;
|
||||
import id.ontime.customer.json.PromoRequestJson;
|
||||
import id.ontime.customer.json.PromoResponseJson;
|
||||
import id.ontime.customer.json.RideCarResponseJson;
|
||||
import id.ontime.customer.json.fcm.DriverRequest;
|
||||
import id.ontime.customer.json.fcm.DriverResponse;
|
||||
import id.ontime.customer.json.fcm.FCMMessage;
|
||||
import id.ontime.customer.models.DriverModel;
|
||||
import id.ontime.customer.models.FiturModel;
|
||||
import id.ontime.customer.models.ItemModel;
|
||||
import id.ontime.customer.models.PesananMerchant;
|
||||
import id.ontime.customer.models.TransaksiModel;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.utils.SettingPreference;
|
||||
import id.ontime.customer.utils.Utility;
|
||||
import id.ontime.customer.utils.api.FCMHelper;
|
||||
import id.ontime.customer.utils.api.MapDirectionAPI;
|
||||
import id.ontime.customer.utils.api.ServiceGenerator;
|
||||
import id.ontime.customer.utils.api.service.BookService;
|
||||
import id.ontime.customer.utils.api.service.UserService;
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.mikepenz.fastadapter.FastAdapter;
|
||||
import com.mikepenz.fastadapter.adapters.FastItemAdapter;
|
||||
import com.mikepenz.fastadapter.listeners.ClickEventHook;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import io.realm.Realm;
|
||||
import io.realm.RealmResults;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
import static id.ontime.customer.json.fcm.FCMType.ORDER;
|
||||
|
||||
public class DetailOrderActivity extends AppCompatActivity implements ItemItem.OnCalculatePrice {
|
||||
|
||||
public static final String FITUR_KEY = "FiturKey";
|
||||
private final int DESTINATION_ID = 1;
|
||||
TextView location, orderprice, deliveryfee, diskon, total, diskontext, topuptext, textnotif, saldotext;
|
||||
Button order;
|
||||
RecyclerView rvmerchantnear;
|
||||
LinearLayout llcheckedcash, llcheckedwallet, llbtn;
|
||||
ImageButton checkedcash, checkedwallet;
|
||||
RelativeLayout rlprogress;
|
||||
Thread thread;
|
||||
boolean threadRun = true;
|
||||
TransaksiModel transaksi;
|
||||
TextView cashpayment, walletpayment;
|
||||
String alamat, biayaminimum, getbiaya, biayaakhir, biayadistance;
|
||||
double lat, lon, merlat, merlon, distance;
|
||||
ImageView backbtn;
|
||||
int fitur;
|
||||
SettingPreference sp;
|
||||
RelativeLayout rlnotif;
|
||||
EditText promokode;
|
||||
String home, layanan, keterangan, icon;
|
||||
Button btnpromo;
|
||||
double km;
|
||||
private DriverRequest request;
|
||||
private double jarak;
|
||||
private long harga, promocode;
|
||||
private FiturModel designedFitur;
|
||||
private LatLng pickUpLatLang;
|
||||
private LatLng destinationLatLang;
|
||||
private FastItemAdapter<ItemItem> itemAdapter;
|
||||
private Realm realm;
|
||||
private List<DriverModel> driverAvailable;
|
||||
private long foodCostLong = 0, maksimum;
|
||||
private long deliveryCostLong = 0;
|
||||
private String saldoWallet, checkedpaywallet, checkedpaycash, idresto, alamatresto, namamerchant, back;
|
||||
private okhttp3.Callback updateRouteCallback = new okhttp3.Callback() {
|
||||
@Override
|
||||
public void onFailure(@NonNull okhttp3.Call call, @NonNull IOException e) {
|
||||
DetailOrderActivity.this.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
rlprogress.setVisibility(View.GONE);
|
||||
notif("Kesalahan koneksi, pilih lokasi lagi.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull okhttp3.Call call, okhttp3.Response response) throws IOException {
|
||||
if (response.isSuccessful()) {
|
||||
final String json = Objects.requireNonNull(response.body()).string();
|
||||
final String errorMsg = MapDirectionAPI.getDirectionErrorMessage(json);
|
||||
if (errorMsg != null) {
|
||||
DetailOrderActivity.this.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
rlprogress.setVisibility(View.GONE);
|
||||
notif(errorMsg);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
final long distancetext = MapDirectionAPI.getDistance(DetailOrderActivity.this, json);
|
||||
if (distancetext >= 0) {
|
||||
DetailOrderActivity.this.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String format = String.format(Locale.US, "%.0f", ((float) (distancetext)) / 1000f);
|
||||
long dist = Long.parseLong(format);
|
||||
promocode = 0;
|
||||
promokode.setText("");
|
||||
distance = ((float) (distancetext)) / 1000f;
|
||||
updateDistance();
|
||||
if (dist < maksimum) {
|
||||
order.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (readyToOrder()) {
|
||||
sendOrder();
|
||||
back = "1";
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
notif("Tujuan terlalu jauh!");
|
||||
order.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (readyToOrder()) {
|
||||
notif("Tujuan terlalu jauh!");
|
||||
back = "0";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
DetailOrderActivity.this.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
rlprogress.setVisibility(View.GONE);
|
||||
notif("Gagal memuat rute, pilih lokasi lagi.");
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
DetailOrderActivity.this.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
rlprogress.setVisibility(View.GONE);
|
||||
notif("Gagal memuat rute, coba lagi.");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_detail_order);
|
||||
promocode = 0;
|
||||
realm = Realm.getDefaultInstance();
|
||||
rvmerchantnear = findViewById(R.id.merchantnear);
|
||||
location = findViewById(R.id.pickUpText);
|
||||
orderprice = findViewById(R.id.orderprice);
|
||||
llcheckedcash = findViewById(R.id.llcheckedcash);
|
||||
llcheckedwallet = findViewById(R.id.llcheckedwallet);
|
||||
cashpayment = findViewById(R.id.cashPayment);
|
||||
walletpayment = findViewById(R.id.walletpayment);
|
||||
deliveryfee = findViewById(R.id.cost);
|
||||
checkedcash = findViewById(R.id.checkedcash);
|
||||
checkedwallet = findViewById(R.id.checkedwallet);
|
||||
total = findViewById(R.id.price);
|
||||
diskon = findViewById(R.id.diskon);
|
||||
backbtn = findViewById(R.id.back_btn);
|
||||
diskontext = findViewById(R.id.ketsaldo);
|
||||
topuptext = findViewById(R.id.topUp);
|
||||
order = findViewById(R.id.order);
|
||||
rlprogress = findViewById(R.id.rlprogress);
|
||||
textnotif = findViewById(R.id.textnotif);
|
||||
rlnotif = findViewById(R.id.rlnotif);
|
||||
saldotext = findViewById(R.id.saldo);
|
||||
promokode = findViewById(R.id.promocode);
|
||||
btnpromo = findViewById(R.id.btnpromo);
|
||||
back = "0";
|
||||
llbtn = findViewById(R.id.llbtn);
|
||||
|
||||
driverAvailable = new ArrayList<>();
|
||||
fitur = 0;
|
||||
topuptext.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(getApplicationContext(), TopupSaldoActivity.class));
|
||||
}
|
||||
});
|
||||
|
||||
location.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(DetailOrderActivity.this, PicklocationActivity.class);
|
||||
intent.putExtra(PicklocationActivity.FORM_VIEW_INDICATOR, DESTINATION_ID);
|
||||
startActivityForResult(intent, PicklocationActivity.LOCATION_PICKER_ID);
|
||||
}
|
||||
});
|
||||
|
||||
backbtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
sp = new SettingPreference(this);
|
||||
Intent intent = getIntent();
|
||||
lat = intent.getDoubleExtra("lat", 0);
|
||||
lon = intent.getDoubleExtra("lon", 0);
|
||||
merlat = intent.getDoubleExtra("merlat", 0);
|
||||
merlon = intent.getDoubleExtra("merlon", 0);
|
||||
distance = intent.getDoubleExtra("distance", 0);
|
||||
alamatresto = intent.getStringExtra("alamatresto");
|
||||
idresto = intent.getStringExtra("idresto");
|
||||
alamat = intent.getStringExtra("alamat");
|
||||
namamerchant = intent.getStringExtra("namamerchant");
|
||||
fitur = intent.getIntExtra(FITUR_KEY, -1);
|
||||
if (fitur != -1)
|
||||
designedFitur = realm.where(FiturModel.class).equalTo("idFitur", fitur).findFirst();
|
||||
home = Objects.requireNonNull(designedFitur).getHome();
|
||||
layanan = designedFitur.getFitur();
|
||||
keterangan = designedFitur.getKeterangan();
|
||||
icon = designedFitur.getIcon();
|
||||
|
||||
RealmResults<FiturModel> fiturs = realm.where(FiturModel.class).findAll();
|
||||
|
||||
for (FiturModel fitur : fiturs) {
|
||||
Log.e("ID_FITUR", fitur.getIdFitur() + " " + fitur.getFitur() + " " + fitur.getBiayaAkhir());
|
||||
}
|
||||
getbiaya = String.valueOf(designedFitur.getBiaya());
|
||||
biayaminimum = String.valueOf(designedFitur.getBiaya_minimum());
|
||||
biayaakhir = String.valueOf(designedFitur.getBiayaAkhir());
|
||||
maksimum = Long.parseLong(designedFitur.getMaksimumdist());
|
||||
|
||||
diskontext.setText("Diskon " + designedFitur.getDiskon() + " pakai koin");
|
||||
total.setText("wait");
|
||||
deliveryfee.setText("wait");
|
||||
Utility.currencyTXT(diskon, String.valueOf(promocode), DetailOrderActivity.this);
|
||||
User userLogin = BaseApp.getInstance(this).getLoginUser();
|
||||
saldoWallet = String.valueOf(userLogin.getWalletSaldo());
|
||||
|
||||
pickUpLatLang = new LatLng(merlat, merlon);
|
||||
destinationLatLang = new LatLng(lat, lon);
|
||||
location.setText(alamat);
|
||||
|
||||
btnpromo.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
try {
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
||||
Objects.requireNonNull(imm).hideSoftInputFromWindow(Objects.requireNonNull(getCurrentFocus()).getWindowToken(), 0);
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
if (promokode.getText().toString().isEmpty()) {
|
||||
notif("Kode promo tidak boleh kosong!");
|
||||
} else {
|
||||
promokodedata();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
itemAdapter = new FastItemAdapter<>();
|
||||
itemAdapter.notifyDataSetChanged();
|
||||
itemAdapter.withSelectable(true);
|
||||
itemAdapter.withItemEvent(new ClickEventHook<ItemItem>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public View onBind(@NonNull RecyclerView.ViewHolder viewHolder) {
|
||||
if (viewHolder instanceof ItemItem.ViewHolder) {
|
||||
return ((ItemItem.ViewHolder) viewHolder).itemView;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v, int position, FastAdapter<ItemItem> fastAdapter, ItemItem item) {
|
||||
//sheetlist(position);
|
||||
}
|
||||
});
|
||||
rvmerchantnear.setLayoutManager(new LinearLayoutManager(this));
|
||||
rvmerchantnear.setAdapter(itemAdapter);
|
||||
updateEstimatedItemCost();
|
||||
loadItem();
|
||||
}
|
||||
|
||||
public void notif(String text) {
|
||||
rlnotif.setVisibility(View.VISIBLE);
|
||||
textnotif.setText(text);
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
rlnotif.setVisibility(View.GONE);
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
private boolean readyToOrder() {
|
||||
if (destinationLatLang == null) {
|
||||
Toast.makeText(this, "Silahkan pilih lokasi kamu.", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
} else if (total.getText().toString().isEmpty() || total.getText().toString().equals("wait")) {
|
||||
Toast.makeText(this, "Mohon tunggu...", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
List<PesananMerchant> existingFood = realm.copyFromRealm(realm.where(PesananMerchant.class).findAll());
|
||||
|
||||
int quantity = 0;
|
||||
for (int p = 0; p < existingFood.size(); p++) {
|
||||
quantity += existingFood.get(p).getQty();
|
||||
}
|
||||
|
||||
if (quantity == 0) {
|
||||
Toast.makeText(this, "Harap pesan minimal 1 item.", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (jarak == -99.0) {
|
||||
Toast.makeText(this, "Tolong tunggu sebentar...", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == PicklocationActivity.LOCATION_PICKER_ID) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
String addressset = data.getStringExtra(PicklocationActivity.LOCATION_NAME);
|
||||
LatLng latLng = data.getParcelableExtra(PicklocationActivity.LOCATION_LATLNG);
|
||||
location.setText(addressset);
|
||||
destinationLatLang = new LatLng(Objects.requireNonNull(latLng).latitude, latLng.longitude);
|
||||
if (pickUpLatLang != null) {
|
||||
MapDirectionAPI.getDirection(DetailOrderActivity.this, pickUpLatLang, destinationLatLang).enqueue(updateRouteCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadItem() {
|
||||
List<ItemModel> makananList = realm.copyFromRealm(realm.where(ItemModel.class).findAll());
|
||||
List<PesananMerchant> pesananFoods = realm.copyFromRealm(realm.where(PesananMerchant.class).findAll());
|
||||
itemAdapter.clear();
|
||||
for (PesananMerchant pesanan : pesananFoods) {
|
||||
ItemItem makananItem = new ItemItem(this, this);
|
||||
for (ItemModel makanan : makananList) {
|
||||
if (makanan.getId_item() == pesanan.getIdItem()) {
|
||||
makananItem.quantity = pesanan.getQty();
|
||||
makananItem.id = makanan.getId_item();
|
||||
makananItem.namaMenu = makanan.getNama_item();
|
||||
makananItem.deskripsiMenu = makanan.getDeskripsi_item();
|
||||
makananItem.foto = makanan.getFoto_item();
|
||||
makananItem.harga = Long.parseLong(makanan.getHarga_item());
|
||||
makananItem.promo = makanan.getStatus_promo();
|
||||
if (makanan.getHarga_promo().isEmpty()) {
|
||||
makananItem.hargapromo = 0;
|
||||
} else {
|
||||
makananItem.hargapromo = Long.parseLong(makanan.getHarga_promo());
|
||||
}
|
||||
makananItem.catatan = pesanan.getCatatan();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
itemAdapter.add(makananItem);
|
||||
}
|
||||
|
||||
itemAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private void promokodedata() {
|
||||
btnpromo.setEnabled(false);
|
||||
btnpromo.setText("tunggu...");
|
||||
final User user = BaseApp.getInstance(this).getLoginUser();
|
||||
PromoRequestJson request = new PromoRequestJson();
|
||||
request.setFitur(String.valueOf(fitur));
|
||||
request.setCode(promokode.getText().toString());
|
||||
|
||||
UserService service = ServiceGenerator.createService(UserService.class, user.getNoTelepon(), user.getPassword());
|
||||
service.promocode(request).enqueue(new Callback<PromoResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<PromoResponseJson> call, @NonNull Response<PromoResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
if (Objects.requireNonNull(response.body()).getMessage().equalsIgnoreCase("success")) {
|
||||
final long finalBiayaTotalpay = foodCostLong + harga;
|
||||
btnpromo.setEnabled(true);
|
||||
btnpromo.setText("Use");
|
||||
if (response.body().getType().equals("persen")) {
|
||||
promocode = (Long.parseLong(response.body().getNominal()) * finalBiayaTotalpay) / 100;
|
||||
} else {
|
||||
promocode = Long.parseLong(response.body().getNominal());
|
||||
}
|
||||
updateDistance();
|
||||
} else {
|
||||
notif("Kode promo tidak berlaku!");
|
||||
btnpromo.setEnabled(true);
|
||||
btnpromo.setText("Use");
|
||||
promocode = 0;
|
||||
updateDistance();
|
||||
}
|
||||
} else {
|
||||
notif("error!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<PromoResponseJson> call, @NonNull Throwable t) {
|
||||
t.printStackTrace();
|
||||
notif("error");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculatePrice() {
|
||||
updateEstimatedItemCost();
|
||||
}
|
||||
|
||||
private void updateEstimatedItemCost() {
|
||||
List<PesananMerchant> existingFood = realm.copyFromRealm(realm.where(PesananMerchant.class).findAll());
|
||||
long cost = 0;
|
||||
for (int p = 0; p < existingFood.size(); p++) {
|
||||
cost += existingFood.get(p).getTotalHarga();
|
||||
}
|
||||
foodCostLong = cost;
|
||||
Utility.currencyTXT(orderprice, String.valueOf(foodCostLong), this);
|
||||
MapDirectionAPI.getDirection(DetailOrderActivity.this, pickUpLatLang, destinationLatLang).enqueue(updateRouteCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
if (back.equals("1")) {
|
||||
Intent intent = new Intent(DetailOrderActivity.this, MainActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDistance() {
|
||||
|
||||
checkedpaycash = "1";
|
||||
checkedpaywallet = "0";
|
||||
Log.e("CHECKEDWALLET", checkedpaywallet);
|
||||
checkedcash.setSelected(true);
|
||||
checkedwallet.setSelected(false);
|
||||
cashpayment.setTextColor(getResources().getColor(R.color.colorgradient));
|
||||
walletpayment.setTextColor(getResources().getColor(R.color.gray));
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
checkedcash.setBackgroundTintList(getResources().getColorStateList(R.color.colorgradient));
|
||||
checkedwallet.setBackgroundTintList(getResources().getColorStateList(R.color.gray));
|
||||
}
|
||||
km = distance;
|
||||
|
||||
|
||||
this.jarak = km;
|
||||
|
||||
String biaya = String.valueOf(biayaminimum);
|
||||
long biayaTotal = (long) (Double.parseDouble(getbiaya) * km);
|
||||
if (biayaTotal < Double.parseDouble(biayaminimum)) {
|
||||
this.harga = Long.parseLong(biayaminimum);
|
||||
biayaTotal = Long.parseLong(biayaminimum);
|
||||
biayadistance = biaya;
|
||||
} else {
|
||||
biayadistance = getbiaya;
|
||||
}
|
||||
this.harga = biayaTotal;
|
||||
|
||||
deliveryCostLong = biayaTotal;
|
||||
Log.e("distance", String.valueOf(deliveryCostLong));
|
||||
|
||||
Utility.currencyTXT(deliveryfee, String.valueOf(deliveryCostLong), this);
|
||||
final long finalBiayaTotalpay = foodCostLong + harga;
|
||||
|
||||
Utility.currencyTXT(total, String.valueOf(finalBiayaTotalpay - promocode), DetailOrderActivity.this);
|
||||
Utility.currencyTXT(diskon, String.valueOf(promocode), DetailOrderActivity.this);
|
||||
long saldokini = Long.parseLong(saldoWallet);
|
||||
if (saldokini < ((foodCostLong + harga) - (finalBiayaTotalpay * Double.parseDouble(biayaakhir)))) {
|
||||
llcheckedcash.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Utility.currencyTXT(total, String.valueOf(finalBiayaTotalpay - promocode), DetailOrderActivity.this);
|
||||
Utility.currencyTXT(diskon, String.valueOf(promocode), DetailOrderActivity.this);
|
||||
checkedcash.setSelected(true);
|
||||
checkedwallet.setSelected(false);
|
||||
checkedpaycash = "1";
|
||||
checkedpaywallet = "0";
|
||||
Log.e("CHECKEDWALLET", checkedpaywallet);
|
||||
cashpayment.setTextColor(getResources().getColor(R.color.colorgradient));
|
||||
walletpayment.setTextColor(getResources().getColor(R.color.gray));
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
checkedcash.setBackgroundTintList(getResources().getColorStateList(R.color.colorgradient));
|
||||
checkedwallet.setBackgroundTintList(getResources().getColorStateList(R.color.gray));
|
||||
}
|
||||
}
|
||||
});
|
||||
llcheckedwallet.setEnabled(false);
|
||||
} else {
|
||||
llcheckedwallet.setEnabled(true);
|
||||
llcheckedcash.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Utility.currencyTXT(total, String.valueOf(finalBiayaTotalpay - promocode), DetailOrderActivity.this);
|
||||
Utility.currencyTXT(diskon, String.valueOf(promocode), DetailOrderActivity.this);
|
||||
checkedcash.setSelected(true);
|
||||
checkedwallet.setSelected(false);
|
||||
checkedpaycash = "1";
|
||||
checkedpaywallet = "0";
|
||||
Log.e("CHECKEDWALLET", checkedpaywallet);
|
||||
cashpayment.setTextColor(getResources().getColor(R.color.colorgradient));
|
||||
walletpayment.setTextColor(getResources().getColor(R.color.gray));
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
checkedcash.setBackgroundTintList(getResources().getColorStateList(R.color.colorgradient));
|
||||
checkedwallet.setBackgroundTintList(getResources().getColorStateList(R.color.gray));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
llcheckedwallet.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
long diskonwallet = (long) ((finalBiayaTotalpay * Double.parseDouble(biayaakhir)) + promocode);
|
||||
Log.e("distance", String.valueOf((foodCostLong + harga) - (finalBiayaTotalpay * Double.parseDouble(biayaakhir))));
|
||||
String totalwallet = String.valueOf(diskonwallet);
|
||||
Utility.currencyTXT(diskon, totalwallet, DetailOrderActivity.this);
|
||||
Utility.currencyTXT(total, String.valueOf(finalBiayaTotalpay - diskonwallet), DetailOrderActivity.this);
|
||||
checkedcash.setSelected(false);
|
||||
checkedwallet.setSelected(true);
|
||||
checkedpaycash = "0";
|
||||
checkedpaywallet = "1";
|
||||
Log.e("CHECKEDWALLET", checkedpaywallet);
|
||||
walletpayment.setTextColor(getResources().getColor(R.color.colorgradient));
|
||||
cashpayment.setTextColor(getResources().getColor(R.color.gray));
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
checkedwallet.setBackgroundTintList(getResources().getColorStateList(R.color.colorgradient));
|
||||
checkedcash.setBackgroundTintList(getResources().getColorStateList(R.color.gray));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void sendOrder() {
|
||||
List<PesananMerchant> existingItem = realm.copyFromRealm(realm.where(PesananMerchant.class).findAll());
|
||||
|
||||
for (PesananMerchant pesanan : existingItem) {
|
||||
if (pesanan.getCatatan() == null || pesanan.getCatatan().trim().equals(""))
|
||||
pesanan.setCatatan("");
|
||||
}
|
||||
|
||||
ItemRequestJson param = new ItemRequestJson();
|
||||
User userLogin = BaseApp.getInstance(this).getLoginUser();
|
||||
param.setIdPelanggan(userLogin.getId());
|
||||
param.setOrderFitur(String.valueOf(fitur));
|
||||
param.setStartLatitude(destinationLatLang.latitude);
|
||||
param.setStartLongitude(destinationLatLang.longitude);
|
||||
param.setEndLatitude(merlat);
|
||||
param.setEndLongitude(merlon);
|
||||
param.setAlamatTujuan(location.getText().toString());
|
||||
param.setAlamatAsal(alamatresto);
|
||||
param.setJarak(jarak);
|
||||
param.setEstimasi(String.valueOf(distance));
|
||||
param.setHarga(deliveryCostLong);
|
||||
if (checkedpaycash.equals("1")) {
|
||||
param.setPakaiWallet(0);
|
||||
param.setKreditpromo(String.valueOf(promocode));
|
||||
} else {
|
||||
param.setPakaiWallet(1);
|
||||
param.setKreditpromo(diskon.getText().toString().replace(".", "").replace(sp.getSetting()[0], ""));
|
||||
}
|
||||
param.setIdResto(idresto);
|
||||
param.setTotalBiayaBelanja(foodCostLong);
|
||||
param.setCatatan("");
|
||||
param.setPesanan(existingItem);
|
||||
|
||||
Log.e("Bookingdata", ServiceGenerator.gson.toJson(param));
|
||||
|
||||
fetchNearDriver(param);
|
||||
}
|
||||
|
||||
private void fetchNearDriver(final ItemRequestJson paramdata) {
|
||||
rlprogress.setVisibility(View.VISIBLE);
|
||||
if (destinationLatLang != null) {
|
||||
User loginUser = BaseApp.getInstance(this).getLoginUser();
|
||||
|
||||
BookService service = ServiceGenerator.createService(BookService.class, loginUser.getEmail(), loginUser.getPassword());
|
||||
GetNearRideCarRequestJson param = new GetNearRideCarRequestJson();
|
||||
param.setLatitude(merlat);
|
||||
param.setLongitude(merlon);
|
||||
param.setFitur(String.valueOf(fitur));
|
||||
|
||||
service.getNearRide(param).enqueue(new Callback<GetNearRideCarResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<GetNearRideCarResponseJson> call, @NonNull Response<GetNearRideCarResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
driverAvailable = Objects.requireNonNull(response.body()).getData();
|
||||
if (driverAvailable.isEmpty()) {
|
||||
finish();
|
||||
Toast.makeText(DetailOrderActivity.this, "tidak ada pengemudi di sekitar Anda!", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
sendRequestTransaksi(paramdata, driverAvailable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull retrofit2.Call<GetNearRideCarResponseJson> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void buildDriverRequest(RideCarResponseJson response) {
|
||||
transaksi = response.getData().get(0);
|
||||
Log.e("wallet", String.valueOf(transaksi.isPakaiWallet()));
|
||||
User loginUser = BaseApp.getInstance(this).getLoginUser();
|
||||
if (request == null) {
|
||||
request = new DriverRequest();
|
||||
request.setIdTransaksi(transaksi.getId());
|
||||
request.setIdPelanggan(transaksi.getIdPelanggan());
|
||||
request.setRegIdPelanggan(loginUser.getToken());
|
||||
request.setOrderFitur(home);
|
||||
request.setStartLatitude(transaksi.getStartLatitude());
|
||||
request.setStartLongitude(transaksi.getStartLongitude());
|
||||
request.setEndLatitude(transaksi.getEndLatitude());
|
||||
request.setEndLongitude(transaksi.getEndLongitude());
|
||||
request.setJarak(transaksi.getJarak());
|
||||
request.setHarga(transaksi.getHarga() + foodCostLong);
|
||||
request.setWaktuOrder(transaksi.getWaktuOrder());
|
||||
request.setAlamatAsal(transaksi.getAlamatAsal());
|
||||
request.setAlamatTujuan(transaksi.getAlamatTujuan());
|
||||
request.setKodePromo(transaksi.getKodePromo());
|
||||
request.setKreditPromo(transaksi.getKreditPromo());
|
||||
request.setPakaiWallet(String.valueOf(transaksi.isPakaiWallet()));
|
||||
request.setEstimasi(namamerchant);
|
||||
request.setLayanan(layanan);
|
||||
request.setLayanandesc(keterangan);
|
||||
request.setIcon(icon);
|
||||
request.setBiaya(String.valueOf(foodCostLong));
|
||||
request.setTokenmerchant(transaksi.getToken_merchant());
|
||||
request.setIdtransmerchant(transaksi.getIdtransmerchant());
|
||||
request.setDistance(String.valueOf(deliveryCostLong));
|
||||
|
||||
|
||||
String namaLengkap = String.format("%s", loginUser.getFullnama());
|
||||
request.setNamaPelanggan(namaLengkap);
|
||||
request.setTelepon(loginUser.getNoTelepon());
|
||||
request.setType(ORDER);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendRequestTransaksi(ItemRequestJson param, final List<DriverModel> driverList) {
|
||||
User loginUser = BaseApp.getInstance(this).getLoginUser();
|
||||
final BookService service = ServiceGenerator.createService(BookService.class, loginUser.getEmail(), loginUser.getPassword());
|
||||
|
||||
service.requestTransaksiMerchant(param).enqueue(new Callback<RideCarResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<RideCarResponseJson> call, @NonNull Response<RideCarResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
buildDriverRequest(Objects.requireNonNull(response.body()));
|
||||
thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (int i = 0; i < driverList.size(); i++) {
|
||||
fcmBroadcast(i, driverList);
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(30000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (threadRun) {
|
||||
CheckStatusTransaksiRequest param = new CheckStatusTransaksiRequest();
|
||||
param.setIdTransaksi(transaksi.getId());
|
||||
service.checkStatusTransaksi(param).enqueue(new Callback<CheckStatusTransaksiResponse>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<CheckStatusTransaksiResponse> call, @NonNull Response<CheckStatusTransaksiResponse> response) {
|
||||
if (response.isSuccessful()) {
|
||||
CheckStatusTransaksiResponse checkStatus = response.body();
|
||||
if (!Objects.requireNonNull(checkStatus).isStatus()) {
|
||||
notif("Driver tidak ditemukan!");
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
notif("Driver tidak ditemukan!");
|
||||
}
|
||||
});
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
finish();
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<CheckStatusTransaksiResponse> call, @NonNull Throwable t) {
|
||||
notif("Driver tidak ditemukan!");
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
notif("Driver tidak ditemukan!");
|
||||
}
|
||||
});
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
finish();
|
||||
}
|
||||
}, 3000);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<RideCarResponseJson> call, @NonNull Throwable t) {
|
||||
t.printStackTrace();
|
||||
notif("Ada masalah di akun anda, silahkan hubungi team admin!");
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
finish();
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void fcmBroadcast(int index, List<DriverModel> driverList) {
|
||||
DriverModel driverToSend = driverList.get(index);
|
||||
request.setTime_accept(new Date().getTime() + "");
|
||||
final FCMMessage message = new FCMMessage();
|
||||
message.setTo(driverToSend.getRegId());
|
||||
message.setData(request);
|
||||
|
||||
Log.e("REQUEST TO DRIVER", message.getData().toString());
|
||||
|
||||
FCMHelper.sendMessage(message).enqueue(new okhttp3.Callback() {
|
||||
@Override
|
||||
public void onResponse(@NonNull okhttp3.Call call, @NonNull okhttp3.Response response) {
|
||||
Log.e("REQUEST TO DRIVER", message.getData().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull okhttp3.Call call, @NonNull IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
|
||||
public void onMessageEvent(final DriverResponse response) {
|
||||
Log.e("DRIVER RESPONSE (W)", response.getResponse() + " " + response.getId() + " " + response.getIdTransaksi());
|
||||
if (response.getResponse().equalsIgnoreCase(DriverResponse.ACCEPT) || response.getResponse().equals("3") || response.getResponse().equals("4")) {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
threadRun = false;
|
||||
for (DriverModel cDriver : driverAvailable) {
|
||||
if (cDriver.getId().equals(response.getId())) {
|
||||
Intent intent = new Intent(DetailOrderActivity.this, ProgressActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.putExtra("id_driver", cDriver.getId());
|
||||
intent.putExtra("id_transaksi", request.getIdTransaksi());
|
||||
intent.putExtra("response", "2");
|
||||
intent.putExtra("complete", "1");
|
||||
startActivity(intent);
|
||||
DriverResponse response = new DriverResponse();
|
||||
response.setId("");
|
||||
response.setIdTransaksi("");
|
||||
response.setResponse("");
|
||||
EventBus.getDefault().postSticky(response);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
User userLogin = BaseApp.getInstance(this).getLoginUser();
|
||||
saldoWallet = String.valueOf(userLogin.getWalletSaldo());
|
||||
Utility.koinTXT(saldotext,saldoWallet, this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,579 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.media.MediaScannerConnection;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Base64;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.exifinterface.media.ExifInterface;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.json.EditprofileRequestJson;
|
||||
import id.ontime.customer.json.RegisterResponseJson;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.panicbutton.api.SaveProfileInfoAPI;
|
||||
import id.ontime.customer.panicbutton.model.Value;
|
||||
import id.ontime.customer.utils.Log;
|
||||
import id.ontime.customer.utils.PicassoTrustAll;
|
||||
import id.ontime.customer.utils.api.ServiceGenerator;
|
||||
import id.ontime.customer.utils.api.service.UserService;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog;
|
||||
import com.ybs.countrypicker.CountryPicker;
|
||||
import com.ybs.countrypicker.CountryPickerListener;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import io.realm.Realm;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public class EditProfileActivity extends AppCompatActivity {
|
||||
|
||||
ImageView foto, gantifoto, backbtn, backButtonverify;
|
||||
EditText phone, nama, email;
|
||||
TextView tanggal, countryCode, textnotif;
|
||||
Button submit;
|
||||
RelativeLayout rlnotif;
|
||||
byte[] imageByteArray;
|
||||
Bitmap decoded;
|
||||
String dateview, disableback, onsubmit;
|
||||
String country_iso_code = "en";
|
||||
private SimpleDateFormat dateFormatter, dateFormatterview;
|
||||
// public static final String URL = "http://peci.semestaterpadu.my.id/";
|
||||
String idUser, idUserOld, namaUser, noHP;
|
||||
private final int GALLERY = 1;
|
||||
private final int CAMERA = 2;
|
||||
private static final String IMAGE_DIRECTORY = "/Pictures";
|
||||
private BottomSheetDialog mBottomSheetDialog;
|
||||
private BottomSheetBehavior mBehavior;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_editprofile);
|
||||
View bottom_sheet = findViewById(R.id.bottom_sheet);
|
||||
mBehavior = BottomSheetBehavior.from(bottom_sheet);
|
||||
foto = findViewById(R.id.foto);
|
||||
gantifoto = findViewById(R.id.editfoto);
|
||||
backbtn = findViewById(R.id.back_btn);
|
||||
phone = findViewById(R.id.phonenumber);
|
||||
nama = findViewById(R.id.nama);
|
||||
email = findViewById(R.id.email);
|
||||
tanggal = findViewById(R.id.tanggal);
|
||||
submit = findViewById(R.id.submit);
|
||||
rlnotif = findViewById(R.id.rlnotif);
|
||||
textnotif = findViewById(R.id.textnotif);
|
||||
countryCode = findViewById(R.id.countrycode);
|
||||
backButtonverify = findViewById(R.id.back_btn_verify);
|
||||
backbtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
onsubmit = "true";
|
||||
|
||||
User loginUser = BaseApp.getInstance(this).getLoginUser();
|
||||
PicassoTrustAll.getInstance(this)
|
||||
.load(Constants.IMAGESUSER + loginUser.getFotopelanggan())
|
||||
.placeholder(R.drawable.image_placeholder)
|
||||
.resize(250, 250)
|
||||
.into(foto);
|
||||
|
||||
phone.setText(loginUser.getPhone());
|
||||
nama.setText(loginUser.getFullnama());
|
||||
email.setText(loginUser.getEmail());
|
||||
|
||||
countryCode.setText(loginUser.getCountrycode());
|
||||
dateview = loginUser.getTglLahir();
|
||||
foto.setOnClickListener(new View.OnClickListener() {
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
selectImage();
|
||||
}
|
||||
});
|
||||
gantifoto.setOnClickListener(new View.OnClickListener() {
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
selectImage();
|
||||
}
|
||||
});
|
||||
|
||||
countryCode.setOnClickListener(new View.OnClickListener() {
|
||||
@SuppressLint("WrongConstant")
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final CountryPicker picker = CountryPicker.newInstance("Select Country");
|
||||
picker.setListener(new CountryPickerListener() {
|
||||
@Override
|
||||
public void onSelectCountry(String name, String code, String dialCode, int flagDrawableResID) {
|
||||
countryCode.setText(dialCode);
|
||||
picker.dismiss();
|
||||
country_iso_code = code;
|
||||
}
|
||||
});
|
||||
picker.setStyle(R.style.countrypicker_style, R.style.countrypicker_style);
|
||||
picker.show(getSupportFragmentManager(), "Select Country");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Date myDate = null;
|
||||
dateFormatter = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
|
||||
dateFormatterview = new SimpleDateFormat("dd MMM yyyy", Locale.US);
|
||||
try {
|
||||
myDate = dateFormatter.parse(loginUser.getTglLahir());
|
||||
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String finalDate = dateFormatterview.format(Objects.requireNonNull(myDate));
|
||||
tanggal.setText(finalDate);
|
||||
submit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final String emailPattern = "[a-zA-Z0-9._-]+@[a-z]+\\.+[a-z]+";
|
||||
final String emailvalidate = email.getText().toString();
|
||||
|
||||
if (TextUtils.isEmpty(phone.getText().toString())) {
|
||||
|
||||
notif(getString(R.string.phoneempty));
|
||||
|
||||
} else if (TextUtils.isEmpty(nama.getText().toString())) {
|
||||
|
||||
notif("Nama tidak boleh kosong");
|
||||
|
||||
} else if (TextUtils.isEmpty(email.getText().toString())) {
|
||||
|
||||
notif(getString(R.string.emailempty));
|
||||
|
||||
} else if (TextUtils.isEmpty(tanggal.getText().toString())) {
|
||||
|
||||
notif("tanggal lahir tidak boleh kosong!");
|
||||
|
||||
} else if (!emailvalidate.matches(emailPattern)) {
|
||||
|
||||
notif("format email salah!");
|
||||
|
||||
} else {
|
||||
if (onsubmit.equals("true")) {
|
||||
submit.setText(getString(R.string.waiting_pleaseWait));
|
||||
submit.setBackground(getResources().getDrawable(R.drawable.rounded_corners_button));
|
||||
editprofile();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
tanggal.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showTanggal();
|
||||
}
|
||||
});
|
||||
disableback = "false";
|
||||
|
||||
}
|
||||
|
||||
private void showTanggal() {
|
||||
|
||||
DatePickerDialog datePicker = DatePickerDialog.newInstance(
|
||||
new DatePickerDialog.OnDateSetListener() {
|
||||
@Override
|
||||
public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.YEAR, year);
|
||||
calendar.set(Calendar.MONTH, monthOfYear);
|
||||
calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
|
||||
long date_ship_millis = calendar.getTimeInMillis();
|
||||
tanggal.setText(dateFormatterview.format(date_ship_millis));
|
||||
dateview = dateFormatter.format(date_ship_millis);
|
||||
}
|
||||
}
|
||||
);
|
||||
datePicker.setThemeDark(false);
|
||||
datePicker.setAccentColor(getResources().getColor(R.color.colorgradient));
|
||||
datePicker.show(getFragmentManager(), "Datepickerdialog");
|
||||
}
|
||||
|
||||
|
||||
public void notif(String text) {
|
||||
rlnotif.setVisibility(View.VISIBLE);
|
||||
textnotif.setText(text);
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
rlnotif.setVisibility(View.GONE);
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
private void selectImage() {
|
||||
boolean pick = true;
|
||||
if (pick) {
|
||||
if (!checkCameraPermission()) {
|
||||
requestCameraPermission();
|
||||
} else PickImage();
|
||||
} else {
|
||||
if (!checkStoragePermission()) {
|
||||
requestStoragePermission();
|
||||
} else PickImage();
|
||||
}
|
||||
|
||||
/* if (check_ReadStoragepermission()) {
|
||||
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
startActivityForResult(intent, 2);
|
||||
} */
|
||||
}
|
||||
|
||||
private void PickImage() {
|
||||
|
||||
if (mBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED) {
|
||||
mBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
}
|
||||
|
||||
@SuppressLint("InflateParams") final View mDialog = getLayoutInflater().inflate(R.layout.sheet_upload, null);
|
||||
CardView Galery = mDialog.findViewById(R.id.ll_gallery_intent);
|
||||
CardView Camera = mDialog.findViewById(R.id.ll_camera_intent);
|
||||
|
||||
Galery.setOnClickListener(v -> choosePhotoFromGallery());
|
||||
Camera.setOnClickListener(v -> takePhotoFromCamera());
|
||||
|
||||
mBottomSheetDialog = new BottomSheetDialog(this);
|
||||
mBottomSheetDialog.setContentView(mDialog);
|
||||
mBottomSheetDialog.show();
|
||||
// mBottomSheetDialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
mBottomSheetDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
mBottomSheetDialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation;
|
||||
mBottomSheetDialog.getWindow().setGravity(Gravity.BOTTOM);
|
||||
|
||||
mBottomSheetDialog.setOnDismissListener(dialog -> mBottomSheetDialog = null);
|
||||
|
||||
/* AlertDialog.Builder pictureDialog = new AlertDialog.Builder(this,R.style.DialogStyle);
|
||||
pictureDialog.setTitle("Ambil Foto Melalui");
|
||||
String[] pictureDialogItems = {
|
||||
"- Galeri",
|
||||
"- Kamera" };
|
||||
pictureDialog.setItems(pictureDialogItems,
|
||||
(dialog, which) -> {
|
||||
switch (which) {
|
||||
case 0:
|
||||
choosePhotoFromGallery();
|
||||
break;
|
||||
case 1:
|
||||
takePhotoFromCamera();
|
||||
break;
|
||||
}
|
||||
});
|
||||
pictureDialog.show();
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
public void choosePhotoFromGallery() {
|
||||
Intent galleryIntent = new Intent(Intent.ACTION_PICK,
|
||||
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
|
||||
startActivityForResult(galleryIntent, GALLERY);
|
||||
mBottomSheetDialog.dismiss();
|
||||
}
|
||||
|
||||
private void takePhotoFromCamera() {
|
||||
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
startActivityForResult(intent, CAMERA);
|
||||
mBottomSheetDialog.dismiss();
|
||||
}
|
||||
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
private void requestStoragePermission() {
|
||||
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 100);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
private void requestCameraPermission() {
|
||||
requestPermissions(new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 100);
|
||||
}
|
||||
|
||||
private boolean checkStoragePermission() {
|
||||
if (ContextCompat.checkSelfPermission(this.getApplicationContext(),
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
== PackageManager.PERMISSION_GRANTED) {
|
||||
return true;
|
||||
} else {
|
||||
try {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
|
||||
Constants.permission_Read_data);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkCameraPermission() {
|
||||
boolean res1 = ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED;
|
||||
boolean res2 = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
|
||||
return res1 && res2;
|
||||
}
|
||||
|
||||
|
||||
public String getPath(Uri uri) {
|
||||
String result = null;
|
||||
String[] proj = {MediaStore.Images.Media.DATA};
|
||||
Cursor cursor = this.getContentResolver().query(uri, proj, null, null, null);
|
||||
if (cursor != null) {
|
||||
if (cursor.moveToFirst()) {
|
||||
int column_index = cursor.getColumnIndexOrThrow(proj[0]);
|
||||
result = cursor.getString(column_index);
|
||||
}
|
||||
cursor.close();
|
||||
}
|
||||
if (result == null) {
|
||||
result = "Not found";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
if (resultCode == RESULT_CANCELED) {
|
||||
return;
|
||||
}
|
||||
Uri contentURI = data.getData();
|
||||
if (requestCode == GALLERY) {
|
||||
if (data != null) {
|
||||
|
||||
try {
|
||||
Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), contentURI);
|
||||
String path = saveImage(bitmap);
|
||||
foto.setImageBitmap(bitmap);
|
||||
// Toast.makeText(this, "Image Saved!", Toast.LENGTH_SHORT).show();
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(this, "Failed!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
} else if (requestCode == CAMERA) {
|
||||
Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
|
||||
foto.setImageBitmap(thumbnail);
|
||||
saveImage(thumbnail);
|
||||
// Toast.makeText(this, "Image Saved!", Toast.LENGTH_SHORT).show();
|
||||
/*Intent i = new Intent(this,MainActivity.class);
|
||||
i.putExtra("imagepath", contentURI.toString());
|
||||
startActivity(i);
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String saveImage(Bitmap myBitmap) {
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
myBitmap.compress(Bitmap.CompressFormat.JPEG, 90, bytes);
|
||||
imageByteArray = bytes.toByteArray();
|
||||
decoded = BitmapFactory.decodeStream(new ByteArrayInputStream(bytes.toByteArray()));
|
||||
/* File wallpaperDirectory = new File(
|
||||
Environment.getExternalStorageDirectory() + IMAGE_DIRECTORY);
|
||||
// have the object build the directory structure, if needed.
|
||||
if (!wallpaperDirectory.exists()) {
|
||||
wallpaperDirectory.mkdirs();
|
||||
}
|
||||
|
||||
try {
|
||||
File f = new File(wallpaperDirectory, Calendar.getInstance()
|
||||
.getTimeInMillis() + ".jpg");
|
||||
f.createNewFile();
|
||||
FileOutputStream fo = new FileOutputStream(f);
|
||||
fo.write(bytes.toByteArray());
|
||||
MediaScannerConnection.scanFile(this,
|
||||
new String[]{f.getPath()},
|
||||
new String[]{"image/jpeg"}, null);
|
||||
fo.close();
|
||||
Log.d("TAG", "File Saved::--->" + f.getAbsolutePath());
|
||||
|
||||
return f.getAbsolutePath();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
*/
|
||||
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
private void editprofile() {
|
||||
onsubmit = "false";
|
||||
User loginUser = BaseApp.getInstance(this).getLoginUser();
|
||||
EditprofileRequestJson request = new EditprofileRequestJson();
|
||||
request.setFullNama(nama.getText().toString());
|
||||
request.setEmail(email.getText().toString());
|
||||
request.setEmaillama(loginUser.getEmail());
|
||||
request.setId(loginUser.getId());
|
||||
request.setNoTelepon(countryCode.getText().toString().replace("+", "") + phone.getText().toString());
|
||||
request.setPhone(phone.getText().toString());
|
||||
request.setPhonelama(loginUser.getNoTelepon());
|
||||
request.setCountrycode(countryCode.getText().toString());
|
||||
if (imageByteArray != null) {
|
||||
request.setFotopelangganlama(loginUser.getFotopelanggan());
|
||||
request.setFotopelanggan(getStringImage(decoded));
|
||||
}
|
||||
request.setTglLahir(dateview);
|
||||
|
||||
|
||||
UserService service = ServiceGenerator.createService(UserService.class, loginUser.getEmail(), loginUser.getPassword());
|
||||
service.editProfile(request).enqueue(new Callback<RegisterResponseJson>() {
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<RegisterResponseJson> call, @NonNull Response<RegisterResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
if (Objects.requireNonNull(response.body()).getMessage().equalsIgnoreCase("success")) {
|
||||
User user = response.body().getData().get(0);
|
||||
saveProfilPanic();
|
||||
saveUser(user);
|
||||
|
||||
finish();
|
||||
onsubmit = "true";
|
||||
|
||||
} else {
|
||||
onsubmit = "true";
|
||||
submit.setText("Submit");
|
||||
submit.setBackground(getResources().getDrawable(R.drawable.button_round_1));
|
||||
notif(response.body().getMessage());
|
||||
}
|
||||
} else {
|
||||
onsubmit = "true";
|
||||
submit.setText("Submit");
|
||||
submit.setBackground(getResources().getDrawable(R.drawable.button_round_1));
|
||||
notif("error");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<RegisterResponseJson> call, @NonNull Throwable t) {
|
||||
t.printStackTrace();
|
||||
notif("error!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public String getStringImage(Bitmap bmp) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
if (bmp != null) {
|
||||
bmp.compress(Bitmap.CompressFormat.JPEG, 20, baos);
|
||||
imageByteArray = baos.toByteArray();
|
||||
return Base64.encodeToString(imageByteArray, Base64.DEFAULT);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void saveUser(User user) {
|
||||
Realm realm = Realm.getDefaultInstance();
|
||||
realm.beginTransaction();
|
||||
realm.delete(User.class);
|
||||
realm.copyToRealm(user);
|
||||
realm.commitTransaction();
|
||||
BaseApp.getInstance(EditProfileActivity.this).setLoginUser(user);
|
||||
}
|
||||
|
||||
private void saveProfilPanic(){
|
||||
SharedPreferences sharedPreferences =
|
||||
PreferenceManager.getDefaultSharedPreferences(EditProfileActivity.this);
|
||||
idUser = email.getText().toString();
|
||||
idUserOld = sharedPreferences.getString("idUser", "kosong");
|
||||
namaUser = nama.getText().toString();
|
||||
noHP = countryCode.getText().toString().replace("+", "") + phone.getText().toString();
|
||||
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl(Constants.URL)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.build();
|
||||
SaveProfileInfoAPI saveProfileInfoAPI = retrofit.create(SaveProfileInfoAPI.class);
|
||||
Call<Value> call = saveProfileInfoAPI.save(idUser, idUserOld, namaUser, noHP);
|
||||
call.enqueue(new Callback<Value>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Value> call, @NonNull Response<Value> response) {
|
||||
if (Objects.requireNonNull(response.body()).getMessage().equalsIgnoreCase("success")){
|
||||
String value = response.body().getValue();
|
||||
if (value.equals("1")) {
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString("idUser", idUser);
|
||||
editor.apply();
|
||||
// finish();
|
||||
}
|
||||
} else {
|
||||
notif(response.body().getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Value> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.item.FavouriteItem;
|
||||
import id.ontime.customer.models.FavouriteModel;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.utils.DatabaseHelper;
|
||||
|
||||
public class FavoriteNewsActivity extends AppCompatActivity {
|
||||
|
||||
private Context context;
|
||||
private ArrayList<FavouriteModel> listItem;
|
||||
private RecyclerView recyclerView;
|
||||
private DatabaseHelper databaseHelper;
|
||||
private RelativeLayout notFound;
|
||||
ImageView backBtn;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_favorite_news);
|
||||
|
||||
context = getApplicationContext();
|
||||
listItem = new ArrayList<>();
|
||||
databaseHelper = new DatabaseHelper(this);
|
||||
notFound = findViewById(R.id.rlnodata);
|
||||
backBtn = findViewById(R.id.back_btn);
|
||||
recyclerView = findViewById(R.id.inboxlist);
|
||||
|
||||
recyclerView.setHasFixedSize(true);
|
||||
recyclerView.setNestedScrollingEnabled(false);
|
||||
recyclerView.setLayoutManager(new GridLayoutManager(this, 1));
|
||||
|
||||
backBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
User loginUser = BaseApp.getInstance(context).getLoginUser();
|
||||
if (databaseHelper.getFavouriteByMyid(loginUser.getId())) {
|
||||
listItem = databaseHelper.getFavourite();
|
||||
}
|
||||
displayData();
|
||||
}
|
||||
|
||||
private void displayData() {
|
||||
FavouriteItem adapter = new FavouriteItem(this, listItem, R.layout.item_grid_full);
|
||||
recyclerView.setAdapter(adapter);
|
||||
if (adapter.getItemCount() == 0) {
|
||||
notFound.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
notFound.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.utils.AppIntroPagerAdapter;
|
||||
import id.ontime.customer.utils.ProjectUtils;
|
||||
import id.ontime.customer.utils.SharedPrefrence;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
public class IntroActivity extends AppCompatActivity implements ViewPager.OnPageChangeListener {
|
||||
public SharedPrefrence preference;
|
||||
ViewPager mViewPager;
|
||||
Button buttonSign;
|
||||
int[] mResources = {R.drawable.slide_one, R.drawable.slide_two, R.drawable.slide_three};
|
||||
private AppIntroPagerAdapter mAdapter;
|
||||
private LinearLayout viewPagerCountDots;
|
||||
private int dotsCount;
|
||||
private ImageView[] dots;
|
||||
private Context mContext;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ProjectUtils.Fullscreen(IntroActivity.this);
|
||||
setContentView(R.layout.activity_intro);
|
||||
mContext = IntroActivity.this;
|
||||
preference = SharedPrefrence.getInstance(mContext);
|
||||
|
||||
buttonSign = findViewById(R.id.tombolstar);
|
||||
buttonSign.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent i = new Intent(IntroActivity.this, LoginActivity.class);
|
||||
startActivity(i);
|
||||
}
|
||||
});
|
||||
removeNotif();
|
||||
mViewPager = findViewById(R.id.viewpager);
|
||||
viewPagerCountDots = findViewById(R.id.viewPagerCountDots);
|
||||
|
||||
|
||||
mAdapter = new AppIntroPagerAdapter(IntroActivity.this, mContext, mResources);
|
||||
mViewPager.setAdapter(mAdapter);
|
||||
mViewPager.setCurrentItem(0);
|
||||
mViewPager.setOnPageChangeListener(this);
|
||||
setPageViewIndicator();
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
private void setPageViewIndicator() {
|
||||
|
||||
Log.d("###setPageViewIndicator", " : called");
|
||||
dotsCount = mAdapter.getCount();
|
||||
dots = new ImageView[dotsCount];
|
||||
|
||||
for (int i = 0; i < dotsCount; i++) {
|
||||
dots[i] = new ImageView(mContext);
|
||||
dots[i].setImageDrawable(getResources().getDrawable(R.drawable.nonselecteditem_dot));
|
||||
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||
25,
|
||||
25
|
||||
);
|
||||
|
||||
params.setMargins(4, 20, 4, 0);
|
||||
|
||||
final int presentPosition = i;
|
||||
dots[presentPosition].setOnTouchListener(new View.OnTouchListener() {
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
mViewPager.setCurrentItem(presentPosition);
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
viewPagerCountDots.addView(dots[i], params);
|
||||
}
|
||||
|
||||
dots[0].setImageDrawable(getResources().getDrawable(R.drawable.selecteditem_dot));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
Log.e("###onPageSelected, pos ", String.valueOf(position));
|
||||
for (int i = 0; i < dotsCount; i++) {
|
||||
dots[i].setImageDrawable(getResources().getDrawable(R.drawable.nonselecteditem_dot));
|
||||
}
|
||||
|
||||
|
||||
dots[position].setImageDrawable(getResources().getDrawable(R.drawable.selecteditem_dot));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
|
||||
}
|
||||
|
||||
public void scrollPage(int position) {
|
||||
mViewPager.setCurrentItem(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
clickDone();
|
||||
}
|
||||
|
||||
public void clickDone() {
|
||||
new AlertDialog.Builder(this)
|
||||
.setIcon(R.mipmap.ic_launcher)
|
||||
.setTitle(getString(R.string.app_name))
|
||||
.setMessage(getString(R.string.exit))
|
||||
.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
finish();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
private void removeNotif() {
|
||||
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
Objects.requireNonNull(notificationManager).cancel(0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,658 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.Editable;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.method.HideReturnsTransformationMethod;
|
||||
import android.text.method.PasswordTransformationMethod;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.ViewFlipper;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.json.LoginRequestJson;
|
||||
import id.ontime.customer.json.LoginResponseJson;
|
||||
import id.ontime.customer.models.FirebaseToken;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.panicbutton.api.LoginAPI;
|
||||
import id.ontime.customer.panicbutton.model.Value;
|
||||
import id.ontime.customer.utils.NetworkUtils;
|
||||
import id.ontime.customer.utils.api.ServiceGenerator;
|
||||
import id.ontime.customer.utils.api.service.UserService;
|
||||
|
||||
import com.google.android.gms.tasks.OnCompleteListener;
|
||||
import com.google.android.gms.tasks.Task;
|
||||
import com.google.firebase.FirebaseException;
|
||||
import com.google.firebase.FirebaseTooManyRequestsException;
|
||||
import com.google.firebase.auth.AuthResult;
|
||||
import com.google.firebase.auth.FirebaseAuth;
|
||||
import com.google.firebase.auth.FirebaseAuthInvalidCredentialsException;
|
||||
import com.google.firebase.auth.PhoneAuthCredential;
|
||||
import com.google.firebase.auth.PhoneAuthProvider;
|
||||
import com.google.firebase.iid.FirebaseInstanceId;
|
||||
import com.ybs.countrypicker.CountryPicker;
|
||||
import com.ybs.countrypicker.CountryPickerListener;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.realm.Realm;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
|
||||
public class LoginActivity extends AppCompatActivity {
|
||||
|
||||
EditText phoneText, password, email, numOne, numTwo, numThree, numFour, numFive, numSix;
|
||||
TextView countryCode, sendTo, privacypolicy, textnotif, daftar, textnotif2, lupapass;
|
||||
Button buttonLogin, confirmButton;
|
||||
ImageView backButton, backButtonverify, showPassword;
|
||||
ViewFlipper viewFlipper;
|
||||
String phoneNumber, disableback;
|
||||
FirebaseAuth mAuth;
|
||||
RelativeLayout rlprogress, rlnotif, rlnotif2, rldaftar;
|
||||
String verify;
|
||||
SharedPreferences sharedPreferences;
|
||||
String country_iso_code = "en";
|
||||
private String phoneVerificationId;
|
||||
private PhoneAuthProvider.OnVerificationStateChangedCallbacks verificationCallbacks;
|
||||
private PhoneAuthProvider.ForceResendingToken resendToken;
|
||||
private FirebaseAuth fbAuth;
|
||||
String idUser, password2;
|
||||
// public static final String URL = "http://beontime.semestaterpadu.my.id/";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_login);
|
||||
try {
|
||||
fbAuth = FirebaseAuth.getInstance();
|
||||
mAuth = FirebaseAuth.getInstance();
|
||||
} catch (IllegalStateException e) {
|
||||
// Firebase not initialized or misconfigured; disable FirebaseAuth usage for this session.
|
||||
fbAuth = null;
|
||||
mAuth = null;
|
||||
Log.e("LoginActivity", "FirebaseAuth not available; continuing without phone auth", e);
|
||||
}
|
||||
|
||||
numOne = findViewById(R.id.numone);
|
||||
numTwo = findViewById(R.id.numtwo);
|
||||
numThree = findViewById(R.id.numthree);
|
||||
numFour = findViewById(R.id.numfour);
|
||||
numFive = findViewById(R.id.numfive);
|
||||
numSix = findViewById(R.id.numsix);
|
||||
privacypolicy = findViewById(R.id.privacypolice);
|
||||
daftar = findViewById(R.id.clickdaftar);
|
||||
rldaftar = findViewById(R.id.rldaftar);
|
||||
lupapass = findViewById(R.id.lupapass);
|
||||
showPassword = findViewById(R.id.iv_showPassword);
|
||||
|
||||
phoneText = findViewById(R.id.phonenumber);
|
||||
countryCode = findViewById(R.id.countrycode);
|
||||
buttonLogin = findViewById(R.id.buttonlogin);
|
||||
backButton = findViewById(R.id.back_btn);
|
||||
confirmButton = findViewById(R.id.buttonconfirm);
|
||||
sendTo = findViewById(R.id.sendtotxt);
|
||||
viewFlipper = findViewById(R.id.viewflipper);
|
||||
backButtonverify = findViewById(R.id.back_btn_verify);
|
||||
rlprogress = findViewById(R.id.rlprogress);
|
||||
password = findViewById(R.id.password);
|
||||
email = findViewById(R.id.email);
|
||||
rlnotif = findViewById(R.id.rlnotif);
|
||||
textnotif = findViewById(R.id.textnotif);
|
||||
rlnotif2 = findViewById(R.id.rlnotif2);
|
||||
textnotif2 = findViewById(R.id.textnotif2);
|
||||
|
||||
sharedPreferences = getSharedPreferences(Constants.PREF_NAME, MODE_PRIVATE);
|
||||
|
||||
String priv = getResources().getString(R.string.privacy);
|
||||
privacypolicy.setText(Html.fromHtml(priv));
|
||||
|
||||
verify = "false";
|
||||
|
||||
|
||||
showPassword.setImageResource(R.drawable.ic_visibility_eye);
|
||||
showPassword.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (password.getTransformationMethod().equals(HideReturnsTransformationMethod.getInstance())){
|
||||
password.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
||||
showPassword.setImageResource(R.drawable.ic_visibility_eye);
|
||||
} else {
|
||||
password.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
|
||||
showPassword.setImageResource(R.drawable.ic_visibility_offeye);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
buttonLogin.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String emailText = email.getText().toString();
|
||||
String phonetext = phoneText.getText().toString();
|
||||
String pass = password.getText().toString();
|
||||
boolean hasEmail = !TextUtils.isEmpty(emailText);
|
||||
|
||||
if (TextUtils.isEmpty(pass)) {
|
||||
notif(getString(R.string.passempty));
|
||||
} else if (!hasEmail && TextUtils.isEmpty(phonetext)) {
|
||||
// Neither email nor phone filled
|
||||
notif(getString(R.string.phonepass));
|
||||
} else {
|
||||
if (NetworkUtils.isConnected(LoginActivity.this)) {
|
||||
// For email+password login, skip SMS verification.
|
||||
verify = hasEmail ? "true" : "false";
|
||||
|
||||
if (!hasEmail) {
|
||||
// Only set phoneNumber when doing phone-based login.
|
||||
phoneNumber = countryCode.getText().toString() + phonetext;
|
||||
}
|
||||
|
||||
progressshow();
|
||||
onSignInClick();
|
||||
} else {
|
||||
progresshide();
|
||||
notif(getString(R.string.text_noInternet));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
countryCode.setOnClickListener(new View.OnClickListener() {
|
||||
@SuppressLint("WrongConstant")
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final CountryPicker picker = CountryPicker.newInstance("Select Country");
|
||||
picker.setListener(new CountryPickerListener() {
|
||||
@Override
|
||||
public void onSelectCountry(String name, String code, String dialCode, int flagDrawableResID) {
|
||||
countryCode.setText(dialCode);
|
||||
picker.dismiss();
|
||||
country_iso_code = code;
|
||||
}
|
||||
});
|
||||
picker.setStyle(R.style.countrypicker_style, R.style.countrypicker_style);
|
||||
picker.show(getSupportFragmentManager(), "Select Country");
|
||||
}
|
||||
});
|
||||
|
||||
lupapass.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(LoginActivity.this, LupapassActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
daftar.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(LoginActivity.this, RegisterActivity.class);
|
||||
startActivity(i);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
privacypolicy.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(LoginActivity.this, PrivacyActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
backButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
backButtonverify.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
confirmButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
verifyCode(viewFlipper);
|
||||
}
|
||||
});
|
||||
disableback = "false";
|
||||
codenumber();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (!disableback.equals("true")) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
public void notif(String text) {
|
||||
rlnotif.setVisibility(View.VISIBLE);
|
||||
textnotif.setText(text);
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
rlnotif.setVisibility(View.GONE);
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
public void notif2(String text) {
|
||||
rlnotif2.setVisibility(View.VISIBLE);
|
||||
textnotif2.setText(text);
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
rlnotif2.setVisibility(View.GONE);
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
public void progressshow() {
|
||||
rlprogress.setVisibility(View.VISIBLE);
|
||||
disableback = "true";
|
||||
}
|
||||
|
||||
public void progresshide() {
|
||||
rlprogress.setVisibility(View.GONE);
|
||||
disableback = "false";
|
||||
}
|
||||
|
||||
|
||||
public void codenumber() {
|
||||
|
||||
numOne.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
if (numOne.getText().toString().length() == 0) {
|
||||
numTwo.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
numTwo.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
if (numTwo.getText().toString().length() == 0) {
|
||||
numThree.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
numThree.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
if (numThree.getText().toString().length() == 0) {
|
||||
numFour.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
numFour.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
if (numFour.getText().toString().length() == 0) {
|
||||
numFive.requestFocus();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
numFive.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
if (numFive.getText().toString().length() == 0) {
|
||||
numSix.requestFocus();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void Nextbtn(View view) {
|
||||
phoneNumber = countryCode.getText().toString() + phoneText.getText().toString();
|
||||
String ccode = countryCode.getText().toString();
|
||||
|
||||
if ((!TextUtils.isEmpty(phoneNumber) && !TextUtils.isEmpty(ccode)) && phoneNumber.length() > 5) {
|
||||
progressshow();
|
||||
Send_Number_tofirebase(phoneNumber);
|
||||
|
||||
} else {
|
||||
notif(getString(R.string.wrongnumber));
|
||||
}
|
||||
}
|
||||
|
||||
public void Send_Number_tofirebase(String phoneNumber) {
|
||||
if (fbAuth == null) {
|
||||
progresshide();
|
||||
notif2(getString(R.string.text_noInternet));
|
||||
return;
|
||||
}
|
||||
|
||||
setUpVerificatonCallbacks();
|
||||
PhoneAuthProvider.getInstance().verifyPhoneNumber(
|
||||
phoneNumber,
|
||||
120,
|
||||
TimeUnit.SECONDS,
|
||||
this,
|
||||
verificationCallbacks);
|
||||
}
|
||||
|
||||
private void setUpVerificatonCallbacks() {
|
||||
verificationCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
|
||||
@Override
|
||||
public void onVerificationCompleted(@NonNull PhoneAuthCredential credential) {
|
||||
signInWithPhoneAuthCredential(credential);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVerificationFailed(@NonNull FirebaseException e) {
|
||||
progresshide();
|
||||
Log.d("respon", e.toString());
|
||||
notif2("kode sms salah!");
|
||||
if (e instanceof FirebaseAuthInvalidCredentialsException) {
|
||||
notif2("kode sms salah!");
|
||||
} else if (e instanceof FirebaseTooManyRequestsException) {
|
||||
notif2("Terlalu banyak permintaan, gunakan nomor hp lain!");
|
||||
notif("Terlalu banyak permintaan, gunakan nomor hp lain!");
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onCodeSent(@NonNull String verificationId, @NonNull PhoneAuthProvider.ForceResendingToken token) {
|
||||
phoneVerificationId = verificationId;
|
||||
resendToken = token;
|
||||
sendTo.setText("Kirim ke( " + phoneNumber + " )");
|
||||
progresshide();
|
||||
viewFlipper.setInAnimation(LoginActivity.this, R.anim.from_right);
|
||||
viewFlipper.setOutAnimation(LoginActivity.this, R.anim.to_left);
|
||||
viewFlipper.setDisplayedChild(1);
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public void verifyCode(View view) {
|
||||
backButton.setVisibility(View.GONE);
|
||||
rldaftar.setVisibility(View.GONE);
|
||||
String code = "" + numOne.getText().toString() + numTwo.getText().toString() + numThree.getText().toString() + numFour.getText().toString() + numFive.getText().toString() + numSix.getText().toString();
|
||||
if (!code.equals("")) {
|
||||
progressshow();
|
||||
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(phoneVerificationId, code);
|
||||
signInWithPhoneAuthCredential(credential);
|
||||
} else {
|
||||
notif2("verifikasi kode sms tidak boleh kosong!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void signInWithPhoneAuthCredential(PhoneAuthCredential credential) {
|
||||
if (fbAuth == null) {
|
||||
progresshide();
|
||||
notif2(getString(R.string.text_noInternet));
|
||||
return;
|
||||
}
|
||||
|
||||
fbAuth.signInWithCredential(credential)
|
||||
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
|
||||
@Override
|
||||
public void onComplete(@NonNull Task<AuthResult> task) {
|
||||
if (task.isSuccessful()) {
|
||||
verify = "true";
|
||||
onSignInClick();
|
||||
|
||||
} else {
|
||||
rlprogress.setVisibility(View.GONE);
|
||||
if (task.getException() instanceof FirebaseAuthInvalidCredentialsException) {
|
||||
notif2("kode sms salah!");
|
||||
} else if (task.getException() instanceof FirebaseTooManyRequestsException) {
|
||||
notif2("Terlalu banyak permintaan, gunakan nomor hp lain!");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void resendCode(View view) {
|
||||
|
||||
if (fbAuth == null) {
|
||||
progresshide();
|
||||
notif2(getString(R.string.text_noInternet));
|
||||
return;
|
||||
}
|
||||
|
||||
setUpVerificatonCallbacks();
|
||||
PhoneAuthProvider.getInstance().verifyPhoneNumber(
|
||||
phoneNumber,
|
||||
120,
|
||||
TimeUnit.SECONDS,
|
||||
this,
|
||||
verificationCallbacks,
|
||||
resendToken);
|
||||
}
|
||||
|
||||
private void onSignInClick() {
|
||||
progressshow();
|
||||
LoginRequestJson request = new LoginRequestJson();
|
||||
String emailText = email.getText().toString().trim();
|
||||
String phoneDigits = phoneText.getText().toString().trim();
|
||||
|
||||
if (!TextUtils.isEmpty(emailText)) {
|
||||
// Login using email + password
|
||||
request.setEmail(emailText);
|
||||
request.setNotelepon("");
|
||||
} else {
|
||||
// Login using phone number + password (legacy flow)
|
||||
request.setEmail(null);
|
||||
request.setNotelepon(countryCode.getText().toString().replace("+", "") + phoneDigits);
|
||||
}
|
||||
request.setPassword(password.getText().toString());
|
||||
try {
|
||||
FirebaseInstanceId token = FirebaseInstanceId.getInstance();
|
||||
request.setRegId(token.getToken());
|
||||
} catch (Exception e) {
|
||||
Log.e("LoginActivity", "Failed to get FirebaseInstanceId token; continuing without regId", e);
|
||||
request.setRegId(null);
|
||||
}
|
||||
|
||||
String basicUser = !TextUtils.isEmpty(emailText) ? emailText : request.getNotelepon();
|
||||
UserService service = ServiceGenerator.createService(UserService.class, basicUser, request.getPassword());
|
||||
service.login(request).enqueue(new Callback<LoginResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<LoginResponseJson> call, @NonNull Response<LoginResponseJson> response) {
|
||||
progresshide();
|
||||
if (response.isSuccessful()) {
|
||||
LoginResponseJson body = response.body();
|
||||
if (body != null && body.getMessage().equalsIgnoreCase("found")) {
|
||||
// On any successful login (email or phone), go straight to home.
|
||||
User user = body.getData().get(0);
|
||||
saveUser(user);
|
||||
loginPanic();
|
||||
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
} else {
|
||||
notif(getString(R.string.phoneemailwrong));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<LoginResponseJson> call, @NonNull Throwable t) {
|
||||
progresshide();
|
||||
t.printStackTrace();
|
||||
notif("error");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == RegisterActivity.SIGNUP_ID) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
if (verify.equals("true")) {
|
||||
User user = (User) data.getSerializableExtra(RegisterActivity.USER_KEY);
|
||||
saveUser(user);
|
||||
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveUser(User user) {
|
||||
Realm realm = Realm.getDefaultInstance();
|
||||
realm.beginTransaction();
|
||||
realm.delete(User.class);
|
||||
realm.copyToRealm(user);
|
||||
realm.commitTransaction();
|
||||
BaseApp.getInstance(LoginActivity.this).setLoginUser(user);
|
||||
|
||||
}
|
||||
|
||||
private void loginPanic() {
|
||||
User loginUser = BaseApp.getInstance(LoginActivity.this).getLoginUser();
|
||||
idUser = loginUser.getEmail();
|
||||
password2 = loginUser.getPassword();
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl(Constants.URL)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.build();
|
||||
LoginAPI loginAPI = retrofit.create(LoginAPI.class);
|
||||
Call<Value> call = loginAPI.login(idUser, password2);
|
||||
call.enqueue(new Callback<Value>() {
|
||||
@Override
|
||||
public void onResponse(Call<Value> call, Response<Value> response) {
|
||||
String value = response.body().getValue();
|
||||
String message = response.body().getMessage();
|
||||
if (value.equals("1")) {
|
||||
gotoMainActivity();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Value> call, Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void gotoMainActivity() {
|
||||
SharedPreferences sharedPreferences = PreferenceManager.
|
||||
getDefaultSharedPreferences(getApplicationContext());
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString("idUser", idUser);
|
||||
editor.putString("status", "Logged In");
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
|
||||
public void onMessageEvent(FirebaseToken response) {
|
||||
Realm realm = Realm.getDefaultInstance();
|
||||
realm.beginTransaction();
|
||||
realm.delete(FirebaseToken.class);
|
||||
realm.copyToRealm(response);
|
||||
realm.commitTransaction();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.json.LoginRequestJson;
|
||||
import id.ontime.customer.json.LoginResponseJson;
|
||||
import id.ontime.customer.utils.api.ServiceGenerator;
|
||||
import id.ontime.customer.utils.api.service.UserService;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
|
||||
public class LupapassActivity extends AppCompatActivity {
|
||||
|
||||
ImageView backbtn;
|
||||
Button submit;
|
||||
EditText email;
|
||||
TextView notiftext;
|
||||
LinearLayout rlnotif;
|
||||
RelativeLayout rlprogress;
|
||||
String disableback;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_lupapassword);
|
||||
|
||||
backbtn = findViewById(R.id.back_btn_verify);
|
||||
submit = findViewById(R.id.buttonconfirm);
|
||||
email = findViewById(R.id.email);
|
||||
notiftext = findViewById(R.id.textnotif2);
|
||||
rlnotif = findViewById(R.id.rlnotif2);
|
||||
rlprogress = findViewById(R.id.rlprogress);
|
||||
|
||||
disableback = "false";
|
||||
|
||||
backbtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
submit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (email.getText().toString().isEmpty()) {
|
||||
notif(getString(R.string.emailempty));
|
||||
} else {
|
||||
get();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void get() {
|
||||
progressshow();
|
||||
LoginRequestJson request = new LoginRequestJson();
|
||||
request.setEmail(email.getText().toString());
|
||||
|
||||
UserService service = ServiceGenerator.createService(UserService.class, request.getEmail(), "12345");
|
||||
service.forgot(request).enqueue(new Callback<LoginResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<LoginResponseJson> call, @NonNull Response<LoginResponseJson> response) {
|
||||
progresshide();
|
||||
if (response.isSuccessful()) {
|
||||
if (Objects.requireNonNull(response.body()).getMessage().equalsIgnoreCase("found")) {
|
||||
notif("Link Reset password telah dikirim ke email! Cek folder utama atau spam");
|
||||
|
||||
} else {
|
||||
notif(("Email tidak terdaftar"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<LoginResponseJson> call, @NonNull Throwable t) {
|
||||
progresshide();
|
||||
t.printStackTrace();
|
||||
notif("error");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void progressshow() {
|
||||
rlprogress.setVisibility(View.VISIBLE);
|
||||
disableback = "true";
|
||||
}
|
||||
|
||||
public void progresshide() {
|
||||
rlprogress.setVisibility(View.GONE);
|
||||
disableback = "false";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (!disableback.equals("true")) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
public void notif(String text) {
|
||||
rlnotif.setVisibility(View.VISIBLE);
|
||||
notiftext.setText(text);
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
rlnotif.setVisibility(View.GONE);
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,290 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentSender;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.navigation.NavigationBarView;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.google.android.play.core.appupdate.AppUpdateManager;
|
||||
import com.google.android.play.core.appupdate.AppUpdateManagerFactory;
|
||||
import com.google.android.play.core.install.InstallStateUpdatedListener;
|
||||
import com.google.android.play.core.install.model.AppUpdateType;
|
||||
import com.google.android.play.core.install.model.InstallStatus;
|
||||
import com.google.android.play.core.install.model.UpdateAvailability;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.constants.VersionChecker;
|
||||
import id.ontime.customer.fragment.FavouriteFragment;
|
||||
import id.ontime.customer.fragment.HistoryFragment;
|
||||
import id.ontime.customer.fragment.HomeFragment;
|
||||
import id.ontime.customer.fragment.MessageFragment;
|
||||
import id.ontime.customer.fragment.ProfileFragment;
|
||||
import id.ontime.customer.json.GetFiturResponseJson;
|
||||
import id.ontime.customer.models.FiturModel;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.panicbutton.LoginPanicActivity;
|
||||
import id.ontime.customer.utils.SettingPreference;
|
||||
import id.ontime.customer.utils.api.ServiceGenerator;
|
||||
import id.ontime.customer.utils.api.service.UserService;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import io.realm.Realm;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
public static String apikey;
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
public static MainActivity mainActivity;
|
||||
long mBackPressed;
|
||||
// LinearLayout mAdViewLayout;
|
||||
BottomNavigationView navigation;
|
||||
int previousSelect = 0;
|
||||
private Fragment fragment;
|
||||
private FragmentManager fragmentManager;
|
||||
FloatingActionButton panicButton;
|
||||
private SettingPreference sp;
|
||||
|
||||
private AppUpdateManager mAppUpdateManager;
|
||||
private static final int RC_APP_UPDATE =100;
|
||||
|
||||
public static MainActivity getInstance() {
|
||||
return mainActivity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
Intent intent = getIntent();
|
||||
// mAdViewLayout = findViewById(R.id.adView);
|
||||
navigation = findViewById(R.id.navigation);
|
||||
fragmentManager = getSupportFragmentManager();
|
||||
panicButton = findViewById(R.id.panicbutton);
|
||||
sp = new SettingPreference(MainActivity.this);
|
||||
|
||||
panicButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i= new Intent(MainActivity.this, LoginPanicActivity.class);
|
||||
i.putExtra("id_driver",intent.getStringExtra("id_driver"));
|
||||
i.putExtra("id_transaksi", intent.getStringExtra("id_transaksi"));
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
}
|
||||
});
|
||||
|
||||
mAppUpdateManager = AppUpdateManagerFactory.create(this);
|
||||
mAppUpdateManager.getAppUpdateInfo().addOnSuccessListener(appUpdateInfo -> {
|
||||
if(appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)) {
|
||||
try {
|
||||
mAppUpdateManager.startUpdateFlowForResult(appUpdateInfo, AppUpdateType.FLEXIBLE,MainActivity.this, RC_APP_UPDATE);
|
||||
} catch (IntentSender.SendIntentException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//Untuk inisialisasi fragment pertama kali
|
||||
|
||||
navigation.setSelectedItemId(R.id.home);
|
||||
|
||||
fragmentManager.beginTransaction().replace(R.id.container, new HomeFragment()).commit();
|
||||
navigation.setLabelVisibilityMode(NavigationBarView.LABEL_VISIBILITY_LABELED);
|
||||
navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
if (id == R.id.home) {
|
||||
fragment = new HomeFragment();
|
||||
} else if (id == R.id.order) {
|
||||
fragment = new HistoryFragment();
|
||||
} else if (id == R.id.favourite) {
|
||||
fragment = new FavouriteFragment();
|
||||
} else if (id == R.id.chat) {
|
||||
fragment = new MessageFragment();
|
||||
} else if (id == R.id.profile) {
|
||||
fragment = new ProfileFragment();
|
||||
}
|
||||
final FragmentTransaction transaction = fragmentManager.beginTransaction();
|
||||
transaction.replace(R.id.container, fragment).commit();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
User loginUser = BaseApp.getInstance(this).getLoginUser();
|
||||
Constants.TOKEN = loginUser.getToken();
|
||||
Constants.USERID = loginUser.getId();
|
||||
apikey = getString(R.string.google_maps_key);
|
||||
// apikey = sp.getSetting()[3];
|
||||
|
||||
PackageInfo packageInfo = null;
|
||||
try {
|
||||
packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Constants.versionname = Objects.requireNonNull(packageInfo).versionName;
|
||||
|
||||
mAppUpdateManager.registerListener(installStateUpdatedListener);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private InstallStateUpdatedListener installStateUpdatedListener = installState -> {
|
||||
|
||||
if(installState.installStatus() == InstallStatus.DOWNLOADED) {
|
||||
showCompletedUpdate();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
|
||||
if(mAppUpdateManager != null) mAppUpdateManager.unregisterListener(installStateUpdatedListener);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
private void showCompletedUpdate() {
|
||||
Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content), "Update Aplikasi terbaru sudah tersedia!",
|
||||
Snackbar.LENGTH_INDEFINITE);
|
||||
snackbar.setAction("Install", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mAppUpdateManager.completeUpdate();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
snackbar.show();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
|
||||
if(requestCode == RC_APP_UPDATE && resultCode != RESULT_OK) {
|
||||
Toast.makeText(this, "Cancel", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
//Check_version();
|
||||
update();
|
||||
}
|
||||
|
||||
/* public void Check_version() {
|
||||
VersionChecker versionChecker = new VersionChecker(this);
|
||||
versionChecker.execute();
|
||||
} */
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
int count = this.getSupportFragmentManager().getBackStackEntryCount();
|
||||
if (count == 0) {
|
||||
if (mBackPressed + 2000 > System.currentTimeMillis()) {
|
||||
super.onBackPressed();
|
||||
} else {
|
||||
clickDone();
|
||||
|
||||
}
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
public void clickDone() {
|
||||
new AlertDialog.Builder(this)
|
||||
.setIcon(R.mipmap.ic_launcher)
|
||||
.setTitle(getString(R.string.app_name))
|
||||
.setMessage(getString(R.string.exit))
|
||||
.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
finish();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
|
||||
public void loadFrag(Fragment f1, String name, FragmentManager fm) {
|
||||
for (int i = 0; i < fm.getBackStackEntryCount(); ++i) {
|
||||
fm.popBackStack();
|
||||
}
|
||||
FragmentTransaction ft = fm.beginTransaction();
|
||||
ft.replace(R.id.Container, f1, name);
|
||||
ft.commit();
|
||||
}
|
||||
|
||||
public void navigationItemSelected(int position) {
|
||||
previousSelect = position;
|
||||
}
|
||||
|
||||
private void update() {
|
||||
User loginUser = BaseApp.getInstance(this).getLoginUser();
|
||||
UserService userService = ServiceGenerator.createService(UserService.class,
|
||||
loginUser.getEmail(), loginUser.getPassword());
|
||||
userService.getFitur().enqueue(new Callback<GetFiturResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<GetFiturResponseJson> call, @NonNull Response<GetFiturResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
Realm realm = BaseApp.getInstance(MainActivity.this).getRealmInstance();
|
||||
realm.beginTransaction();
|
||||
realm.delete(FiturModel.class);
|
||||
realm.copyToRealm(Objects.requireNonNull(response.body()).getData());
|
||||
realm.commitTransaction();
|
||||
|
||||
Constants.CURRENCY = response.body().getCurrencyModel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<GetFiturResponseJson> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.os.Bundle;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import com.google.android.gms.maps.CameraUpdateFactory;
|
||||
import com.google.android.gms.maps.GoogleMap;
|
||||
import com.google.android.gms.maps.OnMapReadyCallback;
|
||||
import com.google.android.gms.maps.SupportMapFragment;
|
||||
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.google.android.gms.maps.model.MarkerOptions;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class MapsMerchantActivity extends AppCompatActivity implements OnMapReadyCallback {
|
||||
|
||||
ImageView backbtn;
|
||||
String lat, lon, name;
|
||||
private GoogleMap mGoogleMap;
|
||||
private View marker_view;
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_maps_merchant);
|
||||
|
||||
Intent intent = getIntent();
|
||||
lat = intent.getStringExtra("lat");
|
||||
lon = intent.getStringExtra("lon");
|
||||
name = intent.getStringExtra("name");
|
||||
|
||||
backbtn = findViewById(R.id.back_btn);
|
||||
|
||||
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
marker_view = Objects.requireNonNull(inflater).inflate(R.layout.maps_marker, null);
|
||||
|
||||
backbtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
|
||||
.findFragmentById(R.id.mapView);
|
||||
Objects.requireNonNull(mapFragment).getMapAsync(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapReady(GoogleMap googleMap) {
|
||||
mGoogleMap = googleMap;
|
||||
|
||||
mGoogleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
|
||||
//googleMap.setMyLocationEnabled(true);
|
||||
mGoogleMap.setTrafficEnabled(false);
|
||||
mGoogleMap.setIndoorEnabled(false);
|
||||
mGoogleMap.setBuildingsEnabled(true);
|
||||
mGoogleMap.getUiSettings().setZoomControlsEnabled(true);
|
||||
mGoogleMap.getUiSettings().setZoomGesturesEnabled(true);
|
||||
|
||||
|
||||
if (!lat.isEmpty() && !lon.isEmpty()) {
|
||||
double latitude = Double.parseDouble(lat);
|
||||
double longitude = Double.parseDouble(lon);
|
||||
drawMarker(latitude, longitude, name);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawMarker(double latitude, double longitude, String propname) {
|
||||
mGoogleMap.clear();
|
||||
|
||||
MarkerOptions markerOptions = new MarkerOptions();
|
||||
|
||||
markerOptions.position(new LatLng(latitude, longitude));
|
||||
markerOptions.title(propname);
|
||||
markerOptions.icon(BitmapDescriptorFactory.fromBitmap(createBitmapFromView(marker_view)));
|
||||
|
||||
markerOptions.draggable(false);
|
||||
mGoogleMap.addMarker(markerOptions);
|
||||
mGoogleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude, longitude), 15));
|
||||
}
|
||||
|
||||
public Bitmap createBitmapFromView(View view) {
|
||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
|
||||
view.measure(displayMetrics.widthPixels, displayMetrics.heightPixels);
|
||||
view.layout(0, 0, displayMetrics.widthPixels, displayMetrics.heightPixels);
|
||||
view.buildDrawingCache();
|
||||
Bitmap bitmap = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
|
||||
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
view.draw(canvas);
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,561 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.InputFilter;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.adapter.CityAdapter;
|
||||
import id.ontime.customer.adapter.ExpedisiAdapter;
|
||||
import id.ontime.customer.adapter.ProvinceAdapter;
|
||||
import id.ontime.customer.api.ApiService;
|
||||
import id.ontime.customer.api.ApiUrl;
|
||||
import id.ontime.customer.models.city.ItemCity;
|
||||
import id.ontime.customer.models.cost.ItemCost;
|
||||
import id.ontime.customer.models.expedisi.ItemExpedisi;
|
||||
import id.ontime.customer.models.province.ItemProvince;
|
||||
import id.ontime.customer.models.province.Result;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public class OngkirActivity extends AppCompatActivity {
|
||||
|
||||
private EditText etFromProvince, etToProvince;
|
||||
private EditText etFromCity, etToCity;
|
||||
private EditText etWeight, etCourier;
|
||||
|
||||
private AlertDialog.Builder alert;
|
||||
private AlertDialog ad;
|
||||
private EditText searchList;
|
||||
private ListView mListView;
|
||||
|
||||
private ProvinceAdapter adapter_province;
|
||||
private List<Result> ListProvince = new ArrayList<Result>();
|
||||
|
||||
private CityAdapter adapter_city;
|
||||
private List<id.ontime.customer.models.city.Result> ListCity = new ArrayList<>();
|
||||
|
||||
private ExpedisiAdapter adapter_expedisi;
|
||||
private List<ItemExpedisi> listItemExpedisi = new ArrayList<ItemExpedisi>();
|
||||
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_ongkir);
|
||||
|
||||
etFromProvince = findViewById(R.id.etFromProvince);
|
||||
etFromCity = findViewById(R.id.etFromCity);
|
||||
etToProvince = findViewById(R.id.etToProvince);
|
||||
etToCity = findViewById(R.id.etToCity);
|
||||
etWeight = findViewById(R.id.etWeight);
|
||||
etCourier = findViewById(R.id.etCourier);
|
||||
|
||||
etFromProvince.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
popUpProvince(etFromProvince, etFromCity);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
etFromCity.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
try {
|
||||
if (etFromProvince.getTag().equals("")) {
|
||||
etFromProvince.setError("Mohon pilih provinsi");
|
||||
} else {
|
||||
popUpCity(etFromCity, etFromProvince);
|
||||
}
|
||||
|
||||
} catch (NullPointerException e) {
|
||||
etFromProvince.setError("Mohon pilih provinsi");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
etToProvince.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
popUpProvince(etToProvince, etToCity);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
etToCity.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
try {
|
||||
if (etToProvince.getTag().equals("")) {
|
||||
etToProvince.setError("Mohon pilih tujuan provinsi");
|
||||
} else {
|
||||
popUpCity(etToCity, etToProvince);
|
||||
}
|
||||
|
||||
} catch (NullPointerException e) {
|
||||
etToProvince.setError("Mohon pilih tujuan provinsi");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
etCourier.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
popUpExpedisi(etCourier);
|
||||
}
|
||||
});
|
||||
|
||||
Button btnProcess = (Button) findViewById(R.id.btnProcess);
|
||||
btnProcess.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
String Origin = etFromCity.getText().toString();
|
||||
String destination = etToCity.getText().toString();
|
||||
String Weight = etWeight.getText().toString();
|
||||
String expedisi = etCourier.getText().toString();
|
||||
|
||||
if (Origin.equals("")){
|
||||
etFromCity.setError("Masukan posisi pengirim");
|
||||
} else if (destination.equals("")){
|
||||
etToCity.setError("Masukan tujuan kota ");
|
||||
} else if (Weight.equals("")){
|
||||
etWeight.setError("Masukan berat paket");
|
||||
} else if (expedisi.equals("")){
|
||||
etCourier.setError("Mohon pilih expedisinya");
|
||||
} else {
|
||||
|
||||
progressDialog = new ProgressDialog(OngkirActivity.this);
|
||||
progressDialog.setMessage("Mohon tunggu..");
|
||||
progressDialog.show();
|
||||
|
||||
getCoast(
|
||||
etFromCity.getTag().toString(),
|
||||
etToCity.getTag().toString(),
|
||||
etWeight.getText().toString(),
|
||||
etCourier.getText().toString()
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void popUpProvince(final EditText etProvince, final EditText etCity ) {
|
||||
|
||||
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
View alertLayout = inflater.inflate(R.layout.custom_dialog_search, null);
|
||||
|
||||
alert = new AlertDialog.Builder(OngkirActivity.this);
|
||||
alert.setTitle("Daftar Provinsi");
|
||||
alert.setMessage("Pilih Provinsi");
|
||||
alert.setView(alertLayout);
|
||||
alert.setCancelable(true);
|
||||
|
||||
ad = alert.show();
|
||||
|
||||
searchList = alertLayout.findViewById(R.id.searchItem);
|
||||
searchList.addTextChangedListener(new MyTextWatcherProvince(searchList));
|
||||
searchList.setFilters(new InputFilter[]{new InputFilter.AllCaps()});
|
||||
|
||||
mListView = alertLayout.findViewById(R.id.listItem);
|
||||
|
||||
ListProvince.clear();
|
||||
adapter_province = new ProvinceAdapter(OngkirActivity.this, ListProvince);
|
||||
mListView.setClickable(true);
|
||||
|
||||
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
Object o = mListView.getItemAtPosition(i);
|
||||
Result cn = (Result) o;
|
||||
|
||||
etProvince.setError(null);
|
||||
etProvince.setText(cn.getProvince());
|
||||
etProvince.setTag(cn.getProvinceId());
|
||||
|
||||
etCity.setText("");
|
||||
etCity.setTag("");
|
||||
|
||||
ad.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
progressDialog = new ProgressDialog(OngkirActivity.this);
|
||||
progressDialog.setMessage("Mohon tunggu..");
|
||||
progressDialog.show();
|
||||
|
||||
getProvince();
|
||||
|
||||
}
|
||||
|
||||
public void popUpCity(final EditText etCity, final EditText etProvince) {
|
||||
|
||||
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
View alertLayout = inflater.inflate(R.layout.custom_dialog_search, null);
|
||||
|
||||
alert = new AlertDialog.Builder(OngkirActivity.this);
|
||||
alert.setTitle("Daftar Kota");
|
||||
alert.setMessage("Pilih Kota");
|
||||
alert.setView(alertLayout);
|
||||
alert.setCancelable(true);
|
||||
|
||||
ad = alert.show();
|
||||
|
||||
searchList = (EditText) alertLayout.findViewById(R.id.searchItem);
|
||||
searchList.addTextChangedListener(new MyTextWatcherCity(searchList));
|
||||
searchList.setFilters(new InputFilter[]{new InputFilter.AllCaps()});
|
||||
|
||||
mListView = (ListView) alertLayout.findViewById(R.id.listItem);
|
||||
|
||||
ListCity.clear();
|
||||
adapter_city = new CityAdapter(OngkirActivity.this, ListCity);
|
||||
mListView.setClickable(true);
|
||||
|
||||
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
Object o = mListView.getItemAtPosition(i);
|
||||
id.ontime.customer.models.city.Result cn = (id.ontime.customer.models.city.Result) o;
|
||||
|
||||
etCity.setError(null);
|
||||
etCity.setText(cn.getCityName());
|
||||
etCity.setTag(cn.getCityId());
|
||||
|
||||
ad.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
progressDialog = new ProgressDialog(OngkirActivity.this);
|
||||
progressDialog.setMessage("Mohon tunggu..");
|
||||
progressDialog.show();
|
||||
|
||||
getCity(etProvince.getTag().toString());
|
||||
|
||||
}
|
||||
|
||||
public void popUpExpedisi(final EditText etExpedisi) {
|
||||
|
||||
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
View alertLayout = inflater.inflate(R.layout.custom_dialog_search, null);
|
||||
|
||||
alert = new AlertDialog.Builder(OngkirActivity.this);
|
||||
alert.setTitle("Daftar Expedisi");
|
||||
alert.setMessage("Pilih Expedisi");
|
||||
alert.setView(alertLayout);
|
||||
alert.setCancelable(true);
|
||||
|
||||
ad = alert.show();
|
||||
|
||||
searchList = (EditText) alertLayout.findViewById(R.id.searchItem);
|
||||
searchList.addTextChangedListener(new MyTextWatcherCity(searchList));
|
||||
searchList.setFilters(new InputFilter[]{new InputFilter.AllCaps()});
|
||||
|
||||
mListView = (ListView) alertLayout.findViewById(R.id.listItem);
|
||||
|
||||
listItemExpedisi.clear();
|
||||
adapter_expedisi = new ExpedisiAdapter(OngkirActivity.this, listItemExpedisi);
|
||||
mListView.setClickable(true);
|
||||
|
||||
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
Object o = mListView.getItemAtPosition(i);
|
||||
ItemExpedisi cn = (ItemExpedisi) o;
|
||||
|
||||
etExpedisi.setError(null);
|
||||
etExpedisi.setText(cn.getName());
|
||||
etExpedisi.setTag(cn.getId());
|
||||
|
||||
ad.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
getExpedisi();
|
||||
|
||||
}
|
||||
|
||||
private class MyTextWatcherProvince implements TextWatcher {
|
||||
|
||||
private View view;
|
||||
|
||||
private MyTextWatcherProvince(View view) {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
}
|
||||
|
||||
public void onTextChanged(CharSequence s, int i, int before, int i2) {
|
||||
}
|
||||
|
||||
public void afterTextChanged(Editable editable) {
|
||||
if (view.getId() == R.id.searchItem) {
|
||||
adapter_province.filter(editable.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class MyTextWatcherCity implements TextWatcher {
|
||||
|
||||
private View view;
|
||||
|
||||
private MyTextWatcherCity(View view) {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
}
|
||||
|
||||
public void onTextChanged(CharSequence s, int i, int before, int i2) {
|
||||
}
|
||||
|
||||
public void afterTextChanged(Editable editable) {
|
||||
if (view.getId() == R.id.searchItem) {
|
||||
adapter_city.filter(editable.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void getProvince() {
|
||||
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl(ApiUrl.URL_ROOT_HTTPS)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.build();
|
||||
|
||||
ApiService service = retrofit.create(ApiService.class);
|
||||
Call<ItemProvince> call = service.getProvince();
|
||||
|
||||
call.enqueue(new Callback<ItemProvince>() {
|
||||
@Override
|
||||
public void onResponse(Call<ItemProvince> call, Response<ItemProvince> response) {
|
||||
|
||||
progressDialog.dismiss();
|
||||
Log.v("wow", "json : " + new Gson().toJson(response));
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
int count_data = response.body().getRajaongkir().getResults().size();
|
||||
for (int a = 0; a <= count_data - 1; a++) {
|
||||
Result itemProvince = new Result(
|
||||
response.body().getRajaongkir().getResults().get(a).getProvinceId(),
|
||||
response.body().getRajaongkir().getResults().get(a).getProvince()
|
||||
);
|
||||
|
||||
ListProvince.add(itemProvince);
|
||||
mListView.setAdapter(adapter_province);
|
||||
}
|
||||
|
||||
adapter_province.setList(ListProvince);
|
||||
adapter_province.filter("");
|
||||
|
||||
} else {
|
||||
String error = "Error Retrive Data from Server !!!";
|
||||
Toast.makeText(OngkirActivity.this, error, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ItemProvince> call, Throwable t) {
|
||||
progressDialog.dismiss();
|
||||
Toast.makeText(OngkirActivity.this, "Message : Error " + t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void getCity(String id_province) {
|
||||
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl(ApiUrl.URL_ROOT_HTTPS)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.build();
|
||||
|
||||
ApiService service = retrofit.create(ApiService.class);
|
||||
Call<ItemCity> call = service.getCity(id_province);
|
||||
|
||||
call.enqueue(new Callback<ItemCity>() {
|
||||
@Override
|
||||
public void onResponse(Call<ItemCity> call, Response<ItemCity> response) {
|
||||
|
||||
progressDialog.dismiss();
|
||||
Log.v("wow", "json : " + new Gson().toJson(response));
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
int count_data = response.body().getRajaongkir().getResults().size();
|
||||
for (int a = 0; a <= count_data - 1; a++) {
|
||||
id.ontime.customer.models.city.Result itemProvince = new id.ontime.customer.models.city.Result(
|
||||
response.body().getRajaongkir().getResults().get(a).getCityId(),
|
||||
response.body().getRajaongkir().getResults().get(a).getProvinceId(),
|
||||
response.body().getRajaongkir().getResults().get(a).getProvince(),
|
||||
response.body().getRajaongkir().getResults().get(a).getType(),
|
||||
response.body().getRajaongkir().getResults().get(a).getCityName(),
|
||||
response.body().getRajaongkir().getResults().get(a).getPostalCode()
|
||||
);
|
||||
|
||||
ListCity.add(itemProvince);
|
||||
mListView.setAdapter(adapter_city);
|
||||
}
|
||||
|
||||
adapter_city.setList(ListCity);
|
||||
adapter_city.filter("");
|
||||
|
||||
} else {
|
||||
String error = "Error Retrive Data from Server !!!";
|
||||
Toast.makeText(OngkirActivity.this, error, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ItemCity> call, Throwable t) {
|
||||
progressDialog.dismiss();
|
||||
Toast.makeText(OngkirActivity.this, "Message : Error " + t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void getExpedisi() {
|
||||
|
||||
ItemExpedisi itemItemExpedisi = new ItemExpedisi();
|
||||
|
||||
itemItemExpedisi = new ItemExpedisi("1", "pos");
|
||||
listItemExpedisi.add(itemItemExpedisi);
|
||||
itemItemExpedisi = new ItemExpedisi("1", "tiki");
|
||||
listItemExpedisi.add(itemItemExpedisi);
|
||||
itemItemExpedisi = new ItemExpedisi("1", "jne");
|
||||
listItemExpedisi.add(itemItemExpedisi);
|
||||
|
||||
mListView.setAdapter(adapter_expedisi);
|
||||
|
||||
adapter_expedisi.setList(listItemExpedisi);
|
||||
adapter_expedisi.filter("");
|
||||
|
||||
}
|
||||
|
||||
public void getCoast(String origin,
|
||||
String destination,
|
||||
String weight,
|
||||
String courier) {
|
||||
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl(ApiUrl.URL_ROOT_HTTPS)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.build();
|
||||
|
||||
ApiService service = retrofit.create(ApiService.class);
|
||||
Call<ItemCost> call = service.getCost(
|
||||
"2c1cf2e4614041e9e929dbee9b2ccfd1",
|
||||
origin,
|
||||
destination,
|
||||
weight,
|
||||
courier
|
||||
);
|
||||
|
||||
call.enqueue(new Callback<ItemCost>() {
|
||||
@Override
|
||||
public void onResponse(Call<ItemCost> call, Response<ItemCost> response) {
|
||||
|
||||
Log.v("wow", "json : " + new Gson().toJson(response));
|
||||
progressDialog.dismiss();
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
int statusCode = response.body().getRajaongkir().getStatus().getCode();
|
||||
|
||||
if (statusCode == 200){
|
||||
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
View alertLayout = inflater.inflate(R.layout.custom_dialog_result, null);
|
||||
alert = new AlertDialog.Builder(OngkirActivity.this);
|
||||
alert.setTitle("Keterangan");
|
||||
alert.setMessage("Hasil perhitungan");
|
||||
alert.setView(alertLayout);
|
||||
alert.setCancelable(true);
|
||||
|
||||
ad = alert.show();
|
||||
|
||||
TextView tv_origin = (TextView) alertLayout.findViewById(R.id.tv_origin);
|
||||
TextView tv_destination = (TextView) alertLayout.findViewById(R.id.tv_destination);
|
||||
TextView tv_expedisi = (TextView) alertLayout.findViewById(R.id.tv_expedisi);
|
||||
TextView tv_coast = (TextView) alertLayout.findViewById(R.id.tv_coast);
|
||||
TextView tv_time = (TextView) alertLayout.findViewById(R.id.tv_time);
|
||||
|
||||
tv_origin.setText(response.body().getRajaongkir().getOriginDetails().getCityName()+" (Postal Code : "+
|
||||
response.body().getRajaongkir().getOriginDetails().getPostalCode()+")");
|
||||
|
||||
tv_destination.setText(response.body().getRajaongkir().getDestinationDetails().getCityName()+" (Postal Code : "+
|
||||
response.body().getRajaongkir().getDestinationDetails().getPostalCode()+")");
|
||||
|
||||
tv_expedisi.setText(response.body().getRajaongkir().getResults().get(0).getCosts().get(0).getDescription()+" ("+
|
||||
response.body().getRajaongkir().getResults().get(0).getName()+") ");
|
||||
|
||||
tv_coast.setText("Rp. "+response.body().getRajaongkir().getResults().get(0).getCosts().get(0).getCost().get(0).getValue().toString());
|
||||
|
||||
tv_time.setText(response.body().getRajaongkir().getResults().get(0).getCosts().get(0).getCost().get(0).getEtd()+" (Days)");
|
||||
|
||||
etFromProvince.setText("");
|
||||
etFromCity.setText("");
|
||||
etToProvince.setText("");
|
||||
etToCity.setText("");
|
||||
etWeight.setText("");
|
||||
etCourier.setText("");
|
||||
} else {
|
||||
|
||||
String message = response.body().getRajaongkir().getStatus().getDescription();
|
||||
Toast.makeText(OngkirActivity.this, message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
} else {
|
||||
String error = "Error Retrive Data from Server !!!";
|
||||
Toast.makeText(OngkirActivity.this, error, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ItemCost> call, Throwable t) {
|
||||
|
||||
progressDialog.dismiss();
|
||||
Toast.makeText(OngkirActivity.this, "Message : Error " + t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.item.TopUpItem;
|
||||
import id.ontime.customer.item.TopUpPlnHistoryItem;
|
||||
import id.ontime.customer.json.MobileTopUpDetailResponseModel;
|
||||
import id.ontime.customer.json.MobileTopUpRequestModel;
|
||||
import id.ontime.customer.json.MobileTopUpResponseModel;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.utils.ProjectUtils;
|
||||
import id.ontime.customer.utils.SettingPreference;
|
||||
import id.ontime.customer.utils.api.ServiceGenerator;
|
||||
import id.ontime.customer.utils.api.service.UserService;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class OperatorProviderListActivity extends AppCompatActivity implements TopUpPlnHistoryItem.onRecyclerViewOnClicked {
|
||||
|
||||
RecyclerView recycle;
|
||||
TopUpItem adapterTopUp;
|
||||
String disableBack;
|
||||
TextView tvTitle;
|
||||
RelativeLayout rlProgress;
|
||||
EditText etSearchProduct;
|
||||
ImageView backButton;
|
||||
SettingPreference sp;
|
||||
|
||||
String topUpType;
|
||||
|
||||
public static final String TOPUP_TYPE = "topuptype";
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_provider_list);
|
||||
etSearchProduct = findViewById(R.id.etSearchProduct);
|
||||
rlProgress= findViewById(R.id.rlprogress);
|
||||
backButton = findViewById(R.id.back_btn);
|
||||
recycle = findViewById(R.id.rcView);
|
||||
tvTitle = findViewById(R.id.tvTitle);
|
||||
sp = new SettingPreference(this);
|
||||
|
||||
initRecyclerView();
|
||||
initIntent();
|
||||
|
||||
backButton.setOnClickListener(v -> finish());
|
||||
|
||||
etSearchProduct.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
if (adapterTopUp != null) {
|
||||
adapterTopUp.getFilter().filter(s.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initRecyclerView() {
|
||||
recycle.setHasFixedSize(true);
|
||||
recycle.setNestedScrollingEnabled(false);
|
||||
recycle.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
|
||||
}
|
||||
|
||||
private void initIntent() {
|
||||
Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
String operator = intent.getStringExtra(Constants.OPERATOR);
|
||||
topUpType = intent.getStringExtra(TOPUP_TYPE);
|
||||
tvTitle.setText(operator != null ?operator.toUpperCase(): "");
|
||||
getData(operator);
|
||||
}
|
||||
}
|
||||
|
||||
private void progressShow() {
|
||||
rlProgress.setVisibility(View.VISIBLE);
|
||||
disableBack = "true";
|
||||
}
|
||||
|
||||
private void progressHide() {
|
||||
rlProgress.setVisibility(View.GONE);
|
||||
disableBack = "false";
|
||||
}
|
||||
|
||||
/**
|
||||
* setSign (please change this between develop and production)
|
||||
* generate md5 (current mobile pulsa username + api key + "pl")
|
||||
*/
|
||||
private void getData(String operator) {
|
||||
progressShow();
|
||||
String signId = sp.getSetting()[7] + sp.getSetting()[8] + "pl";
|
||||
|
||||
MobileTopUpRequestModel request = new MobileTopUpRequestModel();
|
||||
request.setUsername(sp.getSetting()[7]);
|
||||
request.setSign(ProjectUtils.md5(signId));
|
||||
request.setCommand("pricelist");
|
||||
request.setStatus("all");
|
||||
final User user = BaseApp.getInstance(this).getLoginUser();
|
||||
UserService service = ServiceGenerator.createService(UserService.class, user.getNoTelepon(), user.getPassword());
|
||||
service.getAllMobileTopUpType(Constants.MOBILEPULSA_PRODUCTION_URL +"/"+topUpType+"/"+operator, request).enqueue(new Callback<MobileTopUpResponseModel>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<MobileTopUpResponseModel> call, @NonNull Response<MobileTopUpResponseModel> response) {
|
||||
progressHide();
|
||||
if (response.body() != null) {
|
||||
adapterTopUp = new TopUpItem(response.body().getDetailResponse(), OperatorProviderListActivity.this);
|
||||
recycle.setAdapter(adapterTopUp);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<MobileTopUpResponseModel> call, @NonNull Throwable t) {
|
||||
progressHide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(MobileTopUpDetailResponseModel model) {
|
||||
Intent i = new Intent();
|
||||
i.putExtra(Constants.OPERATOR, model);
|
||||
setResult(RESULT_OK, i);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.Address;
|
||||
import android.location.Geocoder;
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import com.google.android.gms.common.ConnectionResult;
|
||||
import com.google.android.gms.common.api.GoogleApiClient;
|
||||
import com.google.android.gms.common.api.Status;
|
||||
import com.google.android.gms.location.LocationServices;
|
||||
import com.google.android.gms.maps.CameraUpdateFactory;
|
||||
import com.google.android.gms.maps.GoogleMap;
|
||||
import com.google.android.gms.maps.OnMapReadyCallback;
|
||||
import com.google.android.gms.maps.SupportMapFragment;
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.google.android.libraries.places.api.Places;
|
||||
import com.google.android.libraries.places.api.model.Place;
|
||||
import com.google.android.libraries.places.widget.Autocomplete;
|
||||
import com.google.android.libraries.places.widget.AutocompleteActivity;
|
||||
import com.google.android.libraries.places.widget.model.AutocompleteActivityMode;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
public class PicklocationActivity extends AppCompatActivity
|
||||
implements OnMapReadyCallback, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
|
||||
|
||||
public static final int LOCATION_PICKER_ID = 78;
|
||||
public static final String FORM_VIEW_INDICATOR = "FormToFill";
|
||||
public static final String LOCATION_NAME = "LocationName";
|
||||
public static final String LOCATION_LATLNG = "LocationLatLng";
|
||||
private static final int REQUEST_PERMISSION_LOCATION = 991;
|
||||
TextView autoCompleteTextView;
|
||||
|
||||
TextView currentAddress;
|
||||
|
||||
Button selectLocation;
|
||||
ImageView backbutton;
|
||||
|
||||
|
||||
private GoogleMap gMap;
|
||||
private GoogleApiClient googleApiClient;
|
||||
|
||||
|
||||
private int formToFill;
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
googleApiClient.connect();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
googleApiClient.disconnect();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_picklocation);
|
||||
|
||||
autoCompleteTextView = findViewById(R.id.locationPicker_autoCompleteText);
|
||||
currentAddress = findViewById(R.id.locationPicker_currentAddress);
|
||||
selectLocation = findViewById(R.id.locationPicker_destinationButton);
|
||||
backbutton = findViewById(R.id.back_btn);
|
||||
Places.initialize(getApplicationContext(), getString(R.string.google_maps_key));
|
||||
|
||||
if (!Places.isInitialized()) {
|
||||
Places.initialize(getApplicationContext(), getString(R.string.google_maps_key));
|
||||
}
|
||||
|
||||
setupGoogleApiClient();
|
||||
|
||||
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
|
||||
.findFragmentById(R.id.locationPicker_maps);
|
||||
Objects.requireNonNull(mapFragment).getMapAsync(this);
|
||||
|
||||
Intent intent = getIntent();
|
||||
formToFill = intent.getIntExtra(FORM_VIEW_INDICATOR, -1);
|
||||
|
||||
selectLocation.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
selectLocation();
|
||||
}
|
||||
});
|
||||
|
||||
backbutton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
autoCompleteTextView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
setupAutocompleteTextView();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void selectLocation() {
|
||||
LatLng selectedLocation = gMap.getCameraPosition().target;
|
||||
String selectedAddress = currentAddress.getText().toString();
|
||||
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(FORM_VIEW_INDICATOR, formToFill);
|
||||
intent.putExtra(LOCATION_NAME, selectedAddress);
|
||||
intent.putExtra(LOCATION_LATLNG, selectedLocation);
|
||||
setResult(Activity.RESULT_OK, intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
private void setupGoogleApiClient() {
|
||||
if (googleApiClient == null) {
|
||||
googleApiClient = new GoogleApiClient.Builder(this)
|
||||
.addConnectionCallbacks(this)
|
||||
.addOnConnectionFailedListener(this)
|
||||
.addApi(LocationServices.API)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupAutocompleteTextView() {
|
||||
List<Place.Field> fields = Arrays.asList(Place.Field.ID, Place.Field.ADDRESS, Place.Field.LAT_LNG);
|
||||
Intent intent = new Autocomplete.IntentBuilder(
|
||||
AutocompleteActivityMode.FULLSCREEN, fields)
|
||||
.build(this);
|
||||
startActivityForResult(intent, 1);
|
||||
}
|
||||
|
||||
|
||||
private void updateLastLocation() {
|
||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_PERMISSION_LOCATION);
|
||||
return;
|
||||
}
|
||||
|
||||
Location lastKnownLocation = LocationServices.FusedLocationApi.getLastLocation(
|
||||
googleApiClient);
|
||||
gMap.setMyLocationEnabled(true);
|
||||
|
||||
if (lastKnownLocation != null) {
|
||||
gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
|
||||
new LatLng(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude()), 15f)
|
||||
);
|
||||
|
||||
gMap.animateCamera(CameraUpdateFactory.zoomTo(15f));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onMapReady(GoogleMap googleMap) {
|
||||
gMap = googleMap;
|
||||
gMap.getUiSettings().setMyLocationButtonEnabled(true);
|
||||
updateLastLocation();
|
||||
setupMapOnCameraChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
|
||||
if (requestCode == REQUEST_PERMISSION_LOCATION) {
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
updateLastLocation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == 1) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
Place place = Autocomplete.getPlaceFromIntent(data);
|
||||
currentAddress.setText(place.getAddress());
|
||||
LatLng latLng = place.getLatLng();
|
||||
if (latLng != null) {
|
||||
gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
|
||||
new LatLng(latLng.latitude, latLng.longitude), 15f)
|
||||
);
|
||||
}
|
||||
} else if (resultCode == AutocompleteActivity.RESULT_ERROR) {
|
||||
Status status = Autocomplete.getStatusFromIntent(data);
|
||||
Log.i("TAG", Objects.requireNonNull(status.getStatusMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setupMapOnCameraChange() {
|
||||
gMap.setOnCameraIdleListener(new GoogleMap.OnCameraIdleListener() {
|
||||
@Override
|
||||
public void onCameraIdle() {
|
||||
LatLng center = gMap.getCameraPosition().target;
|
||||
fillAddress(currentAddress, center);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void fillAddress(final TextView textView, final LatLng latLng) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Geocoder geocoder = new Geocoder(PicklocationActivity.this, Locale.getDefault());
|
||||
final List<Address> addresses = geocoder.getFromLocation(latLng.latitude, latLng.longitude, 1);
|
||||
PicklocationActivity.this.runOnUiThread(new Runnable() {
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void run() {
|
||||
if (!addresses.isEmpty()) {
|
||||
addresses.size();
|
||||
String address = addresses.get(0).getAddressLine(0);
|
||||
textView.setText(address);
|
||||
} else {
|
||||
textView.setText("Tidak tersedia");
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnected(@Nullable Bundle bundle) {
|
||||
updateLastLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionSuspended(int i) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.Button;;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import id.ontime.customer.R;
|
||||
|
||||
|
||||
public class PpobActivity extends AppCompatActivity {
|
||||
|
||||
private Context context;
|
||||
Button pulsa, token, bpjs;
|
||||
TextView notif;
|
||||
ImageView backbtn, images;
|
||||
RelativeLayout rlnotif, rlprogress;
|
||||
String disableback;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_ppob);
|
||||
disableback = "false";
|
||||
backbtn = findViewById(R.id.back_btn);
|
||||
pulsa = findViewById(R.id.pulsa);
|
||||
token = findViewById(R.id.token);
|
||||
bpjs = findViewById(R.id.bpjs);
|
||||
rlnotif = findViewById(R.id.rlnotif);
|
||||
notif = findViewById(R.id.textnotif);
|
||||
rlprogress = findViewById(R.id.rlprogress);
|
||||
images = findViewById(R.id.imagebackground);
|
||||
|
||||
|
||||
pulsa.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(PpobActivity.this, TopUpPulsaActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
token.setOnClickListener(v -> {
|
||||
Intent i = new Intent(PpobActivity.this, TopUpPlnActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
|
||||
});
|
||||
|
||||
bpjs.setOnClickListener(v -> {
|
||||
Intent i = new Intent(PpobActivity.this, TopUpBpjsActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
|
||||
});
|
||||
|
||||
|
||||
backbtn.setOnClickListener(v -> finish());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.json.PrivacyRequestJson;
|
||||
import id.ontime.customer.json.PrivacyResponseJson;
|
||||
import id.ontime.customer.models.SettingsModel;
|
||||
import id.ontime.customer.utils.NetworkUtils;
|
||||
import id.ontime.customer.utils.api.ServiceGenerator;
|
||||
import id.ontime.customer.utils.api.service.UserService;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class PrivacyActivity extends AppCompatActivity {
|
||||
|
||||
WebView webView;
|
||||
ImageView backbtn;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_privacy);
|
||||
webView = findViewById(R.id.webView);
|
||||
backbtn = findViewById(R.id.back_btn);
|
||||
webView.setBackgroundColor(Color.TRANSPARENT);
|
||||
if (NetworkUtils.isConnected(PrivacyActivity.this)) {
|
||||
get();
|
||||
}
|
||||
backbtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void get() {
|
||||
PrivacyRequestJson request = new PrivacyRequestJson();
|
||||
|
||||
UserService service = ServiceGenerator.createService(UserService.class, "admin", "12345");
|
||||
service.privacy(request).enqueue(new Callback<PrivacyResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<PrivacyResponseJson> call, @NonNull Response<PrivacyResponseJson> response) {
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
if (Objects.requireNonNull(response.body()).getMessage().equalsIgnoreCase("found")) {
|
||||
SettingsModel model = response.body().getData().get(0);
|
||||
setResult(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<PrivacyResponseJson> call, @NonNull Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setResult(SettingsModel getprivacy) {
|
||||
|
||||
String mimeType = "text/html";
|
||||
String encoding = "utf-8";
|
||||
String htmlText = getprivacy.getPrivacy();
|
||||
String text = "<html dir=" + "><head>"
|
||||
+ "<style type=\"text/css\">@font-face {font-family: MyFont;src: url(\"file:///android_asset/fonts/Montserrat_Regular.ttf\")}body{font-family: MyFont;color: #000000;text-align:justify;line-height:1.2}"
|
||||
+ "</style></head>"
|
||||
+ "<body>"
|
||||
+ htmlText
|
||||
+ "</body></html>";
|
||||
|
||||
webView.loadDataWithBaseURL(null, text, mimeType, encoding, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem menuItem) {
|
||||
if (menuItem.getItemId() == android.R.id.home) {
|
||||
onBackPressed();
|
||||
} else {
|
||||
return super.onOptionsItemSelected(menuItem);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,98 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.item.PromoItem;
|
||||
import id.ontime.customer.json.PromoRequestJson;
|
||||
import id.ontime.customer.json.PromoResponseJson;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.utils.api.ServiceGenerator;
|
||||
import id.ontime.customer.utils.api.service.UserService;
|
||||
import com.facebook.shimmer.ShimmerFrameLayout;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class PromoActivity extends AppCompatActivity {
|
||||
|
||||
ShimmerFrameLayout shimmer;
|
||||
RecyclerView recycle;
|
||||
PromoItem promoItem;
|
||||
RelativeLayout rlnodata;
|
||||
ImageView backButton;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_promo);
|
||||
shimmer = findViewById(R.id.shimmer);
|
||||
recycle = findViewById(R.id.inboxlist);
|
||||
rlnodata = findViewById(R.id.rlnodata);
|
||||
backButton = findViewById(R.id.back_btn);
|
||||
recycle.setHasFixedSize(true);
|
||||
recycle.setNestedScrollingEnabled(false);
|
||||
recycle.setLayoutManager(new GridLayoutManager(this, 1));
|
||||
backButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
getData();
|
||||
}
|
||||
|
||||
private void shimmershow() {
|
||||
rlnodata.setVisibility(View.GONE);
|
||||
recycle.setVisibility(View.GONE);
|
||||
shimmer.setVisibility(View.VISIBLE);
|
||||
shimmer.startShimmerAnimation();
|
||||
}
|
||||
|
||||
private void shimmertutup() {
|
||||
|
||||
recycle.setVisibility(View.VISIBLE);
|
||||
shimmer.setVisibility(View.GONE);
|
||||
shimmer.stopShimmerAnimation();
|
||||
}
|
||||
|
||||
private void getData() {
|
||||
shimmershow();
|
||||
User loginUser = BaseApp.getInstance(this).getLoginUser();
|
||||
UserService service = ServiceGenerator.createService(UserService.class, loginUser.getEmail(), loginUser.getPassword());
|
||||
PromoRequestJson param = new PromoRequestJson();
|
||||
|
||||
service.listpromocode(param).enqueue(new Callback<PromoResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<PromoResponseJson> call, @NonNull Response<PromoResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
shimmertutup();
|
||||
if (Objects.requireNonNull(response.body()).getData().isEmpty()) {
|
||||
rlnodata.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
promoItem = new PromoItem(PromoActivity.this, response.body().getData(), R.layout.item_promo);
|
||||
recycle.setAdapter(promoItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull retrofit2.Call<PromoResponseJson> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.json.DetailRequestJson;
|
||||
import id.ontime.customer.json.DetailTransResponseJson;
|
||||
import id.ontime.customer.json.RateRequestJson;
|
||||
import id.ontime.customer.json.RateResponseJson;
|
||||
import id.ontime.customer.models.DriverModel;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.utils.PicassoTrustAll;
|
||||
import id.ontime.customer.utils.api.ServiceGenerator;
|
||||
import id.ontime.customer.utils.api.service.BookService;
|
||||
import id.ontime.customer.utils.api.service.UserService;
|
||||
import com.facebook.shimmer.ShimmerFrameLayout;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class RateActivity extends AppCompatActivity {
|
||||
|
||||
String iddriver, idtrans, response, submit;
|
||||
ImageView image;
|
||||
TextView nama;
|
||||
EditText comment;
|
||||
Button button;
|
||||
ShimmerFrameLayout shimmername;
|
||||
// Rating view removed with third-party dependency; rating is fixed to a default value.
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_rate);
|
||||
image = findViewById(R.id.image);
|
||||
nama = findViewById(R.id.namadriver);
|
||||
comment = findViewById(R.id.addComment);
|
||||
button = findViewById(R.id.submit);
|
||||
shimmername = findViewById(R.id.shimmername);
|
||||
Intent intent = getIntent();
|
||||
iddriver = intent.getStringExtra("id_driver");
|
||||
idtrans = intent.getStringExtra("id_transaksi");
|
||||
response = intent.getStringExtra("response");
|
||||
getData(idtrans, iddriver);
|
||||
submit = "true";
|
||||
shimmeractive();
|
||||
removeNotif();
|
||||
}
|
||||
|
||||
private void shimmeractive() {
|
||||
shimmername.startShimmerAnimation();
|
||||
}
|
||||
|
||||
private void shimmernonactive() {
|
||||
shimmername.setVisibility(View.GONE);
|
||||
image.setVisibility(View.VISIBLE);
|
||||
nama.setVisibility(View.VISIBLE);
|
||||
comment.setVisibility(View.VISIBLE);
|
||||
button.setVisibility(View.VISIBLE);
|
||||
shimmername.stopShimmerAnimation();
|
||||
}
|
||||
|
||||
private void getData(String idtrans, String iddriver) {
|
||||
User loginUser = BaseApp.getInstance(this).getLoginUser();
|
||||
BookService service = ServiceGenerator.createService(BookService.class, loginUser.getEmail(), loginUser.getPassword());
|
||||
DetailRequestJson param = new DetailRequestJson();
|
||||
param.setId(idtrans);
|
||||
param.setIdDriver(iddriver);
|
||||
service.detailtrans(param).enqueue(new Callback<DetailTransResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<DetailTransResponseJson> call, @NonNull Response<DetailTransResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
DriverModel driver = Objects.requireNonNull(response.body()).getDriver().get(0);
|
||||
parsedata(driver);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull retrofit2.Call<DetailTransResponseJson> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void parsedata(final DriverModel driver) {
|
||||
|
||||
PicassoTrustAll.getInstance(this)
|
||||
.load(Constants.IMAGESDRIVER + driver.getFoto())
|
||||
.placeholder(R.drawable.image_placeholder)
|
||||
.into(image);
|
||||
nama.setText(driver.getNamaDriver());
|
||||
final User userLogin = BaseApp.getInstance(this).getLoginUser();
|
||||
if (submit.equals("true")) {
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
RateRequestJson request = new RateRequestJson();
|
||||
request.id_transaksi = idtrans;
|
||||
request.id_pelanggan = userLogin.getId();
|
||||
request.id_driver = iddriver;
|
||||
request.rating = "5"; // default rating since rating widget has been removed
|
||||
request.catatan = comment.getText().toString();
|
||||
ratingUser(request);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
shimmernonactive();
|
||||
}
|
||||
|
||||
private void ratingUser(RateRequestJson request) {
|
||||
submit = "false";
|
||||
button.setText(getString(R.string.waiting_pleaseWait));
|
||||
button.setBackground(getResources().getDrawable(R.drawable.rounded_corners_button));
|
||||
|
||||
User loginUser = BaseApp.getInstance(RateActivity.this).getLoginUser();
|
||||
|
||||
UserService service = ServiceGenerator.createService(UserService.class, loginUser.getEmail(), loginUser.getPassword());
|
||||
service.rateDriver(request).enqueue(new Callback<RateResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<RateResponseJson> call, @NonNull Response<RateResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
if (Objects.requireNonNull(response.body()).mesage.equals("success")) {
|
||||
Intent i = new Intent(RateActivity.this, MainActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<RateResponseJson> call, @NonNull Throwable t) {
|
||||
t.printStackTrace();
|
||||
submit = "true";
|
||||
button.setText("Submit");
|
||||
button.setBackground(getResources().getDrawable(R.drawable.button_round_1));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void removeNotif() {
|
||||
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
Objects.requireNonNull(notificationManager).cancel(0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,967 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.Editable;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.method.HideReturnsTransformationMethod;
|
||||
import android.text.method.PasswordTransformationMethod;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.ViewFlipper;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.exifinterface.media.ExifInterface;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.json.RegisterRequestJson;
|
||||
import id.ontime.customer.json.RegisterResponseJson;
|
||||
import id.ontime.customer.models.FirebaseToken;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.panicbutton.api.LoginAPI;
|
||||
import id.ontime.customer.panicbutton.api.RegisterAPI;
|
||||
import id.ontime.customer.panicbutton.model.Value;
|
||||
import id.ontime.customer.utils.api.ServiceGenerator;
|
||||
import id.ontime.customer.utils.api.service.UserService;
|
||||
import com.google.android.gms.tasks.OnCompleteListener;
|
||||
import com.google.android.gms.tasks.Task;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.google.firebase.FirebaseException;
|
||||
import com.google.firebase.FirebaseTooManyRequestsException;
|
||||
import com.google.firebase.auth.AuthResult;
|
||||
import com.google.firebase.auth.FirebaseAuth;
|
||||
import com.google.firebase.auth.FirebaseAuthInvalidCredentialsException;
|
||||
import com.google.firebase.auth.FirebaseUser;
|
||||
import com.google.firebase.auth.PhoneAuthCredential;
|
||||
import com.google.firebase.auth.PhoneAuthProvider;
|
||||
import com.google.firebase.iid.FirebaseInstanceId;
|
||||
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog;
|
||||
import com.ybs.countrypicker.CountryPicker;
|
||||
import com.ybs.countrypicker.CountryPickerListener;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.realm.Realm;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public class RegisterActivity extends AppCompatActivity {
|
||||
|
||||
public static final int SIGNUP_ID = 110;
|
||||
public static final String USER_KEY = "UserKey";
|
||||
// public static final String URL = "http://peci.semestaterpadu.my.id/";
|
||||
ImageView foto, gantifoto, backbtn, backButtonverify, showPassword;
|
||||
EditText phone, nama, email, password, numOne, numTwo, numThree, numFour, numFive, numSix;
|
||||
TextView tanggal, countryCode, sendTo, textnotif, textnotif2, privacypolicy;
|
||||
Button submit, confirmButton;
|
||||
RelativeLayout rlnotif, rlprogress, rlnotif2;
|
||||
String phoneNumber;
|
||||
String idUser, namaUser, noHP, password2;
|
||||
FirebaseUser firebaseUser;
|
||||
FirebaseAuth mAuth;
|
||||
byte[] imageByteArray;
|
||||
Bitmap decoded;
|
||||
String dateview, disableback;
|
||||
ViewFlipper viewFlipper;
|
||||
String country_iso_code = "en";
|
||||
String verify, token;
|
||||
private SimpleDateFormat dateFormatter, dateFormatterview;
|
||||
private String phoneVerificationId;
|
||||
private PhoneAuthProvider.OnVerificationStateChangedCallbacks verificationCallbacks;
|
||||
private PhoneAuthProvider.ForceResendingToken resendToken;
|
||||
private FirebaseAuth fbAuth;
|
||||
private final int GALLERY = 1;
|
||||
private final int CAMERA = 2;
|
||||
private static final String IMAGE_DIRECTORY = "/Pictures";
|
||||
private BottomSheetDialog mBottomSheetDialog;
|
||||
private BottomSheetBehavior mBehavior;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_register);
|
||||
View bottom_sheet = findViewById(R.id.bottom_sheet);
|
||||
mBehavior = BottomSheetBehavior.from(bottom_sheet);
|
||||
try {
|
||||
fbAuth = FirebaseAuth.getInstance();
|
||||
mAuth = FirebaseAuth.getInstance();
|
||||
firebaseUser = mAuth.getCurrentUser();
|
||||
} catch (IllegalStateException e) {
|
||||
// Firebase not initialized or misconfigured; disable FirebaseAuth usage for this session.
|
||||
fbAuth = null;
|
||||
mAuth = null;
|
||||
firebaseUser = null;
|
||||
Log.e("RegisterActivity", "FirebaseAuth not available; continuing without phone auth", e);
|
||||
}
|
||||
foto = findViewById(R.id.foto);
|
||||
gantifoto = findViewById(R.id.editfoto);
|
||||
backbtn = findViewById(R.id.back_btn);
|
||||
phone = findViewById(R.id.phonenumber);
|
||||
nama = findViewById(R.id.nama);
|
||||
email = findViewById(R.id.email);
|
||||
password = findViewById(R.id.password);
|
||||
tanggal = findViewById(R.id.tanggal);
|
||||
submit = findViewById(R.id.submit);
|
||||
rlnotif = findViewById(R.id.rlnotif);
|
||||
textnotif = findViewById(R.id.textnotif);
|
||||
countryCode = findViewById(R.id.countrycode);
|
||||
viewFlipper = findViewById(R.id.viewflipper);
|
||||
backButtonverify = findViewById(R.id.back_btn_verify);
|
||||
rlprogress = findViewById(R.id.rlprogress);
|
||||
password = findViewById(R.id.password);
|
||||
showPassword = findViewById(R.id.iv_showPassword);
|
||||
rlnotif2 = findViewById(R.id.rlnotif2);
|
||||
textnotif2 = findViewById(R.id.textnotif2);
|
||||
confirmButton = findViewById(R.id.buttonconfirm);
|
||||
try {
|
||||
token = FirebaseInstanceId.getInstance().getToken();
|
||||
} catch (Exception e) {
|
||||
Log.e("RegisterActivity", "Failed to get FirebaseInstanceId token; continuing without token", e);
|
||||
token = null;
|
||||
}
|
||||
numOne = findViewById(R.id.numone);
|
||||
numTwo = findViewById(R.id.numtwo);
|
||||
numThree = findViewById(R.id.numthree);
|
||||
numFour = findViewById(R.id.numfour);
|
||||
numFive = findViewById(R.id.numfive);
|
||||
numSix = findViewById(R.id.numsix);
|
||||
sendTo = findViewById(R.id.sendtotxt);
|
||||
privacypolicy = findViewById(R.id.privacypolice);
|
||||
backbtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
foto.setOnClickListener(new View.OnClickListener() {
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
selectImage();
|
||||
}
|
||||
});
|
||||
gantifoto.setOnClickListener(new View.OnClickListener() {
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
selectImage();
|
||||
}
|
||||
});
|
||||
|
||||
String priv = getResources().getString(R.string.privacy);
|
||||
privacypolicy.setText(Html.fromHtml(priv));
|
||||
|
||||
showPassword.setImageResource(R.drawable.ic_visibility_eye);
|
||||
showPassword.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (password.getTransformationMethod().equals(HideReturnsTransformationMethod.getInstance())){
|
||||
password.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
||||
showPassword.setImageResource(R.drawable.ic_visibility_eye);
|
||||
} else {
|
||||
password.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
|
||||
showPassword.setImageResource(R.drawable.ic_visibility_offeye);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
countryCode.setOnClickListener(new View.OnClickListener() {
|
||||
@SuppressLint("WrongConstant")
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final CountryPicker picker = CountryPicker.newInstance("Select Country");
|
||||
picker.setListener(new CountryPickerListener() {
|
||||
@Override
|
||||
public void onSelectCountry(String name, String code, String dialCode, int flagDrawableResID) {
|
||||
countryCode.setText(dialCode);
|
||||
picker.dismiss();
|
||||
country_iso_code = code;
|
||||
}
|
||||
});
|
||||
picker.setStyle(R.style.countrypicker_style, R.style.countrypicker_style);
|
||||
picker.show(getSupportFragmentManager(), "Select Country");
|
||||
}
|
||||
});
|
||||
dateFormatter = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
|
||||
dateFormatterview = new SimpleDateFormat("dd MMM yyyy", Locale.US);
|
||||
|
||||
privacypolicy.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(RegisterActivity.this, PrivacyActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
submit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final String emailPattern = "[a-zA-Z0-9._-]+@[a-z]+\\.+[a-z]+";
|
||||
final String emailvalidate = email.getText().toString();
|
||||
|
||||
if (imageByteArray == null) {
|
||||
notif("kamu lupa memasukan photo!");
|
||||
} else if (TextUtils.isEmpty(phone.getText().toString())) {
|
||||
|
||||
notif(getString(R.string.phoneempty));
|
||||
|
||||
} else if (TextUtils.isEmpty(nama.getText().toString())) {
|
||||
|
||||
notif("nama tidak boleh kosong");
|
||||
|
||||
} else if (TextUtils.isEmpty(email.getText().toString())) {
|
||||
|
||||
notif(getString(R.string.emailempty));
|
||||
|
||||
} else if (TextUtils.isEmpty(tanggal.getText().toString())) {
|
||||
|
||||
notif("tanggal lahir tidak boleh kosong!");
|
||||
|
||||
} else if (!emailvalidate.matches(emailPattern)) {
|
||||
|
||||
notif("format email salah!");
|
||||
|
||||
} else if (TextUtils.isEmpty(password.getText().toString())) {
|
||||
|
||||
notif(getString(R.string.passempty));
|
||||
|
||||
} else {
|
||||
|
||||
upload("true");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
confirmButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
verifyCode(viewFlipper);
|
||||
}
|
||||
});
|
||||
backButtonverify.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
tanggal.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showTanggal();
|
||||
}
|
||||
});
|
||||
disableback = "false";
|
||||
codenumber();
|
||||
verify = "false";
|
||||
|
||||
}
|
||||
|
||||
private void showTanggal() {
|
||||
|
||||
DatePickerDialog datePicker = DatePickerDialog.newInstance(
|
||||
new DatePickerDialog.OnDateSetListener() {
|
||||
@Override
|
||||
public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.YEAR, year);
|
||||
calendar.set(Calendar.MONTH, monthOfYear);
|
||||
calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
|
||||
long date_ship_millis = calendar.getTimeInMillis();
|
||||
tanggal.setText(dateFormatterview.format(date_ship_millis));
|
||||
dateview = dateFormatter.format(date_ship_millis);
|
||||
}
|
||||
}
|
||||
);
|
||||
datePicker.setThemeDark(false);
|
||||
datePicker.setAccentColor(getResources().getColor(R.color.colorgradient));
|
||||
datePicker.show(getFragmentManager(), "Datepickerdialog");
|
||||
}
|
||||
|
||||
|
||||
public void progressshow() {
|
||||
rlprogress.setVisibility(View.VISIBLE);
|
||||
disableback = "true";
|
||||
}
|
||||
|
||||
public void progresshide() {
|
||||
rlprogress.setVisibility(View.GONE);
|
||||
disableback = "false";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (!disableback.equals("true")) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
public void Nextbtn(View view) {
|
||||
phoneNumber = countryCode.getText().toString() + phone.getText().toString();
|
||||
String ccode = countryCode.getText().toString();
|
||||
|
||||
if ((!TextUtils.isEmpty(phoneNumber) && !TextUtils.isEmpty(ccode)) && phoneNumber.length() > 5) {
|
||||
progressshow();
|
||||
Send_Number_tofirebase(phoneNumber);
|
||||
|
||||
} else {
|
||||
notif("Silakan masukkan no hp dengan benar");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void notif(String text) {
|
||||
rlnotif.setVisibility(View.VISIBLE);
|
||||
textnotif.setText(text);
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
rlnotif.setVisibility(View.GONE);
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* uploadfoto-------------start.
|
||||
*/
|
||||
private boolean check_ReadStoragepermission() {
|
||||
if (ContextCompat.checkSelfPermission(this.getApplicationContext(),
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
== PackageManager.PERMISSION_GRANTED) {
|
||||
return true;
|
||||
} else {
|
||||
try {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
|
||||
Constants.permission_Read_data);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
private void selectImage() {
|
||||
boolean pick = true;
|
||||
if (pick) {
|
||||
if (!checkCameraPermission()) {
|
||||
requestCameraPermission();
|
||||
} else PickImage();
|
||||
} else {
|
||||
if (!checkStoragePermission()) {
|
||||
requestStoragePermission();
|
||||
} else PickImage();
|
||||
}
|
||||
|
||||
/* if (check_ReadStoragepermission()) {
|
||||
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
startActivityForResult(intent, 2);
|
||||
} */
|
||||
}
|
||||
|
||||
private void PickImage() {
|
||||
|
||||
if (mBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED) {
|
||||
mBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
}
|
||||
|
||||
@SuppressLint("InflateParams") final View mDialog = getLayoutInflater().inflate(R.layout.sheet_upload, null);
|
||||
CardView Galery = mDialog.findViewById(R.id.ll_gallery_intent);
|
||||
CardView Camera = mDialog.findViewById(R.id.ll_camera_intent);
|
||||
|
||||
Galery.setOnClickListener(v -> choosePhotoFromGallery());
|
||||
Camera.setOnClickListener(v -> takePhotoFromCamera());
|
||||
|
||||
mBottomSheetDialog = new BottomSheetDialog(this);
|
||||
mBottomSheetDialog.setContentView(mDialog);
|
||||
mBottomSheetDialog.show();
|
||||
// mBottomSheetDialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
mBottomSheetDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
mBottomSheetDialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation;
|
||||
mBottomSheetDialog.getWindow().setGravity(Gravity.BOTTOM);
|
||||
|
||||
|
||||
mBottomSheetDialog.setOnDismissListener(dialog -> mBottomSheetDialog = null);
|
||||
|
||||
}
|
||||
|
||||
public void choosePhotoFromGallery() {
|
||||
Intent galleryIntent = new Intent(Intent.ACTION_PICK,
|
||||
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
|
||||
startActivityForResult(galleryIntent, GALLERY);
|
||||
mBottomSheetDialog.dismiss();
|
||||
}
|
||||
|
||||
private void takePhotoFromCamera() {
|
||||
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
startActivityForResult(intent, CAMERA);
|
||||
mBottomSheetDialog.dismiss();
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
private void requestStoragePermission() {
|
||||
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 100);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
private void requestCameraPermission() {
|
||||
requestPermissions(new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 100);
|
||||
}
|
||||
|
||||
private boolean checkStoragePermission() {
|
||||
if (ContextCompat.checkSelfPermission(this.getApplicationContext(),
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
== PackageManager.PERMISSION_GRANTED) {
|
||||
return true;
|
||||
} else {
|
||||
try {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
|
||||
Constants.permission_Read_data);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkCameraPermission() {
|
||||
boolean res1 = ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED;
|
||||
boolean res2 = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
|
||||
return res1 && res2;
|
||||
}
|
||||
|
||||
public String getPath(Uri uri) {
|
||||
String result = null;
|
||||
String[] proj = {MediaStore.Images.Media.DATA};
|
||||
Cursor cursor = this.getContentResolver().query(uri, proj, null, null, null);
|
||||
if (cursor != null) {
|
||||
if (cursor.moveToFirst()) {
|
||||
int column_index = cursor.getColumnIndexOrThrow(proj[0]);
|
||||
result = cursor.getString(column_index);
|
||||
}
|
||||
cursor.close();
|
||||
}
|
||||
if (result == null) {
|
||||
result = "Not found";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
if (resultCode == RESULT_CANCELED) {
|
||||
return;
|
||||
}
|
||||
Uri contentURI = data.getData();
|
||||
if (requestCode == GALLERY) {
|
||||
if (data != null) {
|
||||
|
||||
try {
|
||||
Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), contentURI);
|
||||
String path = saveImage(bitmap);
|
||||
foto.setImageBitmap(bitmap);
|
||||
// Toast.makeText(this, "Image Saved!", Toast.LENGTH_SHORT).show();
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(this, "Failed!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
} else if (requestCode == CAMERA) {
|
||||
Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
|
||||
foto.setImageBitmap(thumbnail);
|
||||
saveImage(thumbnail);
|
||||
// Toast.makeText(this, "Image Saved!", Toast.LENGTH_SHORT).show();
|
||||
/*Intent i = new Intent(this,MainActivity.class);
|
||||
i.putExtra("imagepath", contentURI.toString());
|
||||
startActivity(i);
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String saveImage(Bitmap myBitmap) {
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
myBitmap.compress(Bitmap.CompressFormat.JPEG, 90, bytes);
|
||||
imageByteArray = bytes.toByteArray();
|
||||
decoded = BitmapFactory.decodeStream(new ByteArrayInputStream(bytes.toByteArray()));
|
||||
|
||||
/* File wallpaperDirectory = new File(
|
||||
Environment.getExternalStorageDirectory() + IMAGE_DIRECTORY);
|
||||
// have the object build the directory structure, if needed.
|
||||
if (!wallpaperDirectory.exists()) {
|
||||
wallpaperDirectory.mkdirs();
|
||||
}
|
||||
|
||||
try {
|
||||
File f = new File(wallpaperDirectory, Calendar.getInstance()
|
||||
.getTimeInMillis() + ".jpg");
|
||||
f.createNewFile();
|
||||
FileOutputStream fo = new FileOutputStream(f);
|
||||
fo.write(bytes.toByteArray());
|
||||
MediaScannerConnection.scanFile(this,
|
||||
new String[]{f.getPath()},
|
||||
new String[]{"image/jpeg"}, null);
|
||||
fo.close();
|
||||
id.go.purworejokab.newsindolalak.utils.Log.d("TAG", "File Saved::--->" + f.getAbsolutePath());
|
||||
|
||||
return f.getAbsolutePath();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
*/
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
public String getStringImage(Bitmap bmp) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
if (bmp != null) {
|
||||
bmp.compress(Bitmap.CompressFormat.JPEG, 20, baos);
|
||||
imageByteArray = baos.toByteArray();
|
||||
return Base64.encodeToString(imageByteArray, Base64.DEFAULT);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* uploadfoto-------------end.
|
||||
*/
|
||||
|
||||
//sendcode-----------------------
|
||||
public void notif2(String text) {
|
||||
rlnotif2.setVisibility(View.VISIBLE);
|
||||
textnotif2.setText(text);
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
rlnotif2.setVisibility(View.GONE);
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
public void Send_Number_tofirebase(String phoneNumber) {
|
||||
if (fbAuth == null) {
|
||||
progresshide();
|
||||
notif2(getString(R.string.text_noInternet));
|
||||
return;
|
||||
}
|
||||
|
||||
setUpVerificatonCallbacks();
|
||||
PhoneAuthProvider.getInstance().verifyPhoneNumber(
|
||||
phoneNumber,
|
||||
120,
|
||||
TimeUnit.SECONDS,
|
||||
this,
|
||||
verificationCallbacks);
|
||||
}
|
||||
|
||||
private void setUpVerificatonCallbacks() {
|
||||
verificationCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
|
||||
@Override
|
||||
public void onVerificationCompleted(@NonNull PhoneAuthCredential credential) {
|
||||
signInWithPhoneAuthCredential(credential);
|
||||
verify = "true";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVerificationFailed(@NonNull FirebaseException e) {
|
||||
progresshide();
|
||||
Log.d("respon", e.toString());
|
||||
notif2("kode sms salah!");
|
||||
if (e instanceof FirebaseAuthInvalidCredentialsException) {
|
||||
notif2("kode sms salah!!");
|
||||
} else if (e instanceof FirebaseTooManyRequestsException) {
|
||||
notif2("Terlalu banyak permintaan, gunakan nomor hp lain!");
|
||||
notif("Terlalu banyak permintaan, gunakan nomor hp lain!");
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onCodeSent(@NonNull String verificationId, @NonNull PhoneAuthProvider.ForceResendingToken token) {
|
||||
phoneVerificationId = verificationId;
|
||||
resendToken = token;
|
||||
sendTo.setText("Dikirim ke ( " + phoneNumber + " )");
|
||||
progresshide();
|
||||
viewFlipper.setInAnimation(RegisterActivity.this, R.anim.from_right);
|
||||
viewFlipper.setOutAnimation(RegisterActivity.this, R.anim.to_left);
|
||||
viewFlipper.setDisplayedChild(1);
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public void verifyCode(View view) {
|
||||
String code = "" + numOne.getText().toString() + numTwo.getText().toString() + numThree.getText().toString() + numFour.getText().toString() + numFive.getText().toString() + numSix.getText().toString();
|
||||
if (!code.equals("")) {
|
||||
progressshow();
|
||||
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(phoneVerificationId, code);
|
||||
signInWithPhoneAuthCredential(credential);
|
||||
|
||||
} else {
|
||||
notif2("Masukan kode sms!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void signInWithPhoneAuthCredential(PhoneAuthCredential credential) {
|
||||
if (fbAuth == null) {
|
||||
progresshide();
|
||||
notif2(getString(R.string.text_noInternet));
|
||||
return;
|
||||
}
|
||||
|
||||
fbAuth.signInWithCredential(credential)
|
||||
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
|
||||
@Override
|
||||
public void onComplete(@NonNull Task<AuthResult> task) {
|
||||
if (task.isSuccessful()) {
|
||||
upload("false");
|
||||
|
||||
} else {
|
||||
if (task.getException() instanceof
|
||||
FirebaseAuthInvalidCredentialsException) {
|
||||
progresshide();
|
||||
notif2("kode sms salah!");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void resendCode(View view) {
|
||||
|
||||
if (fbAuth == null) {
|
||||
progresshide();
|
||||
notif2(getString(R.string.text_noInternet));
|
||||
return;
|
||||
}
|
||||
|
||||
setUpVerificatonCallbacks();
|
||||
PhoneAuthProvider.getInstance().verifyPhoneNumber(
|
||||
phoneNumber,
|
||||
120,
|
||||
TimeUnit.SECONDS,
|
||||
this,
|
||||
verificationCallbacks,
|
||||
resendToken);
|
||||
}
|
||||
|
||||
public void codenumber() {
|
||||
|
||||
numOne.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
if (numOne.getText().toString().length() == 0) {
|
||||
numTwo.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
numTwo.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
if (numTwo.getText().toString().length() == 0) {
|
||||
numThree.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
numThree.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
if (numThree.getText().toString().length() == 0) {
|
||||
numFour.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
numFour.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
if (numFour.getText().toString().length() == 0) {
|
||||
numFive.requestFocus();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
numFive.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
if (numFive.getText().toString().length() == 0) {
|
||||
numSix.requestFocus();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void upload(final String check) {
|
||||
progressshow();
|
||||
RegisterRequestJson request = new RegisterRequestJson();
|
||||
request.setFullNama(nama.getText().toString());
|
||||
request.setEmail(email.getText().toString());
|
||||
request.setPassword(password.getText().toString());
|
||||
request.setNoTelepon(countryCode.getText().toString().replace("+", "") + phone.getText().toString());
|
||||
request.setPhone(phone.getText().toString());
|
||||
request.setTglLahir(dateview);
|
||||
request.setFotopelanggan(getStringImage(decoded));
|
||||
request.setCountrycode(countryCode.getText().toString());
|
||||
request.setChecked(check);
|
||||
|
||||
try {
|
||||
FirebaseInstanceId token = FirebaseInstanceId.getInstance();
|
||||
request.setToken(token.getToken());
|
||||
} catch (Exception e) {
|
||||
Log.e("RegisterActivity", "Failed to get FirebaseInstanceId token; continuing without token", e);
|
||||
request.setToken(null);
|
||||
}
|
||||
|
||||
UserService service = ServiceGenerator.createService(UserService.class, request.getEmail(), request.getPassword());
|
||||
service.register(request).enqueue(new Callback<RegisterResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<RegisterResponseJson> call, @NonNull Response<RegisterResponseJson> response) {
|
||||
progresshide();
|
||||
if (response.isSuccessful()) {
|
||||
if (Objects.requireNonNull(response.body()).getMessage().equalsIgnoreCase("next")) {
|
||||
Nextbtn(viewFlipper);
|
||||
|
||||
} else if (response.body().getMessage().equalsIgnoreCase("success")) {
|
||||
|
||||
User user = response.body().getData().get(0);
|
||||
saveUser(user);
|
||||
registerPanic();
|
||||
Intent intent = new Intent(RegisterActivity.this, MainActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
|
||||
} else {
|
||||
notif(response.body().getMessage());
|
||||
}
|
||||
} else {
|
||||
notif("error");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<RegisterResponseJson> call, @NonNull Throwable t) {
|
||||
progresshide();
|
||||
t.printStackTrace();
|
||||
notif("error!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void saveUser(User user) {
|
||||
Realm realm = Realm.getDefaultInstance();
|
||||
realm.beginTransaction();
|
||||
realm.delete(User.class);
|
||||
realm.copyToRealm(user);
|
||||
realm.commitTransaction();
|
||||
BaseApp.getInstance(RegisterActivity.this).setLoginUser(user);
|
||||
}
|
||||
|
||||
private void registerPanic(){
|
||||
User loginUser = BaseApp.getInstance(RegisterActivity.this).getLoginUser();
|
||||
idUser = email.getText().toString();
|
||||
namaUser = nama.getText().toString();
|
||||
noHP = countryCode.getText().toString().replace("+", "") + phone.getText().toString();
|
||||
password2 = loginUser.getPassword();
|
||||
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl(Constants.URL)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.build();
|
||||
RegisterAPI registerAPI = retrofit.create(RegisterAPI.class);
|
||||
Call<Value> call =registerAPI.register(idUser,namaUser,noHP,password2);
|
||||
call.enqueue(new Callback<Value>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Value> call, @NonNull Response<Value> response) {
|
||||
// if (Objects.requireNonNull(response.body()).getMessage().equalsIgnoreCase("success")){
|
||||
login();
|
||||
// } else {
|
||||
// notif(response.body().getMessage());
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Value> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void login(){
|
||||
User loginUser = BaseApp.getInstance(RegisterActivity.this).getLoginUser();
|
||||
// idUser = email.getText().toString();
|
||||
idUser = loginUser.getEmail();
|
||||
password2 = loginUser.getPassword();
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl(Constants.URL)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.build();
|
||||
LoginAPI loginAPI = retrofit.create(LoginAPI.class);
|
||||
Call<Value> call = loginAPI.login(idUser, password2);
|
||||
call.enqueue(new Callback<Value>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Value> call, @NonNull Response<Value> response) {
|
||||
String value = response.body().getValue();
|
||||
String message = response.body().getMessage();
|
||||
if (value.equals("1")) {
|
||||
gotoMainActivity();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Value> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void gotoMainActivity(){
|
||||
SharedPreferences sharedPreferences = PreferenceManager.
|
||||
getDefaultSharedPreferences(getApplicationContext());
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString("idUser", idUser);
|
||||
editor.putString("status", "Logged In");
|
||||
editor.apply();
|
||||
Intent intent = new Intent(RegisterActivity.this,
|
||||
MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
|
||||
public void onMessageEvent(FirebaseToken response) {
|
||||
Realm realm = Realm.getDefaultInstance();
|
||||
realm.beginTransaction();
|
||||
realm.delete(FirebaseToken.class);
|
||||
realm.copyToRealm(response);
|
||||
realm.commitTransaction();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,774 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.gmap.directions.Directions;
|
||||
import id.ontime.customer.gmap.directions.Route;
|
||||
import id.ontime.customer.json.GetNearRideCarRequestJson;
|
||||
import id.ontime.customer.json.GetNearRideCarResponseJson;
|
||||
import id.ontime.customer.models.DriverModel;
|
||||
import id.ontime.customer.models.FiturModel;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.utils.PicassoTrustAll;
|
||||
import id.ontime.customer.utils.api.MapDirectionAPI;
|
||||
import id.ontime.customer.utils.api.ServiceGenerator;
|
||||
import id.ontime.customer.utils.api.service.BookService;
|
||||
import com.google.android.gms.common.ConnectionResult;
|
||||
import com.google.android.gms.common.api.GoogleApiClient;
|
||||
import com.google.android.gms.common.api.Status;
|
||||
import com.google.android.gms.location.LocationServices;
|
||||
import com.google.android.gms.maps.CameraUpdateFactory;
|
||||
import com.google.android.gms.maps.GoogleMap;
|
||||
import com.google.android.gms.maps.OnMapReadyCallback;
|
||||
import com.google.android.gms.maps.SupportMapFragment;
|
||||
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.google.android.gms.maps.model.MapStyleOptions;
|
||||
import com.google.android.gms.maps.model.Marker;
|
||||
import com.google.android.gms.maps.model.MarkerOptions;
|
||||
import com.google.android.gms.maps.model.Polyline;
|
||||
import com.google.android.gms.maps.model.PolylineOptions;
|
||||
import com.google.android.libraries.places.api.Places;
|
||||
import com.google.android.libraries.places.api.model.Place;
|
||||
import com.google.android.libraries.places.widget.Autocomplete;
|
||||
import com.google.android.libraries.places.widget.AutocompleteActivity;
|
||||
import com.google.android.libraries.places.widget.model.AutocompleteActivityMode;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import io.realm.Realm;
|
||||
import io.realm.RealmResults;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
|
||||
public class SendActivity extends AppCompatActivity
|
||||
implements OnMapReadyCallback, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
|
||||
public static final String FITUR_KEY = "FiturKey";
|
||||
private static final String TAG = "RideCarActivity";
|
||||
private static final int REQUEST_PERMISSION_LOCATION = 991;
|
||||
String ICONFITUR;
|
||||
LinearLayout setPickUpContainer;
|
||||
LinearLayout setDestinationContainer;
|
||||
Button setPickUpButton;
|
||||
Button setDestinationButton;
|
||||
TextView pickUpText;
|
||||
LinearLayout bottomsheet;
|
||||
TextView destinationText;
|
||||
Button orderButton;
|
||||
ImageView icon;
|
||||
TextView layanan;
|
||||
TextView layanandesk;
|
||||
ImageView backbtn;
|
||||
RelativeLayout rlprogress;
|
||||
RelativeLayout rlnotif;
|
||||
TextView textnotif;
|
||||
TextView textprogress;
|
||||
String fitur, getbiaya, biayaminimum, biayaakhir;
|
||||
int fiturId;
|
||||
long maksimum;
|
||||
private GoogleMap gMap;
|
||||
private GoogleApiClient googleApiClient;
|
||||
private Location lastKnownLocation;
|
||||
private LatLng pickUpLatLang;
|
||||
private LatLng destinationLatLang;
|
||||
private Polyline directionLine;
|
||||
private Marker pickUpMarker;
|
||||
private Marker destinationMarker;
|
||||
private ArrayList<DriverModel> driverAvailable;
|
||||
private List<Marker> driverMarkers;
|
||||
private Realm realm;
|
||||
private FiturModel designedFitur;
|
||||
private double jarak;
|
||||
private boolean isMapReady = false;
|
||||
private String timeDistance, icondrver;
|
||||
private okhttp3.Callback updateRouteCallback = new okhttp3.Callback() {
|
||||
@Override
|
||||
public void onFailure(@NonNull okhttp3.Call call, @NonNull IOException e) {
|
||||
SendActivity.this.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
rlprogress.setVisibility(View.GONE);
|
||||
setDestinationContainer.setVisibility(View.VISIBLE);
|
||||
notif("Kesalahan koneksi, pilih tujuan lagi.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull okhttp3.Call call, okhttp3.Response response) throws IOException {
|
||||
if (response.isSuccessful()) {
|
||||
final String json = Objects.requireNonNull(response.body()).string();
|
||||
final String errorMsg = MapDirectionAPI.getDirectionErrorMessage(json);
|
||||
if (errorMsg != null) {
|
||||
SendActivity.this.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
rlprogress.setVisibility(View.GONE);
|
||||
setDestinationContainer.setVisibility(View.VISIBLE);
|
||||
notif(errorMsg);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
final long distance = MapDirectionAPI.getDistance(SendActivity.this, json);
|
||||
final String time = MapDirectionAPI.getTimeDistance(SendActivity.this, json);
|
||||
if (distance >= 0) {
|
||||
SendActivity.this.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
String format = String.format(Locale.US, "%.0f", (double) distance / 1000f);
|
||||
long dist = Long.parseLong(format);
|
||||
if (dist < maksimum) {
|
||||
rlprogress.setVisibility(View.GONE);
|
||||
updateLineDestination(json);
|
||||
updateDistance(distance);
|
||||
timeDistance = time;
|
||||
} else {
|
||||
orderButton.setEnabled(false);
|
||||
orderButton.setBackground(getResources().getDrawable(R.drawable.rounded_corners_button));
|
||||
setDestinationContainer.setVisibility(View.VISIBLE);
|
||||
rlprogress.setVisibility(View.GONE);
|
||||
notif("Tujuan destinasi terlalu jauh!");
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
SendActivity.this.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
rlprogress.setVisibility(View.GONE);
|
||||
setDestinationContainer.setVisibility(View.VISIBLE);
|
||||
notif("Gagal memuat rute, pilih tujuan lagi.");
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
SendActivity.this.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
rlprogress.setVisibility(View.GONE);
|
||||
setDestinationContainer.setVisibility(View.VISIBLE);
|
||||
notif("Gagal memuat rute, coba lagi.");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_send);
|
||||
// Manual view binding (ButterKnife removed)
|
||||
setPickUpContainer = findViewById(R.id.pickUpContainer);
|
||||
setDestinationContainer = findViewById(R.id.destinationContainer);
|
||||
setPickUpButton = findViewById(R.id.pickUpButton);
|
||||
setDestinationButton = findViewById(R.id.destinationButton);
|
||||
pickUpText = findViewById(R.id.pickUpText);
|
||||
bottomsheet = findViewById(R.id.bottom_sheet);
|
||||
destinationText = findViewById(R.id.destinationText);
|
||||
orderButton = findViewById(R.id.order);
|
||||
icon = findViewById(R.id.image);
|
||||
layanan = findViewById(R.id.layanan);
|
||||
layanandesk = findViewById(R.id.layanandes);
|
||||
backbtn = findViewById(R.id.back_btn);
|
||||
rlprogress = findViewById(R.id.rlprogress);
|
||||
rlnotif = findViewById(R.id.rlnotif);
|
||||
textnotif = findViewById(R.id.textnotif);
|
||||
textprogress = findViewById(R.id.textprogress);
|
||||
driverAvailable = new ArrayList<>();
|
||||
BottomSheetBehavior behavior = BottomSheetBehavior.from(bottomsheet);
|
||||
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||
Places.initialize(getApplicationContext(), getString(R.string.google_maps_key));
|
||||
|
||||
if (!Places.isInitialized()) {
|
||||
Places.initialize(getApplicationContext(), getString(R.string.google_maps_key));
|
||||
}
|
||||
|
||||
setPickUpContainer.setVisibility(View.VISIBLE);
|
||||
setDestinationContainer.setVisibility(View.GONE);
|
||||
|
||||
setPickUpButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
onPickUp();
|
||||
}
|
||||
});
|
||||
|
||||
setDestinationButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
onDestination();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
backbtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
pickUpText.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
setPickUpContainer.setVisibility(View.VISIBLE);
|
||||
setDestinationContainer.setVisibility(View.GONE);
|
||||
openAutocompleteActivity(1);
|
||||
}
|
||||
});
|
||||
|
||||
destinationText.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
setDestinationContainer.setVisibility(View.VISIBLE);
|
||||
setPickUpContainer.setVisibility(View.GONE);
|
||||
openAutocompleteActivity(2);
|
||||
}
|
||||
});
|
||||
|
||||
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
|
||||
.findFragmentById(R.id.mapView);
|
||||
Objects.requireNonNull(mapFragment).getMapAsync(this);
|
||||
|
||||
driverAvailable = new ArrayList<>();
|
||||
driverMarkers = new ArrayList<>();
|
||||
|
||||
if (googleApiClient == null) {
|
||||
googleApiClient = new GoogleApiClient.Builder(this)
|
||||
.addConnectionCallbacks(this)
|
||||
.addOnConnectionFailedListener(this)
|
||||
.addApi(LocationServices.API)
|
||||
.build();
|
||||
}
|
||||
|
||||
realm = Realm.getDefaultInstance();
|
||||
|
||||
Intent intent = getIntent();
|
||||
fiturId = intent.getIntExtra(FITUR_KEY, -1);
|
||||
ICONFITUR = intent.getStringExtra("icon");
|
||||
Log.e("FITUR_ID", fiturId + "");
|
||||
if (fiturId != -1)
|
||||
designedFitur = realm.where(FiturModel.class).equalTo("idFitur", fiturId).findFirst();
|
||||
|
||||
RealmResults<FiturModel> fiturs = realm.where(FiturModel.class).findAll();
|
||||
|
||||
for (FiturModel fitur : fiturs) {
|
||||
Log.e("ID_FITUR", fitur.getIdFitur() + " " + fitur.getFitur() + " " + fitur.getBiayaAkhir() + " " + ICONFITUR);
|
||||
}
|
||||
fitur = String.valueOf(designedFitur.getIdFitur());
|
||||
getbiaya = String.valueOf(designedFitur.getBiaya());
|
||||
biayaminimum = String.valueOf(designedFitur.getBiaya_minimum());
|
||||
biayaakhir = String.valueOf(designedFitur.getBiayaAkhir());
|
||||
icondrver = designedFitur.getIcon_driver();
|
||||
maksimum = Long.parseLong(designedFitur.getMaksimumdist());
|
||||
|
||||
Log.e("biaya", getbiaya);
|
||||
|
||||
updateFitur();
|
||||
|
||||
PicassoTrustAll.getInstance(this)
|
||||
.load(Constants.IMAGESFITUR + ICONFITUR)
|
||||
.placeholder(R.drawable.logo)
|
||||
.resize(100, 100)
|
||||
.into(icon);
|
||||
|
||||
layanan.setText(designedFitur.getFitur());
|
||||
layanandesk.setText(designedFitur.getKeterangan());
|
||||
orderButton.setBackground(getResources().getDrawable(R.drawable.rounded_corners_button));
|
||||
}
|
||||
|
||||
public void notif(String text) {
|
||||
rlnotif.setVisibility(View.VISIBLE);
|
||||
textnotif.setText(text);
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
rlnotif.setVisibility(View.GONE);
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
private void openAutocompleteActivity(int request_code) {
|
||||
List<Place.Field> fields = Arrays.asList(Place.Field.ID, Place.Field.ADDRESS, Place.Field.LAT_LNG);
|
||||
Intent intent = new Autocomplete.IntentBuilder(
|
||||
AutocompleteActivityMode.FULLSCREEN, fields)
|
||||
.build(this);
|
||||
startActivityForResult(intent, request_code);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == 1) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
Place place = Autocomplete.getPlaceFromIntent(data);
|
||||
pickUpText.setText(place.getAddress());
|
||||
LatLng latLng = place.getLatLng();
|
||||
if (latLng != null) {
|
||||
gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
|
||||
new LatLng(latLng.latitude, latLng.longitude), 15f)
|
||||
);
|
||||
onPickUp();
|
||||
}
|
||||
} else if (resultCode == AutocompleteActivity.RESULT_ERROR) {
|
||||
Status status = Autocomplete.getStatusFromIntent(data);
|
||||
Log.i(TAG, Objects.requireNonNull(status.getStatusMessage()));
|
||||
}
|
||||
}
|
||||
if (requestCode == 2) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
Place place = Autocomplete.getPlaceFromIntent(data);
|
||||
destinationText.setText(place.getAddress());
|
||||
LatLng latLng = place.getLatLng();
|
||||
if (latLng != null) {
|
||||
gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
|
||||
new LatLng(latLng.latitude, latLng.longitude), 15f)
|
||||
);
|
||||
onDestination();
|
||||
}
|
||||
} else if (resultCode == AutocompleteActivity.RESULT_ERROR) {
|
||||
Status status = Autocomplete.getStatusFromIntent(data);
|
||||
Log.i(TAG, Objects.requireNonNull(status.getStatusMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
|
||||
if (requestCode == REQUEST_PERMISSION_LOCATION) {
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
updateLastLocation(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnected(@Nullable Bundle bundle) {
|
||||
updateLastLocation(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionSuspended(int i) {
|
||||
updateLastLocation(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
|
||||
updateLastLocation(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapReady(GoogleMap googleMap) {
|
||||
gMap = googleMap;
|
||||
gMap.getUiSettings().setMyLocationButtonEnabled(true);
|
||||
gMap.getUiSettings().setMapToolbarEnabled(true);
|
||||
try {
|
||||
boolean success = googleMap.setMapStyle(
|
||||
MapStyleOptions.loadRawResourceStyle(
|
||||
this, R.raw.style_json));
|
||||
|
||||
if (!success) {
|
||||
Log.e(TAG, "Style parsing failed.");
|
||||
}
|
||||
} catch (Resources.NotFoundException e) {
|
||||
Log.e(TAG, "Can't find style. Error: ", e);
|
||||
}
|
||||
|
||||
isMapReady = true;
|
||||
|
||||
updateLastLocation(true);
|
||||
}
|
||||
|
||||
private void updateLastLocation(boolean move) {
|
||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_PERMISSION_LOCATION);
|
||||
return;
|
||||
}
|
||||
if (pickUpLatLang != null && destinationLatLang != null && orderButton != null && orderButton.getVisibility() == View.VISIBLE) {
|
||||
return;
|
||||
}
|
||||
lastKnownLocation = LocationServices.FusedLocationApi.getLastLocation(
|
||||
googleApiClient);
|
||||
gMap.setMyLocationEnabled(true);
|
||||
|
||||
if (lastKnownLocation != null) {
|
||||
if (move) {
|
||||
gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
|
||||
new LatLng(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude()), 15f)
|
||||
);
|
||||
|
||||
gMap.animateCamera(CameraUpdateFactory.zoomTo(15f));
|
||||
}
|
||||
|
||||
fetchNearDriver(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void updateFitur() {
|
||||
if (driverAvailable != null) {
|
||||
driverAvailable.clear();
|
||||
}
|
||||
if (driverMarkers != null) {
|
||||
for (Marker m : driverMarkers) {
|
||||
m.remove();
|
||||
}
|
||||
driverMarkers.clear();
|
||||
}
|
||||
if (isMapReady) updateLastLocation(false);
|
||||
}
|
||||
|
||||
private void createMarker() {
|
||||
if (!driverAvailable.isEmpty()) {
|
||||
for (Marker m : driverMarkers) {
|
||||
m.remove();
|
||||
}
|
||||
|
||||
driverMarkers.clear();
|
||||
for (DriverModel driver : driverAvailable) {
|
||||
LatLng currentDriverPos = new LatLng(driver.getLatitude(), driver.getLongitude());
|
||||
|
||||
if (icondrver.equals("1")) {
|
||||
driverMarkers.add(
|
||||
gMap.addMarker(new MarkerOptions()
|
||||
.position(currentDriverPos)
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.drivermap))
|
||||
.anchor((float) 0.5, (float) 0.5)
|
||||
.rotation(Float.parseFloat(driver.getBearing()))
|
||||
.flat(true)
|
||||
)
|
||||
);
|
||||
} else if (icondrver.equals("2")) {
|
||||
driverMarkers.add(
|
||||
gMap.addMarker(new MarkerOptions()
|
||||
.position(currentDriverPos)
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.carmap))
|
||||
.anchor((float) 0.5, (float) 0.5)
|
||||
.rotation(Float.parseFloat(driver.getBearing()))
|
||||
.flat(true)
|
||||
)
|
||||
);
|
||||
} else if (icondrver.equals("3")) {
|
||||
driverMarkers.add(
|
||||
gMap.addMarker(new MarkerOptions()
|
||||
.position(currentDriverPos)
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.truck))
|
||||
.anchor((float) 0.5, (float) 0.5)
|
||||
.rotation(Float.parseFloat(driver.getBearing()))
|
||||
.flat(true)
|
||||
)
|
||||
);
|
||||
} else if (icondrver.equals("4")) {
|
||||
driverMarkers.add(
|
||||
gMap.addMarker(new MarkerOptions()
|
||||
.position(currentDriverPos)
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.delivery))
|
||||
.anchor((float) 0.5, (float) 0.5)
|
||||
.rotation(Float.parseFloat(driver.getBearing()))
|
||||
.flat(true)
|
||||
)
|
||||
);
|
||||
} else if (icondrver.equals("5")) {
|
||||
driverMarkers.add(
|
||||
gMap.addMarker(new MarkerOptions()
|
||||
.position(currentDriverPos)
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.hatchback))
|
||||
.anchor((float) 0.5, (float) 0.5)
|
||||
.rotation(Float.parseFloat(driver.getBearing()))
|
||||
.flat(true)
|
||||
)
|
||||
);
|
||||
} else if (icondrver.equals("6")) {
|
||||
driverMarkers.add(
|
||||
gMap.addMarker(new MarkerOptions()
|
||||
.position(currentDriverPos)
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.suv))
|
||||
.anchor((float) 0.5, (float) 0.5)
|
||||
.rotation(Float.parseFloat(driver.getBearing()))
|
||||
.flat(true)
|
||||
)
|
||||
);
|
||||
} else if (icondrver.equals("7")) {
|
||||
driverMarkers.add(
|
||||
gMap.addMarker(new MarkerOptions()
|
||||
.position(currentDriverPos)
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.van))
|
||||
.anchor((float) 0.5, (float) 0.5)
|
||||
.rotation(Float.parseFloat(driver.getBearing()))
|
||||
.flat(true)
|
||||
)
|
||||
);
|
||||
} else if (icondrver.equals("8")) {
|
||||
driverMarkers.add(
|
||||
gMap.addMarker(new MarkerOptions()
|
||||
.position(currentDriverPos)
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bicycle))
|
||||
.anchor((float) 0.5, (float) 0.5)
|
||||
.rotation(Float.parseFloat(driver.getBearing()))
|
||||
.flat(true)
|
||||
)
|
||||
);
|
||||
} else if (icondrver.equals("9")) {
|
||||
driverMarkers.add(
|
||||
gMap.addMarker(new MarkerOptions()
|
||||
.position(currentDriverPos)
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bajaj))
|
||||
.anchor((float) 0.5, (float) 0.5)
|
||||
.rotation(Float.parseFloat(driver.getBearing()))
|
||||
.flat(true)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void onDestination() {
|
||||
|
||||
if (destinationMarker != null) destinationMarker.remove();
|
||||
LatLng centerPos = gMap.getCameraPosition().target;
|
||||
destinationMarker = gMap.addMarker(new MarkerOptions()
|
||||
.position(centerPos)
|
||||
.title("Destination")
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.destination)));
|
||||
destinationLatLang = centerPos;
|
||||
|
||||
requestAddress(centerPos, destinationText);
|
||||
requestRoute();
|
||||
|
||||
setDestinationContainer.setVisibility(View.GONE);
|
||||
if (pickUpText.getText().toString().isEmpty()) {
|
||||
setPickUpContainer.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
setPickUpContainer.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void onPickUp() {
|
||||
|
||||
setDestinationContainer.setVisibility(View.VISIBLE);
|
||||
setPickUpContainer.setVisibility(View.GONE);
|
||||
if (pickUpMarker != null) pickUpMarker.remove();
|
||||
LatLng centerPos = gMap.getCameraPosition().target;
|
||||
pickUpMarker = gMap.addMarker(new MarkerOptions()
|
||||
.position(centerPos)
|
||||
.title("Pick Up")
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.pickup)));
|
||||
pickUpLatLang = centerPos;
|
||||
textprogress.setVisibility(View.VISIBLE);
|
||||
|
||||
requestAddress(centerPos, pickUpText);
|
||||
fetchNearDriver(pickUpLatLang.latitude, pickUpLatLang.longitude);
|
||||
requestRoute();
|
||||
}
|
||||
|
||||
private void requestRoute() {
|
||||
if (pickUpLatLang != null && destinationLatLang != null) {
|
||||
rlprogress.setVisibility(View.VISIBLE);
|
||||
textprogress.setText(getString(R.string.waiting_pleaseWait));
|
||||
MapDirectionAPI.getDirection(SendActivity.this, pickUpLatLang, destinationLatLang).enqueue(updateRouteCallback);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void updateLineDestination(String json) {
|
||||
Directions directions = new Directions(SendActivity.this);
|
||||
try {
|
||||
List<Route> routes = directions.parse(json);
|
||||
|
||||
if (directionLine != null) directionLine.remove();
|
||||
if (routes.size() > 0) {
|
||||
directionLine = gMap.addPolyline((new PolylineOptions())
|
||||
.addAll(routes.get(0).getOverviewPolyLine())
|
||||
.color(ContextCompat.getColor(SendActivity.this, R.color.colorgradient))
|
||||
.width(8));
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDistance(long distance) {
|
||||
orderButton.setEnabled(true);
|
||||
orderButton.setBackground(getResources().getDrawable(R.drawable.button_round_1));
|
||||
BottomSheetBehavior behavior = BottomSheetBehavior.from(bottomsheet);
|
||||
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||
setDestinationContainer.setVisibility(View.GONE);
|
||||
setPickUpContainer.setVisibility(View.GONE);
|
||||
orderButton.setVisibility(View.VISIBLE);
|
||||
|
||||
this.jarak = ((float) (distance)) / 1000f;
|
||||
|
||||
orderButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (driverAvailable.isEmpty()) {
|
||||
notif("Maaf, tidak ada pengemudi di sekitar Anda.");
|
||||
} else {
|
||||
onNextButtonClick();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void onNextButtonClick() {
|
||||
Intent intent = new Intent(this, SendDetailActivity.class);
|
||||
intent.putExtra("distance", jarak);//double
|
||||
intent.putExtra("price", getbiaya);//long
|
||||
intent.putExtra("pickup_latlng", pickUpLatLang);
|
||||
intent.putExtra("destination_latlng", destinationLatLang);
|
||||
intent.putExtra("pickup", pickUpText.getText().toString());
|
||||
intent.putExtra("destination", destinationText.getText().toString());
|
||||
intent.putExtra("driver", driverAvailable);
|
||||
intent.putExtra("biaya_minimum", biayaminimum);
|
||||
intent.putExtra("time_distance", timeDistance);
|
||||
intent.putExtra("driver", driverAvailable);
|
||||
intent.putExtra("icon", ICONFITUR);
|
||||
intent.putExtra("layanan", layanan.getText().toString());
|
||||
intent.putExtra("layanandesk", layanandesk.getText().toString());
|
||||
intent.putExtra(FITUR_KEY, fiturId);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
realm.close();
|
||||
}
|
||||
|
||||
private void fetchNearDriver(double latitude, double longitude) {
|
||||
if (driverAvailable != null) {
|
||||
driverAvailable.clear();
|
||||
}
|
||||
if (driverMarkers != null) {
|
||||
for (Marker m : driverMarkers) {
|
||||
m.remove();
|
||||
}
|
||||
driverMarkers.clear();
|
||||
}
|
||||
if (lastKnownLocation != null) {
|
||||
User loginUser = BaseApp.getInstance(this).getLoginUser();
|
||||
|
||||
BookService service = ServiceGenerator.createService(BookService.class, loginUser.getEmail(), loginUser.getPassword());
|
||||
GetNearRideCarRequestJson param = new GetNearRideCarRequestJson();
|
||||
param.setLatitude(latitude);
|
||||
param.setLongitude(longitude);
|
||||
param.setFitur(fitur);
|
||||
|
||||
service.getNearRide(param).enqueue(new Callback<GetNearRideCarResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<GetNearRideCarResponseJson> call, @NonNull Response<GetNearRideCarResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
driverAvailable = Objects.requireNonNull(response.body()).getData();
|
||||
createMarker();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<GetNearRideCarResponseJson> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void requestAddress(LatLng latlang, final TextView textView) {
|
||||
if (latlang != null) {
|
||||
MapDirectionAPI.getAddress(SendActivity.this, latlang).enqueue(new okhttp3.Callback() {
|
||||
@Override
|
||||
public void onFailure(@NonNull okhttp3.Call call, @NonNull IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull okhttp3.Call call, @NonNull final okhttp3.Response response) throws IOException {
|
||||
if (response.isSuccessful()) {
|
||||
final String json = Objects.requireNonNull(response.body()).string();
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
JSONObject Jobject = new JSONObject(json);
|
||||
JSONArray Jarray = Jobject.getJSONArray("results");
|
||||
JSONObject userdata = Jarray.getJSONObject(0);
|
||||
String address = userdata.getString("formatted_address");
|
||||
textView.setText(address);
|
||||
Log.e("TESTER", userdata.getString("formatted_address"));
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
googleApiClient.connect();
|
||||
super.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
googleApiClient.disconnect();
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,761 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.json.CheckStatusTransaksiRequest;
|
||||
import id.ontime.customer.json.CheckStatusTransaksiResponse;
|
||||
import id.ontime.customer.json.PromoRequestJson;
|
||||
import id.ontime.customer.json.PromoResponseJson;
|
||||
import id.ontime.customer.json.SendRequestJson;
|
||||
import id.ontime.customer.json.SendResponseJson;
|
||||
import id.ontime.customer.json.fcm.DriverRequest;
|
||||
import id.ontime.customer.json.fcm.DriverResponse;
|
||||
import id.ontime.customer.json.fcm.FCMMessage;
|
||||
import id.ontime.customer.models.DriverModel;
|
||||
import id.ontime.customer.models.FiturModel;
|
||||
import id.ontime.customer.models.TransaksiSendModel;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.utils.Utility;
|
||||
import id.ontime.customer.utils.api.FCMHelper;
|
||||
import id.ontime.customer.utils.api.ServiceGenerator;
|
||||
import id.ontime.customer.utils.api.service.BookService;
|
||||
import id.ontime.customer.utils.api.service.UserService;
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.ybs.countrypicker.CountryPicker;
|
||||
import com.ybs.countrypicker.CountryPickerListener;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import io.realm.Realm;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
import static id.ontime.customer.activity.SendActivity.FITUR_KEY;
|
||||
import static id.ontime.customer.json.fcm.FCMType.ORDER;
|
||||
|
||||
|
||||
public class SendDetailActivity extends AppCompatActivity {
|
||||
|
||||
Button dokument;
|
||||
Button fashion;
|
||||
Button box;
|
||||
Button other;
|
||||
EditText othertext;
|
||||
ImageView backbtn;
|
||||
TextView countrycode;
|
||||
TextView countrycodereceiver;
|
||||
TextView distanceText;
|
||||
TextView priceText;
|
||||
TextView topUp;
|
||||
TextView diskontext;
|
||||
TextView diskon;
|
||||
TextView saldotext;
|
||||
ImageButton checkedcash;
|
||||
ImageButton checkedwallet;
|
||||
TextView cashpayment;
|
||||
TextView walletpayment;
|
||||
LinearLayout llcheckedwallet;
|
||||
LinearLayout llcheckedcash;
|
||||
TextView fiturtext;
|
||||
EditText sendername;
|
||||
EditText recievername;
|
||||
EditText senderphone;
|
||||
EditText recieverphone;
|
||||
RelativeLayout rlprogress;
|
||||
RelativeLayout rlnotif;
|
||||
TextView textnotif;
|
||||
Button order;
|
||||
|
||||
EditText promokode;
|
||||
|
||||
Button btnpromo;
|
||||
|
||||
TextView promonotif;
|
||||
|
||||
String itemdetail, fitur;
|
||||
String country_iso_code = "en";
|
||||
Context context = SendDetailActivity.this;
|
||||
Realm realm;
|
||||
TransaksiSendModel transaksi;
|
||||
Thread thread;
|
||||
boolean threadRun = true;
|
||||
private double distance;
|
||||
private LatLng pickUpLatLang;
|
||||
private LatLng destinationLatLang;
|
||||
private String pickup, icon, layanan, layanandesk;
|
||||
private String destination;
|
||||
private String biayaakhir;
|
||||
private ArrayList<DriverModel> driverAvailable;
|
||||
private FiturModel fiturModel;
|
||||
private String saldoWallet;
|
||||
private String checkedpaywallet;
|
||||
private long harga, promocode;
|
||||
private DriverRequest request;
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_send_detail);
|
||||
// Manual view binding (ButterKnife removed)
|
||||
dokument = findViewById(R.id.dokumen);
|
||||
fashion = findViewById(R.id.fashion);
|
||||
box = findViewById(R.id.box);
|
||||
other = findViewById(R.id.other);
|
||||
othertext = findViewById(R.id.otherdetail);
|
||||
backbtn = findViewById(R.id.back_btn);
|
||||
countrycode = findViewById(R.id.countrycode);
|
||||
countrycodereceiver = findViewById(R.id.countrycodereceiver);
|
||||
distanceText = findViewById(R.id.distance);
|
||||
priceText = findViewById(R.id.price);
|
||||
topUp = findViewById(R.id.topUp);
|
||||
diskontext = findViewById(R.id.ketsaldo);
|
||||
diskon = findViewById(R.id.diskon);
|
||||
saldotext = findViewById(R.id.saldo);
|
||||
checkedcash = findViewById(R.id.checkedcash);
|
||||
checkedwallet = findViewById(R.id.checkedwallet);
|
||||
cashpayment = findViewById(R.id.cashPayment);
|
||||
walletpayment = findViewById(R.id.walletpayment);
|
||||
llcheckedwallet = findViewById(R.id.llcheckedwallet);
|
||||
llcheckedcash = findViewById(R.id.llcheckedcash);
|
||||
fiturtext = findViewById(R.id.fitur);
|
||||
sendername = findViewById(R.id.sendername);
|
||||
recievername = findViewById(R.id.recievername);
|
||||
senderphone = findViewById(R.id.phonenumber);
|
||||
recieverphone = findViewById(R.id.phonenumberreceiever);
|
||||
rlprogress = findViewById(R.id.rlprogress);
|
||||
rlnotif = findViewById(R.id.rlnotif);
|
||||
textnotif = findViewById(R.id.textnotif);
|
||||
order = findViewById(R.id.order);
|
||||
promokode = findViewById(R.id.promocode);
|
||||
btnpromo = findViewById(R.id.btnpromo);
|
||||
promonotif = findViewById(R.id.promonotif);
|
||||
promocode = 0;
|
||||
realm = Realm.getDefaultInstance();
|
||||
User userLogin = BaseApp.getInstance(this).getLoginUser();
|
||||
saldoWallet = String.valueOf(userLogin.getWalletSaldo());
|
||||
Intent intent = getIntent();
|
||||
distance = intent.getDoubleExtra("distance", 0);
|
||||
String price = intent.getStringExtra("price");
|
||||
pickUpLatLang = intent.getParcelableExtra("pickup_latlng");
|
||||
destinationLatLang = intent.getParcelableExtra("destination_latlng");
|
||||
pickup = intent.getStringExtra("pickup");
|
||||
icon = intent.getStringExtra("icon");
|
||||
layanan = intent.getStringExtra("layanan");
|
||||
layanandesk = intent.getStringExtra("layanandesk");
|
||||
destination = intent.getStringExtra("destination");
|
||||
String biayaminimum = intent.getStringExtra("biaya_minimum");
|
||||
String timeDistance = intent.getStringExtra("time_distance");
|
||||
driverAvailable = (ArrayList<DriverModel>) intent.getSerializableExtra("driver");
|
||||
int selectedFitur = intent.getIntExtra(FITUR_KEY, -1);
|
||||
|
||||
if (selectedFitur != -1)
|
||||
fiturModel = realm.where(FiturModel.class).equalTo("idFitur", selectedFitur).findFirst();
|
||||
assert fiturModel != null;
|
||||
fitur = String.valueOf(fiturModel.getIdFitur());
|
||||
|
||||
biayaakhir = String.valueOf(fiturModel.getBiayaAkhir());
|
||||
fiturtext.setText(timeDistance);
|
||||
float km = ((float) distance);
|
||||
String format = String.format(Locale.US, "%.1f", km);
|
||||
distanceText.setText(format);
|
||||
|
||||
Utility.currencyTXT(diskon, String.valueOf(promocode), SendDetailActivity.this);
|
||||
diskontext.setText("Diskon " + fiturModel.getDiskon() + " pakai koin");
|
||||
|
||||
checkedpaywallet = "0";
|
||||
Log.e("CHECKEDWALLET", checkedpaywallet);
|
||||
checkedcash.setSelected(true);
|
||||
checkedwallet.setSelected(false);
|
||||
cashpayment.setTextColor(getResources().getColor(R.color.colorgradient));
|
||||
walletpayment.setTextColor(getResources().getColor(R.color.gray));
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
checkedcash.setBackgroundTintList(getResources().getColorStateList(R.color.colorgradient));
|
||||
checkedwallet.setBackgroundTintList(getResources().getColorStateList(R.color.gray));
|
||||
}
|
||||
|
||||
String biaya = String.valueOf(biayaminimum);
|
||||
long biayaTotal = (long) (Double.parseDouble(Objects.requireNonNull(price)) * km);
|
||||
if (biayaTotal < Double.parseDouble(Objects.requireNonNull(biayaminimum))) {
|
||||
this.harga = Long.parseLong(biayaminimum);
|
||||
biayaTotal = Long.parseLong(biayaminimum);
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
this.harga = biayaTotal;
|
||||
|
||||
final long finalBiayaTotal = biayaTotal;
|
||||
String totalbiaya = String.valueOf(finalBiayaTotal);
|
||||
Utility.currencyTXT(priceText, totalbiaya, this);
|
||||
|
||||
long saldokini = Long.parseLong(saldoWallet);
|
||||
if (saldokini < (biayaTotal - (harga * Double.parseDouble(biayaakhir)))) {
|
||||
llcheckedcash.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String totalbiaya = String.valueOf(finalBiayaTotal);
|
||||
Utility.currencyTXT(priceText, totalbiaya, context);
|
||||
Utility.currencyTXT(diskon, String.valueOf(promocode), SendDetailActivity.this);
|
||||
checkedcash.setSelected(true);
|
||||
checkedwallet.setSelected(false);
|
||||
checkedpaywallet = "0";
|
||||
Log.e("CHECKEDWALLET", checkedpaywallet);
|
||||
cashpayment.setTextColor(getResources().getColor(R.color.colorgradient));
|
||||
walletpayment.setTextColor(getResources().getColor(R.color.gray));
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
checkedcash.setBackgroundTintList(getResources().getColorStateList(R.color.colorgradient));
|
||||
checkedwallet.setBackgroundTintList(getResources().getColorStateList(R.color.gray));
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
llcheckedcash.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String totalbiaya = String.valueOf(finalBiayaTotal);
|
||||
Utility.currencyTXT(priceText, totalbiaya, context);
|
||||
Utility.currencyTXT(diskon, String.valueOf(promocode), SendDetailActivity.this);
|
||||
checkedcash.setSelected(true);
|
||||
checkedwallet.setSelected(false);
|
||||
checkedpaywallet = "0";
|
||||
Log.e("CHECKEDWALLET", checkedpaywallet);
|
||||
cashpayment.setTextColor(getResources().getColor(R.color.colorgradient));
|
||||
walletpayment.setTextColor(getResources().getColor(R.color.gray));
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
checkedcash.setBackgroundTintList(getResources().getColorStateList(R.color.colorgradient));
|
||||
checkedwallet.setBackgroundTintList(getResources().getColorStateList(R.color.gray));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
final long finalBiayaTotal1 = biayaTotal;
|
||||
llcheckedwallet.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
long diskonwallet = (long) (Double.parseDouble(biayaakhir) * harga);
|
||||
String totalwallet = String.valueOf(diskonwallet + promocode);
|
||||
Utility.currencyTXT(diskon, totalwallet, context);
|
||||
String totalbiaya = String.valueOf(finalBiayaTotal1 - (diskonwallet + promocode));
|
||||
Utility.currencyTXT(priceText, totalbiaya, context);
|
||||
checkedcash.setSelected(false);
|
||||
checkedwallet.setSelected(true);
|
||||
checkedpaywallet = "1";
|
||||
Log.e("CHECKEDWALLET", checkedpaywallet);
|
||||
walletpayment.setTextColor(getResources().getColor(R.color.colorgradient));
|
||||
cashpayment.setTextColor(getResources().getColor(R.color.gray));
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
checkedwallet.setBackgroundTintList(getResources().getColorStateList(R.color.colorgradient));
|
||||
checkedcash.setBackgroundTintList(getResources().getColorStateList(R.color.gray));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dokument.setSelected(true);
|
||||
fashion.setSelected(false);
|
||||
box.setSelected(false);
|
||||
other.setSelected(false);
|
||||
itemdetail = "document";
|
||||
othertext.setVisibility(View.GONE);
|
||||
|
||||
dokument.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dokument.setSelected(true);
|
||||
fashion.setSelected(false);
|
||||
box.setSelected(false);
|
||||
other.setSelected(false);
|
||||
itemdetail = "document";
|
||||
othertext.setVisibility(View.GONE);
|
||||
othertext.setText("");
|
||||
}
|
||||
});
|
||||
|
||||
backbtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
fashion.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dokument.setSelected(false);
|
||||
fashion.setSelected(true);
|
||||
box.setSelected(false);
|
||||
other.setSelected(false);
|
||||
itemdetail = "fashion";
|
||||
othertext.setVisibility(View.GONE);
|
||||
othertext.setText("");
|
||||
}
|
||||
});
|
||||
|
||||
box.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dokument.setSelected(false);
|
||||
fashion.setSelected(false);
|
||||
box.setSelected(true);
|
||||
other.setSelected(false);
|
||||
itemdetail = "box";
|
||||
othertext.setVisibility(View.GONE);
|
||||
othertext.setText("");
|
||||
}
|
||||
});
|
||||
|
||||
other.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dokument.setSelected(false);
|
||||
fashion.setSelected(false);
|
||||
box.setSelected(false);
|
||||
other.setSelected(true);
|
||||
othertext.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
countrycode.setOnClickListener(new View.OnClickListener() {
|
||||
@SuppressLint("WrongConstant")
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final CountryPicker picker = CountryPicker.newInstance("Select Country");
|
||||
picker.setListener(new CountryPickerListener() {
|
||||
@Override
|
||||
public void onSelectCountry(String name, String code, String dialCode, int flagDrawableResID) {
|
||||
countrycode.setText(dialCode);
|
||||
picker.dismiss();
|
||||
country_iso_code = code;
|
||||
}
|
||||
});
|
||||
picker.setStyle(R.style.countrypicker_style, R.style.countrypicker_style);
|
||||
picker.show(getSupportFragmentManager(), "Select Country");
|
||||
}
|
||||
});
|
||||
|
||||
countrycodereceiver.setOnClickListener(new View.OnClickListener() {
|
||||
@SuppressLint("WrongConstant")
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final CountryPicker picker = CountryPicker.newInstance("Select Country");
|
||||
picker.setListener(new CountryPickerListener() {
|
||||
@Override
|
||||
public void onSelectCountry(String name, String code, String dialCode, int flagDrawableResID) {
|
||||
countrycodereceiver.setText(dialCode);
|
||||
picker.dismiss();
|
||||
country_iso_code = code;
|
||||
}
|
||||
});
|
||||
picker.setStyle(R.style.countrypicker_style, R.style.countrypicker_style);
|
||||
picker.show(getSupportFragmentManager(), "Select Country");
|
||||
}
|
||||
});
|
||||
|
||||
order.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (sendername.getText().toString().isEmpty()) {
|
||||
notif("Nama pengirim tidak boleh kosong!");
|
||||
} else if (senderphone.getText().toString().isEmpty()) {
|
||||
notif("Telepon pengirim tidak boleh kosong!");
|
||||
} else if (recievername.getText().toString().isEmpty()) {
|
||||
notif("Penerima tidak boleh kosong!");
|
||||
} else if (recieverphone.getText().toString().isEmpty()) {
|
||||
notif("Telepon penerima tidak boleh kosong!");
|
||||
} else {
|
||||
onOrderButton();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
btnpromo.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
try {
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
||||
Objects.requireNonNull(imm).hideSoftInputFromWindow(Objects.requireNonNull(getCurrentFocus()).getWindowToken(), 0);
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
if (promokode.getText().toString().isEmpty()) {
|
||||
notif("Kode promo tidk boleh kosong!");
|
||||
} else {
|
||||
promokodedata();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private void promokodedata() {
|
||||
btnpromo.setEnabled(false);
|
||||
btnpromo.setText("Wait...");
|
||||
final User user = BaseApp.getInstance(this).getLoginUser();
|
||||
PromoRequestJson request = new PromoRequestJson();
|
||||
request.setFitur(fitur);
|
||||
request.setCode(promokode.getText().toString());
|
||||
|
||||
UserService service = ServiceGenerator.createService(UserService.class, user.getNoTelepon(), user.getPassword());
|
||||
service.promocode(request).enqueue(new Callback<PromoResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<PromoResponseJson> call, @NonNull Response<PromoResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
if (Objects.requireNonNull(response.body()).getMessage().equalsIgnoreCase("success")) {
|
||||
btnpromo.setEnabled(true);
|
||||
btnpromo.setText("Use");
|
||||
if (response.body().getType().equals("persen")) {
|
||||
promocode = (Long.parseLong(response.body().getNominal()) * harga) / 100;
|
||||
} else {
|
||||
promocode = Long.parseLong(response.body().getNominal());
|
||||
}
|
||||
Log.e("", String.valueOf(promocode));
|
||||
if (checkedpaywallet.equals("1")) {
|
||||
long diskonwallet = (long) (Double.parseDouble(biayaakhir) * harga);
|
||||
String diskontotal = String.valueOf(diskonwallet + promocode);
|
||||
String totalbiaya = String.valueOf(harga - (diskonwallet + promocode));
|
||||
Utility.currencyTXT(priceText, totalbiaya, context);
|
||||
Utility.currencyTXT(diskon, diskontotal, SendDetailActivity.this);
|
||||
} else {
|
||||
String diskontotal = String.valueOf(promocode);
|
||||
String totalbiaya = String.valueOf(harga - promocode);
|
||||
Utility.currencyTXT(priceText, totalbiaya, context);
|
||||
Utility.currencyTXT(diskon, diskontotal, SendDetailActivity.this);
|
||||
}
|
||||
} else {
|
||||
btnpromo.setEnabled(true);
|
||||
btnpromo.setText("Use");
|
||||
notif("kode promo tidak tersedia!");
|
||||
promocode = 0;
|
||||
if (checkedpaywallet.equals("1")) {
|
||||
long diskonwallet = (long) (Double.parseDouble(biayaakhir) * harga);
|
||||
String diskontotal = String.valueOf(diskonwallet + promocode);
|
||||
String totalbiaya = String.valueOf(harga - (diskonwallet + promocode));
|
||||
Utility.currencyTXT(priceText, totalbiaya, context);
|
||||
Utility.currencyTXT(diskon, diskontotal, SendDetailActivity.this);
|
||||
} else {
|
||||
String diskontotal = String.valueOf(promocode);
|
||||
String totalbiaya = String.valueOf(harga - promocode);
|
||||
Utility.currencyTXT(priceText, totalbiaya, context);
|
||||
Utility.currencyTXT(diskon, diskontotal, SendDetailActivity.this);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
notif("error!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<PromoResponseJson> call, @NonNull Throwable t) {
|
||||
t.printStackTrace();
|
||||
notif("error");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
User userLogin = BaseApp.getInstance(this).getLoginUser();
|
||||
saldoWallet = String.valueOf(userLogin.getWalletSaldo());
|
||||
|
||||
Utility.koinTXT(saldotext, saldoWallet, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
realm.close();
|
||||
}
|
||||
|
||||
private void onOrderButton() {
|
||||
if (checkedpaywallet.equals("1")) {
|
||||
if (driverAvailable.isEmpty()) {
|
||||
notif("Maaf, tidak ada pengemudi di sekitar Anda.");
|
||||
} else {
|
||||
rlprogress.setVisibility(View.VISIBLE);
|
||||
SendRequestJson param = new SendRequestJson();
|
||||
User userLogin = BaseApp.getInstance(this).getLoginUser();
|
||||
param.setIdPelanggan(userLogin.getId());
|
||||
param.setOrderFitur(String.valueOf(fiturModel.getIdFitur()));
|
||||
param.setStartLatitude(pickUpLatLang.latitude);
|
||||
param.setStartLongitude(pickUpLatLang.longitude);
|
||||
param.setEndLatitude(destinationLatLang.latitude);
|
||||
param.setEndLongitude(destinationLatLang.longitude);
|
||||
param.setJarak(distance);
|
||||
param.setHarga(this.harga);
|
||||
param.setEstimasi(fiturtext.getText().toString());
|
||||
param.setKreditpromo(String.valueOf((Double.parseDouble(biayaakhir) * this.harga) + promocode));
|
||||
param.setAlamatAsal(pickup);
|
||||
param.setAlamatTujuan(destination);
|
||||
param.setPakaiWallet(1);
|
||||
param.setNamaPengirim(sendername.getText().toString());
|
||||
param.setTeleponPengirim(countrycode.getText().toString() + senderphone.getText().toString());
|
||||
param.setNamaPenerima(recievername.getText().toString());
|
||||
param.setTeleponPenerima(countrycodereceiver.getText().toString() + recieverphone.getText().toString());
|
||||
if (!othertext.getText().toString().isEmpty()) {
|
||||
param.setNamaBarang(othertext.getText().toString());
|
||||
} else {
|
||||
param.setNamaBarang(itemdetail);
|
||||
}
|
||||
sendRequestTransaksi(param, driverAvailable);
|
||||
}
|
||||
} else {
|
||||
if (driverAvailable.isEmpty()) {
|
||||
notif("Maaf, tidak ada pengemudi di sekitar Anda.");
|
||||
} else {
|
||||
rlprogress.setVisibility(View.VISIBLE);
|
||||
SendRequestJson param = new SendRequestJson();
|
||||
User userLogin = BaseApp.getInstance(this).getLoginUser();
|
||||
param.setIdPelanggan(userLogin.getId());
|
||||
param.setOrderFitur(String.valueOf(fiturModel.getIdFitur()));
|
||||
param.setStartLatitude(pickUpLatLang.latitude);
|
||||
param.setStartLongitude(pickUpLatLang.longitude);
|
||||
param.setEndLatitude(destinationLatLang.latitude);
|
||||
param.setEndLongitude(destinationLatLang.longitude);
|
||||
param.setJarak(distance);
|
||||
param.setHarga(this.harga);
|
||||
param.setEstimasi(fiturtext.getText().toString());
|
||||
param.setKreditpromo(String.valueOf(promocode));
|
||||
param.setAlamatAsal(pickup);
|
||||
param.setAlamatTujuan(destination);
|
||||
param.setPakaiWallet(0);
|
||||
param.setNamaPengirim(sendername.getText().toString());
|
||||
param.setTeleponPengirim(countrycode.getText().toString() + senderphone.getText().toString());
|
||||
param.setNamaPenerima(recievername.getText().toString());
|
||||
param.setTeleponPenerima(countrycodereceiver.getText().toString() + recieverphone.getText().toString());
|
||||
if (!othertext.getText().toString().isEmpty()) {
|
||||
param.setNamaBarang(othertext.getText().toString());
|
||||
} else {
|
||||
param.setNamaBarang(itemdetail);
|
||||
}
|
||||
|
||||
sendRequestTransaksi(param, driverAvailable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void notif(String text) {
|
||||
rlnotif.setVisibility(View.VISIBLE);
|
||||
textnotif.setText(text);
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
rlnotif.setVisibility(View.GONE);
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
private void sendRequestTransaksi(SendRequestJson param, final List<DriverModel> driverList) {
|
||||
rlprogress.setVisibility(View.VISIBLE);
|
||||
User loginUser = BaseApp.getInstance(this).getLoginUser();
|
||||
final BookService service = ServiceGenerator.createService(BookService.class, loginUser.getEmail(), loginUser.getPassword());
|
||||
|
||||
service.requestTransaksisend(param).enqueue(new Callback<SendResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<SendResponseJson> call, @NonNull Response<SendResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
buildDriverRequest(Objects.requireNonNull(response.body()));
|
||||
thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (int i = 0; i < driverList.size(); i++) {
|
||||
fcmBroadcast(i, driverList);
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(30000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (threadRun) {
|
||||
CheckStatusTransaksiRequest param = new CheckStatusTransaksiRequest();
|
||||
param.setIdTransaksi(transaksi.getId());
|
||||
service.checkStatusTransaksi(param).enqueue(new Callback<CheckStatusTransaksiResponse>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<CheckStatusTransaksiResponse> call, @NonNull Response<CheckStatusTransaksiResponse> response) {
|
||||
if (response.isSuccessful()) {
|
||||
CheckStatusTransaksiResponse checkStatus = response.body();
|
||||
if (!Objects.requireNonNull(checkStatus).isStatus()) {
|
||||
notif("Driver tidak ada!");
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
notif("Driver tidak ada!");
|
||||
}
|
||||
});
|
||||
|
||||
rlprogress.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<CheckStatusTransaksiResponse> call, @NonNull Throwable t) {
|
||||
notif("Driver tidak ada!");
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
notif("Driver tidak ada!");
|
||||
rlprogress.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
rlprogress.setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<SendResponseJson> call, @NonNull Throwable t) {
|
||||
t.printStackTrace();
|
||||
notif("Akun anda bermasalah, silahkan hubungi team admin!");
|
||||
rlprogress.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void buildDriverRequest(SendResponseJson response) {
|
||||
transaksi = response.getData().get(0);
|
||||
User loginUser = BaseApp.getInstance(this).getLoginUser();
|
||||
if (request == null) {
|
||||
request = new DriverRequest();
|
||||
request.setIdTransaksi(transaksi.getId());
|
||||
request.setIdPelanggan(transaksi.getIdPelanggan());
|
||||
request.setRegIdPelanggan(loginUser.getToken());
|
||||
request.setOrderFitur(fiturModel.getHome());
|
||||
request.setStartLatitude(transaksi.getStartLatitude());
|
||||
request.setStartLongitude(transaksi.getStartLongitude());
|
||||
request.setEndLatitude(transaksi.getEndLatitude());
|
||||
request.setEndLongitude(transaksi.getEndLongitude());
|
||||
request.setJarak(transaksi.getJarak());
|
||||
request.setHarga(transaksi.getHarga());
|
||||
request.setWaktuOrder(transaksi.getWaktuOrder());
|
||||
request.setAlamatAsal(transaksi.getAlamatAsal());
|
||||
request.setAlamatTujuan(transaksi.getAlamatTujuan());
|
||||
request.setKodePromo(transaksi.getKodePromo());
|
||||
request.setKreditPromo(transaksi.getKreditPromo());
|
||||
request.setPakaiWallet(String.valueOf(transaksi.isPakaiWallet()));
|
||||
request.setEstimasi(transaksi.getEstimasi());
|
||||
request.setLayanan(layanan);
|
||||
request.setLayanandesc(layanandesk);
|
||||
request.setIcon(icon);
|
||||
|
||||
request.setDistance(distanceText.getText().toString());
|
||||
|
||||
|
||||
String namaLengkap = String.format("%s", loginUser.getFullnama());
|
||||
request.setNamaPelanggan(namaLengkap);
|
||||
request.setTelepon(loginUser.getNoTelepon());
|
||||
request.setType(ORDER);
|
||||
}
|
||||
}
|
||||
|
||||
private void fcmBroadcast(int index, List<DriverModel> driverList) {
|
||||
DriverModel driverToSend = driverList.get(index);
|
||||
request.setTime_accept(new Date().getTime() + "");
|
||||
final FCMMessage message = new FCMMessage();
|
||||
message.setTo(driverToSend.getRegId());
|
||||
message.setData(request);
|
||||
|
||||
Log.e("REQUEST TO DRIVER", message.getData().toString());
|
||||
|
||||
FCMHelper.sendMessage(message).enqueue(new okhttp3.Callback() {
|
||||
@Override
|
||||
public void onResponse(@NonNull okhttp3.Call call, @NonNull okhttp3.Response response) {
|
||||
Log.e("REQUEST TO DRIVER", message.getData().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull okhttp3.Call call, @NonNull IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
|
||||
public void onMessageEvent(final DriverResponse response) {
|
||||
if (response.getResponse().equalsIgnoreCase(DriverResponse.ACCEPT) || response.getResponse().equals("3") || response.getResponse().equals("4")) {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
threadRun = false;
|
||||
for (DriverModel cDriver : driverAvailable) {
|
||||
if (cDriver.getId().equals(response.getId())) {
|
||||
|
||||
|
||||
Intent intent = new Intent(SendDetailActivity.this, ProgressActivity.class);
|
||||
intent.putExtra("id_driver", cDriver.getId());
|
||||
intent.putExtra("id_transaksi", request.getIdTransaksi());
|
||||
intent.putExtra("response", "2");
|
||||
startActivity(intent);
|
||||
DriverResponse response = new DriverResponse();
|
||||
response.setId("");
|
||||
response.setIdTransaksi("");
|
||||
response.setResponse("");
|
||||
EventBus.getDefault().postSticky(response);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.Location;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.provider.Settings;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.fragment.EnableLlocationFragment;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.utils.PhoneProviderHelper;
|
||||
import com.google.android.gms.location.FusedLocationProviderClient;
|
||||
import com.google.android.gms.location.LocationServices;
|
||||
import com.google.android.gms.tasks.OnSuccessListener;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import pl.droidsonroids.gif.GifDrawable;
|
||||
|
||||
|
||||
public class SplashActivity extends AppCompatActivity {
|
||||
|
||||
SharedPreferences sharedPreferences;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_splash);
|
||||
try {
|
||||
GifDrawable getAssets = new GifDrawable(getAssets(), "logoflash.png");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
removeNotif();
|
||||
final User user = BaseApp.getInstance(this).getLoginUser();
|
||||
sharedPreferences = getSharedPreferences(Constants.PREF_NAME, MODE_PRIVATE);
|
||||
PhoneProviderHelper.addOperator(sharedPreferences);
|
||||
new Handler().postDelayed(() -> {
|
||||
|
||||
if (user != null) {
|
||||
|
||||
if (ActivityCompat.checkSelfPermission(SplashActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(SplashActivity.this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
enable_location();
|
||||
} else {
|
||||
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
} else {
|
||||
if (ActivityCompat.checkSelfPermission(SplashActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(SplashActivity.this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
enable_location();
|
||||
} else {
|
||||
Intent intent = new Intent(SplashActivity.this, IntroActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
||||
}, 2000);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void GPSStatus() {
|
||||
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
||||
boolean GpsStatus = Objects.requireNonNull(locationManager).isProviderEnabled(LocationManager.GPS_PROVIDER);
|
||||
if (!GpsStatus) {
|
||||
Toast.makeText(this, "On Location in High Accuracy", Toast.LENGTH_SHORT).show();
|
||||
startActivityForResult(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS), 2);
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
GetCurrentlocation();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == 2) {
|
||||
GPSStatus();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void GetCurrentlocation() {
|
||||
FusedLocationProviderClient mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
|
||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
enable_location();
|
||||
return;
|
||||
}
|
||||
|
||||
mFusedLocationClient.getLastLocation()
|
||||
.addOnSuccessListener(this, new OnSuccessListener<Location>() {
|
||||
@Override
|
||||
public void onSuccess(Location location) {
|
||||
// Got last known location. In some rare situations this can be null.
|
||||
if (location != null) {
|
||||
|
||||
// if we successfully get the location of the customer then we will save the locatio into
|
||||
//locally and go to the Main view
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString(String.valueOf(Constants.LATITUDE), "" + location.getLatitude());
|
||||
editor.putString(String.valueOf(Constants.LONGITUDE), "" + location.getLongitude());
|
||||
editor.apply();
|
||||
Constants.LATITUDE = location.getLatitude();
|
||||
Constants.LONGITUDE = location.getLongitude();
|
||||
startActivity(new Intent(SplashActivity.this, MainActivity.class));
|
||||
overridePendingTransition(R.anim.from_right, R.anim.to_left);
|
||||
finish();
|
||||
} else {
|
||||
|
||||
if (sharedPreferences.getString(String.valueOf(Constants.LATITUDE), "").equals("") || sharedPreferences.getString(String.valueOf(Constants.LONGITUDE), "").equals("")) {
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString(String.valueOf(Constants.LATITUDE), "33.738045");
|
||||
editor.putString(String.valueOf(Constants.LONGITUDE), "73.084488");
|
||||
editor.apply();
|
||||
Constants.LATITUDE = Double.valueOf("33.738045");
|
||||
Constants.LONGITUDE = Double.valueOf("73.084488");
|
||||
}
|
||||
startActivity(new Intent(SplashActivity.this, MainActivity.class));
|
||||
overridePendingTransition(R.anim.from_right, R.anim.to_left);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void enable_location() {
|
||||
EnableLlocationFragment enable_llocationFragment = new EnableLlocationFragment();
|
||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||
transaction.setCustomAnimations(R.anim.from_right, R.anim.to_left, R.anim.from_left, R.anim.to_right);
|
||||
getSupportFragmentManager().popBackStackImmediate();
|
||||
transaction.replace(R.id.splash, enable_llocationFragment).addToBackStack(null).commit();
|
||||
|
||||
}
|
||||
|
||||
private void removeNotif() {
|
||||
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
Objects.requireNonNull(notificationManager).cancel(0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,259 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.utils.local_interface.OnBpjsItemClick;
|
||||
import id.ontime.customer.item.TopUpBPJSHistoryItem;
|
||||
import id.ontime.customer.json.MobilePulsaHealthBPJSBaseResponse;
|
||||
import id.ontime.customer.json.MobilePulsaHealthBPJSResponseModel;
|
||||
import id.ontime.customer.json.MobileTopUpPostPaidStatusJson;
|
||||
import id.ontime.customer.json.fcm.FCMMessage;
|
||||
import id.ontime.customer.models.Notif;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.utils.ProjectUtils;
|
||||
import id.ontime.customer.utils.SettingPreference;
|
||||
import id.ontime.customer.utils.Utility;
|
||||
import id.ontime.customer.utils.api.FCMHelper;
|
||||
import id.ontime.customer.utils.api.MobilePulsaApiHelper;
|
||||
import id.ontime.customer.utils.api.service.ApiListener;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class TopUpBpjsActivity extends AppCompatActivity implements OnBpjsItemClick {
|
||||
ImageView ivBack;
|
||||
Spinner spinner;
|
||||
EditText etIdBpjs;
|
||||
Button submit;
|
||||
RelativeLayout rlProgress,rlnotif;
|
||||
String disableBack;
|
||||
TextView notif;
|
||||
SettingPreference sp;
|
||||
RecyclerView rcBpjsHistory;
|
||||
LinearLayout llHistory;
|
||||
List<MobilePulsaHealthBPJSResponseModel> mobileBPJSHistory = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_top_up_bpjs);
|
||||
ivBack = findViewById(R.id.ivBack);
|
||||
spinner = findViewById(R.id.spinnerListDates);
|
||||
etIdBpjs = findViewById(R.id.etIdBpjs);
|
||||
submit = findViewById(R.id.submit);
|
||||
rlnotif = findViewById(R.id.rlnotif);
|
||||
rlProgress = findViewById(R.id.rlprogress);
|
||||
notif = findViewById(R.id.textnotif);
|
||||
rcBpjsHistory = findViewById(R.id.rcBpjsTopUp);
|
||||
llHistory = findViewById(R.id.llListPastTopUp);
|
||||
|
||||
sp = new SettingPreference(this);
|
||||
initSpinner();
|
||||
|
||||
ivBack.setOnClickListener(v -> finish());
|
||||
submit.setOnClickListener(v -> {
|
||||
progressShow();
|
||||
checkBpjsNumber();
|
||||
});
|
||||
}
|
||||
|
||||
private void checkBpjsNumber() {
|
||||
MobilePulsaApiHelper.checkHealthBPJS(etIdBpjs.getText().toString(),
|
||||
spinner.getSelectedItemPosition() + 1, sp).enqueue(new Callback<MobilePulsaHealthBPJSBaseResponse>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<MobilePulsaHealthBPJSBaseResponse> cal, @NonNull Response<MobilePulsaHealthBPJSBaseResponse> response) {
|
||||
progressHide();
|
||||
if (response.isSuccessful()) {
|
||||
if (response.body() != null &&
|
||||
response.body().getData().getMessage().equalsIgnoreCase("inquiry success")) {
|
||||
payBPJS(String.valueOf(response.body().getData().getTransactionId()));
|
||||
} else {
|
||||
progressHide();
|
||||
notif(Objects.requireNonNull(response.body()).getData().getMessage());
|
||||
}
|
||||
} else {
|
||||
progressHide();
|
||||
notif(Objects.requireNonNull(response.errorBody()).toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<MobilePulsaHealthBPJSBaseResponse> call, @NonNull Throwable t) {
|
||||
progressHide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void payBPJS(String trId) {
|
||||
MobilePulsaApiHelper.payBPJSKes(trId,sp).enqueue(new Callback<MobilePulsaHealthBPJSBaseResponse>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<MobilePulsaHealthBPJSBaseResponse> call,@NonNull Response<MobilePulsaHealthBPJSBaseResponse> response) {
|
||||
progressHide();
|
||||
if (response.isSuccessful()) {
|
||||
if (response.body() != null &&
|
||||
response.body().getData().getMessage().equalsIgnoreCase("PAYMENT SUCCESS")) {
|
||||
MobilePulsaHealthBPJSResponseModel data = response.body().getData();
|
||||
sp.updateBPJSList(data);
|
||||
MobilePulsaApiHelper.trackUserTopUp(String.valueOf(data.getSellingPrice()), "BPJS", etIdBpjs.getText().toString(),
|
||||
TopUpBpjsActivity.this, sp, new ApiListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Notif notif = new Notif();
|
||||
notif.title = "Topup";
|
||||
notif.message = "Permintaan pengisian telah berhasil, kami akan mengirimkan pemberitahuan setelah kami mengkonfirmasi";
|
||||
final User user = BaseApp.getInstance(TopUpBpjsActivity.this).getLoginUser();
|
||||
sendNotif(user.getToken(), notif);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
notif(Objects.requireNonNull(response.body()).getData().getMessage());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
notif(Objects.requireNonNull(response.body()).getData().getMessage());
|
||||
}
|
||||
} else {
|
||||
notif(Objects.requireNonNull(response.errorBody()).toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<MobilePulsaHealthBPJSBaseResponse> call, @NonNull Throwable t) {
|
||||
progressHide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initSpinner() {
|
||||
ArrayAdapter<String> nominalListAdapter =
|
||||
new ArrayAdapter<>(this, R.layout.dialog_spinner_item, ProjectUtils.getNext12MonthList());
|
||||
nominalListAdapter.setDropDownViewResource(R.layout.dialog_spinner_dropdown_item);
|
||||
spinner.setAdapter(nominalListAdapter);
|
||||
|
||||
initRcView();
|
||||
}
|
||||
|
||||
private void initRcView() {
|
||||
if (sp.getSetting()[11] != null && !sp.getSetting()[11].isEmpty()) {
|
||||
llHistory.setVisibility(View.VISIBLE);
|
||||
Type listOfMyClassObject = new TypeToken<ArrayList<MobilePulsaHealthBPJSResponseModel>>() {}.getType();
|
||||
mobileBPJSHistory.addAll(new Gson().fromJson(sp.getSetting()[11], listOfMyClassObject));
|
||||
|
||||
rcBpjsHistory.setHasFixedSize(true);
|
||||
rcBpjsHistory.setNestedScrollingEnabled(false);
|
||||
rcBpjsHistory.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false));
|
||||
|
||||
TopUpBPJSHistoryItem item = new TopUpBPJSHistoryItem(mobileBPJSHistory, this);
|
||||
rcBpjsHistory.setAdapter(item);
|
||||
} else {
|
||||
llHistory.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void notif(String text) {
|
||||
rlnotif.setVisibility(View.VISIBLE);
|
||||
notif.setText(text);
|
||||
|
||||
new Handler().postDelayed(() -> rlnotif.setVisibility(View.GONE), 3000);
|
||||
}
|
||||
|
||||
private void progressShow() {
|
||||
rlProgress.setVisibility(View.VISIBLE);
|
||||
disableBack = "true";
|
||||
}
|
||||
|
||||
private void progressHide() {
|
||||
rlProgress.setVisibility(View.GONE);
|
||||
disableBack = "false";
|
||||
}
|
||||
|
||||
private void sendNotif(final String regIDTujuan, final Notif notif) {
|
||||
|
||||
final FCMMessage message = new FCMMessage();
|
||||
message.setTo(regIDTujuan);
|
||||
message.setData(notif);
|
||||
|
||||
FCMHelper.sendMessage(message).enqueue(new okhttp3.Callback() {
|
||||
@Override
|
||||
public void onResponse(@NonNull okhttp3.Call call, @NonNull okhttp3.Response response) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull okhttp3.Call call, @NonNull IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(MobilePulsaHealthBPJSResponseModel model) {
|
||||
progressShow();
|
||||
MobilePulsaApiHelper.checkPostPaidStatus(model.getReferenceId(),sp).enqueue(new Callback<MobileTopUpPostPaidStatusJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<MobileTopUpPostPaidStatusJson> call, @NonNull Response<MobileTopUpPostPaidStatusJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
if (response.body() != null) {
|
||||
progressHide();
|
||||
MobileTopUpPostPaidStatusJson.MobileTOpUpPostPaidDetailJson data = response.body().getData();
|
||||
|
||||
final Dialog dialog = new Dialog(TopUpBpjsActivity.this);
|
||||
dialog.setContentView(R.layout.dialog_payment_details);
|
||||
TextView tvPel = dialog.findViewById(R.id.idPelanggan);
|
||||
TextView tvTotal = dialog.findViewById(R.id.tvTotal);
|
||||
TextView titlePel = dialog.findViewById(R.id.tvIdPel);
|
||||
|
||||
titlePel.setText("STATUS");
|
||||
tvPel.setText(data.getMessage());
|
||||
|
||||
int total = data.getPrice() + 600;
|
||||
tvTotal.setText(new StringBuilder().append(data.getPeriod()).append(" bulan\n").append(Utility.convertCurrency(String.valueOf(total), TopUpBpjsActivity.this)).toString());
|
||||
dialog.show();
|
||||
} else {
|
||||
progressHide();
|
||||
notif(Objects.requireNonNull(response.errorBody()).toString());
|
||||
}
|
||||
} else {
|
||||
progressHide();
|
||||
notif("error, silahkan cek data akun anda!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<MobileTopUpPostPaidStatusJson> call, @NonNull Throwable t) {
|
||||
progressHide();
|
||||
notif("error, silahkan cek data akun anda!");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,317 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.item.TopUpPlnHistoryItem;
|
||||
import id.ontime.customer.json.MobilePulsaPLNCheckResponse;
|
||||
import id.ontime.customer.json.MobileTopUpDetailResponseModel;
|
||||
import id.ontime.customer.json.MobileTopUpResponseModel;
|
||||
import id.ontime.customer.json.TopUpBaseResponse;
|
||||
import id.ontime.customer.json.TopUpRequestResponse;
|
||||
import id.ontime.customer.json.fcm.FCMMessage;
|
||||
import id.ontime.customer.models.Notif;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.utils.ProjectUtils;
|
||||
import id.ontime.customer.utils.SettingPreference;
|
||||
import id.ontime.customer.utils.Utility;
|
||||
import id.ontime.customer.utils.api.MobilePulsaApiHelper;
|
||||
import id.ontime.customer.utils.api.FCMHelper;
|
||||
import id.ontime.customer.utils.api.service.ApiListener;
|
||||
import id.ontime.customer.utils.local_interface.OnItemClicked;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class TopUpPlnActivity extends AppCompatActivity implements OnItemClicked {
|
||||
RelativeLayout rlProgress,rlnotif;
|
||||
String disableBack;
|
||||
EditText etIdPln;
|
||||
Spinner spinner;
|
||||
TextView notif;
|
||||
Button submit;
|
||||
SettingPreference sp;
|
||||
ImageView ivBack;
|
||||
RecyclerView rcView;
|
||||
LinearLayout llListPastTopUp;
|
||||
List<TopUpRequestResponse> listOfPreviousPLNTopUpRequest= new ArrayList<>();
|
||||
List<MobileTopUpDetailResponseModel> dataList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.top_up_pln_activity);
|
||||
rlnotif = findViewById(R.id.rlnotif);
|
||||
rlProgress = findViewById(R.id.rlprogress);
|
||||
etIdPln = findViewById(R.id.etIdPln);
|
||||
spinner = findViewById(R.id.listNominal);
|
||||
notif = findViewById(R.id.textnotif);
|
||||
submit = findViewById(R.id.submit);
|
||||
ivBack = findViewById(R.id.ivBack);
|
||||
rcView = findViewById(R.id.rcPlnTopUpList);
|
||||
llListPastTopUp = findViewById(R.id.llListPastTopUp);
|
||||
|
||||
sp = new SettingPreference(this);
|
||||
|
||||
getMobilePulsaPriceListData();
|
||||
|
||||
ivBack.setOnClickListener(v -> finish());
|
||||
|
||||
submit.setOnClickListener(v -> {
|
||||
User userLogin = BaseApp.getInstance(TopUpPlnActivity.this).getLoginUser();
|
||||
if(userLogin.getWalletSaldo() < dataList.get(spinner.getSelectedItemPosition()).getPhoneCreditPrice()) {
|
||||
Toast.makeText(this, "Your wallet is not enough. Please top up first", Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
checkPlnSubscriber();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getMobilePulsaPriceListData() {
|
||||
progressShow();
|
||||
String url = Constants.MOBILEPULSA_PRODUCTION_URL + "/pln/pln";
|
||||
MobilePulsaApiHelper.getMobilePulsaPriceList( url,
|
||||
ProjectUtils.md5(ProjectUtils.generateSignInMobilePulsa("pl", sp)), "pricelist",sp).enqueue(new Callback<MobileTopUpResponseModel>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<MobileTopUpResponseModel> call, @NonNull Response<MobileTopUpResponseModel> response) {
|
||||
progressHide();
|
||||
if (response.isSuccessful()) {
|
||||
if (response.body() != null) {
|
||||
List<String> categoryList = new ArrayList<>();
|
||||
dataList.addAll(response.body().getDetailResponse());
|
||||
Collections.sort(dataList, (o1, o2) -> Integer.valueOf(o1.getPhoneCreditDescription()).compareTo(Integer.valueOf(o2.getPhoneCreditDescription())));
|
||||
for (MobileTopUpDetailResponseModel data: dataList) {
|
||||
int price = data.getPhoneCreditPrice() + 600;
|
||||
categoryList.add(Utility.convertCurrency(String.valueOf(price), TopUpPlnActivity.this));
|
||||
}
|
||||
initSpinner(categoryList);
|
||||
initPastPLNPaidBill(sp.getSetting()[10]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<MobileTopUpResponseModel> call, @NonNull Throwable t) {
|
||||
progressHide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initPastPLNPaidBill(String list) {
|
||||
if (!list.isEmpty()) {
|
||||
llListPastTopUp.setVisibility(View.VISIBLE);
|
||||
Type listOfMyClassObject = new TypeToken<List<TopUpRequestResponse>>() {}.getType();
|
||||
listOfPreviousPLNTopUpRequest.addAll(new Gson().fromJson(list, listOfMyClassObject));
|
||||
|
||||
rcView.setHasFixedSize(true);
|
||||
rcView.setNestedScrollingEnabled(false);
|
||||
rcView.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false));
|
||||
|
||||
TopUpPlnHistoryItem item = new TopUpPlnHistoryItem(listOfPreviousPLNTopUpRequest, this);
|
||||
rcView.setAdapter(item);
|
||||
} else {
|
||||
llListPastTopUp.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void initSpinner(List<String> data) {
|
||||
ArrayAdapter<String> nominalListAdapter =
|
||||
new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, data);
|
||||
nominalListAdapter.setDropDownViewResource(R.layout.dialog_spinner_dropdown_item);
|
||||
spinner.setAdapter(nominalListAdapter);
|
||||
}
|
||||
|
||||
private void checkPlnSubscriber() {
|
||||
progressShow();
|
||||
String enteredMeter = etIdPln.getText().toString();
|
||||
MobilePulsaApiHelper.checkPLNSubscriber( Constants.MOBILEPULSA_PRODUCTION_URL, ProjectUtils.md5(ProjectUtils.generateSignInMobilePulsa(enteredMeter,sp)),
|
||||
"inquiry_pln", enteredMeter, sp).enqueue(new Callback<MobilePulsaPLNCheckResponse>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<MobilePulsaPLNCheckResponse> call, @NonNull Response<MobilePulsaPLNCheckResponse> response) {
|
||||
if (response.isSuccessful()) {
|
||||
if (response.body() != null) {
|
||||
if ("SUCCESS".equalsIgnoreCase(response.body().getDetailResponse().getMessage())) {
|
||||
topUpRequest();
|
||||
} else {
|
||||
progressHide();
|
||||
notif(response.body().getDetailResponse().getMessage());
|
||||
}
|
||||
} else {
|
||||
progressHide();
|
||||
notif("error, silahkan cek data akun anda!");
|
||||
}
|
||||
} else {
|
||||
notif("error, silahkan cek data akun anda!");
|
||||
progressHide();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<MobilePulsaPLNCheckResponse> call, @NonNull Throwable t) {
|
||||
progressHide();
|
||||
notif("error, silahkan cek data akun anda!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void topUpRequest() {
|
||||
String pulsaCode = dataList.get(spinner.getSelectedItemPosition()).getPhoneCreditCode();
|
||||
MobilePulsaApiHelper.topUpRequestToken(etIdPln.getText().toString(),
|
||||
pulsaCode,sp).enqueue(new Callback<TopUpBaseResponse>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<TopUpBaseResponse> call,@NonNull Response<TopUpBaseResponse> response) {
|
||||
if (response.isSuccessful()) {
|
||||
if (response.body() != null) {
|
||||
sp.updatePlnList(response.body().getData());
|
||||
trackTopUp();
|
||||
} else {
|
||||
progressHide();
|
||||
notif(Objects.requireNonNull(response.errorBody()).toString());
|
||||
}
|
||||
} else {
|
||||
progressHide();
|
||||
notif("error, silahkan cek data akun anda!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<TopUpBaseResponse> call, @NonNull Throwable t) {
|
||||
progressHide();
|
||||
notif("error, silahkan cek data akun anda!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void trackTopUp() {
|
||||
MobilePulsaApiHelper.trackUserTopUp(String.valueOf(dataList.get(spinner.getSelectedItemPosition()).getPhoneCreditPrice()), "PLN", etIdPln.getText().toString(),
|
||||
TopUpPlnActivity.this, sp, new ApiListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Notif notif = new Notif();
|
||||
notif.title = "Topup";
|
||||
notif.message = "Permintaan pengisian telah berhasil, kami akan mengirimkan pemberitahuan setelah kami mengkonfirmasi";
|
||||
final User user = BaseApp.getInstance(TopUpPlnActivity.this).getLoginUser();
|
||||
sendNotif(user.getToken(), notif);
|
||||
progressHide();
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
progressHide();
|
||||
notif("error, silahkan cek data akun anda!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void notif(String text) {
|
||||
rlnotif.setVisibility(View.VISIBLE);
|
||||
notif.setText(text);
|
||||
|
||||
new Handler().postDelayed(() -> rlnotif.setVisibility(View.GONE), 3000);
|
||||
}
|
||||
|
||||
private void progressShow() {
|
||||
rlProgress.setVisibility(View.VISIBLE);
|
||||
disableBack = "true";
|
||||
}
|
||||
|
||||
private void progressHide() {
|
||||
rlProgress.setVisibility(View.GONE);
|
||||
disableBack = "false";
|
||||
}
|
||||
|
||||
private void sendNotif(final String regIDTujuan, final Notif notif) {
|
||||
|
||||
final FCMMessage message = new FCMMessage();
|
||||
message.setTo(regIDTujuan);
|
||||
message.setData(notif);
|
||||
|
||||
FCMHelper.sendMessage(message).enqueue(new okhttp3.Callback() {
|
||||
@Override
|
||||
public void onResponse(@NonNull okhttp3.Call call, @NonNull okhttp3.Response response) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull okhttp3.Call call, @NonNull IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(TopUpRequestResponse previousResponse) {
|
||||
progressShow();
|
||||
MobilePulsaApiHelper.checkPrepaidStatus(previousResponse.getRefId(), sp).enqueue(new Callback<TopUpBaseResponse>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<TopUpBaseResponse> call, @NonNull Response<TopUpBaseResponse> response) {
|
||||
if (response.isSuccessful()) {
|
||||
if (response.body() != null) {
|
||||
progressHide();
|
||||
TopUpRequestResponse data = response.body().getData();
|
||||
|
||||
final Dialog dialog = new Dialog(TopUpPlnActivity.this);
|
||||
dialog.setContentView(R.layout.dialog_payment_details);
|
||||
TextView tvPel = dialog.findViewById(R.id.idPelanggan);
|
||||
TextView tvTotal = dialog.findViewById(R.id.tvTotal);
|
||||
TextView titlePel = dialog.findViewById(R.id.tvIdPel);
|
||||
|
||||
if (data.getMeteredToken() != null && !data.getMeteredToken().isEmpty()) {
|
||||
tvPel.setText(data.getMeteredToken().split("/")[0]);
|
||||
} else {
|
||||
titlePel.setText("STATUS");
|
||||
tvPel.setText(data.getMessage());
|
||||
}
|
||||
|
||||
int total = data.getPrice() + 600;
|
||||
tvTotal.setText(Utility.convertCurrency(String.valueOf(total), TopUpPlnActivity.this));
|
||||
dialog.show();
|
||||
} else {
|
||||
progressHide();
|
||||
notif(Objects.requireNonNull(response.errorBody()).toString());
|
||||
}
|
||||
} else {
|
||||
progressHide();
|
||||
notif("error, silahkan cek data akun anda!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<TopUpBaseResponse> call, @NonNull Throwable t) {
|
||||
progressHide();
|
||||
notif("error, silahkan cek data akun anda!");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.constants.TopUpType;
|
||||
import id.ontime.customer.json.MobileTopUpDetailResponseModel;
|
||||
import id.ontime.customer.json.TopUpBaseResponse;
|
||||
import id.ontime.customer.json.fcm.FCMMessage;
|
||||
import id.ontime.customer.models.Notif;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.utils.ProjectUtils;
|
||||
import id.ontime.customer.utils.SettingPreference;
|
||||
import id.ontime.customer.utils.Utility;
|
||||
import id.ontime.customer.utils.api.FCMHelper;
|
||||
import id.ontime.customer.utils.api.MobilePulsaApiHelper;
|
||||
import id.ontime.customer.utils.api.service.ApiListener;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class TopUpPulsaActivity extends AppCompatActivity {
|
||||
EditText phoneNumber, productTitle;
|
||||
TextView tvOperatorName, notif;
|
||||
Button submit;
|
||||
RelativeLayout rlProgress,rlnotif;
|
||||
MobileTopUpDetailResponseModel topUpDetailModel;
|
||||
SettingPreference sp;
|
||||
public static final int ACTIVITY_RESULT = 0x123;
|
||||
String disableBack;
|
||||
|
||||
Spinner spinnerDataType;
|
||||
TopUpType topUpType = TopUpType.pulsa;
|
||||
List<String> dataType = new ArrayList<>(Arrays.asList("Pulsa", "Paket Data"));
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_top_up_pulsa);
|
||||
phoneNumber = findViewById(R.id.etPhoneNumber);
|
||||
submit= findViewById(R.id.submit);
|
||||
rlnotif = findViewById(R.id.rlnotif);
|
||||
notif = findViewById(R.id.textnotif);
|
||||
rlProgress= findViewById(R.id.rlprogress);
|
||||
tvOperatorName = findViewById(R.id.tvOperator);
|
||||
productTitle = findViewById(R.id.etProduct);
|
||||
sp = new SettingPreference(this);
|
||||
spinnerDataType = findViewById(R.id.spinnerPulsaType);
|
||||
|
||||
initSpinner();
|
||||
|
||||
|
||||
phoneNumber.addTextChangedListener(Utility.listenOperatorName(phoneNumber, this, tvOperatorName));
|
||||
productTitle.setOnClickListener(v -> {
|
||||
if (tvOperatorName.getText().toString().isEmpty()) return;
|
||||
Intent i = new Intent(this, OperatorProviderListActivity.class);
|
||||
i.putExtra(Constants.OPERATOR, tvOperatorName.getText().toString());
|
||||
i.putExtra(OperatorProviderListActivity.TOPUP_TYPE, topUpType.toString());
|
||||
startActivityForResult(i, ACTIVITY_RESULT);
|
||||
});
|
||||
|
||||
submit.setOnClickListener(v -> {
|
||||
User userLogin = BaseApp.getInstance(TopUpPulsaActivity.this).getLoginUser();
|
||||
|
||||
if (topUpDetailModel == null) {
|
||||
Toast.makeText(this, "Please pick product first", Toast.LENGTH_LONG).show();
|
||||
} else if(userLogin.getWalletSaldo() < topUpDetailModel.getPhoneCreditPrice()) {
|
||||
Toast.makeText(this, "Your wallet is not enough. Please top up first", Toast.LENGTH_LONG).show();
|
||||
} else if (!ProjectUtils.isPhoneNumberValid(phoneNumber.getText().toString())) {
|
||||
Toast.makeText(this, "Phone Number is not valid", Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
requestTopUp();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initSpinner() {
|
||||
ArrayAdapter<String> nominalListAdapter =
|
||||
new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, dataType);
|
||||
nominalListAdapter.setDropDownViewResource(R.layout.dialog_spinner_dropdown_item);
|
||||
spinnerDataType.setAdapter(nominalListAdapter);
|
||||
spinnerDataType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
topUpType = position == 1 ? TopUpType.data : TopUpType.pulsa;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void progressShow() {
|
||||
rlProgress.setVisibility(View.VISIBLE);
|
||||
disableBack = "true";
|
||||
}
|
||||
|
||||
private void progressHide() {
|
||||
rlProgress.setVisibility(View.GONE);
|
||||
disableBack = "false";
|
||||
}
|
||||
|
||||
public void notif(String text) {
|
||||
rlnotif.setVisibility(View.VISIBLE);
|
||||
notif.setText(text);
|
||||
|
||||
new Handler().postDelayed(() -> rlnotif.setVisibility(View.GONE), 3000);
|
||||
}
|
||||
|
||||
private void trackTopUp() {
|
||||
SettingPreference sp = new SettingPreference(this);
|
||||
int harga = Integer.parseInt(sp.getSetting()[12]);
|
||||
int totalAmount = topUpDetailModel.getPhoneCreditPrice() + harga;
|
||||
MobilePulsaApiHelper.trackUserTopUp(String.valueOf(totalAmount), topUpDetailModel.getPhoneCreditOperator(), phoneNumber.getText().toString(),
|
||||
this, sp, new ApiListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
progressHide();
|
||||
final User user = BaseApp.getInstance(TopUpPulsaActivity.this).getLoginUser();
|
||||
Notif notif = new Notif();
|
||||
notif.title = "Topup";
|
||||
notif.message = "Permintaan pengisian telah berhasil.";
|
||||
sendNotif(user.getToken(), notif);
|
||||
new Handler().postDelayed(() -> {
|
||||
Intent intent = new Intent(TopUpPulsaActivity.this, MainActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
progressHide();
|
||||
notif("User error");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void requestTopUp() {
|
||||
progressShow();
|
||||
MobilePulsaApiHelper.topUpRequestToken(phoneNumber.getText().toString(), topUpDetailModel.getPhoneCreditCode(),
|
||||
sp).enqueue(new Callback<TopUpBaseResponse>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<TopUpBaseResponse> call, @NonNull Response<TopUpBaseResponse> response) {
|
||||
if (response.isSuccessful()) {
|
||||
if (response.body() != null) {
|
||||
trackTopUp();
|
||||
} else {
|
||||
progressHide();
|
||||
notif("error, silahkan cek data akun anda!");
|
||||
}
|
||||
} else {
|
||||
notif("error, silahkan cek data akun anda!");
|
||||
progressHide();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<TopUpBaseResponse> call, @NonNull Throwable t) {
|
||||
progressHide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void sendNotif(final String regIDTujuan, final Notif notif) {
|
||||
|
||||
final FCMMessage message = new FCMMessage();
|
||||
message.setTo(regIDTujuan);
|
||||
message.setData(notif);
|
||||
|
||||
FCMHelper.sendMessage(message).enqueue(new okhttp3.Callback() {
|
||||
@Override
|
||||
public void onResponse(@NonNull okhttp3.Call call, @NonNull okhttp3.Response response) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull okhttp3.Call call, @NonNull IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == ACTIVITY_RESULT && resultCode == RESULT_OK) {
|
||||
if (data != null) {
|
||||
topUpDetailModel = (MobileTopUpDetailResponseModel) data.getSerializableExtra(Constants.OPERATOR);
|
||||
if (topUpType == TopUpType.pulsa&&topUpDetailModel!=null && topUpDetailModel.getPhoneCreditDescription().matches("[0-9]+")) {
|
||||
Utility.currencyET(productTitle, topUpDetailModel != null ?
|
||||
topUpDetailModel.getPhoneCreditDescription() : "", this);
|
||||
} else {
|
||||
productTitle.setText(topUpDetailModel != null ?
|
||||
topUpDetailModel.getPhoneCreditDescription() : "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,291 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.cardview.widget.CardView;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.json.ResponseJson;
|
||||
import id.ontime.customer.json.WithdrawRequestJson;
|
||||
import id.ontime.customer.json.fcm.FCMMessage;
|
||||
import id.ontime.customer.models.Notif;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.utils.SettingPreference;
|
||||
import id.ontime.customer.utils.api.FCMHelper;
|
||||
import id.ontime.customer.utils.api.ServiceGenerator;
|
||||
import id.ontime.customer.utils.api.service.UserService;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Objects;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class TopupSaldoActivity extends AppCompatActivity {
|
||||
EditText nominal;
|
||||
CardView text1, text2, text3, text4, text5, text6;
|
||||
RelativeLayout rlnotif, rlprogress;
|
||||
TextView textnotif, privacy;
|
||||
String disableback;
|
||||
LinearLayout banktransfer, midtrans;
|
||||
Button whatsapp;
|
||||
SettingPreference sp;
|
||||
ImageView backBtn;
|
||||
boolean debug;
|
||||
private String paymentAmount;
|
||||
|
||||
public static String hashCal(String str) {
|
||||
byte[] hashseq = str.getBytes();
|
||||
StringBuilder hexString = new StringBuilder();
|
||||
try {
|
||||
MessageDigest algorithm = MessageDigest.getInstance("SHA-512");
|
||||
algorithm.reset();
|
||||
algorithm.update(hashseq);
|
||||
byte[] messageDigest = algorithm.digest();
|
||||
for (byte aMessageDigest : messageDigest) {
|
||||
String hex = Integer.toHexString(0xFF & aMessageDigest);
|
||||
if (hex.length() == 1) {
|
||||
hexString.append("0");
|
||||
}
|
||||
hexString.append(hex);
|
||||
}
|
||||
} catch (NoSuchAlgorithmException ignored) {
|
||||
}
|
||||
return hexString.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_topup);
|
||||
View bottom_sheet = findViewById(R.id.bottom_sheet);
|
||||
BottomSheetBehavior.from(bottom_sheet);
|
||||
sp = new SettingPreference(this);
|
||||
|
||||
nominal = findViewById(R.id.saldo);
|
||||
text1 = findViewById(R.id.text1);
|
||||
text2 = findViewById(R.id.text2);
|
||||
text3 = findViewById(R.id.text3);
|
||||
text4 = findViewById(R.id.text4);
|
||||
text5 = findViewById(R.id.text5);
|
||||
text6 = findViewById(R.id.text6);
|
||||
rlnotif = findViewById(R.id.rlnotif);
|
||||
textnotif = findViewById(R.id.textnotif);
|
||||
rlprogress = findViewById(R.id.rlprogress);
|
||||
backBtn = findViewById(R.id.back_btn);
|
||||
banktransfer = findViewById(R.id.banktransfer);
|
||||
midtrans = findViewById(R.id.midtrans);
|
||||
whatsapp = findViewById(R.id.whatsapp);
|
||||
privacy = findViewById(R.id.privacy);
|
||||
|
||||
|
||||
|
||||
banktransfer.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!nominal.getText().toString().isEmpty()) {
|
||||
Intent i = new Intent(TopupSaldoActivity.this, TopupviewActivity.class);
|
||||
i.putExtra("type", "topup");
|
||||
i.putExtra("nominal", convertAngka(nominal.getText().toString()));
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
} else {
|
||||
notif("Nominal tidak boleh kosong!");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Midtrans top-up flow removed: this button is disabled in this build.
|
||||
midtrans.setOnClickListener(v -> notif("Topup via Midtrans tidak tersedia di versi ini."));
|
||||
|
||||
whatsapp.setOnClickListener(v -> {
|
||||
Intent i = new Intent(TopupSaldoActivity.this, ConfirmWAActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
|
||||
});
|
||||
|
||||
privacy.setOnClickListener(v -> {
|
||||
Intent i = new Intent(TopupSaldoActivity.this, PrivacyActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
|
||||
});
|
||||
|
||||
|
||||
text1.setOnClickListener(new View.OnClickListener() {
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
nominal.setText("20.000");
|
||||
}
|
||||
});
|
||||
|
||||
text2.setOnClickListener(new View.OnClickListener() {
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
nominal.setText("50.000");
|
||||
}
|
||||
});
|
||||
|
||||
text3.setOnClickListener(new View.OnClickListener() {
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
nominal.setText("100.000");
|
||||
}
|
||||
});
|
||||
|
||||
text4.setOnClickListener(new View.OnClickListener() {
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
nominal.setText("200.000");
|
||||
}
|
||||
});
|
||||
|
||||
text5.setOnClickListener(new View.OnClickListener() {
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
nominal.setText("300.000");
|
||||
}
|
||||
});
|
||||
text6.setOnClickListener(new View.OnClickListener() {
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
nominal.setText("500.000");
|
||||
}
|
||||
});
|
||||
|
||||
backBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
disableback = "false";
|
||||
}
|
||||
|
||||
public void notif(String text) {
|
||||
rlnotif.setVisibility(View.VISIBLE);
|
||||
textnotif.setText(text);
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
rlnotif.setVisibility(View.GONE);
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (!disableback.equals("true")) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
public String convertAngka(String value) {
|
||||
return (((((value + "")
|
||||
.replaceAll(sp.getSetting()[0], ""))
|
||||
.replaceAll(" ", ""))
|
||||
.replaceAll(",", ""))
|
||||
.replaceAll("[$.]", ""));
|
||||
}
|
||||
|
||||
private void submit() {
|
||||
progressshow();
|
||||
paymentAmount = nominal.getText().toString();
|
||||
final User user = BaseApp.getInstance(this).getLoginUser();
|
||||
WithdrawRequestJson request = new WithdrawRequestJson();
|
||||
request.setId(user.getId());
|
||||
request.setBank("midtrans");
|
||||
request.setName(user.getFullnama());
|
||||
request.setAmount(convertAngka(paymentAmount.replace(sp.getSetting()[0], "")));
|
||||
request.setCard("1234");
|
||||
request.setNotelepon(user.getNoTelepon());
|
||||
request.setEmail(user.getEmail());
|
||||
|
||||
UserService service = ServiceGenerator.createService(UserService.class, user.getNoTelepon(), user.getPassword());
|
||||
service.withdraw(request).enqueue(new Callback<ResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<ResponseJson> call, @NonNull Response<ResponseJson> response) {
|
||||
progresshide();
|
||||
if (response.isSuccessful()) {
|
||||
if (Objects.requireNonNull(response.body()).getMessage().equalsIgnoreCase("success")) {
|
||||
Intent i = new Intent(TopupSaldoActivity.this, MainActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
|
||||
Notif notif = new Notif();
|
||||
notif.title = "Top up";
|
||||
notif.message = "Topup berhasil masuk";
|
||||
sendNotif(user.getToken(), notif);
|
||||
|
||||
} else {
|
||||
notif("Error, silahkan cek data akun Anda!");
|
||||
}
|
||||
} else {
|
||||
notif("Error!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<ResponseJson> call, @NonNull Throwable t) {
|
||||
progresshide();
|
||||
t.printStackTrace();
|
||||
notif("Error");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void progressshow() {
|
||||
rlprogress.setVisibility(View.VISIBLE);
|
||||
disableback = "true";
|
||||
}
|
||||
|
||||
public void progresshide() {
|
||||
rlprogress.setVisibility(View.GONE);
|
||||
disableback = "false";
|
||||
}
|
||||
|
||||
private void sendNotif(final String regIDTujuan, final Notif notif) {
|
||||
|
||||
final FCMMessage message = new FCMMessage();
|
||||
message.setTo(regIDTujuan);
|
||||
message.setData(notif);
|
||||
|
||||
FCMHelper.sendMessage(message).enqueue(new okhttp3.Callback() {
|
||||
@Override
|
||||
public void onResponse(@NonNull okhttp3.Call call, @NonNull okhttp3.Response response) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull okhttp3.Call call, @NonNull IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,255 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.item.BankItem;
|
||||
import id.ontime.customer.json.BankResponseJson;
|
||||
import id.ontime.customer.json.ResponseJson;
|
||||
import id.ontime.customer.json.WithdrawRequestJson;
|
||||
import id.ontime.customer.json.fcm.FCMMessage;
|
||||
import id.ontime.customer.models.Notif;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.utils.SettingPreference;
|
||||
import id.ontime.customer.utils.Utility;
|
||||
import id.ontime.customer.utils.api.FCMHelper;
|
||||
import id.ontime.customer.utils.api.ServiceGenerator;
|
||||
import id.ontime.customer.utils.api.service.UserService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class TopupviewActivity extends AppCompatActivity {
|
||||
|
||||
EditText jumlah, bankkamu, namaakun, norek;
|
||||
Button submit;
|
||||
TextView notif;
|
||||
ImageView backbtn, images;
|
||||
RelativeLayout rlnotif, rlprogress;
|
||||
String disableback, type, nominal;
|
||||
SettingPreference sp;
|
||||
RecyclerView petunjuk;
|
||||
LinearLayout llpentunjuk;
|
||||
BankItem bankItem;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_topupview);
|
||||
disableback = "false";
|
||||
jumlah = findViewById(R.id.jumlah);
|
||||
bankkamu = findViewById(R.id.bankkamu);
|
||||
norek = findViewById(R.id.norek);
|
||||
backbtn = findViewById(R.id.back_btn);
|
||||
submit = findViewById(R.id.submit);
|
||||
rlnotif = findViewById(R.id.rlnotif);
|
||||
notif = findViewById(R.id.textnotif);
|
||||
rlprogress = findViewById(R.id.rlprogress);
|
||||
namaakun = findViewById(R.id.namaakun);
|
||||
images = findViewById(R.id.imagebackground);
|
||||
sp = new SettingPreference(this);
|
||||
llpentunjuk = findViewById(R.id.llpentunjuk);
|
||||
petunjuk = findViewById(R.id.petunjuk);
|
||||
sp = new SettingPreference(this);
|
||||
|
||||
Intent intent = getIntent();
|
||||
type = intent.getStringExtra("type");
|
||||
|
||||
if (Objects.equals(type, "topup")) {
|
||||
images.setImageResource(R.drawable.atm);
|
||||
images.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
nominal = intent.getStringExtra("nominal");
|
||||
|
||||
Utility.currencyTXT(jumlah, Objects.requireNonNull(nominal), TopupviewActivity.this);
|
||||
petunjuk.setHasFixedSize(true);
|
||||
petunjuk.setNestedScrollingEnabled(false);
|
||||
petunjuk.setLayoutManager(new GridLayoutManager(this, 1));
|
||||
getpetunjuk();
|
||||
}
|
||||
|
||||
jumlah.addTextChangedListener(Utility.currencyTW(jumlah, this));
|
||||
|
||||
submit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
User userLogin = BaseApp.getInstance(TopupviewActivity.this).getLoginUser();
|
||||
if (type.equals("withdraw")) {
|
||||
if (jumlah.getText().toString().isEmpty()) {
|
||||
notif("nominal tidak boleh kosong!");
|
||||
} else if (Long.parseLong(jumlah.getText()
|
||||
.toString()
|
||||
.replace(".", "")
|
||||
.replace(",", "")
|
||||
.replace(sp.getSetting()[0], "")) > userLogin.getWalletSaldo()) {
|
||||
notif("saldo tidak cukup!");
|
||||
} else if (bankkamu.getText().toString().isEmpty()) {
|
||||
notif("bank tidak boleh kosong!");
|
||||
} else if (norek.getText().toString().isEmpty()) {
|
||||
notif("nomor tidak boleh kosong");
|
||||
} else {
|
||||
submit();
|
||||
}
|
||||
} else {
|
||||
if (jumlah.getText().toString().isEmpty()) {
|
||||
notif("jumlah tidak boleh kosong!");
|
||||
} else if (bankkamu.getText().toString().isEmpty()) {
|
||||
notif("bank tidak boleh kosong!");
|
||||
} else if (norek.getText().toString().isEmpty()) {
|
||||
notif("nomor tidak boleh kosong!");
|
||||
} else {
|
||||
submit();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
backbtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void submit() {
|
||||
progressshow();
|
||||
final User user = BaseApp.getInstance(this).getLoginUser();
|
||||
WithdrawRequestJson request = new WithdrawRequestJson();
|
||||
request.setId(user.getId());
|
||||
request.setBank(bankkamu.getText().toString());
|
||||
request.setName(namaakun.getText().toString());
|
||||
request.setAmount(jumlah.getText().toString().replace(".", "").replace(sp.getSetting()[0], ""));
|
||||
request.setCard(norek.getText().toString());
|
||||
request.setNotelepon(user.getNoTelepon());
|
||||
request.setEmail(user.getEmail());
|
||||
request.setType(type);
|
||||
|
||||
UserService service = ServiceGenerator.createService(UserService.class, user.getNoTelepon(), user.getPassword());
|
||||
service.withdraw(request).enqueue(new Callback<ResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<ResponseJson> call, @NonNull Response<ResponseJson> response) {
|
||||
progresshide();
|
||||
if (response.isSuccessful()) {
|
||||
if (Objects.requireNonNull(response.body()).getMessage().equalsIgnoreCase("success")) {
|
||||
Intent intent = new Intent(TopupviewActivity.this, MainActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
|
||||
Notif notif = new Notif();
|
||||
if (type.equals("withdraw")) {
|
||||
notif.title = "Pulsa";
|
||||
notif.message = "Permintaan penarikan telah berhasil, kami akan mengirimkan pemberitahuan setelah kami mengirim dana ke akun Anda";
|
||||
} else {
|
||||
notif.title = "Topup";
|
||||
notif.message = "Permintaan TopUp telah berhasil, Segera Transfer dan Konfirmasi Pembayaran ke Admin";
|
||||
}
|
||||
sendNotif(user.getToken(), notif);
|
||||
|
||||
} else {
|
||||
notif("error, silahkan cek data akun anda!");
|
||||
}
|
||||
} else {
|
||||
notif("error!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<ResponseJson> call, @NonNull Throwable t) {
|
||||
progresshide();
|
||||
t.printStackTrace();
|
||||
notif("error");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onBackPressed() {
|
||||
if (!disableback.equals("true")) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
public void notif(String text) {
|
||||
rlnotif.setVisibility(View.VISIBLE);
|
||||
notif.setText(text);
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
rlnotif.setVisibility(View.GONE);
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
public void progressshow() {
|
||||
rlprogress.setVisibility(View.VISIBLE);
|
||||
disableback = "true";
|
||||
}
|
||||
|
||||
public void progresshide() {
|
||||
rlprogress.setVisibility(View.GONE);
|
||||
disableback = "false";
|
||||
}
|
||||
|
||||
private void sendNotif(final String regIDTujuan, final Notif notif) {
|
||||
|
||||
final FCMMessage message = new FCMMessage();
|
||||
message.setTo(regIDTujuan);
|
||||
message.setData(notif);
|
||||
|
||||
FCMHelper.sendMessage(message).enqueue(new okhttp3.Callback() {
|
||||
@Override
|
||||
public void onResponse(@NonNull okhttp3.Call call, @NonNull okhttp3.Response response) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull okhttp3.Call call, @NonNull IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getpetunjuk() {
|
||||
User user = BaseApp.getInstance(this).getLoginUser();
|
||||
WithdrawRequestJson request = new WithdrawRequestJson();
|
||||
|
||||
UserService service = ServiceGenerator.createService(UserService.class, user.getNoTelepon(), user.getPassword());
|
||||
service.listbank(request).enqueue(new Callback<BankResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<BankResponseJson> call, @NonNull Response<BankResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
llpentunjuk.setVisibility(View.VISIBLE);
|
||||
bankItem = new BankItem(TopupviewActivity.this, Objects.requireNonNull(response.body()).getData(), R.layout.item_bank);
|
||||
petunjuk.setAdapter(bankItem);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<BankResponseJson> call, @NonNull Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.item.WalletItem;
|
||||
import id.ontime.customer.json.WalletRequestJson;
|
||||
import id.ontime.customer.json.WalletResponseJson;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.utils.api.ServiceGenerator;
|
||||
import id.ontime.customer.utils.api.service.UserService;
|
||||
import com.facebook.shimmer.ShimmerFrameLayout;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class WalletActivity extends AppCompatActivity {
|
||||
ImageView backbtn;
|
||||
ShimmerFrameLayout shimmer;
|
||||
RecyclerView recycle;
|
||||
WalletItem walletItem;
|
||||
RelativeLayout rlnodata;
|
||||
Button whatsapp;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_wallet);
|
||||
|
||||
shimmer = findViewById(R.id.shimmerwallet);
|
||||
recycle = findViewById(R.id.recycle);
|
||||
rlnodata = findViewById(R.id.rlnodata);
|
||||
backbtn = findViewById(R.id.back_btn);
|
||||
recycle.setHasFixedSize(true);
|
||||
recycle.setLayoutManager(new GridLayoutManager(this, 1));
|
||||
whatsapp = findViewById(R.id.whatsapp);
|
||||
|
||||
backbtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
whatsapp.setOnClickListener(v -> {
|
||||
Intent i = new Intent(WalletActivity.this, ConfirmWAActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
|
||||
});
|
||||
|
||||
getdatawallet();
|
||||
|
||||
}
|
||||
|
||||
private void shimmershow() {
|
||||
recycle.setVisibility(View.GONE);
|
||||
shimmer.setVisibility(View.VISIBLE);
|
||||
shimmer.startShimmerAnimation();
|
||||
}
|
||||
|
||||
private void shimmertutup() {
|
||||
|
||||
recycle.setVisibility(View.VISIBLE);
|
||||
shimmer.setVisibility(View.GONE);
|
||||
shimmer.stopShimmerAnimation();
|
||||
}
|
||||
|
||||
private void getdatawallet() {
|
||||
shimmershow();
|
||||
User loginUser = BaseApp.getInstance(this).getLoginUser();
|
||||
UserService userService = ServiceGenerator.createService(
|
||||
UserService.class, loginUser.getNoTelepon(), loginUser.getPassword());
|
||||
WalletRequestJson param = new WalletRequestJson();
|
||||
param.setId(loginUser.getId());
|
||||
userService.wallet(param).enqueue(new Callback<WalletResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<WalletResponseJson> call, @NonNull Response<WalletResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
shimmertutup();
|
||||
walletItem = new WalletItem(WalletActivity.this, Objects.requireNonNull(response.body()).getData(), R.layout.item_wallet);
|
||||
recycle.setAdapter(walletItem);
|
||||
if (response.body().getData().isEmpty()) {
|
||||
recycle.setVisibility(View.GONE);
|
||||
rlnodata.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
recycle.setVisibility(View.VISIBLE);
|
||||
rlnodata.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<WalletResponseJson> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
package id.ontime.customer.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.item.BankItem;
|
||||
import id.ontime.customer.json.BankResponseJson;
|
||||
import id.ontime.customer.json.ResponseJson;
|
||||
import id.ontime.customer.json.WithdrawRequestJson;
|
||||
import id.ontime.customer.json.fcm.FCMMessage;
|
||||
import id.ontime.customer.models.Notif;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.utils.SettingPreference;
|
||||
import id.ontime.customer.utils.Utility;
|
||||
import id.ontime.customer.utils.api.FCMHelper;
|
||||
import id.ontime.customer.utils.api.ServiceGenerator;
|
||||
import id.ontime.customer.utils.api.service.UserService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class WithdrawActivity extends AppCompatActivity {
|
||||
|
||||
EditText amount, bank, accnumber, nama;
|
||||
Button submit;
|
||||
TextView notif;
|
||||
ImageView backbtn, images;
|
||||
RelativeLayout rlnotif, rlprogress;
|
||||
String disableback, type, nominal;
|
||||
SettingPreference sp;
|
||||
RecyclerView petunjuk;
|
||||
LinearLayout llpentunjuk;
|
||||
BankItem bankItem;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_withdraw);
|
||||
disableback = "false";
|
||||
amount = findViewById(R.id.amount);
|
||||
bank = findViewById(R.id.bank);
|
||||
accnumber = findViewById(R.id.accnumber);
|
||||
backbtn = findViewById(R.id.back_btn);
|
||||
submit = findViewById(R.id.submit);
|
||||
rlnotif = findViewById(R.id.rlnotif);
|
||||
notif = findViewById(R.id.textnotif);
|
||||
rlprogress = findViewById(R.id.rlprogress);
|
||||
nama = findViewById(R.id.namanumber);
|
||||
images = findViewById(R.id.imagebackground);
|
||||
llpentunjuk = findViewById(R.id.llpentunjuk);
|
||||
petunjuk = findViewById(R.id.petunjuk);
|
||||
sp = new SettingPreference(this);
|
||||
|
||||
Intent intent = getIntent();
|
||||
type = intent.getStringExtra("type");
|
||||
|
||||
if (Objects.equals(type, "topup")) {
|
||||
images.setImageResource(R.drawable.atm);
|
||||
images.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||
nominal = intent.getStringExtra("nominal");
|
||||
|
||||
Utility.currencyTXT(amount, Objects.requireNonNull(nominal), WithdrawActivity.this);
|
||||
petunjuk.setHasFixedSize(true);
|
||||
petunjuk.setNestedScrollingEnabled(false);
|
||||
petunjuk.setLayoutManager(new GridLayoutManager(this, 1));
|
||||
getpetunjuk();
|
||||
}
|
||||
|
||||
amount.addTextChangedListener(Utility.currencyTW(amount, this));
|
||||
|
||||
submit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
User userLogin = BaseApp.getInstance(WithdrawActivity.this).getLoginUser();
|
||||
if (type.equals("withdraw")) {
|
||||
if (amount.getText().toString().isEmpty()) {
|
||||
notif("nominal tidak boleh kosong!");
|
||||
} else if (Long.parseLong(amount.getText()
|
||||
.toString()
|
||||
.replace(".", "")
|
||||
.replace(",", "")
|
||||
.replace(sp.getSetting()[0], "")) > userLogin.getWalletSaldo()) {
|
||||
notif("saldo tidak cukup!");
|
||||
} else if (bank.getText().toString().isEmpty()) {
|
||||
notif("bank tidak boleh kosong!");
|
||||
} else if (accnumber.getText().toString().isEmpty()) {
|
||||
notif("nomor tidak boleh kosong");
|
||||
} else {
|
||||
submit();
|
||||
}
|
||||
} else {
|
||||
if (amount.getText().toString().isEmpty()) {
|
||||
notif("jumlah tidak boleh kosong!");
|
||||
} else if (bank.getText().toString().isEmpty()) {
|
||||
notif("bank tidak boleh kosong!");
|
||||
} else if (accnumber.getText().toString().isEmpty()) {
|
||||
notif("nomor tidak boleh kosong!");
|
||||
} else {
|
||||
submit();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
backbtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void submit() {
|
||||
progressshow();
|
||||
final User user = BaseApp.getInstance(this).getLoginUser();
|
||||
WithdrawRequestJson request = new WithdrawRequestJson();
|
||||
request.setId(user.getId());
|
||||
request.setBank(bank.getText().toString());
|
||||
request.setName(nama.getText().toString());
|
||||
request.setAmount(amount.getText().toString().replace(".", "").replace(sp.getSetting()[0], ""));
|
||||
request.setCard(accnumber.getText().toString());
|
||||
request.setNotelepon(user.getNoTelepon());
|
||||
request.setEmail(user.getEmail());
|
||||
request.setType(type);
|
||||
|
||||
UserService service = ServiceGenerator.createService(UserService.class, user.getNoTelepon(), user.getPassword());
|
||||
service.withdraw(request).enqueue(new Callback<ResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<ResponseJson> call, @NonNull Response<ResponseJson> response) {
|
||||
progresshide();
|
||||
if (response.isSuccessful()) {
|
||||
if (Objects.requireNonNull(response.body()).getMessage().equalsIgnoreCase("success")) {
|
||||
Intent intent = new Intent(WithdrawActivity.this, MainActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
|
||||
Notif notif = new Notif();
|
||||
if (type.equals("withdraw")) {
|
||||
notif.title = "Pulsa";
|
||||
notif.message = "Permintaan pulsa telah berhasil, kami akan mengirimkan pemberitahuan setelah kami mengirim pulsa ke akun Anda";
|
||||
} else {
|
||||
notif.title = "Topup";
|
||||
notif.message = "Permintaan pengisian telah berhasil, kami akan mengirimkan pemberitahuan setelah kami mengkonfirmasi";
|
||||
}
|
||||
sendNotif(user.getToken(), notif);
|
||||
|
||||
} else {
|
||||
notif("error, silahkan cek data akun anda!");
|
||||
}
|
||||
} else {
|
||||
notif("error!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<ResponseJson> call, @NonNull Throwable t) {
|
||||
progresshide();
|
||||
t.printStackTrace();
|
||||
notif("error");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onBackPressed() {
|
||||
if (!disableback.equals("true")) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
public void notif(String text) {
|
||||
rlnotif.setVisibility(View.VISIBLE);
|
||||
notif.setText(text);
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
rlnotif.setVisibility(View.GONE);
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
public void progressshow() {
|
||||
rlprogress.setVisibility(View.VISIBLE);
|
||||
disableback = "true";
|
||||
}
|
||||
|
||||
public void progresshide() {
|
||||
rlprogress.setVisibility(View.GONE);
|
||||
disableback = "false";
|
||||
}
|
||||
|
||||
private void sendNotif(final String regIDTujuan, final Notif notif) {
|
||||
|
||||
final FCMMessage message = new FCMMessage();
|
||||
message.setTo(regIDTujuan);
|
||||
message.setData(notif);
|
||||
|
||||
FCMHelper.sendMessage(message).enqueue(new okhttp3.Callback() {
|
||||
@Override
|
||||
public void onResponse(@NonNull okhttp3.Call call, @NonNull okhttp3.Response response) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull okhttp3.Call call, @NonNull IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getpetunjuk() {
|
||||
User user = BaseApp.getInstance(this).getLoginUser();
|
||||
WithdrawRequestJson request = new WithdrawRequestJson();
|
||||
|
||||
UserService service = ServiceGenerator.createService(UserService.class, user.getNoTelepon(), user.getPassword());
|
||||
service.listbank(request).enqueue(new Callback<BankResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<BankResponseJson> call, @NonNull Response<BankResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
llpentunjuk.setVisibility(View.VISIBLE);
|
||||
bankItem = new BankItem(WithdrawActivity.this, Objects.requireNonNull(response.body()).getData(), R.layout.item_bank);
|
||||
petunjuk.setAdapter(bankItem);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<BankResponseJson> call, @NonNull Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package id.ontime.customer.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.models.city.Result;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
public class CityAdapter extends BaseAdapter {
|
||||
private Activity activity;
|
||||
private LayoutInflater inflater;
|
||||
private List<Result> movieItems;
|
||||
private ArrayList<Result> listlokasiasli;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new Inbox adapter.
|
||||
*
|
||||
* @param activity the activity
|
||||
* @param movieItems the movie items
|
||||
*/
|
||||
public CityAdapter(Activity activity, List<Result> movieItems) {
|
||||
this.activity = activity;
|
||||
this.movieItems = movieItems;
|
||||
|
||||
listlokasiasli = new ArrayList<Result>();
|
||||
listlokasiasli.addAll(movieItems);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return movieItems.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int location) {
|
||||
return movieItems.get(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
|
||||
if (inflater == null)
|
||||
inflater = (LayoutInflater) activity
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
if (convertView == null)
|
||||
convertView = inflater.inflate(R.layout.item_category, null);
|
||||
|
||||
TextView tv_category = (TextView) convertView.findViewById(R.id.tv_category);
|
||||
TextView tv_detail = (TextView) convertView.findViewById(R.id.tv_detail);
|
||||
|
||||
Result m = movieItems.get(position);
|
||||
|
||||
tv_category.setText(m.getCityName());
|
||||
tv_detail.setText(m.getCityId());
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
public void filter(String charText)
|
||||
{
|
||||
charText = charText.toLowerCase();
|
||||
|
||||
movieItems.clear();
|
||||
if (charText.length() == 0) {
|
||||
/* tampilkan seluruh data */
|
||||
movieItems.addAll(listlokasiasli);
|
||||
|
||||
} else {
|
||||
for (Result lok : listlokasiasli) {
|
||||
if (lok.getCityName().toLowerCase().contains(charText)) {
|
||||
movieItems.add(lok);
|
||||
} else {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setList(List<Result> movieItems){
|
||||
this.listlokasiasli.addAll(movieItems);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package id.ontime.customer.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.models.expedisi.ItemExpedisi;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
public class ExpedisiAdapter extends BaseAdapter {
|
||||
private Activity activity;
|
||||
private LayoutInflater inflater;
|
||||
private List<ItemExpedisi> movieItems;
|
||||
private ArrayList<ItemExpedisi> listlokasiasli;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new Inbox adapter.
|
||||
*
|
||||
* @param activity the activity
|
||||
* @param movieItems the movie items
|
||||
*/
|
||||
public ExpedisiAdapter(Activity activity, List<ItemExpedisi> movieItems) {
|
||||
this.activity = activity;
|
||||
this.movieItems = movieItems;
|
||||
|
||||
listlokasiasli = new ArrayList<ItemExpedisi>();
|
||||
listlokasiasli.addAll(movieItems);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return movieItems.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int location) {
|
||||
return movieItems.get(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
|
||||
if (inflater == null)
|
||||
inflater = (LayoutInflater) activity
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
if (convertView == null)
|
||||
convertView = inflater.inflate(R.layout.item_category, null);
|
||||
|
||||
TextView tv_category = (TextView) convertView.findViewById(R.id.tv_category);
|
||||
TextView tv_detail = (TextView) convertView.findViewById(R.id.tv_detail);
|
||||
|
||||
ItemExpedisi m = movieItems.get(position);
|
||||
|
||||
tv_category.setText(m.getName());
|
||||
tv_detail.setText(m.getId());
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
public void filter(String charText)
|
||||
{
|
||||
charText = charText.toLowerCase();
|
||||
|
||||
movieItems.clear();
|
||||
if (charText.length() == 0) {
|
||||
/* tampilkan seluruh data */
|
||||
movieItems.addAll(listlokasiasli);
|
||||
|
||||
} else {
|
||||
for (ItemExpedisi lok : listlokasiasli) {
|
||||
if (lok.getName().toLowerCase().contains(charText)) {
|
||||
movieItems.add(lok);
|
||||
} else {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setList(List<ItemExpedisi> movieItems){
|
||||
this.listlokasiasli.addAll(movieItems);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package id.ontime.customer.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.models.province.Result;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
public class ProvinceAdapter extends BaseAdapter {
|
||||
private Activity activity;
|
||||
private LayoutInflater inflater;
|
||||
private List<Result> movieItems;
|
||||
private ArrayList<Result> listlokasiasli;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new Inbox adapter.
|
||||
*
|
||||
* @param activity the activity
|
||||
* @param movieItems the movie items
|
||||
*/
|
||||
public ProvinceAdapter(Activity activity, List<Result> movieItems) {
|
||||
this.activity = activity;
|
||||
this.movieItems = movieItems;
|
||||
|
||||
listlokasiasli = new ArrayList<Result>();
|
||||
listlokasiasli.addAll(movieItems);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return movieItems.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int location) {
|
||||
return movieItems.get(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
|
||||
if (inflater == null)
|
||||
inflater = (LayoutInflater) activity
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
if (convertView == null)
|
||||
convertView = inflater.inflate(R.layout.item_category, null);
|
||||
|
||||
TextView tv_category = (TextView) convertView.findViewById(R.id.tv_category);
|
||||
TextView tv_detail = (TextView) convertView.findViewById(R.id.tv_detail);
|
||||
|
||||
Result m = movieItems.get(position);
|
||||
|
||||
tv_category.setText(m.getProvince());
|
||||
tv_detail.setText(m.getProvinceId());
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
public void filter(String charText)
|
||||
{
|
||||
charText = charText.toLowerCase();
|
||||
|
||||
movieItems.clear();
|
||||
if (charText.length() == 0) {
|
||||
/* tampilkan seluruh data */
|
||||
movieItems.addAll(listlokasiasli);
|
||||
|
||||
} else {
|
||||
for (Result lok : listlokasiasli) {
|
||||
if (lok.getProvince().toLowerCase().contains(charText)) {
|
||||
movieItems.add(lok);
|
||||
} else {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setList(List<Result> movieItems){
|
||||
this.listlokasiasli.addAll(movieItems);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package id.ontime.customer.api;
|
||||
|
||||
|
||||
|
||||
import id.ontime.customer.models.city.ItemCity;
|
||||
import id.ontime.customer.models.cost.ItemCost;
|
||||
import id.ontime.customer.models.province.ItemProvince;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Headers;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface ApiService {
|
||||
|
||||
// Province
|
||||
@GET("province")
|
||||
@Headers("key:2c1cf2e4614041e9e929dbee9b2ccfd1")
|
||||
Call<ItemProvince> getProvince();
|
||||
|
||||
// City
|
||||
@GET("city")
|
||||
@Headers("key:2c1cf2e4614041e9e929dbee9b2ccfd1")
|
||||
Call<ItemCity> getCity(@Query("province") String province);
|
||||
|
||||
// Cost
|
||||
@FormUrlEncoded
|
||||
@POST("cost")
|
||||
Call<ItemCost> getCost(@Field("key") String Token,
|
||||
@Field("origin") String origin,
|
||||
@Field("destination") String destination,
|
||||
@Field("weight") String weight,
|
||||
@Field("courier") String courier);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package id.ontime.customer.api;
|
||||
|
||||
|
||||
|
||||
public class ApiUrl {
|
||||
|
||||
public static final String URL_ROOT_HTTPS = "https://api.rajaongkir.com/starter/";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package id.ontime.customer.constants;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.multidex.MultiDex;
|
||||
|
||||
import id.ontime.customer.models.FirebaseToken;
|
||||
import id.ontime.customer.models.User;
|
||||
import com.google.firebase.FirebaseApp;
|
||||
import com.google.firebase.iid.FirebaseInstanceId;
|
||||
import com.google.firebase.messaging.FirebaseMessaging;
|
||||
|
||||
import io.realm.Realm;
|
||||
import io.realm.RealmConfiguration;
|
||||
|
||||
|
||||
public class BaseApp extends Application {
|
||||
|
||||
private static final int SCHEMA_VERSION = 0;
|
||||
|
||||
private User loginUser;
|
||||
|
||||
private Realm realmInstance;
|
||||
|
||||
public static BaseApp getInstance(Context context) {
|
||||
return (BaseApp) context.getApplicationContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
Realm.init(this);
|
||||
RealmConfiguration config = new RealmConfiguration.Builder()
|
||||
.schemaVersion(SCHEMA_VERSION)
|
||||
.deleteRealmIfMigrationNeeded()
|
||||
.build();
|
||||
|
||||
Realm.setDefaultConfiguration(config);
|
||||
|
||||
// realmInstance = Realm.getInstance(config);
|
||||
realmInstance = Realm.getDefaultInstance();
|
||||
|
||||
// Best-effort Firebase initialization and token registration.
|
||||
// If Firebase is not configured for this build, ignore failures so the app can still run.
|
||||
try {
|
||||
FirebaseApp app = FirebaseApp.initializeApp(this);
|
||||
if (app != null) {
|
||||
String fcmToken = FirebaseInstanceId.getInstance().getToken();
|
||||
if (fcmToken != null) {
|
||||
FirebaseToken token = new FirebaseToken(fcmToken);
|
||||
FirebaseMessaging.getInstance().subscribeToTopic("pelanggan");
|
||||
|
||||
realmInstance.beginTransaction();
|
||||
realmInstance.delete(FirebaseToken.class);
|
||||
realmInstance.copyToRealm(token);
|
||||
realmInstance.commitTransaction();
|
||||
}
|
||||
}
|
||||
} catch (IllegalStateException e) {
|
||||
// Firebase not initialized / misconfigured for this build; skip FCM registration in debug.
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
start();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
super.attachBaseContext(base);
|
||||
MultiDex.install(this);
|
||||
}
|
||||
|
||||
public User getLoginUser() {
|
||||
try {
|
||||
if (loginUser == null) {
|
||||
start();
|
||||
}
|
||||
return loginUser;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return loginUser;
|
||||
}
|
||||
|
||||
public void setLoginUser(User loginUser) {
|
||||
this.loginUser = loginUser;
|
||||
}
|
||||
|
||||
public final Realm getRealmInstance() {
|
||||
return realmInstance;
|
||||
}
|
||||
|
||||
private void start() {
|
||||
Realm realm = getRealmInstance();
|
||||
User user = realm.where(User.class).findFirst();
|
||||
if (user != null) {
|
||||
setLoginUser(user);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package id.ontime.customer.constants;
|
||||
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
public class Constants {
|
||||
|
||||
private static final String BASE_URL = "https://apitest.semestaterpadu.my.id/";
|
||||
public static final String URL = "https://panic.on-time.id/"; //panicButton
|
||||
public static final String CONNECTION = BASE_URL + "api/";
|
||||
public static final String IMAGESFITUR = BASE_URL + "images/fitur/";
|
||||
public static final String IMAGESMERCHANT = BASE_URL + "images/merchant/";
|
||||
public static final String IMAGESBANK = BASE_URL + "images/bank/";
|
||||
public static final String IMAGESITEM = BASE_URL + "images/itemmerchant/";
|
||||
public static final String IMAGESBERITA = BASE_URL + "images/berita/";
|
||||
public static final String IMAGESSLIDER = BASE_URL + "images/promo/";
|
||||
public static final String IMAGESDRIVER = BASE_URL + "images/fotodriver/";
|
||||
public static final String IMAGESUSER = BASE_URL + "images/pelanggan/";
|
||||
public static final int REJECT = 0;
|
||||
public static final int ACCEPT = 2;
|
||||
public static final int CANCEL = 5;
|
||||
public static final int START = 3;
|
||||
public static final int FINISH = 4;
|
||||
public static String CURRENCY = "";
|
||||
public static Double LATITUDE;
|
||||
public static Double LONGITUDE;
|
||||
public static String LOCATION;
|
||||
|
||||
public static String TOKEN = "token";
|
||||
|
||||
public static String USERID = "uid";
|
||||
|
||||
public static String PREF_NAME = "pref_name";
|
||||
|
||||
public static int permission_camera_code = 786;
|
||||
public static int permission_write_data = 788;
|
||||
public static int permission_Read_data = 789;
|
||||
public static int permission_Recording_audio = 790;
|
||||
|
||||
public static SimpleDateFormat df =
|
||||
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH);
|
||||
public static String versionname = "1.0";
|
||||
|
||||
public static String OPERATOR = "OPERATOR_LIST";
|
||||
public static String MOBILEPULSA_PRODUCTION_URL = "https://api.mobilepulsa.net/v1/legacy/index";
|
||||
//public static String MOBILEPULSA_DEV_URL = "https://testprepaid.mobilepulsa.net/v1/legacy/index";
|
||||
|
||||
//public static String XENDITAPIKEY = "UkFKQU1BU1RFUlNFUlZFUg==";
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package id.ontime.customer.constants;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
public class Functions {
|
||||
|
||||
public static void hideSoftKeyboard(Activity activity) {
|
||||
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
|
||||
View view = activity.getCurrentFocus();
|
||||
if (view == null) {
|
||||
view = new View(activity);
|
||||
}
|
||||
Objects.requireNonNull(imm).hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package id.ontime.customer.constants;
|
||||
|
||||
public enum TopUpType {pulsa, data}
|
||||
@@ -0,0 +1,83 @@
|
||||
package id.ontime.customer.constants;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.utils.Log;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
public class VersionChecker extends AsyncTask<String, String, String> {
|
||||
|
||||
private String newVersion;
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private Activity context;
|
||||
|
||||
public VersionChecker(Activity context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String doInBackground(String... params) {
|
||||
|
||||
try {
|
||||
newVersion = Jsoup.connect("https://play.google.com/store/apps/details?id=" + context.getPackageName() + "&hl=en")
|
||||
.timeout(30000)
|
||||
.userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
|
||||
.referrer("http://www.google.com")
|
||||
.get()
|
||||
.select(".IQ1z0d .htlgb")
|
||||
.get(7)
|
||||
.ownText();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return newVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String s) {
|
||||
super.onPostExecute(s);
|
||||
PackageInfo pInfo = null;
|
||||
try {
|
||||
pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (newVersion != null) {
|
||||
int latestVersion = Integer.parseInt(newVersion.replace(".", ""));
|
||||
int versionCode = Integer.parseInt(Objects.requireNonNull(pInfo).versionName.replace(".", ""));
|
||||
Log.e("", newVersion);
|
||||
if (versionCode < latestVersion) {
|
||||
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(context, R.style.DialogStyle);
|
||||
alert.setTitle(R.string.app_name)
|
||||
.setIcon(R.mipmap.ic_launcher)
|
||||
.setMessage("Silahkan update" + " " + context.getString(R.string.app_name) + " " + "aplikasi. Anda memiliki versi lama.")
|
||||
.setNegativeButton("Update", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + context.getPackageName())));
|
||||
context.finish();
|
||||
}
|
||||
});
|
||||
|
||||
alert.setCancelable(false);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
package id.ontime.customer.fragment;
|
||||
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.Address;
|
||||
import android.location.Geocoder;
|
||||
import android.location.Location;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.activity.IntroActivity;
|
||||
import id.ontime.customer.activity.MainActivity;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.models.User;
|
||||
import com.google.android.gms.location.FusedLocationProviderClient;
|
||||
import com.google.android.gms.location.LocationServices;
|
||||
import com.google.android.gms.tasks.OnSuccessListener;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
||||
|
||||
public class EnableLlocationFragment extends Fragment {
|
||||
|
||||
|
||||
private Context context;
|
||||
private SharedPreferences sharedPreferences;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View getView = inflater.inflate(R.layout.fragment_enablelocation, container, false);
|
||||
context = getContext();
|
||||
|
||||
|
||||
sharedPreferences = requireContext().getSharedPreferences(Constants.PREF_NAME, MODE_PRIVATE);
|
||||
|
||||
Button enableLocation = getView.findViewById(R.id.enable_location_btn);
|
||||
enableLocation.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
getLocationPermission();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return getView;
|
||||
}
|
||||
|
||||
private void getLocationPermission() {
|
||||
|
||||
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION},
|
||||
123);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
|
||||
if (requestCode == 123) {
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
GetCurrentlocation();
|
||||
} else {
|
||||
Toast.makeText(context, "Iinkan aplikasi", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void GPSStatus() {
|
||||
LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
||||
boolean GpsStatus = Objects.requireNonNull(locationManager).isProviderEnabled(LocationManager.GPS_PROVIDER);
|
||||
if (!GpsStatus) {
|
||||
Toast.makeText(context, "Nyalakan akurasi tinggi maps", Toast.LENGTH_SHORT).show();
|
||||
startActivityForResult(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS), 2);
|
||||
} else {
|
||||
GetCurrentlocation();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == 2) {
|
||||
GPSStatus();
|
||||
}
|
||||
}
|
||||
|
||||
private void GetCurrentlocation() {
|
||||
FusedLocationProviderClient mFusedLocationClient = LocationServices.getFusedLocationProviderClient(context);
|
||||
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
|
||||
getLocationPermission();
|
||||
return;
|
||||
}
|
||||
|
||||
mFusedLocationClient.getLastLocation()
|
||||
.addOnSuccessListener(requireActivity(), new OnSuccessListener<Location>() {
|
||||
@Override
|
||||
public void onSuccess(Location location) {
|
||||
if (location != null) {
|
||||
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString(String.valueOf(Constants.LATITUDE), "" + location.getLatitude());
|
||||
editor.putString(String.valueOf(Constants.LONGITUDE), "" + location.getLongitude());
|
||||
editor.apply();
|
||||
Constants.LATITUDE = location.getLatitude();
|
||||
Constants.LONGITUDE = location.getLongitude();
|
||||
try {
|
||||
Geocoder geocoder = new Geocoder(getActivity(), Locale.getDefault());
|
||||
final List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1);
|
||||
if (!addresses.isEmpty()) {
|
||||
addresses.size();
|
||||
String address = addresses.get(0).getAddressLine(0);
|
||||
Constants.LOCATION = String.valueOf(address);
|
||||
} else {
|
||||
Constants.LOCATION = "tidak tersedia";
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
GoToNext_Activty();
|
||||
|
||||
} else {
|
||||
|
||||
if (sharedPreferences.getString(String.valueOf(Constants.LATITUDE), "").equals("") || sharedPreferences.getString(String.valueOf(Constants.LONGITUDE), "").equals("")) {
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString(String.valueOf(Constants.LATITUDE), "33.738045");
|
||||
editor.putString(String.valueOf(Constants.LONGITUDE), "73.084488");
|
||||
editor.apply();
|
||||
|
||||
}
|
||||
|
||||
GoToNext_Activty();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void GoToNext_Activty() {
|
||||
final User user = BaseApp.getInstance(context).getLoginUser();
|
||||
if (user != null) {
|
||||
Intent intent = new Intent(getActivity(), MainActivity.class);
|
||||
startActivity(intent);
|
||||
requireActivity().finish();
|
||||
} else {
|
||||
Intent intent = new Intent(getActivity(), IntroActivity.class);
|
||||
startActivity(intent);
|
||||
requireActivity().finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package id.ontime.customer.fragment;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.item.FavouriteItem;
|
||||
import id.ontime.customer.models.FavouriteModel;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.utils.DatabaseHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public class FavouriteFragment extends Fragment {
|
||||
|
||||
|
||||
private Context context;
|
||||
private ArrayList<FavouriteModel> listItem;
|
||||
private RecyclerView recyclerView;
|
||||
private DatabaseHelper databaseHelper;
|
||||
private RelativeLayout notFound;
|
||||
|
||||
@Override
|
||||
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View getView = inflater.inflate(R.layout.fragment_recycle, container, false);
|
||||
context = getContext();
|
||||
listItem = new ArrayList<>();
|
||||
databaseHelper = new DatabaseHelper(getActivity());
|
||||
notFound = getView.findViewById(R.id.rlnodata);
|
||||
recyclerView = getView.findViewById(R.id.inboxlist);
|
||||
|
||||
recyclerView.setHasFixedSize(true);
|
||||
recyclerView.setNestedScrollingEnabled(false);
|
||||
recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 1));
|
||||
|
||||
|
||||
return getView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
User loginUser = BaseApp.getInstance(context).getLoginUser();
|
||||
if (databaseHelper.getFavouriteByMyid(loginUser.getId())) {
|
||||
listItem = databaseHelper.getFavourite();
|
||||
}
|
||||
displayData();
|
||||
}
|
||||
|
||||
private void displayData() {
|
||||
FavouriteItem adapter = new FavouriteItem(getActivity(), listItem, R.layout.item_grid_full);
|
||||
recyclerView.setAdapter(adapter);
|
||||
if (adapter.getItemCount() == 0) {
|
||||
notFound.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
notFound.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
package id.ontime.customer.fragment;
|
||||
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.utils.PicassoTrustAll;
|
||||
import com.squareup.picasso.Callback;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class FullImageFragment extends Fragment {
|
||||
|
||||
private Context context;
|
||||
|
||||
private String chat_id;
|
||||
private ProgressBar progressBar;
|
||||
private ProgressDialog progressDialog;
|
||||
private File fullpath;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View getView = inflater.inflate(R.layout.fragment_fullimage, container, false);
|
||||
context = getContext();
|
||||
|
||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
requireActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
String imageUrl = requireArguments().getString("image_url");
|
||||
chat_id = getArguments().getString("chat_id");
|
||||
Button savebtn2 = getView.findViewById(R.id.savebtn2);
|
||||
|
||||
ImageView closeGallery = getView.findViewById(R.id.close_gallery);
|
||||
closeGallery.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
requireActivity().onBackPressed();
|
||||
}
|
||||
});
|
||||
|
||||
progressDialog = new ProgressDialog(context, R.style.DialogStyle);
|
||||
progressDialog.setMessage("Mohon tunggu");
|
||||
|
||||
fullpath = new File(Environment.getExternalStorageDirectory() + "/ontime/" + chat_id + ".jpg");
|
||||
|
||||
Button savebtn = getView.findViewById(R.id.savebtn);
|
||||
if (fullpath.exists()) {
|
||||
savebtn.setVisibility(View.GONE);
|
||||
savebtn2.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
savebtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Savepicture(false);
|
||||
}
|
||||
});
|
||||
progressBar = getView.findViewById(R.id.progress);
|
||||
ImageView singleImage = getView.findViewById(R.id.single_image);
|
||||
|
||||
if (fullpath.exists()) {
|
||||
Uri uri = Uri.parse(fullpath.getAbsolutePath());
|
||||
singleImage.setImageURI(uri);
|
||||
} else {
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
PicassoTrustAll.getInstance(context).load(imageUrl).placeholder(R.drawable.image_placeholder)
|
||||
.into(singleImage, new Callback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ImageButton sharebtn = getView.findViewById(R.id.sharebtn);
|
||||
sharebtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
SharePicture();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return getView;
|
||||
}
|
||||
|
||||
private void SharePicture() {
|
||||
if (Checkstoragepermision()) {
|
||||
Uri bitmapuri;
|
||||
if (fullpath.exists()) {
|
||||
bitmapuri = Uri.parse(fullpath.getAbsolutePath());
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
intent.setType("image/png");
|
||||
intent.putExtra(Intent.EXTRA_STREAM, bitmapuri);
|
||||
startActivity(Intent.createChooser(intent, ""));
|
||||
} else {
|
||||
Savepicture(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void Savepicture(final boolean isfromshare) {
|
||||
// Download/save implementation removed with PRDownloader; just notify user.
|
||||
progressDialog.show();
|
||||
progressDialog.dismiss();
|
||||
Toast.makeText(context, "Simpan gambar tidak tersedia di versi ini.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
Toast.makeText(context, "Tekan lagi", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean Checkstoragepermision() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (context.checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
== PackageManager.PERMISSION_GRANTED) {
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
||||
requestPermissions(new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
package id.ontime.customer.fragment;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.item.HistoryItem;
|
||||
import id.ontime.customer.json.AllTransResponseJson;
|
||||
import id.ontime.customer.json.DetailRequestJson;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.utils.api.ServiceGenerator;
|
||||
import id.ontime.customer.utils.api.service.UserService;
|
||||
import com.facebook.shimmer.ShimmerFrameLayout;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
|
||||
public class HistoryFragment extends Fragment {
|
||||
|
||||
|
||||
private Context context;
|
||||
private ShimmerFrameLayout shimmer;
|
||||
private RecyclerView recycle;
|
||||
private HistoryItem historyItem;
|
||||
private RelativeLayout rlnodata;
|
||||
|
||||
@Override
|
||||
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View getView = inflater.inflate(R.layout.fragment_recycle, container, false);
|
||||
context = getContext();
|
||||
shimmer = getView.findViewById(R.id.shimmerwallet);
|
||||
recycle = getView.findViewById(R.id.inboxlist);
|
||||
rlnodata = getView.findViewById(R.id.rlnodata);
|
||||
|
||||
recycle.setHasFixedSize(true);
|
||||
recycle.setLayoutManager(new GridLayoutManager(context, 1));
|
||||
|
||||
return getView;
|
||||
}
|
||||
|
||||
private void shimmershow() {
|
||||
recycle.setVisibility(View.GONE);
|
||||
shimmer.setVisibility(View.VISIBLE);
|
||||
shimmer.startShimmerAnimation();
|
||||
}
|
||||
|
||||
private void shimmertutup() {
|
||||
|
||||
recycle.setVisibility(View.VISIBLE);
|
||||
shimmer.setVisibility(View.GONE);
|
||||
shimmer.stopShimmerAnimation();
|
||||
}
|
||||
|
||||
private void getdatatrans() {
|
||||
shimmershow();
|
||||
User loginUser = BaseApp.getInstance(context).getLoginUser();
|
||||
UserService userService = ServiceGenerator.createService(
|
||||
UserService.class, loginUser.getNoTelepon(), loginUser.getPassword());
|
||||
DetailRequestJson param = new DetailRequestJson();
|
||||
param.setId(loginUser.getId());
|
||||
userService.history(param).enqueue(new Callback<AllTransResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<AllTransResponseJson> call, @NonNull Response<AllTransResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
shimmertutup();
|
||||
historyItem = new HistoryItem(context, Objects.requireNonNull(response.body()).getData(), R.layout.item_order);
|
||||
recycle.setAdapter(historyItem);
|
||||
if (response.body().getData().isEmpty()) {
|
||||
recycle.setVisibility(View.GONE);
|
||||
rlnodata.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
recycle.setVisibility(View.VISIBLE);
|
||||
rlnodata.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<AllTransResponseJson> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getdatatrans();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,642 @@
|
||||
package id.ontime.customer.fragment;
|
||||
|
||||
import android.animation.ArgbEvaluator;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.location.Location;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import java.util.Calendar;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.activity.AllBeritaActivity;
|
||||
import id.ontime.customer.activity.IntroActivity;
|
||||
import id.ontime.customer.activity.PromoActivity;
|
||||
import id.ontime.customer.activity.TopupSaldoActivity;
|
||||
import id.ontime.customer.activity.WalletActivity;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.item.AllFiturItem;
|
||||
import id.ontime.customer.item.BeritaItem;
|
||||
import id.ontime.customer.item.CatMerchantItem;
|
||||
import id.ontime.customer.item.CatMerchantNearItem;
|
||||
import id.ontime.customer.item.FiturItem;
|
||||
import id.ontime.customer.item.MerchantItem;
|
||||
import id.ontime.customer.item.MerchantNearItem;
|
||||
import id.ontime.customer.item.SliderItem;
|
||||
import id.ontime.customer.json.GetHomeRequestJson;
|
||||
import id.ontime.customer.json.GetHomeResponseJson;
|
||||
import id.ontime.customer.json.GetMerchantbyCatRequestJson;
|
||||
import id.ontime.customer.json.MerchantByCatResponseJson;
|
||||
import id.ontime.customer.json.MerchantByNearResponseJson;
|
||||
import id.ontime.customer.models.AllFiturModel;
|
||||
import id.ontime.customer.models.CatMerchantModel;
|
||||
import id.ontime.customer.models.FiturDataModel;
|
||||
import id.ontime.customer.models.FiturModel;
|
||||
import id.ontime.customer.models.MerchantModel;
|
||||
import id.ontime.customer.models.MerchantNearModel;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.utils.Log;
|
||||
import id.ontime.customer.utils.SettingPreference;
|
||||
import id.ontime.customer.utils.Utility;
|
||||
import id.ontime.customer.utils.api.ServiceGenerator;
|
||||
import id.ontime.customer.utils.api.service.UserService;
|
||||
import com.facebook.shimmer.ShimmerFrameLayout;
|
||||
import com.google.android.gms.location.FusedLocationProviderClient;
|
||||
import com.google.android.gms.location.LocationServices;
|
||||
import com.google.android.gms.tasks.OnCompleteListener;
|
||||
import com.google.android.gms.tasks.OnSuccessListener;
|
||||
import com.google.android.gms.tasks.Task;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import io.realm.Realm;
|
||||
import me.relex.circleindicator.CircleIndicator;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class HomeFragment extends Fragment {
|
||||
|
||||
TextView greetings;
|
||||
private Context context;
|
||||
private ViewPager viewPager;
|
||||
private SliderItem adapter;
|
||||
private Integer[] colors = null;
|
||||
private ArgbEvaluator argbEvaluator = new ArgbEvaluator();
|
||||
private CircleIndicator circleIndicator;
|
||||
private RecyclerView rvCategory, rvberita, rvmerchant, rvcatmerchantpromo, rvcatmerchantnear, rvmerchantnear;
|
||||
private LinearLayout llslider, promoslider, llberita, llmerchant, llmerchantnear, shimlistpromo, shimlistcatpromo, shimlistnear, shimlistcatnear;
|
||||
private FiturItem fiturItem;
|
||||
private BeritaItem beritaItem;
|
||||
private MerchantItem merchantItem;
|
||||
private MerchantNearItem merchantNearItem;
|
||||
private CatMerchantNearItem catMerchantNearItem;
|
||||
private CatMerchantItem catMerchantItem;
|
||||
private ShimmerFrameLayout mShimmerCat, shimerPromo, shimberita, shimmerchantpromo, getShimmerchantnear;
|
||||
private TextView saldo, nama;
|
||||
private TextView nodatapromo;
|
||||
private TextView nodatanear;
|
||||
private SettingPreference sp;
|
||||
private List<MerchantModel> click;
|
||||
private List<MerchantNearModel> clicknear;
|
||||
private ArrayList<FiturDataModel> fiturlist;
|
||||
private List<FiturModel> fiturdata;
|
||||
private List<AllFiturModel> allfiturdata;
|
||||
private BottomSheetBehavior mBehavior;
|
||||
private BottomSheetDialog mBottomSheetDialog;
|
||||
ImageView banner;
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View getView = inflater.inflate(R.layout.fragment_home, container, false);
|
||||
context = getContext();
|
||||
View bottom_sheet = getView.findViewById(R.id.bottom_sheet);
|
||||
mBehavior = BottomSheetBehavior.from(bottom_sheet);
|
||||
viewPager = getView.findViewById(R.id.viewPager);
|
||||
circleIndicator = getView.findViewById(R.id.indicator_unselected_background);
|
||||
viewPager = getView.findViewById(R.id.viewPager);
|
||||
rvCategory = getView.findViewById(R.id.category);
|
||||
rvberita = getView.findViewById(R.id.berita);
|
||||
rvmerchant = getView.findViewById(R.id.merchantpromo);
|
||||
rvcatmerchantpromo = getView.findViewById(R.id.catmerchantpromo);
|
||||
rvcatmerchantnear = getView.findViewById(R.id.catmerchantnear);
|
||||
promoslider = getView.findViewById(R.id.rlslider);
|
||||
llslider = getView.findViewById(R.id.promoslider);
|
||||
saldo = getView.findViewById(R.id.saldo);
|
||||
nama = getView.findViewById(R.id.nama);
|
||||
greetings = getView.findViewById(R.id.greetings);
|
||||
banner = getView.findViewById(R.id.banner);
|
||||
RelativeLayout topup = getView.findViewById(R.id.topup);
|
||||
RelativeLayout detail = getView.findViewById(R.id.detail);
|
||||
llberita = getView.findViewById(R.id.llnews);
|
||||
llmerchant = getView.findViewById(R.id.llmerchantpromo);
|
||||
llmerchantnear = getView.findViewById(R.id.llmerchantnear);
|
||||
TextView showall = getView.findViewById(R.id.showall);
|
||||
shimlistpromo = getView.findViewById(R.id.shimlistpromo);
|
||||
shimlistnear = getView.findViewById(R.id.shimlistnear);
|
||||
nodatapromo = getView.findViewById(R.id.nodatapromo);
|
||||
shimlistcatpromo = getView.findViewById(R.id.shimlistcatpromo);
|
||||
shimlistcatnear = getView.findViewById(R.id.shimlistcatnear);
|
||||
rvcatmerchantnear = getView.findViewById(R.id.catmerchantnear);
|
||||
rvmerchantnear = getView.findViewById(R.id.merchantnear);
|
||||
nodatanear = getView.findViewById(R.id.nodatanear);
|
||||
sp = new SettingPreference(context);
|
||||
RelativeLayout promo = getView.findViewById(R.id.promo);
|
||||
fiturlist = new ArrayList<>();
|
||||
|
||||
|
||||
mShimmerCat = getView.findViewById(R.id.shimmercat);
|
||||
shimerPromo = getView.findViewById(R.id.shimmepromo);
|
||||
shimberita = getView.findViewById(R.id.shimberita);
|
||||
shimmerchantpromo = getView.findViewById(R.id.shimmerchantpromo);
|
||||
getShimmerchantnear = getView.findViewById(R.id.shimmerchantnear);
|
||||
|
||||
rvCategory.setHasFixedSize(true);
|
||||
rvCategory.setLayoutManager(new GridLayoutManager(getActivity(), 3));
|
||||
|
||||
rvberita.setHasFixedSize(true);
|
||||
rvberita.setNestedScrollingEnabled(false);
|
||||
rvberita.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false));
|
||||
|
||||
rvmerchant.setHasFixedSize(true);
|
||||
rvmerchant.setNestedScrollingEnabled(false);
|
||||
rvmerchant.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false));
|
||||
|
||||
rvcatmerchantnear.setHasFixedSize(true);
|
||||
rvcatmerchantnear.setNestedScrollingEnabled(false);
|
||||
rvcatmerchantnear.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false));
|
||||
|
||||
rvmerchantnear.setHasFixedSize(true);
|
||||
rvmerchantnear.setNestedScrollingEnabled(false);
|
||||
rvmerchantnear.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false));
|
||||
|
||||
rvcatmerchantpromo.setHasFixedSize(true);
|
||||
rvcatmerchantpromo.setNestedScrollingEnabled(false);
|
||||
rvcatmerchantpromo.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false));
|
||||
|
||||
|
||||
Integer[] colors_temp = {
|
||||
getResources().getColor(R.color.transparent),
|
||||
getResources().getColor(R.color.transparent),
|
||||
getResources().getColor(R.color.transparent),
|
||||
getResources().getColor(R.color.transparent)
|
||||
};
|
||||
|
||||
Calendar kalender = Calendar.getInstance();
|
||||
int jam = kalender.get(Calendar.HOUR_OF_DAY);
|
||||
|
||||
if(jam >=0 && jam < 10){
|
||||
greetings.setText("Selamat Pagi, ");
|
||||
}
|
||||
else if(jam >=10 && jam < 16){
|
||||
greetings.setText("Selamat Siang, ");
|
||||
}
|
||||
else if(jam >=16 && jam < 19){
|
||||
greetings.setText("Selamat Sore, ");
|
||||
}
|
||||
else if(jam >=19 && jam < 24){
|
||||
greetings.setText("Selamat Malam, ");
|
||||
}
|
||||
else {
|
||||
greetings.setText("Hallo, ");
|
||||
|
||||
}
|
||||
|
||||
topup.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(context, TopupSaldoActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
promo.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(context, PromoActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
showall.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(context, AllBeritaActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
detail.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(context, WalletActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
|
||||
if (position < (adapter.getCount() - 1) && position < (colors.length - 1)) {
|
||||
viewPager.setBackgroundColor(
|
||||
|
||||
(Integer) argbEvaluator.evaluate(
|
||||
positionOffset,
|
||||
colors[position],
|
||||
colors[position + 1]
|
||||
)
|
||||
);
|
||||
} else {
|
||||
viewPager.setBackgroundColor(colors[colors.length - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
FusedLocationProviderClient mFusedLocation = LocationServices.getFusedLocationProviderClient(context);
|
||||
mFusedLocation.getLastLocation().addOnCompleteListener(requireActivity(), new OnCompleteListener<Location>() {
|
||||
@Override
|
||||
public void onComplete(@NonNull Task<Location> task) {
|
||||
Location location = task.isSuccessful() && task.getResult() != null ? task.getResult() : null;
|
||||
if (location != null) {
|
||||
Constants.LATITUDE = location.getLatitude();
|
||||
Constants.LONGITUDE = location.getLongitude();
|
||||
Log.e("BEARING:", String.valueOf(location.getBearing()));
|
||||
} else {
|
||||
// No cached location or task failed. Use defaults so home data still loads.
|
||||
location = getDefaultLocation();
|
||||
}
|
||||
gethome(location);
|
||||
}
|
||||
});
|
||||
|
||||
colors = colors_temp;
|
||||
shimmershow();
|
||||
|
||||
return getView;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a default Location when getLastLocation() is null, so home API is still called
|
||||
* and the UI can leave the loading state instead of showing shimmer indefinitely.
|
||||
*/
|
||||
private Location getDefaultLocation() {
|
||||
Location fallback = new Location("default");
|
||||
fallback.setLatitude(Constants.LATITUDE != null ? Constants.LATITUDE : 0.0);
|
||||
fallback.setLongitude(Constants.LONGITUDE != null ? Constants.LONGITUDE : 0.0);
|
||||
return fallback;
|
||||
}
|
||||
|
||||
private void shimmershow() {
|
||||
rvCategory.setVisibility(View.GONE);
|
||||
rvberita.setVisibility(View.GONE);
|
||||
rvmerchant.setVisibility(View.GONE);
|
||||
rvmerchantnear.setVisibility(View.GONE);
|
||||
rvcatmerchantpromo.setVisibility(View.GONE);
|
||||
shimmerchantpromo.startShimmerAnimation();
|
||||
getShimmerchantnear.startShimmerAnimation();
|
||||
shimberita.startShimmerAnimation();
|
||||
mShimmerCat.startShimmerAnimation();
|
||||
shimerPromo.startShimmerAnimation();
|
||||
saldo.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void shimmertutup() {
|
||||
rvCategory.setVisibility(View.VISIBLE);
|
||||
rvberita.setVisibility(View.VISIBLE);
|
||||
rvmerchant.setVisibility(View.VISIBLE);
|
||||
rvcatmerchantpromo.setVisibility(View.VISIBLE);
|
||||
rvcatmerchantnear.setVisibility(View.VISIBLE);
|
||||
rvmerchantnear.setVisibility(View.VISIBLE);
|
||||
shimberita.stopShimmerAnimation();
|
||||
shimberita.setVisibility(View.GONE);
|
||||
shimmerchantpromo.stopShimmerAnimation();
|
||||
shimmerchantpromo.setVisibility(View.GONE);
|
||||
mShimmerCat.setVisibility(View.GONE);
|
||||
mShimmerCat.stopShimmerAnimation();
|
||||
shimerPromo.setVisibility(View.GONE);
|
||||
shimerPromo.stopShimmerAnimation();
|
||||
getShimmerchantnear.stopShimmerAnimation();
|
||||
getShimmerchantnear.setVisibility(View.GONE);
|
||||
|
||||
saldo.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void gethome(final Location location) {
|
||||
User loginUser = BaseApp.getInstance(context).getLoginUser();
|
||||
UserService userService = ServiceGenerator.createService(
|
||||
UserService.class, loginUser.getNoTelepon(), loginUser.getPassword());
|
||||
GetHomeRequestJson param = new GetHomeRequestJson();
|
||||
param.setId(loginUser.getId());
|
||||
param.setLat(String.valueOf(location.getLatitude()));
|
||||
param.setLon(String.valueOf(location.getLongitude()));
|
||||
param.setPhone(loginUser.getNoTelepon());
|
||||
userService.home(param).enqueue(new Callback<GetHomeResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<GetHomeResponseJson> call, @NonNull Response<GetHomeResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
if (Objects.requireNonNull(response.body()).getMessage().equalsIgnoreCase("success")) {
|
||||
Log.v("TAG", "" + response.body());
|
||||
shimmertutup();
|
||||
|
||||
sp.updateabout(response.body().getAboutus());
|
||||
sp.updateemail(response.body().getEmail());
|
||||
sp.updatephone(response.body().getPhone());
|
||||
sp.updateweb(response.body().getWebsite());
|
||||
sp.updatempstatus(response.body().getMpstatus());
|
||||
sp.updatempactive(response.body().getMpactive());
|
||||
sp.updateMobilepulsausername(response.body().getMobilepulsausername());
|
||||
sp.updateMobilepulsaapikey(response.body().getMobilepulsaapikey());
|
||||
sp.updateMobilepulsaharga(response.body().getMobilepulsaharga());
|
||||
|
||||
Utility.koinTXT(saldo, response.body().getSaldo(), context);
|
||||
|
||||
if (response.body().getSlider().isEmpty()) {
|
||||
llslider.setVisibility(View.GONE);
|
||||
} else {
|
||||
promoslider.setVisibility(View.VISIBLE);
|
||||
adapter = new SliderItem(response.body().getSlider(), getActivity());
|
||||
viewPager.setAdapter(adapter);
|
||||
circleIndicator.setViewPager(viewPager);
|
||||
viewPager.setPadding(27, 0, 27, 0);
|
||||
}
|
||||
fiturdata = response.body().getFitur();
|
||||
allfiturdata = response.body().getAllfitur();
|
||||
for (int i = 0; i < fiturdata.size(); i++) {
|
||||
FiturDataModel fiturmodel = new FiturDataModel();
|
||||
fiturmodel.setIdFitur(fiturdata.get(i).getIdFitur());
|
||||
fiturmodel.setFitur(fiturdata.get(i).getFitur());
|
||||
fiturmodel.setIcon(fiturdata.get(i).getIcon());
|
||||
fiturmodel.setHome(fiturdata.get(i).getHome());
|
||||
fiturlist.add(fiturmodel);
|
||||
}
|
||||
|
||||
if (fiturdata.size() > 6) {
|
||||
FiturDataModel fiturmodel = new FiturDataModel();
|
||||
fiturmodel.setIdFitur(100);
|
||||
fiturmodel.setFitur("Semua");
|
||||
fiturmodel.setHome("0");
|
||||
fiturlist.add(fiturmodel);
|
||||
}
|
||||
|
||||
fiturItem = new FiturItem(getActivity(), fiturlist, R.layout.item_fitur, new FiturItem.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(FiturDataModel item) {
|
||||
sheetlist();
|
||||
}
|
||||
});
|
||||
rvCategory.setAdapter(fiturItem);
|
||||
if (response.body().getBerita().isEmpty()) {
|
||||
llberita.setVisibility(View.GONE);
|
||||
} else {
|
||||
beritaItem = new BeritaItem(getActivity(), response.body().getBerita(), R.layout.item_grid);
|
||||
rvberita.setAdapter(beritaItem);
|
||||
rvberita.setPadding(0,0,0,0);
|
||||
}
|
||||
|
||||
|
||||
if (response.body().getMerchantpromo().isEmpty()) {
|
||||
llmerchant.setVisibility(View.GONE);
|
||||
} else {
|
||||
|
||||
click = response.body().getMerchantpromo();
|
||||
merchantItem = new MerchantItem(getActivity(), click, R.layout.item_merchant);
|
||||
rvmerchant.setAdapter(merchantItem);
|
||||
catMerchantItem = new CatMerchantItem(getActivity(), response.body().getCatmerchant(), R.layout.item_cat_merchant, new CatMerchantItem.OnItemClickListener() {
|
||||
@SuppressLint("MissingPermission")
|
||||
@Override
|
||||
public void onItemClick(final CatMerchantModel item) {
|
||||
|
||||
click.clear();
|
||||
shimlistpromo.setVisibility(View.VISIBLE);
|
||||
shimmerchantpromo.setVisibility(View.VISIBLE);
|
||||
shimlistcatpromo.setVisibility(View.GONE);
|
||||
rvmerchant.setVisibility(View.GONE);
|
||||
nodatapromo.setVisibility(View.GONE);
|
||||
shimmerchantpromo.startShimmerAnimation();
|
||||
FusedLocationProviderClient mFusedLocation = LocationServices.getFusedLocationProviderClient(context);
|
||||
mFusedLocation.getLastLocation().addOnSuccessListener(requireActivity(), new OnSuccessListener<Location>() {
|
||||
@Override
|
||||
public void onSuccess(Location location) {
|
||||
if (location != null) {
|
||||
getmerchntbycatpromo(location, item.getId_kategori_merchant());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
rvcatmerchantpromo.setAdapter(catMerchantItem);
|
||||
|
||||
}
|
||||
|
||||
if (response.body().getMerchantnear().isEmpty()) {
|
||||
llmerchantnear.setVisibility(View.GONE);
|
||||
} else {
|
||||
clicknear = response.body().getMerchantnear();
|
||||
merchantNearItem = new MerchantNearItem(getActivity(), clicknear, R.layout.item_merchant);
|
||||
rvmerchantnear.setAdapter(merchantNearItem);
|
||||
|
||||
catMerchantNearItem = new CatMerchantNearItem(getActivity(), response.body().getCatmerchant(), R.layout.item_cat_merchant, new CatMerchantNearItem.OnItemClickListener() {
|
||||
@SuppressLint("MissingPermission")
|
||||
@Override
|
||||
public void onItemClick(final CatMerchantModel item) {
|
||||
clicknear.clear();
|
||||
shimlistnear.setVisibility(View.VISIBLE);
|
||||
getShimmerchantnear.setVisibility(View.VISIBLE);
|
||||
shimlistcatnear.setVisibility(View.GONE);
|
||||
rvmerchantnear.setVisibility(View.GONE);
|
||||
nodatanear.setVisibility(View.GONE);
|
||||
getShimmerchantnear.startShimmerAnimation();
|
||||
FusedLocationProviderClient mFusedLocation = LocationServices.getFusedLocationProviderClient(context);
|
||||
mFusedLocation.getLastLocation().addOnSuccessListener(requireActivity(), new OnSuccessListener<Location>() {
|
||||
@Override
|
||||
public void onSuccess(Location location) {
|
||||
if (location != null) {
|
||||
getmerchntbycatnear(location, item.getId_kategori_merchant());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
rvcatmerchantnear.setAdapter(catMerchantNearItem);
|
||||
}
|
||||
User user = response.body().getData().get(0);
|
||||
saveUser(user);
|
||||
if (HomeFragment.this.getActivity() != null) {
|
||||
Realm realm = BaseApp.getInstance(HomeFragment.this.getActivity()).getRealmInstance();
|
||||
User loginUser = BaseApp.getInstance(HomeFragment.this.getActivity()).getLoginUser();
|
||||
realm.beginTransaction();
|
||||
if (response.body().getSaldo() != null && !response.body().getSaldo().isEmpty()) {
|
||||
loginUser.setWalletSaldo(Long.parseLong(response.body().getSaldo()));
|
||||
}
|
||||
realm.commitTransaction();
|
||||
}
|
||||
} else {
|
||||
Realm realm = BaseApp.getInstance(context).getRealmInstance();
|
||||
realm.beginTransaction();
|
||||
realm.delete(User.class);
|
||||
realm.commitTransaction();
|
||||
BaseApp.getInstance(context).setLoginUser(null);
|
||||
startActivity(new Intent(context, IntroActivity.class)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||
requireActivity().finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<GetHomeResponseJson> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getmerchntbycatpromo(final Location location, String cat) {
|
||||
User loginUser = BaseApp.getInstance(context).getLoginUser();
|
||||
UserService userService = ServiceGenerator.createService(
|
||||
UserService.class, loginUser.getNoTelepon(), loginUser.getPassword());
|
||||
GetMerchantbyCatRequestJson param = new GetMerchantbyCatRequestJson();
|
||||
param.setId(loginUser.getId());
|
||||
param.setLat(String.valueOf(location.getLatitude()));
|
||||
param.setLon(String.valueOf(location.getLongitude()));
|
||||
param.setPhone(loginUser.getNoTelepon());
|
||||
param.setKategori(cat);
|
||||
userService.getmerchanbycat(param).enqueue(new Callback<MerchantByCatResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<MerchantByCatResponseJson> call, @NonNull Response<MerchantByCatResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
if (Objects.requireNonNull(response.body()).getMessage().equalsIgnoreCase("success")) {
|
||||
click = response.body().getData();
|
||||
shimmerchantpromo.setVisibility(View.GONE);
|
||||
rvmerchant.setVisibility(View.VISIBLE);
|
||||
shimmerchantpromo.stopShimmerAnimation();
|
||||
if (response.body().getData().isEmpty()) {
|
||||
nodatapromo.setVisibility(View.VISIBLE);
|
||||
rvmerchant.setVisibility(View.GONE);
|
||||
} else {
|
||||
nodatapromo.setVisibility(View.GONE);
|
||||
merchantItem = new MerchantItem(getActivity(), click, R.layout.item_merchant);
|
||||
rvmerchant.setAdapter(merchantItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<MerchantByCatResponseJson> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getmerchntbycatnear(final Location location, String cat) {
|
||||
User loginUser = BaseApp.getInstance(context).getLoginUser();
|
||||
UserService userService = ServiceGenerator.createService(
|
||||
UserService.class, loginUser.getNoTelepon(), loginUser.getPassword());
|
||||
GetMerchantbyCatRequestJson param = new GetMerchantbyCatRequestJson();
|
||||
param.setId(loginUser.getId());
|
||||
param.setLat(String.valueOf(location.getLatitude()));
|
||||
param.setLon(String.valueOf(location.getLongitude()));
|
||||
param.setPhone(loginUser.getNoTelepon());
|
||||
param.setKategori(cat);
|
||||
userService.getmerchanbynear(param).enqueue(new Callback<MerchantByNearResponseJson>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<MerchantByNearResponseJson> call, @NonNull Response<MerchantByNearResponseJson> response) {
|
||||
if (response.isSuccessful()) {
|
||||
if (Objects.requireNonNull(response.body()).getMessage().equalsIgnoreCase("success")) {
|
||||
clicknear = response.body().getData();
|
||||
getShimmerchantnear.setVisibility(View.GONE);
|
||||
rvmerchantnear.setVisibility(View.VISIBLE);
|
||||
getShimmerchantnear.stopShimmerAnimation();
|
||||
if (response.body().getData().isEmpty()) {
|
||||
nodatanear.setVisibility(View.VISIBLE);
|
||||
rvmerchantnear.setVisibility(View.GONE);
|
||||
} else {
|
||||
nodatanear.setVisibility(View.GONE);
|
||||
merchantNearItem = new MerchantNearItem(getActivity(), clicknear, R.layout.item_merchant);
|
||||
rvmerchantnear.setAdapter(merchantNearItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<MerchantByNearResponseJson> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
User loginUser = BaseApp.getInstance(context).getLoginUser();
|
||||
nama.setText(loginUser.getFullnama());
|
||||
Utility.koinTXT(saldo, String.valueOf(loginUser.getWalletSaldo()), context);
|
||||
|
||||
}
|
||||
|
||||
private void saveUser(User user) {
|
||||
Realm realm = Realm.getDefaultInstance();
|
||||
realm.beginTransaction();
|
||||
realm.delete(User.class);
|
||||
realm.copyToRealm(user);
|
||||
realm.commitTransaction();
|
||||
BaseApp.getInstance(context).setLoginUser(user);
|
||||
}
|
||||
|
||||
private void sheetlist() {
|
||||
if (mBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED) {
|
||||
mBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
}
|
||||
|
||||
@SuppressLint("InflateParams") final View mDialog = getLayoutInflater().inflate(R.layout.sheet_category, null);
|
||||
RecyclerView view = mDialog.findViewById(R.id.category);
|
||||
|
||||
view.setHasFixedSize(true);
|
||||
view.setLayoutManager(new GridLayoutManager(getActivity(), 4));
|
||||
|
||||
AllFiturItem allfiturItem = new AllFiturItem(getActivity(), allfiturdata, R.layout.item_fitur);
|
||||
view.setAdapter(allfiturItem);
|
||||
|
||||
mBottomSheetDialog = new BottomSheetDialog(context);
|
||||
mBottomSheetDialog.setContentView(mDialog);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
Objects.requireNonNull(mBottomSheetDialog.getWindow()).addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
}
|
||||
|
||||
mBottomSheetDialog.show();
|
||||
mBottomSheetDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
mBottomSheetDialog = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
package id.ontime.customer.fragment;
|
||||
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.activity.ChatActivity;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.constants.Functions;
|
||||
import id.ontime.customer.item.MessageItem;
|
||||
import id.ontime.customer.models.MessageModels;
|
||||
import id.ontime.customer.models.User;
|
||||
import com.facebook.shimmer.ShimmerFrameLayout;
|
||||
import com.google.firebase.database.DataSnapshot;
|
||||
import com.google.firebase.database.DatabaseError;
|
||||
import com.google.firebase.database.DatabaseReference;
|
||||
import com.google.firebase.database.FirebaseDatabase;
|
||||
import com.google.firebase.database.Query;
|
||||
import com.google.firebase.database.ValueEventListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
public class MessageFragment extends Fragment {
|
||||
|
||||
|
||||
private View getView;
|
||||
private Context context;
|
||||
|
||||
private RecyclerView inboxList;
|
||||
|
||||
private ArrayList<MessageModels> inboxArraylist;
|
||||
private ShimmerFrameLayout shimmer;
|
||||
private DatabaseReference rootRef;
|
||||
|
||||
private MessageItem inboxItem;
|
||||
private ValueEventListener valueEventListener;
|
||||
private Query inboxQuery;
|
||||
|
||||
@Override
|
||||
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
getView = inflater.inflate(R.layout.fragment_recycle, container, false);
|
||||
context = getContext();
|
||||
|
||||
try {
|
||||
rootRef = FirebaseDatabase.getInstance().getReference();
|
||||
} catch (IllegalStateException e) {
|
||||
e.printStackTrace();
|
||||
rootRef = null;
|
||||
}
|
||||
|
||||
inboxList = getView.findViewById(R.id.inboxlist);
|
||||
shimmer = getView.findViewById(R.id.shimmerwallet);
|
||||
inboxArraylist = new ArrayList<>();
|
||||
inboxList = getView.findViewById(R.id.inboxlist);
|
||||
LinearLayoutManager layout = new LinearLayoutManager(context);
|
||||
inboxList.setLayoutManager(layout);
|
||||
inboxList.setHasFixedSize(false);
|
||||
inboxItem = new MessageItem(context, inboxArraylist, new MessageItem.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(MessageModels item) {
|
||||
User loginuser = BaseApp.getInstance(context).getLoginUser();
|
||||
if (checkReadStoragepermission()) {
|
||||
Intent intent = new Intent(getActivity(), ChatActivity.class);
|
||||
intent.putExtra("senderid", loginuser.getId());
|
||||
intent.putExtra("receiverid", item.getId());
|
||||
intent.putExtra("name", item.getName());
|
||||
intent.putExtra("tokendriver", loginuser.getToken());
|
||||
intent.putExtra("tokenku", item.getTokenuser());
|
||||
intent.putExtra("pic", item.getPicture());
|
||||
requireActivity().startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inboxList.setAdapter(inboxItem);
|
||||
|
||||
|
||||
getView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Functions.hideSoftKeyboard(requireActivity());
|
||||
}
|
||||
});
|
||||
shimmershow();
|
||||
return getView;
|
||||
}
|
||||
|
||||
private void shimmershow() {
|
||||
inboxList.setVisibility(View.GONE);
|
||||
shimmer.setVisibility(View.VISIBLE);
|
||||
shimmer.startShimmerAnimation();
|
||||
}
|
||||
|
||||
private void shimmertutup() {
|
||||
|
||||
inboxList.setVisibility(View.VISIBLE);
|
||||
shimmer.setVisibility(View.GONE);
|
||||
shimmer.stopShimmerAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
if (rootRef == null) {
|
||||
shimmertutup();
|
||||
if (getView != null) {
|
||||
View empty = getView.findViewById(R.id.rlnodata);
|
||||
if (empty != null) {
|
||||
empty.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
inboxQuery = rootRef.child("Inbox").child(Constants.USERID).orderByChild("date");
|
||||
valueEventListener = new ValueEventListener() {
|
||||
@Override
|
||||
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
|
||||
shimmertutup();
|
||||
inboxArraylist.clear();
|
||||
|
||||
for (DataSnapshot ds : dataSnapshot.getChildren()) {
|
||||
MessageModels model = new MessageModels();
|
||||
model.setId(ds.getKey());
|
||||
model.setName(Objects.requireNonNull(ds.child("name").getValue()).toString());
|
||||
model.setMessage(Objects.requireNonNull(ds.child("msg").getValue()).toString());
|
||||
model.setTimestamp(Objects.requireNonNull(ds.child("date").getValue()).toString());
|
||||
model.setStatus(Objects.requireNonNull(ds.child("status").getValue()).toString());
|
||||
model.setPicture(Objects.requireNonNull(ds.child("pic").getValue()).toString());
|
||||
model.setTokendriver(Objects.requireNonNull(ds.child("tokendriver").getValue()).toString());
|
||||
model.setTokenuser(Objects.requireNonNull(ds.child("tokenuser").getValue()).toString());
|
||||
inboxArraylist.add(model);
|
||||
}
|
||||
Collections.reverse(inboxArraylist);
|
||||
inboxItem.notifyDataSetChanged();
|
||||
|
||||
if (inboxArraylist.isEmpty()) {
|
||||
getView.findViewById(R.id.rlnodata).setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
getView.findViewById(R.id.rlnodata).setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancelled(@NonNull DatabaseError databaseError) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
inboxQuery.addValueEventListener(valueEventListener);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
if (inboxQuery != null)
|
||||
inboxQuery.removeEventListener(valueEventListener);
|
||||
}
|
||||
|
||||
private boolean checkReadStoragepermission() {
|
||||
if (ContextCompat.checkSelfPermission(requireActivity().getApplicationContext(),
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
== PackageManager.PERMISSION_GRANTED) {
|
||||
return true;
|
||||
} else {
|
||||
try {
|
||||
requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
|
||||
Constants.permission_Read_data);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package id.ontime.customer.fragment;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
|
||||
import nl.changer.audiowife.AudioWife;
|
||||
|
||||
|
||||
public class PlayAudioFragment extends Fragment {
|
||||
|
||||
private AudioWife audioWife;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View getView = inflater.inflate(R.layout.fragment_playaudio, container, false);
|
||||
|
||||
Context context = getContext();
|
||||
|
||||
ImageView close_btn = getView.findViewById(R.id.close_btn);
|
||||
ImageButton playBtn = getView.findViewById(R.id.playbtn);
|
||||
ImageButton pauseBtn = getView.findViewById(R.id.pause_btn);
|
||||
SeekBar seekBar = getView.findViewById(R.id.seekbar);
|
||||
TextView durationTime = getView.findViewById(R.id.duration_time);
|
||||
TextView totalTime = getView.findViewById(R.id.totaltime);
|
||||
|
||||
String filepath = requireArguments().getString("path");
|
||||
Uri uri = Uri.parse(filepath);
|
||||
|
||||
audioWife = AudioWife.getInstance();
|
||||
audioWife.init(context, uri)
|
||||
.setPlayView(playBtn)
|
||||
.setPauseView(pauseBtn)
|
||||
.setSeekBar(seekBar)
|
||||
.setRuntimeView(durationTime)
|
||||
.setTotalTimeView(totalTime);
|
||||
|
||||
audioWife.play();
|
||||
|
||||
close_btn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
requireActivity().onBackPressed();
|
||||
}
|
||||
});
|
||||
|
||||
return getView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
audioWife.pause();
|
||||
audioWife.release();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
package id.ontime.customer.fragment;
|
||||
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Dialog;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.activity.ChangepassActivity;
|
||||
import id.ontime.customer.activity.EditProfileActivity;
|
||||
import id.ontime.customer.activity.IntroActivity;
|
||||
import id.ontime.customer.activity.PrivacyActivity;
|
||||
import id.ontime.customer.activity.TopupSaldoActivity;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.panicbutton.api.LogoutAPI;
|
||||
import id.ontime.customer.panicbutton.model.Value;
|
||||
import id.ontime.customer.utils.PicassoTrustAll;
|
||||
import id.ontime.customer.utils.SettingPreference;
|
||||
import id.ontime.customer.utils.Utility;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import io.realm.Realm;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
import static android.content.Context.NOTIFICATION_SERVICE;
|
||||
|
||||
|
||||
public class ProfileFragment extends Fragment {
|
||||
private Context context;
|
||||
private ImageView foto;
|
||||
private TextView nama, email,countryCode, phone, saldo;
|
||||
private SettingPreference sp;
|
||||
private String saldoWallet;
|
||||
// public static final String URL = "http://peci.semestaterpadu.my.id/";
|
||||
|
||||
@Override
|
||||
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View getView = inflater.inflate(R.layout.fragment_profile, container, false);
|
||||
context = getContext();
|
||||
foto = getView.findViewById(R.id.userphoto);
|
||||
nama = getView.findViewById(R.id.username);
|
||||
email = getView.findViewById(R.id.useremail);
|
||||
countryCode = getView.findViewById(R.id.countrycode);
|
||||
phone = getView.findViewById(R.id.phone);
|
||||
saldo = getView.findViewById(R.id.saldo);
|
||||
LinearLayout aboutus = getView.findViewById(R.id.llaboutus);
|
||||
LinearLayout privacy = getView.findViewById(R.id.llprivacypolicy);
|
||||
LinearLayout shareapp = getView.findViewById(R.id.llshareapp);
|
||||
LinearLayout rateapp = getView.findViewById(R.id.llrateapp);
|
||||
LinearLayout editprofile = getView.findViewById(R.id.lleditprofile);
|
||||
LinearLayout logout = getView.findViewById(R.id.lllogout);
|
||||
LinearLayout llpassword = getView.findViewById(R.id.llpassword);
|
||||
LinearLayout topUp = getView.findViewById(R.id.topUp);
|
||||
sp = new SettingPreference(context);
|
||||
|
||||
|
||||
privacy.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(context, PrivacyActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
aboutus.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
aboutus();
|
||||
}
|
||||
});
|
||||
|
||||
shareapp.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
||||
shareIntent.setType("text/plain");
|
||||
shareIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name));
|
||||
String shareMessage = "Download Sekarang! ";
|
||||
shareMessage = shareMessage + "https://play.google.com/store/apps/details?id=" + requireActivity().getPackageName() + "\n\n";
|
||||
shareIntent.putExtra(Intent.EXTRA_TEXT, shareMessage);
|
||||
startActivity(Intent.createChooser(shareIntent, "choose one"));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
rateapp.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Uri uri = Uri.parse("market://details?id=" + requireActivity().getPackageName());
|
||||
Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY |
|
||||
Intent.FLAG_ACTIVITY_NEW_DOCUMENT |
|
||||
Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||
}
|
||||
try {
|
||||
startActivity(goToMarket);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW,
|
||||
Uri.parse("http://play.google.com/store/apps/details?id=" + getActivity().getPackageName())));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
editprofile.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(context, EditProfileActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
}
|
||||
});
|
||||
|
||||
topUp.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(context, TopupSaldoActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
}
|
||||
});
|
||||
|
||||
llpassword.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(context, ChangepassActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
}
|
||||
});
|
||||
|
||||
logout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
clickDone();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return getView;
|
||||
}
|
||||
|
||||
private void clickDone() {
|
||||
new AlertDialog.Builder(context)
|
||||
.setIcon(R.mipmap.ic_launcher)
|
||||
.setTitle(getString(R.string.app_name))
|
||||
.setMessage(getString(R.string.exit))
|
||||
.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
Realm realm = BaseApp.getInstance(context).getRealmInstance();
|
||||
realm.beginTransaction();
|
||||
realm.delete(User.class);
|
||||
realm.commitTransaction();
|
||||
removeNotif();
|
||||
BaseApp.getInstance(context).setLoginUser(null);
|
||||
logOutPanic();
|
||||
startActivity(new Intent(getContext(), IntroActivity.class)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||
requireActivity().finish();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
private void aboutus() {
|
||||
final Dialog dialog = new Dialog(context);
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // before
|
||||
dialog.setContentView(R.layout.dialog_aboutus);
|
||||
dialog.setCancelable(true);
|
||||
|
||||
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
|
||||
lp.copyFrom(Objects.requireNonNull(dialog.getWindow()).getAttributes());
|
||||
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||
|
||||
final ImageView close = dialog.findViewById(R.id.bt_close);
|
||||
final LinearLayout email = dialog.findViewById(R.id.email);
|
||||
final LinearLayout phone = dialog.findViewById(R.id.phone);
|
||||
final LinearLayout website = dialog.findViewById(R.id.website);
|
||||
final WebView about = dialog.findViewById(R.id.aboutus);
|
||||
|
||||
String mimeType = "text/html";
|
||||
String encoding = "utf-8";
|
||||
String htmlText;
|
||||
htmlText = sp.getSetting()[1];
|
||||
String text = "<html dir=" + "><head>"
|
||||
+ "<style type=\"text/css\">@font-face {font-family: MyFont;src: url(\"file:///android_asset/fonts/Montserrat_Medium.ttf\")}body{font-family: MyFont;color: #000000;text-align:justify;line-height:1.2}"
|
||||
+ "</style></head>"
|
||||
+ "<body>"
|
||||
+ htmlText
|
||||
+ "</body></html>";
|
||||
|
||||
about.loadDataWithBaseURL(null, text, mimeType, encoding, null);
|
||||
|
||||
phone.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
final int REQUEST_PHONE_CALL = 1;
|
||||
Intent callIntent = new Intent(Intent.ACTION_CALL);
|
||||
callIntent.setData(Uri.parse("tel:" + (sp.getSetting()[3])));
|
||||
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (ContextCompat.checkSelfPermission(requireContext(), Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(requireActivity(), new String[]{Manifest.permission.CALL_PHONE}, REQUEST_PHONE_CALL);
|
||||
} else {
|
||||
startActivity(callIntent);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
email.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String[] TO = {(sp.getSetting()[2])};
|
||||
Intent emailIntent = new Intent(Intent.ACTION_SEND);
|
||||
emailIntent.setType("text/plain");
|
||||
|
||||
emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
|
||||
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "halo");
|
||||
emailIntent.putExtra(Intent.EXTRA_TEXT, "email" + "\n");
|
||||
try {
|
||||
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
|
||||
} catch (android.content.ActivityNotFoundException ex) {
|
||||
Toast.makeText(getActivity(),
|
||||
"There is no email client installed.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
website.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String url = (sp.getSetting()[4]);
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse(url));
|
||||
startActivity(i);
|
||||
}
|
||||
});
|
||||
|
||||
close.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
dialog.show();
|
||||
dialog.getWindow().setAttributes(lp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
User loginUser = BaseApp.getInstance(context).getLoginUser();
|
||||
nama.setText(loginUser.getFullnama());
|
||||
email.setText(loginUser.getEmail());
|
||||
countryCode.setText(loginUser.getCountrycode());
|
||||
phone.setText(loginUser.getPhone());
|
||||
saldoWallet = String.valueOf(loginUser.getWalletSaldo());
|
||||
Utility.koinTXT(saldo, saldoWallet, context);
|
||||
|
||||
PicassoTrustAll.getInstance(context)
|
||||
.load(Constants.IMAGESUSER + loginUser.getFotopelanggan())
|
||||
.placeholder(R.drawable.image_placeholder)
|
||||
.resize(250, 250)
|
||||
.into(foto);
|
||||
|
||||
}
|
||||
|
||||
private void removeNotif() {
|
||||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
|
||||
Objects.requireNonNull(notificationManager).cancel(0);
|
||||
}
|
||||
|
||||
private void logOutPanic(){
|
||||
SharedPreferences sharedPreferences = PreferenceManager.
|
||||
getDefaultSharedPreferences(context.getApplicationContext());
|
||||
String idUser = sharedPreferences.getString("idUser", "kosong");
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl(Constants.URL)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.build();
|
||||
LogoutAPI api = retrofit.create(LogoutAPI.class);
|
||||
Call<Value> call = api.logout(idUser);
|
||||
call.enqueue(new Callback<Value>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Value> call, @NonNull Response<Value> response) {
|
||||
String value = response.body().getValue();
|
||||
if (value.equals("1")) {
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString("idUser", "");
|
||||
editor.putString("status", "");
|
||||
editor.apply();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Value> call, Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package id.ontime.customer.gmap;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Direction implements Serializable {
|
||||
|
||||
|
||||
private static final long serialVersionUID = -4198690398884769235L;
|
||||
|
||||
public String durationText;
|
||||
public String html_instructions;
|
||||
public String distanceText;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,329 @@
|
||||
package id.ontime.customer.gmap;
|
||||
|
||||
import id.ontime.customer.activity.MainActivity;
|
||||
import id.ontime.customer.utils.Log;
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
public class GMapDirection {
|
||||
public final static String MODE_DRIVING = "driving";
|
||||
public final static String MODE_WALKING = "walking";
|
||||
|
||||
public GMapDirection() {
|
||||
}
|
||||
|
||||
|
||||
public String getUrl(LatLng start, LatLng end, String mode, boolean isAlternative) {
|
||||
|
||||
String url = "https://maps.googleapis.com/maps/api/directions/json?"
|
||||
+ "origin=" + start.latitude + "," + start.longitude
|
||||
+ "&destination=" + end.latitude + "," + end.longitude
|
||||
+ "&sensor=false&units=metric&mode=" + mode
|
||||
+ "&key=" + MainActivity.apikey;
|
||||
|
||||
if (isAlternative)
|
||||
url += "&alternatives=true";
|
||||
|
||||
Log.e("getUrl", url);
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getUrlVia(String mode, boolean isAlternative, LatLng start, LatLng... end) {
|
||||
String via = "&waypoints=";
|
||||
if (end.length > 1) {
|
||||
for (LatLng end_latLng : end) {
|
||||
via += "via:" + end_latLng.latitude + "%2C" + end_latLng.longitude + "%7C";
|
||||
}
|
||||
} else {
|
||||
via = "";
|
||||
}
|
||||
|
||||
|
||||
String url = "https://maps.googleapis.com/maps/api/directions/json?"
|
||||
+ "origin=" + start.latitude + "," + start.longitude
|
||||
+ "&destination=" + end[end.length - 1].latitude + "," + end[end.length - 1].longitude
|
||||
+ via
|
||||
+ "&sensor=false&units=metric&mode=" + mode
|
||||
+ "&key=" + MainActivity.apikey;
|
||||
|
||||
if (isAlternative)
|
||||
url += "&alternatives=true";
|
||||
|
||||
Log.e("getUrl", url);
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
public Document getDocument(LatLng start, LatLng end, String mode) {
|
||||
|
||||
String url = "https://maps.googleapis.com/maps/api/directions/json?"
|
||||
+ "origin=" + start.latitude + "," + start.longitude
|
||||
+ "&destination=" + end.latitude + "," + end.longitude
|
||||
+ "&sensor=false&units=metric&mode=driving"
|
||||
+ "&key=" + MainActivity.apikey;
|
||||
|
||||
// String url = "http://maps.googleapis.com/maps/api/directions/xml?"
|
||||
// + "origin=" + start.latitude + "," + start.longitude
|
||||
// + "&destination=" + end.latitude + "," + end.longitude
|
||||
// + "&sensor=false&units=metric&mode=driving"+"alternatives=true";
|
||||
|
||||
url = url.replace(" ", "+");
|
||||
|
||||
Log.e("URL", url);
|
||||
|
||||
try {
|
||||
URL ur = new URL(url);
|
||||
URLConnection connection = ur.openConnection();
|
||||
|
||||
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
Document doc = builder.parse(connection.getInputStream());
|
||||
|
||||
return doc;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Document getDocument(String origin, String destination, String mode) {
|
||||
String url = "http://maps.googleapis.com/maps/api/directions/json?"
|
||||
+ "origin=" + origin + "&destination=" + destination
|
||||
+ "&sensor=false&units=metric&mode=driving"
|
||||
+ "&key=" + MainActivity.apikey;
|
||||
|
||||
url = url.replace(" ", "+");
|
||||
Log.e("Query URL", url);
|
||||
|
||||
try {
|
||||
URL ur = new URL(url);
|
||||
URLConnection connection = ur.openConnection();
|
||||
|
||||
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
Document doc = builder.parse(connection.getInputStream());
|
||||
return doc;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getDurationText(Document doc) {
|
||||
NodeList nl1 = doc.getElementsByTagName("duration");
|
||||
Node node1 = nl1.item(0);
|
||||
NodeList nl2 = node1.getChildNodes();
|
||||
Node node2 = nl2.item(getNodeIndex(nl2, "text"));
|
||||
Log.i("DurationText", node2.getTextContent());
|
||||
return node2.getTextContent();
|
||||
}
|
||||
|
||||
public int getDurationValue(Document doc) {
|
||||
NodeList nl1 = doc.getElementsByTagName("duration");
|
||||
Node node1 = nl1.item(0);
|
||||
NodeList nl2 = node1.getChildNodes();
|
||||
Node node2 = nl2.item(getNodeIndex(nl2, "value"));
|
||||
Log.i("DurationValue", node2.getTextContent());
|
||||
return Integer.parseInt(node2.getTextContent());
|
||||
}
|
||||
|
||||
public String getDistanceText(Document doc) {
|
||||
NodeList nl1 = doc.getElementsByTagName("distance");
|
||||
Node node1 = nl1.item(0);
|
||||
NodeList nl2 = node1.getChildNodes();
|
||||
Node node2 = nl2.item(getNodeIndex(nl2, "text"));
|
||||
Log.i("DistanceText", node2.getTextContent());
|
||||
return node2.getTextContent();
|
||||
}
|
||||
|
||||
public int getDistanceValue(Document doc) {
|
||||
NodeList nl1 = doc.getElementsByTagName("distance");
|
||||
Node node1 = nl1.item(0);
|
||||
NodeList nl2 = node1.getChildNodes();
|
||||
Node node2 = nl2.item(getNodeIndex(nl2, "value"));
|
||||
Log.i("DistanceValue", node2.getTextContent());
|
||||
return Integer.parseInt(node2.getTextContent());
|
||||
}
|
||||
|
||||
public List<Float> getDistanceValueInMeters(Document doc) {
|
||||
List<Float> list = new ArrayList<Float>();
|
||||
|
||||
NodeList nl1 = doc.getElementsByTagName("distance");
|
||||
|
||||
for (int x = 0; x < nl1.getLength(); x++) {
|
||||
Node node1 = nl1.item(x);
|
||||
NodeList nl2 = node1.getChildNodes();
|
||||
Node node2 = nl2.item(getNodeIndex(nl2, "value"));
|
||||
|
||||
Log.i("DistanceValue", node2.getTextContent());
|
||||
|
||||
float val = Integer.parseInt(node2.getTextContent());
|
||||
|
||||
list.add(val);
|
||||
}
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public String getStartAddress(Document doc) {
|
||||
NodeList nl1 = doc.getElementsByTagName("start_address");
|
||||
Node node1 = nl1.item(0);
|
||||
Log.i("StartAddress", node1.getTextContent());
|
||||
return node1.getTextContent();
|
||||
}
|
||||
|
||||
public String getEndAddress(Document doc) {
|
||||
NodeList nl1 = doc.getElementsByTagName("end_address");
|
||||
Node node1 = nl1.item(0);
|
||||
Log.i("StartAddress", node1.getTextContent());
|
||||
return node1.getTextContent();
|
||||
}
|
||||
|
||||
public String getCopyRights(Document doc) {
|
||||
NodeList nl1 = doc.getElementsByTagName("copyrights");
|
||||
Node node1 = nl1.item(0);
|
||||
Log.i("CopyRights", node1.getTextContent());
|
||||
return node1.getTextContent();
|
||||
}
|
||||
|
||||
|
||||
public LatLng getStartLocation(Document doc) {
|
||||
NodeList nl1 = doc.getElementsByTagName("start_location");
|
||||
Node node1 = nl1.item(0);
|
||||
NodeList nl2 = node1.getChildNodes();
|
||||
Node node2 = nl2.item(getNodeIndex(nl2, "lat"));
|
||||
Node node21 = nl2.item(getNodeIndex(nl2, "lng"));
|
||||
|
||||
Log.i("DistanceValue", node2.getTextContent());
|
||||
return new LatLng(Float.parseFloat(node2.getTextContent()), Float.parseFloat(node21.getTextContent()));
|
||||
}
|
||||
|
||||
public LatLng getEndLocation(Document doc) {
|
||||
NodeList nl1 = doc.getElementsByTagName("end_location");
|
||||
Node node1 = nl1.item(0);
|
||||
NodeList nl2 = node1.getChildNodes();
|
||||
Node node2 = nl2.item(getNodeIndex(nl2, "lat"));
|
||||
Node node21 = nl2.item(getNodeIndex(nl2, "lng"));
|
||||
|
||||
Log.i("DistanceValue", node2.getTextContent());
|
||||
return new LatLng(Float.parseFloat(node2.getTextContent()), Float.parseFloat(node21.getTextContent()));
|
||||
}
|
||||
|
||||
public ArrayList<LatLng> getDirection(Document doc) {
|
||||
NodeList nl1, nl2, nl3;
|
||||
ArrayList<LatLng> listGeopoints = new ArrayList<LatLng>();
|
||||
nl1 = doc.getElementsByTagName("step");
|
||||
if (nl1.getLength() > 0) {
|
||||
for (int i = 0; i < nl1.getLength(); i++) {
|
||||
Node node1 = nl1.item(i);
|
||||
nl2 = node1.getChildNodes();
|
||||
|
||||
Node locationNode = nl2.item(getNodeIndex(nl2, "start_location"));
|
||||
nl3 = locationNode.getChildNodes();
|
||||
Node latNode = nl3.item(getNodeIndex(nl3, "lat"));
|
||||
double lat = Double.parseDouble(latNode.getTextContent());
|
||||
Node lngNode = nl3.item(getNodeIndex(nl3, "lng"));
|
||||
double lng = Double.parseDouble(lngNode.getTextContent());
|
||||
listGeopoints.add(new LatLng(lat, lng));
|
||||
|
||||
locationNode = nl2.item(getNodeIndex(nl2, "polyline"));
|
||||
nl3 = locationNode.getChildNodes();
|
||||
latNode = nl3.item(getNodeIndex(nl3, "points"));
|
||||
ArrayList<LatLng> arr = decodePoly(latNode.getTextContent());
|
||||
for (int j = 0; j < arr.size(); j++) {
|
||||
listGeopoints.add(new LatLng(arr.get(j).latitude, arr.get(j).longitude));
|
||||
}
|
||||
|
||||
locationNode = nl2.item(getNodeIndex(nl2, "end_location"));
|
||||
nl3 = locationNode.getChildNodes();
|
||||
latNode = nl3.item(getNodeIndex(nl3, "lat"));
|
||||
lat = Double.parseDouble(latNode.getTextContent());
|
||||
lngNode = nl3.item(getNodeIndex(nl3, "lng"));
|
||||
lng = Double.parseDouble(lngNode.getTextContent());
|
||||
listGeopoints.add(new LatLng(lat, lng));
|
||||
}
|
||||
}
|
||||
|
||||
return listGeopoints;
|
||||
}
|
||||
|
||||
public ArrayList<Direction> getDirections(Document doc) {
|
||||
NodeList nl1, nl2, nl3;
|
||||
ArrayList<Direction> listDirections = new ArrayList<Direction>();
|
||||
nl1 = doc.getElementsByTagName("step");
|
||||
if (nl1.getLength() > 0) {
|
||||
for (int i = 0; i < nl1.getLength(); i++) {
|
||||
|
||||
Direction d = new Direction();
|
||||
|
||||
Node node1 = nl1.item(i);
|
||||
nl2 = node1.getChildNodes();
|
||||
|
||||
Node locationNode = nl2.item(getNodeIndex(nl2, "duration"));
|
||||
nl3 = locationNode.getChildNodes();
|
||||
Node latNode = nl3.item(getNodeIndex(nl3, "text"));
|
||||
d.durationText = latNode.getTextContent();
|
||||
|
||||
|
||||
locationNode = nl2.item(getNodeIndex(nl2, "html_instructions"));
|
||||
d.html_instructions = locationNode.getTextContent();
|
||||
|
||||
locationNode = nl2.item(getNodeIndex(nl2, "distance"));
|
||||
nl3 = locationNode.getChildNodes();
|
||||
latNode = nl3.item(getNodeIndex(nl3, "text"));
|
||||
d.distanceText = latNode.getTextContent();
|
||||
|
||||
listDirections.add(d);
|
||||
}
|
||||
}
|
||||
|
||||
return listDirections;
|
||||
}
|
||||
|
||||
private int getNodeIndex(NodeList nl, String nodename) {
|
||||
for (int i = 0; i < nl.getLength(); i++) {
|
||||
if (nl.item(i).getNodeName().equals(nodename))
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private ArrayList<LatLng> decodePoly(String encoded) {
|
||||
ArrayList<LatLng> poly = new ArrayList<LatLng>();
|
||||
int index = 0, len = encoded.length();
|
||||
int lat = 0, lng = 0;
|
||||
while (index < len) {
|
||||
int b, shift = 0, result = 0;
|
||||
do {
|
||||
b = encoded.charAt(index++) - 63;
|
||||
result |= (b & 0x1f) << shift;
|
||||
shift += 5;
|
||||
} while (b >= 0x20);
|
||||
int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
|
||||
lat += dlat;
|
||||
shift = 0;
|
||||
result = 0;
|
||||
do {
|
||||
b = encoded.charAt(index++) - 63;
|
||||
result |= (b & 0x1f) << shift;
|
||||
shift += 5;
|
||||
} while (b >= 0x20);
|
||||
int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
|
||||
lng += dlng;
|
||||
|
||||
LatLng position = new LatLng((double) lat / 1E5, (double) lng / 1E5);
|
||||
poly.add(position);
|
||||
}
|
||||
return poly;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package id.ontime.customer.gmap.directions;
|
||||
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
|
||||
public class Bound {
|
||||
private LatLng northEast;
|
||||
private LatLng southWest;
|
||||
|
||||
public LatLng getNorthEast() {
|
||||
return northEast;
|
||||
}
|
||||
|
||||
public void setNorthEast(LatLng northEast) {
|
||||
this.northEast = northEast;
|
||||
}
|
||||
|
||||
public LatLng getSouthWest() {
|
||||
return southWest;
|
||||
}
|
||||
|
||||
public void setSouthWest(LatLng southWest) {
|
||||
this.southWest = southWest;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package id.ontime.customer.gmap.directions;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Directions {
|
||||
|
||||
Context context;
|
||||
private String ROUTES = "routes";
|
||||
private String SUMMARY = "summary";
|
||||
private String LEGS = "legs";
|
||||
private String DISTANCE = "distance";
|
||||
private String TEXT = "text";
|
||||
|
||||
private String STEPS = "steps";
|
||||
private String DURATION = "duration";
|
||||
private String END_LOCATION = "end_location";
|
||||
private String LATITUDE = "lat";
|
||||
private String HTML_INSTRUCTION = "html_instructions";
|
||||
private String OVERVIEW_POLYLINE = "overview_polyline";
|
||||
private String POLYLINE = "polyline";
|
||||
private String POINTS = "points";
|
||||
|
||||
private String START_LOCATION = "start_location";
|
||||
private String LONGITUDE = "lng";
|
||||
|
||||
private String VALUE = "value";
|
||||
|
||||
public Directions(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
||||
public String convertStreamToString(final InputStream input) throws Exception {
|
||||
try {
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(input));
|
||||
final StringBuffer sBuf = new StringBuffer();
|
||||
String line = null;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
sBuf.append(line);
|
||||
}
|
||||
return sBuf.toString();
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
} finally {
|
||||
try {
|
||||
input.close();
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<Route> parse(String routesJSONString) throws Exception {
|
||||
try {
|
||||
List<Route> routeList = new ArrayList<Route>();
|
||||
|
||||
final JSONObject jSONObject = new JSONObject(routesJSONString);
|
||||
JSONArray routeJSONArray = jSONObject.getJSONArray(ROUTES);
|
||||
Route route;
|
||||
JSONObject routesJSONObject;
|
||||
for (int m = 0; m < routeJSONArray.length(); m++) {
|
||||
route = new Route(context);
|
||||
routesJSONObject = routeJSONArray.getJSONObject(m);
|
||||
JSONArray legsJSONArray;
|
||||
route.setSummary(routesJSONObject.getString(SUMMARY));
|
||||
route.setOverviewPolyLine(decodePolyLines(routesJSONObject.getJSONObject(OVERVIEW_POLYLINE).getString(POINTS)));
|
||||
legsJSONArray = routesJSONObject.getJSONArray(LEGS);
|
||||
JSONObject legJSONObject;
|
||||
Leg leg;
|
||||
JSONArray stepsJSONArray;
|
||||
for (int b = 0; b < legsJSONArray.length(); b++) {
|
||||
leg = new Leg();
|
||||
legJSONObject = legsJSONArray.getJSONObject(b);
|
||||
leg.setDistance(new Distance(legJSONObject.optJSONObject(DISTANCE).optString(TEXT), legJSONObject.optJSONObject(DISTANCE).optLong(VALUE)));
|
||||
leg.setDuration(new Duration(legJSONObject.optJSONObject(DURATION).optString(TEXT), legJSONObject.optJSONObject(DURATION).optLong(VALUE)));
|
||||
stepsJSONArray = legJSONObject.getJSONArray(STEPS);
|
||||
JSONObject stepJSONObject, stepDurationJSONObject, legPolyLineJSONObject, stepStartLocationJSONObject, stepEndLocationJSONObject;
|
||||
Step step;
|
||||
String encodedString;
|
||||
LatLng stepStartLocationLatLng, stepEndLocationLatLng;
|
||||
for (int i = 0; i < stepsJSONArray.length(); i++) {
|
||||
stepJSONObject = stepsJSONArray.getJSONObject(i);
|
||||
step = new Step();
|
||||
JSONObject stepDistanceJSONObject = stepJSONObject.getJSONObject(DISTANCE);
|
||||
step.setDistance(new Distance(stepDistanceJSONObject.getString(TEXT), stepDistanceJSONObject.getLong(VALUE)));
|
||||
stepDurationJSONObject = stepJSONObject.getJSONObject(DURATION);
|
||||
step.setDuration(new Duration(stepDurationJSONObject.getString(TEXT), stepDurationJSONObject.getLong(VALUE)));
|
||||
stepEndLocationJSONObject = stepJSONObject.getJSONObject(END_LOCATION);
|
||||
stepEndLocationLatLng = new LatLng(stepEndLocationJSONObject.getDouble(LATITUDE), stepEndLocationJSONObject.getDouble(LONGITUDE));
|
||||
step.setEndLocation(stepEndLocationLatLng);
|
||||
step.setHtmlInstructions(stepJSONObject.getString(HTML_INSTRUCTION));
|
||||
legPolyLineJSONObject = stepJSONObject.getJSONObject(POLYLINE);
|
||||
encodedString = legPolyLineJSONObject.getString(POINTS);
|
||||
step.setPoints(decodePolyLines(encodedString));
|
||||
|
||||
stepStartLocationJSONObject = stepJSONObject.getJSONObject(START_LOCATION);
|
||||
stepStartLocationLatLng = new LatLng(stepStartLocationJSONObject.getDouble(LATITUDE), stepStartLocationJSONObject.getDouble(LONGITUDE));
|
||||
step.setStartLocation(stepStartLocationLatLng);
|
||||
leg.addStep(step);
|
||||
}
|
||||
route.addLeg(leg);
|
||||
}
|
||||
routeList.add(route);
|
||||
}
|
||||
return routeList;
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private ArrayList<LatLng> decodePolyLines(String encoded) {
|
||||
ArrayList<LatLng> poly = new ArrayList<LatLng>();
|
||||
int index = 0, len = encoded.length();
|
||||
int lat = 0, lng = 0;
|
||||
while (index < len) {
|
||||
int b, shift = 0, result = 0;
|
||||
do {
|
||||
b = encoded.charAt(index++) - 63;
|
||||
result |= (b & 0x1f) << shift;
|
||||
shift += 5;
|
||||
} while (b >= 0x20);
|
||||
int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
|
||||
lat += dlat;
|
||||
shift = 0;
|
||||
result = 0;
|
||||
do {
|
||||
b = encoded.charAt(index++) - 63;
|
||||
result |= (b & 0x1f) << shift;
|
||||
shift += 5;
|
||||
} while (b >= 0x20);
|
||||
int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
|
||||
lng += dlng;
|
||||
|
||||
LatLng position = new LatLng((double) lat / 1E5, (double) lng / 1E5);
|
||||
poly.add(position);
|
||||
}
|
||||
return poly;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package id.ontime.customer.gmap.directions;
|
||||
|
||||
public class Distance {
|
||||
private String text;
|
||||
private long value;
|
||||
|
||||
public Distance(String text, long value) {
|
||||
this.text = text;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public long getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(long value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package id.ontime.customer.gmap.directions;
|
||||
|
||||
public class Duration {
|
||||
private String text;
|
||||
private long value;
|
||||
|
||||
public Duration(String text, long value) {
|
||||
this.text = text;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public long getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(long value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package id.ontime.customer.gmap.directions;
|
||||
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Leg {
|
||||
private Distance distance;
|
||||
private Duration duration;
|
||||
private String endAddress;
|
||||
private LatLng endLocation;
|
||||
private String startAddress;
|
||||
private LatLng startLocation;
|
||||
private List<Step> steps;
|
||||
|
||||
public Leg() {
|
||||
steps = new ArrayList<Step>();
|
||||
}
|
||||
|
||||
public Distance getDistance() {
|
||||
return distance;
|
||||
}
|
||||
|
||||
public void setDistance(Distance distance) {
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
public Duration getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(Duration duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public String getEndAddress() {
|
||||
return endAddress;
|
||||
}
|
||||
|
||||
public void setEndAddress(String endAddress) {
|
||||
this.endAddress = endAddress;
|
||||
}
|
||||
|
||||
public LatLng getEndLocation() {
|
||||
return endLocation;
|
||||
}
|
||||
|
||||
public void setEndLocation(LatLng endLocation) {
|
||||
this.endLocation = endLocation;
|
||||
}
|
||||
|
||||
public String getStartAddress() {
|
||||
return startAddress;
|
||||
}
|
||||
|
||||
public void setStartAddress(String startAddress) {
|
||||
this.startAddress = startAddress;
|
||||
}
|
||||
|
||||
public LatLng getStartLocation() {
|
||||
return startLocation;
|
||||
}
|
||||
|
||||
public void setStartLocation(LatLng startLocation) {
|
||||
this.startLocation = startLocation;
|
||||
}
|
||||
|
||||
public List<Step> getSteps() {
|
||||
return steps;
|
||||
}
|
||||
|
||||
public void setSteps(List<Step> steps) {
|
||||
this.steps = steps;
|
||||
}
|
||||
|
||||
public void addStep(Step step) {
|
||||
this.steps.add(step);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package id.ontime.customer.gmap.directions;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Route implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Bound bounds;
|
||||
private String copyrights;
|
||||
private List<Leg> legs;
|
||||
private List<LatLng> overviewPolyLine;
|
||||
private String summary;
|
||||
|
||||
public Route(Context context) {
|
||||
legs = new ArrayList<Leg>();
|
||||
}
|
||||
|
||||
public static long getSerialversionuid() {
|
||||
return serialVersionUID;
|
||||
}
|
||||
|
||||
public Bound getBounds() {
|
||||
return bounds;
|
||||
}
|
||||
|
||||
public void setBounds(Bound bounds) {
|
||||
this.bounds = bounds;
|
||||
}
|
||||
|
||||
public String getCopyrights() {
|
||||
return copyrights;
|
||||
}
|
||||
|
||||
public void setCopyrights(String copyrights) {
|
||||
this.copyrights = copyrights;
|
||||
}
|
||||
|
||||
public List<Leg> getLegs() {
|
||||
return legs;
|
||||
}
|
||||
|
||||
public void setLegs(List<Leg> legs) {
|
||||
this.legs = legs;
|
||||
}
|
||||
|
||||
public void addLeg(Leg leg) {
|
||||
this.legs.add(leg);
|
||||
}
|
||||
|
||||
public List<LatLng> getOverviewPolyLine() {
|
||||
return overviewPolyLine;
|
||||
}
|
||||
|
||||
public void setOverviewPolyLine(List<LatLng> overviewPolyLine) {
|
||||
this.overviewPolyLine = overviewPolyLine;
|
||||
}
|
||||
|
||||
public String getSummary() {
|
||||
return summary;
|
||||
}
|
||||
|
||||
public void setSummary(String summary) {
|
||||
this.summary = summary;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package id.ontime.customer.gmap.directions;
|
||||
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Step {
|
||||
private Distance distance;
|
||||
private Duration duration;
|
||||
private LatLng endLocation;
|
||||
private LatLng startLocation;
|
||||
private String htmlInstructions;
|
||||
private String travelMode;
|
||||
private List<LatLng> points;
|
||||
|
||||
public List<LatLng> getPoints() {
|
||||
return points;
|
||||
}
|
||||
|
||||
public void setPoints(List<LatLng> points) {
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
public Distance getDistance() {
|
||||
return distance;
|
||||
}
|
||||
|
||||
public void setDistance(Distance distance) {
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
public Duration getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(Duration duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public LatLng getEndLocation() {
|
||||
return endLocation;
|
||||
}
|
||||
|
||||
public void setEndLocation(LatLng endLocation) {
|
||||
this.endLocation = endLocation;
|
||||
}
|
||||
|
||||
public LatLng getStartLocation() {
|
||||
return startLocation;
|
||||
}
|
||||
|
||||
public void setStartLocation(LatLng startLocation) {
|
||||
this.startLocation = startLocation;
|
||||
}
|
||||
|
||||
public String getHtmlInstructions() {
|
||||
return htmlInstructions;
|
||||
}
|
||||
|
||||
public void setHtmlInstructions(String htmlInstructions) {
|
||||
this.htmlInstructions = htmlInstructions;
|
||||
}
|
||||
|
||||
public String getTravelMode() {
|
||||
return travelMode;
|
||||
}
|
||||
|
||||
public void setTravelMode(String travelMode) {
|
||||
this.travelMode = travelMode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package id.ontime.customer.item;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.activity.AllMerchantActivity;
|
||||
import id.ontime.customer.activity.RentCarActivity;
|
||||
import id.ontime.customer.activity.RideCarActivity;
|
||||
import id.ontime.customer.activity.SendActivity;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.models.AllFiturModel;
|
||||
import id.ontime.customer.utils.PicassoTrustAll;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class AllFiturItem extends RecyclerView.Adapter<AllFiturItem.ItemRowHolder> {
|
||||
|
||||
private List<AllFiturModel> dataList;
|
||||
private Context mContext;
|
||||
private int rowLayout;
|
||||
|
||||
|
||||
public AllFiturItem(Context context, List<AllFiturModel> dataList, int rowLayout) {
|
||||
this.dataList = dataList;
|
||||
this.mContext = context;
|
||||
this.rowLayout = rowLayout;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ItemRowHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(rowLayout, parent, false);
|
||||
return new ItemRowHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final ItemRowHolder holder, final int position) {
|
||||
final AllFiturModel singleItem = dataList.get(position);
|
||||
holder.text.setText(singleItem.getFitur());
|
||||
PicassoTrustAll.getInstance(mContext)
|
||||
.load(Constants.IMAGESFITUR + singleItem.getIcon())
|
||||
// .resize(100, 100)
|
||||
.into(holder.image);
|
||||
|
||||
|
||||
if (!singleItem.getHome().equals("1")) {
|
||||
if (!singleItem.getHome().equals("2")) {
|
||||
if (singleItem.getHome().equals("3")) {
|
||||
holder.background.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(mContext, RentCarActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
i.putExtra("FiturKey", singleItem.getIdFitur());
|
||||
i.putExtra("icon", singleItem.getIcon());
|
||||
mContext.startActivity(i);
|
||||
|
||||
}
|
||||
});
|
||||
} else if (singleItem.getHome().equals("4")) {
|
||||
holder.background.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(mContext, AllMerchantActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
i.putExtra("FiturKey", singleItem.getIdFitur());
|
||||
mContext.startActivity(i);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
holder.background.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(mContext, SendActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
i.putExtra("FiturKey", singleItem.getIdFitur());
|
||||
i.putExtra("job", singleItem.getJob());
|
||||
i.putExtra("icon", singleItem.getIcon());
|
||||
mContext.startActivity(i);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
holder.background.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(mContext, RideCarActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
i.putExtra("FiturKey", singleItem.getIdFitur());
|
||||
i.putExtra("job", singleItem.getJob());
|
||||
i.putExtra("icon", singleItem.getIcon());
|
||||
mContext.startActivity(i);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return (null != dataList ? dataList.size() : 0);
|
||||
}
|
||||
|
||||
static class ItemRowHolder extends RecyclerView.ViewHolder {
|
||||
TextView text;
|
||||
ImageView background, image;
|
||||
|
||||
ItemRowHolder(View itemView) {
|
||||
super(itemView);
|
||||
background = itemView.findViewById(R.id.background);
|
||||
image = itemView.findViewById(R.id.image);
|
||||
text = itemView.findViewById(R.id.text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package id.ontime.customer.item;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.activity.DetailMerchantActivity;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.models.MerchantNearModel;
|
||||
import id.ontime.customer.utils.PicassoTrustAll;
|
||||
import com.facebook.shimmer.ShimmerFrameLayout;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
public class AllMerchantNearItem extends RecyclerView.Adapter<AllMerchantNearItem.ItemRowHolder> {
|
||||
|
||||
private List<MerchantNearModel> dataList;
|
||||
private Context mContext;
|
||||
private int rowLayout;
|
||||
|
||||
public AllMerchantNearItem(Context context, List<MerchantNearModel> dataList, int rowLayout) {
|
||||
this.dataList = dataList;
|
||||
this.mContext = context;
|
||||
this.rowLayout = rowLayout;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ItemRowHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(rowLayout, parent, false);
|
||||
return new ItemRowHolder(v);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final ItemRowHolder holder, final int position) {
|
||||
final MerchantNearModel singleItem = dataList.get(position);
|
||||
|
||||
float rate = Float.parseFloat(singleItem.getRate_merchant());
|
||||
String format1 = String.format(Locale.US, "%.1f",rate );
|
||||
holder.rate_merchant.setText(format1);
|
||||
|
||||
holder.name.setText(singleItem.getNama_merchant());
|
||||
if (!singleItem.getFoto_merchant().isEmpty()) {
|
||||
PicassoTrustAll.getInstance(mContext)
|
||||
.load(Constants.IMAGESMERCHANT + singleItem.getFoto_merchant())
|
||||
// .resize(250, 250)
|
||||
.into(holder.images);
|
||||
}
|
||||
|
||||
holder.kategori.setText(singleItem.getCategory_merchant());
|
||||
|
||||
if (singleItem.getStatus_promo().equals("1")) {
|
||||
holder.promobadge.setVisibility(View.VISIBLE);
|
||||
holder.shimmer.startShimmerAnimation();
|
||||
} else {
|
||||
holder.promobadge.setVisibility(View.GONE);
|
||||
holder.shimmer.stopShimmerAnimation();
|
||||
}
|
||||
|
||||
String[] parsedJamBuka = singleItem.getJam_buka().split(":");
|
||||
String[] parsedJamTutup = singleItem.getJam_tutup().split(":");
|
||||
|
||||
int jamBuka = Integer.parseInt(parsedJamBuka[0]), menitBuka = Integer.parseInt(parsedJamBuka[1]);
|
||||
int jamTutup = Integer.parseInt(parsedJamTutup[0]), menitTutup = Integer.parseInt(parsedJamTutup[1]);
|
||||
|
||||
int totalMenitBuka = (jamBuka * 60) + menitBuka;
|
||||
int totalMenitTutup = (jamTutup * 60) + menitTutup;
|
||||
|
||||
Calendar now = Calendar.getInstance();
|
||||
int totalMenitNow = (now.get(Calendar.HOUR_OF_DAY) * 60) + now.get(Calendar.MINUTE);
|
||||
holder.address.setText(singleItem.getAlamat_merchant());
|
||||
float km = Float.parseFloat(singleItem.getDistance());
|
||||
String format = String.format(Locale.US, "%.1f", km);
|
||||
|
||||
if (totalMenitNow <= totalMenitTutup && totalMenitNow >= totalMenitBuka) {
|
||||
holder.distance.setText(format + "km" + " " + mContext.getString(R.string.text_with_bullet) + " " + "Open");
|
||||
} else {
|
||||
holder.distance.setText(format + "km" + " " + mContext.getString(R.string.text_with_bullet) + " " + "Closed");
|
||||
}
|
||||
|
||||
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(mContext, DetailMerchantActivity.class);
|
||||
i.putExtra("lat", singleItem.getLatitude_merchant());
|
||||
i.putExtra("lon", singleItem.getLongitude_merchant());
|
||||
i.putExtra("id", singleItem.getId_merchant());
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
mContext.startActivity(i);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return (null != dataList ? dataList.size() : 0);
|
||||
}
|
||||
|
||||
static class ItemRowHolder extends RecyclerView.ViewHolder {
|
||||
TextView name, address, distance, kategori, rate_merchant;
|
||||
ImageView images;
|
||||
ShimmerFrameLayout shimmer;
|
||||
FrameLayout promobadge;
|
||||
|
||||
ItemRowHolder(View itemView) {
|
||||
super(itemView);
|
||||
images = itemView.findViewById(R.id.image);
|
||||
name = itemView.findViewById(R.id.nama);
|
||||
kategori = itemView.findViewById(R.id.kategori);
|
||||
shimmer = itemView.findViewById(R.id.shimreview);
|
||||
promobadge = itemView.findViewById(R.id.promobadge);
|
||||
address = itemView.findViewById(R.id.alamat);
|
||||
distance = itemView.findViewById(R.id.distance);
|
||||
rate_merchant = itemView.findViewById(R.id.rate_merchant);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package id.ontime.customer.item;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.models.BankModel;
|
||||
import id.ontime.customer.utils.PicassoTrustAll;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static android.content.Context.CLIPBOARD_SERVICE;
|
||||
|
||||
public class BankItem extends RecyclerView.Adapter<BankItem.ItemRowHolder> {
|
||||
|
||||
private List<BankModel> dataList;
|
||||
private Context mContext;
|
||||
private int rowLayout;
|
||||
|
||||
public BankItem(Context context, List<BankModel> dataList, int rowLayout) {
|
||||
this.dataList = dataList;
|
||||
this.mContext = context;
|
||||
this.rowLayout = rowLayout;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ItemRowHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(rowLayout, parent, false);
|
||||
return new ItemRowHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final ItemRowHolder holder, final int position) {
|
||||
final BankModel singleItem = dataList.get(position);
|
||||
PicassoTrustAll.getInstance(mContext)
|
||||
.load(Constants.IMAGESBANK + singleItem.getImage_bank())
|
||||
// .resize(250, 250)
|
||||
.into(holder.images);
|
||||
|
||||
holder.namabank.setText(singleItem.getNama_bank());
|
||||
holder.namapemilik.setText(singleItem.getNama_pemilik());
|
||||
holder.rekening.setText(singleItem.getRekening_bank());
|
||||
|
||||
|
||||
if (position % 2 == 1) {
|
||||
holder.background.setBackgroundColor(mContext.getResources().getColor(R.color.backgroundgray));
|
||||
// holder.imageView.setBackgroundColor(Color.parseColor("#FFFFFF"));
|
||||
} else {
|
||||
holder.background.setBackgroundColor(mContext.getResources().getColor(R.color.white));
|
||||
// holder.imageView.setBackgroundColor(Color.parseColor("#FFFAF8FD"));
|
||||
}
|
||||
|
||||
holder.rekening.setOnClickListener(new View.OnClickListener() {
|
||||
@SuppressLint("ObsoleteSdkInt")
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(mContext, "Disalin!", Toast.LENGTH_SHORT).show();
|
||||
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
|
||||
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) mContext.getSystemService(CLIPBOARD_SERVICE);
|
||||
Objects.requireNonNull(clipboard).setText(singleItem.getRekening_bank());
|
||||
} else {
|
||||
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) mContext.getSystemService(CLIPBOARD_SERVICE);
|
||||
android.content.ClipData clip = android.content.ClipData.newPlainText("Disalin!", singleItem.getRekening_bank());
|
||||
Objects.requireNonNull(clipboard).setPrimaryClip(clip);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return (null != dataList ? dataList.size() : 0);
|
||||
}
|
||||
|
||||
static class ItemRowHolder extends RecyclerView.ViewHolder {
|
||||
TextView namabank;
|
||||
TextView namapemilik, rekening;
|
||||
ImageView images;
|
||||
RelativeLayout background;
|
||||
|
||||
ItemRowHolder(View itemView) {
|
||||
super(itemView);
|
||||
background = itemView.findViewById(R.id.rootLayout);
|
||||
namabank = itemView.findViewById(R.id.namabank);
|
||||
namapemilik = itemView.findViewById(R.id.namapemilik);
|
||||
rekening = itemView.findViewById(R.id.norekening);
|
||||
images = itemView.findViewById(R.id.images);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package id.ontime.customer.item;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.activity.BeritaDetailActivity;
|
||||
import id.ontime.customer.constants.BaseApp;
|
||||
import id.ontime.customer.constants.Constants;
|
||||
import id.ontime.customer.models.BeritaModel;
|
||||
import id.ontime.customer.models.User;
|
||||
import id.ontime.customer.utils.DatabaseHelper;
|
||||
import id.ontime.customer.utils.PicassoTrustAll;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class BeritaItem extends RecyclerView.Adapter<BeritaItem.ItemRowHolder> {
|
||||
|
||||
private List<BeritaModel> dataList;
|
||||
private Context mContext;
|
||||
private int rowLayout;
|
||||
private DatabaseHelper databaseHelper;
|
||||
|
||||
public BeritaItem(List<BeritaModel> clickBerita) {
|
||||
this.dataList = clickBerita;
|
||||
}
|
||||
|
||||
public BeritaItem(Context context, List<BeritaModel> dataList, int rowLayout) {
|
||||
this.dataList = dataList;
|
||||
this.mContext = context;
|
||||
this.rowLayout = rowLayout;
|
||||
databaseHelper = new DatabaseHelper(mContext);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ItemRowHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(rowLayout, parent, false);
|
||||
return new ItemRowHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final ItemRowHolder holder, final int position) {
|
||||
final BeritaModel singleItem = dataList.get(position);
|
||||
holder.name.setText(singleItem.getTitle());
|
||||
if (!singleItem.getFotoberita().isEmpty()) {
|
||||
PicassoTrustAll.getInstance(mContext)
|
||||
.load(Constants.IMAGESBERITA + singleItem.getFotoberita())
|
||||
// .resize(250, 250)
|
||||
.into(holder.images);
|
||||
}
|
||||
|
||||
holder.category.setText(singleItem.getKategori());
|
||||
String htmlText = singleItem.getContent();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
holder.content.setText(Html.fromHtml(htmlText, Html.FROM_HTML_MODE_COMPACT));
|
||||
} else {
|
||||
holder.content.setText(Html.fromHtml(htmlText));
|
||||
}
|
||||
|
||||
final User loginUser = BaseApp.getInstance(mContext).getLoginUser();
|
||||
holder.favourite.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
ContentValues fav = new ContentValues();
|
||||
if (databaseHelper.getFavouriteById(String.valueOf(singleItem.getIdberita()))) {
|
||||
databaseHelper.removeFavouriteById(String.valueOf(singleItem.getIdberita()));
|
||||
holder.favourite.setColorFilter(mContext.getResources().getColor(R.color.gray));
|
||||
Toast.makeText(mContext, "Dihapus dari daftar Bookmark", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
fav.put(DatabaseHelper.KEY_ID, singleItem.getIdberita());
|
||||
fav.put(DatabaseHelper.KEY_USERID, loginUser.getId());
|
||||
fav.put(DatabaseHelper.KEY_TITLE, singleItem.getTitle());
|
||||
fav.put(DatabaseHelper.KEY_CONTENT, singleItem.getContent());
|
||||
fav.put(DatabaseHelper.KEY_KATEGORI, singleItem.getKategori());
|
||||
fav.put(DatabaseHelper.KEY_IMAGE, singleItem.getFotoberita());
|
||||
databaseHelper.addFavourite(DatabaseHelper.TABLE_FAVOURITE_NAME, fav, null);
|
||||
holder.favourite.setColorFilter(mContext.getResources().getColor(R.color.red));
|
||||
Toast.makeText(mContext, "Ditambahkan ke Bookmark", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
if (databaseHelper.getFavouriteById(String.valueOf(singleItem.getIdberita()))) {
|
||||
holder.favourite.setColorFilter(mContext.getResources().getColor(R.color.red));
|
||||
} else {
|
||||
holder.favourite.setColorFilter(mContext.getResources().getColor(R.color.gray));
|
||||
}
|
||||
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(mContext, BeritaDetailActivity.class);
|
||||
i.putExtra("id", singleItem.getIdberita());
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
mContext.startActivity(i);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return (null != dataList ? dataList.size() : 0);
|
||||
}
|
||||
|
||||
static class ItemRowHolder extends RecyclerView.ViewHolder {
|
||||
TextView name, category, content;
|
||||
ImageView images, favourite;
|
||||
CardView cardView;
|
||||
|
||||
ItemRowHolder(View itemView) {
|
||||
super(itemView);
|
||||
images = itemView.findViewById(R.id.image);
|
||||
name = itemView.findViewById(R.id.namakategori);
|
||||
category = itemView.findViewById(R.id.category);
|
||||
content = itemView.findViewById(R.id.content);
|
||||
favourite = itemView.findViewById(R.id.favourite);
|
||||
cardView = itemView.findViewById(R.id.card_view);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package id.ontime.customer.item;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.models.CatItemModel;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
public class CatItemItem extends RecyclerView.Adapter<CatItemItem.ItemRowHolder> {
|
||||
|
||||
private List<CatItemModel> dataList;
|
||||
private Context mContext;
|
||||
private int rowLayout;
|
||||
private int selectedPosition = 0;
|
||||
private CatItemItem.OnItemClickListener listener;
|
||||
|
||||
public CatItemItem(Context context, List<CatItemModel> dataList, int rowLayout, CatItemItem.OnItemClickListener listener) {
|
||||
this.dataList = dataList;
|
||||
this.mContext = context;
|
||||
this.rowLayout = rowLayout;
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ItemRowHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(rowLayout, parent, false);
|
||||
return new ItemRowHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final ItemRowHolder holder, final int position) {
|
||||
final CatItemModel singleItem = dataList.get(position);
|
||||
|
||||
holder.text.setText(singleItem.getNama_kategori());
|
||||
|
||||
if (position == selectedPosition) {
|
||||
holder.text.setTextColor(mContext.getResources().getColor(R.color.white));
|
||||
holder.background.setBackground(mContext.getResources().getDrawable(R.drawable.btn_rect));
|
||||
} else {
|
||||
holder.text.setTextColor(mContext.getResources().getColor(R.color.gray));
|
||||
holder.background.setBackground(mContext.getResources().getDrawable(R.drawable.btn_bordered));
|
||||
Random rand = new Random();
|
||||
int i = rand.nextInt(4);
|
||||
|
||||
|
||||
switch (i) {
|
||||
case 1:
|
||||
holder.background.getBackground().setColorFilter(Color.parseColor("#fd0f57"), PorterDuff.Mode.SRC_ATOP);
|
||||
holder.text.setTextColor(Color.parseColor("#fd0f57"));
|
||||
break;
|
||||
case 2:
|
||||
holder.background.getBackground().setColorFilter(Color.parseColor("#03abcc"), PorterDuff.Mode.SRC_ATOP);
|
||||
holder.text.setTextColor(Color.parseColor("#03abcc"));
|
||||
break;
|
||||
|
||||
case 3:
|
||||
holder.background.getBackground().setColorFilter(Color.parseColor("#00d953"), PorterDuff.Mode.SRC_ATOP);
|
||||
holder.text.setTextColor(Color.parseColor("#00d953"));
|
||||
break;
|
||||
|
||||
case 4:
|
||||
holder.background.getBackground().setColorFilter(Color.parseColor("#ffb700"), PorterDuff.Mode.SRC_ATOP);
|
||||
holder.text.setTextColor(Color.parseColor("#ffb700"));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
holder.bind(singleItem, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return (null != dataList ? dataList.size() : 0);
|
||||
}
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void onItemClick(CatItemModel item);
|
||||
}
|
||||
|
||||
class ItemRowHolder extends RecyclerView.ViewHolder {
|
||||
TextView text;
|
||||
LinearLayout background;
|
||||
|
||||
ItemRowHolder(View itemView) {
|
||||
super(itemView);
|
||||
text = itemView.findViewById(R.id.text);
|
||||
background = itemView.findViewById(R.id.background);
|
||||
}
|
||||
|
||||
public void bind(final CatItemModel item, final CatItemItem.OnItemClickListener listener) {
|
||||
|
||||
itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
listener.onItemClick(item);
|
||||
selectedPosition = getAdapterPosition();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package id.ontime.customer.item;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import id.ontime.customer.R;
|
||||
import id.ontime.customer.models.CatMerchantModel;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
public class CatMerchantItem extends RecyclerView.Adapter<CatMerchantItem.ItemRowHolder> {
|
||||
|
||||
private List<CatMerchantModel> dataList;
|
||||
private Context mContext;
|
||||
private int rowLayout;
|
||||
private int selectedPosition = 0;
|
||||
private CatMerchantItem.OnItemClickListener listener;
|
||||
|
||||
public CatMerchantItem(Context context, List<CatMerchantModel> dataList, int rowLayout, CatMerchantItem.OnItemClickListener listener) {
|
||||
this.dataList = dataList;
|
||||
this.mContext = context;
|
||||
this.rowLayout = rowLayout;
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ItemRowHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(rowLayout, parent, false);
|
||||
return new ItemRowHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final ItemRowHolder holder, final int position) {
|
||||
final CatMerchantModel singleItem = dataList.get(position);
|
||||
|
||||
holder.text.setText(singleItem.getNama_kategori());
|
||||
|
||||
if (position == selectedPosition) {
|
||||
holder.text.setTextColor(mContext.getResources().getColor(R.color.white));
|
||||
holder.background.setBackground(mContext.getResources().getDrawable(R.drawable.btn_rect));
|
||||
} else {
|
||||
holder.text.setTextColor(mContext.getResources().getColor(R.color.gray));
|
||||
holder.background.setBackground(mContext.getResources().getDrawable(R.drawable.btn_bordered));
|
||||
Random rand = new Random();
|
||||
int i = rand.nextInt(4);
|
||||
|
||||
|
||||
switch (i) {
|
||||
case 1:
|
||||
holder.background.getBackground().setColorFilter(Color.parseColor("#fd0f57"), PorterDuff.Mode.SRC_ATOP);
|
||||
holder.text.setTextColor(Color.parseColor("#fd0f57"));
|
||||
break;
|
||||
case 2:
|
||||
holder.background.getBackground().setColorFilter(Color.parseColor("#03abcc"), PorterDuff.Mode.SRC_ATOP);
|
||||
holder.text.setTextColor(Color.parseColor("#03abcc"));
|
||||
break;
|
||||
|
||||
case 3:
|
||||
holder.background.getBackground().setColorFilter(Color.parseColor("#00d953"), PorterDuff.Mode.SRC_ATOP);
|
||||
holder.text.setTextColor(Color.parseColor("#00d953"));
|
||||
break;
|
||||
|
||||
case 4:
|
||||
holder.background.getBackground().setColorFilter(Color.parseColor("#ffb700"), PorterDuff.Mode.SRC_ATOP);
|
||||
holder.text.setTextColor(Color.parseColor("#ffb700"));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
holder.bind(singleItem, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return (null != dataList ? dataList.size() : 0);
|
||||
}
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void onItemClick(CatMerchantModel item);
|
||||
}
|
||||
|
||||
class ItemRowHolder extends RecyclerView.ViewHolder {
|
||||
TextView text;
|
||||
LinearLayout background;
|
||||
|
||||
ItemRowHolder(View itemView) {
|
||||
super(itemView);
|
||||
text = itemView.findViewById(R.id.text);
|
||||
background = itemView.findViewById(R.id.background);
|
||||
}
|
||||
|
||||
public void bind(final CatMerchantModel item, final CatMerchantItem.OnItemClickListener listener) {
|
||||
|
||||
itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
listener.onItemClick(item);
|
||||
selectedPosition = getAdapterPosition();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user