|
@@ -1,21 +1,16 @@
|
|
|
package com.example.david.libretasker;
|
|
package com.example.david.libretasker;
|
|
|
|
|
|
|
|
-import android.content.Context;
|
|
|
|
|
-import android.content.Intent;
|
|
|
|
|
-import android.support.v7.app.AppCompatActivity;
|
|
|
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
-import android.view.LayoutInflater;
|
|
|
|
|
|
|
+import android.support.v4.app.FragmentTransaction;
|
|
|
|
|
+import android.support.v7.app.AppCompatActivity;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.widget.AdapterView;
|
|
import android.widget.AdapterView;
|
|
|
import android.widget.ArrayAdapter;
|
|
import android.widget.ArrayAdapter;
|
|
|
-import android.widget.Button;
|
|
|
|
|
-import android.widget.LinearLayout;
|
|
|
|
|
-import android.widget.ListView;
|
|
|
|
|
import android.widget.Spinner;
|
|
import android.widget.Spinner;
|
|
|
|
|
|
|
|
-import com.example.david.libretasker.Actions.Actions;
|
|
|
|
|
|
|
+import com.example.david.libretasker.InputSelector.State;
|
|
|
|
|
+import com.example.david.libretasker.InputSelector.Text;
|
|
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
@@ -23,10 +18,12 @@ public class NewEventActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
super.onCreate(savedInstanceState);
|
|
super.onCreate(savedInstanceState);
|
|
|
setContentView(R.layout.activity_new_event);
|
|
setContentView(R.layout.activity_new_event);
|
|
|
Spinner spinner = (Spinner) findViewById(R.id.spinner);
|
|
Spinner spinner = (Spinner) findViewById(R.id.spinner);
|
|
|
- List<String> l = Arrays.asList("Screen", "Network", "Phone");
|
|
|
|
|
|
|
+ List<String> l = Arrays.asList("Screen", "Time", "Network", "Phone");
|
|
|
final ArrayAdapter<CharSequence> adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, l);
|
|
final ArrayAdapter<CharSequence> adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, l);
|
|
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
|
|
// Apply the adapter to the spinner
|
|
// Apply the adapter to the spinner
|
|
@@ -35,15 +32,58 @@ public class NewEventActivity extends AppCompatActivity {
|
|
|
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
|
@Override
|
|
@Override
|
|
|
public void onItemSelected(AdapterView<?> adapterView, View view, int pos, long id) {
|
|
public void onItemSelected(AdapterView<?> adapterView, View view, int pos, long id) {
|
|
|
- /*
|
|
|
|
|
- //Actions.Launch(getApplicationContext(), "Toast", adapter.getItem(pos));
|
|
|
|
|
- Button b = new Button(getApplicationContext());
|
|
|
|
|
- b.setText(adapter.getItem(pos));
|
|
|
|
|
- //View view = inflater.inflate(R.layout.activity_new_event, null);
|
|
|
|
|
- LinearLayout ll = (LinearLayout) findViewById(R.id.EventFields);
|
|
|
|
|
- ll.addView(b);*/
|
|
|
|
|
- Intent i = new Intent(getApplicationContext(), EventDisplaySettings.class);
|
|
|
|
|
- startActivity(i);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ String[] a;
|
|
|
|
|
+ boolean multi;
|
|
|
|
|
+ if ( adapter.getItem(pos) == null )
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
|
|
|
|
+
|
|
|
|
|
+ if ( adapter.getItem(pos).equals("Screen")) {
|
|
|
|
|
+ a = new String[]{"On", "Off", "Any"};
|
|
|
|
|
+ multi = false;
|
|
|
|
|
+ ft.replace(R.id.your_placeholder, State.newInstance(a,multi,"Screen"));
|
|
|
|
|
+ ft.commit();
|
|
|
|
|
+
|
|
|
|
|
+ } else if ( adapter.getItem(pos).equals("Time")) {
|
|
|
|
|
+ Bundle args = new Bundle();
|
|
|
|
|
+
|
|
|
|
|
+ String[] b = {"Jan", "Feb", "Mar", "April"};
|
|
|
|
|
+ multi = true;
|
|
|
|
|
+
|
|
|
|
|
+ State s2 = new State();
|
|
|
|
|
+ args = new Bundle();
|
|
|
|
|
+ args.putStringArray("elems", b);
|
|
|
|
|
+ args.putBoolean("multi", multi);
|
|
|
|
|
+ args.putString("key", "Months");
|
|
|
|
|
+ s2.setArguments(args);
|
|
|
|
|
+
|
|
|
|
|
+ ft.replace(R.id.your_placeholder, s2, "testtag2");
|
|
|
|
|
+
|
|
|
|
|
+ State s = new State();
|
|
|
|
|
+ a = new String[]{"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
|
|
|
|
|
+ multi = true;
|
|
|
|
|
+ args = new Bundle();
|
|
|
|
|
+ args.putString("key", "Days");
|
|
|
|
|
+ args.putStringArray("elems", a);
|
|
|
|
|
+ args.putBoolean("multi", multi);
|
|
|
|
|
+ s.setArguments(args);
|
|
|
|
|
+
|
|
|
|
|
+ ft.add(R.id.your_placeholder, s, "testtag1");
|
|
|
|
|
+ ft.commit();
|
|
|
|
|
+//#####################################################################################################
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ ft = getSupportFragmentManager().beginTransaction();
|
|
|
|
|
+ ft.add(R.id.your_placeholder, Text.newInstance("asd","dsa"));
|
|
|
|
|
+ ft.commit();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ // or ft.add(R.id.your_placeholder, new FooFragment());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -52,30 +92,6 @@ public class NewEventActivity extends AppCompatActivity {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- ArrayList<String> list = new ArrayList<>();
|
|
|
|
|
- list.add("Test1");
|
|
|
|
|
- list.add("Test2");
|
|
|
|
|
- ArrayAdapter ActionsAdapter = new ArrayAdapter( this, android.R.layout.simple_list_item_1, list);
|
|
|
|
|
|
|
|
|
|
- ListView listview = (ListView) findViewById(R.id.ActionsList);
|
|
|
|
|
- listview.setAdapter(ActionsAdapter);
|
|
|
|
|
- listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onItemClick(AdapterView<?> parent, final View view,
|
|
|
|
|
- int position, long id) {
|
|
|
|
|
- final String item = (String) parent.getItemAtPosition(position);
|
|
|
|
|
- view.animate().setDuration(200).alpha(0)
|
|
|
|
|
- .withEndAction(new Runnable() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void run() {
|
|
|
|
|
- //list.remove(item);
|
|
|
|
|
- //ActionsAdapter .notifyDataSetChanged();
|
|
|
|
|
- view.setAlpha(1);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- });
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|