|
|
@@ -13,6 +13,12 @@ import java.util.ArrayList;
|
|
|
|
|
|
|
|
|
public class MainActivity extends AppCompatActivity {
|
|
|
+ final static int EDIT_PROFILE = 0;
|
|
|
+ final static int NEW_PROFILE = 1;
|
|
|
+ ArrayList<String> profileList = new ArrayList<>();
|
|
|
+ //ArrayAdapter profileAdapter;
|
|
|
+ LazyAdapter profileAdapter;
|
|
|
+ ListView listview;
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
@@ -25,17 +31,16 @@ public class MainActivity extends AppCompatActivity {
|
|
|
@Override
|
|
|
public void onClick(View view) {
|
|
|
Intent i = new Intent(getApplicationContext(), NewEventActivity.class);
|
|
|
- startActivity(i);
|
|
|
+ i.putExtra("MODE", NEW_PROFILE);
|
|
|
+ startActivityForResult(i, NEW_PROFILE);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- ArrayList<String> list = new ArrayList<>();
|
|
|
- list.add("Test1");
|
|
|
- list.add("Test2");
|
|
|
- ArrayAdapter adapter = new ArrayAdapter( this, android.R.layout.simple_list_item_1, list);
|
|
|
+ //profileAdapter = new ArrayAdapter( this, android.R.layout.simple_list_item_1, profileList);
|
|
|
+ profileAdapter = new LazyAdapter(this, profileList);
|
|
|
|
|
|
- ListView listview = (ListView) findViewById(R.id.listview2);
|
|
|
- listview.setAdapter(adapter);
|
|
|
+ listview = (ListView) findViewById(R.id.listview2);
|
|
|
+ listview.setAdapter(profileAdapter);
|
|
|
listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
|
|
|
@Override
|
|
|
@@ -51,4 +56,17 @@ public class MainActivity extends AppCompatActivity {
|
|
|
startService(new Intent(this, MainService.class));
|
|
|
}
|
|
|
|
|
|
-}
|
|
|
+ @Override
|
|
|
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
+ super.onActivityResult(requestCode, resultCode, data);
|
|
|
+ switch (resultCode) {
|
|
|
+ case NEW_PROFILE:
|
|
|
+ Bundle b = data.getExtras();
|
|
|
+ profileList.add(b.getString("title"));
|
|
|
+ profileAdapter.notifyDataSetChanged();
|
|
|
+ Helpers.setListViewHeightBasedOnChildren(listview, 1);
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|