package com.lsjwzh.loadingeverywhere.sample;

import android.os.AsyncTask;
import android.os.Bundle;
import android.os.SystemClock;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;

import com.lsjwzh.loadingeverywhere.GenericStatusLayout;
import com.lsjwzh.widget.OverlayLayout;


public class GenericStatusLayoutDemo extends ActionBarActivity {

    GenericStatusLayout mGenericStatusLayout;
    TextView textView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        textView = (TextView)findViewById(R.id.textView);
        mGenericStatusLayout = new GenericStatusLayout(this);
//        mGenericStatusLayout.setLayerCreator(new );
        mGenericStatusLayout.attachTo(textView);

    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            mGenericStatusLayout.showLoading();
            new AsyncTask<Void,Void,Void>(){

                @Override
                protected Void doInBackground(Void... params) {
                    SystemClock.sleep(3000);
                    return null;
                }

                @Override
                protected void onPostExecute(Void aVoid) {
                    super.onPostExecute(aVoid);
                    mGenericStatusLayout.hideLoading();
                }
            }.execute();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

@@ -125,16 +125,63 @@
 mClock;%0A
+import android.support.v4.view.MenuItemCompat;%0A
 import a
@@ -221,16 +221,16 @@
 tivity;%0A
-
 import a
@@ -1124,54 +1124,351 @@
     
-get
 MenuI
-nflater().inflate(R.menu.main, menu
+temCompat.setShowAsAction(menu.add(0,0,0,%22loading%22),MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);%0A        MenuItemCompat.setShowAsAction(menu.add(0,1,0,%22empty%22),MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);%0A        MenuItemCompat.setShowAsAction(menu.add(0,2,0,%22error%22),MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW
 );%0A
+%0A
     
@@ -1825,28 +1825,9 @@
  == 
-R.id.action_settings
+0
 ) %7B%0A
@@ -2240,16 +2240,16 @@
 aVoid);%0A
-
         
@@ -2360,24 +2360,1150 @@
 eturn true;%0A
+        %7Delse if (id == 1) %7B%0A            mGenericStatusLayout.showEmpty();%0A            new AsyncTask%3CVoid,Void,Void%3E()%7B%0A%0A                @Override%0A                protected Void doInBackground(Void... params) %7B%0A                    SystemClock.sleep(3000);%0A                    return null;%0A                %7D%0A%0A                @Override%0A                protected void onPostExecute(Void aVoid) %7B%0A                    super.onPostExecute(aVoid);%0A                    mGenericStatusLayout.hideEmpty();%0A                %7D%0A            %7D.execute();%0A            return true;%0A        %7Delse if (id == 2) %7B%0A            mGenericStatusLayout.showError();%0A            new AsyncTask%3CVoid,Void,Void%3E()%7B%0A%0A                @Override%0A                protected Void doInBackground(Void... params) %7B%0A                    SystemClock.sleep(3000);%0A                    return null;%0A                %7D%0A%0A                @Override%0A                protected void onPostExecute(Void aVoid) %7B%0A                    super.onPostExecute(aVoid);%0A                    mGenericStatusLayout.hideError();%0A                %7D%0A            %7D.execute();%0A            return true;%0A
         %7D%0A  

update GenericStatusLayoutDemo