Android
This commit is contained in:
parent
a9151efeac
commit
46880ae893
|
@ -0,0 +1,15 @@
|
|||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
local.properties
|
|
@ -0,0 +1 @@
|
|||
/build
|
|
@ -0,0 +1,52 @@
|
|||
plugins {
|
||||
id 'com.android.application'
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.example.travelapps'
|
||||
compileSdk 34
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.example.travelapps"
|
||||
minSdk 24
|
||||
targetSdk 34
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||
implementation 'com.google.android.material:material:1.8.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation 'com.android.volley:volley:1.2.1'
|
||||
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.7.0'
|
||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0'
|
||||
implementation 'androidx.navigation:navigation-fragment:2.5.3'
|
||||
implementation 'androidx.navigation:navigation-ui:2.5.3'
|
||||
implementation 'com.github.dangiashish:Google-Direction-Api:1.6'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||
implementation 'com.google.android.gms:play-services-maps:18.2.0'
|
||||
implementation 'com.google.android.gms:play-services-location:21.2.0'
|
||||
implementation 'com.midtrans:uikit:2.0.0-SANDBOX'
|
||||
// implementation 'com.midtrans:uikit:2.0.0'
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
|
@ -0,0 +1,26 @@
|
|||
package com.example.travelapps;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals("com.example.travelapps", appContext.getPackageName());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,198 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@drawable/logo"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:replace="android:allowBackup"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".pelanggan.MapsTujuanActivity"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".pelanggan.AboutActivity"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".sopir.DetailSopirActivity"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".sopir.ProfileSopirActivity"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".pelanggan.NewPasswordActivity"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".pelanggan.OtpActivity"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".pelanggan.ForgotPasswordActivity"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".PaymentMidtransWebView"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".pelanggan.ProfileActivity"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".sopir.MapsSopirActivity"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".sopir.HomeSopirActivity"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".sopir.RegisterSopirActivity"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".sopir.LoginSopirActivity"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".pelanggan.DetailPemesananActivity"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".pelanggan.PaymentMidtransActivity"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".pelanggan.FromMapsActivity"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".pelanggan.CurrentLocationActivity"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".DaftarActivity"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".TambahLokasiJemput"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".pelanggan.PesanActivity"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".pelanggan.TiketActivity"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".pelanggan.HomeActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".LoginActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".WelcomeActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".pelanggan.MainActivity"
|
||||
android:exported="true">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
|
||||
<meta-data
|
||||
android:name="com.google.android.geo.API_KEY"
|
||||
android:value="AIzaSyDzpS5kh7o6O9YWq3wOvDVCrHOgY6mPz3U" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -0,0 +1,52 @@
|
|||
package com.example.travelapps.Adapter;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.travelapps.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class InfoAdapter extends RecyclerView.Adapter<InfoAdapter.ViewHolder> {
|
||||
private List<Integer> itemList;
|
||||
private Context context;
|
||||
|
||||
public InfoAdapter(Context context, List<Integer> itemList) {
|
||||
this.context = context;
|
||||
this.itemList = itemList;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_info, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
int imageResourceId = itemList.get(position); // Get the image resource ID
|
||||
holder.imageView.setImageResource(imageResourceId); // Set the image resource
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return itemList.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
ImageView imageView;
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
imageView = itemView.findViewById(R.id.imageView);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.example.travelapps.Adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.travelapps.Model.Kota;
|
||||
import com.example.travelapps.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class KotaAdapter extends ArrayAdapter<String> {
|
||||
|
||||
private Context context;
|
||||
private List<String> kotaList;
|
||||
|
||||
public KotaAdapter(@NonNull Context context, @NonNull List<String> kotaList) {
|
||||
super(context, 0, kotaList);
|
||||
this.context = context;
|
||||
this.kotaList = kotaList;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
||||
return initView(position, convertView, parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
||||
return initView(position, convertView, parent);
|
||||
}
|
||||
|
||||
private View initView(int position, View convertView, ViewGroup parent) {
|
||||
if (convertView == null) {
|
||||
convertView = LayoutInflater.from(getContext()).inflate(R.layout.spiner_item, parent, false);
|
||||
}
|
||||
|
||||
TextView textViewName = convertView.findViewById(R.id.names);
|
||||
String currentKota = getItem(position);
|
||||
|
||||
if (currentKota != null) {
|
||||
textViewName.setText(currentKota);
|
||||
}
|
||||
|
||||
return convertView;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.example.travelapps.Adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.example.travelapps.Model.Notifikasi;
|
||||
import com.example.travelapps.R;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class NotifikasiAdapter extends RecyclerView.Adapter<NotifikasiViewHolder> {
|
||||
private List<Notifikasi> notifikasiList;
|
||||
private Context context;
|
||||
|
||||
public NotifikasiAdapter(Context context, List<Notifikasi> notifikasiList) {
|
||||
this.context = context;
|
||||
this.notifikasiList = notifikasiList;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public NotifikasiViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.notification_list, parent, false);
|
||||
return new NotifikasiViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull NotifikasiViewHolder holder, int position) {
|
||||
Notifikasi notifikasi = notifikasiList.get(position);
|
||||
holder.tvTitle.setText(notifikasi.getTitle());
|
||||
holder.tvDesc.setText(notifikasi.getDesc());
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.getDefault());
|
||||
holder.tvDate.setText(dateFormat.format(notifikasi.getCreatedAt()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return notifikasiList.size();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.example.travelapps.Adapter;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.travelapps.R;
|
||||
|
||||
public class NotifikasiViewHolder extends RecyclerView.ViewHolder {
|
||||
public TextView tvDate, tvTitle, tvDesc;
|
||||
|
||||
public NotifikasiViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
tvDate = itemView.findViewById(R.id.tv_date);
|
||||
tvTitle = itemView.findViewById(R.id.tv_title);
|
||||
tvDesc = itemView.findViewById(R.id.tv_desc);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.example.travelapps.Adapter;
|
||||
|
||||
import com.example.travelapps.Model.TiketData;
|
||||
import com.example.travelapps.Model.TiketSopir;
|
||||
|
||||
public interface OnItemTiketClickListener {
|
||||
void onItemClick(TiketData tiketData);
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.example.travelapps.Adapter;
|
||||
|
||||
import com.example.travelapps.Model.TiketSopir;
|
||||
|
||||
public interface OnItemTiketSopirClickListener {
|
||||
void onItemClick(TiketSopir tiketData);
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package com.example.travelapps.Adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.travelapps.pelanggan.DetailPemesananActivity;
|
||||
import com.example.travelapps.Model.Pemesanan;
|
||||
import com.example.travelapps.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PemesananAdapter extends RecyclerView.Adapter<PemesananAdapter.PemesananViewHolder> {
|
||||
|
||||
private List<Pemesanan.PemesananData> pemesananList;
|
||||
private Context context;
|
||||
|
||||
|
||||
public PemesananAdapter(Context context, List<Pemesanan.PemesananData> pemesananList) {
|
||||
this.context = context;
|
||||
this.pemesananList = pemesananList;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public PemesananViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.pemesanan_list, parent, false);
|
||||
return new PemesananViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull PemesananViewHolder holder, int position) {
|
||||
Pemesanan.PemesananData pemesanan = pemesananList.get(position);
|
||||
holder.bind(pemesanan);
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(context, DetailPemesananActivity.class);
|
||||
intent.putExtra("pemesananData", pemesanan);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return pemesananList.size();
|
||||
}
|
||||
|
||||
public class PemesananViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private TextView orderIdTextView;
|
||||
private TextView waktuTextView;
|
||||
private TextView tanggalBerangkatTextView;
|
||||
private TextView asalTextView;
|
||||
private TextView tujuanTextView;
|
||||
|
||||
public PemesananViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
orderIdTextView = itemView.findViewById(R.id.order_id);
|
||||
tanggalBerangkatTextView = itemView.findViewById(R.id.date);
|
||||
asalTextView = itemView.findViewById(R.id.asal);
|
||||
waktuTextView = itemView.findViewById(R.id.waktu);
|
||||
tujuanTextView = itemView.findViewById(R.id.Tujuan);
|
||||
}
|
||||
|
||||
public void bind(Pemesanan.PemesananData pemesananData) {
|
||||
orderIdTextView.setText(pemesananData.getOrderId());
|
||||
waktuTextView.setText(pemesananData.getWaktuKeberangkatan());
|
||||
tanggalBerangkatTextView.setText(pemesananData.getTanggalBerangkat());
|
||||
asalTextView.setText(pemesananData.getKotaAsal());
|
||||
tujuanTextView.setText(pemesananData.getKotaTujuan());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package com.example.travelapps.Adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.AppCompatButton;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.travelapps.Model.PemesananSopir;
|
||||
import com.example.travelapps.R;
|
||||
import com.example.travelapps.sopir.ApiServicesSopir;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PenumpangAdapter extends RecyclerView.Adapter<PenumpangAdapter.PenumpangViewHolder> {
|
||||
|
||||
private List<PemesananSopir> penumpangList;
|
||||
private Context context;
|
||||
|
||||
public PenumpangAdapter(Context context, List<PemesananSopir> penumpangList) {
|
||||
this.context = context;
|
||||
this.penumpangList = penumpangList;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public PenumpangViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.penumpang_list_active, parent, false);
|
||||
return new PenumpangViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull PenumpangViewHolder holder, int position) {
|
||||
PemesananSopir penumpang = penumpangList.get(position);
|
||||
holder.txtName.setText(penumpang.getNamaLengkap());
|
||||
holder.txtAlamat.setText(penumpang.getAlamatJemput());
|
||||
holder.txtJumlah.setText(penumpang.getQty());
|
||||
holder.txtTelp.setText(penumpang.getNotelp());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return penumpangList.size();
|
||||
}
|
||||
|
||||
public class PenumpangViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView txtName, txtAlamat, txtJumlah, txtTelp;
|
||||
|
||||
public PenumpangViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
txtName = itemView.findViewById(R.id.name);
|
||||
txtJumlah = itemView.findViewById(R.id.jumlah);
|
||||
txtAlamat = itemView.findViewById(R.id.address);
|
||||
txtTelp = itemView.findViewById(R.id.telp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
package com.example.travelapps.Adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.AppCompatButton;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.travelapps.Model.PemesananSopir;
|
||||
import com.example.travelapps.R;
|
||||
import com.example.travelapps.sopir.ApiServicesSopir;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PenumpangAdapterActive extends RecyclerView.Adapter<PenumpangAdapterActive.PenumpangViewHolder> {
|
||||
|
||||
private List<PemesananSopir> penumpangList;
|
||||
private Context context;
|
||||
private OnStatusUpdateListener onStatusUpdateListener;
|
||||
private boolean isDestinationLocation = false;
|
||||
|
||||
public PenumpangAdapterActive(Context context, List<PemesananSopir> penumpangList, OnStatusUpdateListener onStatusUpdateListener) {
|
||||
this.context = context;
|
||||
this.penumpangList = penumpangList;
|
||||
this.onStatusUpdateListener = onStatusUpdateListener;
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public PenumpangViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.penumpang_list, parent, false);
|
||||
return new PenumpangViewHolder(view);
|
||||
}
|
||||
|
||||
public void setDestinationLocation(boolean isDestinationLocation) {
|
||||
this.isDestinationLocation = isDestinationLocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull PenumpangViewHolder holder, int position) {
|
||||
PemesananSopir penumpang = penumpangList.get(position);
|
||||
holder.txtName.setText(penumpang.getNamaLengkap());
|
||||
holder.txtAlamat.setText(penumpang.getAlamatJemput());
|
||||
holder.txtJumlah.setText(penumpang.getQty());
|
||||
holder.txtTelp.setText(penumpang.getNotelp());
|
||||
if (isDestinationLocation) {
|
||||
holder.txtAlamat.setText(penumpang.getAlamatTujuan());
|
||||
holder.txtUrutan.setVisibility(View.GONE);
|
||||
if (penumpang.getAntar().equalsIgnoreCase("active")) {
|
||||
holder.btnSelesai.setVisibility(View.VISIBLE);
|
||||
holder.btnSelesai.setText("antar");
|
||||
holder.btnSelesai.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
ApiServicesSopir.tujuanStatus(context, penumpang.getIdPemesanan(), new ApiServicesSopir.UpdateStatusResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String message) {
|
||||
Toast.makeText(context, "Berhasil update status pengantaran", Toast.LENGTH_SHORT).show();
|
||||
if (onStatusUpdateListener != null) {
|
||||
onStatusUpdateListener.onStatusUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Log.e("update-status" , message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}else {
|
||||
holder.btnSelesai.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
} else {
|
||||
holder.txtUrutan.setVisibility(View.VISIBLE);
|
||||
holder.txtUrutan.setText("Penjemputan ke-" + (position + 1));
|
||||
holder.btnSelesai.setVisibility(View.VISIBLE);
|
||||
holder.btnSelesai.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
ApiServicesSopir.updateStatus(context, penumpang.getIdPemesanan(), new ApiServicesSopir.UpdateStatusResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String message) {
|
||||
Toast.makeText(context, "Berhasil update status penjemputan", Toast.LENGTH_SHORT).show();
|
||||
if (onStatusUpdateListener != null) {
|
||||
onStatusUpdateListener.onStatusUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Log.e("update-status" , message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return penumpangList.size();
|
||||
}
|
||||
public interface OnStatusUpdateListener {
|
||||
void onStatusUpdated();
|
||||
}
|
||||
public class PenumpangViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView txtName, txtAlamat, txtJumlah, txtTelp, txtUrutan;
|
||||
AppCompatButton btnSelesai;
|
||||
|
||||
public PenumpangViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
txtName = itemView.findViewById(R.id.name);
|
||||
txtJumlah = itemView.findViewById(R.id.jumlah);
|
||||
txtAlamat = itemView.findViewById(R.id.address);
|
||||
txtUrutan = itemView.findViewById(R.id.urutan);
|
||||
txtTelp = itemView.findViewById(R.id.telp);
|
||||
btnSelesai = itemView.findViewById(R.id.btn_selesai);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
package com.example.travelapps.Adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.travelapps.Model.TiketSopir;
|
||||
import com.example.travelapps.R;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
|
||||
public class PerjalananSopirAdapter extends RecyclerView.Adapter<PerjalananSopirAdapter.PerjalananSopirViewHolder>{
|
||||
private List<TiketSopir> tiketList;
|
||||
private Context context;
|
||||
private OnItemTiketSopirClickListener itemClickListener;
|
||||
|
||||
public PerjalananSopirAdapter(Context context, List<TiketSopir> tiketList, OnItemTiketSopirClickListener itemClickListener) {
|
||||
this.context = context;
|
||||
this.tiketList = tiketList;
|
||||
this.itemClickListener = itemClickListener;
|
||||
}
|
||||
@NonNull
|
||||
@Override
|
||||
public PerjalananSopirAdapter.PerjalananSopirViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.pemesanan_list_sopir, parent, false);
|
||||
return new PerjalananSopirViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull PerjalananSopirAdapter.PerjalananSopirViewHolder holder, int position) {
|
||||
TiketSopir tiket = tiketList.get(position);
|
||||
holder.bind(tiket);
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
itemClickListener.onItemClick(tiket);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return tiketList.size();
|
||||
}
|
||||
|
||||
class PerjalananSopirViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView dateTextView, asalTextView, tujuanTextView, waktuTextView, hargaTextView, totalTextView;
|
||||
|
||||
PerjalananSopirViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
dateTextView = itemView.findViewById(R.id.tanggal);
|
||||
asalTextView = itemView.findViewById(R.id.tv_kota_asal);
|
||||
tujuanTextView = itemView.findViewById(R.id.tv_kota_tujuan);
|
||||
waktuTextView = itemView.findViewById(R.id.waktu);
|
||||
hargaTextView = itemView.findViewById(R.id.iv_harga);
|
||||
totalTextView = itemView.findViewById(R.id.iv_total);
|
||||
}
|
||||
|
||||
void bind(TiketSopir tiket) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd MMMM yyyy");
|
||||
|
||||
String tanggalFormatted = sdf.format(tiket.getTanggal());
|
||||
|
||||
dateTextView.setText(tanggalFormatted);
|
||||
asalTextView.setText(tiket.getAsal());
|
||||
tujuanTextView.setText(tiket.getTujuan());
|
||||
waktuTextView.setText(tiket.getWaktu());
|
||||
String hargaString = String.format("Rp %.2f", tiket.getHarga());
|
||||
hargaTextView.setText(hargaString);
|
||||
totalTextView.setText(tiket.getTotalPenumpang());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package com.example.travelapps.Adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.travelapps.Model.TiketData;
|
||||
import com.example.travelapps.R;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
|
||||
public class TiketAdapter extends RecyclerView.Adapter<TiketAdapter.TiketViewHolder> {
|
||||
private List<TiketData> tiketList;
|
||||
private Context context;
|
||||
private OnItemTiketClickListener itemClickListener;
|
||||
private String jumlahPenumpang;
|
||||
|
||||
public TiketAdapter(Context context, List<TiketData> tiketList, OnItemTiketClickListener itemClickListener, String jumlahPenumpang) {
|
||||
this.context = context;
|
||||
this.tiketList = tiketList;
|
||||
this.itemClickListener = itemClickListener;
|
||||
this.jumlahPenumpang = jumlahPenumpang;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public TiketViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_tiket, parent, false);
|
||||
return new TiketViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull TiketViewHolder holder, int position) {
|
||||
TiketData tiket = tiketList.get(position);
|
||||
holder.bind(tiket);
|
||||
int penumpangRequired = Integer.parseInt(jumlahPenumpang);
|
||||
int penumpangAvailable = tiket.getJumlahPenumpangInt();
|
||||
if (penumpangAvailable < penumpangRequired || penumpangAvailable == 0) {
|
||||
holder.itemView.setAlpha(0.5f);
|
||||
holder.itemView.setOnClickListener(null);
|
||||
} else {
|
||||
holder.itemView.setAlpha(1.0f);
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
itemClickListener.onItemClick(tiket);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return tiketList.size();
|
||||
}
|
||||
|
||||
class TiketViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView dateTextView, asalTextView, tujuanTextView, waktuTextView, hargaTextView, statusTextView, penumpangTextView;
|
||||
|
||||
TiketViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
dateTextView = itemView.findViewById(R.id.date);
|
||||
asalTextView = itemView.findViewById(R.id.asal);
|
||||
tujuanTextView = itemView.findViewById(R.id.Tujuan);
|
||||
waktuTextView = itemView.findViewById(R.id.waktu);
|
||||
hargaTextView = itemView.findViewById(R.id.harga);
|
||||
statusTextView = itemView.findViewById(R.id.status);
|
||||
penumpangTextView = itemView.findViewById(R.id.penumpang);
|
||||
}
|
||||
|
||||
void bind(TiketData tiket) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd MMMM yyyy");
|
||||
|
||||
// Mengonversi objek Date menjadi string tanggal dengan format yang diinginkan
|
||||
String tanggalFormatted = sdf.format(tiket.getTanggal());
|
||||
|
||||
// Mengatur teks untuk setiap TextView dengan data dari objek TiketData
|
||||
dateTextView.setText(tanggalFormatted);
|
||||
asalTextView.setText(tiket.getAsal());
|
||||
tujuanTextView.setText(tiket.getTujuan());
|
||||
waktuTextView.setText(tiket.getWaktu());
|
||||
String hargaString = String.format("Rp %.2f", tiket.getHarga());
|
||||
hargaTextView.setText(hargaString);
|
||||
statusTextView.setText(tiket.getStatus());
|
||||
penumpangTextView.setText("Sisa tiket : " + tiket.getJumlahPenumpang());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
package com.example.travelapps;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.travelapps.Services.ApiServices;
|
||||
import com.example.travelapps.R;
|
||||
|
||||
public class DaftarActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
|
||||
Button btnDaftar;
|
||||
TextView tvLogin;
|
||||
EditText etEmail, etNama, etNotelp, etAlamat, etPassword, etNik;
|
||||
|
||||
@SuppressLint("MissingInflatedId")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_daftar);
|
||||
|
||||
btnDaftar = findViewById(R.id.buttonRegister);
|
||||
tvLogin = findViewById(R.id.tx_login);
|
||||
etEmail = findViewById(R.id.et_email);
|
||||
etNama = findViewById(R.id.et_nama);
|
||||
etNotelp = findViewById(R.id.et_telp);
|
||||
etAlamat = findViewById(R.id.et_alamat);
|
||||
etPassword = findViewById(R.id.et_password);
|
||||
etNik = findViewById(R.id.et_nik);
|
||||
|
||||
|
||||
btnDaftar.setOnClickListener(this);
|
||||
tvLogin.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v == tvLogin) {
|
||||
Intent i = new Intent(this, LoginActivity.class);
|
||||
startActivity(i);
|
||||
} else {
|
||||
String email = etEmail.getText().toString().trim();
|
||||
String password = etPassword.getText().toString().trim();
|
||||
String notelp = etNotelp.getText().toString().trim();
|
||||
String nama = etNama.getText().toString().trim();
|
||||
String alamat = etAlamat.getText().toString().trim();
|
||||
String nik = etNik.getText().toString().trim();
|
||||
|
||||
if (email.isEmpty()) {
|
||||
etEmail.setError("Email tidak boleh kosong");
|
||||
} else if(!isValidEmail(email)){
|
||||
etEmail.setError("Format email tidak valid");
|
||||
} else if(notelp.isEmpty()){
|
||||
etNotelp.setError("No. Telepon tidak boleh kosong");
|
||||
} else if(notelp.length()>13){
|
||||
etNotelp.setError("No. Telepon tidak boleh lebih dari 13 angka");
|
||||
} else if(alamat.isEmpty()){
|
||||
etAlamat.setError("Alamat tidak boleh kosong");
|
||||
}else if (nik.isEmpty()) {
|
||||
etNik.setError("Nik tidak boleh kosong");
|
||||
}else if (nik.length() > 16) {
|
||||
etNik.setError("Nik tidak boleh lebih dari 16 angka");
|
||||
} else if (password.isEmpty()){
|
||||
etPassword.setError("Password tidak boleh kosong");
|
||||
} else if (password.length() < 8) {
|
||||
etPassword.setError("Panjang password harus minimal 8 karakter");
|
||||
} else {
|
||||
ApiServices.register(DaftarActivity.this, nama, notelp, email, alamat, password, nik, new ApiServices.RegisterResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String message) {
|
||||
Toast.makeText(DaftarActivity.this, "Berhasil Daftar Akun", Toast.LENGTH_LONG).show();
|
||||
Intent i = new Intent(DaftarActivity.this, LoginActivity.class);
|
||||
startActivity(i);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Toast.makeText(DaftarActivity.this, message, Toast.LENGTH_LONG).show();
|
||||
Log.e("Error Register", message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
private boolean isValidEmail(CharSequence target) {
|
||||
return !TextUtils.isEmpty(target) && android.util.Patterns.EMAIL_ADDRESS.matcher(target).matches();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
package com.example.travelapps.Fragment;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.travelapps.Adapter.PemesananAdapter;
|
||||
import com.example.travelapps.Model.Pemesanan;
|
||||
import com.example.travelapps.Model.User;
|
||||
import com.example.travelapps.R;
|
||||
import com.example.travelapps.Services.ApiServices;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link FragmentActivity#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class FragmentActivity extends Fragment {
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
private static final String ARG_PARAM2 = "param2";
|
||||
|
||||
// TODO: Rename and change types of parameters
|
||||
private String mParam1;
|
||||
private String mParam2;
|
||||
|
||||
public FragmentActivity() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this factory method to create a new instance of
|
||||
* this fragment using the provided parameters.
|
||||
*
|
||||
* @param param1 Parameter 1.
|
||||
* @param param2 Parameter 2.
|
||||
* @return A new instance of fragment FragmentActivity.
|
||||
*/
|
||||
// TODO: Rename and change types and number of parameters
|
||||
public static FragmentActivity newInstance(String param1, String param2) {
|
||||
FragmentActivity fragment = new FragmentActivity();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PARAM1, param1);
|
||||
args.putString(ARG_PARAM2, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
}
|
||||
RecyclerView recyclerView;
|
||||
PemesananAdapter adapter;
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View view = inflater.inflate(R.layout.fragment_activity, container, false);
|
||||
recyclerView = view.findViewById(R.id.recyclerView);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
|
||||
SharedPreferences preferences = requireActivity().getSharedPreferences("myPrefs", MODE_PRIVATE);
|
||||
String token = preferences.getString("token", "");
|
||||
ApiServices.getUserData(getContext(), token, new ApiServices.UserResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(User user) {
|
||||
String idUser = user.getId();
|
||||
ApiServices.showPemesanan(getContext(), idUser, new ApiServices.ShowPemesananResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(List<Pemesanan.PemesananData> pemesananDataList) {
|
||||
adapter = new PemesananAdapter(getContext(), pemesananDataList);
|
||||
recyclerView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Toast.makeText(getContext(), message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Log.e("Error", "Gagal mendapatkan data user");
|
||||
}
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,290 @@
|
|||
package com.example.travelapps.Fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.DatePickerDialog;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.text.InputFilter;
|
||||
import android.text.Spanned;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.DatePicker;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.travelapps.Adapter.InfoAdapter;
|
||||
import com.example.travelapps.Adapter.KotaAdapter;
|
||||
import com.example.travelapps.R;
|
||||
import com.example.travelapps.Services.ApiServices;
|
||||
import com.example.travelapps.pelanggan.TiketActivity;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link FragmentHome#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class FragmentHome extends Fragment {
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
private static final String ARG_PARAM2 = "param2";
|
||||
|
||||
// TODO: Rename and change types of parameters
|
||||
private String mParam1;
|
||||
private String mParam2;
|
||||
|
||||
private RecyclerView recyclerView;
|
||||
private InfoAdapter adapter;
|
||||
private List<Integer> itemList;
|
||||
|
||||
public FragmentHome() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this factory method to create a new instance of
|
||||
* this fragment using the provided parameters.
|
||||
*
|
||||
* @param param1 Parameter 1.
|
||||
* @param param2 Parameter 2.
|
||||
* @return A new instance of fragment FragmentHome.
|
||||
*/
|
||||
// TODO: Rename and change types and number of parameters
|
||||
public static FragmentHome newInstance(String param1, String param2) {
|
||||
FragmentHome fragment = new FragmentHome();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PARAM1, param1);
|
||||
args.putString(ARG_PARAM2, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
itemList = new ArrayList<>();
|
||||
itemList.add(R.drawable.banneratas);
|
||||
itemList.add(R.drawable.banner);
|
||||
|
||||
if (getArguments() != null) {
|
||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
}
|
||||
|
||||
EditText etPenumpang, etTanggal;
|
||||
Button btnPesan;
|
||||
private Spinner spinnerKotaAsal;
|
||||
private Spinner spinnerKotaTujuan;
|
||||
private KotaAdapter kotaAsalAdapter;
|
||||
private KotaAdapter kotaTujuanAdapter;
|
||||
|
||||
String selectedKotaAsal = "";
|
||||
String formattedDate = "";
|
||||
String selectedKotaTujuan = "";
|
||||
private DatePickerDialog.OnDateSetListener mDate;
|
||||
@SuppressLint("MissingInflatedId")
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_home, container, false);
|
||||
|
||||
etPenumpang = view.findViewById(R.id.etPenumpang);
|
||||
etTanggal = view.findViewById(R.id.et_tanggal);
|
||||
etPenumpang.setFilters(new InputFilter[]{new InputFilterMinMax("1", "10")});
|
||||
spinnerKotaAsal = view.findViewById(R.id.spinner_asal);
|
||||
spinnerKotaTujuan = view.findViewById(R.id.spinner_tujuan);
|
||||
etTanggal.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int year = calendar.get(Calendar.YEAR);
|
||||
int month = calendar.get(Calendar.MONTH);
|
||||
int day = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
DatePickerDialog dialog = new DatePickerDialog(getContext(),
|
||||
android.R.style.Theme_Holo_Light_Dialog_MinWidth,
|
||||
mDate, year,month,day);
|
||||
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
dialog.getDatePicker().setMinDate(calendar.getTimeInMillis());
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
// Inisialisasi adapter dengan list kosong
|
||||
kotaAsalAdapter = new KotaAdapter(getContext(), new ArrayList<>());
|
||||
kotaTujuanAdapter = new KotaAdapter(getContext(), new ArrayList<>());
|
||||
mDate = new DatePickerDialog.OnDateSetListener() {
|
||||
@Override
|
||||
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
|
||||
|
||||
Calendar selectedDate = Calendar.getInstance();
|
||||
selectedDate.set(year, month, dayOfMonth);
|
||||
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
|
||||
formattedDate = dateFormat.format(selectedDate.getTime());
|
||||
|
||||
etTanggal.setText(formattedDate);
|
||||
}
|
||||
};
|
||||
// Set adapter ke spinner
|
||||
spinnerKotaAsal.setAdapter(kotaAsalAdapter);
|
||||
spinnerKotaTujuan.setAdapter(kotaTujuanAdapter);
|
||||
ApiServices.getCity(getContext(), new ApiServices.GetCityResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(JSONObject response) {
|
||||
try {
|
||||
JSONArray kotaAsalArray = response.getJSONArray("kota_asal");
|
||||
JSONArray kotaTujuanArray = response.getJSONArray("kota_tujuan");
|
||||
|
||||
List<String> kotaAsalList = new ArrayList<>();
|
||||
List<String> kotaTujuanList = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < kotaAsalArray.length(); i++) {
|
||||
kotaAsalList.add(kotaAsalArray.getString(i));
|
||||
}
|
||||
|
||||
for (int i = 0; i < kotaTujuanArray.length(); i++) {
|
||||
kotaTujuanList.add(kotaTujuanArray.getString(i));
|
||||
}
|
||||
|
||||
// Update adapter dengan data baru
|
||||
kotaAsalAdapter.clear();
|
||||
kotaAsalAdapter.addAll(kotaAsalList);
|
||||
kotaAsalAdapter.notifyDataSetChanged();
|
||||
|
||||
kotaTujuanAdapter.clear();
|
||||
kotaTujuanAdapter.addAll(kotaTujuanList);
|
||||
kotaTujuanAdapter.notifyDataSetChanged();
|
||||
|
||||
final String[] selectedValue = {kotaAsalList.get(0)};
|
||||
|
||||
spinnerKotaAsal.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
selectedKotaAsal = (String) adapterView.getItemAtPosition(i);
|
||||
Toast.makeText(getContext(), selectedKotaAsal+" -> "+selectedValue[0], Toast.LENGTH_SHORT).show();
|
||||
if (kotaTujuanList.contains(selectedKotaAsal)) {
|
||||
kotaTujuanList.remove(selectedKotaAsal);
|
||||
}
|
||||
|
||||
if (!selectedValue[0].equalsIgnoreCase(selectedKotaAsal)) {
|
||||
kotaTujuanList.add(selectedValue[0]);
|
||||
}
|
||||
|
||||
kotaTujuanAdapter.clear();
|
||||
kotaTujuanAdapter.addAll(kotaTujuanList);
|
||||
kotaTujuanAdapter.notifyDataSetChanged();
|
||||
|
||||
selectedValue[0] = selectedKotaAsal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> adapterView) {
|
||||
// Do nothing
|
||||
}
|
||||
});
|
||||
|
||||
spinnerKotaTujuan.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
selectedKotaTujuan = (String) adapterView.getItemAtPosition(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> adapterView) {
|
||||
// Do nothing
|
||||
}
|
||||
});
|
||||
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
// Handle error
|
||||
}
|
||||
});
|
||||
|
||||
btnPesan = view.findViewById(R.id.buttonPesanSekarang);
|
||||
btnPesan.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String penumpang = etPenumpang.getText().toString().trim();
|
||||
|
||||
|
||||
if (selectedKotaAsal.isEmpty()) {
|
||||
Toast.makeText(getContext(), "Silahkan isi asal kota anda", Toast.LENGTH_SHORT).show();
|
||||
} else if (selectedKotaTujuan.isEmpty()){
|
||||
Toast.makeText(getContext(), "Silahkan isi tujuan kota anda", Toast.LENGTH_SHORT).show();
|
||||
} else if (selectedKotaAsal.equals(selectedKotaTujuan)) {
|
||||
Toast.makeText(getContext(), "Tujuan tidak boleh sama dengan asal", Toast.LENGTH_SHORT).show();
|
||||
} else if (penumpang.isEmpty()) {
|
||||
etPenumpang.setError("Silakan isi jumlah penumpang");
|
||||
} else {
|
||||
Intent intent = new Intent(getActivity(), TiketActivity.class);
|
||||
intent.putExtra("asal", selectedKotaAsal);
|
||||
intent.putExtra("tujuan", selectedKotaTujuan);
|
||||
intent.putExtra("tanggal", formattedDate);
|
||||
intent.putExtra("penumpang", penumpang);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
public class InputFilterMinMax implements InputFilter {
|
||||
private int min, max;
|
||||
|
||||
public InputFilterMinMax(int min, int max) {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
public InputFilterMinMax(String min, String max) {
|
||||
this.min = Integer.parseInt(min);
|
||||
this.max = Integer.parseInt(max);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
|
||||
try {
|
||||
int input = Integer.parseInt(dest.toString() + source.toString());
|
||||
if (isInRange(min, max, input)) {
|
||||
return null;
|
||||
}
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private boolean isInRange(int a, int b, int c) {
|
||||
return b > a ? c >= a && c <= b : c >= b && c <= a;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
package com.example.travelapps.Fragment;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.example.travelapps.Adapter.NotifikasiAdapter;
|
||||
import com.example.travelapps.Model.Notifikasi;
|
||||
import com.example.travelapps.Model.User;
|
||||
import com.example.travelapps.R;
|
||||
import com.example.travelapps.Services.ApiServices;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link FragmentNotifications#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class FragmentNotifications extends Fragment {
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
private static final String ARG_PARAM2 = "param2";
|
||||
|
||||
// TODO: Rename and change types of parameters
|
||||
private String mParam1;
|
||||
private String mParam2;
|
||||
|
||||
public FragmentNotifications() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this factory method to create a new instance of
|
||||
* this fragment using the provided parameters.
|
||||
*
|
||||
* @param param1 Parameter 1.
|
||||
* @param param2 Parameter 2.
|
||||
* @return A new instance of fragment FragmentNotifications.
|
||||
*/
|
||||
// TODO: Rename and change types and number of parameters
|
||||
public static FragmentNotifications newInstance(String param1, String param2) {
|
||||
FragmentNotifications fragment = new FragmentNotifications();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PARAM1, param1);
|
||||
args.putString(ARG_PARAM2, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
}
|
||||
NotifikasiAdapter notifikasiAdapter ;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View v = inflater.inflate(R.layout.fragment_notifications, container, false);
|
||||
RecyclerView recyclerView = v.findViewById(R.id.rv_notification);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
SharedPreferences preferences = requireActivity().getSharedPreferences("myPrefs", MODE_PRIVATE);
|
||||
String token = preferences.getString("token", "");
|
||||
ApiServices.getUserData(getContext(), token, new ApiServices.UserResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(User user) {
|
||||
String idUser = user.getId();
|
||||
ApiServices.getNotifikasi(getContext(), idUser, new ApiServices.NotifikasiResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(List<Notifikasi> notifikasiList) {
|
||||
notifikasiAdapter = new NotifikasiAdapter(getContext(), notifikasiList);
|
||||
recyclerView.setAdapter(notifikasiAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Log.e("notifications" , message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
|
||||
}
|
||||
});
|
||||
return v;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
package com.example.travelapps.Fragment;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.travelapps.pelanggan.AboutActivity;
|
||||
import com.example.travelapps.LoginActivity;
|
||||
import com.example.travelapps.Model.User;
|
||||
import com.example.travelapps.pelanggan.ProfileActivity;
|
||||
import com.example.travelapps.R;
|
||||
import com.example.travelapps.Services.ApiServices;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link FragmentSettings#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class FragmentSettings extends Fragment {
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
private static final String ARG_PARAM2 = "param2";
|
||||
|
||||
// TODO: Rename and change types of parameters
|
||||
private String mParam1;
|
||||
private String mParam2;
|
||||
|
||||
public FragmentSettings() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this factory method to create a new instance of
|
||||
* this fragment using the provided parameters.
|
||||
*
|
||||
* @param param1 Parameter 1.
|
||||
* @param param2 Parameter 2.
|
||||
* @return A new instance of fragment FragmentSettings.
|
||||
*/
|
||||
// TODO: Rename and change types and number of parameters
|
||||
public static FragmentSettings newInstance(String param1, String param2) {
|
||||
FragmentSettings fragment = new FragmentSettings();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PARAM1, param1);
|
||||
args.putString(ARG_PARAM2, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View view = inflater.inflate(R.layout.fragment_settings, container, false);
|
||||
SharedPreferences preferences = requireActivity().getSharedPreferences("myPrefs", MODE_PRIVATE);
|
||||
String token = preferences.getString("token", "");
|
||||
RelativeLayout relativeLayout = view.findViewById(R.id.profileSection);
|
||||
relativeLayout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(getActivity(), ProfileActivity.class);
|
||||
intent.putExtra("role", "user");
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
LinearLayout logout = view.findViewById(R.id.logout);
|
||||
logout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
SharedPreferences.Editor editor = getActivity().getSharedPreferences("myPrefs", MODE_PRIVATE).edit();
|
||||
editor.remove("isLogin");
|
||||
editor.remove("token");
|
||||
editor.apply();
|
||||
Intent intent = new Intent(getActivity(), LoginActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); // Clear activity stack
|
||||
startActivity(intent);
|
||||
requireActivity().finish();
|
||||
}
|
||||
});
|
||||
LinearLayout about = view.findViewById(R.id.about);
|
||||
about.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent i = new Intent(getActivity(), AboutActivity.class);
|
||||
startActivity(i);
|
||||
}
|
||||
});
|
||||
|
||||
// LinearLayout lupaPassword = view.findViewById(R.id.ganti_password);
|
||||
// lupaPassword.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
// Intent i = new Intent(getActivity(), ForgotPasswordActivity.class);
|
||||
// startActivity(i);
|
||||
// }
|
||||
// });
|
||||
ApiServices.getUserData(getContext(), token, new ApiServices.UserResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(User user) {
|
||||
TextView tvname = view.findViewById(R.id.userName);
|
||||
tvname.setText(user.getNama());
|
||||
TextView tvNickname = view.findViewById(R.id.profileImage);
|
||||
String twoInitials = user.getNama().substring(0, 2);
|
||||
twoInitials = twoInitials.toUpperCase();
|
||||
tvNickname.setText(twoInitials);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
|
||||
}
|
||||
});
|
||||
return view;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
package com.example.travelapps;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.example.travelapps.Services.ApiServices;
|
||||
import com.example.travelapps.pelanggan.HomeActivity;
|
||||
import com.example.travelapps.sopir.HomeSopirActivity;
|
||||
import com.example.travelapps.sopir.LoginSopirActivity;
|
||||
|
||||
public class LoginActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
|
||||
EditText etEmail, etPassword;
|
||||
TextView tvDaftar, tvLogin;
|
||||
Button btnLogin;
|
||||
@SuppressLint("MissingInflatedId")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
SharedPreferences preferences = getSharedPreferences("myPrefs", MODE_PRIVATE);
|
||||
boolean isLogin = preferences.getBoolean("isLogin", false);
|
||||
boolean isLoginSopir = preferences.getBoolean("isLoginSopir", false);
|
||||
|
||||
if (isLogin) {
|
||||
Intent intent = new Intent(LoginActivity.this, HomeActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
} else if(isLoginSopir){
|
||||
Intent intent = new Intent(LoginActivity.this, HomeSopirActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_login);
|
||||
|
||||
etEmail = findViewById(R.id.et_email);
|
||||
etPassword = findViewById(R.id.et_password);
|
||||
tvDaftar = findViewById(R.id.tx_daftar);
|
||||
btnLogin = findViewById(R.id.buttonLogin);
|
||||
tvLogin = findViewById(R.id.tv_login);
|
||||
tvDaftar.setOnClickListener(this);
|
||||
btnLogin.setOnClickListener(this);
|
||||
tvLogin.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v == btnLogin) {
|
||||
String email = etEmail.getText().toString().trim();
|
||||
String password = etPassword.getText().toString().trim();
|
||||
if (email.isEmpty()) {
|
||||
etEmail.setError("Email tidak boleh kosong");
|
||||
} else if(!isValidEmail(email)){
|
||||
etEmail.setError("Format email tidak valid");
|
||||
} else if (password.isEmpty()){
|
||||
etPassword.setError("Password tidak boleh kosong");
|
||||
} else if (password.length() < 8) {
|
||||
etPassword.setError("Panjang password harus minimal 8 karakter");
|
||||
} else {
|
||||
ApiServices.login(LoginActivity.this, email, password, new ApiServices.LoginResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String message) {
|
||||
Toast.makeText(LoginActivity.this, "Berhasil Login", Toast.LENGTH_LONG).show();
|
||||
Intent i = new Intent(LoginActivity.this, HomeActivity.class);
|
||||
startActivity(i);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Toast.makeText(LoginActivity.this, message, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (v == tvDaftar){
|
||||
Intent i = new Intent(this, DaftarActivity.class);
|
||||
startActivity(i);
|
||||
} else if (v == tvLogin) {
|
||||
Intent i = new Intent(this, LoginSopirActivity.class);
|
||||
startActivity(i);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isValidEmail(CharSequence target) {
|
||||
return !TextUtils.isEmpty(target) && android.util.Patterns.EMAIL_ADDRESS.matcher(target).matches();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.example.travelapps.Model;
|
||||
|
||||
public class Bank {
|
||||
private String bank;
|
||||
private String vaNumber;
|
||||
|
||||
// Constructor
|
||||
public Bank(String bank, String vaNumber) {
|
||||
this.bank = bank;
|
||||
this.vaNumber = vaNumber;
|
||||
}
|
||||
|
||||
// Getter methods
|
||||
public String getBank() {
|
||||
return bank;
|
||||
}
|
||||
|
||||
public String getVaNumber() {
|
||||
return vaNumber;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.example.travelapps.Model;
|
||||
|
||||
public class InfoItem {
|
||||
private int image;
|
||||
|
||||
public InfoItem(int image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public int getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public void setImage(int image) {
|
||||
this.image = image;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.example.travelapps.Model;
|
||||
|
||||
public class Kota {
|
||||
private String id;
|
||||
private String nama;
|
||||
|
||||
public Kota(String id, String nama) {
|
||||
this.id = id;
|
||||
this.nama = nama;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getNama() {
|
||||
return nama;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.example.travelapps.Model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class Notifikasi {
|
||||
private String title;
|
||||
private String desc;
|
||||
private Date createdAt;
|
||||
|
||||
public Notifikasi(String title, String desc, Date createdAt) {
|
||||
this.title = title;
|
||||
this.desc = desc;
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public Date getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,174 @@
|
|||
package com.example.travelapps.Model;
|
||||
|
||||
import android.os.Parcelable;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public interface Pemesanan {
|
||||
void onSuccess(List<PemesananData> pemesananDataList);
|
||||
void onError(String message);
|
||||
|
||||
class PemesananData implements Serializable {
|
||||
private String idPemesanan;
|
||||
private String idUser;
|
||||
private String idPerjalanan;
|
||||
private String qty;
|
||||
private String orderId;
|
||||
private String alamatJemput;
|
||||
private String alamatTujuan;
|
||||
private String waktuJemput;
|
||||
private String status;
|
||||
private String tanggalPesan;
|
||||
private String tanggalBerangkat;
|
||||
private String harga;
|
||||
private String kotaAsal;
|
||||
private String kotaTujuan;
|
||||
private String tanggal;
|
||||
private String waktuKeberangkatan;
|
||||
|
||||
public PemesananData(String idPemesanan, String idUser, String idPerjalanan, String qty, String orderId, String alamatJemput, String alamatTujuan, String waktuJemput, String status, String tanggalPesan, String tanggalBerangkat, String harga, String kotaAsal, String kotaTujuan, String tanggal, String waktuKeberangkatan) {
|
||||
this.idPemesanan = idPemesanan;
|
||||
this.idUser = idUser;
|
||||
this.idPerjalanan = idPerjalanan;
|
||||
this.qty = qty;
|
||||
this.orderId = orderId;
|
||||
this.alamatJemput = alamatJemput;
|
||||
this.alamatTujuan = alamatTujuan;
|
||||
this.waktuJemput = waktuJemput;
|
||||
this.status = status;
|
||||
this.tanggalPesan = tanggalPesan;
|
||||
this.tanggalBerangkat = tanggalBerangkat;
|
||||
this.harga = harga;
|
||||
this.kotaAsal = kotaAsal;
|
||||
this.kotaTujuan = kotaTujuan;
|
||||
this.tanggal = tanggal;
|
||||
this.waktuKeberangkatan = waktuKeberangkatan;
|
||||
}
|
||||
|
||||
// Getter methods
|
||||
public String getIdPemesanan() {
|
||||
return idPemesanan;
|
||||
}
|
||||
|
||||
public String getIdUser() {
|
||||
return idUser;
|
||||
}
|
||||
|
||||
public String getIdPerjalanan() {
|
||||
return idPerjalanan;
|
||||
}
|
||||
|
||||
public String getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
public String getQty() {
|
||||
return qty;
|
||||
}
|
||||
|
||||
public String getAlamatJemput() {
|
||||
return alamatJemput;
|
||||
}
|
||||
|
||||
public String getAlamatTujuan() {
|
||||
return alamatTujuan;
|
||||
}
|
||||
|
||||
public String getWaktuJemput() {
|
||||
return waktuJemput;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public String getTanggalPesan() {
|
||||
return tanggalPesan;
|
||||
}
|
||||
|
||||
public String getTanggalBerangkat() {
|
||||
return tanggalBerangkat;
|
||||
}
|
||||
|
||||
public String getHarga() {
|
||||
return harga;
|
||||
}
|
||||
|
||||
public String getKotaAsal() {
|
||||
return kotaAsal;
|
||||
}
|
||||
|
||||
public String getKotaTujuan() {
|
||||
return kotaTujuan;
|
||||
}
|
||||
|
||||
public String getTanggal() {
|
||||
return tanggal;
|
||||
}
|
||||
|
||||
public String getWaktuKeberangkatan() {
|
||||
return waktuKeberangkatan;
|
||||
}
|
||||
|
||||
public void setIdPemesanan(String idPemesanan) {
|
||||
this.idPemesanan = idPemesanan;
|
||||
}
|
||||
|
||||
public void setIdUser(String idUser) {
|
||||
this.idUser = idUser;
|
||||
}
|
||||
|
||||
public void setIdPerjalanan(String idPerjalanan) {
|
||||
this.idPerjalanan = idPerjalanan;
|
||||
}
|
||||
|
||||
public void setOrderId(String orderId) {
|
||||
this.orderId = orderId;
|
||||
}
|
||||
|
||||
public void setAlamatJemput(String alamatJemput) {
|
||||
this.alamatJemput = alamatJemput;
|
||||
}
|
||||
|
||||
public void setAlamatTujuan(String alamatTujuan) {
|
||||
this.alamatTujuan = alamatTujuan;
|
||||
}
|
||||
|
||||
public void setWaktuJemput(String waktuJemput) {
|
||||
this.waktuJemput = waktuJemput;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public void setTanggalPesan(String tanggalPesan) {
|
||||
this.tanggalPesan = tanggalPesan;
|
||||
}
|
||||
|
||||
public void setTanggalBerangkat(String tanggalBerangkat) {
|
||||
this.tanggalBerangkat = tanggalBerangkat;
|
||||
}
|
||||
|
||||
public void setHarga(String harga) {
|
||||
this.harga = harga;
|
||||
}
|
||||
|
||||
public void setKotaAsal(String kotaAsal) {
|
||||
this.kotaAsal = kotaAsal;
|
||||
}
|
||||
|
||||
public void setKotaTujuan(String kotaTujuan) {
|
||||
this.kotaTujuan = kotaTujuan;
|
||||
}
|
||||
|
||||
public void setTanggal(String tanggal) {
|
||||
this.tanggal = tanggal;
|
||||
}
|
||||
|
||||
public void setWaktuKeberangkatan(String waktuKeberangkatan) {
|
||||
this.waktuKeberangkatan = waktuKeberangkatan;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,356 @@
|
|||
package com.example.travelapps.Model;
|
||||
|
||||
public class PemesananSopir {
|
||||
private String idPemesanan;
|
||||
private String idUser;
|
||||
private String idPerjalanan;
|
||||
private String orderId;
|
||||
private String alamatJemput;
|
||||
private String alamatTujuan;
|
||||
private String waktuJemput;
|
||||
private String status;
|
||||
private String tanggalPesan;
|
||||
private String tanggalBerangkat;
|
||||
private String qty;
|
||||
private String harga;
|
||||
private String namaLengkap;
|
||||
private String username;
|
||||
private String notelp;
|
||||
private String email;
|
||||
private String alamat;
|
||||
private String idRole;
|
||||
private String password;
|
||||
private String latitude;
|
||||
private String longitude;
|
||||
private String token;
|
||||
private String kotaAsal;
|
||||
private String kotaTujuan;
|
||||
private String tanggal;
|
||||
private String waktuKeberangkatan;
|
||||
private String jumlahPenumpang;
|
||||
private String idSopir;
|
||||
private String mobilId;
|
||||
private String latTujuan;
|
||||
private String lngTujuan;
|
||||
private double distance;
|
||||
private double distanceTujuan;
|
||||
private String jemput;
|
||||
private String antar;
|
||||
|
||||
public PemesananSopir(String idPemesanan, String idUser, String idPerjalanan, String orderId, String alamatJemput, String alamatTujuan, String waktuJemput, String status, String tanggalPesan, String tanggalBerangkat, String qty, String harga, String namaLengkap, String username, String notelp, String email, String alamat, String idRole, String password, String latitude, String longitude, String token, String kotaAsal, String kotaTujuan, String tanggal, String waktuKeberangkatan, String jumlahPenumpang, String idSopir, String mobilId, String latTujuan, String lngTujuan, String jemput, String antar) {
|
||||
this.idPemesanan = idPemesanan;
|
||||
this.idUser = idUser;
|
||||
this.idPerjalanan = idPerjalanan;
|
||||
this.orderId = orderId;
|
||||
this.alamatJemput = alamatJemput;
|
||||
this.alamatTujuan = alamatTujuan;
|
||||
this.waktuJemput = waktuJemput;
|
||||
this.status = status;
|
||||
this.tanggalPesan = tanggalPesan;
|
||||
this.tanggalBerangkat = tanggalBerangkat;
|
||||
this.qty = qty;
|
||||
this.harga = harga;
|
||||
this.namaLengkap = namaLengkap;
|
||||
this.username = username;
|
||||
this.notelp = notelp;
|
||||
this.email = email;
|
||||
this.alamat = alamat;
|
||||
this.idRole = idRole;
|
||||
this.password = password;
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
this.token = token;
|
||||
this.kotaAsal = kotaAsal;
|
||||
this.kotaTujuan = kotaTujuan;
|
||||
this.tanggal = tanggal;
|
||||
this.waktuKeberangkatan = waktuKeberangkatan;
|
||||
this.jumlahPenumpang = jumlahPenumpang;
|
||||
this.idSopir = idSopir;
|
||||
this.mobilId = mobilId;
|
||||
this.latTujuan = latTujuan;
|
||||
this.lngTujuan = lngTujuan;
|
||||
this.jemput = jemput;
|
||||
this.antar = antar;
|
||||
}
|
||||
|
||||
public String getIdPemesanan() {
|
||||
return idPemesanan;
|
||||
}
|
||||
|
||||
public void setIdPemesanan(String idPemesanan) {
|
||||
this.idPemesanan = idPemesanan;
|
||||
}
|
||||
|
||||
public String getIdUser() {
|
||||
return idUser;
|
||||
}
|
||||
|
||||
public void setIdUser(String idUser) {
|
||||
this.idUser = idUser;
|
||||
}
|
||||
|
||||
public String getIdPerjalanan() {
|
||||
return idPerjalanan;
|
||||
}
|
||||
|
||||
public void setIdPerjalanan(String idPerjalanan) {
|
||||
this.idPerjalanan = idPerjalanan;
|
||||
}
|
||||
|
||||
public String getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
public void setOrderId(String orderId) {
|
||||
this.orderId = orderId;
|
||||
}
|
||||
|
||||
public String getAlamatJemput() {
|
||||
return alamatJemput;
|
||||
}
|
||||
|
||||
public void setAlamatJemput(String alamatJemput) {
|
||||
this.alamatJemput = alamatJemput;
|
||||
}
|
||||
|
||||
public String getAlamatTujuan() {
|
||||
return alamatTujuan;
|
||||
}
|
||||
|
||||
public void setAlamatTujuan(String alamatTujuan) {
|
||||
this.alamatTujuan = alamatTujuan;
|
||||
}
|
||||
|
||||
public String getWaktuJemput() {
|
||||
return waktuJemput;
|
||||
}
|
||||
|
||||
public void setWaktuJemput(String waktuJemput) {
|
||||
this.waktuJemput = waktuJemput;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getTanggalPesan() {
|
||||
return tanggalPesan;
|
||||
}
|
||||
|
||||
public void setTanggalPesan(String tanggalPesan) {
|
||||
this.tanggalPesan = tanggalPesan;
|
||||
}
|
||||
|
||||
public String getTanggalBerangkat() {
|
||||
return tanggalBerangkat;
|
||||
}
|
||||
|
||||
public void setTanggalBerangkat(String tanggalBerangkat) {
|
||||
this.tanggalBerangkat = tanggalBerangkat;
|
||||
}
|
||||
|
||||
public String getQty() {
|
||||
return qty;
|
||||
}
|
||||
|
||||
public void setQty(String qty) {
|
||||
this.qty = qty;
|
||||
}
|
||||
|
||||
public String getHarga() {
|
||||
return harga;
|
||||
}
|
||||
|
||||
public void setHarga(String harga) {
|
||||
this.harga = harga;
|
||||
}
|
||||
|
||||
public String getNamaLengkap() {
|
||||
return namaLengkap;
|
||||
}
|
||||
|
||||
public void setNamaLengkap(String namaLengkap) {
|
||||
this.namaLengkap = namaLengkap;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getNotelp() {
|
||||
return notelp;
|
||||
}
|
||||
|
||||
public void setNotelp(String notelp) {
|
||||
this.notelp = notelp;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getAlamat() {
|
||||
return alamat;
|
||||
}
|
||||
|
||||
public void setAlamat(String alamat) {
|
||||
this.alamat = alamat;
|
||||
}
|
||||
|
||||
public String getIdRole() {
|
||||
return idRole;
|
||||
}
|
||||
|
||||
public void setIdRole(String idRole) {
|
||||
this.idRole = idRole;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public void setLatitude(String latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public String getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public void setLongitude(String longitude) {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public String getKotaAsal() {
|
||||
return kotaAsal;
|
||||
}
|
||||
|
||||
public void setKotaAsal(String kotaAsal) {
|
||||
this.kotaAsal = kotaAsal;
|
||||
}
|
||||
|
||||
public String getKotaTujuan() {
|
||||
return kotaTujuan;
|
||||
}
|
||||
|
||||
public void setKotaTujuan(String kotaTujuan) {
|
||||
this.kotaTujuan = kotaTujuan;
|
||||
}
|
||||
|
||||
public String getTanggal() {
|
||||
return tanggal;
|
||||
}
|
||||
|
||||
public void setTanggal(String tanggal) {
|
||||
this.tanggal = tanggal;
|
||||
}
|
||||
|
||||
public String getWaktuKeberangkatan() {
|
||||
return waktuKeberangkatan;
|
||||
}
|
||||
|
||||
public void setWaktuKeberangkatan(String waktuKeberangkatan) {
|
||||
this.waktuKeberangkatan = waktuKeberangkatan;
|
||||
}
|
||||
|
||||
public String getJumlahPenumpang() {
|
||||
return jumlahPenumpang;
|
||||
}
|
||||
|
||||
public void setJumlahPenumpang(String jumlahPenumpang) {
|
||||
this.jumlahPenumpang = jumlahPenumpang;
|
||||
}
|
||||
|
||||
public String getIdSopir() {
|
||||
return idSopir;
|
||||
}
|
||||
|
||||
public void setIdSopir(String idSopir) {
|
||||
this.idSopir = idSopir;
|
||||
}
|
||||
|
||||
public String getMobilId() {
|
||||
return mobilId;
|
||||
}
|
||||
|
||||
public void setMobilId(String mobilId) {
|
||||
this.mobilId = mobilId;
|
||||
}
|
||||
|
||||
public String getLatTujuan() {
|
||||
return latTujuan;
|
||||
}
|
||||
|
||||
public void setLatTujuan(String latTujuan) {
|
||||
this.latTujuan = latTujuan;
|
||||
}
|
||||
|
||||
public String getLngTujuan() {
|
||||
return lngTujuan;
|
||||
}
|
||||
|
||||
public void setLngTujuan(String lngTujuan) {
|
||||
this.lngTujuan = lngTujuan;
|
||||
}
|
||||
|
||||
public double getDistance() {
|
||||
return distance;
|
||||
}
|
||||
|
||||
public void setDistance(double distance) {
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
public double getDistanceTujuan() {
|
||||
return distanceTujuan;
|
||||
}
|
||||
|
||||
public void setDistanceTujuan(double distanceTujuan) {
|
||||
this.distanceTujuan = distanceTujuan;
|
||||
}
|
||||
|
||||
public String getJemput() {
|
||||
return jemput;
|
||||
}
|
||||
|
||||
public void setJemput(String jemput) {
|
||||
this.jemput = jemput;
|
||||
}
|
||||
|
||||
public String getAntar() {
|
||||
return antar;
|
||||
}
|
||||
|
||||
public void setAntar(String antar) {
|
||||
this.antar = antar;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package com.example.travelapps.Model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Perjalanan implements Serializable {
|
||||
private String id;
|
||||
private String asal;
|
||||
private String tujuan;
|
||||
private String waktu;
|
||||
private double harga;
|
||||
private String status;
|
||||
|
||||
public Perjalanan(String id, String asal, String tujuan, String waktu, double harga, String status) {
|
||||
this.id = id;
|
||||
this.asal = asal;
|
||||
this.tujuan = tujuan;
|
||||
this.waktu = waktu;
|
||||
this.harga = harga;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getAsal() {
|
||||
return asal;
|
||||
}
|
||||
|
||||
public String getTujuan() {
|
||||
return tujuan;
|
||||
}
|
||||
|
||||
public String getWaktu() {
|
||||
return waktu;
|
||||
}
|
||||
|
||||
public Double getHarga() {
|
||||
return harga;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package com.example.travelapps.Model;
|
||||
|
||||
public class Sopir {
|
||||
private String idSopir;
|
||||
private String namaLengkap;
|
||||
private String username;
|
||||
private String noSim;
|
||||
private String noTelp;
|
||||
private String alamat;
|
||||
private String active;
|
||||
|
||||
public Sopir(String idSopir, String namaLengkap, String username, String noSim, String noTelp, String alamat, String active) {
|
||||
this.idSopir = idSopir;
|
||||
this.namaLengkap = namaLengkap;
|
||||
this.username = username;
|
||||
this.noSim = noSim;
|
||||
this.noTelp = noTelp;
|
||||
this.alamat = alamat;
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
public String getIdSopir() {
|
||||
return idSopir;
|
||||
}
|
||||
|
||||
public String getNamaLengkap() {
|
||||
return namaLengkap;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getNoSim() {
|
||||
return noSim;
|
||||
}
|
||||
|
||||
public String getNoTelp() {
|
||||
return noTelp;
|
||||
}
|
||||
|
||||
public String getAlamat() {
|
||||
return alamat;
|
||||
}
|
||||
|
||||
public String getActive() {
|
||||
return active;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.example.travelapps.Model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
public class TiketData implements Serializable {
|
||||
private String id;
|
||||
private String asal;
|
||||
private String tujuan;
|
||||
private Date tanggal;
|
||||
private String waktu;
|
||||
private double harga;
|
||||
private String jumlahPenumpang;
|
||||
private String status;
|
||||
|
||||
public TiketData(String id, String asal, String tujuan, Date tanggal, String waktu, double harga, String jumlahPenumpang, String status) {
|
||||
this.id = id;
|
||||
this.asal = asal;
|
||||
this.tujuan = tujuan;
|
||||
this.tanggal = tanggal;
|
||||
this.waktu = waktu;
|
||||
this.harga = harga;
|
||||
this.jumlahPenumpang = jumlahPenumpang;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getAsal() {
|
||||
return asal;
|
||||
}
|
||||
|
||||
public String getTujuan() {
|
||||
return tujuan;
|
||||
}
|
||||
|
||||
public Date getTanggal() {
|
||||
return tanggal;
|
||||
}
|
||||
|
||||
public String getWaktu() {
|
||||
return waktu;
|
||||
}
|
||||
|
||||
public double getHarga() {
|
||||
return harga;
|
||||
}
|
||||
|
||||
public String getJumlahPenumpang() {
|
||||
return jumlahPenumpang;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public int getJumlahPenumpangInt() {
|
||||
return Integer.parseInt(jumlahPenumpang);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package com.example.travelapps.Model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
public class TiketSopir implements Serializable {
|
||||
private String id;
|
||||
private String asal;
|
||||
private String tujuan;
|
||||
private Date tanggal;
|
||||
private String waktu;
|
||||
private double harga;
|
||||
private String jumlahPenumpang;
|
||||
private String status;
|
||||
private String TotalPenumpang;
|
||||
|
||||
public TiketSopir(String id, String asal, String tujuan, Date tanggal, String waktu, double harga, String jumlahPenumpang, String status, String totalPenumpang) {
|
||||
this.id = id;
|
||||
this.asal = asal;
|
||||
this.tujuan = tujuan;
|
||||
this.tanggal = tanggal;
|
||||
this.waktu = waktu;
|
||||
this.harga = harga;
|
||||
this.jumlahPenumpang = jumlahPenumpang;
|
||||
this.status = status;
|
||||
TotalPenumpang = totalPenumpang;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getAsal() {
|
||||
return asal;
|
||||
}
|
||||
|
||||
public String getTujuan() {
|
||||
return tujuan;
|
||||
}
|
||||
|
||||
public Date getTanggal() {
|
||||
return tanggal;
|
||||
}
|
||||
|
||||
public String getWaktu() {
|
||||
return waktu;
|
||||
}
|
||||
|
||||
public double getHarga() {
|
||||
return harga;
|
||||
}
|
||||
|
||||
public String getJumlahPenumpang() {
|
||||
return jumlahPenumpang;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public String getTotalPenumpang() {
|
||||
return TotalPenumpang;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
package com.example.travelapps.Model;
|
||||
|
||||
public class TransactionModel {
|
||||
private String statusCode;
|
||||
private String statusMessage;
|
||||
private String transactionId;
|
||||
private String maskedCard;
|
||||
private String orderId;
|
||||
private String paymentType;
|
||||
private String transactionTime;
|
||||
private String transactionStatus;
|
||||
private String fraudStatus;
|
||||
private String approvalCode;
|
||||
private String signatureKey;
|
||||
private Bank bankInfo; // Objek bank yang berisi bank dan vaNumber
|
||||
private String grossAmount;
|
||||
private String channelResponseCode;
|
||||
private String channelResponseMessage;
|
||||
private String cardType;
|
||||
private String paymentOptionType;
|
||||
private String shopeepayReferenceNumber;
|
||||
private String referenceId;
|
||||
|
||||
// Constructor
|
||||
public TransactionModel(String statusCode, String statusMessage, String transactionId, String maskedCard, String orderId, String paymentType, String transactionTime, String transactionStatus, String fraudStatus, String approvalCode, String signatureKey, Bank bankInfo, String grossAmount, String channelResponseCode, String channelResponseMessage, String cardType, String paymentOptionType, String shopeepayReferenceNumber, String referenceId) {
|
||||
this.statusCode = statusCode;
|
||||
this.statusMessage = statusMessage;
|
||||
this.transactionId = transactionId;
|
||||
this.maskedCard = maskedCard;
|
||||
this.orderId = orderId;
|
||||
this.paymentType = paymentType;
|
||||
this.transactionTime = transactionTime;
|
||||
this.transactionStatus = transactionStatus;
|
||||
this.fraudStatus = fraudStatus;
|
||||
this.approvalCode = approvalCode;
|
||||
this.signatureKey = signatureKey;
|
||||
this.bankInfo = bankInfo;
|
||||
this.grossAmount = grossAmount;
|
||||
this.channelResponseCode = channelResponseCode;
|
||||
this.channelResponseMessage = channelResponseMessage;
|
||||
this.cardType = cardType;
|
||||
this.paymentOptionType = paymentOptionType;
|
||||
this.shopeepayReferenceNumber = shopeepayReferenceNumber;
|
||||
this.referenceId = referenceId;
|
||||
}
|
||||
|
||||
// Getter methods
|
||||
public String getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
public String getStatusMessage() {
|
||||
return statusMessage;
|
||||
}
|
||||
|
||||
public String getTransactionId() {
|
||||
return transactionId;
|
||||
}
|
||||
|
||||
public String getMaskedCard() {
|
||||
return maskedCard;
|
||||
}
|
||||
|
||||
public String getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
public String getPaymentType() {
|
||||
return paymentType;
|
||||
}
|
||||
|
||||
public String getTransactionTime() {
|
||||
return transactionTime;
|
||||
}
|
||||
|
||||
public String getTransactionStatus() {
|
||||
return transactionStatus;
|
||||
}
|
||||
|
||||
public String getFraudStatus() {
|
||||
return fraudStatus;
|
||||
}
|
||||
|
||||
public String getApprovalCode() {
|
||||
return approvalCode;
|
||||
}
|
||||
|
||||
public String getSignatureKey() {
|
||||
return signatureKey;
|
||||
}
|
||||
|
||||
public Bank getBankInfo() {
|
||||
return bankInfo;
|
||||
}
|
||||
|
||||
public String getGrossAmount() {
|
||||
return grossAmount;
|
||||
}
|
||||
|
||||
public String getChannelResponseCode() {
|
||||
return channelResponseCode;
|
||||
}
|
||||
|
||||
public String getChannelResponseMessage() {
|
||||
return channelResponseMessage;
|
||||
}
|
||||
|
||||
public String getCardType() {
|
||||
return cardType;
|
||||
}
|
||||
|
||||
public String getPaymentOptionType() {
|
||||
return paymentOptionType;
|
||||
}
|
||||
|
||||
public String getShopeepayReferenceNumber() {
|
||||
return shopeepayReferenceNumber;
|
||||
}
|
||||
|
||||
public String getReferenceId() {
|
||||
return referenceId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.example.travelapps.Model;
|
||||
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
|
||||
public class Tujuan {
|
||||
private LatLng latLngTujuan;
|
||||
private double formattedDistanceTujuan;
|
||||
private String namaLengkap;
|
||||
|
||||
public Tujuan(LatLng latLngTujuan, double formattedDistanceTujuan, String namaLengkap) {
|
||||
this.latLngTujuan = latLngTujuan;
|
||||
this.formattedDistanceTujuan = formattedDistanceTujuan;
|
||||
this.namaLengkap = namaLengkap;
|
||||
}
|
||||
|
||||
public LatLng getLatLngTujuan() {
|
||||
return latLngTujuan;
|
||||
}
|
||||
|
||||
public double getFormattedDistanceTujuan() {
|
||||
return formattedDistanceTujuan;
|
||||
}
|
||||
|
||||
public String getNamaLengkap() {
|
||||
return namaLengkap;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package com.example.travelapps.Model;
|
||||
|
||||
public class User {
|
||||
private String id;
|
||||
private String nama;
|
||||
private String notelp;
|
||||
private String email;
|
||||
private String alamat;
|
||||
private String latitude;
|
||||
private String longitude;
|
||||
private String nik;
|
||||
|
||||
public User(String id, String nama, String notelp, String email, String alamat, String latitude, String longitude, String nik) {
|
||||
this.id = id;
|
||||
this.nama = nama;
|
||||
this.notelp = notelp;
|
||||
this.email = email;
|
||||
this.alamat = alamat;
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
this.nik = nik;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getNama() {
|
||||
return nama;
|
||||
}
|
||||
|
||||
public String getNotelp() {
|
||||
return notelp;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public String getAlamat() {
|
||||
return alamat;
|
||||
}
|
||||
|
||||
public String getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public String getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
public String getNik() {
|
||||
return nik;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.example.travelapps;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.ImageView;
|
||||
|
||||
public class PaymentMidtransWebView extends AppCompatActivity {
|
||||
private WebView webView;
|
||||
private ImageView ivBack;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_payment_midtrans_web_view);
|
||||
|
||||
String paymentUrl = getIntent().getStringExtra("payment_url");
|
||||
|
||||
webView = findViewById(R.id.webView);
|
||||
ivBack = findViewById(R.id.ivBack);
|
||||
ivBack.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
onBackPressed();
|
||||
}
|
||||
});
|
||||
setupWebView();
|
||||
loadPaymentUrl(paymentUrl);
|
||||
}
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
private void setupWebView() {
|
||||
WebSettings webSettings = webView.getSettings();
|
||||
webSettings.setJavaScriptEnabled(true); // Aktifkan JavaScript jika diperlukan
|
||||
webView.setWebViewClient(new WebViewClient());
|
||||
}
|
||||
|
||||
private void loadPaymentUrl(String paymentUrl) {
|
||||
if (paymentUrl != null && !paymentUrl.isEmpty()) {
|
||||
webView.loadUrl(paymentUrl);
|
||||
} else {
|
||||
// URL pembayaran tidak tersedia, tangani sesuai kebutuhan aplikasi Anda
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,745 @@
|
|||
package com.example.travelapps.Services;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.volley.AuthFailureError;
|
||||
import com.android.volley.Request;
|
||||
import com.android.volley.RequestQueue;
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.android.volley.toolbox.StringRequest;
|
||||
import com.android.volley.toolbox.Volley;
|
||||
import com.example.travelapps.Model.Kota;
|
||||
import com.example.travelapps.Model.Notifikasi;
|
||||
import com.example.travelapps.Model.Pemesanan;
|
||||
import com.example.travelapps.Model.Perjalanan;
|
||||
import com.example.travelapps.Model.TiketData;
|
||||
import com.example.travelapps.Model.User;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URL;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ApiServices {
|
||||
private static String HOST = "http://172.20.10.4/TugasAkhir/api/";
|
||||
|
||||
public static String getHOST() {
|
||||
return HOST;
|
||||
}
|
||||
|
||||
public interface LoginResponseListener {
|
||||
void onSuccess(String message);
|
||||
void onError(String message);
|
||||
}
|
||||
|
||||
public interface RegisterResponseListener {
|
||||
void onSuccess(String message);
|
||||
void onError(String message);
|
||||
}
|
||||
|
||||
public interface PerjalananResponseListener {
|
||||
void onSuccess(List<TiketData> tiketData);
|
||||
void onError(String message);
|
||||
}
|
||||
|
||||
public interface UserResponseListener {
|
||||
void onSuccess(User user);
|
||||
void onError(String message);
|
||||
}
|
||||
|
||||
public interface PemesananResponseListener {
|
||||
void onSuccess(String message);
|
||||
void onError(String message);
|
||||
}
|
||||
public interface ShowPemesananResponseListener {
|
||||
void onSuccess(List<Pemesanan.PemesananData> pemesananDataList);
|
||||
void onError(String message);
|
||||
}
|
||||
|
||||
public interface AddLatlongResponseListener {
|
||||
void onSuccess(String message);
|
||||
void onError(String message);
|
||||
}
|
||||
|
||||
public interface CheckLatlongResponseListener {
|
||||
void onResult(boolean success, double latitude, double longitude);
|
||||
void onError(String message);
|
||||
}
|
||||
|
||||
public interface NotifikasiResponseListener {
|
||||
void onSuccess(List<Notifikasi> notifikasiList);
|
||||
void onError(String message);
|
||||
}
|
||||
public interface GetCityResponseListener {
|
||||
void onSuccess(JSONObject response);
|
||||
void onError(String message);
|
||||
}
|
||||
public static void getCity(Context context, GetCityResponseListener listener) {
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.GET, HOST + "getcity.php", new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(response);
|
||||
Boolean success = jsonObject.getBoolean("success");
|
||||
if (success) {
|
||||
listener.onSuccess(jsonObject);
|
||||
} else {
|
||||
listener.onError("Failed to retrieve city list");
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
listener.onError("Failed to parse response: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
if (error.networkResponse != null && error.networkResponse.data != null) {
|
||||
try {
|
||||
String responseBody = new String(error.networkResponse.data, "utf-8");
|
||||
JSONObject jsonObject = new JSONObject(responseBody);
|
||||
String message = jsonObject.getString("message");
|
||||
listener.onError("Error: " + message);
|
||||
} catch (UnsupportedEncodingException | JSONException e) {
|
||||
e.printStackTrace();
|
||||
listener.onError("Failed to parse error response: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
listener.onError("Network error: response is null");
|
||||
}
|
||||
}
|
||||
});
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
public static void login(Context context, String email, String pass, LoginResponseListener listener) {
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.POST, HOST + "login.php", new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
Log.e("Response", response);
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(response);
|
||||
String message = jsonObject.getString("message");
|
||||
Boolean success = jsonObject.getBoolean("success");
|
||||
if (message.equals("Berhasil Login")){
|
||||
String token = jsonObject.getString("token");
|
||||
SharedPreferences.Editor editor = context.getSharedPreferences("myPrefs", MODE_PRIVATE).edit();
|
||||
editor.putBoolean("isLogin", true);
|
||||
editor.putString("token", token);
|
||||
editor.apply();
|
||||
listener.onSuccess(message);
|
||||
} else if (success.equals(false)) {
|
||||
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} catch (JSONException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener(){
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
if (error.networkResponse != null && error.networkResponse.data != null) {
|
||||
try {
|
||||
int statusCode = error.networkResponse.statusCode;
|
||||
String responseBody = new String(error.networkResponse.data, "utf-8");
|
||||
if (statusCode == 401) {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(responseBody);
|
||||
String message = jsonObject.getString("message");
|
||||
if (message.equals("Email dan Password Salah")) {
|
||||
listener.onError("Email / password anda salah");
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
listener.onError("Gagal Login: " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else{
|
||||
listener.onError("Gagal Login: network response is null");
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
{
|
||||
@Override
|
||||
protected Map<String, String> getParams() throws AuthFailureError {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("email", email);
|
||||
params.put("password", pass);
|
||||
return params;
|
||||
}
|
||||
};
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
|
||||
public static void register(Context context, String nama, String notelp, String email, String alamat, String password, String nik, RegisterResponseListener listener) {
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.POST, HOST + "register.php", new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(response);
|
||||
String success = jsonObject.getString("success");
|
||||
if ("true".equals(success)) {
|
||||
listener.onSuccess("Berhasil Register");
|
||||
} else {
|
||||
listener.onError("Gagal register: " + jsonObject.getString("message"));
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
listener.onError("Gagal register: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener(){
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
if (error.networkResponse != null && error.networkResponse.data != null) {
|
||||
try {
|
||||
int statusCode = error.networkResponse.statusCode;
|
||||
String responseBody = new String(error.networkResponse.data, "utf-8");
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(responseBody);
|
||||
String message = jsonObject.getString("message");
|
||||
if (message.equals("Email sudah terdaftar")) {
|
||||
listener.onError("Email sudah terdaftar , Silahkan gunakan email yang lain");
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
listener.onError("Gagal register: " + e.getMessage());
|
||||
}
|
||||
} catch ( UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
} else {
|
||||
listener.onError("Gagal register: network response is null");
|
||||
}
|
||||
}
|
||||
})
|
||||
{
|
||||
@Override
|
||||
protected Map<String, String> getParams() {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("nama_lengkap", nama);
|
||||
params.put("email", email);
|
||||
params.put("password", password);
|
||||
params.put("alamat", alamat);
|
||||
params.put("notelp", notelp);
|
||||
params.put("nik", nik);
|
||||
return params;
|
||||
}
|
||||
};
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
public static void notifikasi(Context context, String id_user, String title, String desc ,RegisterResponseListener listener) {
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.POST, HOST + "notifikasi-store.php", new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(response);
|
||||
String success = jsonObject.getString("success");
|
||||
if ("true".equals(success)) {
|
||||
listener.onSuccess("Berhasil store notifikasi");
|
||||
} else {
|
||||
listener.onError("Gagal mengirim notifikasi: ");
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
listener.onError("Gagal: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener(){
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
if (error.networkResponse == null) {
|
||||
listener.onError("Gagal mengirim notif: network response is null");
|
||||
}
|
||||
}
|
||||
})
|
||||
{
|
||||
@Override
|
||||
protected Map<String, String> getParams() {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("id_user", id_user);
|
||||
params.put("title", title);
|
||||
params.put("desc", desc);
|
||||
return params;
|
||||
}
|
||||
};
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
|
||||
public static void getNotifikasi(Context context, String id_user, NotifikasiResponseListener listener) {
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.GET, HOST + "get-notifikasi.php?id_user=" + id_user,
|
||||
new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
Log.e("Response", response);
|
||||
try {
|
||||
JSONArray jsonArray = new JSONArray(response);
|
||||
List<Notifikasi> notifikasiList = new ArrayList<>();
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String title = jsonObject.getString("title");
|
||||
String desc = jsonObject.getString("desc");
|
||||
String createdAtString = jsonObject.getString("created_at");
|
||||
Date createdAt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(createdAtString);
|
||||
Notifikasi notifikasi = new Notifikasi(title, desc, createdAt);
|
||||
notifikasiList.add(notifikasi);
|
||||
}
|
||||
listener.onSuccess(notifikasiList);
|
||||
} catch (JSONException | ParseException e) {
|
||||
e.printStackTrace();
|
||||
listener.onError("Failed to parse response: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
if (error.networkResponse != null && error.networkResponse.data != null) {
|
||||
try {
|
||||
String responseBody = new String(error.networkResponse.data, "utf-8");
|
||||
JSONObject jsonObject = new JSONObject(responseBody);
|
||||
String message = jsonObject.getString("message");
|
||||
listener.onError(message);
|
||||
} catch (JSONException | UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
listener.onError("Failed to parse error response: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
listener.onError("Network error: " + error.toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
public static void showPerjalanan(Context context,String kotaAsal, String kotaTujuan, String tanggal, final PerjalananResponseListener listener) {
|
||||
String url = HOST + "schedule.php?kota_asal=" + kotaAsal + "&kota_tujuan=" + kotaTujuan + "&tanggal=" +tanggal ;
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
|
||||
new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(response);
|
||||
String message = jsonObject.getString("message");
|
||||
if (message.equals("success")) {
|
||||
JSONArray jsonArray = jsonObject.getJSONArray("data");
|
||||
Log.e("response", response);
|
||||
Log.e("url", url);
|
||||
List<TiketData> tiketDataList = new ArrayList<>();
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
JSONObject jsonArrayJSONObject = jsonArray.getJSONObject(i);
|
||||
String id = jsonArrayJSONObject.getString("id_perjalanan");
|
||||
String asal = jsonArrayJSONObject.getString("kota_asal");
|
||||
String tujuan = jsonArrayJSONObject.getString("kota_tujuan");
|
||||
String tanggal = jsonArrayJSONObject.getString("tanggal");
|
||||
String waktu = jsonArrayJSONObject.getString("waktu_keberangkatan");
|
||||
Double harga = jsonArrayJSONObject.getDouble("harga");
|
||||
String jumlahPenumpang = jsonArrayJSONObject.getString("jumlah_penumpang");
|
||||
String status = jsonArrayJSONObject.getString("status");
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date ntanggal;
|
||||
try {
|
||||
ntanggal = sdf.parse(tanggal);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
TiketData tiketData = new TiketData(id, asal, tujuan,ntanggal, waktu, harga,jumlahPenumpang, status);
|
||||
|
||||
tiketDataList.add(tiketData);
|
||||
}
|
||||
listener.onSuccess(tiketDataList);
|
||||
} else {
|
||||
listener.onError("Tidak ada tiket perjalanan");
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
if (error.networkResponse != null && error.networkResponse.data != null) {
|
||||
try {
|
||||
String responseBody = new String(error.networkResponse.data, "utf-8");
|
||||
JSONObject jsonObject = new JSONObject(responseBody);
|
||||
String message = jsonObject.getString("message");
|
||||
listener.onError(message);
|
||||
} catch (JSONException | UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
listener.onError("Gagal mendapatkan data perjalanan: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
listener.onError("Gagal mendapatkan data perjalanan: network response is null");
|
||||
}
|
||||
}
|
||||
}) {
|
||||
};
|
||||
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
|
||||
public static void getUserData(Context context, String token, final UserResponseListener listener) {
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.GET, HOST + "getuserbyid.php?token=" + token,
|
||||
new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
try {
|
||||
Log.e("user", response);
|
||||
JSONObject jsonObject = new JSONObject(response);
|
||||
String message = jsonObject.getString("message");
|
||||
if (message.equals("success")){
|
||||
JSONObject userObj = jsonObject.getJSONObject("user");
|
||||
String id = userObj.getString("id_user");
|
||||
String nama = userObj.getString("nama_lengkap");
|
||||
String notelp = userObj.getString("notelp");
|
||||
String alamat = userObj.getString("alamat");
|
||||
String email = userObj.getString("email");
|
||||
String longitude = userObj.getString("longitude");
|
||||
String latitude = userObj.getString("latitude");
|
||||
String nik = userObj.getString("nik");
|
||||
User user = new User(id, nama,notelp,email,alamat,latitude, longitude, nik);
|
||||
listener.onSuccess(user);
|
||||
}
|
||||
} catch (JSONException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
if (error.networkResponse != null && error.networkResponse.data != null) {
|
||||
try {
|
||||
String responseBody = new String(error.networkResponse.data, "utf-8");
|
||||
JSONObject jsonObject = new JSONObject(responseBody);
|
||||
String message = jsonObject.getString("message");
|
||||
listener.onError(message);
|
||||
} catch (JSONException | UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
listener.onError("Gagal mendapatkan data user: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
listener.onError("Gagal mendapatkan data user: network response is null");
|
||||
}
|
||||
}
|
||||
}) {
|
||||
};
|
||||
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
public static void updateUser(Context context, String token, String nama_lengkap, String notelp, String email, String alamat, String nik, final UpdateUserResponseListener listener) {
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.POST, HOST + "update-user.php",
|
||||
new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(response);
|
||||
boolean success = jsonObject.getBoolean("success");
|
||||
String message = jsonObject.getString("message");
|
||||
listener.onUpdateUserResponse(success, message);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
listener.onUpdateUserResponse(false, "Failed to parse response: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
listener.onUpdateUserResponse(false, "Failed to update user: " + error.getMessage());
|
||||
}
|
||||
}) {
|
||||
@Override
|
||||
protected Map<String, String> getParams() throws AuthFailureError {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("token", token);
|
||||
params.put("nama_lengkap", nama_lengkap);
|
||||
params.put("notelp", notelp);
|
||||
params.put("email", email);
|
||||
params.put("alamat", alamat);
|
||||
params.put("nik", nik);
|
||||
return params;
|
||||
}
|
||||
};
|
||||
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
|
||||
public interface UpdateUserResponseListener {
|
||||
void onUpdateUserResponse(boolean success, String message);
|
||||
}
|
||||
|
||||
public static void addLatlong(Context context, String token, double latitude, double longitude, AddLatlongResponseListener listener) {
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.POST, HOST + "addlatLng.php", new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(response);
|
||||
boolean success = jsonObject.getBoolean("success");
|
||||
if (success) {
|
||||
listener.onSuccess("Latitude dan Longitude berhasil disimpan");
|
||||
} else {
|
||||
String error = jsonObject.getString("error");
|
||||
listener.onError("Gagal menyimpan Latitude dan Longitude: " + error);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
listener.onError("Gagal menyimpan Latitude dan Longitude: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener(){
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
listener.onError("Gagal menyimpan Latitude dan Longitude: " + error.getMessage());
|
||||
}
|
||||
})
|
||||
{
|
||||
@Override
|
||||
protected Map<String, String> getParams() {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("token", token);
|
||||
params.put("latitude", String.valueOf(latitude));
|
||||
params.put("longitude", String.valueOf(longitude));
|
||||
return params;
|
||||
}
|
||||
};
|
||||
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
|
||||
public static void checkLatlong(Context context, String token, CheckLatlongResponseListener listener) {
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.POST, HOST + "checkLatLng.php", new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(response);
|
||||
boolean success = jsonObject.getBoolean("success");
|
||||
if (success) {
|
||||
double latitude = jsonObject.getDouble("latitude");
|
||||
double longitude = jsonObject.getDouble("longitude");
|
||||
listener.onResult(true, latitude, longitude);
|
||||
} else {
|
||||
listener.onResult(false, 0, 0);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
listener.onError("Gagal memeriksa Latitude dan Longitude: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener(){
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
listener.onError("Gagal memeriksa Latitude dan Longitude: " + error.getMessage());
|
||||
}
|
||||
})
|
||||
{
|
||||
@Override
|
||||
protected Map<String, String> getParams() {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("token", token);
|
||||
return params;
|
||||
}
|
||||
};
|
||||
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
|
||||
public static void pemesanan(Context context, String id_user, String id_perjalanan, String qty, String order_id, String alamat_jemput, String alamat_tujuan, String waktu_jemput,String status, String tglBerangkat, String harga , String lattujuan, String lngtujuan, PemesananResponseListener listener) {
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.POST, HOST + "pesanan.php", new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(response);
|
||||
String success = jsonObject.getString("success");
|
||||
if ("true".equals(success)) {
|
||||
listener.onSuccess("Berhasil melakukan pemesanan tiket");
|
||||
} else {
|
||||
listener.onError("Gagal pesan: " + jsonObject.getString("message"));
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
listener.onError("Gagal pesan: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener(){
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
if (error.networkResponse != null && error.networkResponse.data != null) {
|
||||
try {
|
||||
int statusCode = error.networkResponse.statusCode;
|
||||
String responseBody = new String(error.networkResponse.data, "utf-8");
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(responseBody);
|
||||
String message = jsonObject.getString("error");
|
||||
if (message.equals("Failed to insert pemesanan")) {
|
||||
listener.onError("Failed to insert pemesanan");
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
listener.onError("Gagal pesan: " + e.getMessage());
|
||||
}
|
||||
} catch ( UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
} else {
|
||||
listener.onError("Gagal pesan: network response is null");
|
||||
}
|
||||
}
|
||||
})
|
||||
{
|
||||
@Override
|
||||
protected Map<String, String> getParams() {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("id_user", id_user);
|
||||
params.put("id_perjalanan", id_perjalanan);
|
||||
params.put("order_id", order_id);
|
||||
params.put("alamat_jemput", alamat_jemput);
|
||||
params.put("alamat_tujuan", alamat_tujuan);
|
||||
params.put("waktu_jemput", waktu_jemput);
|
||||
params.put("status", status);
|
||||
params.put("qty", qty);
|
||||
params.put("tanggal_berangkat", tglBerangkat);
|
||||
params.put("harga", harga);
|
||||
params.put("lat_tujuan", lattujuan);
|
||||
params.put("lng_tujuan", lngtujuan);
|
||||
return params;
|
||||
}
|
||||
};
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
|
||||
public static void status(Context context, String order_id, String status, AddLatlongResponseListener listener) {
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.POST, HOST + "updateStatus.php", new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(response);
|
||||
boolean success = jsonObject.getBoolean("success");
|
||||
if (success) {
|
||||
listener.onSuccess("Pesanan berhasil");
|
||||
} else {
|
||||
String error = jsonObject.getString("error");
|
||||
listener.onError("Gagal: " + error);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
listener.onError("Gagal menyimpan Latitude dan Longitude: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener(){
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
listener.onError("Gagal update: " + error.getMessage());
|
||||
}
|
||||
})
|
||||
{
|
||||
@Override
|
||||
protected Map<String, String> getParams() {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("status", status);
|
||||
params.put("order_id", order_id);
|
||||
return params;
|
||||
}
|
||||
};
|
||||
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
|
||||
public static void showPemesanan(Context context, String idUser, ShowPemesananResponseListener listener) {
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.GET, HOST + "showpemesanan.php?id_user=" + idUser, new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
Log.e("Response", response);
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(response);
|
||||
String message = jsonObject.getString("message");
|
||||
if (message.equals("success")) {
|
||||
JSONArray dataArray = jsonObject.getJSONArray("data");
|
||||
List<Pemesanan.PemesananData> pemesananDataList = new ArrayList<>();
|
||||
for (int i = 0; i < dataArray.length(); i++) {
|
||||
JSONObject dataObject = dataArray.getJSONObject(i);
|
||||
// Parse each pemesanan data
|
||||
String id = dataObject.getString("id_pemesanan");
|
||||
String idUser = dataObject.getString("id_user");
|
||||
String idPerjalanan = dataObject.getString("id_perjalanan");
|
||||
String qty = dataObject.getString("qty");
|
||||
String orderId = dataObject.getString("order_id");
|
||||
String alamat_jemput = dataObject.getString("alamat_jemput");
|
||||
String alamatTujuan = dataObject.getString("alamat_tujuan");
|
||||
String waktu_jemput = dataObject.getString("waktu_jemput");
|
||||
String status = dataObject.getString("pemesanan_status");
|
||||
String tanggalPesan = dataObject.getString("tanggal_pesan");
|
||||
String tanggalBerangkat = dataObject.getString("tanggal_berangkat");
|
||||
String harga = dataObject.getString("harga");
|
||||
String kotaAsal = dataObject.getString("kota_asal");
|
||||
String kotaTujuan = dataObject.getString("kota_tujuan");
|
||||
String tanggal = dataObject.getString("tanggal");
|
||||
String waktuKeberangkatan = dataObject.getString("waktu_keberangkatan");
|
||||
Pemesanan.PemesananData pemesananData = new Pemesanan.PemesananData(id, idUser, idPerjalanan,qty, orderId, alamat_jemput, alamatTujuan, waktu_jemput, status, tanggalPesan, tanggalBerangkat, harga, kotaAsal, kotaTujuan, tanggal, waktuKeberangkatan);
|
||||
pemesananDataList.add(pemesananData);
|
||||
}
|
||||
listener.onSuccess(pemesananDataList);
|
||||
} else {
|
||||
listener.onError("Failed to fetch pemesanan data: " + message);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
listener.onError("Failed to parse JSON response: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
listener.onError("Failed to fetch pemesanan data: " + error.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,196 @@
|
|||
package com.example.travelapps.Services;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
import com.android.volley.Request;
|
||||
import com.android.volley.RequestQueue;
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.android.volley.toolbox.JsonObjectRequest;
|
||||
import com.android.volley.toolbox.Volley;
|
||||
import com.example.travelapps.Model.Bank;
|
||||
import com.example.travelapps.Model.TransactionModel;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MidtransServices {
|
||||
private static final String MIDTRANS_API_URL = "https://app.sandbox.midtrans.com/snap/v1/transactions";
|
||||
private static final String CLIENT_API = "SB-Mid-server-yIQsPkGPeYXJDAM2voIw1mp_:";
|
||||
private static final String MIDTRANS_TRANSACTION = "https://api.sandbox.midtrans.com/v2/";
|
||||
private final Context context;
|
||||
|
||||
public interface TokenResponseListener {
|
||||
void onSuccess(String token, String url);
|
||||
void onError(String message);
|
||||
}
|
||||
|
||||
public interface TransactionStatusResponseListener {
|
||||
void onSuccess(TransactionModel transactionModel);
|
||||
void onError(String message);
|
||||
}
|
||||
public MidtransServices(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public void getToken(final String orderId, final int grossAmount, final TokenResponseListener listener) {
|
||||
JSONObject postData = new JSONObject();
|
||||
JSONObject transactionDetails = new JSONObject();
|
||||
try {
|
||||
transactionDetails.put("order_id", orderId);
|
||||
transactionDetails.put("gross_amount", grossAmount);
|
||||
postData.put("transaction_details", transactionDetails);
|
||||
postData.put("credit_card", new JSONObject().put("secure", true));
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, MIDTRANS_API_URL, postData,
|
||||
new Response.Listener<JSONObject>() {
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
try {
|
||||
String token = response.getString("token");
|
||||
String url = response.getString("token");
|
||||
listener.onSuccess(token, url);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
listener.onError("Error parsing token response");
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
Log.e("GetMidtransToken", "Error: " + error.getMessage());
|
||||
listener.onError("Error getting token: " + error.getMessage());
|
||||
}
|
||||
}) {
|
||||
@Override
|
||||
public Map<String, String> getHeaders() {
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Content-Type", "application/json");
|
||||
headers.put("Accept", "application/json");
|
||||
headers.put("authorization", "Basic " + Base64.encodeToString(CLIENT_API.getBytes(), Base64.NO_WRAP));
|
||||
return headers;
|
||||
}
|
||||
};
|
||||
|
||||
// Adding request to the request queue
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(request);
|
||||
}
|
||||
public void getTransactionStatus(final String orderId, final TransactionStatusResponseListener listener) {
|
||||
String url = MIDTRANS_TRANSACTION + orderId + "/status";
|
||||
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, url, null,
|
||||
new Response.Listener<JSONObject>() {
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
try {
|
||||
Log.e("response transaction", response.toString());
|
||||
String statusCode = response.getString("status_code");
|
||||
String statusMessage = response.getString("status_message");
|
||||
String transactionId = response.getString("transaction_id");
|
||||
String orderId = response.getString("order_id");
|
||||
String paymentType = response.getString("payment_type");
|
||||
String transactionTime = response.getString("transaction_time");
|
||||
String transactionStatus = response.getString("transaction_status");
|
||||
String fraudStatus = response.getString("fraud_status");
|
||||
String grossAmount = response.getString("gross_amount");
|
||||
String approvalCode = response.optString("approval_code", "");
|
||||
// JSONArray vaNumbersArray = response.getJSONArray("va_numbers");
|
||||
String bank = "";
|
||||
String va = "";
|
||||
|
||||
// Check if the key "va_numbers" exists and is not null
|
||||
if (response.has("va_numbers") && !response.isNull("va_numbers")) {
|
||||
JSONArray vaNumbersArray = response.getJSONArray("va_numbers");
|
||||
if (vaNumbersArray.length() > 0) {
|
||||
JSONObject vaObject = vaNumbersArray.getJSONObject(0);
|
||||
bank = vaObject.getString("bank");
|
||||
va = vaObject.getString("va_number");
|
||||
}
|
||||
}
|
||||
|
||||
Bank bank2 = new Bank(bank, va);
|
||||
|
||||
TransactionModel transactionModel = new TransactionModel(
|
||||
statusCode, statusMessage, transactionId, null, orderId,
|
||||
paymentType, transactionTime, transactionStatus, fraudStatus,
|
||||
approvalCode, null , bank2, grossAmount, null,
|
||||
null, null, null, null,null
|
||||
);
|
||||
|
||||
listener.onSuccess(transactionModel);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
listener.onError("Error parsing transaction status response");
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
Log.e("GetMidtransToken", "Error: " + error.getMessage());
|
||||
listener.onError("Error getting transaction status: " + error.getMessage());
|
||||
}
|
||||
}) {
|
||||
@Override
|
||||
public Map<String, String> getHeaders() {
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Content-Type", "application/json");
|
||||
headers.put("Accept", "application/json");
|
||||
headers.put("authorization", "Basic " + Base64.encodeToString(CLIENT_API.getBytes(), Base64.NO_WRAP));
|
||||
return headers;
|
||||
}
|
||||
};
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(request);
|
||||
}
|
||||
public void getPaymentLink(final JSONObject requestBody, final PaymentLinkResponseListener listener) {
|
||||
JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, "https://api.sandbox.midtrans.com/v1/payment-links", requestBody,
|
||||
new Response.Listener<JSONObject>() {
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
try {
|
||||
String orderId = response.getString("order_id");
|
||||
String paymentUrl = response.getString("payment_url");
|
||||
listener.onSuccess(orderId, paymentUrl);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
listener.onError("Error parsing payment link response");
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
Log.e("GetPaymentLink", "Error: " + error.toString());
|
||||
listener.onError("Error getting payment link: " + error.toString());
|
||||
}
|
||||
}) {
|
||||
@Override
|
||||
public Map<String, String> getHeaders() {
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Content-Type", "application/json");
|
||||
headers.put("Accept", "application/json");
|
||||
headers.put("Authorization", "Basic " + Base64.encodeToString("SB-Mid-server-yIQsPkGPeYXJDAM2voIw1mp_".getBytes(), Base64.NO_WRAP));
|
||||
return headers;
|
||||
}
|
||||
};
|
||||
|
||||
// Adding request to the request queue
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(request);
|
||||
}
|
||||
|
||||
public interface PaymentLinkResponseListener {
|
||||
void onSuccess(String orderId, String paymentUrl);
|
||||
void onError(String message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,279 @@
|
|||
package com.example.travelapps;
|
||||
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.AppCompatButton;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.travelapps.Model.TiketData;
|
||||
import com.example.travelapps.pelanggan.CurrentLocationActivity;
|
||||
import com.example.travelapps.pelanggan.FromMapsActivity;
|
||||
import com.midtrans.sdk.corekit.callback.TransactionFinishedCallback;
|
||||
import com.midtrans.sdk.corekit.core.MidtransSDK;
|
||||
import com.midtrans.sdk.corekit.core.PaymentMethod;
|
||||
import com.midtrans.sdk.corekit.core.TransactionRequest;
|
||||
import com.midtrans.sdk.corekit.core.UIKitCustomSetting;
|
||||
import com.midtrans.sdk.corekit.core.themes.CustomColorTheme;
|
||||
import com.midtrans.sdk.corekit.models.CustomerDetails;
|
||||
import com.midtrans.sdk.corekit.models.ItemDetails;
|
||||
import com.midtrans.sdk.corekit.models.snap.TransactionResult;
|
||||
import com.midtrans.sdk.uikit.SdkUIFlowBuilder;
|
||||
import com.midtrans.sdk.uikit.api.model.Address;
|
||||
import com.midtrans.sdk.uikit.external.UiKitApi;
|
||||
import com.midtrans.sdk.uikit.internal.util.UiKitConstants;
|
||||
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TambahLokasiJemput extends AppCompatActivity {
|
||||
|
||||
String idPerjalanan = "";
|
||||
String asal = "";
|
||||
String waktu = "";
|
||||
Date tanggal;
|
||||
String tujuan = "";
|
||||
String idUser = "";
|
||||
String harga = "";
|
||||
String namaUser = "";
|
||||
String emailUser = "";
|
||||
String telpUser = "";
|
||||
String alamatUser = "";
|
||||
String penumpang = "";
|
||||
Double totalHarga;
|
||||
double hargaDouble;
|
||||
TiketData tiketData;
|
||||
|
||||
|
||||
TextView tvAsal, tvTujuan, tvWaktu, tvTanggal, tvNama, tvPenumpang, tvTotal;
|
||||
EditText etAlamatTujuan;
|
||||
AppCompatButton btnLokasi, btnLokasiMaps, btnBayar;
|
||||
|
||||
@SuppressLint("MissingInflatedId")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_tambah_lokasi_jemput);
|
||||
|
||||
onBindView();
|
||||
initMidtransSdk();
|
||||
// buildUiKit();
|
||||
Intent intent = getIntent();
|
||||
if (intent.getExtras() != null) {
|
||||
tiketData = (TiketData) intent.getSerializableExtra("tiket");
|
||||
idPerjalanan = tiketData.getId();
|
||||
asal = tiketData.getAsal();
|
||||
tujuan = tiketData.getTujuan();
|
||||
waktu = tiketData.getWaktu();
|
||||
tanggal = tiketData.getTanggal();
|
||||
hargaDouble = tiketData.getHarga();
|
||||
|
||||
idUser = intent.getStringExtra("id_user");
|
||||
namaUser = intent.getStringExtra("nama_user");
|
||||
emailUser = intent.getStringExtra("email_user");
|
||||
telpUser = intent.getStringExtra("telp_user");
|
||||
alamatUser = intent.getStringExtra("alamat_user");
|
||||
penumpang = intent.getStringExtra("penumpang");
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd MMMM yyyy");
|
||||
|
||||
String tanggalFormatted = sdf.format(tanggal);
|
||||
tvAsal.setText(asal);
|
||||
tvWaktu.setText(waktu);
|
||||
tvTanggal.setText(tanggalFormatted);
|
||||
tvTujuan.setText(tujuan);
|
||||
|
||||
int penumpangInt = Integer.parseInt(penumpang);
|
||||
totalHarga = hargaDouble * penumpangInt;
|
||||
tvTotal.setText(String.valueOf(totalHarga));
|
||||
tvNama.setText(namaUser);
|
||||
tvPenumpang.setText(penumpang);
|
||||
|
||||
btnBayar.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MidtransSDK.getInstance().setTransactionRequest(initTransactionRequest());
|
||||
MidtransSDK.getInstance().startPaymentUiFlow(TambahLokasiJemput.this, PaymentMethod.BANK_TRANSFER_MANDIRI);
|
||||
}
|
||||
});
|
||||
}
|
||||
btnLokasi.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(TambahLokasiJemput.this, CurrentLocationActivity.class);
|
||||
startActivity(i);
|
||||
}
|
||||
});
|
||||
btnLokasiMaps.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(TambahLokasiJemput.this, FromMapsActivity.class);
|
||||
startActivity(i);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void onBindView(){
|
||||
tvAsal = findViewById(R.id.asal);
|
||||
tvTujuan = findViewById(R.id.Tujuan);
|
||||
tvWaktu = findViewById(R.id.waktu);
|
||||
tvTanggal = findViewById(R.id.date);
|
||||
tvPenumpang = findViewById(R.id.txtJumlahPenumpang);
|
||||
tvNama = findViewById(R.id.txtpenumpang);
|
||||
tvTotal = findViewById(R.id.tvTotal);
|
||||
etAlamatTujuan = findViewById(R.id.et_alamat);
|
||||
btnLokasi = findViewById(R.id.btnCurrentLoc);
|
||||
btnLokasiMaps = findViewById(R.id.maps);
|
||||
btnBayar = findViewById(R.id.bayarsekarang);
|
||||
}
|
||||
private void initMidtransSdk(){
|
||||
String CLIENT_KEY = "SB-Mid-client-M2wdn0pfhe0Wld-l";
|
||||
String MERCHANT_URL = "https://hallomomswebsite.000webhostapp.com/midtrans.php/";
|
||||
SdkUIFlowBuilder.init()
|
||||
.setClientKey(CLIENT_KEY) // client_key is mandatory
|
||||
.setContext(TambahLokasiJemput.this) // context is mandatory
|
||||
.setTransactionFinishedCallback(new TransactionFinishedCallback() {
|
||||
@Override
|
||||
public void onTransactionFinished(TransactionResult result) {
|
||||
if (result.getResponse() != null) {
|
||||
switch (result.getStatus()) {
|
||||
case TransactionResult.STATUS_SUCCESS:
|
||||
Toast.makeText(TambahLokasiJemput.this, "Transaction Finished. ID: " + result.getResponse().getTransactionId(), Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case TransactionResult.STATUS_PENDING:
|
||||
Toast.makeText(TambahLokasiJemput.this, "Transaction Pending. ID: " + result.getResponse().getTransactionId(), Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case TransactionResult.STATUS_FAILED:
|
||||
Toast.makeText(TambahLokasiJemput.this, "Transaction Failed. ID: " + result.getResponse().getTransactionId() + ". Message: " + result.getResponse().getStatusMessage(), Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
}
|
||||
} else if (result.isTransactionCanceled()) {
|
||||
Toast.makeText(TambahLokasiJemput.this, "Transaction Canceled", Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
if (result.getStatus().equalsIgnoreCase(TransactionResult.STATUS_INVALID)) {
|
||||
Toast.makeText(TambahLokasiJemput.this, "Transaction Invalid", Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
Toast.makeText(TambahLokasiJemput.this, "Transaction Finished with failure.", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}) // set transaction finish callback (sdk callback)
|
||||
.setMerchantBaseUrl(MERCHANT_URL) //set merchant url (required)
|
||||
.enableLog(true) // enable sdk log (optional)
|
||||
.setColorTheme(new CustomColorTheme("#FFE51255", "#B61548", "#FFE51255")) // set theme. it will replace theme on snap theme on MAP ( optional)
|
||||
.setLanguage("id")
|
||||
.buildSDK();
|
||||
uiKitCustomSetting();
|
||||
}
|
||||
private void uiKitCustomSetting() {
|
||||
UIKitCustomSetting uIKitCustomSetting = new UIKitCustomSetting();
|
||||
uIKitCustomSetting.setSaveCardChecked(true);
|
||||
MidtransSDK.getInstance().setUiKitCustomSetting(uIKitCustomSetting);
|
||||
}
|
||||
private CustomerDetails initCustomerDetails() {
|
||||
CustomerDetails mCustomerDetails = new CustomerDetails();
|
||||
mCustomerDetails.setPhone(telpUser);
|
||||
mCustomerDetails.setFirstName(namaUser);
|
||||
mCustomerDetails.setEmail(emailUser);
|
||||
mCustomerDetails.setCustomerIdentifier(emailUser);
|
||||
return mCustomerDetails;
|
||||
}
|
||||
private com.midtrans.sdk.uikit.api.model.CustomerDetails cus() {
|
||||
Address shippingAddress = new Address(
|
||||
null, // First Name
|
||||
null, // Last Name
|
||||
"Jalan Andalas Gang Sebelah No. 1", // Address
|
||||
"Jakarta", // City
|
||||
"10220", // PostCode
|
||||
null, // Phone Number
|
||||
null // Country Code
|
||||
);
|
||||
com.midtrans.sdk.uikit.api.model.CustomerDetails mCustomerDetails = new com.midtrans.sdk.uikit.api.model.CustomerDetails(
|
||||
emailUser, namaUser, namaUser, emailUser, telpUser, shippingAddress, shippingAddress
|
||||
);
|
||||
return mCustomerDetails;
|
||||
}
|
||||
private TransactionRequest initTransactionRequest() {
|
||||
String orderId = "PETTA-Express-";
|
||||
TransactionRequest transactionRequestNew = new
|
||||
TransactionRequest(orderId + System.currentTimeMillis() + "", totalHarga);
|
||||
transactionRequestNew.setCustomerDetails(initCustomerDetails());
|
||||
|
||||
ItemDetails itemDetails1 = new ItemDetails("idPerjalanan", hargaDouble, Integer.parseInt(penumpang), "ITEM_NAME_1");
|
||||
ArrayList<ItemDetails> itemDetailsList = new ArrayList<>();
|
||||
itemDetailsList.add(itemDetails1);
|
||||
transactionRequestNew.setItemDetails(itemDetailsList);
|
||||
return transactionRequestNew;
|
||||
}
|
||||
|
||||
private final ActivityResultLauncher<Intent> launcher = registerForActivityResult(
|
||||
new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if (result.getResultCode() == RESULT_OK && result.getData() != null) {
|
||||
com.midtrans.sdk.uikit.api.model.TransactionResult transactionResult = result.getData()
|
||||
.getParcelableExtra(UiKitConstants.KEY_TRANSACTION_RESULT);
|
||||
if (transactionResult != null) {
|
||||
switch (transactionResult.getStatus()) {
|
||||
case UiKitConstants.STATUS_SUCCESS:
|
||||
Toast.makeText(this, "Transaction Finished. ID: " +
|
||||
transactionResult.getTransactionId(), Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case UiKitConstants.STATUS_PENDING:
|
||||
Toast.makeText(this, "Transaction Pending. ID: " +
|
||||
transactionResult.getTransactionId(), Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case UiKitConstants.STATUS_FAILED:
|
||||
Toast.makeText(this, "Transaction Failed. ID: " +
|
||||
transactionResult.getTransactionId(), Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case UiKitConstants.STATUS_CANCELED:
|
||||
Toast.makeText(this, "Transaction Cancelled", Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case UiKitConstants.STATUS_INVALID:
|
||||
Toast.makeText(this, "Transaction Invalid. ID: " +
|
||||
transactionResult.getTransactionId(), Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
default:
|
||||
Toast.makeText(this, "Transaction ID: " +
|
||||
transactionResult.getTransactionId() + ". Message: " +
|
||||
transactionResult.getStatus(), Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(this, "Transaction Invalid", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
private com.midtrans.sdk.uikit.api.model.SnapTransactionDetail initTransactionDetails() {
|
||||
return new com.midtrans.sdk.uikit.api.model.SnapTransactionDetail(
|
||||
UUID.randomUUID().toString(),
|
||||
20000.0, "IDR"
|
||||
);
|
||||
}
|
||||
private void buildUiKit() {
|
||||
String CLIENT_KEY = "SB-Mid-client-M2wdn0pfhe0Wld-l";
|
||||
String MERCHANT_URL = "https://hallomomswebsite.000webhostapp.com/midtrans.php/";
|
||||
new UiKitApi.Builder()
|
||||
.withContext(this.getApplicationContext())
|
||||
.withMerchantUrl(MERCHANT_URL)
|
||||
.withMerchantClientKey(CLIENT_KEY)
|
||||
.enableLog(true)
|
||||
.withColorTheme(new com.midtrans.sdk.uikit.api.model.CustomColorTheme("#FFE51255", "#B61548", "#FFE51255"))
|
||||
.build();
|
||||
uiKitCustomSetting();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.example.travelapps;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.example.travelapps.R;
|
||||
|
||||
public class WelcomeActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_welcome);
|
||||
|
||||
// Delay untuk beberapa detik
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Intent untuk pindah ke LoginActivity
|
||||
Intent intent = new Intent(WelcomeActivity.this, LoginActivity.class);
|
||||
startActivity(intent);
|
||||
finish(); // Menutup aktivitas saat ini
|
||||
}
|
||||
}, 3000); // Misalnya, delay 3 detik
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.example.travelapps.pelanggan;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.example.travelapps.R;
|
||||
|
||||
public class AboutActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_about);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
package com.example.travelapps.pelanggan;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.AppCompatButton;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
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.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.travelapps.R;
|
||||
import com.google.android.gms.location.FusedLocationProviderClient;
|
||||
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.gms.maps.model.MarkerOptions;
|
||||
import com.google.android.gms.tasks.OnSuccessListener;
|
||||
import com.google.android.gms.tasks.Task;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class CurrentLocationActivity extends AppCompatActivity implements OnMapReadyCallback {
|
||||
|
||||
private GoogleMap gMaps;
|
||||
final private int FINE_PERMISSION_CODE = 1;
|
||||
Location currentLocation;
|
||||
TextView tvAlamat;
|
||||
AppCompatButton btnSimpan;
|
||||
FusedLocationProviderClient fusedLocationProviderClient;
|
||||
@SuppressLint("MissingInflatedId")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_current_location);
|
||||
|
||||
SharedPreferences preferences = CurrentLocationActivity.this.getSharedPreferences("myPrefs", MODE_PRIVATE);
|
||||
String token = preferences.getString("token", "");
|
||||
|
||||
fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this);
|
||||
getLastLocation();
|
||||
|
||||
tvAlamat = findViewById(R.id.alamat);
|
||||
btnSimpan = findViewById(R.id.btnSimpan);
|
||||
btnSimpan.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(CurrentLocationActivity.this, PaymentMidtransActivity.class);
|
||||
i.putExtra("tiket", getIntent().getSerializableExtra("tiket"));
|
||||
i.putExtra("id_user", getIntent().getStringExtra("id_user"));
|
||||
i.putExtra("nama_user", getIntent().getStringExtra("nama_user"));
|
||||
i.putExtra("email_user", getIntent().getStringExtra("email_user"));
|
||||
i.putExtra("telp_user", getIntent().getStringExtra("telp_user"));
|
||||
i.putExtra("alamat_user", getIntent().getStringExtra("alamat_user"));
|
||||
i.putExtra("penumpang", getIntent().getStringExtra("penumpang"));
|
||||
i.putExtra("lat_jemput", String.valueOf(currentLocation.getLatitude()));
|
||||
i.putExtra("lng_jemput", String.valueOf(currentLocation.getLongitude()));
|
||||
startActivity(i);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getLastLocation() {
|
||||
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, FINE_PERMISSION_CODE);
|
||||
return;
|
||||
}
|
||||
Task<Location> task = fusedLocationProviderClient.getLastLocation();
|
||||
task.addOnSuccessListener(new OnSuccessListener<Location>() {
|
||||
@Override
|
||||
public void onSuccess(Location location) {
|
||||
if (location != null) {
|
||||
currentLocation = location;
|
||||
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
|
||||
mapFragment.getMapAsync(CurrentLocationActivity.this);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapReady(@NonNull GoogleMap googleMap) {
|
||||
gMaps = googleMap;
|
||||
|
||||
LatLng sydney = new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude());
|
||||
gMaps.addMarker(new MarkerOptions().position(sydney).title("MyLocation"));
|
||||
float zoomLevel = 16.0f;
|
||||
gMaps.moveCamera(CameraUpdateFactory.newLatLngZoom(sydney, zoomLevel));
|
||||
getAddressFromLocation(currentLocation.getLatitude(), currentLocation.getLongitude());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == FINE_PERMISSION_CODE) {
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
getLastLocation();
|
||||
} else {
|
||||
Toast.makeText(this, "Location Permission is Denied", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void getAddressFromLocation(double latitude, double longitude) {
|
||||
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
|
||||
try {
|
||||
List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);
|
||||
if (addresses != null && addresses.size() > 0) {
|
||||
Address address = addresses.get(0);
|
||||
String addressLine = address.getAddressLine(0);
|
||||
tvAlamat.setText(addressLine);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,220 @@
|
|||
package com.example.travelapps.pelanggan;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.travelapps.Model.Pemesanan;
|
||||
import com.example.travelapps.Model.TransactionModel;
|
||||
import com.example.travelapps.Services.ApiServices;
|
||||
import com.example.travelapps.Services.MidtransServices;
|
||||
import com.example.travelapps.R;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class DetailPemesananActivity extends AppCompatActivity {
|
||||
|
||||
TextView tvAsal, tvTujuan, tvDate, tvWaktu, tvPenumpang, tvStatus, tvJemput, tvATujuan, tvPembayaran, tvBank, tvVa;
|
||||
// AppCompatButton btnBayar;
|
||||
String orderId = "";
|
||||
String idPerjalanan = "";
|
||||
Pemesanan.PemesananData pemesanan;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_detail_pemesanan);
|
||||
SharedPreferences preferences = DetailPemesananActivity.this.getSharedPreferences("myPrefs", MODE_PRIVATE);
|
||||
String token = preferences.getString("token", "");
|
||||
|
||||
onBindView();
|
||||
getIntentView();
|
||||
// btnBayar.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// Toast.makeText(DetailPemesananActivity.this, "hahah", Toast.LENGTH_SHORT).show();
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
public void onBindView(){
|
||||
tvAsal = findViewById(R.id.asal);
|
||||
tvTujuan = findViewById(R.id.Tujuan);
|
||||
tvDate = findViewById(R.id.date);
|
||||
tvWaktu = findViewById(R.id.waktu);
|
||||
tvPenumpang = findViewById(R.id.txtPenumpang);
|
||||
tvStatus = findViewById(R.id.tvStatus);
|
||||
tvJemput = findViewById(R.id.tvAlamatJemput);
|
||||
tvATujuan = findViewById(R.id.tvAlamatTujuan);
|
||||
// btnBayar = findViewById(R.id.bayarsekarang);
|
||||
tvPembayaran = findViewById(R.id.pembayaran);
|
||||
tvBank = findViewById(R.id.bank);
|
||||
tvVa = findViewById(R.id.va_number);
|
||||
}
|
||||
|
||||
public void getIntentView(){
|
||||
Intent i = getIntent();
|
||||
if (i.getExtras() != null) {
|
||||
pemesanan = (Pemesanan.PemesananData) i.getSerializableExtra("pemesananData");
|
||||
|
||||
String asal = pemesanan.getKotaAsal();
|
||||
String tujuan = pemesanan.getKotaTujuan();
|
||||
String tanggal = pemesanan.getTanggal();
|
||||
String waktu = pemesanan.getWaktuKeberangkatan();
|
||||
String jemput = pemesanan.getAlamatJemput();
|
||||
String tujuanA = pemesanan.getAlamatTujuan();
|
||||
orderId = pemesanan.getOrderId();
|
||||
idPerjalanan = pemesanan.getIdPerjalanan();
|
||||
String qty = pemesanan.getQty();
|
||||
String status1 = pemesanan.getStatus();
|
||||
String idUser = pemesanan.getIdUser();
|
||||
|
||||
tvAsal.setText(asal);
|
||||
tvTujuan.setText(tujuan);
|
||||
tvDate.setText(tanggal);
|
||||
tvWaktu.setText(waktu);
|
||||
tvJemput.setText(jemput);
|
||||
tvATujuan.setText(tujuanA);
|
||||
tvPenumpang.setText(qty);
|
||||
tvStatus.setText(status1);
|
||||
|
||||
if (!Objects.equals(status1, "Gagal")) {
|
||||
MidtransServices midtransServices = new MidtransServices(this);
|
||||
midtransServices.getTransactionStatus(orderId, new MidtransServices.TransactionStatusResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(TransactionModel transactionModel) {
|
||||
String status = transactionModel.getTransactionStatus();
|
||||
String orderId = transactionModel.getOrderId();
|
||||
String status1 = pemesanan.getStatus();
|
||||
String bank = transactionModel.getBankInfo().getBank();
|
||||
String va = transactionModel.getBankInfo().getVaNumber();
|
||||
if (Objects.equals(status, "failure")) {
|
||||
ApiServices.status(DetailPemesananActivity.this, orderId, "Gagal", new ApiServices.AddLatlongResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String message) {
|
||||
Log.e("statusPesan", "berhasil update status gagal");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Log.e("statusPesan", message);
|
||||
}
|
||||
});
|
||||
ApiServices.notifikasi(DetailPemesananActivity.this, idUser, "Pemesanan Tiket", "Pembayaran anda Gagal, transaksi dibatalkan", new ApiServices.RegisterResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String message) {
|
||||
Log.e("notifikasi", message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Log.e("notifikasi", message);
|
||||
}
|
||||
});
|
||||
} else if (Objects.equals(status, "expire")) {
|
||||
ApiServices.status(DetailPemesananActivity.this, orderId, "Gagal", new ApiServices.AddLatlongResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String message) {
|
||||
Log.e("statusPesan", "berhasil update status gagal");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Log.e("statusPesan", message);
|
||||
}
|
||||
});
|
||||
ApiServices.notifikasi(DetailPemesananActivity.this, idUser, "Pemesanan Tiket", "Pembayaran anda expired, silahkan lakukan transaksi ulang", new ApiServices.RegisterResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String message) {
|
||||
Log.e("notifikasi", message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Log.e("notifikasi", message);
|
||||
}
|
||||
});
|
||||
}
|
||||
else if(Objects.equals(status, "pending")){
|
||||
ApiServices.status(DetailPemesananActivity.this, orderId, "Menunggu", new ApiServices.AddLatlongResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String message) {
|
||||
Log.e("statusPesan", "berhasil update status menunggu");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Log.e("statusPesan", message);
|
||||
}
|
||||
});
|
||||
ApiServices.notifikasi(DetailPemesananActivity.this, idUser, "Pemesanan Tiket", "Pembayaran anda pending, silahkan lakukan pembayaran", new ApiServices.RegisterResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String message) {
|
||||
Log.e("notifikasi", message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Log.e("notifikasi", message);
|
||||
}
|
||||
});
|
||||
tvVa.setVisibility(View.VISIBLE);
|
||||
tvVa.setText("Va Number : " + va);
|
||||
tvBank.setVisibility(View.VISIBLE);
|
||||
tvBank.setText("Bank : " + bank);
|
||||
} else if(Objects.equals(status, "settlement")){
|
||||
ApiServices.status(DetailPemesananActivity.this, orderId, "Selesai", new ApiServices.AddLatlongResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String message) {
|
||||
Log.e("statusPesan", "berhasil update status berhasil");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Log.e("statusPesan", message);
|
||||
}
|
||||
});
|
||||
ApiServices.notifikasi(DetailPemesananActivity.this, idUser, "Pemesanan Tiket", "Pembayaran anda Berhasil", new ApiServices.RegisterResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String message) {
|
||||
Log.e("notifikasi", message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Log.e("notifikasi", message);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Log.e("statusPesan", status);
|
||||
|
||||
}
|
||||
tvStatus.setText(status1);
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Log.e("DetailPemesananActivity", "Error: " + message);
|
||||
}
|
||||
});
|
||||
|
||||
} else if(Objects.equals(status1, "Menunggu")){
|
||||
// btnBayar.setVisibility(View.VISIBLE);
|
||||
tvPembayaran.setVisibility(View.VISIBLE);
|
||||
tvVa.setVisibility(View.VISIBLE);
|
||||
tvBank.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
// btnBayar.setVisibility(View.GONE);
|
||||
tvPembayaran.setVisibility(View.GONE);
|
||||
tvVa.setVisibility(View.GONE);
|
||||
tvBank.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package com.example.travelapps.pelanggan;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.AppCompatButton;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.volley.Request;
|
||||
import com.android.volley.RequestQueue;
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.android.volley.toolbox.StringRequest;
|
||||
import com.android.volley.toolbox.Volley;
|
||||
import com.example.travelapps.R;
|
||||
import com.example.travelapps.Services.ApiServices;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ForgotPasswordActivity extends AppCompatActivity {
|
||||
|
||||
EditText etEmail;
|
||||
AppCompatButton btnSend;
|
||||
@SuppressLint("MissingInflatedId")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_forgot_password);
|
||||
etEmail = findViewById(R.id.et_email);
|
||||
btnSend = findViewById(R.id.btn_send);
|
||||
String email = etEmail.getText().toString().trim();
|
||||
|
||||
btnSend.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (email.isEmpty()) {
|
||||
Toast.makeText(ForgotPasswordActivity.this, "Silahkan masukkan email anda", Toast.LENGTH_SHORT);
|
||||
} else {
|
||||
Intent intent = new Intent(ForgotPasswordActivity.this, NewPasswordActivity.class);
|
||||
intent.putExtra("email", email);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
private void sendResetPasswordRequest() {
|
||||
String email = etEmail.getText().toString().trim();
|
||||
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.POST, ApiServices.getHOST() + "reset-password.php", new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
try {
|
||||
JSONObject jsonResponse = new JSONObject(response);
|
||||
Log.e("res", response);
|
||||
boolean success = jsonResponse.getBoolean("success");
|
||||
if (success) {
|
||||
// removeTokenFromPrefs();
|
||||
Toast.makeText(ForgotPasswordActivity.this, "Email sent successfully", Toast.LENGTH_SHORT).show();
|
||||
Intent intent = new Intent(ForgotPasswordActivity.this, OtpActivity.class);
|
||||
intent.putExtra("email", email);
|
||||
startActivity(intent);
|
||||
} else {
|
||||
String message = jsonResponse.getString("message");
|
||||
Toast.makeText(ForgotPasswordActivity.this, message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(ForgotPasswordActivity.this, "JSON parsing error", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
error.printStackTrace();
|
||||
Toast.makeText(ForgotPasswordActivity.this, "Volley error" + error, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}) {
|
||||
@Override
|
||||
protected Map<String, String> getParams() {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("email", email);
|
||||
return params;
|
||||
}
|
||||
};
|
||||
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(this);
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,174 @@
|
|||
package com.example.travelapps.pelanggan;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.AppCompatButton;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.Address;
|
||||
import android.location.Geocoder;
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.SearchView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.travelapps.Services.ApiServices;
|
||||
import com.google.android.gms.location.FusedLocationProviderClient;
|
||||
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.gms.maps.model.MarkerOptions;
|
||||
import com.google.android.gms.tasks.OnSuccessListener;
|
||||
import com.google.android.gms.tasks.Task;
|
||||
import com.example.travelapps.R;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class FromMapsActivity extends AppCompatActivity implements OnMapReadyCallback {
|
||||
|
||||
private GoogleMap gMaps;
|
||||
final private int FINE_PERMISSION_CODE = 1;
|
||||
Location currentLocation;
|
||||
TextView tvAlamat;
|
||||
SearchView searchView;
|
||||
AppCompatButton btnSimpan;
|
||||
String locationSearch = "";
|
||||
FusedLocationProviderClient fusedLocationProviderClient;
|
||||
LatLng newlatLng;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_from_maps);
|
||||
SharedPreferences preferences = FromMapsActivity.this.getSharedPreferences("myPrefs", MODE_PRIVATE);
|
||||
String token = preferences.getString("token", "");
|
||||
fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this);
|
||||
getLastLocation();
|
||||
|
||||
tvAlamat = findViewById(R.id.alamat);
|
||||
searchView = findViewById(R.id.search);
|
||||
|
||||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
locationSearch = searchView.getQuery().toString();
|
||||
List<Address> addresses = null;
|
||||
if (locationSearch != null) {
|
||||
Geocoder geo = new Geocoder(FromMapsActivity.this);
|
||||
try {
|
||||
addresses = geo.getFromLocationName(locationSearch, 1);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Address address = addresses.get(0);
|
||||
LatLng latLng = new LatLng(address.getLatitude(), address.getLongitude());
|
||||
newlatLng = latLng;
|
||||
gMaps.clear();
|
||||
gMaps.addMarker(new MarkerOptions().position(newlatLng).title("MyLocation"));
|
||||
gMaps.animateCamera(CameraUpdateFactory.newLatLngZoom(newlatLng, 16.0f));
|
||||
getAddressFromLocation(address.getLatitude(), address.getLongitude());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
btnSimpan = findViewById(R.id.btnSimpan);
|
||||
btnSimpan.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ApiServices.addLatlong(FromMapsActivity.this, token, currentLocation.getLatitude(), currentLocation.getLongitude(), new ApiServices.AddLatlongResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String message) {
|
||||
onBackPressed();
|
||||
Toast.makeText(FromMapsActivity.this, "Berhasil menyimpan lokasi penjemputan", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Toast.makeText(FromMapsActivity.this, "Error " + message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void getLastLocation() {
|
||||
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, FINE_PERMISSION_CODE);
|
||||
return;
|
||||
}
|
||||
Task<Location> task = fusedLocationProviderClient.getLastLocation();
|
||||
task.addOnSuccessListener(new OnSuccessListener<Location>() {
|
||||
@Override
|
||||
public void onSuccess(Location location) {
|
||||
if (location != null) {
|
||||
currentLocation = location;
|
||||
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
|
||||
mapFragment.getMapAsync(FromMapsActivity.this);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapReady(@NonNull GoogleMap googleMap) {
|
||||
gMaps = googleMap;
|
||||
gMaps.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
|
||||
@Override
|
||||
public void onMapClick(LatLng latLng) {
|
||||
newlatLng = latLng;
|
||||
currentLocation.setLatitude(newlatLng.latitude);
|
||||
currentLocation.setLongitude(newlatLng.longitude);
|
||||
gMaps.clear();
|
||||
gMaps.addMarker(new MarkerOptions().position(newlatLng).title("MyLocation"));
|
||||
gMaps.animateCamera(CameraUpdateFactory.newLatLngZoom(newlatLng, 16.0f));
|
||||
getAddressFromLocation(latLng.latitude, latLng.longitude);
|
||||
}
|
||||
});
|
||||
newlatLng = new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude());
|
||||
gMaps.addMarker(new MarkerOptions().position(newlatLng).title("MyLocation"));
|
||||
float zoomLevel = 16.0f;
|
||||
gMaps.moveCamera(CameraUpdateFactory.newLatLngZoom(newlatLng, zoomLevel));
|
||||
getAddressFromLocation(currentLocation.getLatitude(), currentLocation.getLongitude());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == FINE_PERMISSION_CODE) {
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
getLastLocation();
|
||||
} else {
|
||||
Toast.makeText(this, "Location Permission is Denied", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void getAddressFromLocation(double latitude, double longitude) {
|
||||
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
|
||||
try {
|
||||
List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);
|
||||
if (addresses != null && addresses.size() > 0) {
|
||||
Address address = addresses.get(0);
|
||||
String addressLine = address.getAddressLine(0);
|
||||
tvAlamat.setText(addressLine);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.example.travelapps.pelanggan;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.example.travelapps.Fragment.FragmentActivity;
|
||||
import com.example.travelapps.Fragment.FragmentHome;
|
||||
import com.example.travelapps.Fragment.FragmentNotifications;
|
||||
import com.example.travelapps.Fragment.FragmentSettings;
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
import com.example.travelapps.R;
|
||||
|
||||
public class HomeActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_home);
|
||||
|
||||
BottomNavigationView bottomNavigationView = findViewById(R.id.bottomNavigationView);
|
||||
bottomNavigationView.setOnItemSelectedListener(navListener);
|
||||
|
||||
// Tampilkan fragment pertama kali (misalnya, FragmentHome)
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.frameLayoutContainer,
|
||||
new FragmentHome()).commit();
|
||||
}
|
||||
|
||||
private final BottomNavigationView.OnItemSelectedListener navListener =
|
||||
new BottomNavigationView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||
Fragment selectedFragment = null;
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_home:
|
||||
selectedFragment = new FragmentHome();
|
||||
break;
|
||||
case R.id.menu_profile:
|
||||
selectedFragment = new FragmentActivity();
|
||||
break;
|
||||
case R.id.menu_notifications:
|
||||
selectedFragment = new FragmentNotifications();
|
||||
break;
|
||||
case R.id.menu_settings:
|
||||
selectedFragment = new FragmentSettings();
|
||||
break;
|
||||
}
|
||||
|
||||
// Ganti fragment yang ditampilkan
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.frameLayoutContainer,
|
||||
selectedFragment).commit();
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.example.travelapps.pelanggan;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.example.travelapps.R;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,169 @@
|
|||
package com.example.travelapps.pelanggan;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.AppCompatButton;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
||||
import android.Manifest;
|
||||
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.view.View;
|
||||
import android.widget.SearchView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.travelapps.R;
|
||||
import com.google.android.gms.location.FusedLocationProviderClient;
|
||||
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.gms.maps.model.MarkerOptions;
|
||||
import com.google.android.gms.tasks.OnSuccessListener;
|
||||
import com.google.android.gms.tasks.Task;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class MapsTujuanActivity extends AppCompatActivity implements OnMapReadyCallback {
|
||||
private GoogleMap gMaps;
|
||||
final private int FINE_PERMISSION_CODE = 1;
|
||||
Location currentLocation;
|
||||
TextView tvAlamat;
|
||||
SearchView searchView;
|
||||
AppCompatButton btnSimpan;
|
||||
String locationSearch = "";
|
||||
FusedLocationProviderClient fusedLocationProviderClient;
|
||||
LatLng newlatLng;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_maps_tujuan);
|
||||
fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this);
|
||||
getLastLocation();
|
||||
|
||||
tvAlamat = findViewById(R.id.alamat);
|
||||
searchView = findViewById(R.id.search);
|
||||
|
||||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
locationSearch = searchView.getQuery().toString();
|
||||
List<Address> addresses = null;
|
||||
if (locationSearch != null) {
|
||||
Geocoder geo = new Geocoder(MapsTujuanActivity.this);
|
||||
try {
|
||||
addresses = geo.getFromLocationName(locationSearch, 1);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Address address = addresses.get(0);
|
||||
LatLng latLng = new LatLng(address.getLatitude(), address.getLongitude());
|
||||
newlatLng = latLng;
|
||||
gMaps.clear();
|
||||
gMaps.addMarker(new MarkerOptions().position(newlatLng).title("MyLocation"));
|
||||
gMaps.animateCamera(CameraUpdateFactory.newLatLngZoom(newlatLng, 16.0f));
|
||||
getAddressFromLocation(address.getLatitude(), address.getLongitude());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
btnSimpan = findViewById(R.id.btnSimpan);
|
||||
btnSimpan.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(MapsTujuanActivity.this, PaymentMidtransActivity.class);
|
||||
i.putExtra("tiket", getIntent().getSerializableExtra("tiket"));
|
||||
i.putExtra("id_user", getIntent().getStringExtra("id_user"));
|
||||
i.putExtra("nama_user", getIntent().getStringExtra("nama_user"));
|
||||
i.putExtra("email_user", getIntent().getStringExtra("email_user"));
|
||||
i.putExtra("telp_user", getIntent().getStringExtra("telp_user"));
|
||||
i.putExtra("alamat_user", getIntent().getStringExtra("alamat_user"));
|
||||
i.putExtra("penumpang", getIntent().getStringExtra("penumpang"));
|
||||
i.putExtra("lat_tujuan", String.valueOf(currentLocation.getLatitude()));
|
||||
i.putExtra("lng_tujuan", String.valueOf(currentLocation.getLongitude()));
|
||||
i.putExtra("alamat_tujuan", String.valueOf(tvAlamat.getText()));
|
||||
startActivity(i);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
private void getLastLocation() {
|
||||
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, FINE_PERMISSION_CODE);
|
||||
return;
|
||||
}
|
||||
Task<Location> task = fusedLocationProviderClient.getLastLocation();
|
||||
task.addOnSuccessListener(new OnSuccessListener<Location>() {
|
||||
@Override
|
||||
public void onSuccess(Location location) {
|
||||
if (location != null) {
|
||||
currentLocation = location;
|
||||
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
|
||||
mapFragment.getMapAsync(MapsTujuanActivity.this);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapReady(@NonNull GoogleMap googleMap) {
|
||||
gMaps = googleMap;
|
||||
gMaps.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
|
||||
@Override
|
||||
public void onMapClick(LatLng latLng) {
|
||||
newlatLng = latLng;
|
||||
currentLocation.setLatitude(newlatLng.latitude);
|
||||
currentLocation.setLongitude(newlatLng.longitude);
|
||||
gMaps.clear();
|
||||
gMaps.addMarker(new MarkerOptions().position(newlatLng).title("MyLocation"));
|
||||
gMaps.animateCamera(CameraUpdateFactory.newLatLngZoom(newlatLng, 16.0f));
|
||||
getAddressFromLocation(latLng.latitude, latLng.longitude);
|
||||
}
|
||||
});
|
||||
newlatLng = new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude());
|
||||
gMaps.addMarker(new MarkerOptions().position(newlatLng).title("MyLocation"));
|
||||
float zoomLevel = 16.0f;
|
||||
gMaps.moveCamera(CameraUpdateFactory.newLatLngZoom(newlatLng, zoomLevel));
|
||||
getAddressFromLocation(currentLocation.getLatitude(), currentLocation.getLongitude());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == FINE_PERMISSION_CODE) {
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
getLastLocation();
|
||||
} else {
|
||||
Toast.makeText(this, "Location Permission is Denied", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void getAddressFromLocation(double latitude, double longitude) {
|
||||
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
|
||||
try {
|
||||
List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);
|
||||
if (addresses != null && addresses.size() > 0) {
|
||||
Address address = addresses.get(0);
|
||||
String addressLine = address.getAddressLine(0);
|
||||
tvAlamat.setText(addressLine);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
package com.example.travelapps.pelanggan;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.AppCompatButton;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.volley.Request;
|
||||
import com.android.volley.RequestQueue;
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.android.volley.toolbox.StringRequest;
|
||||
import com.android.volley.toolbox.Volley;
|
||||
import com.example.travelapps.LoginActivity;
|
||||
import com.example.travelapps.R;
|
||||
import com.example.travelapps.Services.ApiServices;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class NewPasswordActivity extends AppCompatActivity {
|
||||
EditText etPassword, etPasswordConfirm, etPasswordOld;
|
||||
AppCompatButton btnUpdate;
|
||||
RequestQueue requestQueue;
|
||||
@SuppressLint("MissingInflatedId")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_new_password);
|
||||
etPassword = findViewById(R.id.et_password);
|
||||
etPasswordOld = findViewById(R.id.et_password_old);
|
||||
etPasswordConfirm = findViewById(R.id.et_password_confirm);
|
||||
btnUpdate = findViewById(R.id.btn_update);
|
||||
requestQueue = Volley.newRequestQueue(this);
|
||||
Intent i = getIntent();
|
||||
String email = i.getStringExtra("email");
|
||||
btnUpdate.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String password = etPassword.getText().toString().trim();
|
||||
String confirm = etPassword.getText().toString().trim();
|
||||
if (password.isEmpty()) {
|
||||
Toast.makeText(NewPasswordActivity.this, "Silahkan masukkan password baru", Toast.LENGTH_SHORT).show();
|
||||
} else if(!password.equals(confirm)){
|
||||
Toast.makeText(NewPasswordActivity.this, "Password harus sama", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else {
|
||||
newPassword(email, password, etPasswordOld.getText().toString().trim());
|
||||
}}
|
||||
});
|
||||
}
|
||||
|
||||
private void newPassword(final String email, final String new_password, String oldPassword){
|
||||
String url = ApiServices.getHOST() + "new-password.php";
|
||||
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.POST, url,
|
||||
new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
try {
|
||||
Log.e("hahah", response);
|
||||
JSONObject jsonResponse = new JSONObject(response);
|
||||
boolean success = jsonResponse.getBoolean("success");
|
||||
if (success) {
|
||||
Intent intent = new Intent(NewPasswordActivity.this, LoginActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
Toast.makeText(NewPasswordActivity.this, "Update password successfully", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
String message = jsonResponse.getString("message");
|
||||
Toast.makeText(NewPasswordActivity.this, "Update password failed: " + message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(NewPasswordActivity.this, "Error parsing response", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
Toast.makeText(NewPasswordActivity.this, "Error: " + error.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}) {
|
||||
@Override
|
||||
protected Map<String, String> getParams() {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("email", email);
|
||||
params.put("old_password", oldPassword);
|
||||
params.put("new_password", new_password);
|
||||
return params;
|
||||
}
|
||||
};
|
||||
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
package com.example.travelapps.pelanggan;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.AppCompatButton;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.volley.Request;
|
||||
import com.android.volley.RequestQueue;
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.android.volley.toolbox.StringRequest;
|
||||
import com.android.volley.toolbox.Volley;
|
||||
import com.example.travelapps.R;
|
||||
import com.example.travelapps.Services.ApiServices;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class OtpActivity extends AppCompatActivity {
|
||||
|
||||
EditText etOtp;
|
||||
AppCompatButton btnVeifikasi;
|
||||
RequestQueue requestQueue;
|
||||
@SuppressLint("MissingInflatedId")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_otp);
|
||||
etOtp = findViewById(R.id.et_otp);
|
||||
btnVeifikasi = findViewById(R.id.btn_verifikasi);
|
||||
requestQueue = Volley.newRequestQueue(this);
|
||||
Intent i = getIntent();
|
||||
String email = i.getStringExtra("email");
|
||||
// Log.e("email", email);
|
||||
btnVeifikasi.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String otp = etOtp.getText().toString().trim();
|
||||
if (!otp.isEmpty()) {
|
||||
Log.e("email", email);
|
||||
verifyOTP(email, otp);
|
||||
} else {
|
||||
Toast.makeText(OtpActivity.this, "Please enter OTP", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void verifyOTP(final String email, final String otp){
|
||||
String url = ApiServices.getHOST() + "verifikasi-otp.php";
|
||||
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.POST, url,
|
||||
new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
try {
|
||||
JSONObject jsonResponse = new JSONObject(response);
|
||||
boolean success = jsonResponse.getBoolean("success");
|
||||
if (success) {
|
||||
SharedPreferences.Editor editor = OtpActivity.this.getSharedPreferences("myPrefs", MODE_PRIVATE).edit();
|
||||
editor.remove("isLogin");
|
||||
editor.remove("token");
|
||||
editor.remove("id");
|
||||
editor.apply();
|
||||
Intent intent = new Intent(OtpActivity.this, NewPasswordActivity.class);
|
||||
intent.putExtra("email", email);
|
||||
startActivity(intent);
|
||||
Toast.makeText(OtpActivity.this, "OTP verified successfully", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
String message = jsonResponse.getString("message");
|
||||
Toast.makeText(OtpActivity.this, "OTP verification failed: " + message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(OtpActivity.this, "Error parsing response", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
Toast.makeText(OtpActivity.this, "Error: " + error.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}) {
|
||||
@Override
|
||||
protected Map<String, String> getParams() {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("email", email);
|
||||
params.put("otp", otp);
|
||||
return params;
|
||||
}
|
||||
};
|
||||
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,465 @@
|
|||
package com.example.travelapps.pelanggan;
|
||||
|
||||
import static com.midtrans.sdk.corekit.core.PaymentMethod.BANK_TRANSFER;
|
||||
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import androidx.appcompat.widget.AppCompatButton;
|
||||
import androidx.core.os.LocaleListCompat;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.location.Geocoder;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.travelapps.Model.TiketData;
|
||||
import com.example.travelapps.Services.ApiServices;
|
||||
import com.midtrans.sdk.corekit.core.PaymentMethod;
|
||||
import com.midtrans.sdk.uikit.api.model.Address;
|
||||
import com.midtrans.sdk.uikit.api.model.Authentication;
|
||||
import com.midtrans.sdk.uikit.api.model.BankType;
|
||||
import com.midtrans.sdk.uikit.api.model.CreditCard;
|
||||
import com.midtrans.sdk.uikit.api.model.CustomColorTheme;
|
||||
import com.midtrans.sdk.uikit.api.model.CustomerDetails;
|
||||
import com.midtrans.sdk.uikit.api.model.Expiry;
|
||||
import com.midtrans.sdk.uikit.api.model.ItemDetails;
|
||||
import com.midtrans.sdk.uikit.api.model.PaymentType;
|
||||
import com.midtrans.sdk.uikit.api.model.SnapTransactionDetail;
|
||||
import com.midtrans.sdk.uikit.api.model.TransactionResult;
|
||||
import com.midtrans.sdk.uikit.external.UiKitApi;
|
||||
import com.midtrans.sdk.uikit.internal.util.UiKitConstants;
|
||||
import com.example.travelapps.R;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PaymentMidtransActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
|
||||
TextView tvAsal, tvTujuan, tvWaktu, tvTanggal, tvNama, tvPenumpang, tvTotal;
|
||||
EditText et_alamat;
|
||||
EditText etAlamatTujuan;
|
||||
AppCompatButton btnLokasi, btnLokasiMaps, btnBayar, btnMapsTujuan;
|
||||
ImageView btnBack;
|
||||
TiketData tiketData;
|
||||
String idPerjalanan = "";
|
||||
String asal = "";
|
||||
String waktu = "";
|
||||
Date tanggal;
|
||||
String tujuan = "";
|
||||
String idUser = "";
|
||||
String harga = "";
|
||||
String namaUser = "";
|
||||
String emailUser = "";
|
||||
String telpUser = "";
|
||||
String alamatUser = "";
|
||||
String penumpang = "";
|
||||
double hargaDouble;
|
||||
double totalHarga;
|
||||
String idOrder = "";
|
||||
String lat_jemput = "";
|
||||
String lng_jemput = "";
|
||||
String lat_tujuan="";
|
||||
String lng_tujuan="";
|
||||
String alamat_tujuan="";
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_payment_midtrans);
|
||||
onBindView();
|
||||
Intent intent = getIntent();
|
||||
getIntentData(intent);
|
||||
btnLokasi.setOnClickListener(this);
|
||||
btnLokasiMaps.setOnClickListener(this);
|
||||
btnBayar.setOnClickListener(this);
|
||||
btnBack.setOnClickListener(this);
|
||||
// btnMapsTujuan.setOnClickListener(this);
|
||||
buildUiKit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (view == btnLokasi) {
|
||||
Intent i = new Intent(PaymentMidtransActivity.this, FromMapsActivity.class);
|
||||
i.putExtra("tiket", tiketData);
|
||||
i.putExtra("id_user", idUser);
|
||||
i.putExtra("nama_user", namaUser);
|
||||
i.putExtra("email_user", emailUser);
|
||||
i.putExtra("telp_user", telpUser);
|
||||
i.putExtra("alamat_user", alamatUser);
|
||||
i.putExtra("penumpang", penumpang);
|
||||
startActivity(i);
|
||||
} else if(view == btnBack) {
|
||||
onBackPressed();
|
||||
}
|
||||
// else if (view == btnLokasiMaps) {
|
||||
// Intent i = new Intent(PaymentMidtransActivity.this, FromMapsActivity.class);
|
||||
// i.putExtra("tiket", tiketData);
|
||||
// i.putExtra("id_user", idUser);
|
||||
// i.putExtra("nama_user", namaUser);
|
||||
// i.putExtra("email_user", emailUser);
|
||||
// i.putExtra("telp_user", telpUser);
|
||||
// i.putExtra("alamat_user", alamatUser);
|
||||
// i.putExtra("penumpang", penumpang);
|
||||
// startActivity(i);
|
||||
// }
|
||||
else if (view == btnLokasiMaps){
|
||||
Intent i = new Intent(PaymentMidtransActivity.this, MapsTujuanActivity.class);
|
||||
i.putExtra("tiket", tiketData);
|
||||
i.putExtra("id_user", idUser);
|
||||
i.putExtra("nama_user", namaUser);
|
||||
i.putExtra("email_user", emailUser);
|
||||
i.putExtra("telp_user", telpUser);
|
||||
i.putExtra("alamat_user", alamatUser);
|
||||
i.putExtra("penumpang", penumpang);
|
||||
startActivity(i);
|
||||
}
|
||||
else {
|
||||
if (etAlamatTujuan.getText().toString().trim().isEmpty()) {
|
||||
etAlamatTujuan.setText("silahkan isi detail alamat tujuan");
|
||||
} else {
|
||||
if (Objects.equals(lat_tujuan, "") && Objects.equals(lng_tujuan, "")){
|
||||
Toast.makeText(this, "LatLngTujuan tidak ditemukan", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
startPayment(lat_tujuan, lng_tujuan);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onBindView(){
|
||||
tvAsal = findViewById(R.id.asal);
|
||||
tvTujuan = findViewById(R.id.Tujuan);
|
||||
tvWaktu = findViewById(R.id.waktu);
|
||||
tvTanggal = findViewById(R.id.date);
|
||||
tvPenumpang = findViewById(R.id.txtJumlahPenumpang);
|
||||
tvNama = findViewById(R.id.txtpenumpang);
|
||||
tvTotal = findViewById(R.id.tvTotal);
|
||||
etAlamatTujuan = findViewById(R.id.et_alamat);
|
||||
btnLokasi = findViewById(R.id.btnCurrentLoc);
|
||||
btnLokasiMaps = findViewById(R.id.maps);
|
||||
btnBayar = findViewById(R.id.bayarsekarang);
|
||||
btnBack = findViewById(R.id.backtodetailpemesanan);
|
||||
et_alamat = findViewById(R.id.et_alamat);
|
||||
// btnMapsTujuan = findViewById(R.id.mapsTujuan);
|
||||
}
|
||||
private void getIntentData(Intent intent){
|
||||
if (intent.getExtras() != null) {
|
||||
tiketData = (TiketData) intent.getSerializableExtra("tiket");
|
||||
idPerjalanan = tiketData.getId();
|
||||
asal = tiketData.getAsal();
|
||||
tujuan = tiketData.getTujuan();
|
||||
waktu = tiketData.getWaktu();
|
||||
tanggal = tiketData.getTanggal();
|
||||
hargaDouble = tiketData.getHarga();
|
||||
|
||||
idUser = intent.getStringExtra("id_user");
|
||||
namaUser = intent.getStringExtra("nama_user");
|
||||
emailUser = intent.getStringExtra("email_user");
|
||||
telpUser = intent.getStringExtra("telp_user");
|
||||
alamatUser = intent.getStringExtra("alamat_user");
|
||||
penumpang = intent.getStringExtra("penumpang");
|
||||
alamat_tujuan = intent.getStringExtra("alamat_tujuan");
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd MMMM yyyy");
|
||||
|
||||
String tanggalFormatted = sdf.format(tanggal);
|
||||
tvAsal.setText(asal);
|
||||
tvWaktu.setText(waktu);
|
||||
tvTanggal.setText(tanggalFormatted);
|
||||
tvTujuan.setText(tujuan);
|
||||
int penumpangInt = Integer.parseInt(penumpang);
|
||||
totalHarga = hargaDouble * penumpangInt;
|
||||
tvTotal.setText(String.valueOf(totalHarga));
|
||||
tvNama.setText(namaUser);
|
||||
tvPenumpang.setText(penumpang);
|
||||
et_alamat.setText(alamat_tujuan);
|
||||
|
||||
// String latJemputCurrent = intent.getStringExtra("lat_jemput_f");
|
||||
// String lngJemputCurrent = intent.getStringExtra("lng_jemput_f");
|
||||
String latJemputMaps = intent.getStringExtra("lat_tujuan");
|
||||
String lngJemputMaps = intent.getStringExtra("lng_tujuan");
|
||||
// if (latJemputCurrent != null && lngJemputCurrent != null ) {
|
||||
// lat_jemput = latJemputCurrent;
|
||||
// lng_jemput = lngJemputCurrent;
|
||||
// Log.e("latJemput:" , latJemputCurrent);
|
||||
// Log.e("lngJemput:" , lngJemputCurrent);
|
||||
// } else {
|
||||
// Log.e("ltlngJemput:" , "gada");
|
||||
// }
|
||||
if (latJemputMaps != null && lngJemputMaps != null ) {
|
||||
lat_tujuan = latJemputMaps;
|
||||
lng_tujuan = lngJemputMaps;
|
||||
Log.e("latTujuan:" , latJemputMaps);
|
||||
Log.e("lngTUjuan:" , lngJemputMaps);
|
||||
} else {
|
||||
Log.e("ltlngTujuan:" , "gada");
|
||||
}
|
||||
|
||||
// lat_tujuan = intent.getStringExtra("lat_tujuan");
|
||||
// lng_tujuan = intent.getStringExtra("lng_tujuan");
|
||||
}
|
||||
}
|
||||
|
||||
private void setLocaleNew(String languageCode) {
|
||||
LocaleListCompat locales = LocaleListCompat.forLanguageTags(languageCode);
|
||||
AppCompatDelegate.setApplicationLocales(locales);
|
||||
}
|
||||
|
||||
private void buildUiKit() {
|
||||
String CLIENT_KEY = "SB-Mid-client-M2wdn0pfhe0Wld-l";
|
||||
String MERCHANT_URL = "https://hallomomswebsite.000webhostapp.com/midtrans.php/";
|
||||
new UiKitApi.Builder()
|
||||
.withContext(PaymentMidtransActivity.this)
|
||||
.withMerchantUrl(MERCHANT_URL)
|
||||
.withMerchantClientKey(CLIENT_KEY)
|
||||
.enableLog(true)
|
||||
.withColorTheme(new CustomColorTheme("#1e3d59", "#B61548", "#1e3d59"))
|
||||
.build();
|
||||
setLocaleNew("id");
|
||||
}
|
||||
|
||||
private final ActivityResultLauncher<Intent> launcher = registerForActivityResult(
|
||||
new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if (result.getResultCode() == RESULT_OK && result.getData() != null) {
|
||||
TransactionResult transactionResult = result.getData()
|
||||
.getParcelableExtra(UiKitConstants.KEY_TRANSACTION_RESULT);
|
||||
if (transactionResult != null) {
|
||||
switch (transactionResult.getStatus()) {
|
||||
case UiKitConstants.STATUS_SUCCESS:
|
||||
Toast.makeText(this, "Transaction Finished. ID: " +
|
||||
transactionResult.getTransactionId(), Toast.LENGTH_LONG).show();
|
||||
Intent intent = new Intent(PaymentMidtransActivity.this, HomeActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
ApiServices.status(PaymentMidtransActivity.this, idOrder, "Berhasil", new ApiServices.AddLatlongResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String message) {
|
||||
Log.e("status", message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Log.e("status", message);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case UiKitConstants.STATUS_PENDING:
|
||||
Toast.makeText(this, "Transaction Pending. ID: " +
|
||||
transactionResult.getTransactionId(), Toast.LENGTH_LONG).show();
|
||||
Intent i = new Intent(PaymentMidtransActivity.this, HomeActivity.class);
|
||||
startActivity(i);
|
||||
finish();
|
||||
break;
|
||||
case UiKitConstants.STATUS_FAILED:
|
||||
Toast.makeText(this, "Transaction Failed. ID: " +
|
||||
transactionResult.getTransactionId(), Toast.LENGTH_LONG).show();
|
||||
Intent intent1 = new Intent(PaymentMidtransActivity.this, HomeActivity.class);
|
||||
startActivity(intent1);
|
||||
finish();
|
||||
ApiServices.status(PaymentMidtransActivity.this, idOrder, "Gagal", new ApiServices.AddLatlongResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String message) {
|
||||
Log.e("status", message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Log.e("status", message);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case UiKitConstants.STATUS_CANCELED:
|
||||
Toast.makeText(this, "Transaction Cancelled", Toast.LENGTH_LONG).show();
|
||||
Intent intent2 = new Intent(PaymentMidtransActivity.this, HomeActivity.class);
|
||||
startActivity(intent2);
|
||||
finish();
|
||||
ApiServices.status(PaymentMidtransActivity.this, idOrder, "Gagal", new ApiServices.AddLatlongResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String message) {
|
||||
Log.e("statuspesan", "cancel");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Log.e("statuspesan", message);
|
||||
|
||||
}
|
||||
});
|
||||
break;
|
||||
case UiKitConstants.STATUS_INVALID:
|
||||
Toast.makeText(this, "Transaction Invalid. ID: " +
|
||||
transactionResult.getTransactionId(), Toast.LENGTH_LONG).show();
|
||||
Intent intent3 = new Intent(PaymentMidtransActivity.this, HomeActivity.class);
|
||||
startActivity(intent3);
|
||||
finish();
|
||||
break;
|
||||
default:
|
||||
Toast.makeText(this, "Transaction ID: " +
|
||||
transactionResult.getTransactionId() + ". Message: " +
|
||||
transactionResult.getStatus(), Toast.LENGTH_LONG).show();
|
||||
Intent intent4 = new Intent(PaymentMidtransActivity.this, HomeActivity.class);
|
||||
startActivity(intent4);
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(this, "Transaction Invalid", Toast.LENGTH_LONG).show();
|
||||
Intent intent = new Intent(PaymentMidtransActivity.this, HomeActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
private CustomerDetails initCustomerDetails() {
|
||||
Address shippingAddress = new Address(
|
||||
null,
|
||||
null,
|
||||
"Jalan Andalas Gang Sebelah No. 1",
|
||||
"Jakarta",
|
||||
"10220",
|
||||
null,
|
||||
null
|
||||
);
|
||||
Address billingAddress = new Address(
|
||||
null,
|
||||
null,
|
||||
"Jalan Andalas Gang Sebelah No. 1",
|
||||
"Jakarta",
|
||||
"10220",
|
||||
null,
|
||||
null
|
||||
);
|
||||
CustomerDetails mCustomerDetails = new CustomerDetails(
|
||||
emailUser, namaUser, namaUser, emailUser, telpUser, shippingAddress, shippingAddress
|
||||
);
|
||||
return mCustomerDetails;
|
||||
}
|
||||
|
||||
private List<ItemDetails> initItemDetails(){
|
||||
ItemDetails itemDetails = new ItemDetails(idPerjalanan, hargaDouble, Integer.parseInt(penumpang), asal + tujuan);
|
||||
List<ItemDetails> itemDetailsList = new ArrayList<>();
|
||||
itemDetailsList.add(itemDetails);
|
||||
return itemDetailsList;
|
||||
}
|
||||
|
||||
private SnapTransactionDetail initTransactionDetails() {
|
||||
String orderId = "PETTA-Express-";
|
||||
return new SnapTransactionDetail(
|
||||
idOrder,
|
||||
totalHarga, "IDR"
|
||||
);
|
||||
}
|
||||
private CreditCard initCreditCard(){
|
||||
CreditCard creditCard = new CreditCard(
|
||||
false,
|
||||
null,
|
||||
Authentication.AUTH_3DS,
|
||||
CreditCard.MIGS,
|
||||
BankType.MANDIRI,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
return creditCard;
|
||||
}
|
||||
|
||||
private Expiry initExpiry(){
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
Date currentDate = new Date(currentTimeMillis);
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z", Locale.getDefault());
|
||||
dateFormat.setTimeZone(TimeZone.getDefault());
|
||||
String currentTimeString = dateFormat.format(currentDate);
|
||||
Expiry expiry = new Expiry(currentTimeString, Expiry.Companion.getUNIT_HOUR(), 1);
|
||||
return expiry;
|
||||
}
|
||||
private String getAddressFromLocation(double latitude, double longitude) {
|
||||
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
|
||||
try {
|
||||
List<android.location.Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);
|
||||
if (addresses != null && addresses.size() > 0) {
|
||||
android.location.Address address = addresses.get(0);
|
||||
String addressLine = address.getAddressLine(0);
|
||||
return addressLine;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void startPayment(String latTujuan, String lngTujuan){
|
||||
idOrder = "PETTA-Express-" + UUID.randomUUID().toString();
|
||||
SharedPreferences preferences = PaymentMidtransActivity.this.getSharedPreferences("myPrefs", MODE_PRIVATE);
|
||||
String token = preferences.getString("token", "");
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String tanggalFormatted = sdf.format(tanggal);
|
||||
ApiServices.checkLatlong(PaymentMidtransActivity.this, token, new ApiServices.CheckLatlongResponseListener() {
|
||||
@Override
|
||||
public void onResult(boolean success, double latitude, double longitude) {
|
||||
String alamatJemput = getAddressFromLocation(latitude, longitude);
|
||||
String alamatTujuan = etAlamatTujuan.getText().toString().trim();
|
||||
ApiServices.pemesanan(PaymentMidtransActivity.this, idUser, idPerjalanan, penumpang, idOrder, alamatJemput, alamatTujuan, waktu, "Menunggu", tanggalFormatted, String.valueOf(totalHarga), latTujuan,lngTujuan, new ApiServices.PemesananResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String message) {
|
||||
UiKitApi.Companion.getDefaultInstance().startPaymentUiFlow(
|
||||
PaymentMidtransActivity.this,
|
||||
launcher,
|
||||
initTransactionDetails(),
|
||||
initCustomerDetails(),
|
||||
initItemDetails(),
|
||||
initCreditCard(),
|
||||
idUser,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
initExpiry(),
|
||||
PaymentMethod.BANK_TRANSFER,
|
||||
Arrays.asList(PaymentType.BANK_TRANSFER),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"Cash1",
|
||||
"Debit2",
|
||||
"Credit3"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Toast.makeText(PaymentMidtransActivity.this, "Gagal melakukan pemesanan" + message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Log.e("Error", "Gagal mendapatkan alamat, " + message);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
package com.example.travelapps.pelanggan;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.AppCompatButton;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.travelapps.Model.TiketData;
|
||||
import com.example.travelapps.Model.User;
|
||||
import com.example.travelapps.R;
|
||||
import com.example.travelapps.Services.ApiServices;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class PesanActivity extends AppCompatActivity {
|
||||
|
||||
TiketData tiketData;
|
||||
String id = "";
|
||||
String asal = "";
|
||||
String tujuan = "";
|
||||
Date tanggal;
|
||||
String waktu = "";
|
||||
String harga = "";
|
||||
String status = "";
|
||||
Double hargaDouble;
|
||||
String penumpang = "";
|
||||
String idUser = "";
|
||||
String nik = "";
|
||||
String namaUser = "";
|
||||
String emailUser = "";
|
||||
String alamatUser = "";
|
||||
String notelpUser = "";
|
||||
String jumlahPenumpang = "";
|
||||
String tanggalFormatted = "";
|
||||
|
||||
TextView tvDate, tvAsal, tvWaktu, tvTujuan, tvNamaUser, tvEmailUser, tvNotelpUser, tvPenumpang, tvNik;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_pesan);
|
||||
|
||||
SharedPreferences preferences = PesanActivity.this.getSharedPreferences("myPrefs", MODE_PRIVATE);
|
||||
String token = preferences.getString("token", "");
|
||||
|
||||
ImageButton backButton = findViewById(R.id.backtotiket);
|
||||
backButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onBackPressed();
|
||||
}
|
||||
});
|
||||
|
||||
ApiServices.getUserData(this, token, new ApiServices.UserResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(User user) {
|
||||
idUser = user.getId();
|
||||
namaUser = user.getNama();
|
||||
notelpUser = user.getNotelp();
|
||||
emailUser = user.getEmail();
|
||||
alamatUser = user.getAlamat();
|
||||
nik = user.getNik();
|
||||
|
||||
tvNamaUser.setText(namaUser);
|
||||
tvNotelpUser.setText(notelpUser);
|
||||
tvEmailUser.setText(emailUser);
|
||||
tvNik.setText(nik);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Log.e("Error", "Gagal mendapatkan data user");
|
||||
}
|
||||
});
|
||||
|
||||
tvDate = findViewById(R.id.date);
|
||||
tvAsal = findViewById(R.id.asal);
|
||||
tvWaktu = findViewById(R.id.waktu);
|
||||
tvTujuan = findViewById(R.id.Tujuan);
|
||||
tvPenumpang = findViewById(R.id.txtPenumpang);
|
||||
tvNamaUser = findViewById(R.id.txtNama);
|
||||
tvEmailUser = findViewById(R.id.txtEmail);
|
||||
tvNotelpUser = findViewById(R.id.txtNoTelp);
|
||||
tvNik = findViewById(R.id.txtNik);
|
||||
|
||||
Intent intent = getIntent();
|
||||
if (intent.getExtras() != null){
|
||||
tiketData = (TiketData) intent.getSerializableExtra("tiket_data");
|
||||
id = tiketData.getId();
|
||||
asal = tiketData.getAsal();
|
||||
tujuan = tiketData.getTujuan();
|
||||
tanggal = tiketData.getTanggal();
|
||||
waktu = tiketData.getWaktu();
|
||||
jumlahPenumpang = tiketData.getJumlahPenumpang();
|
||||
hargaDouble = tiketData.getHarga();
|
||||
String hargaString = String.format("Rp %.2f", tiketData.getHarga());
|
||||
harga = hargaString;
|
||||
penumpang = intent.getStringExtra("penumpang");
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd MMMM yyyy");
|
||||
|
||||
tanggalFormatted = sdf.format(tanggal);
|
||||
|
||||
tvDate.setText(tanggalFormatted);
|
||||
tvAsal.setText(asal);
|
||||
tvWaktu.setText(waktu);
|
||||
tvTujuan.setText(tujuan);
|
||||
tvPenumpang.setText(penumpang);
|
||||
AppCompatButton selanjutnyaButton = findViewById(R.id.selanjutnyapilihkursi);
|
||||
|
||||
selanjutnyaButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int jumlahPenumpangInt = Integer.parseInt(jumlahPenumpang);
|
||||
int penumpangInt = Integer.parseInt(penumpang);
|
||||
|
||||
if (jumlahPenumpangInt < penumpangInt) {
|
||||
Toast.makeText(PesanActivity.this, "Jumlah penumpang tidak mencukupi", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Intent intent = new Intent(PesanActivity.this, PaymentMidtransActivity.class);
|
||||
TiketData tiketData = new TiketData(id, asal, tujuan, tanggal, waktu, hargaDouble, jumlahPenumpang, status);
|
||||
intent.putExtra("tiket", tiketData);
|
||||
intent.putExtra("id_user", idUser);
|
||||
intent.putExtra("nama_user", namaUser);
|
||||
intent.putExtra("nik_user", nik);
|
||||
intent.putExtra("email_user", emailUser);
|
||||
intent.putExtra("telp_user", notelpUser);
|
||||
intent.putExtra("alamat_user", alamatUser);
|
||||
intent.putExtra("penumpang", penumpang);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,143 @@
|
|||
package com.example.travelapps.pelanggan;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.AppCompatButton;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.travelapps.Model.Sopir;
|
||||
import com.example.travelapps.Model.User;
|
||||
import com.example.travelapps.R;
|
||||
import com.example.travelapps.Services.ApiServices;
|
||||
import com.example.travelapps.sopir.ApiServicesSopir;
|
||||
import com.example.travelapps.sopir.HomeSopirActivity;
|
||||
|
||||
public class ProfileActivity extends AppCompatActivity {
|
||||
|
||||
EditText etNama, etEmail, etTelp, etAlamat, etUsername, etSim, etNik;
|
||||
AppCompatButton btnSimpan;
|
||||
TextView tvUsername, tvEmail, tvSim, tvNik;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_profile);
|
||||
onBindView();
|
||||
Intent i = getIntent();
|
||||
String role = i.getStringExtra("role");
|
||||
SharedPreferences preferences = ProfileActivity.this.getSharedPreferences("myPrefs", MODE_PRIVATE);
|
||||
String token = preferences.getString("token", "");
|
||||
String id = preferences.getString("id", "");
|
||||
if (role.equals("sopir")) {
|
||||
tvEmail.setVisibility(View.GONE);
|
||||
etEmail.setVisibility(View.GONE);
|
||||
tvNik.setVisibility(View.GONE);
|
||||
etNik.setVisibility(View.GONE);
|
||||
ApiServicesSopir.getSopirData(this, id, new ApiServicesSopir.SopirResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(Sopir sopir) {
|
||||
TextView tvname = findViewById(R.id.userName);
|
||||
tvname.setText(sopir.getNamaLengkap());
|
||||
TextView tvNickname = findViewById(R.id.profileImage);
|
||||
String twoInitials = sopir.getNamaLengkap().substring(0, 2);
|
||||
twoInitials = twoInitials.toUpperCase();
|
||||
tvNickname.setText(twoInitials);
|
||||
etNama.setText(sopir.getNamaLengkap());
|
||||
etUsername.setText(sopir.getUsername());
|
||||
etTelp.setText(sopir.getNoTelp());
|
||||
etAlamat.setText(sopir.getAlamat());
|
||||
etSim.setText(sopir.getNoSim());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
|
||||
}
|
||||
});
|
||||
btnSimpan.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String nama = etNama.getText().toString().trim();
|
||||
String username = etUsername.getText().toString().trim();
|
||||
String telp = etTelp.getText().toString().trim();
|
||||
String sim = etSim.getText().toString().trim();
|
||||
String alamat = etAlamat.getText().toString().trim();
|
||||
ApiServicesSopir.updateUser(ProfileActivity.this, id, nama, sim, telp, username, alamat, new ApiServices.UpdateUserResponseListener() {
|
||||
@Override
|
||||
public void onUpdateUserResponse(boolean success, String message) {
|
||||
Intent intent = new Intent(ProfileActivity.this, HomeSopirActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
Toast.makeText(ProfileActivity.this, message, Toast.LENGTH_SHORT).show();
|
||||
Log.e("error", message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
tvUsername.setVisibility(View.GONE);
|
||||
etUsername.setVisibility(View.GONE);
|
||||
tvSim.setVisibility(View.GONE);
|
||||
etSim.setVisibility(View.GONE);
|
||||
ApiServices.getUserData(this, token, new ApiServices.UserResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(User user) {
|
||||
TextView tvname = findViewById(R.id.userName);
|
||||
tvname.setText(user.getNama());
|
||||
TextView tvNickname = findViewById(R.id.profileImage);
|
||||
String twoInitials = user.getNama().substring(0, 2);
|
||||
twoInitials = twoInitials.toUpperCase();
|
||||
tvNickname.setText(twoInitials);
|
||||
etNama.setText(user.getNama());
|
||||
etEmail.setText(user.getEmail());
|
||||
etTelp.setText(user.getNotelp());
|
||||
etAlamat.setText(user.getAlamat());
|
||||
etNik.setText(user.getNik());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
|
||||
}
|
||||
});
|
||||
btnSimpan.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
ApiServices.updateUser(ProfileActivity.this, token, etNama.getText().toString().trim(), etTelp.getText().toString().trim(), etEmail.getText().toString().trim(), etAlamat.getText().toString().trim(), etNik.getText().toString().trim(), new ApiServices.UpdateUserResponseListener() {
|
||||
@Override
|
||||
public void onUpdateUserResponse(boolean success, String message) {
|
||||
Intent intent = new Intent(ProfileActivity.this, HomeActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
Toast.makeText(ProfileActivity.this, message, Toast.LENGTH_SHORT).show();
|
||||
Log.e("error", message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void onBindView() {
|
||||
etNama = findViewById(R.id.et_nama);
|
||||
etEmail = findViewById(R.id.et_email);
|
||||
etTelp = findViewById(R.id.et_notelp);
|
||||
etAlamat = findViewById(R.id.et_alamat);
|
||||
etUsername = findViewById(R.id.et_username);
|
||||
etSim = findViewById(R.id.et_sim);
|
||||
tvNik = findViewById(R.id.tv_nik);
|
||||
etNik = findViewById(R.id.et_nik);
|
||||
tvEmail = findViewById(R.id.tv_email);
|
||||
tvSim = findViewById(R.id.tv_sim);
|
||||
tvUsername = findViewById(R.id.tv_username);
|
||||
btnSimpan = findViewById(R.id.btn_simpan);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package com.example.travelapps.pelanggan;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.travelapps.Adapter.OnItemTiketClickListener;
|
||||
import com.example.travelapps.Adapter.TiketAdapter;
|
||||
import com.example.travelapps.Model.Perjalanan;
|
||||
import com.example.travelapps.Model.TiketData;
|
||||
import com.example.travelapps.Services.ApiServices;
|
||||
import com.example.travelapps.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TiketActivity extends AppCompatActivity implements OnItemTiketClickListener {
|
||||
private RecyclerView recyclerView;
|
||||
private TiketAdapter adapter;
|
||||
String kotaAsal;
|
||||
String kotaTujuan;
|
||||
String penumpang;
|
||||
String tanggal;
|
||||
Perjalanan perjalanan;
|
||||
TextView tvNull;
|
||||
ImageView ivBack;
|
||||
@SuppressLint("MissingInflatedId")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_tiket);
|
||||
|
||||
recyclerView = findViewById(R.id.recyclerView);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
tvNull = findViewById(R.id.tvNull);
|
||||
ivBack = findViewById(R.id.backtohome);
|
||||
Intent intent = getIntent();
|
||||
if (intent.getExtras() != null) {
|
||||
kotaAsal = intent.getStringExtra("asal");
|
||||
kotaTujuan = intent.getStringExtra("tujuan");
|
||||
penumpang = intent.getStringExtra("penumpang");
|
||||
tanggal = intent.getStringExtra("tanggal");
|
||||
|
||||
Log.e("intent", kotaAsal + kotaTujuan + penumpang);
|
||||
}
|
||||
|
||||
ApiServices.showPerjalanan(this, kotaAsal, kotaTujuan, tanggal, new ApiServices.PerjalananResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(List<TiketData> tiketData) {
|
||||
if (tiketData.isEmpty()) {
|
||||
tvNull.setText("Tidak ada tiket perjalanan");
|
||||
}
|
||||
adapter = new TiketAdapter(TiketActivity.this, tiketData, TiketActivity.this, penumpang);
|
||||
recyclerView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
if (message.equals("Tidak ada tiket perjalanan")) {
|
||||
tvNull.setText("Tidak ada tiket perjalanan");
|
||||
}
|
||||
Log.e("Gagal mendapatkan data", message);
|
||||
}
|
||||
});
|
||||
}
|
||||
public String getPenumpang() {
|
||||
return penumpang;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(TiketData tiketData) {
|
||||
Intent intent = new Intent(TiketActivity.this, PesanActivity.class);
|
||||
intent.putExtra("tiket_data", tiketData);
|
||||
intent.putExtra("penumpang", penumpang);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,571 @@
|
|||
package com.example.travelapps.sopir;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.volley.AuthFailureError;
|
||||
import com.android.volley.Request;
|
||||
import com.android.volley.RequestQueue;
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.android.volley.toolbox.StringRequest;
|
||||
import com.android.volley.toolbox.Volley;
|
||||
import com.example.travelapps.Model.PemesananSopir;
|
||||
import com.example.travelapps.Model.Sopir;
|
||||
import com.example.travelapps.Model.TiketData;
|
||||
import com.example.travelapps.Model.TiketSopir;
|
||||
import com.example.travelapps.Model.User;
|
||||
import com.example.travelapps.Services.ApiServices;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ApiServicesSopir {
|
||||
|
||||
public interface PerjalananResponseListener {
|
||||
void onSuccess(List<PemesananSopir> pemesananSopir);
|
||||
void onError(String message);
|
||||
}
|
||||
public interface PerjalananNowResponseListener {
|
||||
void onSuccess(List<TiketData> tiketDataList);
|
||||
void onError(String message);
|
||||
}
|
||||
public interface TiketSopirResponseListener {
|
||||
void onSuccess(List<TiketSopir> tiketDataList);
|
||||
void onError(String message);
|
||||
}
|
||||
|
||||
|
||||
public interface UpdateStatusResponseListener {
|
||||
void onSuccess(String message);
|
||||
void onError(String message);
|
||||
}
|
||||
|
||||
public interface SopirResponseListener{
|
||||
void onSuccess(Sopir sopir);
|
||||
void onError(String message);
|
||||
}
|
||||
|
||||
public static void login(Context context, String username, String pass, ApiServices.LoginResponseListener listener) {
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.POST, ApiServices.getHOST() + "login_sopir.php", new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
Log.e("Response", response);
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(response);
|
||||
String message = jsonObject.getString("message");
|
||||
Boolean success = jsonObject.getBoolean("success");
|
||||
if (message.equals("Berhasil Login")){
|
||||
JSONObject userObject = jsonObject.getJSONObject("user");
|
||||
String id = userObject.getString("id_sopir");
|
||||
SharedPreferences.Editor editor = context.getSharedPreferences("myPrefs", MODE_PRIVATE).edit();
|
||||
editor.putBoolean("isLoginSopir", true);
|
||||
editor.putString("id", id);
|
||||
editor.apply();
|
||||
listener.onSuccess(message);
|
||||
} else if (success.equals(false)) {
|
||||
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} catch (JSONException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener(){
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
if (error.networkResponse != null && error.networkResponse.data != null) {
|
||||
try {
|
||||
int statusCode = error.networkResponse.statusCode;
|
||||
String responseBody = new String(error.networkResponse.data, "utf-8");
|
||||
if (statusCode == 401) {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(responseBody);
|
||||
String message = jsonObject.getString("message");
|
||||
if (message.equals("Username dan Password Salah")) {
|
||||
listener.onError("Username / password anda salah");
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
listener.onError("Gagal Login: " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else{
|
||||
listener.onError("Gagal Login: network response is null");
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
{
|
||||
@Override
|
||||
protected Map<String, String> getParams() throws AuthFailureError {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("username", username);
|
||||
params.put("password", pass);
|
||||
return params;
|
||||
}
|
||||
};
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
public static void register(Context context, String nama_lengkap, String username, String password, String no_SIM, String notelp, String alamat, ApiServices.RegisterResponseListener listener) {
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.POST, ApiServices.getHOST() + "register_sopir.php", new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
Log.e("Response", response);
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(response);
|
||||
boolean success = jsonObject.getBoolean("success");
|
||||
if (success) {
|
||||
listener.onSuccess("Registrasi berhasil");
|
||||
} else {
|
||||
String error = jsonObject.getString("error");
|
||||
listener.onError(error);
|
||||
}
|
||||
} catch (JSONException e){
|
||||
e.printStackTrace();
|
||||
listener.onError("Gagal melakukan registrasi: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener(){
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
listener.onError("Gagal melakukan registrasi: " + error.getMessage());
|
||||
}
|
||||
})
|
||||
{
|
||||
@Override
|
||||
protected Map<String, String> getParams() throws AuthFailureError {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("nama_lengkap", nama_lengkap);
|
||||
params.put("username", username);
|
||||
params.put("password", password);
|
||||
params.put("no_SIM", no_SIM);
|
||||
params.put("notelp", notelp);
|
||||
params.put("alamat", alamat);
|
||||
return params;
|
||||
}
|
||||
};
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
public static void getPenumpangSopir(Context context, String idSopir,String id_perjalanan, PerjalananResponseListener listener) {
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.POST, ApiServices.getHOST() + "getperjalanansopir.php", new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
Log.e("Response", response);
|
||||
try {
|
||||
JSONArray jsonArray = new JSONArray(response);
|
||||
List<PemesananSopir> pemesananSopirList = new ArrayList<>();
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String idPemesanan = jsonObject.getString("id_pemesanan");
|
||||
String idUser = jsonObject.getString("id_user");
|
||||
String idPerjalanan = jsonObject.getString("id_perjalanan");
|
||||
String orderId = jsonObject.getString("order_id");
|
||||
String alamatJemput = jsonObject.getString("alamat_jemput");
|
||||
String alamatTujuan = jsonObject.getString("alamat_tujuan");
|
||||
String waktuJemput = jsonObject.getString("waktu_jemput");
|
||||
String status = jsonObject.getString("status");
|
||||
String tanggalPesan = jsonObject.getString("tanggal_pesan");
|
||||
String tanggalBerangkat = jsonObject.getString("tanggal_berangkat");
|
||||
String qty = jsonObject.getString("qty");
|
||||
String harga = jsonObject.getString("harga");
|
||||
String namaLengkap = jsonObject.getString("nama_lengkap");
|
||||
String username = jsonObject.getString("username");
|
||||
String notelp = jsonObject.getString("notelp");
|
||||
String email = jsonObject.getString("email");
|
||||
String alamat = jsonObject.getString("alamat");
|
||||
String idRole = jsonObject.getString("id_role");
|
||||
String password = jsonObject.getString("password");
|
||||
String latitude = jsonObject.getString("latitude");
|
||||
String longitude = jsonObject.getString("longitude");
|
||||
String token = jsonObject.getString("token");
|
||||
String kotaAsal = jsonObject.getString("kota_asal");
|
||||
String kotaTujuan = jsonObject.getString("kota_tujuan");
|
||||
String tanggal = jsonObject.getString("tanggal");
|
||||
String waktuKeberangkatan = jsonObject.getString("waktu_keberangkatan");
|
||||
String jumlahPenumpang = jsonObject.getString("jumlah_penumpang");
|
||||
String idSopir = jsonObject.getString("id_sopir");
|
||||
String idmobil = jsonObject.getString("mobil_id");
|
||||
String latTujuan = jsonObject.getString("lat_tujuan");
|
||||
String lngTujuan = jsonObject.getString("lng_tujuan");
|
||||
String jemput = jsonObject.getString("status_penjemputan");
|
||||
String antar = jsonObject.getString("status_antar");
|
||||
|
||||
PemesananSopir pemesananSopir = new PemesananSopir(idPemesanan, idUser, idPerjalanan, orderId, alamatJemput, alamatTujuan, waktuJemput, status, tanggalPesan, tanggalBerangkat, qty, harga, namaLengkap, username, notelp, email, alamat, idRole, password, latitude, longitude, token, kotaAsal, kotaTujuan, tanggal, waktuKeberangkatan, jumlahPenumpang, idSopir, idmobil, latTujuan, lngTujuan, jemput, antar);
|
||||
pemesananSopirList.add(pemesananSopir);
|
||||
}
|
||||
listener.onSuccess(pemesananSopirList);
|
||||
} catch (JSONException e){
|
||||
e.printStackTrace();
|
||||
listener.onError("Failed to parse response: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener(){
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
listener.onError("Failed to retrieve data: " + error.getMessage());
|
||||
}
|
||||
})
|
||||
{
|
||||
@Override
|
||||
protected Map<String, String> getParams() throws AuthFailureError {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("id_sopir", idSopir);
|
||||
params.put("id_perjalanan", id_perjalanan);
|
||||
return params;
|
||||
}
|
||||
};
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
public static void getPenumpangSopirActive(Context context, String idSopir,String id_perjalanan, PerjalananResponseListener listener) {
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.POST, ApiServices.getHOST() + "getperjalanansopiractive.php", new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
Log.e("Response", response);
|
||||
try {
|
||||
JSONObject jsonResponse = new JSONObject(response);
|
||||
String message = jsonResponse.getString("message");
|
||||
if (message.equals("ok")) {
|
||||
JSONArray jsonArray = jsonResponse.getJSONArray("data");
|
||||
List<PemesananSopir> pemesananSopirList = new ArrayList<>();
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String idPemesanan = jsonObject.getString("id_pemesanan");
|
||||
String idUser = jsonObject.getString("id_user");
|
||||
String idPerjalanan = jsonObject.getString("id_perjalanan");
|
||||
String orderId = jsonObject.getString("order_id");
|
||||
String alamatJemput = jsonObject.getString("alamat_jemput");
|
||||
String alamatTujuan = jsonObject.getString("alamat_tujuan");
|
||||
String waktuJemput = jsonObject.getString("waktu_jemput");
|
||||
String status = jsonObject.getString("status");
|
||||
String tanggalPesan = jsonObject.getString("tanggal_pesan");
|
||||
String tanggalBerangkat = jsonObject.getString("tanggal_berangkat");
|
||||
String qty = jsonObject.getString("qty");
|
||||
String harga = jsonObject.getString("harga");
|
||||
String namaLengkap = jsonObject.getString("nama_lengkap");
|
||||
String username = jsonObject.getString("username");
|
||||
String notelp = jsonObject.getString("notelp");
|
||||
String email = jsonObject.getString("email");
|
||||
String alamat = jsonObject.getString("alamat");
|
||||
String idRole = jsonObject.getString("id_role");
|
||||
String password = jsonObject.getString("password");
|
||||
String latitude = jsonObject.getString("latitude");
|
||||
String longitude = jsonObject.getString("longitude");
|
||||
String token = jsonObject.getString("token");
|
||||
String kotaAsal = jsonObject.getString("kota_asal");
|
||||
String kotaTujuan = jsonObject.getString("kota_tujuan");
|
||||
String tanggal = jsonObject.getString("tanggal");
|
||||
String waktuKeberangkatan = jsonObject.getString("waktu_keberangkatan");
|
||||
String jumlahPenumpang = jsonObject.getString("jumlah_penumpang");
|
||||
String idSopir = jsonObject.getString("id_sopir");
|
||||
String idmobil = jsonObject.getString("mobil_id");
|
||||
String latTujuan = jsonObject.getString("lat_tujuan");
|
||||
String lngTujuan = jsonObject.getString("lng_tujuan");
|
||||
String jemput = jsonObject.getString("status_penjemputan");
|
||||
String antar = jsonObject.getString("status_antar");
|
||||
|
||||
|
||||
|
||||
PemesananSopir pemesananSopir = new PemesananSopir(idPemesanan, idUser, idPerjalanan, orderId, alamatJemput, alamatTujuan, waktuJemput, status, tanggalPesan, tanggalBerangkat, qty, harga, namaLengkap, username, notelp, email, alamat, idRole, password, latitude, longitude, token, kotaAsal, kotaTujuan, tanggal, waktuKeberangkatan, jumlahPenumpang, idSopir, idmobil, latTujuan, lngTujuan, jemput, antar);
|
||||
pemesananSopirList.add(pemesananSopir);
|
||||
}
|
||||
listener.onSuccess(pemesananSopirList);
|
||||
} else if(message.equals("Data tidak ditemukan")) {
|
||||
listener.onError("Data tidak ditemukan");
|
||||
}
|
||||
} catch (JSONException e){
|
||||
e.printStackTrace();
|
||||
listener.onError("Failed to parse response: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener(){
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
listener.onError("Failed to retrieve data: " + error.getMessage());
|
||||
}
|
||||
})
|
||||
{
|
||||
@Override
|
||||
protected Map<String, String> getParams() throws AuthFailureError {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("id_sopir", idSopir);
|
||||
params.put("id_perjalanan", id_perjalanan);
|
||||
return params;
|
||||
}
|
||||
};
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
public static void getPerjalananSopirNow(Context context, String idSopir, PerjalananNowResponseListener listener) {
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.GET, ApiServices.getHOST() + "getdaftar.php?id_sopir=" + idSopir, new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
Log.e("Response", response);
|
||||
try {
|
||||
JSONArray jsonArray = new JSONArray(response);
|
||||
List<TiketData> tiketDataList = new ArrayList<>();
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String idPerjalanan = jsonObject.getString("id_perjalanan");
|
||||
String kotaAsal = jsonObject.getString("kota_asal");
|
||||
String kotaTujuan = jsonObject.getString("kota_tujuan");
|
||||
String tanggalPerjalanan = jsonObject.getString("tanggal");
|
||||
String waktuKeberangkatan = jsonObject.getString("waktu_keberangkatan");
|
||||
double harga = jsonObject.getDouble("harga");
|
||||
String status = jsonObject.getString("status");
|
||||
String jumlahPenumpang = jsonObject.getString("jumlah_penumpang");
|
||||
Date ntanggal;
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
try {
|
||||
ntanggal = sdf.parse(tanggalPerjalanan);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
TiketData tiketData = new TiketData(idPerjalanan, kotaAsal, kotaTujuan, ntanggal, waktuKeberangkatan, harga, jumlahPenumpang, status);
|
||||
tiketDataList.add(tiketData);
|
||||
}
|
||||
listener.onSuccess(tiketDataList);
|
||||
} catch (JSONException e){
|
||||
e.printStackTrace();
|
||||
listener.onError("Gagal memproses data: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener(){
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
listener.onError("Gagal mendapatkan data: " + error.getMessage());
|
||||
}
|
||||
});
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
public static void getTiketSopir(Context context, String idSopir, TiketSopirResponseListener listener) {
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.GET, ApiServices.getHOST() + "getstoryperjalanan.php?id_sopir=" + idSopir, new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
Log.e("Response", response);
|
||||
try {
|
||||
JSONArray jsonArray = new JSONArray(response);
|
||||
List<TiketSopir> tiketDataList = new ArrayList<>();
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String idPerjalanan = jsonObject.getString("id_perjalanan");
|
||||
String kotaAsal = jsonObject.getString("kota_asal");
|
||||
String kotaTujuan = jsonObject.getString("kota_tujuan");
|
||||
String tanggalPerjalanan = jsonObject.getString("tanggal");
|
||||
String waktuKeberangkatan = jsonObject.getString("waktu_keberangkatan");
|
||||
double harga = jsonObject.getDouble("harga");
|
||||
String status = jsonObject.getString("status");
|
||||
String jumlahPenumpang = jsonObject.getString("jumlah_penumpang");
|
||||
String totalPenumpang = jsonObject.getString("total_penumpang");
|
||||
Date ntanggal;
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
try {
|
||||
ntanggal = sdf.parse(tanggalPerjalanan);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
TiketSopir tiketData = new TiketSopir(idPerjalanan, kotaAsal, kotaTujuan, ntanggal, waktuKeberangkatan, harga, jumlahPenumpang, status, totalPenumpang);
|
||||
tiketDataList.add(tiketData);
|
||||
}
|
||||
listener.onSuccess(tiketDataList);
|
||||
} catch (JSONException e){
|
||||
e.printStackTrace();
|
||||
listener.onError("Gagal memproses data: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener(){
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
listener.onError("Gagal mendapatkan data: " + error.getMessage());
|
||||
}
|
||||
});
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
public static void updateStatus(Context context, String idPemesanan, UpdateStatusResponseListener listener) {
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.POST, ApiServices.getHOST() + "update-status-penjemputan.php",
|
||||
new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
try {
|
||||
JSONObject jsonResponse = new JSONObject(response);
|
||||
String message = jsonResponse.getString("message");
|
||||
listener.onSuccess(message);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
listener.onError("Gagal memproses response");
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
listener.onError("Gagal mengirim request: " + error.getMessage());
|
||||
}
|
||||
}) {
|
||||
@Override
|
||||
protected Map<String, String> getParams() {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("id_pemesanan", idPemesanan);
|
||||
return params;
|
||||
}
|
||||
};
|
||||
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
|
||||
public static void tujuanStatus(Context context, String idPemesanan, UpdateStatusResponseListener listener) {
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.POST, ApiServices.getHOST() + "status-antar-sopir.php",
|
||||
new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
try {
|
||||
JSONObject jsonResponse = new JSONObject(response);
|
||||
String message = jsonResponse.getString("message");
|
||||
listener.onSuccess(message);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
listener.onError("Gagal memproses response");
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
listener.onError("Gagal mengirim request: " + error.getMessage());
|
||||
}
|
||||
}) {
|
||||
@Override
|
||||
protected Map<String, String> getParams() {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("id_pemesanan", idPemesanan);
|
||||
return params;
|
||||
}
|
||||
};
|
||||
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
|
||||
public static void getSopirData(Context context, String token, final SopirResponseListener listener) {
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.GET, ApiServices.getHOST() + "getsopirbyid.php?id=" + token,
|
||||
new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
try {
|
||||
Log.e("sopir", response);
|
||||
JSONObject jsonObject = new JSONObject(response);
|
||||
String message = jsonObject.getString("message");
|
||||
if (message.equals("success")){
|
||||
JSONObject userObj = jsonObject.getJSONObject("sopir");
|
||||
String id = userObj.getString("id_sopir");
|
||||
String nama = userObj.getString("nama_lengkap");
|
||||
String notelp = userObj.getString("notelp");
|
||||
String alamat = userObj.getString("alamat");
|
||||
String username = userObj.getString("username");
|
||||
String noSim = userObj.getString("no_SIM");
|
||||
String active = userObj.getString("status");
|
||||
Sopir sopir = new Sopir(id, nama, username, noSim, notelp,alamat, active);
|
||||
listener.onSuccess(sopir);
|
||||
}
|
||||
} catch (JSONException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
if (error.networkResponse != null && error.networkResponse.data != null) {
|
||||
try {
|
||||
String responseBody = new String(error.networkResponse.data, "utf-8");
|
||||
JSONObject jsonObject = new JSONObject(responseBody);
|
||||
String message = jsonObject.getString("message");
|
||||
listener.onError(message);
|
||||
} catch (JSONException | UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
listener.onError("Gagal mendapatkan data sopir: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
listener.onError("Gagal mendapatkan data sopir: network response is null");
|
||||
}
|
||||
}
|
||||
}) {
|
||||
};
|
||||
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
public static void updateUser(Context context, String token, String nama_lengkap, String sim, String notelp, String username, String alamat, final ApiServices.UpdateUserResponseListener listener) {
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.POST, ApiServices.getHOST() + "update-sopir.php",
|
||||
new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(response);
|
||||
boolean success = jsonObject.getBoolean("success");
|
||||
String message = jsonObject.getString("message");
|
||||
listener.onUpdateUserResponse(success, message);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
listener.onUpdateUserResponse(false, "Failed to parse response: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
listener.onUpdateUserResponse(false, "Failed to update user: " + error.getMessage());
|
||||
}
|
||||
}) {
|
||||
@Override
|
||||
protected Map<String, String> getParams() throws AuthFailureError {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("id_sopir", token);
|
||||
params.put("nama_lengkap", nama_lengkap);
|
||||
params.put("notelp", notelp);
|
||||
params.put("username", username);
|
||||
params.put("alamat", alamat);
|
||||
params.put("no_SIM", sim);
|
||||
return params;
|
||||
}
|
||||
};
|
||||
|
||||
RequestQueue requestQueue = Volley.newRequestQueue(context);
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.example.travelapps.sopir;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.travelapps.Adapter.PenumpangAdapter;
|
||||
import com.example.travelapps.Model.PemesananSopir;
|
||||
import com.example.travelapps.Model.TiketData;
|
||||
import com.example.travelapps.Model.TiketSopir;
|
||||
import com.example.travelapps.R;
|
||||
import com.google.android.gms.location.FusedLocationProviderClient;
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.google.android.gms.maps.model.Polyline;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DetailSopirActivity extends AppCompatActivity {
|
||||
|
||||
String idSopir = "";
|
||||
String idPerjalanan = "";
|
||||
RecyclerView recyclerView;
|
||||
private List<PemesananSopir> pemesananSopirList;
|
||||
private PenumpangAdapter adapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_detail_sopir);
|
||||
RecyclerView recyclerView = findViewById(R.id.rv_detail);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
pemesananSopirList = new ArrayList<>();
|
||||
adapter = new PenumpangAdapter(this, pemesananSopirList);
|
||||
recyclerView.setAdapter(adapter);
|
||||
Intent i = getIntent();
|
||||
if (i.getExtras() != null) {
|
||||
TiketSopir tiketData = (TiketSopir) i.getSerializableExtra("tiket");
|
||||
idPerjalanan = tiketData.getId();
|
||||
idSopir = i.getStringExtra("id");
|
||||
}
|
||||
|
||||
ApiServicesSopir.getPenumpangSopir(this, idSopir, idPerjalanan, new ApiServicesSopir.PerjalananResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(List<PemesananSopir> pemesananSopir) {
|
||||
pemesananSopirList.clear();
|
||||
pemesananSopirList.addAll(pemesananSopir);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
// Toast.makeText(DetailSopirActivity.this, "Error: " + message, Toast.LENGTH_SHORT).show();
|
||||
Log.e("detail" , "Error: " + message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package com.example.travelapps.sopir;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.PriorityQueue;
|
||||
import java.util.Set;
|
||||
class Graph {
|
||||
private final Map<String, List<Edge>> adjVertices = new HashMap<>();
|
||||
|
||||
void addVertex(String label) {
|
||||
adjVertices.putIfAbsent(label, new ArrayList<>());
|
||||
}
|
||||
|
||||
void addEdge(String label1, String label2, int weight) {
|
||||
adjVertices.computeIfAbsent(label1, k -> new ArrayList<>()).add(new Edge(label2, weight));
|
||||
adjVertices.computeIfAbsent(label2, k -> new ArrayList<>()).add(new Edge(label1, weight)); // Untuk graf tak berarah
|
||||
}
|
||||
|
||||
List<Edge> getAdjVertices(String label) {
|
||||
return adjVertices.get(label);
|
||||
}
|
||||
|
||||
static class Edge {
|
||||
String vertex;
|
||||
int weight;
|
||||
|
||||
Edge(String vertex, int weight) {
|
||||
this.vertex = vertex;
|
||||
this.weight = weight;
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Integer> dijkstra(String start) {
|
||||
PriorityQueue<Edge> pq = new PriorityQueue<>(Comparator.comparingInt(edge -> edge.weight));
|
||||
Map<String, Integer> distances = new HashMap<>();
|
||||
Set<String> visited = new HashSet<>();
|
||||
|
||||
pq.add(new Edge(start, 0));
|
||||
distances.put(start, 0);
|
||||
|
||||
while (!pq.isEmpty()) {
|
||||
Edge current = pq.poll();
|
||||
visited.add(current.vertex);
|
||||
|
||||
for (Edge neighbor : adjVertices.get(current.vertex)) {
|
||||
if (!visited.contains(neighbor.vertex)) {
|
||||
int newDist = distances.get(current.vertex) + neighbor.weight;
|
||||
if (newDist < distances.getOrDefault(neighbor.vertex, Integer.MAX_VALUE)) {
|
||||
distances.put(neighbor.vertex, newDist);
|
||||
pq.add(new Edge(neighbor.vertex, newDist));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return distances;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.example.travelapps.sopir;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.example.travelapps.Fragment.FragmentActivity;
|
||||
import com.example.travelapps.Fragment.FragmentHome;
|
||||
import com.example.travelapps.Fragment.FragmentNotifications;
|
||||
import com.example.travelapps.Fragment.FragmentSettings;
|
||||
import com.example.travelapps.R;
|
||||
import com.example.travelapps.R;
|
||||
import com.example.travelapps.sopir.ui.dashboard.DashboardFragment;
|
||||
import com.example.travelapps.sopir.ui.home.HomeFragment;
|
||||
import com.example.travelapps.sopir.ui.notifications.NotificationsFragment;
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
|
||||
public class HomeSopirActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_home_sopir);
|
||||
|
||||
BottomNavigationView bottomNavigationView = findViewById(R.id.nav_view);
|
||||
bottomNavigationView.setOnItemSelectedListener(navListener);
|
||||
|
||||
// Tampilkan fragment pertama kali (misalnya, FragmentHome)
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.nav_host_fragment_activity_home_sopir,
|
||||
new HomeFragment()).commit();
|
||||
}
|
||||
|
||||
private final BottomNavigationView.OnItemSelectedListener navListener =
|
||||
new BottomNavigationView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||
Fragment selectedFragment = null;
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.home:
|
||||
selectedFragment = new HomeFragment();
|
||||
break;
|
||||
case R.id.aktivitas:
|
||||
selectedFragment = new DashboardFragment();
|
||||
break;
|
||||
case R.id.navigation_notifications:
|
||||
selectedFragment = new NotificationsFragment();
|
||||
break;
|
||||
}
|
||||
|
||||
// Ganti fragment yang ditampilkan
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.nav_host_fragment_activity_home_sopir,
|
||||
selectedFragment).commit();
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package com.example.travelapps.sopir;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.AppCompatButton;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.travelapps.R;
|
||||
import com.example.travelapps.Services.ApiServices;
|
||||
import com.example.travelapps.LoginActivity;
|
||||
|
||||
public class LoginSopirActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
|
||||
EditText etUsername, etPassword;
|
||||
AppCompatButton btnLogin;
|
||||
TextView tvUser, tvRegister;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_login_sopir);
|
||||
onBindView();
|
||||
}
|
||||
|
||||
private void onBindView(){
|
||||
etUsername = findViewById(R.id.et_username);
|
||||
etPassword = findViewById(R.id.et_password);
|
||||
btnLogin = findViewById(R.id.buttonLogin);
|
||||
tvUser = findViewById(R.id.tv_login);
|
||||
tvRegister = findViewById(R.id.tx_daftar);
|
||||
|
||||
btnLogin.setOnClickListener(this);
|
||||
tvUser.setOnClickListener(this);
|
||||
tvRegister.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v == btnLogin) {
|
||||
String username = etUsername.getText().toString().trim();
|
||||
String password = etPassword.getText().toString().trim();
|
||||
|
||||
if (username.isEmpty()) {
|
||||
etUsername.setError("Username tidak boleh kosong");
|
||||
} else if (password.isEmpty()){
|
||||
etPassword.setError("Password tidak boleh kosong");
|
||||
} else if (password.length() < 8) {
|
||||
etPassword.setError("Panjang password harus minimal 8 karakter");
|
||||
} else {
|
||||
ApiServicesSopir.login(LoginSopirActivity.this, username, password, new ApiServices.LoginResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String message) {
|
||||
Toast.makeText(LoginSopirActivity.this, "Berhasil Login", Toast.LENGTH_LONG).show();
|
||||
Intent i = new Intent(LoginSopirActivity.this, HomeSopirActivity.class);
|
||||
startActivity(i);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Toast.makeText(LoginSopirActivity.this, message, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (v == tvUser) {
|
||||
Intent intent = new Intent(LoginSopirActivity.this, LoginActivity.class);
|
||||
startActivity(intent);
|
||||
} else {
|
||||
Intent intent = new Intent(LoginSopirActivity.this, RegisterSopirActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,548 @@
|
|||
package com.example.travelapps.sopir;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.AppCompatButton;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.location.Address;
|
||||
import android.location.Geocoder;
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.volley.Request;
|
||||
import com.android.volley.RequestQueue;
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.android.volley.toolbox.JsonObjectRequest;
|
||||
import com.android.volley.toolbox.Volley;
|
||||
import com.codebyashish.googledirectionapi.AbstractRouting;
|
||||
import com.codebyashish.googledirectionapi.ErrorHandling;
|
||||
import com.codebyashish.googledirectionapi.RouteDrawing;
|
||||
import com.codebyashish.googledirectionapi.RouteInfoModel;
|
||||
import com.codebyashish.googledirectionapi.RouteListener;
|
||||
import com.example.travelapps.Adapter.PenumpangAdapter;
|
||||
import com.example.travelapps.Adapter.PenumpangAdapterActive;
|
||||
import com.example.travelapps.Adapter.PerjalananSopirAdapter;
|
||||
import com.example.travelapps.Model.PemesananSopir;
|
||||
import com.example.travelapps.Model.TiketData;
|
||||
import com.example.travelapps.Model.TiketSopir;
|
||||
import com.example.travelapps.Model.Tujuan;
|
||||
import com.example.travelapps.R;
|
||||
import com.google.android.gms.location.FusedLocationProviderClient;
|
||||
import com.google.android.gms.location.LocationListener;
|
||||
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.BitmapDescriptor;
|
||||
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
||||
import com.google.android.gms.maps.model.CameraPosition;
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
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.gms.maps.model.RoundCap;
|
||||
import com.google.android.gms.tasks.OnSuccessListener;
|
||||
import com.google.android.gms.tasks.Task;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public class MapsSopirActivity extends AppCompatActivity implements OnMapReadyCallback, LocationListener, PenumpangAdapterActive.OnStatusUpdateListener {
|
||||
|
||||
private GoogleMap gMaps;
|
||||
final private int FINE_PERMISSION_CODE = 1;
|
||||
Location currentLocation;
|
||||
String idSopir = "";
|
||||
String idPerjalanan = "";
|
||||
RecyclerView recyclerView;
|
||||
private ProgressDialog dialog;
|
||||
FusedLocationProviderClient fusedLocationProviderClient;
|
||||
LatLng userLocation, destinationLocation;
|
||||
Polyline currentRoute;
|
||||
private List<PemesananSopir> pemesananSopirList;
|
||||
private PenumpangAdapterActive adapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_maps_sopir);
|
||||
fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this);
|
||||
getLastLocation();
|
||||
RecyclerView recyclerView = findViewById(R.id.rvUser);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
pemesananSopirList = new ArrayList<>();
|
||||
adapter = new PenumpangAdapterActive(this, pemesananSopirList, this);
|
||||
recyclerView.setAdapter(adapter);
|
||||
Intent i = getIntent();
|
||||
if (i.getExtras() != null) {
|
||||
TiketData tiketData = (TiketData) i.getSerializableExtra("tiket");
|
||||
idPerjalanan = tiketData.getId();
|
||||
idSopir = i.getStringExtra("id");
|
||||
}
|
||||
|
||||
dialog = new ProgressDialog(MapsSopirActivity.this);
|
||||
}
|
||||
|
||||
private void getLastLocation() {
|
||||
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, FINE_PERMISSION_CODE);
|
||||
return;
|
||||
}
|
||||
Task<Location> task = fusedLocationProviderClient.getLastLocation();
|
||||
task.addOnSuccessListener(new OnSuccessListener<Location>() {
|
||||
@Override
|
||||
public void onSuccess(Location location) {
|
||||
if (location != null) {
|
||||
currentLocation = location;
|
||||
userLocation = new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude());
|
||||
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
|
||||
mapFragment.getMapAsync(MapsSopirActivity.this);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// private void locationJemputTujuanUser() {
|
||||
// ApiServicesSopir.getPenumpangSopirActive(MapsSopirActivity.this, idSopir, idPerjalanan, new ApiServicesSopir.PerjalananResponseListener() {
|
||||
// @Override
|
||||
// public void onSuccess(List<PemesananSopir> pemesananSopir) {
|
||||
// gMaps.clear();
|
||||
//
|
||||
// for (PemesananSopir pemesanan : pemesananSopir) {
|
||||
// LatLng latLngJemput = new LatLng(
|
||||
// Double.parseDouble(pemesanan.getLatitude()),
|
||||
// Double.parseDouble(pemesanan.getLongitude())
|
||||
// );
|
||||
// double distanceJemput = calculateDistance(userLocation.latitude, userLocation.longitude, latLngJemput.latitude, latLngJemput.longitude);
|
||||
// pemesanan.setDistance(distanceJemput);
|
||||
//
|
||||
// LatLng latLngTujuan = new LatLng(
|
||||
// Double.parseDouble(pemesanan.getLatTujuan()),
|
||||
// Double.parseDouble(pemesanan.getLngTujuan())
|
||||
// );
|
||||
// double distanceTujuan = calculateDistance(userLocation.latitude, userLocation.longitude, latLngTujuan.latitude, latLngTujuan.longitude);
|
||||
// pemesanan.setDistanceTujuan(distanceTujuan);
|
||||
// }
|
||||
//
|
||||
// Collections.sort(pemesananSopir, new Comparator<PemesananSopir>() {
|
||||
// @Override
|
||||
// public int compare(PemesananSopir p1, PemesananSopir p2) {
|
||||
// return Double.compare(p1.getDistance(), p2.getDistance());
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// gMaps.addMarker(new MarkerOptions().position(userLocation).icon(BitmapDescriptorFactory.fromBitmap(createCustomMarker(MapsSopirActivity.this, "Lokasi Anda"))));
|
||||
//
|
||||
// for (int i = 0; i < pemesananSopir.size(); i++) {
|
||||
// PemesananSopir pemesanan = pemesananSopir.get(i);
|
||||
// String formattedDistanceJemput = String.format("%.1f", pemesanan.getDistance());
|
||||
// String labelJemput = "Penjemputan ke-" + (i + 1) + ": " + pemesanan.getNamaLengkap() + " (" + formattedDistanceJemput + " km)";
|
||||
// LatLng latLngJemput = new LatLng(
|
||||
// Double.parseDouble(pemesanan.getLatitude()),
|
||||
// Double.parseDouble(pemesanan.getLongitude())
|
||||
// );
|
||||
// LatLng latLngTujuan = new LatLng(
|
||||
// Double.parseDouble(pemesanan.getLatTujuan()),
|
||||
// Double.parseDouble(pemesanan.getLngTujuan())
|
||||
// );
|
||||
//
|
||||
// // Add custom markers with labels
|
||||
// gMaps.addMarker(new MarkerOptions()
|
||||
// .position(latLngJemput)
|
||||
// .icon(BitmapDescriptorFactory.fromBitmap(createCustomMarker(MapsSopirActivity.this, labelJemput))));
|
||||
//
|
||||
// String formattedDistanceTujuan = String.format("%.1f", pemesanan.getDistanceTujuan());
|
||||
// String labelTujuan = "Tujuan: " + pemesanan.getNamaLengkap() + " (" + formattedDistanceTujuan + " km)";
|
||||
// gMaps.addMarker(new MarkerOptions()
|
||||
// .position(latLngTujuan)
|
||||
// .icon(BitmapDescriptorFactory.fromBitmap(createCustomMarker(MapsSopirActivity.this, labelTujuan))));
|
||||
//
|
||||
// // Draw routes
|
||||
// getRouteFromOSRM(userLocation, latLngJemput);
|
||||
// getRouteFromOSRM(userLocation, latLngTujuan);
|
||||
// }
|
||||
//
|
||||
// // Update RecyclerView
|
||||
// pemesananSopirList.clear();
|
||||
// pemesananSopirList.addAll(pemesananSopir);
|
||||
// adapter.notifyDataSetChanged();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(String message) {
|
||||
// if (message.equals("Data tidak ditemukan")) {
|
||||
// destinationLocation();
|
||||
// } else {
|
||||
// Toast.makeText(MapsSopirActivity.this, "Error: " + message, Toast.LENGTH_LONG).show();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
private void locationJemputTujuanUser() {
|
||||
ApiServicesSopir.getPenumpangSopirActive(MapsSopirActivity.this, idSopir, idPerjalanan, new ApiServicesSopir.PerjalananResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(List<PemesananSopir> pemesananSopir) {
|
||||
gMaps.clear();
|
||||
Graph graph = new Graph();
|
||||
|
||||
// Tambahkan lokasi pengguna sebagai simpul awal
|
||||
graph.addVertex("userLocation");
|
||||
|
||||
// Tambahkan semua lokasi penjemputan dan tujuan ke graf
|
||||
for (PemesananSopir pemesanan : pemesananSopir) {
|
||||
String jemputLabel = pemesanan.getIdPemesanan() + "_jemput";
|
||||
String tujuanLabel = pemesanan.getIdPemesanan() + "_tujuan";
|
||||
|
||||
graph.addVertex(jemputLabel);
|
||||
graph.addVertex(tujuanLabel);
|
||||
|
||||
// Tambahkan edge dengan bobot sesuai jarak atau waktu
|
||||
double jarakJemput = calculateDistance(userLocation.latitude, userLocation.longitude, Double.parseDouble(pemesanan.getLatitude()), Double.parseDouble(pemesanan.getLongitude()));
|
||||
graph.addEdge("userLocation", jemputLabel, (int) jarakJemput);
|
||||
|
||||
double jarakTujuan = calculateDistance(userLocation.latitude, userLocation.longitude, Double.parseDouble(pemesanan.getLatTujuan()), Double.parseDouble(pemesanan.getLngTujuan()));
|
||||
graph.addEdge("userLocation", tujuanLabel, (int) jarakTujuan);
|
||||
|
||||
// Tambahkan edge antar lokasi jemput dan tujuan
|
||||
double jarakAntarLokasi = calculateDistance(Double.parseDouble(pemesanan.getLatitude()), Double.parseDouble(pemesanan.getLongitude()), Double.parseDouble(pemesanan.getLatTujuan()), Double.parseDouble(pemesanan.getLngTujuan()));
|
||||
graph.addEdge(jemputLabel, tujuanLabel, (int) jarakAntarLokasi);
|
||||
}
|
||||
|
||||
// Hitung jalur terpendek dari lokasi pengguna ke semua lokasi jemput dan tujuan
|
||||
Map<String, Integer> distances = graph.dijkstra("userLocation");
|
||||
|
||||
for (PemesananSopir pemesanan : pemesananSopir) {
|
||||
String jemputLabel = pemesanan.getIdPemesanan() + "_jemput";
|
||||
String tujuanLabel = pemesanan.getIdPemesanan() + "_tujuan";
|
||||
|
||||
// Set jarak dari lokasi pengguna ke lokasi jemput dan tujuan
|
||||
double distanceJemput = distances.get(jemputLabel);
|
||||
pemesanan.setDistance(distanceJemput);
|
||||
|
||||
double distanceTujuan = distances.get(tujuanLabel);
|
||||
pemesanan.setDistanceTujuan(distanceTujuan);
|
||||
}
|
||||
|
||||
// Lakukan sorting berdasarkan jarak
|
||||
Collections.sort(pemesananSopir, new Comparator<PemesananSopir>() {
|
||||
@Override
|
||||
public int compare(PemesananSopir p1, PemesananSopir p2) {
|
||||
return Double.compare(p1.getDistance(), p2.getDistance());
|
||||
}
|
||||
});
|
||||
|
||||
gMaps.addMarker(new MarkerOptions().position(userLocation).icon(BitmapDescriptorFactory.fromBitmap(createCustomMarker(MapsSopirActivity.this, "Lokasi Anda"))));
|
||||
|
||||
ArrayList<Tujuan> tujuanList = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < pemesananSopir.size(); i++) {
|
||||
PemesananSopir pemesanan = pemesananSopir.get(i);
|
||||
String formattedDistanceJemput = String.format("%.1f", pemesanan.getDistance());
|
||||
String labelJemput = "Penjemputan ke-" + (i + 1) + ": " + pemesanan.getNamaLengkap() + " (" + formattedDistanceJemput + " km)";
|
||||
LatLng latLngJemput = new LatLng(
|
||||
Double.parseDouble(pemesanan.getLatitude()),
|
||||
Double.parseDouble(pemesanan.getLongitude())
|
||||
);
|
||||
LatLng latLngTujuan = new LatLng(
|
||||
Double.parseDouble(pemesanan.getLatTujuan()),
|
||||
Double.parseDouble(pemesanan.getLngTujuan())
|
||||
);
|
||||
|
||||
// Tambahkan marker custom dengan label
|
||||
gMaps.addMarker(new MarkerOptions()
|
||||
.position(latLngJemput)
|
||||
.icon(BitmapDescriptorFactory.fromBitmap(createCustomMarker(MapsSopirActivity.this, labelJemput))));
|
||||
|
||||
Tujuan tujuan = new Tujuan(latLngTujuan, pemesanan.getDistanceTujuan(), pemesanan.getNamaLengkap());
|
||||
tujuanList.add(tujuan);
|
||||
|
||||
// String formattedDistanceTujuan = String.format("%.1f", pemesanan.getDistanceTujuan());
|
||||
// String labelTujuan = "Tujuan: " + pemesanan.getNamaLengkap() + " (" + formattedDistanceTujuan + " km)";
|
||||
//
|
||||
// gMaps.addMarker(new MarkerOptions()
|
||||
// .position(latLngTujuan)
|
||||
// .icon(BitmapDescriptorFactory.fromBitmap(createCustomMarker(MapsSopirActivity.this, labelTujuan))));
|
||||
|
||||
|
||||
// Gambar rute
|
||||
getRouteFromOSRM(userLocation, latLngJemput);
|
||||
// getRouteFromOSRM(userLocation, latLngTujuan);
|
||||
}
|
||||
|
||||
// Update RecyclerView
|
||||
pemesananSopirList.clear();
|
||||
pemesananSopirList.addAll(pemesananSopir);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
if (message.equals("Data tidak ditemukan")) {
|
||||
destinationLocation();
|
||||
} else {
|
||||
Toast.makeText(MapsSopirActivity.this, "Error: " + message, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private Bitmap createCustomMarker(Context context, String label) {
|
||||
View marker = LayoutInflater.from(context).inflate(R.layout.custom_marker, null);
|
||||
|
||||
TextView markerLabel = marker.findViewById(R.id.marker_label);
|
||||
markerLabel.setText(label);
|
||||
|
||||
// Measure and layout the view
|
||||
marker.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
|
||||
marker.layout(0, 0, marker.getMeasuredWidth(), marker.getMeasuredHeight());
|
||||
|
||||
// Create a bitmap and draw the view into the bitmap
|
||||
Bitmap bitmap = Bitmap.createBitmap(marker.getMeasuredWidth(), marker.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
marker.draw(canvas);
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
|
||||
private void destinationLocation() {
|
||||
ApiServicesSopir.getPenumpangSopir(MapsSopirActivity.this, idSopir, idPerjalanan, new ApiServicesSopir.PerjalananResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(List<PemesananSopir> pemesananSopir) {
|
||||
gMaps.clear();
|
||||
|
||||
// Add marker for user's location
|
||||
gMaps.addMarker(new MarkerOptions().position(userLocation).title("Lokasi anda"));
|
||||
|
||||
// Calculate distances and add to the PemesananSopir objects
|
||||
for (PemesananSopir pemesanan : pemesananSopir) {
|
||||
LatLng latLngTujuan = new LatLng(
|
||||
Double.parseDouble(pemesanan.getLatTujuan()),
|
||||
Double.parseDouble(pemesanan.getLngTujuan())
|
||||
);
|
||||
double distanceTujuan = calculateDistance(userLocation.latitude, userLocation.longitude, latLngTujuan.latitude, latLngTujuan.longitude);
|
||||
pemesanan.setDistanceTujuan(distanceTujuan);
|
||||
}
|
||||
|
||||
// Sort destinations by distance
|
||||
Collections.sort(pemesananSopir, new Comparator<PemesananSopir>() {
|
||||
@Override
|
||||
public int compare(PemesananSopir p1, PemesananSopir p2) {
|
||||
return Double.compare(p1.getDistanceTujuan(), p2.getDistanceTujuan());
|
||||
}
|
||||
});
|
||||
|
||||
// Add custom markers with distance and order labels
|
||||
for (int i = 0; i < pemesananSopir.size(); i++) {
|
||||
PemesananSopir pemesanan = pemesananSopir.get(i);
|
||||
String namaLengkap = pemesanan.getNamaLengkap();
|
||||
LatLng latLngTujuan = new LatLng(
|
||||
Double.parseDouble(pemesanan.getLatTujuan()),
|
||||
Double.parseDouble(pemesanan.getLngTujuan())
|
||||
);
|
||||
|
||||
String formattedDistanceTujuan = String.format("%.1f", pemesanan.getDistanceTujuan());
|
||||
String label = "Tujuan ke-" + (i + 1) + ": " + namaLengkap + " (" + formattedDistanceTujuan + " km)";
|
||||
gMaps.addMarker(new MarkerOptions()
|
||||
.position(latLngTujuan)
|
||||
.icon(BitmapDescriptorFactory.fromBitmap(createCustomMarker(MapsSopirActivity.this, label))));
|
||||
|
||||
// Draw route from user's location to destination
|
||||
getRouteFromOSRM(userLocation, latLngTujuan);
|
||||
}
|
||||
|
||||
// Update RecyclerView
|
||||
pemesananSopirList.clear();
|
||||
pemesananSopirList.addAll(pemesananSopir);
|
||||
adapter.setDestinationLocation(true);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
gMaps.clear();
|
||||
gMaps.addMarker(new MarkerOptions().position(userLocation).title("Lokasi anda"));
|
||||
pemesananSopirList.clear();
|
||||
adapter.setDestinationLocation(true);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void locationUser() {
|
||||
ApiServicesSopir.getPenumpangSopirActive(MapsSopirActivity.this, idSopir, idPerjalanan, new ApiServicesSopir.PerjalananResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(List<PemesananSopir> pemesananSopir) {
|
||||
List<LatLng> coordinates = new ArrayList<>();
|
||||
double shortestDistance = Double.MAX_VALUE;
|
||||
LatLng nearestMarkerLatLng = null;
|
||||
|
||||
for (PemesananSopir pemesanan : pemesananSopir) {
|
||||
double latitude = Double.parseDouble(pemesanan.getLatitude());
|
||||
double longitude = Double.parseDouble(pemesanan.getLongitude());
|
||||
LatLng markerLatLng = new LatLng(latitude, longitude);
|
||||
coordinates.add(markerLatLng);
|
||||
|
||||
float[] distanceResult = new float[1];
|
||||
Location.distanceBetween(userLocation.latitude, userLocation.longitude,
|
||||
latitude, longitude, distanceResult);
|
||||
double distance = distanceResult[0];
|
||||
|
||||
if (distance < shortestDistance) {
|
||||
shortestDistance = distance;
|
||||
nearestMarkerLatLng = markerLatLng;
|
||||
}
|
||||
String username = pemesanan.getNamaLengkap();
|
||||
gMaps.addMarker(new MarkerOptions().position(markerLatLng).title(username));
|
||||
}
|
||||
|
||||
if (nearestMarkerLatLng != null) {
|
||||
if (currentRoute != null) {
|
||||
currentRoute.remove();
|
||||
}
|
||||
getRouteFromOSRM(userLocation, nearestMarkerLatLng);
|
||||
}
|
||||
pemesananSopirList.clear();
|
||||
pemesananSopirList.addAll(pemesananSopir);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Toast.makeText(MapsSopirActivity.this, "Error: " + message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapReady(@NonNull GoogleMap googleMap) {
|
||||
gMaps = googleMap;
|
||||
LatLng sydney = new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude());
|
||||
gMaps.addMarker(new MarkerOptions().position(sydney).title("Lokasi Anda"));
|
||||
float zoomLevel = 14.0f;
|
||||
CameraPosition cameraPosition = new CameraPosition.Builder().target(sydney).zoom(zoomLevel).build();
|
||||
gMaps.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
|
||||
locationJemputTujuanUser();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == FINE_PERMISSION_CODE) {
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
getLastLocation();
|
||||
} else {
|
||||
Toast.makeText(this, "Location Permission is Denied", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static double calculateDistance(double lat1, double lon1, double lat2, double lon2) {
|
||||
final int R = 6371;
|
||||
double latDistance = Math.toRadians(lat2 - lat1);
|
||||
double lonDistance = Math.toRadians(lon2 - lon1);
|
||||
double a = Math.sin(latDistance / 2) * Math.sin(latDistance / 2)
|
||||
+ Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2))
|
||||
* Math.sin(lonDistance / 2) * Math.sin(lonDistance / 2);
|
||||
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
||||
double distance = R * c;
|
||||
return distance;
|
||||
}
|
||||
|
||||
private void getRouteFromOSRM(LatLng origin, LatLng destination) {
|
||||
String url = "http://router.project-osrm.org/route/v1/driving/" +
|
||||
origin.longitude + "," + origin.latitude + ";" +
|
||||
destination.longitude + "," + destination.latitude +
|
||||
"?steps=true&annotations=true&overview=full&geometries=geojson";
|
||||
RequestQueue queue = Volley.newRequestQueue(this);
|
||||
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, null,
|
||||
new Response.Listener<JSONObject>() {
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
handleGeoJSONResponse(response);
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
Log.e("Volley Error", error.toString());
|
||||
}
|
||||
});
|
||||
|
||||
queue.add(jsonObjectRequest);
|
||||
}
|
||||
private void handleGeoJSONResponse(JSONObject response) {
|
||||
try {
|
||||
JSONArray routes = response.getJSONArray("routes");
|
||||
JSONObject route = routes.getJSONObject(0);
|
||||
JSONObject geometry = route.getJSONObject("geometry");
|
||||
JSONArray coordinates = geometry.getJSONArray("coordinates");
|
||||
|
||||
List<LatLng> decodedCoordinates = parseGeoJSONCoordinates(coordinates);
|
||||
PolylineOptions polylineOptions = new PolylineOptions()
|
||||
.addAll(decodedCoordinates)
|
||||
.color(Color.RED)
|
||||
.width(12);
|
||||
currentRoute = gMaps.addPolyline(polylineOptions);
|
||||
dialog.dismiss();
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
private List<LatLng> parseGeoJSONCoordinates(JSONArray coordinates) throws JSONException {
|
||||
List<LatLng> decodedCoordinates = new ArrayList<>();
|
||||
for (int i = 0; i < coordinates.length(); i++) {
|
||||
JSONArray coordPair = coordinates.getJSONArray(i);
|
||||
double latitude = Double.parseDouble(coordPair.getString(1).replace("[", "").replace("]", ""));
|
||||
double longitude = Double.parseDouble(coordPair.getString(0).replace("[", "").replace("]", ""));
|
||||
decodedCoordinates.add(new LatLng(latitude, longitude));
|
||||
}
|
||||
return decodedCoordinates;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(@NonNull Location location) {
|
||||
currentLocation = location;
|
||||
userLocation = new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude());
|
||||
if (gMaps != null) {
|
||||
gMaps.animateCamera(CameraUpdateFactory.newLatLng(userLocation));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusUpdated() {
|
||||
locationJemputTujuanUser();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package com.example.travelapps.sopir;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.AppCompatButton;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.travelapps.pelanggan.HomeActivity;
|
||||
import com.example.travelapps.Model.Sopir;
|
||||
import com.example.travelapps.R;
|
||||
import com.example.travelapps.Services.ApiServices;
|
||||
|
||||
public class ProfileSopirActivity extends AppCompatActivity {
|
||||
EditText etNama, etUsername, etTelp, etAlamat, etSim;
|
||||
AppCompatButton btnSimpan;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_profile_sopir);
|
||||
onBindView();
|
||||
SharedPreferences preferences = ProfileSopirActivity.this.getSharedPreferences("myPrefs", MODE_PRIVATE);
|
||||
String token = preferences.getString("id", "");
|
||||
ApiServicesSopir.getSopirData(ProfileSopirActivity.this, token, new ApiServicesSopir.SopirResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(Sopir sopir) {
|
||||
TextView tvname = findViewById(R.id.userName);
|
||||
tvname.setText(sopir.getNamaLengkap());
|
||||
TextView tvNickname = findViewById(R.id.profileImage);
|
||||
String twoInitials = sopir.getNamaLengkap().substring(0, 2);
|
||||
twoInitials = twoInitials.toUpperCase();
|
||||
tvNickname.setText(twoInitials);
|
||||
etNama.setText(sopir.getNamaLengkap());
|
||||
etUsername.setText(sopir.getUsername());
|
||||
etTelp.setText(sopir.getNoTelp());
|
||||
etSim.setText(sopir.getNoSim());
|
||||
etAlamat.setText(sopir.getAlamat());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
|
||||
}
|
||||
});
|
||||
btnSimpan.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
ApiServicesSopir.updateUser(ProfileSopirActivity.this, token, etNama.getText().toString().trim(), etSim.getText().toString().trim(), etTelp.getText().toString().trim(), etUsername.getText().toString().trim(), etAlamat.getText().toString().trim(), new ApiServices.UpdateUserResponseListener() {
|
||||
@Override
|
||||
public void onUpdateUserResponse(boolean success, String message) {
|
||||
Intent intent = new Intent(ProfileSopirActivity.this, HomeActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
Toast.makeText(ProfileSopirActivity.this, message, Toast.LENGTH_SHORT).show();
|
||||
Log.e("error", message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
private void onBindView() {
|
||||
etNama = findViewById(R.id.et_nama);
|
||||
etUsername = findViewById(R.id.et_username);
|
||||
etTelp = findViewById(R.id.et_notelp);
|
||||
etSim = findViewById(R.id.et_sim);
|
||||
etAlamat = findViewById(R.id.et_alamat);
|
||||
btnSimpan = findViewById(R.id.btn_simpan);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
package com.example.travelapps.sopir;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.AppCompatButton;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.travelapps.DaftarActivity;
|
||||
import com.example.travelapps.LoginActivity;
|
||||
import com.example.travelapps.Services.ApiServices;
|
||||
import com.example.travelapps.R;
|
||||
|
||||
public class RegisterSopirActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
|
||||
EditText etUsername, etNama, etPassword, etSim, etTelp, etAlamat;
|
||||
TextView tvLogin;
|
||||
AppCompatButton btnDaftar;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_register_sopir);
|
||||
onBindView();
|
||||
}
|
||||
|
||||
private void onBindView(){
|
||||
etUsername = findViewById(R.id.et_username);
|
||||
etNama = findViewById(R.id.et_nama);
|
||||
etPassword = findViewById(R.id.et_password);
|
||||
etSim = findViewById(R.id.et_sim);
|
||||
etTelp = findViewById(R.id.et_telp);
|
||||
etAlamat = findViewById(R.id.et_alamat);
|
||||
btnDaftar = findViewById(R.id.buttonRegister);
|
||||
tvLogin = findViewById(R.id.tx_login);
|
||||
|
||||
btnDaftar.setOnClickListener(this);
|
||||
tvLogin.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v == btnDaftar) {
|
||||
String username = etUsername.getText().toString().trim();
|
||||
String nama = etNama.getText().toString().trim();
|
||||
String password = etPassword.getText().toString().trim();
|
||||
String sim = etSim.getText().toString().trim();
|
||||
String telp = etTelp.getText().toString().trim();
|
||||
String alamat = etAlamat.getText().toString().trim();
|
||||
|
||||
if (username.isEmpty()) {
|
||||
etUsername.setError("Username tidak boleh kosong");
|
||||
} else if (nama.isEmpty()) {
|
||||
etNama.setError("Nama tidak boleh kosong");
|
||||
} else if (password.isEmpty()){
|
||||
etPassword.setError("Password tidak boleh kosong");
|
||||
} else if (password.length() < 8) {
|
||||
etPassword.setError("Panjang password harus minimal 8 karakter");
|
||||
} else if (sim.isEmpty()) {
|
||||
etSim.setError("Nomor SIM tidak boleh kosong");
|
||||
} else if (telp.isEmpty()) {
|
||||
etTelp.setError("Nomor telepon tidak boleh kosong");
|
||||
} else if (alamat.isEmpty()) {
|
||||
etAlamat.setError("Alamat tidak boleh kosong");
|
||||
} else {
|
||||
ApiServicesSopir.register(RegisterSopirActivity.this, nama, username, password, sim, telp, alamat, new ApiServices.RegisterResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(String message) {
|
||||
Toast.makeText(RegisterSopirActivity.this, "Berhasil Daftar Akun", Toast.LENGTH_LONG).show();
|
||||
Intent i = new Intent(RegisterSopirActivity.this, LoginSopirActivity.class);
|
||||
startActivity(i);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Toast.makeText(RegisterSopirActivity.this, message, Toast.LENGTH_LONG).show();
|
||||
Log.e("Error Register", message);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
Intent i = new Intent(RegisterSopirActivity.this, LoginSopirActivity.class);
|
||||
startActivity(i);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package com.example.travelapps.sopir.ui.dashboard;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.travelapps.Adapter.OnItemTiketSopirClickListener;
|
||||
import com.example.travelapps.Adapter.PerjalananSopirAdapter;
|
||||
import com.example.travelapps.Adapter.TiketAdapter;
|
||||
import com.example.travelapps.Model.PemesananSopir;
|
||||
import com.example.travelapps.Model.TiketData;
|
||||
import com.example.travelapps.Model.TiketSopir;
|
||||
import com.example.travelapps.databinding.FragmentDashboardBinding;
|
||||
import com.example.travelapps.sopir.ApiServicesSopir;
|
||||
import com.example.travelapps.sopir.DetailSopirActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DashboardFragment extends Fragment implements OnItemTiketSopirClickListener {
|
||||
|
||||
private FragmentDashboardBinding binding;
|
||||
private List<TiketSopir> tiketDataList;
|
||||
private PerjalananSopirAdapter adapter;
|
||||
String idSopir= "";
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
DashboardViewModel dashboardViewModel =
|
||||
new ViewModelProvider(this).get(DashboardViewModel.class);
|
||||
|
||||
binding = FragmentDashboardBinding.inflate(inflater, container, false);
|
||||
View root = binding.getRoot();
|
||||
RecyclerView recyclerView = binding.rvDaftar;
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
tiketDataList = new ArrayList<>();
|
||||
adapter = new PerjalananSopirAdapter(getContext(), tiketDataList, this);
|
||||
recyclerView.setAdapter(adapter);
|
||||
SharedPreferences preferences = getActivity().getSharedPreferences("myPrefs", MODE_PRIVATE);
|
||||
idSopir = preferences.getString("id", "");
|
||||
getPerjalananSopirFromApi(idSopir);
|
||||
return root;
|
||||
}
|
||||
|
||||
private void getPerjalananSopirFromApi(String idSopir) {
|
||||
ApiServicesSopir.getTiketSopir(getContext(), idSopir, new ApiServicesSopir.TiketSopirResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(List<TiketSopir> pemesananSopir) {
|
||||
tiketDataList.clear();
|
||||
tiketDataList.addAll(pemesananSopir);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
Log.e("DashboardFragmentSopir", "Error: " + message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
binding = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(TiketSopir tiketData) {
|
||||
Intent intent = new Intent(getContext(), DetailSopirActivity.class);
|
||||
intent.putExtra("id", idSopir);
|
||||
intent.putExtra("tiket", tiketData);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.example.travelapps.sopir.ui.dashboard;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
public class DashboardViewModel extends ViewModel {
|
||||
|
||||
private final MutableLiveData<String> mText;
|
||||
|
||||
public DashboardViewModel() {
|
||||
mText = new MutableLiveData<>();
|
||||
mText.setValue("This is dashboard fragment");
|
||||
}
|
||||
|
||||
public LiveData<String> getText() {
|
||||
return mText;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
package com.example.travelapps.sopir.ui.home;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.travelapps.Adapter.OnItemTiketClickListener;
|
||||
import com.example.travelapps.Adapter.TiketAdapter;
|
||||
import com.example.travelapps.Model.Sopir;
|
||||
import com.example.travelapps.Model.TiketData;
|
||||
import com.example.travelapps.databinding.FragmentHome2Binding;
|
||||
import com.example.travelapps.sopir.ApiServicesSopir;
|
||||
import com.example.travelapps.sopir.MapsSopirActivity;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class HomeFragment extends Fragment implements OnItemTiketClickListener {
|
||||
|
||||
private FragmentHome2Binding binding;
|
||||
private List<TiketData> tiketDataList;
|
||||
private TiketAdapter adapter;
|
||||
String idSopir = "";
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
HomeViewModel homeViewModel =
|
||||
new ViewModelProvider(this).get(HomeViewModel.class);
|
||||
|
||||
binding = FragmentHome2Binding.inflate(inflater, container, false);
|
||||
View root = binding.getRoot();
|
||||
RecyclerView recyclerView = binding.rvPerjalanan;
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
|
||||
tiketDataList = new ArrayList<>();
|
||||
adapter = new TiketAdapter(getContext(), tiketDataList, this, "0");
|
||||
recyclerView.setAdapter(adapter);
|
||||
SharedPreferences preferences = getActivity().getSharedPreferences("myPrefs", MODE_PRIVATE);
|
||||
idSopir = preferences.getString("id", "");
|
||||
getPerjalananSopirFromApi(idSopir);
|
||||
ApiServicesSopir.getSopirData(getContext(), idSopir, new ApiServicesSopir.SopirResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(Sopir sopir) {
|
||||
TextView tvNama = binding.tvNama;
|
||||
tvNama.setText(sopir.getNamaLengkap());
|
||||
TextView tvSim = binding.tvSim;
|
||||
tvSim.setText(sopir.getNoSim());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
|
||||
}
|
||||
});
|
||||
return root;
|
||||
}
|
||||
|
||||
private void getPerjalananSopirFromApi(String idSopir) {
|
||||
Date currentDate = Calendar.getInstance().getTime();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String currentDateStr = sdf.format(currentDate);
|
||||
ApiServicesSopir.getPerjalananSopirNow(getContext(), idSopir, new ApiServicesSopir.PerjalananNowResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(List<TiketData> tiketDataListResponse) {
|
||||
tiketDataList.clear();
|
||||
tiketDataList.addAll(tiketDataListResponse);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
// Toast.makeText(getContext(), "Error: " + message, Toast.LENGTH_SHORT).show();
|
||||
Log.e("HomeFragmentSopir", "Error: " + message);
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
binding = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(TiketData tiketData) {
|
||||
Intent i = new Intent(getContext(), MapsSopirActivity.class);
|
||||
i.putExtra("id", idSopir);
|
||||
i.putExtra("tiket", tiketData);
|
||||
startActivity(i);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.example.travelapps.sopir.ui.home;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
public class HomeViewModel extends ViewModel {
|
||||
|
||||
private final MutableLiveData<String> mText;
|
||||
|
||||
public HomeViewModel() {
|
||||
mText = new MutableLiveData<>();
|
||||
mText.setValue("This is home fragment");
|
||||
}
|
||||
|
||||
public LiveData<String> getText() {
|
||||
return mText;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package com.example.travelapps.sopir.ui.notifications;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.example.travelapps.pelanggan.AboutActivity;
|
||||
import com.example.travelapps.LoginActivity;
|
||||
import com.example.travelapps.Model.Sopir;
|
||||
import com.example.travelapps.pelanggan.ProfileActivity;
|
||||
import com.example.travelapps.databinding.FragmentNotifications2Binding;
|
||||
import com.example.travelapps.sopir.ApiServicesSopir;
|
||||
|
||||
|
||||
public class NotificationsFragment extends Fragment {
|
||||
|
||||
private FragmentNotifications2Binding binding;
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
NotificationsViewModel notificationsViewModel =
|
||||
new ViewModelProvider(this).get(NotificationsViewModel.class);
|
||||
|
||||
binding = FragmentNotifications2Binding.inflate(inflater, container, false);
|
||||
View root = binding.getRoot();
|
||||
LinearLayout about = binding.about;
|
||||
about.setOnClickListener(view -> {
|
||||
Intent i = new Intent(getActivity(), AboutActivity.class);
|
||||
startActivity(i);
|
||||
});
|
||||
LinearLayout logout = binding.logout;
|
||||
logout.setOnClickListener(
|
||||
view -> {
|
||||
SharedPreferences.Editor editor = getActivity().getSharedPreferences("myPrefs", MODE_PRIVATE).edit();
|
||||
editor.remove("isLoginSopir");
|
||||
editor.remove("id");
|
||||
editor.apply();
|
||||
Intent intent = new Intent(getActivity(), LoginActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); // Clear activity stack
|
||||
startActivity(intent);
|
||||
requireActivity().finish();
|
||||
}
|
||||
);
|
||||
|
||||
RelativeLayout relativeLayout = binding.profileSection;
|
||||
relativeLayout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(getActivity(), ProfileActivity.class);
|
||||
intent.putExtra("role", "sopir");
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
SharedPreferences preferences = requireActivity().getSharedPreferences("myPrefs", MODE_PRIVATE);
|
||||
String token = preferences.getString("id", "");
|
||||
ApiServicesSopir.getSopirData(getContext(), token, new ApiServicesSopir.SopirResponseListener() {
|
||||
@Override
|
||||
public void onSuccess(Sopir sopir) {
|
||||
TextView tvNama = binding.userName;
|
||||
tvNama.setText(sopir.getNamaLengkap());
|
||||
TextView tvNickname = binding.profileImage;
|
||||
String twoInitials = sopir.getNamaLengkap().substring(0, 2);
|
||||
twoInitials = twoInitials.toUpperCase();
|
||||
tvNickname.setText(twoInitials);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
binding = null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.example.travelapps.sopir.ui.notifications;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
public class NotificationsViewModel extends ViewModel {
|
||||
|
||||
private final MutableLiveData<String> mText;
|
||||
|
||||
public NotificationsViewModel() {
|
||||
mText = new MutableLiveData<>();
|
||||
mText.setValue("This is notifications fragment");
|
||||
}
|
||||
|
||||
public LiveData<String> getText() {
|
||||
return mText;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
Binary file not shown.
After Width: | Height: | Size: 60 KiB |
Binary file not shown.
After Width: | Height: | Size: 205 KiB |
Binary file not shown.
After Width: | Height: | Size: 166 KiB |
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- State when item is selected -->
|
||||
<item android:color="@color/btn" android:state_checked="true" />
|
||||
|
||||
<!-- Default state -->
|
||||
<item android:color="@color/bottom" />
|
||||
</selector>
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/btn"/>
|
||||
<corners android:radius="15dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="5dp"
|
||||
android:color="@color/btn" />
|
||||
<corners android:radius="20dp" />
|
||||
</shape>
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
<solid android:color="@color/btn"/> <!-- Ganti dengan warna yang Anda inginkan -->
|
||||
</shape>
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="@color/btn"/>
|
||||
<corners
|
||||
android:radius="10dp"/>
|
||||
</shape>
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="@color/btn"/>
|
||||
<corners
|
||||
android:radius="10dp"/>
|
||||
<solid
|
||||
android:color="@color/white"/>
|
||||
</shape>
|
|
@ -0,0 +1,14 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="302dp"
|
||||
android:height="57dp"
|
||||
android:viewportWidth="302"
|
||||
android:viewportHeight="57">
|
||||
<path
|
||||
android:pathData="M106,6H162H286C294.284,6 301,12.716 301,21V41C301,49.284 294.284,56 286,56H16C7.716,56 1,49.284 1,41V21C1,12.716 7.716,6 16,6H20.5"
|
||||
android:strokeWidth="1.5"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#3469A7"/>
|
||||
<path
|
||||
android:pathData="M31.995,9H33.051L30.29,1.377H29.135L26.363,9H27.419L28.035,7.295H31.379L31.995,9ZM31.093,6.481H28.321L29.707,2.609L31.093,6.481ZM34.314,9H35.315V0.86H34.314V9ZM36.702,5.964C36.702,7.834 37.945,9.099 39.551,9.099C40.662,9.099 41.443,8.527 41.806,7.878V9H42.818V2.972H41.806V4.072C41.454,3.445 40.684,2.873 39.562,2.873C37.945,2.873 36.702,4.083 36.702,5.964ZM41.806,5.975C41.806,7.394 40.86,8.219 39.76,8.219C38.66,8.219 37.725,7.383 37.725,5.964C37.725,4.545 38.66,3.742 39.76,3.742C40.86,3.742 41.806,4.578 41.806,5.975ZM53.266,9H54.256V5.447C54.256,3.72 53.189,2.862 51.814,2.862C50.89,2.862 50.032,3.335 49.68,4.204C49.284,3.302 48.459,2.862 47.469,2.862C46.677,2.862 45.962,3.203 45.566,3.841V2.972H44.565V9H45.566V5.678C45.566,4.38 46.259,3.731 47.271,3.731C48.261,3.731 48.921,4.358 48.921,5.59V9H49.911V5.678C49.911,4.38 50.604,3.731 51.616,3.731C52.606,3.731 53.266,4.358 53.266,5.59V9ZM55.579,5.964C55.579,7.834 56.822,9.099 58.428,9.099C59.539,9.099 60.32,8.527 60.683,7.878V9H61.695V2.972H60.683V4.072C60.331,3.445 59.561,2.873 58.439,2.873C56.822,2.873 55.579,4.083 55.579,5.964ZM60.683,5.975C60.683,7.394 59.737,8.219 58.637,8.219C57.537,8.219 56.602,7.383 56.602,5.964C56.602,4.545 57.537,3.742 58.637,3.742C59.737,3.742 60.683,4.578 60.683,5.975ZM63.661,7.35C63.661,8.56 64.266,9 65.333,9H66.235V8.153H65.498C64.882,8.153 64.662,7.944 64.662,7.35V3.797H66.235V2.972H64.662V1.454H63.661V2.972H62.88V3.797H63.661V7.35ZM74.616,1.322H70.491V9H74.616V8.175H71.492V5.535H74.286V4.71H71.492V2.147H74.616V1.322ZM84.886,9H85.876V5.447C85.876,3.72 84.809,2.862 83.434,2.862C82.51,2.862 81.652,3.335 81.3,4.204C80.904,3.302 80.079,2.862 79.089,2.862C78.297,2.862 77.582,3.203 77.186,3.841V2.972H76.185V9H77.186V5.678C77.186,4.38 77.879,3.731 78.891,3.731C79.881,3.731 80.541,4.358 80.541,5.59V9H81.531V5.678C81.531,4.38 82.224,3.731 83.236,3.731C84.226,3.731 84.886,4.358 84.886,5.59V9ZM87.199,5.964C87.199,7.834 88.442,9.099 90.048,9.099C91.159,9.099 91.94,8.527 92.303,7.878V9H93.315V2.972H92.303V4.072C91.951,3.445 91.181,2.873 90.059,2.873C88.442,2.873 87.199,4.083 87.199,5.964ZM92.303,5.975C92.303,7.394 91.357,8.219 90.257,8.219C89.157,8.219 88.222,7.383 88.222,5.964C88.222,4.545 89.157,3.742 90.257,3.742C91.357,3.742 92.303,4.578 92.303,5.975ZM95.062,9H96.063V2.972H95.062V9ZM95.579,1.993C95.942,1.993 96.239,1.696 96.239,1.311C96.239,0.926 95.942,0.629 95.579,0.629C95.194,0.629 94.897,0.926 94.897,1.311C94.897,1.696 95.194,1.993 95.579,1.993ZM97.824,9H98.825V0.86H97.824V9Z"
|
||||
android:fillColor="#678EBD"/>
|
||||
</vector>
|
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#000000"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-6h2v6zM13,9h-2L11,7h2v2z"/>
|
||||
</vector>
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#000000"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M19,18l2,1V3c0,-1.1 -0.9,-2 -2,-2H8.99C7.89,1 7,1.9 7,3h10c1.1,0 2,0.9 2,2v13zM15,5H5c-1.1,0 -2,0.9 -2,2v16l7,-3 7,3V7c0,-1.1 -0.9,-2 -2,-2z"/>
|
||||
</vector>
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:autoMirrored="true" android:height="24dp"
|
||||
android:tint="#000000" android:viewportHeight="24"
|
||||
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
|
||||
</vector>
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:autoMirrored="true" android:height="24dp"
|
||||
android:tint="#000000" android:viewportHeight="24"
|
||||
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M8.59,16.59L13.17,12 8.59,7.41 10,6l6,6 -6,6 -1.41,-1.41z"/>
|
||||
</vector>
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#1E3D59"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M17.77,3.77l-1.77,-1.77l-10,10l10,10l1.77,-1.77l-8.23,-8.23z"/>
|
||||
</vector>
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M17.77,3.77l-1.77,-1.77l-10,10l10,10l1.77,-1.77l-8.23,-8.23z"/>
|
||||
</vector>
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#1E3D59"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M9,11L7,11v2h2v-2zM13,11h-2v2h2v-2zM17,11h-2v2h2v-2zM19,4h-1L18,2h-2v2L8,4L8,2L6,2v2L5,4c-1.11,0 -1.99,0.9 -1.99,2L3,20c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,6c0,-1.1 -0.9,-2 -2,-2zM19,20L5,20L5,9h14v11z"/>
|
||||
</vector>
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#FF0000"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M12,2C8.13,2 5,5.13 5,9c0,5.25 7,13 7,13s7,-7.75 7,-13c0,-3.87 -3.13,-7 -7,-7zM12,11.5c-1.38,0 -2.5,-1.12 -2.5,-2.5s1.12,-2.5 2.5,-2.5 2.5,1.12 2.5,2.5 -1.12,2.5 -2.5,2.5z"/>
|
||||
</vector>
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#000000"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.89,2 2,2zM18,16v-5c0,-3.07 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.63,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2z"/>
|
||||
</vector>
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#000000"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M12.65,10C11.83,7.67 9.61,6 7,6c-3.31,0 -6,2.69 -6,6s2.69,6 6,6c2.61,0 4.83,-1.67 5.65,-4H17v4h4v-4h2v-4H12.65zM7,14c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2z"/>
|
||||
</vector>
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M3,13h8L11,3L3,3v10zM3,21h8v-6L3,15v6zM13,21h8L21,11h-8v10zM13,3v6h8L21,3h-8z" />
|
||||
</vector>
|
|
@ -0,0 +1,6 @@
|
|||
<vector android:height="24dp" android:tint="#000000"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M6.41,6l-1.41,1.41l4.58,4.59l-4.58,4.59l1.41,1.41l6,-6z"/>
|
||||
<path android:fillColor="@android:color/white" android:pathData="M13,6l-1.41,1.41l4.58,4.59l-4.58,4.59l1.41,1.41l6,-6z"/>
|
||||
</vector>
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#000000"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z"/>
|
||||
</vector>
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#000000"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z"/>
|
||||
</vector>
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z" />
|
||||
</vector>
|
|
@ -0,0 +1,170 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:autoMirrored="true" android:height="24dp"
|
||||
android:tint="#000000" android:viewportHeight="24"
|
||||
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M17,7l-1.41,1.41L18.17,11H8v2h10.17l-2.58,2.58L17,17l5,-5zM4,5h8V3H4c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h8v-2H4V5z"/>
|
||||
</vector>
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#000000"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.89,2 2,2zM18,16v-5c0,-3.07 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.63,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2z"/>
|
||||
</vector>
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.89,2 2,2zM18,16v-5c0,-3.07 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.63,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2z" />
|
||||
</vector>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue