NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

package com.example.kartasemar.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.kartasemar.Model.Keranjang;
import com.example.kartasemar.R;
import com.squareup.picasso.Picasso;

import java.text.NumberFormat;
import java.util.List;
import java.util.Locale;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatButton;
import androidx.recyclerview.widget.RecyclerView;

public class KeranjangAdapter extends RecyclerView.Adapter<KeranjangAdapter.KeranjangViewHolder> {

private Context mCtx;
private List<Keranjang> keranjangList;
private AdapterView.OnItemClickListener cListener;

public KeranjangAdapter(Context mCtx, List<Keranjang> keranjangList){
this.mCtx = mCtx;
this.keranjangList = keranjangList;
}

public interface onItemClickListener {
void onItemClick(int position);

}

public void setOnItemClickListenerC(AdapterView.OnItemClickListener listener) {
cListener = listener;
}

@NonNull
@Override
public KeranjangAdapter.KeranjangViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(mCtx).inflate(R.layout.item_keranjang_layout, parent, false);
return new KeranjangViewHolder(view);
}

private String formatRupiah(Double number){
Locale localeID = new Locale("IND", "ID");
NumberFormat numberFormat = NumberFormat.getCurrencyInstance(localeID);
String formatrupiah = numberFormat.format(number);
String[] split = formatrupiah.split(",");
int length = split[0].length();
return split[0].substring(0,2)+". "+split[0].substring(2, length);
}



@Override
public void onBindViewHolder(@NonNull KeranjangViewHolder holder, int position){
Keranjang keranjang = keranjangList.get(position);

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

holder.nama_produk.setText(keranjang.getNama_produk());
holder.harga_produk.setText(formatRupiah((double) keranjang.getHarga_produk()));
//holder.harga_produk.setText(keranjang.getHarga_produk());
Picasso.get().load("http://gallery-umkm.id/kartasemar/" + keranjang.getGambar_produk()).fit().into(holder.gambar_produk);

}

@Override
public int getItemCount() {
return keranjangList.size();
}

public class KeranjangViewHolder extends RecyclerView.ViewHolder{

TextView nama_produk, toko_produk, harga_produk;
ImageView gambar_produk;
AppCompatButton btn_editorder, btn_continue_order;

public KeranjangViewHolder(@NonNull View itemView) {
super(itemView);

nama_produk = itemView.findViewById(R.id.tvnamaprodukkeranjang);
//toko_produk = itemView.findViewById(R.id.service_waktu);
harga_produk = itemView.findViewById(R.id.tvhargakeranjang);
gambar_produk = itemView.findViewById(R.id.img_keranjang);
//btn_editorder = itemView.findViewById(R.id.btn_edit_order);
//btn_continue_order = itemView.findViewById(R.id.btn_continue_order);

/* itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (cListener != null){
int position = getAdapterPosition();
if (position != RecyclerView.NO_POSITION){
cListener.onItemClick(position);
}
}
}
});

btn_editorder.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (cListener != null){
int position = getAdapterPosition();
if (position != RecyclerView.NO_POSITION) {
cListener.onItemClick(position);
}
}
}
});

btn_continue_order.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Keranjang clickedKeranjang = keranjangList.get(getAdapterPosition());

int id = clickedKeranjang.getId_keranjang();

Call<DefaultResponse> call = RetrofitClient
.getInstance()
.getApi()
.addToOrder(id);

call.enqueue(new Callback<DefaultResponse>() {
@Override
public void onResponse(Call<DefaultResponse> call, Response<DefaultResponse> response) {
if (response.code() == 201){
Toast.makeText(v.getContext(), "Pesanan ditambahkan", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(mCtx, OrderCustomerActivity.class);
mCtx.startActivity(intent);
((KeranjangActivity)mCtx).finish();
} else {
Toast.makeText(v.getContext(),response.message(), Toast.LENGTH_SHORT).show();
}
}

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

}
});
}
});*/
}
}
}
     
 
what is notes.io
 

Notes is a web-based application for online 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 14 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.