| | |
| | | package com.example.agvcontroller; |
| | | |
| | | import android.content.Intent; |
| | | import android.annotation.SuppressLint; |
| | | import android.content.SharedPreferences; |
| | | import android.os.Bundle; |
| | | import android.util.Log; |
| | |
| | | public class EditeActivity extends AppCompatActivity { |
| | | |
| | | private RecyclerView recyclerView; |
| | | private List<Item> items; |
| | | private List<AGVCar> items; |
| | | private EditeAdapter adapter; |
| | | private SharedPreferences sharedPreferences; |
| | | private AppCompatImageButton addItem; |
| | | private Button confirm; |
| | | |
| | | @SuppressLint("WrongViewCast") |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | |
| | | @Override |
| | | public void onClick(View v) { |
| | | |
| | | items.add(new Item("", "", 0, "", 0)); |
| | | items.add(new AGVCar("", "", 0, "", 0)); |
| | | adapter.notifyDataSetChanged(); |
| | | Log.d("items", items.toString()); |
| | | } |
| | |
| | | editor.apply(); |
| | | } |
| | | |
| | | private List<Item> loadItemsFromSharedPreferences() { |
| | | private List<AGVCar> loadItemsFromSharedPreferences() { |
| | | Gson gson = new Gson(); |
| | | String json = sharedPreferences.getString("items", null); |
| | | if (json != null) { |
| | | Type type = new TypeToken<List<Item>>(){}.getType(); |
| | | Type type = new TypeToken<List<AGVCar>>(){}.getType(); |
| | | return gson.fromJson(json, type); |
| | | } |
| | | return new ArrayList<>(); |