Animated app(Launcher) icon
I need to implement animated app(launcher) icon like facebook, instagram, whatsapp etc in android .
My target version is 26
minSdkVersion 15
targetSdkVersion 26
ic_launcher.xml
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_app_background"/>
<foreground android:drawable="@mipmap/ic_app_foreground"/>
</adaptive-icon>
If anybody know please help me to do the same.
See also questions close to this topic
-
Recyclerview returning Null
I had a listview for displaying a list of messages and i changed it to recyclerview for better readability and UI and its returning a nullpointerexception... can any1 help me out on why its reyurning null
Activity
RecyclerView messageList; List<Messages> messagesList = new ArrayList<>(); private LinearLayoutManager linearLayoutManager; private MessageAdapter mAdapter; mAdapter = new MessageAdapter(messagesList); messageList = (RecyclerView) findViewById(R.id.messageList); linearLayoutManager = new LinearLayoutManager(this); messageList.setHasFixedSize(true); messageList.setLayoutManager(linearLayoutManager); messageList.setAdapter(mAdapter); private void fetchMessages() { rootRef.child("Messages").child(MessageSenderId).child(MessageRecieverId).addChildEventListener(new ChildEventListener() { @Override public void onChildAdded(DataSnapshot dataSnapshot, String s) { Messages message = dataSnapshot.getValue(Messages.class); messagesList.add(message); mAdapter.notifyDataSetChanged(); } @Override public void onChildChanged(DataSnapshot dataSnapshot, String s) { } @Override public void onChildRemoved(DataSnapshot dataSnapshot) { } @Override public void onChildMoved(DataSnapshot dataSnapshot, String s) { } @Override public void onCancelled(DatabaseError databaseError) { } });
Messages Class
public class Messages { private String from; private String message; private String type; private boolean seen; private long time; public Messages(){}; public String getFrom() { return from; } public void setFrom(String from) { this.from = from; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public String getType() { return type; } public void setType(String type) { this.type = type; } public boolean isSeen() { return seen; } public void setSeen(boolean seen) { this.seen = seen; } public long getTime() { return time; } public void setTime(long time) { this.time = time; }
}
Adapter
public class MessageAdapter extends RecyclerView.Adapter<MessageAdapter.MessageViewHolder>{ private List<Messages> userMessageList; private FirebaseAuth mAuth; public MessageAdapter (List<Messages>userMessageList) { this.userMessageList = userMessageList; } public class MessageViewHolder extends RecyclerView.ViewHolder{ public TextView messageText; public MessageViewHolder(View view) { super(view); messageText = (TextView)view.findViewById(R.id.message_text); } } @Override public int getItemCount() { return userMessageList.size(); } @Override public MessageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View V = LayoutInflater.from(parent.getContext()).inflate(R.layout.activity_chat_custom,parent,false); mAuth = FirebaseAuth.getInstance(); return new MessageViewHolder(V); } @SuppressLint("ResourceType") @Override public void onBindViewHolder(MessageViewHolder holder, int position) { String current_user_id = mAuth.getInstance().getCurrentUser().getUid(); Messages messages = userMessageList.get(position); String from_user = messages.getFrom(); // Log.d("TAG",current_user_id + "/" + from_user); if (from_user.equals(current_user_id)){ holder.messageText.setBackgroundResource(Color.BLUE); holder.messageText.setTextColor(Color.RED); }else { holder.messageText.setBackgroundResource(R.drawable.text_background1); holder.messageText.setTextColor(Color.CYAN); } holder.messageText.setText(messages.getMessage()); } }
Im getting an error in the line if (from_user.equals(current_user_id)){
The error
FATAL EXCEPTION: main Process: com.appmaster.akash.messageplus, PID: 1135 java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference at com.appmaster.akash.messageplus.MessageAdapter.onBindViewHolder(MessageAdapter.java:59) at com.appmaster.akash.messageplus.MessageAdapter.onBindViewHolder(MessageAdapter.java:19) at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6482) at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6515) at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5458) at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5724) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5563) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5559) at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2229) at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1556) at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1516) at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:608) at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3693) at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3410) at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3962) at android.view.View.layout(View.java:16669) at android.view.ViewGroup.layout(ViewGroup.java:5440) at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1080) at android.view.View.layout(View.java:16669) at android.view.ViewGroup.layout(ViewGroup.java:5440) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336) at android.widget.FrameLayout.onLayout(FrameLayout.java:273) at android.view.View.layout(View.java:16669) at android.view.ViewGroup.layout(ViewGroup.java:5440) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586) at android.widget.LinearLayout.onLayout(LinearLayout.java:1495) at android.view.View.layout(View.java:16669) at android.view.ViewGroup.layout(ViewGroup.java:5440) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336) at android.widget.FrameLayout.onLayout(FrameLayout.java:273) at android.view.View.layout(View.java:16669) at android.view.ViewGroup.layout(ViewGroup.java:5440) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586) at android.widget.LinearLayout.onLayout(LinearLayout.java:1495) at android.view.View.layout(View.java:16669) at android.view.ViewGroup.layout(ViewGroup.java:5440) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336) at android.widget.FrameLayout.onLayout(FrameLayout.java:273) at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2678) at android.view.View.layout(View.java:16669) at android.view.ViewGroup.layout(ViewGroup.java:5440) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2207) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1963) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1139) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6064) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:860) at android.view.Choreographer.doCallbacks(Choreographer.java:672) at android.view.Choreographer.doFrame(Choreographer.java:608) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:846) at android.os.Handler.handleCallback(Handler.java:742) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:157) at android.app.ActivityThread.main(ActivityThread.java:5
Someone please help me out.... sorry if its too much code but for finding out what the error is this much code is required... if you need more details please ask... and also it was working perfectly fine before when i was using listview so its not because of the logic or database
-
Android: Retrieve data of a specific user from a Firebase database
I am trying to read "specific" data from my
firebase
realtime database. I have seen examples of getting all data from a table and going through it to find the data record you want, but that is definitly not a recommended safe practice.Below is how I save my data
private void saveInDatabase(String email) { // Write a message to the database FirebaseDatabase database = FirebaseDatabase.getInstance(); DatabaseReference myRef = database.getReference("user"); String key = myRef.push().getKey(); User user = new User(); user.setCountry("United States"); user.setEmail(email); user.setFirstName("John"); user.setLastName("Doh"); user.setGender("Male"); myRef.child(key).setValue(user); }
Well that works great. But now I need to retrieve the data record from the
user
table, that is only belong toJohn
. If I do this with MySQL, it will be smething likeselect * from user where primaryKey =JOHN_PRYMARY_KEY
I gave it a try, check below.
database.getReference("user" + FirebaseAuth.getInstance().getCurrentUser().getUid());
I am really not sure how I can proceed from here, I see no method to go forward. Please advice.
-
Android fragments memory leaking
I am currently developing an Android application using fragments and i am encountering a memory leak that forces my app to close after a while.
The main activity of the app features 3 fragments side by side using a viewpager which can be swiped between. The middle fragment features a catalog for our store. when the user clicks a category in the catalog, a new fragment is loaded with more options; the brands in the category. The user can then click one of these brands to view the products within it. The user can then click a product and view it on the full screen with more details.
Each time the user clicks on of these buttons, a new fragment is created showing the content for which button they have clicked.
the fragments go like this:
Catalog -> Brands -> All Products -> Indiviudal Product
to change the fragment being shown, i am using this code:
Brands brandsFragment = new Brands(); FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.catalogcontent, brandsFragment); transaction.addToBackStack(null); transaction.commit();
When the user clicks on the back button, they are directed to the previous fragment. This is what i want to happen, however it seems to be creating an entirely new fragment instead of using the old one.
This is causing huge memory leaks when viewing some of our larger brands.
When the user presses the back button, the current fragment they are on should be destroyed but they seem to be persisting.
I have found an answer here: https://stackoverflow.com/a/20023140/9364403
however, the answer suggests using the .add() function, where as I am currently using the .replace() function. What is the difference in these?
I have also tried to clear the backstack completely but that does not seem to clear the memory.
the Android Profiler tool (shown in the image) shows that the most memory being used up is under Java. Is this actually something to do with the fragments or is there some other issue with my application?
Thanks.
-
Can't set image Opactity Property
I have this Image:
<Image x:Name="imgOsuLogo" Stretch="Uniform" Margin="205" Source="{Binding Logo}">
And this code behind to animate the Image:
public MainWindow() { InitializeComponent(); imgOsuLogo.DataContext = workingResources; imgOsuLogo.Opacity = 0; txbUpdate.DataContext = workingResources; GetSongName(); GetSkinInfo(); Task task = new Task(() => { Thread.Sleep(3000); Dispatcher.Invoke(FadeInBlackBackGround); }); Task task2 = new Task(() => { Thread.Sleep(6000); Dispatcher.Invoke(MainOsu); }); task.Start(); task2.Start(); } private void MainOsu() { BlackCurtain.Visibility = Visibility.Collapsed; imgOsuLogo.Opacity = 1; } private void FadeInBlackBackGround() { DoubleAnimation animation = new DoubleAnimation(0, 1, TimeSpan.FromSeconds(1)); BlackCurtain.BeginAnimation(OpacityProperty, animation); DoubleAnimation animationLogo = new DoubleAnimation(1, 0, TimeSpan.FromSeconds(1)); imgOsuLogo.BeginAnimation(OpacityProperty, animationLogo); }
When the line
imgOsuLogo.Opacity = 1;
inMainOsu
Method executes, the Opacity Property not change to 1, even when I try to change it in Visual Studio Debugger. -
Why animation does not work?
Why animation does not work?
All code
import React, { Component } from 'react'; import { AppRegistry, View, Image, StyleSheet, WebView, Linking, TouchableOpacity, Animated, Keyboard, TextInput, KeyboardAvoidingView } from 'react-native'; import { Button, Text, Container, Card, CardItem, Body, Content, Header, Title, Left, Icon, Right, Form, Picker, Item } from 'native-base'; import { Actions } from 'react-native-router-flux'; import { styles, colors, paddings, fonts } from '../styles'; import DefaultInput from "./DefaultInput"; import validate from "./Validation"; import ModalComponent from "./Modal"; import ModalDropdown from 'react-native-modal-dropdown'; import { LinearGradient } from 'expo'; import CheckBox from 'react-native-check-box'; class CheckIn extends Component { constructor(props) { super(props); this.inputMarginTop = new Animated.Value(8); } componentWillMount () { this.keyboardWillShowSub = Keyboard.addListener('keyboardWillShow', this.keyboardWillShow); this.keyboardWillHideSub = Keyboard.addListener('keyboardWillHide', this.keyboardWillHide); } componentWillUnmount() { this.keyboardWillShowSub.remove(); this.keyboardWillHideSub.remove(); } keyboardWillShow = (event) => { Animated.timing(this.inputMarginTop, { duration: event.duration, toValue: 2, }).start(); }; keyboardWillHide = (event) => { Animated.timing(this.inputMarginTop, { duration: event.duration, toValue: 8, }).start(); }; render() { console.log(this.inputMarginTop._value); return ( <View style={{height: '100%', alignItems: 'center', flexDirection: 'column'}}> <TextInput style={{width: '90%', height: 20, borderWidth:1, marginTop: 100}} /> <View style={{width: '90%'}}> <Animated.Text style={{marginLeft: 10, marginBottom: 8, marginTop: `${this.inputMarginTop}%`}}>Имя</Animated.Text> </View> </View> ); } } export default CheckIn;
Important parts of the code
this.inputMarginTop = new Animated.Value(8);
<View style={{width: '90%'}}> <Animated.Text style={{marginLeft: 10, marginBottom: 8, marginTop: `${this.inputMarginTop}%`}}>Имя</Animated.Text> </View>
-
Observing UIViewPropertyAnimator is running issue
From Apple Documents pausesoncompletion
Because the completion handler is not called when this property is true, you cannot use the animator's completion handler to determine when the animations have finished running. Instead, you determine when the animation has ended by observing the isRunning property.
But i found observe
isRunning
not work. util i wathched WWDC 2017 - Session 230-Advanced Animations with UIKit ,i konwed i should observerunning
//not work animator.addObserver(self, forKeyPath: "isRunning", options: [.new], context: nil) //this work animator.addObserver(self, forKeyPath: "running", options: [.new], context: nil)
My Question is: where can i find the excatly keypath, not only this case. Thx~
-
Xamarin UWP icon assets for the application
I am developing the Xamarin UWP project for an existing Xamarin forms project of mine. My existing project has support to Android and iOS only. Now, i am trying to extend the support to UWP as well.
In Xamarin UWP project what should be the icon sizes that needs to be used in UWP project so that it is compatible in all the devices(mobile, tablet and desktop).?
In Android we have the option of providing the sizes as per the drawable folders and in iOS we can mention the icon with their sizes like 1x, 2x and 3x. Likewise What is the method to add the icon assets used in the Xamarin UWP project.?
I have checked the below link and also tried to generate the icons used in the Visual assets tab in the package manifest file in UWP project but it has not worked. Relevant documentation here.
Anyone please provide me the way to generate or standard sizes of icons used in the Xamarin UWP project?
-
How to make Smart Icon Animations (when Launch and Exit Apps) in Android?
Smart Animated Icons
is one of the Highlighted Features ofMIUI 9
.You can see the New Animation when you Launch and Exit Apps. Open/Launch the App and You can notice the Animation on its Icon when you exit the App. Animation seems to be cool and it gives you a live Experience as if Icons are Live. Take a look at the below GIFs to see the Animation on Icons.Facebook Smart Icon animation exmaple.
Settings app Smart Icon animation
For more smart App icon Animation understanding and information please check this link Smart Icon Animation
1) how to achieve this same features ? How can I do it in my app?
2) Android SDK that supports dynamic app icons ? is it possible to achieve this using
<activity-alias>
? -
Animated adaptive app icon like fb, whatsapp and instagram
I am using adaptive app icon for my application and able to change icon shape according to device OEM but not able to animate like Facebook, Whatsapp and instagram. I also go through the developer.android.com but not getting any solution for the same.
Any help will be appreciated.
-
Correct way to use adaptive icons in api 26+
I managed to get my adaptive icons working by creating a folder
mipmap-anydpi
and placing suggested xml file there (https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive.html#studio)This worked on api 26, but broke icons on android versions lower than that, they now show default android image. I managed to fix this by renaming my folder to
mipmap-anydpi-v26
, now icons work as expected on all supported apis.My question is this, are we supposed to do it like this? Will
-v26
make it also work on api 27+ or I have to create separate-v2X
folder for each future api?