improve button lainnya
This commit is contained in:
parent
c55af6141f
commit
a07e7a99ac
@ -2,31 +2,64 @@ package com.example.bdkipoc;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private boolean isExpanded = false;
|
||||
private CardView cardBantuan, cardInfoToko;
|
||||
private MaterialButton btnLainnya;
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
if (hasFocus) {
|
||||
getWindow().getDecorView().setSystemUiVisibility(
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
| View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
|
||||
}
|
||||
}
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
// Enable hardware acceleration for smoother scrolling
|
||||
getWindow().setFlags(
|
||||
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
|
||||
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED
|
||||
);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
EdgeToEdge.enable(this);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
// Ganti findViewById(R.id.main) dengan findViewById(R.id.merchant_card)
|
||||
// atau root layout yang ada di XML
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(android.R.id.content), (v, insets) -> {
|
||||
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||
return insets;
|
||||
});
|
||||
|
||||
// Initialize views
|
||||
cardBantuan = findViewById(R.id.card_bantuan);
|
||||
cardInfoToko = findViewById(R.id.card_info_toko);
|
||||
btnLainnya = findViewById(R.id.btn_lainnya);
|
||||
|
||||
// Setup menu listeners
|
||||
setupMenuListeners();
|
||||
}
|
||||
@ -42,40 +75,72 @@ public class MainActivity extends AppCompatActivity {
|
||||
R.id.card_cetak_ulang,
|
||||
R.id.card_refund,
|
||||
R.id.card_settlement,
|
||||
R.id.card_histori
|
||||
R.id.card_histori,
|
||||
R.id.card_bantuan,
|
||||
R.id.card_info_toko
|
||||
};
|
||||
|
||||
// Cara 1: Menggunakan loop dengan if-else
|
||||
for (int cardId : cardIds) {
|
||||
CardView cardView = findViewById(cardId);
|
||||
cardView.setOnClickListener(v -> {
|
||||
if (cardId == R.id.card_kartu_kredit) {
|
||||
// Arahkan ke PaymentActivity untuk Transfer
|
||||
startActivity(new Intent(MainActivity.this, PaymentActivity.class));
|
||||
} else if (cardId == R.id.card_kartu_debit) {
|
||||
Toast.makeText(this, "Kartu Debit Diklik", Toast.LENGTH_SHORT).show();
|
||||
} else if (cardId == R.id.card_qris) {
|
||||
// Arahkan ke TransactionActivity untuk QRIS
|
||||
startActivity(new Intent(MainActivity.this, TransactionActivity.class));
|
||||
} else if (cardId == R.id.card_transfer) {
|
||||
Toast.makeText(this, "Transfer Diklik", Toast.LENGTH_SHORT).show();
|
||||
} else if (cardId == R.id.card_uang_elektronik) {
|
||||
Toast.makeText(this, "Uang Elektronik Diklik", Toast.LENGTH_SHORT).show();
|
||||
} else if (cardId == R.id.card_cetak_ulang) {
|
||||
Toast.makeText(this, "Cetak Ulang Diklik", Toast.LENGTH_SHORT).show();
|
||||
} else if (cardId == R.id.card_refund) {
|
||||
Toast.makeText(this, "Refund Diklik", Toast.LENGTH_SHORT).show();
|
||||
} else if (cardId == R.id.card_settlement) {
|
||||
Toast.makeText(this, "Settlement Diklik", Toast.LENGTH_SHORT).show();
|
||||
} else if (cardId == R.id.card_histori) {
|
||||
Toast.makeText(this, "Histori Diklik", Toast.LENGTH_SHORT).show();
|
||||
} else if (cardId == R.id.card_bantuan) {
|
||||
Toast.makeText(this, "Bantuan Diklik", Toast.LENGTH_SHORT).show();
|
||||
} else if (cardId == R.id.card_info_toko) {
|
||||
Toast.makeText(this, "Info Toko Diklik", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
// Simplified version - just show the card ID
|
||||
Toast.makeText(this, "Menu Diklik: " + cardId, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Lainnya button listener
|
||||
findViewById(R.id.btn_lainnya).setOnClickListener(v ->
|
||||
Toast.makeText(this, "Lainnya Diklik", Toast.LENGTH_SHORT).show()
|
||||
);
|
||||
btnLainnya.setOnClickListener(v -> {
|
||||
isExpanded = !isExpanded;
|
||||
|
||||
if (isExpanded) {
|
||||
// Show additional menus with animation
|
||||
cardBantuan.setVisibility(View.VISIBLE);
|
||||
cardInfoToko.setVisibility(View.VISIBLE);
|
||||
cardBantuan.setAlpha(0f);
|
||||
cardInfoToko.setAlpha(0f);
|
||||
|
||||
cardBantuan.animate()
|
||||
.alpha(1f)
|
||||
.setDuration(300)
|
||||
.setInterpolator(new AccelerateDecelerateInterpolator())
|
||||
.start();
|
||||
|
||||
cardInfoToko.animate()
|
||||
.alpha(1f)
|
||||
.setDuration(300)
|
||||
.setInterpolator(new AccelerateDecelerateInterpolator())
|
||||
.start();
|
||||
|
||||
btnLainnya.setText("Tampilkan Lebih Sedikit");
|
||||
} else {
|
||||
// Hide additional menus with animation
|
||||
cardBantuan.animate()
|
||||
.alpha(0f)
|
||||
.setDuration(300)
|
||||
.setInterpolator(new AccelerateDecelerateInterpolator())
|
||||
.withEndAction(() -> cardBantuan.setVisibility(View.GONE))
|
||||
.start();
|
||||
|
||||
cardInfoToko.animate()
|
||||
.alpha(0f)
|
||||
.setDuration(300)
|
||||
.setInterpolator(new AccelerateDecelerateInterpolator())
|
||||
.withEndAction(() -> cardInfoToko.setVisibility(View.GONE))
|
||||
.start();
|
||||
|
||||
btnLainnya.setText("Lainnya");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,8 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true"
|
||||
android:overScrollMode="never"
|
||||
android:scrollbars="none"
|
||||
android:background="#FFFFFF">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#FFFFFF"
|
||||
@ -413,6 +421,76 @@
|
||||
style="@style/MenuCardTitle"/>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<!-- Bantuan -->
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/card_bantuan"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_columnWeight="1"
|
||||
android:layout_rowWeight="1"
|
||||
android:layout_margin="8dp"
|
||||
android:visibility="gone"
|
||||
app:cardCornerRadius="12dp"
|
||||
app:cardElevation="2dp"
|
||||
app:cardBackgroundColor="#F3F4F3">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:padding="16dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:src="@drawable/ic_qr_code"
|
||||
android:tint="#E31937"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Bantuan"
|
||||
style="@style/MenuCardTitle"/>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<!-- Info Toko -->
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/card_info_toko"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_columnWeight="1"
|
||||
android:layout_rowWeight="1"
|
||||
android:layout_margin="8dp"
|
||||
android:visibility="gone"
|
||||
app:cardCornerRadius="12dp"
|
||||
app:cardElevation="2dp"
|
||||
app:cardBackgroundColor="#F3F4F3">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:padding="16dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:src="@drawable/ic_qr_code"
|
||||
android:tint="#E31937"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Info Toko"
|
||||
style="@style/MenuCardTitle"/>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</GridLayout>
|
||||
|
||||
<!-- Lainnya Button -->
|
||||
@ -438,13 +516,16 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginBottom="24dp"
|
||||
app:cardCornerRadius="12dp"
|
||||
app:cardBackgroundColor="#E31937"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/btn_lainnya">
|
||||
app:layout_constraintTop_toBottomOf="@id/btn_lainnya"
|
||||
app:layout_constraintVertical_bias="0">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/scan_bayar_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
@ -482,4 +563,6 @@
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</ScrollView>
|
Loading…
x
Reference in New Issue
Block a user