All Questions
Tagged with code-duplication android
20 questions
0
votes
2
answers
142
views
How to fix duplicate code fragment in android
I have this function to update my ImageView in my android project
private fun weatherImageSetup(currentWeather: CurrentWeather) {
fun setImage(imageId: Int) {
viewBinding....
0
votes
1
answer
58
views
Implementing the same feature on two app versions
I have two versions of an app (paid and free). When I add a new feature in both versions I have to write the same code on both of them. Is there a way to write the code on one of them and then add ...
0
votes
1
answer
100
views
Should similar screens be different Fragments?
Ok so I'm creating an app. I have a "Creation" page, and a "Detail" page for the same item. The UI is the same, probably the logic will be the same as well, only difference i can ...
4
votes
1
answer
2k
views
Finding duplicated code (Kotlin) in Android Studio
Is there a way to find duplicated (Copy/pasted code, repeated code) Kotlin code in Android Studio?
I have Android Studio 4.0 but can't find this "Duplicated code fragment" option.
Are there any ...
1
vote
1
answer
289
views
How to avoid duplicate code in the activity and fragment?
When an activity is launched, the condition is checked in it, if the condition is true, the openNewActivity method is called and the current activity ends. But if the condition is false, then a ...
-3
votes
1
answer
30
views
How to avoid duplicating the same chunk of code?
I am a beginner developer of an Android app and have a structure related question.
In my app I have a few screens with buttons that allow us to switch between these screens.
Right now I am setting ...
-1
votes
2
answers
111
views
showing some view in all activities without duplication of code in Android
I have a condition when a specific event will occur in background, I have to show a Floating Action Button in bottom of activity to notify the user if App in fore ground. No matter in what activity ...
1
vote
1
answer
464
views
Android: one or two activities for same layout/similar functions
I'm fairly new to Android development and have a question regarding best practices for designing Activities.
I have two activities that use the same layout, but their functions differ a bit. One ...
1
vote
1
answer
2k
views
Alternative Layouts
I am developing an android application that I want to support Material Design for devices running 5.0+ and devices from 4.1 to 4.4.
I am using the appcompat library to get some support for older ...
-2
votes
1
answer
170
views
Duplicate error-noob programmer
Here's my code, I have no idea what is wrong with it I am completely new at this and I would appreciate it a lot if I can receive some feedback thanks:)When I try to launch my app in the emulator it ...
2
votes
1
answer
546
views
Better way to create Android content providers
I have a content provider in my app and I really don't like it :-). The provider is created after reading number of articles like the official one and this unofficial one.
What I really don't like is ...
14
votes
6
answers
14k
views
Best way to avoid duplicate code if two classes extending different class
I am working on an Android project and i am facing this situation.
I have 2 class :
class A extends B
{
openDoor(){
//impl
}
closeDoor(){
//impl
}
}
class X extends Y{
openDoor(){
//impl
}
...
2
votes
1
answer
320
views
Android: implementing very similar layouts/activities
I'm a beginner to Android development and I'm implementing an address book app. This app will need an 'add contact' screen and an 'edit contact' screen. These screens are going be pretty similar - '...
0
votes
2
answers
179
views
feinstein's SlidingMenu library, Define BehindContentView in every activity?
I am using feinstein's SlidingMenu library, I want to use the SlidingMenu in every activity i have. Should I have to write the SlidingMenu code in every activty?!, or can I write the slidingMenu in a ...
1
vote
1
answer
288
views
Conditionally adding extra else if statements
The following is called from every level of my app (a game)
Pseudo code example
public void checkCollisions(){
if (someCondition)
do something
else if (someCondition2)
do ...
3
votes
2
answers
1k
views
How can I avoid code duplication with Fragment callbacks to a details activity?
I'm using a master/detail pattern with one activity managing the 2-pane view and the selector list and the other activity managing the detail fragments. I'm using an interface to handle fragment ...
1
vote
5
answers
222
views
How do I reduce this code duplication
I'm stuck on how I can reduce this code duplication, I'm using the TextToSpeech engine and using locales so the user can select their language.
language is a Spinner.
language....
0
votes
1
answer
373
views
Making Android/Java code more efficient - removing duplicate
I have a standard AsyncTask like this:
// starting AsyncTask in onCreate
new TaskName().execute();
class TaskName extends AsyncTask<String, String, Void> {
private ProgressDialog ...
1
vote
2
answers
249
views
R unresolved variable when duplicating activities
I am attempting to duplicate my project with a different title and package name. However, when I copy and paste the activities, it returns that R is an unresolved variable that I can either import ...
1
vote
2
answers
325
views
How to avoid having duplicate code for fetching location and data in every activity?
I have 2 activites (one with listview and 1 with mapview). Both activities have refresh button that fetches location and then downloads some data from the internet.
I have duplicate code for location ...