I'm developing a chat app. Here, I have a screen for creating a new private chat with someone and a second screen for creating a group chat. In both screens I need to display a list of friends. How can I share this list between the screens? And what is the most efficient way to share large amount of data?
Should I use a shared viewModel?
Or maybe use a in memory FriendsRepository?
I tried a shared viewModel, but, it doesn't feel right since I have to get data from a viewModel and make uiState in another.
Related
So hello everyone! Greetings for the day!
There are serveral Activities in Android studio I have to get data with. Total of 6 data inputs. However one user enters data for only one of them.
Here's the design sketch.
https://ibb.co/X5yyzQM
So do I have to design 6 Activities with input forms like this or is there any method to use one input form to use for 6 activities and get data with unique form value to the database?
Like BanquetStarter(name, address..) , BanquetBronze(name, address..) etc.
Appreciate your kind help. Appologies for your valuable time.
Thanks ❤.
These are separate screens, but do not necessarily have to be separate activities. Consider architecting this with Fragments. This would allow you to utilize a single ViewModel bound to the lifecycle of the Activity. Each fragment would be responsible for collecting its own information and handing that into the ViewModel, and then once all the information is submitted, you have it all in one place and ready to go.
Activities are heavy weight components, whereas Fragments are lighter weight. Unless you have a very good, explicit reason to do so, prefer a single activity approach with multiple fragments (or multiple composable screens, if this app is being written from scratch utilizing Jetpack Compose).
I just started learning Android App Development recently and I'm curious about this;
Suppose I want to make an app with lots of activities(pages) for example a Bible app with around 1189 chapters with Each chapters having different activities. Does that Mean I will create about 1189 different activities or is there an easier way to create this type of app?
You can use a lot of design patterns. You can put the information you want to display in an class. Then you could span 1189 objects. You could create just one activity, and get 1189 different objects' information. Finally display in activity.
like this https://github.com/newcaoguo/booksource/tree/master/chapter3/RecyclerViewTest
I'm new into android development, and at this stage I try to mimic some functionalities from other apps (please consider the image from bellow).
For example, there is one app o google play which gives details about all the sensors from a device. I know how to read the values from any sensor and how to get a list of all the sensors, but I don't know how to take all the values from all the sensors and to display them in real time.
Are there some good practices or design patterns which can help me achieve the real-time values in an elegant manner?
if you want to design this you have to use fragment on main activity then you have to use viewpager and tabhost to swipe tab and then you have to use recycler view or list view to display data then u have to use censer data try any one censer then u will get deep onto in censer its easy library .first you design this.
i want to create a chat app using flex 4.5 mobile project for android device. For the chat screen, i wanted it to look glossy and stylish. Hence i thought i would use the list component and disable the selection in it. I m able to add the chat messages into the list. But i doubt if large chat data might hinder the performance. Im using a collection and i ve binded it with the list. Whenever i receive a chat i update the collection and it gets displayed in the list. Can someone tell me if his could pose a performance problem as list component is not intended for this purpose.
Thanks..
Why wouldn't a list be intended for this purpose? I'd say a List is the exact component to use for this kind of task. I don't see any performance issues unless you're doing something wrong with the eventListeners or your ItemRenderer. For best performance, use an AS only renderer.
However, as memory is always a concern on mobile devices, you might wanna consider limiting the amount of items in the list, say 100 or so. You likely won't get back to the beginning of the list (your conversation) anyway.
My project is a visitor app for a University, that basically displays places and events on a map, and allows the users to interact with one another by making posts with advice/recommendations/questions and so on.
So far I've been trying out bits of code seperately (lists, tabs, the basics), following the android tutorials and trying things for myself. My problem is that I'm not sure how to combine all the bits of code into one project.
I know that I need to make a database, and a map (using OSM rather than google).
The database will store information on places, events, and posts that users have made. With co-ordinate information because they need to go on the map. This information is also displayed in seperate tabs - e.g. a list of places.
My problem is that I don't know how this will all fit together.
Will I need seperate classes for the database, populating the lists, and displaying on the map? Or can they all be in a single class?
I'm a little hazy on how the classes and activities are going to communicate, too. At the moment I'm thinking the database object is going to get passed to the listviews and mapview, which then take and display some of the information?
Any advice on how to cobble these elements together would be much appreciated. :D
I think I will need to subclass SQLiteOpenHelper for my database, so it'll need to be its own class?
I'm thinking of using OSMdroid for the map, which I'm not sure how to do yet.
And everything needs to be inside a tabview.
Welcome to StackOverflow!
Your question is very vague and broad, and likely to get closed as "not a real question" - I suggest you take problems one by one and ask specific questions as you go along and run into problems. Try to think about your problem in these terms: what's the minimal thing I need to get it to do the thing I want. Keep in mind that ANYTHING you want to do is possible, the main question to ask yourself is: what do you want your application to do exactly? Think about the number of different screens (activities), and how they would communicate to each other (when you click XXX, that will lead you to YYY, and so on). One advice: start simple, it's very easy to get buried in too much complexity, especially since it's your first project. It can quickly become very complex, even with a simple concept.
As you didn't specify your level of expertise in coding, it's difficult to give precise advices: but coding an android application is not very different from a "regular" application, with a web or Swing or C# user interface. So I would advise you to learn about OO programming in general, things like composition, inheritance, encapsulation, dependency injection, unit-testing, etc.
Then start writing a base Activity for your main view, write its layout, and add views and graphical elements to it. Then add the listener code for your widgets, that will generate Intents to other Activity.
Then add a DatabaseHelper when you want to save stuff in a database (that can come later, to begin with, you can just "stub" the interactions to a database, by writing what you would save to db on screen using Toast for example).
All objects can be injected into other objects by passing a reference to them, either at construction time or through setters.
Sorry not to be more precise, as I said it's a very vague question.