package com.huetoyou.chatexchange.ui.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.huetoyou.chatexchange.R;
import com.huetoyou.chatexchange.ui.activity.main.MainActivity;
import com.huetoyou.chatexchange.ui.misc.Utils;
import com.huetoyou.chatexchange.ui.misc.hue.ThemeHue;

public class OfflineActivity extends Activity
{

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        ThemeHue.setTheme(this);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_offline);
    }

    public void checkOnlineStatus(View v)
    {
        if(Utils.areWeOnANetwork(this) && Utils.areWeOnline())
        {
            Toast.makeText(this, "Connection established, reloading app :)", Toast.LENGTH_SHORT).show();
            Intent intent = new Intent(this, SplashActivity.class);
            startActivity(intent);
            finish();
        }
        else
        {
            Toast.makeText(this, "You're still offline :\\", Toast.LENGTH_SHORT).show();
        }
    }
}

@@ -640,24 +640,56 @@
 n_offline);%0A
+        startAsyncPingThread();%0A
     %7D%0A%0A    p
@@ -812,39 +812,250 @@
             
-Toast.makeText(
+reloadApp();%0A        %7D%0A        else%0A        %7B%0A            Toast.makeText(this, %22You're still offline :%5C%5C%22, Toast.LENGTH_SHORT).show();%0A        %7D%0A    %7D%0A%0A    private void reloadApp()%0A    %7B%0A        Toast.makeText(OfflineActivity.
 this, %22Conne
@@ -1128,20 +1128,16 @@
         
- 
-   
 Intent i
@@ -1188,28 +1188,24 @@
 s);%0A        
-    
 startActivit
@@ -1223,20 +1223,16 @@
         
-    
 finish()
@@ -1229,37 +1229,80 @@
   finish();%0A    
+%7D%0A%0A
     
-%7D
+private void startAsyncPingThread()%0A    %7B
 %0A        else%0A  
@@ -1286,36 +1286,35 @@
 )%0A    %7B%0A        
-else
+try
 %0A        %7B%0A     
@@ -1325,80 +1325,1238 @@
    T
-oast.makeText(this, %22You're still offline :%5C%5C%22, Toast.LENGTH_SHORT).show
+hread thread = new Thread(new Runnable()%0A            %7B%0A                @Override%0A                public void run()%0A                %7B%0A                    while (true)%0A                    %7B%0A                        if(Utils.areWeOnline())%0A                        %7B%0A                            OfflineActivity.this.runOnUiThread(new Runnable()%0A                            %7B%0A                                @Override%0A                                public void run()%0A                                %7B%0A                                    reloadApp();%0A                                %7D%0A                            %7D);%0A                            break;%0A                        %7D%0A                        else%0A                        %7B%0A                            try%0A                            %7B%0A                                Thread.sleep(250);%0A                            %7D%0A                            catch (InterruptedException e)%0A                            %7B%0A                                e.printStackTrace();%0A                            %7D%0A                        %7D%0A                    %7D%0A                %7D%0A            %7D);%0A%0A            thread.start();%0A        %7D%0A        catch (Exception e)%0A        %7B%0A            e.printStackTrace
 ();%0A

Implement auto refresh :D