Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.student.mysterygame;
- public class logView extends Fragment implements AbsListView.OnItemClickListener {
- AbsListView mListView;
- EditText testField;
- String mmMessage;
- String name;
- String date;
- boolean hasEnteredPassword;
- public static ArrayAdapter<LogItems> mArrayAdapter;
- public static ArrayList<LogItems> mArrayList;
- private MainActivity mmActivity;
- public static logView newInstance() {
- logView fragment = new logView();;
- return fragment;
- }
- public logView() {
- // Required empty public constructor
- }
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- mArrayList = new ArrayList<LogItems>();
- mArrayAdapter = new textLogAdpater(getActivity(), mArrayList);
- }
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- View view = inflater.inflate(R.layout.fragment_log_view, container, false);
- //testField.setOnEditorActionListener(new onEditorDoneInteraction());
- return view;
- }
- @Override
- public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
- mListView = getView().findViewById(R.id.logView);
- mListView.setAdapter(mArrayAdapter);
- mListView.setOnItemClickListener(this);
- testField = getView().findViewById(R.id.editText);
- Button sendButton = getView().findViewById(R.id.sendButton);
- mmActivity = new MainActivity();
- name = "You";
- date = "09/05/2022";
- sendButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Log.d("Send Button", "Creating a new Log Entry.");
- mmMessage = String.valueOf(testField.getText());
- LogItems newEntry = new LogItems(name, date, mmMessage);
- mArrayAdapter.add(newEntry);
- mArrayAdapter.notifyDataSetChanged();
- if(!hasEnteredPassword){
- if (Objects.equals(mmMessage, "Test")) {
- //UI response is granted
- populateLogOnStartWith("UI", "10/123/2018:", "Checking...");
- final Handler handler = new Handler();
- handler.postDelayed(new Runnable() {
- @Override
- public void run() {
- populateLogOnStartWith("UI", "10/123/2018:", "Access Granted");
- setFriend1Logs();
- }
- }, 1000);
- hasEnteredPassword = true;
- } else {
- populateLogOnStartWith("UI", "10/123/2018:", "checking...");
- final Handler handler = new Handler();
- handler.postDelayed(new Runnable() {
- @Override
- public void run() {
- populateLogOnStartWith("UI", "10/123/2018:", "Access denied! Try Again");
- }
- }, 1000);
- //UI response is denied
- }
- }
- }
- });
- /**
- * ALL POPULATION REQUESTS FOR THE LOG SHOULD BE PUT BELOW THIS COMMENT.
- */
- Log.d("Log Population", "OnCreate called for LogPopulation");
- populateLogOnStartWith("UI", "10/11/2018:", "Connecting to Friend1 Phone....");
- populateLogOnStartWith("UI", "10/11/2018:", "Phone is now Connected");
- populateLogOnStartWith("UI", "10/123/2018:", "Enter Password to access phone:");
- }
- public void setFriend1Logs() {
- Log.d("Log Population", "OnCreate called for LogPopulation");
- populateLogOnStartWith("UI", "10/11/2018:", "blah blah");
- populateLogOnStartWith("UI", "10/11/2018:", "Put Story here");
- populateLogOnStartWith("UI", "10/123/2018:", "I don't know what will come next");
- }
- private void populateLogOnStartWith(String name, String date, String entry) {
- LogItems newEntry = new LogItems(name, date, entry);
- mArrayAdapter.add(newEntry);
- mArrayAdapter.notifyDataSetChanged();
- }
- //---------------------------------------------Save Mechanics----------------------------------------
- @Override
- public void onSaveInstanceState(Bundle savedInstanceState) {
- super.onSaveInstanceState(savedInstanceState);
- }
- @Override
- public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
- }
- package com.example.student.mysterygame;
- //This is a Data set class. This is used to set, store and call a Data Set. in this case
- //The data set contains the logName, logDate and lodEntry.
- /**
- * There is no need to touch this class if you are not adding a data set. this can be ignored
- * for the most part.
- */
- private String logName;
- private String logDate;
- private String logEntry;
- public String getLogName(){return logName;}
- public String getLogDate(){return logDate;}
- public String getLogEntry(){return logEntry;}
- public void setLogName(String LogName){this.logName = LogName;}
- public void setLogDate(String LogDate){this.logDate = LogDate;}
- public void setLogEntry(String logEntry){this.logEntry = logEntry;}
- public LogItems(String name, String date, String logEntry){
- this.logEntry = logEntry;
- this.logName = name;
- this.logDate = date;
- }
Add Comment
Please, Sign In to add comment