The Hour will only come upon the worst of people
Question

I have heard that before the Day of Resurrection there will not be any believers and Allah’s name will not be mentioned. Will this be before the Day of Resurrection or before the Dajjaal (the Anti-Christ) comes? I am very confused about this matter as I know that the number of believers will increase near the end of time and Allah’s law will be implemented in the earth. How to understand this?.
Praise be to Allah.The saheeh Sunnah indicates that the Hour will only come upon the worst of people, when the name of Allah is not mentioned on earth. That will be at the end of the time of this world, after the Dajjaal appears and is killed by ‘Eesa ibn Maryam (peace be upon him) and Islam and its followers prevail, and sharee’ah is applied on earth. 
Al-Bukhaari (2222) and Muslim (155) narrated that Abu Hurayrah (may Allah be pleased with him) said: The Messenger of Allah (peace and blessings of Allah be upon him) said: “By the One in Whose hand is my soul, soon the Son of Maryam (S) will descend among you as a just judge, he will break the cross, kill the pigs and abolish the jizyah, and wealth will become so abundant that no one will accept it.” 
According to a version narrated by Muslim: “By Allah, the son of Maryam will certainly come down as a just judge. He will break the cross and kill the pigs, and he will abolish the jizyah; the young she-camels will be left alone and no one will show any interest in them. Spite, mutual hatred and mutual envy will disappear, and when they are called (to be given) wealth, no one will accept it.” 
Al-Nawawi (may Allah have mercy on him) said: What this means is that there will be no interest in wealth and there will be no desire to keep a lot of wealth; there will be few wishes and no want, and there will be the knowledge that the Resurrection is at hand. Young she-camels are mentioned because they are the noblest of camels and the most precious of wealth to the Arabs. This is the like the verse in which Allah says (interpretation of the meaning): “And when the pregnant she‑camels are neglected” [al-Takweer 81:4]. What is meant by the words “and no one will show any interest in them” is that they will not be taken care of and their owners will neglect them and not look after them. End quote. 
This will be a stage of goodness, faith and prevalence of the Muslims. Then there will come another stage in which the numbers of believers will decrease, until Allah sends a wind that will take their souls, then there will be no one left but the most evil of people, upon whom the Hour will come. Muslim (148) narrated from Anas (may Allah be pleased with him) that the Messenger of Allah (peace and blessings of Allah be upon him) said: “The Hour will not begin until there is no one left on earth who says, ‘Allah, Allah.’”  
Ahmad (3844) narrated that ‘Abd-Allah ibn Mas’ood (may Allah be pleased with him) said: “Among the most evil of mankind will be those on whom the Hour comes when they are still alive, and those who take graves as places of worship.” Classed as hasan by Shu’ayb al-Arna’oot in Tahqeeq al-Musnad. 
These stages are mentioned in detail in the hadeeth narrated by Muslim (2940) from ‘Abd-Allah ibn ‘Amr (may Allah be pleased with him), who said: The Messenger of Allah (peace and blessings of Allah be upon him) said: “The Dajjaal will appear among my ummah and he will stay for forty. Then Allah will send ‘Eesa ibn Maryam, who looks like ‘Urwah ibn Mas’ood, and he will pursue him and kill him. Then the people will remain for seven years with no enmity between any two people. Then Allah will send a cool wind from the direction of Syria and there will be no one left on the face of the earth in whose heart there is an atom’s weight of goodness or faith but it will cause him to die. Even if one of you were to enter the heart of a mountain, it would enter upon him and cause him to die.” He said: I heard it from the Messenger of Allah (peace and blessings of Allah be upon him), who said: “There will be left the most evil of people who will be as careless as birds and be as cruel as wild animals. They will not acknowledge any good or denounce any evil. Then the Shaytaan will appear to them and will say: Will you not listen to me? They will say: What do you command us to do? He will command them to worship idols, but despite that they will have ample provision and a good life. Then the Trumpet will be blown.” 
Al-Nawawi (may Allah have mercy on him) said in his commentary: … With regard to the words of the Prophet (peace and blessings of Allah be upon him), “There will be left the most evil of people who will be as careless as birds and be as cruel as wild animals” the scholars said: what is meant is that in their haste to do evil and fulfil their desires, they will be like birds, and in their enmity and wrongdoing towards one another they will be like wild animals. 
Muslim narrated (2937) that al-Nawwaas ibn Sam’aan (may Allah be pleased with him) said: The Messenger of Allah (peace and blessings of Allah be upon him) mentioned the Dajjaal one day … then he mentioned the descent of the Messiah ‘Eesa ibn Maryam, who will descend to the white minaret in the east of Damascus, wearing two garments lightly perfumed with saffron, placing his hands on the wings of two angels… He will pursue him (i.e., the Dajjaal) until he catches him at the gate of Ludd (Lod), and kills him… Then he mentioned the emergence of Ya’jooj and Ma’jooj, then it will be said to the earth: Bring forth your fruits and restore your blessing. … . Then whilst they are like that, Allah will send a pleasant wind which will seize them beneath their armpits and will take the soul of every believer and every Muslim. The most evil of people will be left and they will fornicate like donkeys and upon them the Hour will come” 
“They will fornicate like donkeys” means that men will have intercourse with women in the presence of other people, as donkeys do. 
We ask Allah to help us and you to do that which He loves and which pleases Him.