NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

package com.example.AppPenjualan;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SearchView;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.Toast;

import com.synnapps.carouselview.CarouselView;
import com.synnapps.carouselview.ImageListener;

import java.text.NumberFormat;
import java.util.ArrayList;

public class UserActivity extends AppCompatActivity {

private CardBarangAdapter cardBarangAdapter;

RecyclerView recyclerView;
ArrayList<Barang> list = new ArrayList<>();
CarouselView carouselView;

int[] sampleImages = {R.drawable.ayam1, R.drawable.ayam2, R.drawable.ayam3};

public static SQLiteHelper mSQLiteHelper;

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

carouselView = (CarouselView) findViewById(R.id.carouselView);
carouselView.setPageCount(sampleImages.length);

carouselView.setImageListener(imageListener);

mSQLiteHelper = new SQLiteHelper(this, "RECORDDB2.sqlite", null, 1);

recyclerView= findViewById(R.id.recycler);
recyclerView.setHasFixedSize(true);

Cursor cursor = UserActivity.mSQLiteHelper.getData("SELECT * FROM BARANG");
list.clear();

NumberFormat nf = NumberFormat.getNumberInstance();
nf.setMaximumFractionDigits(0);

while (cursor.moveToNext()){
String kode = cursor.getString(0);
String nama = cursor.getString(1);
String satuan = cursor.getString(2);
String jumlah = cursor.getString(3);
String harga = nf.format(cursor.getDouble(4));
byte[] image = cursor.getBlob(5);
String deskripsi = cursor.getString(4);
//add to list
list.add(new Barang(kode, nama, satuan, jumlah, harga, image,deskripsi));
}


if (list.size()==0){
//if there is no record in table of database which means listview is empty
Toast.makeText(this, "Record Tidak Ditemukan..", Toast.LENGTH_LONG).show();
}


showRecyclerList();
}

//menampilkan recyclerview
private void showRecyclerList(){
RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(this, 2);
recyclerView.setLayoutManager(mLayoutManager);
cardBarangAdapter = new CardBarangAdapter(list);
recyclerView.setAdapter(cardBarangAdapter);

cardBarangAdapter.setOnItemClickCallback(new CardBarangAdapter.OnItemClickCallback() {
@Override
public void onItemClicked(Barang data) {
showSelectedBarang(data);
}
});
}

//ketika item recycler di klik
private void showSelectedBarang(Barang barang) {
Toast.makeText(this, barang.getItemId(), Toast.LENGTH_SHORT).show();
Intent intent = new Intent(UserActivity.this, UserPenjualanActivity.class);
intent.putExtra("kodeBarang",barang.getItemId());

startActivity(intent);
}

//tombol search di action bar
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.example_menu, menu);

MenuItem searchItem = menu.findItem(R.id.action_search);

androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}

@Override
public boolean onQueryTextChange(String newText) {
cardBarangAdapter.getFilter().filter(newText);
return false;
}
});

return true;
}
ImageListener imageListener = new ImageListener() {
@Override
public void setImageForPosition(int position, ImageView imageView) {
imageView.setImageResource(sampleImages[position]);
}
};

}
     
 
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.