📜 ⬆️ ⬇️

Selloby: how we made elephants for Android



Selloby is a Twitter-style private announcement service and our very first Android project. Despite the relatively small amount of code (just over 8 KLOC), in the process of implementing the Selloby project, we tried a number of techniques and methodologies that were useful in further work. Selloby also gave us the opportunity to feel, albeit in miniature, how Twitter works, which, in addition to self-development, added interest to our work.

The main idea of ​​the project is that all the announcements in the system, like the posts on Twitter, are homogeneous, and the client gets from the stream the information that interests him.
')


Filters


Most likely, the user will only need ads that are selected according to certain criteria. For example, from his city and from some one category. For this purpose, the search function by cities and categories is implemented. An ad feed on the main screen has three display options:





With hash tags, there is one trick. For the price, it is not the value that is indicated, but the maximum and minimum acceptable prices. This further complicated the server logic, since they had to select a fairly large amount of data not by exact coincidence, but by entering the interval. I believe that someday our back-end developers will write a separate article about this.



The current city can be determined automatically by GPS coordinates. This is one of those chips that we used in further development. On the server we have a dictionary of settlements. Using a simple web service, we send our current coordinates there and get the name and location of the city. Well, or the village :)

Creating ads and hash tags


Of course, besides viewing ads, the user should be able to create them. Just in the creation of ads, namely in the use of hash tags, is the main similarity of Selloby with Twitter. Hash tags can be the following:




On the last tag, the cost is worth talking separately. It is selected depending on the current locale. If the system language is Russian, then the ruble sign is put. Otherwise put a dollar sign. For each tag there is an auto substitution of the most frequently entered values.

Up to three photos can be added to the ad. Photos can be downloaded from the phone gallery or received directly from the camera. It was suddenly discovered that there is a bug in the android, and different phones work differently with the camera. Some preedyat photographed picture in the intent, others save it in a temporary directory. The problem was solved by an uncomplicated workout .



In addition to hash tags and locations, each ad belongs to one of several dozen categories that are grouped together (products, work, real estate, services, tourism, etc.).

Each ad can be added to favorites, which is convenient if you need to return to a previously viewed ad.

Authorization


In addition to its own login mechanism, Selloby also has authorization via Facebook and Twitter.

The most difficult thing for us was the authorization via Twitter, since at that time there was no sdk of its own. For this we had raised a special web service that performed the authorization. Mobile application was connected to this service, but not to the Twitter server. By the way, authorization in the system is not necessary - you can view ads without entering your login and password. To work with Facebook, we used the Facebook Android SDK .

Libraries


In this database application we used the OrmLite library. This entailed some difficulties in compiling complex queries and modifying the database, so in the following projects we abandoned it. But another library, RoboGuice , the IoC container for Android applications, showed itself from the best side, and its use has become mandatory for all Android applications developed in Parcsis. To display the list in the spirit of Twitter, the PullToRefresh library was used .

Conclusion


The first version of Selloby for Android was published on July 15, 2011. At the moment, the application is in the process of being finalized, and in the future significant changes await it. Follow our news!

Source: https://habr.com/ru/post/150416/


All Articles