Thursday, May 2, 2024

Ukuran ban dan merek di Indonesia

Ban 185/60 R14

  1. Bridgestone Turanza 185/60 R14
  2. GT Radial Eco 185/60 R14
  3. GT Radial Ecotec 185/60 R14
  4. Dunlop SP Touring R1 185/60 R14
  5. Goodyear Assurance Triplemax 185/60 R14
  6. Goodyear Assurance Triplemax2 185/60 R14
  7. Hankook Kinergy Eco K435 185/60 R14 
  8. Achilles 868 All Seasons - 185/60 R14 82H
  9. Achilles 122 185/60 R14
  10. Accelera Epsilon 185/60 R14 1 arah
  11. BFGoodrich Advantage Touring 185 60 R14 
  12. Falken Sincera SN832i 185/60 R14 
  13. Forceum D 600 185/60 R14
  14. Michelin Energy XM2+ 185/60 R14
  15. Michelin Energy XM2 185/60 R14 
  16. Toyo Tires NanoEnergy 3 (TTM) 185/60 R14
Ban 175/65 R14 *
  1. Bridgestone Ecopia EP 150 175/65 R14
  2. Bridgestone Turanza 175/65 R14
  3. Bridgestone Techno 175/65 R14 
  4. GT Radial Champiro Ecotec 175/65 R14 
  5. GT Radial Champiro Eco 175/65 R14 
  6. Dunlop Enasave EC300+ 175/65 R14
  7. Dunlop SP Touring R1 175/65 R14
  8. Goodyear Assurance Duraplus 2 175/65 R14
  9. Goodyear Assurance Duraplus 175/65 R14 
  10. Goodyear Assurance TripleMax 175/65 R14
  11. Hankook Kinergy Eco2 175/65 R14 
  12. Hankook Kinergy Eco 175/65 R14 
  13. Hankook Optiomo H724 175/65 R14
  14. Achilles All Seasons 868 175/65 R14
  15. Achilles 122 - 175/65 R14 82H
  16. Achilles Platinum 175/65 R14
  17. Accelera Eco Plush 175/65 R14
  18. BFGoodrich Advantage Touring 175/65 R14
  19. Falken Sincera SN832i 175/65 R14
  20. Forceum Ecosa 175/65 R14
  21. Forceum N 300 175/65 R14
  22. Michelin Energy XM2+ 175/65 R14
  23. Michelin Energy XM2 175/65 R14
  24. Toyo Tires NanoEnergy 3 (TTM) 175/65 R14 


Friday, April 26, 2024

Android java: using SQLiteOpenHelper instead Room Library

Using additional Room may increase size of application, means more lines required to executed. I preferred to implement SQLiteOpenHelper rather then using Room Library.

Here is code for extending SQLiteOpenHelper:

package com.dedetok.radiowalkman.mydb;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

/*
 * added 20240319
 * Async task will be done in DB Repository to access database (RUD)
 */

public class MyDBHelper extends SQLiteOpenHelper {

    final static String dbName = "myradiolist"; // db name must final static
    final static int dbversion = 2; // db version must final static

    public MyDBHelper(@Nullable Context appContext) {
        //
        super(appContext, dbName, null, dbversion);
    }

    /*
     * Only called once after creating a new database
     * Will not called if database exist (upgrade version)
     */
    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        //Log.e("dedetok","onCreate"); //debug
        createMyDB(sqLiteDatabase);
    }

    /*
     * Only called once if database exist and version number increase (upgrade)
     */
    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {
        // upgrade from 1 to 2
        //Log.e("dedetok","onUpgrade "+oldVersion+" to "+newVersion); //debug
        if (oldVersion==1) {
            upgradeDBV1toV2(sqLiteDatabase);
        }

    }

    /*
     * version 1
     */
    private void createMyDB(SQLiteDatabase sqLiteDatabase) {
        //Log.e("dedetok","createMyDB"); //debug
        // Main table radiolist
        String sqlCreateRadioList = "CREATE TABLE IF NOT EXISTS "+
                "radiolist ("+
                "countryname TEXT NOT NULL,"+
                "cityname TEXT NOT NULL,"+
                "radiostation TEXT NOT NULL,"+
                "logourl TEXT NOT NULL,"+
                "streamurl TEXT NOT NULL,"+
                "PRIMARY KEY(countryname, cityname, radiostation));";
        sqLiteDatabase.execSQL(sqlCreateRadioList);
        // table radiolistversion only has 1 record and one column
        String sqlCreateRadioListVersion = "CREATE TABLE IF NOT EXISTS "+
                "radiolistversion ("+
                "listversion TEXT NOT NULL,"+
                "PRIMARY KEY(listversion));";
        sqLiteDatabase.execSQL(sqlCreateRadioListVersion);

        //Log.e("dedetok", "create table app_preferences"); //debug
        // 20240422
        upgradeDBV1toV2(sqLiteDatabase);

    }

    /*
     * version 1 to version 2
     */
    private void upgradeDBV1toV2(SQLiteDatabase sqLiteDatabase) {
        //Log.e("dedetok", "upgradeDBV1toV2"); //debug
        // 20240422
        String sqlCreatePreferences = "CREATE TABLE IF NOT EXISTS "+
                "app_preferences ("+
                "pref_key TEXT NOT NULL,"+
                "pref_value TEXT NOT NULL,"+
                "PRIMARY KEY(pref_key));";
        sqLiteDatabase.execSQL(sqlCreatePreferences);
    }

}

 This is java class in Radio Walkman application.

Thursday, April 18, 2024

Java 17 JList using ListModel and JComboBox using BasicComboBoxRenderer to wrap data (hide id)

Source code: 

com.dedetok.tutorialcustomjlist.Person.java

package com.dedetok.tutorialcustomjlist;

public class Person {
    int id;
    String name;
    
    public Person(int id, String name) {
        this.id = id;
        this.name = name;
    }
}

com.dedetok.tutorialcustomjlist.MyListModel.java

package com.dedetok.tutorialcustomjlist;

import java.util.Vector;
import javax.swing.ListModel;
import javax.swing.event.ListDataListener;

public class MyListModel implements ListModel<String> {
    Vector<Person> myData = new Vector<>();

    public MyListModel(Vector<Person> myData) {
        this.myData = myData;
    }
    
    @Override
    public int getSize() {
        return myData.size();
    }

    // to render in JList
    @Override
    public String getElementAt(int index) {
        Person tmpP = myData.get(index);
        return tmpP.name;
    }

    @Override
    public void addListDataListener(ListDataListener l) {
        // TODO Auto-generated method stub
       
    }

    @Override
    public void removeListDataListener(ListDataListener l) {
        // TODO Auto-generated method stub
       
    }

}

com.dedetok.tutorialcustomjlist.MyCBRenderer.java

package com.dedetok.tutorialcustomjlist;

import java.awt.Component;

import javax.swing.JList;
import javax.swing.plaf.basic.BasicComboBoxRenderer;

public class MyCBRenderer extends BasicComboBoxRenderer {

    // to render to JComboBox
    @Override
    public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected,
            boolean cellHasFocus) {
        // TODO Auto-generated method stub
        super.getListCellRendererComponent(list, value, index, isSelected,
            cellHasFocus);
        Person mPerson = (Person) value;
        setText(mPerson.name);
        return this;
    }
}

com.dedetok.tutorialcustomjlist.TutorialJList.java

package com.dedetok.tutorialcustomjlist;

import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.SpringLayout;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.JComboBox;

public class TutorialJList {

    private JFrame frame;

    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    TutorialJList window = new TutorialJList();
                    window.frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * Create the application.
     */
    public TutorialJList() {
        initialize();
    }

    /**
     * Initialize the contents of the frame.
     */
    private void initialize() {
        frame = new JFrame();
        frame.setBounds(100, 100, 450, 300);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        SpringLayout springLayout = new SpringLayout();
        frame.getContentPane().setLayout(springLayout);
       
        Vector<Person> myList = new Vector<>();
        Person tmp = new Person(1,"one");
        myList.add(tmp);
        tmp = new Person(2,"two");
        myList.add(tmp);
        tmp = new Person(3,"Three");
        myList.add(tmp);
       
        MyListModel myDataList = new MyListModel(myList); // implements ListModel<String>
       
        JList<String> list = new JList<>(myDataList);
        list.addListSelectionListener(new ListSelectionListener( ) {

            @Override
            public void valueChanged(ListSelectionEvent e) {
                // TODO Auto-generated method stub
                if (!e.getValueIsAdjusting()) {
                    int selectInt = list.getSelectedIndex();
                    Person tmpP = myDataList.myData.get(selectInt);
                    System.out.println(tmpP.id+" "+tmpP.name);
                }
            }
           
        });


        springLayout.putConstraint(SpringLayout.NORTH, list, 0, SpringLayout.NORTH, frame.getContentPane());
        springLayout.putConstraint(SpringLayout.WEST, list, 0, SpringLayout.WEST, frame.getContentPane());
        springLayout.putConstraint(SpringLayout.EAST, list, 436, SpringLayout.WEST, frame.getContentPane());
        frame.getContentPane().add(list);

        JComboBox<Person> comboBox = new JComboBox<>(myList);
        MyCBRenderer myCBRenderer = new MyCBRenderer();
        comboBox.setRenderer(myCBRenderer);
        ActionListener myAL = new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                // TODO Auto-generated method stub
                Person myPerson = (Person) comboBox.getSelectedItem();
                System.out.println(myPerson.id+" "+myPerson.name);
            }
           
        };
        comboBox.addActionListener(myAL);

        springLayout.putConstraint(SpringLayout.WEST, comboBox, 0, SpringLayout.WEST, list);
        springLayout.putConstraint(SpringLayout.SOUTH, comboBox, 0, SpringLayout.SOUTH, frame.getContentPane());
        frame.getContentPane().add(comboBox);
       
    }
}