A
A
Artem2012-11-13 10:53:37
Android
Artem, 2012-11-13 10:53:37

One parser class for different activities?

I am writing a client for a website. It has three activities that display the downloaded data from the site. I would like to make one class for loading and parsing for all three activities (the url, the data parsing algorithm and the View that are filled with data are different). Again, the algorithms intersect with each other. How to implement it correctly? To transfer to this class a certain int which characterizes the parsing algorithm? And how then to fill the View in different activities? Or do not bother and make a separate class for each url?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
nicolausYes, 2012-11-13
@bartwell

The Template method pattern seems to work for you .

P
palmut, 2012-11-13
@palmut

It's better to move from activities to fragments. Loading and parsing of data should be done through the successor of Loader. Then loading and parsing data (Loader and class for parsing) is separated from the display - fragments (and possibly adapters in the case of ListView).

A
Artem, 2012-11-13
@bartwell

Well, yes, in general it is, sort of. Thank you!
As for returning data to an activity, it's not entirely clear how it can be implemented. In one activity, you need to fill a complex ListView with a custom adapter, in another - ImageView, in the third set of TextView with visibility=gone under certain conditions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question