Async and skipping frames












0















So I've run into an issue where I have an item that I click in a listview, it does a makes a few extras, and moves on the my next activity. I get an issue where my app goes to a black screen and the Console tells me



I/Choreographer: Skipped 630 frames! The application may be doing too much work on its main thread.



I've tried reading up on Async but I'm not sure how to use it in my code. So I'm posting my Main activity since this happens without interacting with the second activity.






public class MainActivity extends AppCompatActivity {


ListView ListofList;
ArrayList<String> Lists;
ArrayAdapter<String> ListAdapter;
Button button;
ArrayList<String> Subject = new ArrayList<>();
int Size = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

ListofList = findViewById(R.id.LofL);
Lists = new ArrayList<String>();
ListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, Lists);
ListofList.setAdapter(ListAdapter);

button = findViewById(R.id.AddList);
Lists.add("Test");

ListofList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent i = new Intent(getBaseContext(), ItemList.class);
String s = (String) ListofList.getItemAtPosition(position);
i.putExtra("Title", s);
i.putExtra("size", Size);
int a = 0;
for (String t : Subject) {
i.putExtra("Item" + a, t);
a++;
}
startActivityForResult(i, 2);
}
});

button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getBaseContext(), CreateItem.class);
String message = "Please enter the name of the list below.";
i.putExtra("mess", message);
startActivityForResult(i, 1);
}
});



}

@Override
protected void onActivityResult (int requestCode, int resultCode, Intent data) {
Bundle extras = getIntent().getExtras();

if (data == null) {

}
if (data != null) {
if (requestCode == 1) {
String item = (data.getStringExtra("item"));
Lists.add(item);
ListAdapter.notifyDataSetChanged();
}
}

if (requestCode == 2) {
ArrayList<String> subject = new ArrayList<String>();
int i = 0;
assert data != null;
int size = (data.getIntExtra("ListSize", 0));
Size = size;
while (i <= size) {
String item = (data.getStringExtra("item" + i));
subject.add(item);

i++;
}

Subject = subject;
}
}


}





At the request of Ben P.






public class ItemList extends AppCompatActivity {

static ArrayList<String> customItems;
ArrayAdapter<String> adapter;
ListView lvItems;

Button button;
Button button2;

ArrayAdapter<String> trashAdapter;
ArrayList<String> trash;
ListView itemtrash;
static TextView Title;
String Tit;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_item_list);
Title = findViewById(R.id.Title);
//set up Item List
customItems = new ArrayList<String>();
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, customItems);
lvItems = (ListView) findViewById(R.id.lvItems);

//Set up trash List
trash = new ArrayList<String>();
trashAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, trash);
itemtrash = findViewById(R.id.itemtrash);

//Initialize Buttons
button = findViewById(R.id.AddItem);
button2 = findViewById(R.id.ClearTrash);

Bundle extras = getIntent().getExtras();
if (extras != null) {
((TextView)findViewById(R.id.Title)).setText(extras.getString("Title"));
Tit = extras.getString("Title");
int i = 0;
int size = (extras.getInt("size", 0));
while (i <= size) {
String item = (extras.getString("Item" + i));
if (item == null) {
continue;
}
customItems.add(item);
i++;
}
}

//CharSequence Titlefilter = Title.getText();
//lvItems.setTextFilterEnabled(true);
//ItemList.this.adapter.getFilter().filter(Titlefilter);
//adapter.notifyDataSetChanged();


button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getBaseContext(), CreateItem.class);
String message = "Please enter new item below.";
i.putExtra("mess", message);
startActivityForResult(i, 1);
}
});

button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
trashAdapter.clear();
trashAdapter.notifyDataSetChanged();
}
});

lvItems.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String s = adapter.getItem(position);
trashAdapter.add(s);
adapter.remove(s);
assert s != null;
adapter.notifyDataSetChanged();
trashAdapter.notifyDataSetChanged();
}
});

itemtrash.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String s = trashAdapter.getItem(position);
customItems.add(s);
trash.remove(s);
adapter.notifyDataSetChanged();
trashAdapter.notifyDataSetChanged();
}
});
lvItems.setAdapter(adapter);
itemtrash.setAdapter(trashAdapter);
}

@Override
public void onBackPressed() {
Intent i = new Intent();
int a = 0;
for (String s : customItems){
String t = adapter.getItem(a);
i.putExtra("item" + a, t);
a++;
}
int size = customItems.size();
i.putExtra("ListSize", size);
setResult(2, i);
finish();
}

@Override
protected void onActivityResult (int requestCode, int resultCode, Intent data) {

Bundle extras = getIntent().getExtras();
if (data == null) {

}
if (data != null) {
String item = (data.getStringExtra("item"));
String title = Tit;
customItems.add(title + "nn" + item);
adapter.notifyDataSetChanged();

}


}

}












share|improve this question

























  • Seems pretty likely that the problem is in the second activity. Is it loading any data to display after you click on the list item?

    – Ben P.
    Nov 13 '18 at 20:09











  • yes give me a moment to edit it in

    – Cristian Espaillat
    Nov 13 '18 at 20:11











  • Hm, nothing jumps out at me (no network connection or db loading is obvious). If you comment out the whole if (extras != null) block, does the problem go away? Obviously you won't see your items, but this might help verify that loading the items is the slow part.

    – Ben P.
    Nov 13 '18 at 20:16











  • Okay so it does let me get to the ItemList Activity. It was working earlier when the items were two textviews, but I changed it to one textview to be able to use a filter. might that've been the cause?

    – Cristian Espaillat
    Nov 13 '18 at 20:23
















0















So I've run into an issue where I have an item that I click in a listview, it does a makes a few extras, and moves on the my next activity. I get an issue where my app goes to a black screen and the Console tells me



I/Choreographer: Skipped 630 frames! The application may be doing too much work on its main thread.



I've tried reading up on Async but I'm not sure how to use it in my code. So I'm posting my Main activity since this happens without interacting with the second activity.






public class MainActivity extends AppCompatActivity {


ListView ListofList;
ArrayList<String> Lists;
ArrayAdapter<String> ListAdapter;
Button button;
ArrayList<String> Subject = new ArrayList<>();
int Size = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

ListofList = findViewById(R.id.LofL);
Lists = new ArrayList<String>();
ListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, Lists);
ListofList.setAdapter(ListAdapter);

button = findViewById(R.id.AddList);
Lists.add("Test");

ListofList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent i = new Intent(getBaseContext(), ItemList.class);
String s = (String) ListofList.getItemAtPosition(position);
i.putExtra("Title", s);
i.putExtra("size", Size);
int a = 0;
for (String t : Subject) {
i.putExtra("Item" + a, t);
a++;
}
startActivityForResult(i, 2);
}
});

button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getBaseContext(), CreateItem.class);
String message = "Please enter the name of the list below.";
i.putExtra("mess", message);
startActivityForResult(i, 1);
}
});



}

@Override
protected void onActivityResult (int requestCode, int resultCode, Intent data) {
Bundle extras = getIntent().getExtras();

if (data == null) {

}
if (data != null) {
if (requestCode == 1) {
String item = (data.getStringExtra("item"));
Lists.add(item);
ListAdapter.notifyDataSetChanged();
}
}

if (requestCode == 2) {
ArrayList<String> subject = new ArrayList<String>();
int i = 0;
assert data != null;
int size = (data.getIntExtra("ListSize", 0));
Size = size;
while (i <= size) {
String item = (data.getStringExtra("item" + i));
subject.add(item);

i++;
}

Subject = subject;
}
}


}





At the request of Ben P.






public class ItemList extends AppCompatActivity {

static ArrayList<String> customItems;
ArrayAdapter<String> adapter;
ListView lvItems;

Button button;
Button button2;

ArrayAdapter<String> trashAdapter;
ArrayList<String> trash;
ListView itemtrash;
static TextView Title;
String Tit;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_item_list);
Title = findViewById(R.id.Title);
//set up Item List
customItems = new ArrayList<String>();
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, customItems);
lvItems = (ListView) findViewById(R.id.lvItems);

//Set up trash List
trash = new ArrayList<String>();
trashAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, trash);
itemtrash = findViewById(R.id.itemtrash);

//Initialize Buttons
button = findViewById(R.id.AddItem);
button2 = findViewById(R.id.ClearTrash);

Bundle extras = getIntent().getExtras();
if (extras != null) {
((TextView)findViewById(R.id.Title)).setText(extras.getString("Title"));
Tit = extras.getString("Title");
int i = 0;
int size = (extras.getInt("size", 0));
while (i <= size) {
String item = (extras.getString("Item" + i));
if (item == null) {
continue;
}
customItems.add(item);
i++;
}
}

//CharSequence Titlefilter = Title.getText();
//lvItems.setTextFilterEnabled(true);
//ItemList.this.adapter.getFilter().filter(Titlefilter);
//adapter.notifyDataSetChanged();


button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getBaseContext(), CreateItem.class);
String message = "Please enter new item below.";
i.putExtra("mess", message);
startActivityForResult(i, 1);
}
});

button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
trashAdapter.clear();
trashAdapter.notifyDataSetChanged();
}
});

lvItems.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String s = adapter.getItem(position);
trashAdapter.add(s);
adapter.remove(s);
assert s != null;
adapter.notifyDataSetChanged();
trashAdapter.notifyDataSetChanged();
}
});

itemtrash.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String s = trashAdapter.getItem(position);
customItems.add(s);
trash.remove(s);
adapter.notifyDataSetChanged();
trashAdapter.notifyDataSetChanged();
}
});
lvItems.setAdapter(adapter);
itemtrash.setAdapter(trashAdapter);
}

@Override
public void onBackPressed() {
Intent i = new Intent();
int a = 0;
for (String s : customItems){
String t = adapter.getItem(a);
i.putExtra("item" + a, t);
a++;
}
int size = customItems.size();
i.putExtra("ListSize", size);
setResult(2, i);
finish();
}

@Override
protected void onActivityResult (int requestCode, int resultCode, Intent data) {

Bundle extras = getIntent().getExtras();
if (data == null) {

}
if (data != null) {
String item = (data.getStringExtra("item"));
String title = Tit;
customItems.add(title + "nn" + item);
adapter.notifyDataSetChanged();

}


}

}












share|improve this question

























  • Seems pretty likely that the problem is in the second activity. Is it loading any data to display after you click on the list item?

    – Ben P.
    Nov 13 '18 at 20:09











  • yes give me a moment to edit it in

    – Cristian Espaillat
    Nov 13 '18 at 20:11











  • Hm, nothing jumps out at me (no network connection or db loading is obvious). If you comment out the whole if (extras != null) block, does the problem go away? Obviously you won't see your items, but this might help verify that loading the items is the slow part.

    – Ben P.
    Nov 13 '18 at 20:16











  • Okay so it does let me get to the ItemList Activity. It was working earlier when the items were two textviews, but I changed it to one textview to be able to use a filter. might that've been the cause?

    – Cristian Espaillat
    Nov 13 '18 at 20:23














0












0








0








So I've run into an issue where I have an item that I click in a listview, it does a makes a few extras, and moves on the my next activity. I get an issue where my app goes to a black screen and the Console tells me



I/Choreographer: Skipped 630 frames! The application may be doing too much work on its main thread.



I've tried reading up on Async but I'm not sure how to use it in my code. So I'm posting my Main activity since this happens without interacting with the second activity.






public class MainActivity extends AppCompatActivity {


ListView ListofList;
ArrayList<String> Lists;
ArrayAdapter<String> ListAdapter;
Button button;
ArrayList<String> Subject = new ArrayList<>();
int Size = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

ListofList = findViewById(R.id.LofL);
Lists = new ArrayList<String>();
ListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, Lists);
ListofList.setAdapter(ListAdapter);

button = findViewById(R.id.AddList);
Lists.add("Test");

ListofList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent i = new Intent(getBaseContext(), ItemList.class);
String s = (String) ListofList.getItemAtPosition(position);
i.putExtra("Title", s);
i.putExtra("size", Size);
int a = 0;
for (String t : Subject) {
i.putExtra("Item" + a, t);
a++;
}
startActivityForResult(i, 2);
}
});

button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getBaseContext(), CreateItem.class);
String message = "Please enter the name of the list below.";
i.putExtra("mess", message);
startActivityForResult(i, 1);
}
});



}

@Override
protected void onActivityResult (int requestCode, int resultCode, Intent data) {
Bundle extras = getIntent().getExtras();

if (data == null) {

}
if (data != null) {
if (requestCode == 1) {
String item = (data.getStringExtra("item"));
Lists.add(item);
ListAdapter.notifyDataSetChanged();
}
}

if (requestCode == 2) {
ArrayList<String> subject = new ArrayList<String>();
int i = 0;
assert data != null;
int size = (data.getIntExtra("ListSize", 0));
Size = size;
while (i <= size) {
String item = (data.getStringExtra("item" + i));
subject.add(item);

i++;
}

Subject = subject;
}
}


}





At the request of Ben P.






public class ItemList extends AppCompatActivity {

static ArrayList<String> customItems;
ArrayAdapter<String> adapter;
ListView lvItems;

Button button;
Button button2;

ArrayAdapter<String> trashAdapter;
ArrayList<String> trash;
ListView itemtrash;
static TextView Title;
String Tit;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_item_list);
Title = findViewById(R.id.Title);
//set up Item List
customItems = new ArrayList<String>();
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, customItems);
lvItems = (ListView) findViewById(R.id.lvItems);

//Set up trash List
trash = new ArrayList<String>();
trashAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, trash);
itemtrash = findViewById(R.id.itemtrash);

//Initialize Buttons
button = findViewById(R.id.AddItem);
button2 = findViewById(R.id.ClearTrash);

Bundle extras = getIntent().getExtras();
if (extras != null) {
((TextView)findViewById(R.id.Title)).setText(extras.getString("Title"));
Tit = extras.getString("Title");
int i = 0;
int size = (extras.getInt("size", 0));
while (i <= size) {
String item = (extras.getString("Item" + i));
if (item == null) {
continue;
}
customItems.add(item);
i++;
}
}

//CharSequence Titlefilter = Title.getText();
//lvItems.setTextFilterEnabled(true);
//ItemList.this.adapter.getFilter().filter(Titlefilter);
//adapter.notifyDataSetChanged();


button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getBaseContext(), CreateItem.class);
String message = "Please enter new item below.";
i.putExtra("mess", message);
startActivityForResult(i, 1);
}
});

button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
trashAdapter.clear();
trashAdapter.notifyDataSetChanged();
}
});

lvItems.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String s = adapter.getItem(position);
trashAdapter.add(s);
adapter.remove(s);
assert s != null;
adapter.notifyDataSetChanged();
trashAdapter.notifyDataSetChanged();
}
});

itemtrash.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String s = trashAdapter.getItem(position);
customItems.add(s);
trash.remove(s);
adapter.notifyDataSetChanged();
trashAdapter.notifyDataSetChanged();
}
});
lvItems.setAdapter(adapter);
itemtrash.setAdapter(trashAdapter);
}

@Override
public void onBackPressed() {
Intent i = new Intent();
int a = 0;
for (String s : customItems){
String t = adapter.getItem(a);
i.putExtra("item" + a, t);
a++;
}
int size = customItems.size();
i.putExtra("ListSize", size);
setResult(2, i);
finish();
}

@Override
protected void onActivityResult (int requestCode, int resultCode, Intent data) {

Bundle extras = getIntent().getExtras();
if (data == null) {

}
if (data != null) {
String item = (data.getStringExtra("item"));
String title = Tit;
customItems.add(title + "nn" + item);
adapter.notifyDataSetChanged();

}


}

}












share|improve this question
















So I've run into an issue where I have an item that I click in a listview, it does a makes a few extras, and moves on the my next activity. I get an issue where my app goes to a black screen and the Console tells me



I/Choreographer: Skipped 630 frames! The application may be doing too much work on its main thread.



I've tried reading up on Async but I'm not sure how to use it in my code. So I'm posting my Main activity since this happens without interacting with the second activity.






public class MainActivity extends AppCompatActivity {


ListView ListofList;
ArrayList<String> Lists;
ArrayAdapter<String> ListAdapter;
Button button;
ArrayList<String> Subject = new ArrayList<>();
int Size = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

ListofList = findViewById(R.id.LofL);
Lists = new ArrayList<String>();
ListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, Lists);
ListofList.setAdapter(ListAdapter);

button = findViewById(R.id.AddList);
Lists.add("Test");

ListofList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent i = new Intent(getBaseContext(), ItemList.class);
String s = (String) ListofList.getItemAtPosition(position);
i.putExtra("Title", s);
i.putExtra("size", Size);
int a = 0;
for (String t : Subject) {
i.putExtra("Item" + a, t);
a++;
}
startActivityForResult(i, 2);
}
});

button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getBaseContext(), CreateItem.class);
String message = "Please enter the name of the list below.";
i.putExtra("mess", message);
startActivityForResult(i, 1);
}
});



}

@Override
protected void onActivityResult (int requestCode, int resultCode, Intent data) {
Bundle extras = getIntent().getExtras();

if (data == null) {

}
if (data != null) {
if (requestCode == 1) {
String item = (data.getStringExtra("item"));
Lists.add(item);
ListAdapter.notifyDataSetChanged();
}
}

if (requestCode == 2) {
ArrayList<String> subject = new ArrayList<String>();
int i = 0;
assert data != null;
int size = (data.getIntExtra("ListSize", 0));
Size = size;
while (i <= size) {
String item = (data.getStringExtra("item" + i));
subject.add(item);

i++;
}

Subject = subject;
}
}


}





At the request of Ben P.






public class ItemList extends AppCompatActivity {

static ArrayList<String> customItems;
ArrayAdapter<String> adapter;
ListView lvItems;

Button button;
Button button2;

ArrayAdapter<String> trashAdapter;
ArrayList<String> trash;
ListView itemtrash;
static TextView Title;
String Tit;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_item_list);
Title = findViewById(R.id.Title);
//set up Item List
customItems = new ArrayList<String>();
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, customItems);
lvItems = (ListView) findViewById(R.id.lvItems);

//Set up trash List
trash = new ArrayList<String>();
trashAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, trash);
itemtrash = findViewById(R.id.itemtrash);

//Initialize Buttons
button = findViewById(R.id.AddItem);
button2 = findViewById(R.id.ClearTrash);

Bundle extras = getIntent().getExtras();
if (extras != null) {
((TextView)findViewById(R.id.Title)).setText(extras.getString("Title"));
Tit = extras.getString("Title");
int i = 0;
int size = (extras.getInt("size", 0));
while (i <= size) {
String item = (extras.getString("Item" + i));
if (item == null) {
continue;
}
customItems.add(item);
i++;
}
}

//CharSequence Titlefilter = Title.getText();
//lvItems.setTextFilterEnabled(true);
//ItemList.this.adapter.getFilter().filter(Titlefilter);
//adapter.notifyDataSetChanged();


button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getBaseContext(), CreateItem.class);
String message = "Please enter new item below.";
i.putExtra("mess", message);
startActivityForResult(i, 1);
}
});

button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
trashAdapter.clear();
trashAdapter.notifyDataSetChanged();
}
});

lvItems.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String s = adapter.getItem(position);
trashAdapter.add(s);
adapter.remove(s);
assert s != null;
adapter.notifyDataSetChanged();
trashAdapter.notifyDataSetChanged();
}
});

itemtrash.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String s = trashAdapter.getItem(position);
customItems.add(s);
trash.remove(s);
adapter.notifyDataSetChanged();
trashAdapter.notifyDataSetChanged();
}
});
lvItems.setAdapter(adapter);
itemtrash.setAdapter(trashAdapter);
}

@Override
public void onBackPressed() {
Intent i = new Intent();
int a = 0;
for (String s : customItems){
String t = adapter.getItem(a);
i.putExtra("item" + a, t);
a++;
}
int size = customItems.size();
i.putExtra("ListSize", size);
setResult(2, i);
finish();
}

@Override
protected void onActivityResult (int requestCode, int resultCode, Intent data) {

Bundle extras = getIntent().getExtras();
if (data == null) {

}
if (data != null) {
String item = (data.getStringExtra("item"));
String title = Tit;
customItems.add(title + "nn" + item);
adapter.notifyDataSetChanged();

}


}

}








public class MainActivity extends AppCompatActivity {


ListView ListofList;
ArrayList<String> Lists;
ArrayAdapter<String> ListAdapter;
Button button;
ArrayList<String> Subject = new ArrayList<>();
int Size = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

ListofList = findViewById(R.id.LofL);
Lists = new ArrayList<String>();
ListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, Lists);
ListofList.setAdapter(ListAdapter);

button = findViewById(R.id.AddList);
Lists.add("Test");

ListofList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent i = new Intent(getBaseContext(), ItemList.class);
String s = (String) ListofList.getItemAtPosition(position);
i.putExtra("Title", s);
i.putExtra("size", Size);
int a = 0;
for (String t : Subject) {
i.putExtra("Item" + a, t);
a++;
}
startActivityForResult(i, 2);
}
});

button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getBaseContext(), CreateItem.class);
String message = "Please enter the name of the list below.";
i.putExtra("mess", message);
startActivityForResult(i, 1);
}
});



}

@Override
protected void onActivityResult (int requestCode, int resultCode, Intent data) {
Bundle extras = getIntent().getExtras();

if (data == null) {

}
if (data != null) {
if (requestCode == 1) {
String item = (data.getStringExtra("item"));
Lists.add(item);
ListAdapter.notifyDataSetChanged();
}
}

if (requestCode == 2) {
ArrayList<String> subject = new ArrayList<String>();
int i = 0;
assert data != null;
int size = (data.getIntExtra("ListSize", 0));
Size = size;
while (i <= size) {
String item = (data.getStringExtra("item" + i));
subject.add(item);

i++;
}

Subject = subject;
}
}


}





public class MainActivity extends AppCompatActivity {


ListView ListofList;
ArrayList<String> Lists;
ArrayAdapter<String> ListAdapter;
Button button;
ArrayList<String> Subject = new ArrayList<>();
int Size = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

ListofList = findViewById(R.id.LofL);
Lists = new ArrayList<String>();
ListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, Lists);
ListofList.setAdapter(ListAdapter);

button = findViewById(R.id.AddList);
Lists.add("Test");

ListofList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent i = new Intent(getBaseContext(), ItemList.class);
String s = (String) ListofList.getItemAtPosition(position);
i.putExtra("Title", s);
i.putExtra("size", Size);
int a = 0;
for (String t : Subject) {
i.putExtra("Item" + a, t);
a++;
}
startActivityForResult(i, 2);
}
});

button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getBaseContext(), CreateItem.class);
String message = "Please enter the name of the list below.";
i.putExtra("mess", message);
startActivityForResult(i, 1);
}
});



}

@Override
protected void onActivityResult (int requestCode, int resultCode, Intent data) {
Bundle extras = getIntent().getExtras();

if (data == null) {

}
if (data != null) {
if (requestCode == 1) {
String item = (data.getStringExtra("item"));
Lists.add(item);
ListAdapter.notifyDataSetChanged();
}
}

if (requestCode == 2) {
ArrayList<String> subject = new ArrayList<String>();
int i = 0;
assert data != null;
int size = (data.getIntExtra("ListSize", 0));
Size = size;
while (i <= size) {
String item = (data.getStringExtra("item" + i));
subject.add(item);

i++;
}

Subject = subject;
}
}


}





public class ItemList extends AppCompatActivity {

static ArrayList<String> customItems;
ArrayAdapter<String> adapter;
ListView lvItems;

Button button;
Button button2;

ArrayAdapter<String> trashAdapter;
ArrayList<String> trash;
ListView itemtrash;
static TextView Title;
String Tit;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_item_list);
Title = findViewById(R.id.Title);
//set up Item List
customItems = new ArrayList<String>();
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, customItems);
lvItems = (ListView) findViewById(R.id.lvItems);

//Set up trash List
trash = new ArrayList<String>();
trashAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, trash);
itemtrash = findViewById(R.id.itemtrash);

//Initialize Buttons
button = findViewById(R.id.AddItem);
button2 = findViewById(R.id.ClearTrash);

Bundle extras = getIntent().getExtras();
if (extras != null) {
((TextView)findViewById(R.id.Title)).setText(extras.getString("Title"));
Tit = extras.getString("Title");
int i = 0;
int size = (extras.getInt("size", 0));
while (i <= size) {
String item = (extras.getString("Item" + i));
if (item == null) {
continue;
}
customItems.add(item);
i++;
}
}

//CharSequence Titlefilter = Title.getText();
//lvItems.setTextFilterEnabled(true);
//ItemList.this.adapter.getFilter().filter(Titlefilter);
//adapter.notifyDataSetChanged();


button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getBaseContext(), CreateItem.class);
String message = "Please enter new item below.";
i.putExtra("mess", message);
startActivityForResult(i, 1);
}
});

button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
trashAdapter.clear();
trashAdapter.notifyDataSetChanged();
}
});

lvItems.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String s = adapter.getItem(position);
trashAdapter.add(s);
adapter.remove(s);
assert s != null;
adapter.notifyDataSetChanged();
trashAdapter.notifyDataSetChanged();
}
});

itemtrash.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String s = trashAdapter.getItem(position);
customItems.add(s);
trash.remove(s);
adapter.notifyDataSetChanged();
trashAdapter.notifyDataSetChanged();
}
});
lvItems.setAdapter(adapter);
itemtrash.setAdapter(trashAdapter);
}

@Override
public void onBackPressed() {
Intent i = new Intent();
int a = 0;
for (String s : customItems){
String t = adapter.getItem(a);
i.putExtra("item" + a, t);
a++;
}
int size = customItems.size();
i.putExtra("ListSize", size);
setResult(2, i);
finish();
}

@Override
protected void onActivityResult (int requestCode, int resultCode, Intent data) {

Bundle extras = getIntent().getExtras();
if (data == null) {

}
if (data != null) {
String item = (data.getStringExtra("item"));
String title = Tit;
customItems.add(title + "nn" + item);
adapter.notifyDataSetChanged();

}


}

}





public class ItemList extends AppCompatActivity {

static ArrayList<String> customItems;
ArrayAdapter<String> adapter;
ListView lvItems;

Button button;
Button button2;

ArrayAdapter<String> trashAdapter;
ArrayList<String> trash;
ListView itemtrash;
static TextView Title;
String Tit;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_item_list);
Title = findViewById(R.id.Title);
//set up Item List
customItems = new ArrayList<String>();
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, customItems);
lvItems = (ListView) findViewById(R.id.lvItems);

//Set up trash List
trash = new ArrayList<String>();
trashAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, trash);
itemtrash = findViewById(R.id.itemtrash);

//Initialize Buttons
button = findViewById(R.id.AddItem);
button2 = findViewById(R.id.ClearTrash);

Bundle extras = getIntent().getExtras();
if (extras != null) {
((TextView)findViewById(R.id.Title)).setText(extras.getString("Title"));
Tit = extras.getString("Title");
int i = 0;
int size = (extras.getInt("size", 0));
while (i <= size) {
String item = (extras.getString("Item" + i));
if (item == null) {
continue;
}
customItems.add(item);
i++;
}
}

//CharSequence Titlefilter = Title.getText();
//lvItems.setTextFilterEnabled(true);
//ItemList.this.adapter.getFilter().filter(Titlefilter);
//adapter.notifyDataSetChanged();


button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getBaseContext(), CreateItem.class);
String message = "Please enter new item below.";
i.putExtra("mess", message);
startActivityForResult(i, 1);
}
});

button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
trashAdapter.clear();
trashAdapter.notifyDataSetChanged();
}
});

lvItems.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String s = adapter.getItem(position);
trashAdapter.add(s);
adapter.remove(s);
assert s != null;
adapter.notifyDataSetChanged();
trashAdapter.notifyDataSetChanged();
}
});

itemtrash.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String s = trashAdapter.getItem(position);
customItems.add(s);
trash.remove(s);
adapter.notifyDataSetChanged();
trashAdapter.notifyDataSetChanged();
}
});
lvItems.setAdapter(adapter);
itemtrash.setAdapter(trashAdapter);
}

@Override
public void onBackPressed() {
Intent i = new Intent();
int a = 0;
for (String s : customItems){
String t = adapter.getItem(a);
i.putExtra("item" + a, t);
a++;
}
int size = customItems.size();
i.putExtra("ListSize", size);
setResult(2, i);
finish();
}

@Override
protected void onActivityResult (int requestCode, int resultCode, Intent data) {

Bundle extras = getIntent().getExtras();
if (data == null) {

}
if (data != null) {
String item = (data.getStringExtra("item"));
String title = Tit;
customItems.add(title + "nn" + item);
adapter.notifyDataSetChanged();

}


}

}






android android-asynctask






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 20:12







Cristian Espaillat

















asked Nov 13 '18 at 20:02









Cristian EspaillatCristian Espaillat

144




144













  • Seems pretty likely that the problem is in the second activity. Is it loading any data to display after you click on the list item?

    – Ben P.
    Nov 13 '18 at 20:09











  • yes give me a moment to edit it in

    – Cristian Espaillat
    Nov 13 '18 at 20:11











  • Hm, nothing jumps out at me (no network connection or db loading is obvious). If you comment out the whole if (extras != null) block, does the problem go away? Obviously you won't see your items, but this might help verify that loading the items is the slow part.

    – Ben P.
    Nov 13 '18 at 20:16











  • Okay so it does let me get to the ItemList Activity. It was working earlier when the items were two textviews, but I changed it to one textview to be able to use a filter. might that've been the cause?

    – Cristian Espaillat
    Nov 13 '18 at 20:23



















  • Seems pretty likely that the problem is in the second activity. Is it loading any data to display after you click on the list item?

    – Ben P.
    Nov 13 '18 at 20:09











  • yes give me a moment to edit it in

    – Cristian Espaillat
    Nov 13 '18 at 20:11











  • Hm, nothing jumps out at me (no network connection or db loading is obvious). If you comment out the whole if (extras != null) block, does the problem go away? Obviously you won't see your items, but this might help verify that loading the items is the slow part.

    – Ben P.
    Nov 13 '18 at 20:16











  • Okay so it does let me get to the ItemList Activity. It was working earlier when the items were two textviews, but I changed it to one textview to be able to use a filter. might that've been the cause?

    – Cristian Espaillat
    Nov 13 '18 at 20:23

















Seems pretty likely that the problem is in the second activity. Is it loading any data to display after you click on the list item?

– Ben P.
Nov 13 '18 at 20:09





Seems pretty likely that the problem is in the second activity. Is it loading any data to display after you click on the list item?

– Ben P.
Nov 13 '18 at 20:09













yes give me a moment to edit it in

– Cristian Espaillat
Nov 13 '18 at 20:11





yes give me a moment to edit it in

– Cristian Espaillat
Nov 13 '18 at 20:11













Hm, nothing jumps out at me (no network connection or db loading is obvious). If you comment out the whole if (extras != null) block, does the problem go away? Obviously you won't see your items, but this might help verify that loading the items is the slow part.

– Ben P.
Nov 13 '18 at 20:16





Hm, nothing jumps out at me (no network connection or db loading is obvious). If you comment out the whole if (extras != null) block, does the problem go away? Obviously you won't see your items, but this might help verify that loading the items is the slow part.

– Ben P.
Nov 13 '18 at 20:16













Okay so it does let me get to the ItemList Activity. It was working earlier when the items were two textviews, but I changed it to one textview to be able to use a filter. might that've been the cause?

– Cristian Espaillat
Nov 13 '18 at 20:23





Okay so it does let me get to the ItemList Activity. It was working earlier when the items were two textviews, but I changed it to one textview to be able to use a filter. might that've been the cause?

– Cristian Espaillat
Nov 13 '18 at 20:23












1 Answer
1






active

oldest

votes


















0














I figured it out. I accidentally made an infinite loop with while in the ItemList activity.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53288641%2fasync-and-skipping-frames%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I figured it out. I accidentally made an infinite loop with while in the ItemList activity.






    share|improve this answer




























      0














      I figured it out. I accidentally made an infinite loop with while in the ItemList activity.






      share|improve this answer


























        0












        0








        0







        I figured it out. I accidentally made an infinite loop with while in the ItemList activity.






        share|improve this answer













        I figured it out. I accidentally made an infinite loop with while in the ItemList activity.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 13 '18 at 21:21









        Cristian EspaillatCristian Espaillat

        144




        144






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53288641%2fasync-and-skipping-frames%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Full-time equivalent

            さくらももこ

            13 indicted, 8 arrested in Calif. drug cartel investigation