NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

package com.example.kartasemar.activity;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextView;

import com.example.kartasemar.Adapter.KeranjangAdapter;
import com.example.kartasemar.DetailProduk;
import com.example.kartasemar.Interface.RetrofitClient;
import com.example.kartasemar.MainActivity;
import com.example.kartasemar.Model.Customer;
import com.example.kartasemar.Model.CustomerKeranjangResponse;
import com.example.kartasemar.Model.Keranjang;
import com.example.kartasemar.R;
import com.example.kartasemar.fragment.AkunFragment;
import com.example.kartasemar.storage.SharedPrefManager;
import com.example.kartasemar.ui.ongkir.OngkirContract;
import com.google.android.material.bottomnavigation.BottomNavigationView;

import java.util.List;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatButton;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class KeranjangActivity extends AppCompatActivity implements KeranjangAdapter.onItemClickListener {

private static final String SHARED_PREF_NAME = "my_shared_preff";
ImageView btn_back, image_kosong;
TextView keranjang_kosong;
AppCompatButton btn_login, btn_edit_order;
ScrollView scrollView3;
RecyclerView mRecyclerView;
KeranjangAdapter adapter;
List<Keranjang> keranjangList;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_keranjang1);

//BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);

btn_back = findViewById(R.id.btn_back);
image_kosong = findViewById(R.id.image_kosong);
keranjang_kosong = findViewById(R.id.keranjang_kosong);
btn_login = findViewById(R.id.btn_login);
btn_edit_order = findViewById(R.id.btn_edit_order);
scrollView3 = findViewById(R.id.scrollView3);
mRecyclerView = findViewById(R.id.recycler_view);

Customer customer = SharedPrefManager.getInstance(this).getCustomer();
//SharedPreferences preferences = getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE);
//String email_customer = preferences.getString("email_customer", null);
String email_customer = "[email protected]";
if (email_customer == null) {
scrollView3.setVisibility(View.GONE);
image_kosong.setVisibility(View.GONE);
keranjang_kosong.setVisibility(View.GONE);
btn_login.setVisibility(View.VISIBLE);
} else {
scrollView3.setVisibility(View.VISIBLE);
btn_login.setVisibility(View.GONE);
image_kosong.setVisibility(View.GONE);
keranjang_kosong.setVisibility(View.GONE);

Call<CustomerKeranjangResponse> call = RetrofitClient.getInstance().getApi().getKeranjangCustomer(customer.getId_customer());

call.enqueue(new Callback<CustomerKeranjangResponse>() {
@Override
public void onResponse(Call<CustomerKeranjangResponse> call, Response<CustomerKeranjangResponse> response) {
try {
keranjangList = response.body().getData();

adapter = new KeranjangAdapter(KeranjangActivity.this, keranjangList);
mRecyclerView.setAdapter(adapter);
adapter.setOnItemClickListenerC(KeranjangActivity.this::onItemClick);
image_kosong.setVisibility(View.GONE);
keranjang_kosong.setVisibility(View.GONE);
} catch (NullPointerException e) {
mRecyclerView.setVisibility(View.GONE);
image_kosong.setVisibility(View.VISIBLE);
keranjang_kosong.setVisibility(View.VISIBLE);
}

}

@Override
public void onFailure(Call<CustomerKeranjangResponse> call, Throwable t) {

}
});

}

mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));

//bottomNavigationView.setSelectedItemId(R.id.cart);
//bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
// @Override
// public boolean onNavigationItemSelected(@NonNull MenuItem item) {
// switch (item.getItemId()) {
// case R.id.main:
// startActivity(new Intent(getApplicationContext(), MainActivity.class));
// overridePendingTransition(0, 0);
// return true;
// case R.id.cart:
// return true;
// case R.id.account:
// startActivity(new Intent(getApplicationContext(), AkunFragment.class));
// overridePendingTransition(0, 0);
// return true;
// }
// return false;
// }
//});

btn_back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});

btn_login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent login = new Intent(KeranjangActivity.this, LoginActivity.class);
startActivity(login);
finish();
}
});
}

private void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
}

@Override
public void onItemClick(int position) {
Keranjang clickedKeranjang = keranjangList.get(position);

int id_keranjang = clickedKeranjang.getId_keranjang();
int id_customer = clickedKeranjang.getId_customer();
String nama_customer = clickedKeranjang.getNama_customer();
int id_produk = clickedKeranjang.getId_produk();
String nama_produk = clickedKeranjang.getNama_produk();
String toko_produk = clickedKeranjang.getToko_produk();
String deskripsi_produk = clickedKeranjang.getDeskripsi_produk();
int harga_produk = clickedKeranjang.getHarga_produk();
String gambar_produk = clickedKeranjang.getGambar_produk();

Intent data = new Intent(this, DetailProduk.class);

data.putExtra("id_keranjang", id_keranjang);
data.putExtra("nama_produk", nama_produk);
data.putExtra("id_customer", id_customer);
data.putExtra("nama_customer", nama_customer);
data.putExtra("id_produk", id_produk);
data.putExtra("toko_produk", toko_produk);
data.putExtra("deskripsi_produk", deskripsi_produk);
data.putExtra("harga_produk", harga_produk);
data.putExtra("gambar_produk",gambar_produk);

startActivity(data);

}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.