Skip to content

An Android project to fetch a webpage content and find the 10th characters and character sequences

License

Notifications You must be signed in to change notification settings

gabpa3/compass-about

Repository files navigation

compass-about

Kotlin Coroutines Room Room Room

Description

This Android project aims to retrieve the content of a given webpage and process it using two different data manipulation requirements: finding every 10th character and finding the character sequence until a whitespace appears.

Approach

The application concurrently fetches content from a specified webpage one time it gets then cached on a database and provides two parallel concurrence mechanisms to achieve the requirements. How its work?

  • Well-defined structure based on Clean Architecture(UI, Data, Domain) and MVVM pattern to notify view states. Usecase for business logic separation and repository for data sources
  • Okhttp for creating an HTTP client and making the request. In this particular scenario, Retrofit was not needed as a mechanism for retrieving data online
  • Room as cache mechanism. For instance, to save and provide the webpage content as a single plain text
  • Coroutines and Flows. One for grabbing the content meanwhile suspend functions and Dispatcher.IO to be a safe thread and the other for manipulating the content and emitting and collecting reactive streams enabling asynchronous data flow. In this last part use Dispatcher.Default
  • DS as LinkedHashMap, HashMap, and StringBuilder to better time performance
  • Service locator pattern as a mechanism to encapsulate dependencies and provide when they will be required
  • JUnit and Kotlin coroutine test to cover and ensure software quality. In this context, All Domain codes, repository, and viewmodel were coverage with 100%
  • UI split into two fragments for a welcome and show the lists
  • Configuration changes
  • Following git flow workflow

This approach meets the requirements, ensures a well-structured codebase, promotes separation of concerns, and enhances the maintainability and the code quality of the application

Consideration

To achieve finding character sequence correctly. More than taking whitespace and break lines as delimiter I had to include '<' and '>' to match one of the requirements. So, every time to find an HTML tag glued to a word I split the sequence.

Screenshots & videos

portrait landscape
portrait.mp4
landscape.mp4

Coverage

Data - Repository

Domain

ViewModel

References

Developer Android - Google -> https://developer.android.com/
Sunflower project - Android -> https://github.com/android/sunflower Kotlin Documentation - Jetbrains -> https://kotlinlang.org/docs/home.html

License

Copyright 2024 Gabriel Perez

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

An Android project to fetch a webpage content and find the 10th characters and character sequences

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages