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");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user