text:
import attr
import pandas as pd
import re

from ..base import TohuBaseGenerator
from ..logging import logger

__all__ = ['get_tohu_items_name', 'make_tohu_items_class']

def make_tohu_items_class(clsname, attr_names):
    """
    Parameters
    ----------
    clsname: string
        Name of the class to be created

    attr_names: list of strings
        Names of the attributes of the class to be created
    """

    item_cls = attr.make_class(clsname, {name: attr.ib() for name in attr_names}, repr=False, cmp=True, frozen=True)

    def new_repr(self):
        all_fields = ', '.join([f'{name}={repr(value)}' for name, value in attr.asdict(self).items()])
        return f'{clsname}({all_fields})'

    orig_eq = item_cls.__eq__

    def new_eq(self, other):
        """
        Custom __eq__() method which also allows comparisons with
        tuples and dictionaries. This is mostly for convenience
        during testing.
        """

        if isinstance(other, self.__class__):
            return orig_eq(self, other)
        else:
            if isinstance(other, tuple):
                return attr.astuple(self) == other
            elif isinstance(other, dict):
                return attr.asdict(self) == other
            else:
                return NotImplemented

    item_cls.__repr__ = new_repr
    item_cls.__eq__ = new_eq
    item_cls.keys = lambda self: attr_names
    item_cls.__getitem__ = lambda self, key: getattr(self, key)
    item_cls.as_dict = lambda self: attr.asdict(self)
    item_cls.to_series = lambda self: pd.Series(attr.asdict(self))

    return item_cls

def get_tohu_items_name(cls):
    """
    Return a string which defines the name of the namedtuple class which will be used
    to produce items for the custom generator.

    By default this will be the first part of the class name (before '...Generator'),
    for example:

        FoobarGenerator -> Foobar
        QuuxGenerator   -> Quux

    However, it can be set explicitly by the user by defining `__tohu_items_name__`
    in the class definition, for example:

        class Quux(CustomGenerator):
            __tohu_items_name__ = 'MyQuuxItem'
    """
    assert issubclass(cls, TohuBaseGenerator)

    try:
        tohu_items_name = cls.__dict__['__tohu_items_name__']
        logger.debug(f"Using item class name '{tohu_items_name}' (derived from attribute '__tohu_items_name__')")
    except KeyError:
        m = re.match('^(.*)Generator$', cls.__name__)
        if m is not None:
            tohu_items_name = m.group(1)
            logger.debug(f"Using item class name '{tohu_items_name}' (derived from custom generator name)")
        else:
            msg = (
                "Cannot derive class name for items to be produced by custom generator. "
                "Please set '__tohu_items_name__' at the top of the custom generator's "
                "definition or change its name so that it ends in '...Generator'"
            )
            raise ValueError(msg)

    return tohu_items_name


text:
package com.java110.common.bmo.assetImportLogDetail.impl;

import com.java110.common.bmo.assetImportLogDetail.IGetAssetImportLogDetailBMO;
import com.java110.dto.assetImportLogDetail.AssetImportLogDetailDto;
import com.java110.intf.common.IAssetImportLogDetailInnerServiceSMO;
import com.java110.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service("getAssetImportLogDetailBMOImpl")
public class GetAssetImportLogDetailBMOImpl implements IGetAssetImportLogDetailBMO {

    @Autowired
    private IAssetImportLogDetailInnerServiceSMO assetImportLogDetailInnerServiceSMOImpl;

    /**
     * @param assetImportLogDetailDto
     * @return 订单服务能够接受的报文
     */
    public ResponseEntity<String> get(AssetImportLogDetailDto assetImportLogDetailDto) {

        int count = assetImportLogDetailInnerServiceSMOImpl.queryAssetImportLogDetailsCount(assetImportLogDetailDto);

        List<AssetImportLogDetailDto> assetImportLogDetailDtos = null;
        if (count > 0) {
            assetImportLogDetailDtos = assetImportLogDetailInnerServiceSMOImpl.queryAssetImportLogDetails(assetImportLogDetailDto);
        } else {
            assetImportLogDetailDtos = new ArrayList<>();
        }

        ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) assetImportLogDetailDto.getRow()), count, assetImportLogDetailDtos);

        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);

        return responseEntity;
    }

}

redpajama_set_name: RedPajamaGithub


text:
function makeData() {
  "use strict";

  var  data1 = [{month: "January", avg: 2.75, city: "Palo Alto"}, {month: "February", avg: 3.07, city: "Palo Alto"}, {month: "March", avg: 2.26, city: "Palo Alto"}, {month: "April", avg: 0.98, city: "Palo Alto"}, {month: "May", avg: 0.47, city: "Palo Alto"}, {month: "June", avg: 0.1, city: "Palo Alto"}, {month: "July", avg: 0.02, city: "Palo Alto"}, {month: "August", avg: 0.01, city: "Palo Alto"}, {month: "September", avg: 0.18, city: "Palo Alto"}, {month: "October", avg: 0.64, city: "Palo Alto"}, {month: "November", avg: 1.64, city: "Palo Alto"}, {month: "December", avg: 2.56, city: "Palo Alto"}];
  var  data2 = [{month: "January", avg: 4.21, city: "San Francisco"}, {month: "February", avg: 4.10, city: "San Francisco"}, {month: "March", avg: 2.74, city: "San Francisco"}, {month: "April", avg: 1.18, city: "San Francisco"}, {month: "May", avg: 0.72, city: "San Francisco"}, {month: "June", avg: 0.15, city: "San Francisco"}, {month: "July", avg: 0.01, city: "San Francisco"}, {month: "August", avg: 0.04, city: "San Francisco"}, {month: "September", avg: 0.19, city: "San Francisco"}, {month: "October", avg: 0.94, city: "San Francisco"}, {month: "November", avg: 2.50, city: "San Francisco"}, {month: "December", avg: 4.00, city: "San Francisco"}];
  var  data3 = [{month: "January", avg: 2.99, city: "San Jose"}, {month: "February", avg: 3.32, city: "San Jose"}, {month: "March", avg: 2.04, city: "San Jose"}, {month: "April", avg: 1.06, city: "San Jose"}, {month: "May", avg: 0.39, city: "San Jose"}, {month: "June", avg: 0.09, city: "San Jose"}, {month: "July", avg: 0.00, city: "San Jose"}, {month: "August", avg: 0.0, city: "San Jose"}, {month: "September", avg: 0.23, city: "San Jose"}, {month: "October", avg: 0.78, city: "San Jose"}, {month: "November", avg: 1.88, city: "San Jose"}, {month: "December", avg: 2.12, city: "San Jose"}];

  return [data1, data2, data3];
}

function run(svg, data, Plottable){
  "use strict";

  var xScale = new Plottable.Scales.Category();
  var yScale = new Plottable.Scales.Linear();
  var colorScale = new Plottable.Scales.Color();

  var xAxis = new Plottable.Axes.Category(xScale, "bottom");
  var yAxis = new Plottable.Axes.Numeric(yScale, "left");

  var clusteredPlot = new Plottable.Plots.ClusteredBar("vertical")
    .addDataset(new Plottable.Dataset(data[0]))
    .addDataset(new Plottable.Dataset(data[1]))
    .addDataset(new Plottable.Dataset(data[2]))
    .x(function(d) { return d.month; }, xScale)
    .y(function(d) { return d.avg; }, yScale)
    .attr("label", function(d) { return d.avg; })
    .attr("fill", function(d) { return d.city; }, colorScale);

  var legend = new Plottable.Components.Legend(colorScale);
  var title = new Plottable.Components.TitleLabel("Average Rainfall in Different Cities between 2013-2014");
  var yUnitLabel = new Plottable.Components.AxisLabel("Inches").angle(-90);

  var chart = new Plottable.Components.Table([
                                            [null,       null,  title        ],
                                            [null,       null,  legend       ],
                                            [yUnitLabel, yAxis, clusteredPlot],
                                            [null,       null,  xAxis        ]]);

  chart.renderTo(svg);
}


text:
<!DOCTYPE HTML>

<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>QUnit Page for sap.ui.core.util.MockServer Class</title>

<script src="../shared-config.js"></script>
<script id="sap-ui-bootstrap"
	src="../../../../../resources/sap-ui-core.js"
	data-sap-ui-theme="sap_bluecrystal" data-sap-ui-noConflict="true"
	data-sap-ui-libs="sap.ui.commons">

</script>

<link rel="stylesheet"
	href="../../../../../resources/sap/ui/thirdparty/qunit.css"
	type="text/css" media="screen" />
<script
	src="../../../../../resources/sap/ui/thirdparty/qunit.js"></script>
<script
	src="../../../../../resources/sap/ui/qunit/qunit-junit.js"></script>
<script
	src="../../../../../resources/sap/ui/qunit/QUnitUtils.js"></script>

<script>
//require the mock server before testing
jQuery.sap.require("sap.ui.core.util.MockServer");

QUnit.module('GIVEN data and complex filter features in MockServer', {
    beforeEach: function () {
    	this.oMockServer = new sap.ui.core.util.MockServer({
   	   	 rootUri: "/myService/"
   		});
   		this.simpleXML = 'testdata/apfapp/tMockServerFeatureTestingMetadata.xml';
   		this.simpleJSON = 'testdata/apfapp/';
   		this.oMockServer.simulate(this.simpleXML, this.simpleJSON);
   		this.oMockServer.start();

        this.log = function (text) {
            var prevLevel = jQuery.sap.log.getLevel();
            jQuery.sap.log.setLevel(jQuery.sap.log.Level.DEBUG);
            jQuery.sap.log.debug("  ##test: " + text);
            jQuery.sap.log.setLevel(prevLevel);
        };
        this.post = function (object, type) {
            var oSettings = JSON.stringify(object);
            this.oResponse = jQuery.sap.syncPost("/myService/" + type, oSettings, "json");
        };
        this.postSet = function (aSet, type) {
            var i = 0;
            for (i; i < aSet.length; ++i) {
                this.oResponse = jQuery.sap.syncPost("/myService/" + type, JSON.stringify(aSet[i]), "json");
            }
        };
        this.postTable = function (aTable, oTemplate, sType) {
            var row, attr = 0, member;
            var obj;
            for (row = 0; row < aTable.length; ++row) {
                obj = {};
                attr = 0;
                for (member in oTemplate) {
                    if (oTemplate.hasOwnProperty(member)) {
                        var value = (aTable[row])[attr];
                        obj["" + member] = value;
                        ++attr;
                    }
                }
                this.oResponse = jQuery.sap.syncPost("/myService/" + sType, JSON.stringify(obj), "json");
            }
        };
    },
    afterEach: function () {
        this.oMockServer.stop();
        this.oMockServer.destroy();
    }
});

// EQ upper case not supported, no hint/error message what goes wrong
   QUnit.test("row filter condition", function (assert) {
    var rowExpr = "(SAPClient eq 'SAPClient_0') and (Currency_E eq 6287.57)";
    var wcaQuery = "TestQueryResults?$filter=" + rowExpr;
    this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
    assert.ok(this.oResponse !== undefined, "response not undefined");
    assert.equal(this.oResponse.statusCode, 200);
    assert.equal(this.oResponse.data.d.results.length, 1, "1 row");
});
QUnit.test("row filter condition", function (assert) {
    var rowExpr = "(SAPClient EQ 'SAPClient_0')";
    var wcaQuery = "TestQueryResults?$filter=" + rowExpr;
    this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
    assert.equal(this.oResponse.statusCode, 400, "is as expected");
});

QUnit.test("AND not supported", function (assert) {
    var rowExpr = "(SAPClient eq 'SAPClient_0') AND (Currency_E eq 6287.57)";
    var wcaQuery = "TestQueryResults?$filter=" + rowExpr;
    this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
    //assert.ok(isNaN(this.oResponse.statusCode), "is as expected");
    assert.equal(this.oResponse.statusCode, 400);
});
QUnit.test("row filter condition", function (assert) {
    var rowExpr = "(SAPClient eq 'SAPClient_0')";
    var wcaQuery = "TestQueryResults?$filter=" + rowExpr;
    this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
    assert.ok(this.oResponse !== undefined, "response not undefined");
    assert.equal(this.oResponse.statusCode, "200");
    assert.equal(this.oResponse.data.d.results.length, 1, "1 row");
});
QUnit.test("row filter condition w/o brackets", function (assert) {
    var rowExpr = "SAPClient eq 'SAPClient_0' and Currency_E eq 6287.57 and P_SAPClient eq 776";
    var wcaQuery = "TestQueryResults?$filter=" + rowExpr;
    this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
    assert.ok(this.oResponse !== undefined, "response not undefined");
    assert.equal(this.oResponse.statusCode, "200");
    assert.equal(this.oResponse.data.d.results.length, 1, "1 row");
});

QUnit.test("BUG row filter condition w/o brackets shall fail", function (assert) {
    var row1 = "SAPClient eq 'SAPClient_0' and Currency_E eq 6287.57 and P_SAPClient eq 776";
    var row2 = "SAPClient eq 'SAPClient_1' and Currency_E eq 3878.94 and P_SAPClient eq 776";
    var wcaQuery = "TestQueryResults?$filter=" + row1 + " or " + row2;
    this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
    assert.ok(this.oResponse !== undefined, "response not undefined");
    assert.equal(this.oResponse.statusCode, "200");
    assert.equal(this.oResponse.data.d.results.length, 1, "correct 2 rows <<<<< BUG");
    assert.equal(this.oResponse.data.d.results[0].ID, "ID_1", " correct ID_0 <<<<< BUG");
});

QUnit.test("row filter condition with brackets", function (assert) {
    var row1 = "(SAPClient eq 'SAPClient_0' and Currency_E eq 6287.57 and P_SAPClient eq 776)";
    var row2 = "(SAPClient eq 'SAPClient_1' and Currency_E eq 3878.94 and P_SAPClient eq 776)";
    var wcaQuery = "TestQueryResults?$filter=" + row1 + " or " + row2;
    this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
    assert.ok(this.oResponse !== undefined, "response not undefined");
    assert.equal(this.oResponse.statusCode, "200", "200 expected");
    assert.equal(this.oResponse.data.d.results.length, 2, "2 row");
});

QUnit.test("multi rows, 1", function (assert) {
    var orExpr = "SAPClient eq 'SAPClient_0' or Currency_E eq 6287.57 or P_SAPClient eq 776";
    var wcaQuery = "TestQueryResults?$filter=" + orExpr;
    this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
    assert.equal(this.oResponse.statusCode, "200");
    assert.equal(this.oResponse.data.d.results[0].ID, "ID_0");
});

QUnit.test("multi rows, 2", function (assert) {
    var orExpr = "SAPClient eq 'SAPClient_0' or SAPClient eq 'SAPClient_1'";
    var wcaQuery = "TestQueryResults?$filter=" + orExpr;
    this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
    assert.equal(this.oResponse.statusCode, "200");
    assert.equal(this.oResponse.data.d.results[0].ID, "ID_0");
});

QUnit.test("multi rows, 2", function (assert) {
    var orExpr = "(SAPClient eq 'SAPClient_0' and P_SAPClient eq 776) or (SAPClient eq 'SAPClient_1'  and P_SAPClient eq 776)";
    var wcaQuery = "TestQueryResults?$filter=" + orExpr;
    this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
    assert.equal(this.oResponse.statusCode, "200", "200 expected");
    assert.equal(this.oResponse.data.d.results.length, 2, "2 row");
});

QUnit.test("multi rows, 2", function (assert) {
    var orExpr = "SAPClient eq 'SAPClient_0' and P_SAPClient eq 776 or SAPClient eq 'SAPClient_1'  and P_SAPClient eq 776";
    var wcaQuery = "TestQueryResults?$filter=" + orExpr;
    this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
    assert.equal(this.oResponse.statusCode, "200");
    assert.equal(this.oResponse.data.d.results[0].ID, "ID_0");
    assert.equal(this.oResponse.data.d.results[1].ID, "ID_1");
});

QUnit.test("multi rows, 2, brackets around or", function (assert) {
    var orExpr = "(SAPClient eq 'SAPClient_0' and P_SAPClient eq 776 or SAPClient eq 'SAPClient_1'  and P_SAPClient eq 776)";
    var wcaQuery = "TestQueryResults?$filter=" + orExpr;
    this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
    assert.equal(this.oResponse.statusCode, "200");
    assert.equal(this.oResponse.data.d.results[0].ID, "ID_0");
    assert.equal(this.oResponse.data.d.results[1].ID, "ID_1");
});

// BUG with brackets
QUnit.test("multi rows, 2, brackets around or", function (assert) {
    var orExpr = "((SAPClient eq 'SAPClient_0') and P_SAPClient eq 776 or SAPClient eq 'SAPClient_1'  and P_SAPClient eq 776)";
    var wcaQuery = "TestQueryResults?$filter=" + orExpr;
    this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
    assert.equal(this.oResponse.statusCode, "200");
    assert.equal(this.oResponse.data.d.results[0].ID, "ID_0");
    assert.equal(this.oResponse.data.d.results.length, 1, "1 row  <<<<<<<<<<< BUG");  // should be 2 rows
});

QUnit.test("multi rows, 2, brackets around or AND eq ", function (assert) {
    var orExpr = "(SAPClient eq 'SAPClient_0' and P_SAPClient eq 776 or SAPClient eq 'SAPClient_1'  and P_SAPClient eq 776) and P_SAPClient eq 776";
    var wcaQuery = "TestQueryResults?$filter=" + orExpr;
    this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
    assert.equal(this.oResponse.statusCode, "200");
    assert.equal(this.oResponse.data.d.results[0].ID, "ID_0");
    assert.equal(this.oResponse.data.d.results[1].ID, "ID_1");
});

QUnit.test("multi rows, 2, brackets around or AND eq in brackets", function (assert) {
    var orExpr = "(SAPClient eq 'SAPClient_0' and P_SAPClient eq 776 or SAPClient eq 'SAPClient_1' and P_SAPClient eq 776) and (P_SAPClient eq 776 or P_SAPClient eq 776)";
    var wcaQuery = "TestQueryResults?$filter=" + orExpr;
    this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
    assert.equal(this.oResponse.statusCode, "200", "200 expected");
    assert.equal(this.oResponse.data.d.results.length, 2, "2 row");
});

QUnit.test("POST object", function (assert) {
    var myData = {
        "ID": "ID_100",
        "P_SAPClient": 778,
        "SAPClient": "SAPClient_100",
        "Currency_E": 1234
    };
    this.post(myData, "TestQueryResults");
    assert.ok(this.oResponse !== undefined, "response undefined");

    var rowExpr = "(SAPClient eq 'SAPClient_100')";
    var wcaQuery = "TestQueryResults?$filter=" + rowExpr;
    var response = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
    assert.equal(response.statusCode, "200");
    var atomId = "/myService/TestQueryResults(ID='ID_100',P_SAPClient=778)";
    response = jQuery.sap.sjax({url: atomId });
    assert.equal(response.statusCode, "200");
});

QUnit.test("POST set of objects", function (assert) {
    var aSet = [];
    aSet.push({
        "ID": "ID_101",
        "P_SAPClient": 999,
        "SAPClient": "SAPClient_999",
        "Currency_E": 1234
    });
    aSet.push({
        "ID": "ID_102",
        "P_SAPClient": 999,
        "SAPClient": "SAPClient_999",
        "Currency_E": 11234
    });
    this.postSet(aSet, "TestQueryResults");

    var response = jQuery.sap.sjax({url: "/myService/TestQueryResults?$filter=(SAPClient eq 'SAPClient_999')"});
    assert.equal(response.statusCode, "200");
    assert.equal(response.data.d.results.length, 2, "many");

    response = jQuery.sap.sjax({url: "/myService/TestQueryResults(ID='ID_101',P_SAPClient=999)" });
    assert.ok(response.data.d !== undefined, "match");
    response = jQuery.sap.sjax({url: "/myService/TestQueryResults(ID='ID_102',P_SAPClient=999)" });
    assert.ok(response.data.d !== undefined, "match");
});

QUnit.test("POST table", function (assert) {
    var aTable = [
        ["ID_101", 999, "SAPClient_999", 11234],
        ["ID_102", 999, "SAPClient_999", 111234]
    ];
    var template = { 'ID': null, 'P_SAPClient': null, SAPClient: null, 'Currency_E': null };
    this.postTable(aTable, template, "TestQueryResults");

    var response = jQuery.sap.sjax({url: "/myService/TestQueryResults?$filter=(SAPClient eq 'SAPClient_999')"});
    assert.equal(response.statusCode, "200");
    assert.equal(response.data.d.results.length, 2, "many");

    response = jQuery.sap.sjax({url: "/myService/TestQueryResults(ID='ID_101',P_SAPClient=999)" });
    assert.ok(response.data.d !== undefined, "match");
    response = jQuery.sap.sjax({url: "/myService/TestQueryResults(ID='ID_102',P_SAPClient=999)" });
    assert.ok(response.data.d !== undefined, "match");
});

	 QUnit.module('MockServer URI ', {
	        beforeEach: function () {

        		this.simpleXML = 'testdata/apfapp/tMockServerFeatureTestingMetadata.xml';
        		this.simpleJSON = 'testdata/apfapp/';
	        	this.localhost = "http://localhost:9999"; /* avoid running on the same host:port -> test will fail! */
	            this.path = "/mickeyMouse"
	            this.absUri = this.simpleXML;
	            this.metaUri = "/$metadata";

	        }
	    });
	    QUnit.test("test full URL path", function(assert) {
	        var stubbedServer = new sap.ui.core.util.MockServer({
	            rootUri : this.localhost + this.path + "/"
	        });
	        var sMetadataUrl = this.localhost + this.path + this.metaUri;
	        stubbedServer.simulate(this.simpleXML);
	        stubbedServer.start();
	        assert.ok(stubbedServer.isStarted(), "Mock server is started");

	        var oResponse = jQuery.sap.sjax({url: sMetadataUrl});
	        assert.ok(oResponse !== undefined, "response not undefined");
	        assert.equal(oResponse.statusCode, "200", "200 http status");

	        stubbedServer.destroy();
	    });

	    QUnit.test("test w/0 horst URL path", function(assert) {
	        var stubbedServer = new sap.ui.core.util.MockServer({
	            rootUri : this.path + "/"
	        });
	        var sMetadataUrl = this.path + this.metaUri;
	        stubbedServer.simulate(this.simpleXML);
	        stubbedServer.start();
	        assert.ok(stubbedServer.isStarted(), "Mock server is started");

	        var oResponse = jQuery.sap.sjax({url: sMetadataUrl});
	        assert.ok(oResponse !== undefined, "response not undefined");
	        assert.equal(oResponse.statusCode, "200", "200 http status");

	        stubbedServer.destroy();
	    });

//TODO check in IE8
	/*    QUnit.test("mock server w/0 host but request URL path with host", function(assert) {
	        var stubbedServer = new sap.ui.core.util.MockServer({
	            rootUri : this.path + "/"
	        });
	        var sMetadataUrl = this.path + this.metaUri;
	        stubbedServer.simulate(simpleXML);
	        stubbedServer.start();
	        assert.ok(stubbedServer.isStarted(), "Mock server is started");

	        var oResponse = jQuery.sap.sjax({url: this.localhost + sMetadataUrl});
	        assert.ok(oResponse !== undefined, "response not undefined");
	        assert.equal(oResponse.statusCode, "0", "expected 200 http status <<<<<<<<<<< but BUG");

	        stubbedServer.destroy();
	    });
*/
	    QUnit.module('MockServer requests', {
	        beforeEach: function () {
	        	this.oMockServer = new sap.ui.core.util.MockServer({
	        	   	 rootUri: "/myService/"
	        		});
	        		this.simpleXML = 'testdata/apfapp/tMockServerFeatureTestingMetadata.xml';
	        		this.simpleJSON = 'testdata/apfapp/';
	        		this.oMockServer.simulate(this.simpleXML, this.simpleJSON);
	        		this.oMockServer.start();
	        },
	        afterEach: function () {
	            this.oResponse = undefined;
	            this.oMessageHandler = undefined;
	            this.oFilter = undefined;
	            this.oCoreApi = undefined;
	            this.oMetadata = undefined;
	            this.oMockServer.destroy();
	        }
	    });

	    QUnit.test("request TestQuery", function (assert) {
	        this.oResponse = jQuery.sap.sjax({url: "/myService/TestQuery"});
	        assert.ok(this.oResponse !== undefined, "response not undefined");
	        assert.equal(this.oResponse.statusCode, "200", "200 http status");
	    });

	    QUnit.test("request TestQuery", function (assert) {
	        this.oResponse = jQuery.sap.sjax({url: "/myService/TestQueryResults"});
	        assert.ok(this.oResponse !== undefined, "response not undefined");
	        assert.equal(this.oResponse.statusCode, "200", "200 http status");
	    });

	    QUnit.test("request with predicate", function (assert) {
	        this.oResponse = jQuery.sap.sjax({url: "/myService/TestQuery(P_SAPClient=777)"});
	        assert.ok(this.oResponse !== undefined, "response not undefined");
	        assert.equal(this.oResponse.statusCode, "200", "200 http status");
	    });

	    QUnit.test("request TestQuery & predicate & navigate", function (assert) {
	        this.oResponse = jQuery.sap.sjax({url: "/myService/TestQuery(P_SAPClient=777)/Results"});
	        assert.ok(this.oResponse !== undefined, "response not undefined");
	        assert.equal(this.oResponse.statusCode, "200", "200 http status");
	    });

	    QUnit.test("request TestQuery & predicate & navigate & paging", function (assert) {
	        this.oResponse = jQuery.sap.sjax({url: "/myService/TestQuery(P_SAPClient=777)/Results?$top=2"});
	        assert.ok(this.oResponse !== undefined, "response not undefined");
	        assert.equal(this.oResponse.statusCode, "200", "200 http status");
	    });

	    QUnit.test("request TestQuery & predicate & navigate & 2nd page", function (assert) {
	        this.oResponse = jQuery.sap.sjax({url: "/myService/TestQuery(P_SAPClient=777)/Results?$top=2&$skip=2"});
	        assert.ok(this.oResponse !== undefined, "response not undefined");
	        assert.equal(this.oResponse.statusCode, "200", "200 http status");
	    });

	    QUnit.test("request TestQuery & predicate & navigate & inlinecount", function (assert) {
	        this.oResponse = jQuery.sap.sjax({url: "/myService/TestQuery(P_SAPClient=777)/Results?$inlinecount=allpages"});
	        assert.ok(this.oResponse !== undefined, "response not undefined");
	        assert.equal(this.oResponse.statusCode, "200", "200 http status");
	    });

	//---------
	    QUnit.test("$format=json", function (assert) {
	        var wcaQuery = "TestQueryResults?$format=json";
	        this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
	        assert.ok(this.oResponse !== undefined, "response not undefined");
	        assert.equal(this.oResponse.statusCode, "200");
	    });

	    QUnit.test("$filter=(...)", function (assert) {
	        var wcaQuery = "TestQueryResults?$filter=(P_SAPClient eq 777)";
	        this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
	        assert.ok(this.oResponse !== undefined, "response not undefined");
	        assert.equal(this.oResponse.statusCode, "200");
	    });

	    QUnit.test("request of WCA query & filter & no navigation", function (assert) {
	        var wcaQuery = "TestQueryResults?$filter=P_SAPClient eq 777";
	        this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
	        assert.ok(this.oResponse !== undefined, "response not undefined");
	        assert.equal(this.oResponse.statusCode, "200", "200 http status");
	        assert.equal(this.oResponse.data.d.results.length, 53, "all 777");
	    });

	    QUnit.test("request of WCA query & orderby", function (assert) {
	        var wcaQuery = "TestQueryResults?$orderby=Currency_E";
	        this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
	        assert.ok(this.oResponse !== undefined, "response not undefined");
	        assert.equal(this.oResponse.statusCode, "200", "200 http status");
	        assert.equal(this.oResponse.data.d.results.length, 100, "all 777");
	        assert.ok(this.oResponse.data.d.results[0].Currency_E <= this.oResponse.data.d.results[1].Currency_E, "ascending");
	    });

	    QUnit.test("1 filter & orderby", function (assert) {
	        var wcaQuery = "TestQueryResults?$filter=P_SAPClient eq 777&$orderby=Currency_E";
	        this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
	        assert.ok(this.oResponse !== undefined, "response not undefined");
	        assert.equal(this.oResponse.statusCode, "200", "200 http status");
	        assert.equal(this.oResponse.data.d.results.length, 53, "all 777");
	        assert.ok(this.oResponse.data.d.results[0].Currency_E <= this.oResponse.data.d.results[1].Currency_E, "ascending");
	    });

	    QUnit.test("BUG spaces in system query handling", function (assert) {
	        // space around & not processed correctly
	        var wcaQuery = "TestQueryResults?$filter=P_SAPClient eq 777 & $orderby=Currency_E";
	        this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
	        assert.ok(this.oResponse !== undefined, "response not undefined");
	        assert.equal(this.oResponse.statusCode, "200", "200 http status");
	        assert.equal(this.oResponse.data.d.results.length, 53, "all 777");
	        var ordered = this.oResponse.data.d.results[0].Currency_E <= this.oResponse.data.d.results[1].Currency_E;
	        assert.ok(!ordered, "un ordered");
	    });

	    QUnit.test("probably BUG malformed filter", function (assert) {
	        // &$filter= twice
	        // http://msdn.microsoft.com/en-us/library/hh169248(v=nav.71).aspx
	        // http://docs.oasis-open.org/odata/odata/v4.0/csprd01/part2-url-conventions/odata-v4.0-csprd01-part2-url-conventions.html
	        var wcaQuery = "TestQueryResults?$filter=P_SAPClient eq 777&$filter=SAPClient eq 'SAPClient_22'";
	        this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
	        assert.ok(this.oResponse !== undefined, "response not undefined");
	        assert.equal(this.oResponse.statusCode, "200", "200 http status");
	        assert.equal(this.oResponse.data.d.results.length, 1, "all 777");
	    });
	    QUnit.test("400 when malformed filter", function (assert) {
	        // "AND $filter !!!!
	        var wcaQuery = "TestQueryResults?$filter=P_SAPClient eq 777 and $filter=P_SAPClient eq 777";
	        this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
	        assert.ok(this.oResponse !== undefined, "response not undefined");
	        assert.equal(this.oResponse.statusCode, "400", "400 http status is correct");
	    });
	    QUnit.test("BUG malformed filter", function (assert) {
	        // MickeyMouse
	        var wcaQuery = "TestQueryResults?$filter=SAPClient eq 'SAPClient_21' MickeyMouse and SAPClient eq 'SAPClient_22'";
	        this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
	        assert.equal(this.oResponse.statusCode, "200", "400 expected resp. malformed URI");
	    });

	    QUnit.test("request of WCA query & filter match 1 element", function (assert) {
	        var wcaQuery = "TestQueryResults?$filter=SAPClient eq 'SAPClient_22'";
	        this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
	        assert.ok(this.oResponse !== undefined, "response not undefined");
	        assert.equal(this.oResponse.statusCode, "200", "200 http status");
	        assert.equal(this.oResponse.data.d.results.length, 1, "1 match");
	    });

	    QUnit.test("request of WCA query & 2 filters match 0 element", function (assert) {
	        var wcaQuery = "TestQueryResults?$filter=SAPClient eq 'SAPClient_22'";
	        this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
	        assert.ok(this.oResponse !== undefined, "response not undefined");
	        assert.equal(this.oResponse.statusCode, "200", "200 http status");
	        assert.equal(this.oResponse.data.d.results.length, 1, "1 match");
	    });

	    QUnit.test("request of WCA query & 2 filters by and", function (assert) {
	        var wcaQuery = "TestQueryResults?$filter=P_SAPClient eq 776 and SAPClient eq 'SAPClient_22'";
	        this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
	        assert.equal(this.oResponse.statusCode, "200", "200 http status");
	        assert.equal(this.oResponse.data.d.results.length, 1, "shall be 1");
	    });

	    QUnit.test("request of WCA query & 2 filters by or", function (assert) {
	        var wcaQuery = "TestQueryResults?$filter=SAPClient eq 'SAPClient_21' or SAPClient eq 'SAPClient_22'";
	        this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
	        assert.equal(this.oResponse.statusCode, "200", "200 http status");
	        assert.equal(this.oResponse.data.d.results.length, 2, "shall be 2");
	    });

	    QUnit.test("request of WCA query w/o encoding", function (assert) {
	        var wcaQuery = "TestQuery(P_SAPClient=777)/Results?$select=ID,P_SAPClient&$filter=P_SAPClient eq 777";
	        this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
	        assert.ok(this.oResponse !== undefined, "response not undefined");
	        assert.equal(this.oResponse.statusCode, "200", "200 http status");
	    });

	    QUnit.test("request of WCA query w/o $batch", function (assert) {
	        var wcaQuery = "TestQuery(P_SAPClient=777)/Results?$select=ID,Currency_E,SAPClient&$filter=SAPClient%20eq%20%27SAPClient_53%27";
	        this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
	        assert.ok(this.oResponse !== undefined, "response not undefined");
	        assert.equal(this.oResponse.statusCode, "200", "200 http status");
	    });

/*
	    QUnit.module('MockServer metadata included requests', {
	        beforeEach: function () {
	            var that = this;

	            this.stubApfCoreAjax = sinon.stub(sap.apf.core, "ajax", function (oSettings) {
	                return null;
	            });
	            this.stubAnnotations = sinon.stub(sap.apf.core.annotation, "parse", function () {
	                return {};
	            });
	            this.oMessageHandler = new sap.apf.core.MessageHandler();
	            this.stubPutMessage = sinon.stub(this.oMessageHandler, "putMessage", function (oMessage, nMaxPreviousObjects) {

	            });

	            var oCoreApi = new sap.apf.core.Instance(that.oMessageHandler);
	            this.oMetadata = new sap.apf.core.Metadata({
	                coreApi: oCoreApi,
	                hashtable: sap.apf.utils.Hashtable,
	                datajs: OData,
	                messageHandler: that.oMessageHandler
	            }, '/myService/');
	        },
	        afterEach: function () {
	            this.oResponse = undefined;
	            this.oMessageHandler = undefined;
	            this.oFilter = undefined;
	            this.oCoreApi = undefined;
	            this.oMetadata = undefined;
	            this.stubPutMessage.restore();
	            this.stubApfCoreAjax.restore();
	            this.stubAnnotations.restore();
	        }
	    });
	// TODO fix xsfr token problem
	    QUnit.test("request metadata", function (assert) {
	        this.oResponse = this.oMetadata.getPropertyMetadata("TestQueryResultsType", "SAPClient");
	        assert.equal(JSON.stringify(this.oResponse), '{"name":"SAPClient","dataType":{"type":"Edm.Int32","maxLength":"3"},"aggregation-role":"dimension","label":"SAP Client"}', "");
	        assert.ok(this.stubPutMessage.calledOnce);
	    });

	    QUnit.module('MockServer batch requests', {
	        beforeEach: function () {
	            var that = this,
	                result;
	            this.stubApfCoreAjax = sinon.stub(sap.apf.core, "ajax", function (oSettings) {
	                return null;
	            });
	            this.stubAnnotations = sinon.stub(sap.apf.core.annotation, "parse", function () {
	                return {};
	            });

	            this.oMessageHandler = new sap.apf.core.MessageHandler();
	            this.stubPutMessage = sinon.stub(this.oMessageHandler, "putMessage", function (oMessage, nMaxPreviousObjects) {

	            });
	            this.oFilter = new sap.apf.core.utils.Filter(this.oMessageHandler, 'P_SAPClient', sap.apf.core.constants.FilterOperators.EQ, 777);
	            this.oCoreApi = new sap.apf.core.Instance(this.oMessageHandler);
	            this.oMetadata = new sap.apf.core.Metadata({
	                coreApi: that.oCoreApi,
	                hashtable: sap.apf.utils.Hashtable,
	                datajs: OData,
	                messageHandler: that.oMessageHandler
	            }, '/myService/');

	            this.requestConfig = {
	                type: "request",
	                id: "requestForTesting",
	                entityType: 'TestQuery',
	                selectProperties: [ 'ID' ],
	                service: "/myService"
	            };
	            this.oInject = {
	                messageHandler: that.oMessageHandler,
	                coreApi: that.oCoreApi
	            };
	        },
	        afterEach: function () {
	            this.oResponse = undefined;
	            this.oMessageHandler = undefined;
	            this.oFilter = undefined;
	            this.oCoreApi = undefined;
	            this.oMetadata = undefined;
	            this.oRequest = undefined;
	            this.stubPutMessage.restore();
	            this.stubApfCoreAjax.restore();
	            this.stubAnnotations.restore();
	        }
	    });

	// GIVEN request with $select=ID, no filter WHEN $batch GET THEN response has all data
	    QUnit.test("batch get request via sap.apf.core.request & selected ID", function (assert) {
	    	var done = assert.async();
	        assert.expect(4);
	        var that = this;
	        this.oRequest = new sap.apf.core.Request(this.oInject, this.requestConfig);

	        this.oRequest.sendGetInBatch(this.oFilter, function (result) {
	            assert.ok(result !== undefined, "Response not undefined");
	            assert.ok(result.data !== undefined, "data returned");
	            assert.equal(result.data.length, 53); // join on client 777
	            assert.ok(that.stubPutMessage.called);
	            done();
	        });
	    });

	    QUnit.test("batch get & selected ID & full select", function (assert) {
	    	var done = assert.async();
	        assert.expect(3);
	        var that = this;
	        this.requestConfig.selectProperties = [ 'ID', 'Currency_E', 'SAPClient' ];
	        this.oRequest = new sap.apf.core.Request(this.oInject, this.requestConfig);

	        this.oRequest.sendGetInBatch(this.oFilter, function (result) {
	            assert.ok(result !== undefined, "Response not undefined");
	            assert.ok(result.data !== undefined, "data returned");
	            assert.equal(result.data.length, 53);  // join on client 777
	            done();
	        });
	    });

	    QUnit.test("batch get & many selected & filter on SAPClient", function (assert) {
	    	var done = assert.async();
	        assert.expect(4);
	        var that = this;

	        this.stubBuildUri = sinon.stub(sap.apf.core.utils.uriGenerator, "buildUri", function () {
	            that.result = "TestQuery(P_SAPClient=777)/Results?$select=ID,Currency_E,SAPClient&$filter=SAPClient%20eq%20%27SAPClient_53%27&$format=json";
	            return that.result;
	        });

	        this.oFilter.addAnd('SAPClient', sap.apf.core.constants.FilterOperators.EQ, 'SAPClient_53');
	        this.requestConfig.selectProperties = [ 'ID', 'Currency_E', 'SAPClient' ];
	        this.oRequest = new sap.apf.core.Request(this.oInject, this.requestConfig);

	        this.oRequest.sendGetInBatch(this.oFilter, function (result) {
	            assert.ok(result !== undefined, "Response not undefined");
	            assert.ok(result.data !== undefined, "data returned");
	            assert.equal(result.data.length, 1);
	            assert.equal(result.data[0].ID, "ID_53");
	            done();
	        });
	    });

	    QUnit.test("Test Metadata Ref Constraints for local test data", function (assert) {

	        var wcaQuery = "TestQuery(P_SAPClient=777)/Results";
	        this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
	        assert.ok(this.oResponse !== undefined, "response not undefined");
	        assert.equal(this.oResponse.statusCode, "200", "200 http status");
	        var resultCounter = this.oResponse.data.d.results.length;
	        assert.equal(resultCounter, 53, "results returned");

	        wcaQuery = "TestQueryResults?$filter=P_SAPClient eq 777";
	        this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
	        assert.ok(this.oResponse !== undefined, "response not undefined");
	        assert.equal(this.oResponse.statusCode, "200", "200 http status");
	        assert.equal(this.oResponse.data.d.results.length, 53, "results returned");

	        assert.equal(this.oResponse.data.d.results.length, resultCounter, "same results");

	    });

	    QUnit.test("Test Metadata Ref Constraints for GENERATED test data", function (assert) {

	        oMockServer = new sap.ui.app.MockServer({
	            rootUri: "/myService/"
	        });

	        oMockServer.simulate(simpleXML);

	        var wcaQuery = "TestQuery(P_SAPClient=777)/Results";
	        this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
	        assert.ok(this.oResponse !== undefined, "response not undefined");
	        assert.equal(this.oResponse.statusCode, "200", "200 http status");
	        var resultCounter = this.oResponse.data.d.results.length;
	        assert.equal(resultCounter, 53, "results returned");

	        wcaQuery = "TestQueryResults?$filter=P_SAPClient eq 777";
	        this.oResponse = jQuery.sap.sjax({url: "/myService/" + wcaQuery});
	        assert.ok(this.oResponse !== undefined, "response not undefined");
	        assert.equal(this.oResponse.statusCode, "200", "200 http status");
	        assert.equal(this.oResponse.data.d.results.length, 53, "results returned");

	        assert.equal(this.oResponse.data.d.results.length, resultCounter, "same results");
	    });
*/

</script>
</head>
<body>
	<h1 id="qunit-header">
		<title>QUnit Page for sap.ui.core.util.MockServer Class</title>
	</h1>
	<h2 id="qunit-banner"></h2>
	<h2 id="qunit-userAgent"></h2>
	<ol id="qunit-tests"></ol>
	<div id="qunit-fixture">test markup, will be hidden</div>
	<div id="canvas" style="height: 300px; width: 300px"></div>
	<div id="target1"></div>
	<div id="target2"></div>
	<div id="target3"></div>
</body>
</html>


text:
package io.treehopper.libraries.sensors.inertial;

import com.badlogic.gdx.math.Vector3;
import io.treehopper.libraries.sensors.IPollable;

/**
 * Accelerometer interface
 */
public interface IAccelerometer extends IPollable {
    Vector3 getAccelerometer();
}


text:
package textapp.client

import javax.swing.SwingUtilities

object Utils {
  def invokeAndWait(block: () => Unit) {
    SwingUtilities.invokeAndWait(new Runnable {
      override def run = block.apply
    })
  }
}


text:
package org.arquillian.extension.governor.jira.api;

import org.arquillian.extension.governor.api.Governor;
import org.arquillian.extension.governor.api.detector.Detectable;
import org.arquillian.extension.governor.api.detector.Detector;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Place this annotation on a test method with JIRA issue (e.g. {@literal @Jira("ARQ-1")})
 *
 * @author Stefan Miklosovic
 */
@Governor
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@Documented
public @interface Jira {

    String value() default "";

    boolean force() default false;

    Detector detector() default @Detector(value = Detectable.True.class);
}


text:
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace Nemiro.OAuth.LoginForms
{

  internal class WebBrowser : System.Windows.Forms.WebBrowser
  {

    public static Guid IID_IHttpSecurity = new Guid("79eac9d7-bafa-11ce-8c82-00aa004ba90b");
    public static Guid IID_IWindowForBindingUI = new Guid("79eac9d5-bafa-11ce-8c82-00aa004ba90b");

    public const int S_OK = 0;
    public const int S_FALSE = 1;
    public const int E_NOINTERFACE = unchecked((int)0x80004002);
    public const int RPC_E_RETRY = unchecked((int)0x80010109);

    protected override WebBrowserSiteBase CreateWebBrowserSiteBase()
    {
      return new WebBrowserSite(this);
    }

    new class WebBrowserSite : System.Windows.Forms.WebBrowser.WebBrowserSite, UCOMIServiceProvider, IHttpSecurity, IWindowForBindingUI
    {

      private Nemiro.OAuth.LoginForms.WebBrowser _WebBrowser = null;

      public WebBrowserSite(Nemiro.OAuth.LoginForms.WebBrowser myWebBrowser)
        : base(myWebBrowser)
      {
        this._WebBrowser = myWebBrowser;
      }

      public int QueryService(ref Guid guidService, ref Guid riid, out IntPtr ppvObject)
      {

        if (riid == IID_IHttpSecurity)
        {
          ppvObject = Marshal.GetComInterfaceForObject(this, typeof(IHttpSecurity));
          return S_OK;
        }

        if (riid == IID_IWindowForBindingUI)
        {
          ppvObject = Marshal.GetComInterfaceForObject(this, typeof(IWindowForBindingUI));
          return S_OK;
        }

        /*if (riid == IID_IInternetProtocol)
        {
          ppvObject = Marshal.GetComInterfaceForObject(this, typeof(IInternetProtocol));
          return S_OK;
        }*/

        ppvObject = IntPtr.Zero;

        return E_NOINTERFACE;
      }

      public int GetWindow(ref Guid rguidReason, ref IntPtr phwnd)
      {
        if (rguidReason == IID_IHttpSecurity || rguidReason == IID_IWindowForBindingUI)
        {
          phwnd = _WebBrowser.Handle;
          return S_OK;
        }
        else
        {
          phwnd = IntPtr.Zero;
          return S_FALSE;
        }
      }

      public int OnSecurityProblem(uint dwProblem)
      {
        // ignore ssl errors
        return S_OK;
      }

    }

    [Guid("6D5140C1-7436-11CE-8034-00AA006009FA")]
    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    [ComImport]
    internal interface UCOMIServiceProvider
    {

      [return: MarshalAs(UnmanagedType.I4)]
      [PreserveSig]
      int QueryService([In] ref Guid guidService, [In] ref Guid riid, [Out] out IntPtr ppvObject);

    }

    [ComImport()]
    [ComVisible(true)]
    [Guid("79eac9d5-bafa-11ce-8c82-00aa004ba90b")]
    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
    internal interface IWindowForBindingUI
    {

      [return: MarshalAs(UnmanagedType.I4)]
      [PreserveSig]
      int GetWindow([In] ref Guid rguidReason, [In, Out] ref IntPtr phwnd);

    }

    [ComImport()]
    [ComVisible(true)]
    [Guid("79eac9d7-bafa-11ce-8c82-00aa004ba90b")]
    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
    internal interface IHttpSecurity
    {

      [return: MarshalAs(UnmanagedType.I4)]
      [PreserveSig]
      int GetWindow([In] ref Guid rguidReason, [In, Out] ref IntPtr phwnd);

      [PreserveSig]
      int OnSecurityProblem([In, MarshalAs(UnmanagedType.U4)] uint dwProblem);

    }

  }

}


text:
<?php

namespace Belvedere\Basecamp\Sections;

use Belvedere\Basecamp\Models\Person;

class People extends AbstractSection
{
    /**
     * Get people.
     *
     * @param  int  $page
     * @return \Illuminate\Support\Collection
     */
    public function index($page = null)
    {
        $url = 'people.json';

        $people = $this->client->get($url, [
            'query' => [
                'page' => $page,
            ]
        ]);

        return $this->indexResponse($people, Person::class);
    }

    /**
     * Get people on a project.
     *
     * @param  int     $bucket
     * @param  int     $page
     * @return \Illuminate\Support\Collection
     */
    public function inProject($bucket, $page = null)
    {
        $url = sprintf('projects/%d/people.json', $bucket);

        $people = $this->client->get($url, [
            'query' => [
                'page' => $page,
            ],
        ]);

        return $this->indexResponse($people, Person::class);
    }

    /**
     * Update an access to a project.
     *
     * @param  int     $bucket
     * @param  array   $data
     * @return \Illuminate\Support\Collection
     */
    public function updateAccessToProject($bucket, $data)
    {
        $access = $this->client->put(
            sprintf('projects/%d/people/users.json', $bucket),
            [
                'json' => $data,
            ]
        );

        return $this->response($access);
    }

    /**
     * Get pingable people.
     *
     * @param  string  $page
     * @return \Illuminate\Support\Collection
     */
    public function pingable($page = null)
    {
        $url = 'circles/people.json';

        $people = $this->client->get($url, [
            'query' => [
                'page' => $page,
            ],
        ]);

        return $this->indexResponse($people, Person::class);
    }

    /**
     * Get a person.
     *
     * @param  int  $id
     * @return \Illuminate\Support\Collection
     */
    public function show($id)
    {
        $person = $this->client->get(sprintf('people/%d.json', $id));

        return new Person($this->response($person));
    }

    /**
     * Get my profile.
     *
     * @return \Illuminate\Support\Collection
     */
    public function profile()
    {
        $profile = $this->client->get('my/profile.json');

        return new Person($this->response($profile));
    }
}


text:
import React, { Component } from 'react';
import { Link, browserHistory } from 'react-router';
import ShareModal from '../ShareModal';
import TransferTicketModal from '../TransferTicketModal';
import SellTicketModal from '../SellTicketModal';

class TicketCard extends Component {
  constructor(props) {
    super(props);
    this.state = {};
  }

  componentDidMount() {
    this.setState({
      ticketTransfered: false,
      initTransfer: false,
      isHover: false
    });
  }

  openShareTicketModal(ticket) {
    this.props.openShareTicketModal(ticket);
  }

  openTransferTicketModal(ticket) {
    this.props.openTransferTicketModal(ticket);
  }

  openSellTicketModal(ticket) {
    this.props.openSellTicketModal(ticket);
  }

  ticketClick(ticket) {
    browserHistory.push(`event/${ticket.event._id}/ticket/${ticket._id}`);
  }

  render() {
    const { ticket } = this.props;
    return (

 this.setState({isHover: true})}
        onMouseLeave={() => this.setState({isHover: false})}>

 this.ticketClick(ticket)}>
            {(ticket.isForSale) ?
For Sale
 : null }

 this.ticketClick(ticket)}>
            {ticket.event.name}
            {ticket.type}

            Ticket Number: {ticket.barcode}

             this.openShareTicketModal(ticket)} className="material-icons share-icon">share

              <Link className="action-button btn-flat waves-effect" onClick={() => this.openSellTicketModal(ticket)}>Sell</Link>
              <Link className="action-button btn-flat waves-effect" onClick={() => this.openTransferTicketModal(ticket)}>Transfer</Link>

 this.ticketClick(ticket)}>
            {(ticket.isForSale) ?
For Sale
 : null }

 this.ticketClick(ticket)}>
              {ticket.event.name}
              {ticket.type}

              Ticket Number: {ticket.barcode}

               this.openShareTicketModal(ticket)} className="material-icons share-icon">share

                <Link className="action-button btn-flat waves-effect" onClick={() => this.openSellTicketModal(ticket)}>Sell</Link>
                <Link className="action-button btn-flat waves-effect" onClick={() => this.openTransferTicketModal(ticket)}>Transfer</Link>

        <ShareModal
          ticket={this.props.ticket}
          closeModal={() => this.setState({shareTicketModalOpen: false})}
          isOpen={this.state.shareTicketModalOpen} />
        <SellTicketModal
          ticket={this.props.ticket}
          isOpen={this.props.sellTicketModalOpen} />
        <TransferTicketModal
          ticket={this.props.ticket}
          isOpen={this.props.transferTicketModalOpen} />

    );
  }
}

export default TicketCard;


text:
/*
 * This source code is licensed under the MIT-style license found in the
 * LICENSE file in the root directory of this source tree.
 */
package com.netease.hearttouch.htrefreshrecyclerview.viewimpl;

import android.animation.Animator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.widget.Scroller;

import com.netease.hearttouch.htrefreshrecyclerview.base.HTBaseRecyclerView;
import com.netease.hearttouch.htrefreshrecyclerview.base.HTOrientation;
import com.netease.hearttouch.htrefreshrecyclerview.base.HTViewHolderTracker;
import com.netease.hearttouch.htrefreshrecyclerview.base.HTWrapperAdapter;
import com.netease.hearttouch.htrefreshrecyclerview.utils.Utils;

import java.util.Arrays;
import java.util.List;

import static com.netease.hearttouch.htrefreshrecyclerview.utils.Utils.getFirstItemPosition;

/**
 * 实现的一种刷新基类
 */
abstract class HTBaseRecyclerViewImpl extends HTBaseRecyclerView {
    private boolean mScreenFilled;
    private int mStartPosition;
    private int mItemCount;
    protected ValueAnimator mLoadMoreAnimator;
    protected ScrollJob mScrollJob;
    protected MotionEvent mLastMoveEvent;
    protected boolean mHasSendCancelEvent;
    protected boolean mAutoRefresh;

    public HTBaseRecyclerViewImpl(Context context) {
        super(context);
    }

    public HTBaseRecyclerViewImpl(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public HTBaseRecyclerViewImpl(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean shouldHandleRefresh() {
        if (mHTViewHolder == null || mRefreshContainerView == null || mRefreshDelegate == null) {
            return false;
        }
        if (mRecyclerView.getLayoutManager() == null || mLoadMoreStatus != LoadMoreStatus.IDLE) {
            return false;
        }
        return true;
    }

    @Override
    public boolean shouldHandleLoadMore() {
        if (mHTViewHolder == null || mLoadMoreContainerView == null || mLoadMoreDelegate == null ||
                mHTWrapperAdapter == null || !mHTWrapperAdapter.hasLoadMoreView()) {
            return false;
        }

        if (mLoadMoreStatus == LoadMoreStatus.LOADING || mRefreshStatus != RefreshStatus.IDLE) {
            return false;
        }

        if (!mHasMore) {//没有更多数据不再触发加载更多
            if (mScreenFilled && !mLoadMoreViewDisplay) {//允许自动隐藏
                postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        changeLoadMoreViewPositionWithAnimation(-mLoadMoreViewSize, null);
                    }
                }, mHTViewHolder.getAnimationTime());
            }
            return false;
        }

        RecyclerView.LayoutManager manager = mRecyclerView.getLayoutManager();

        if (manager == null) {
            return false;
        }

        if (manager.getItemCount() <= 1) {//当前没有内容时,也允许触发加载更多
            return true;
        }

        int firstVisibleItem = getFirstItemPosition(manager, false);//获取第一个可见的Item位置
        return firstVisibleItem + manager.getChildCount() >= manager.getItemCount();
    }

    public boolean defaultDispatchTouchEvent(MotionEvent event) {
        return super.dispatchTouchEvent(event);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
        if (!isEnabled() || mRecyclerView == null || mRefreshContainerView == null) {
            return defaultDispatchTouchEvent(event);
        }

        if (mRefreshStatus == RefreshStatus.REFRESHING && !mEnableScrollOnReFresh) {
            return false;
        }

        switch (event.getAction()) {
            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_CANCEL:
                mHTViewHolderTracker.onRelease();
                if (mHTViewHolderTracker.hasLeftIdlePosition()) { //刷新视图不在初始位置
                    onViewRelease();//释放
                    if (mHTViewHolderTracker.hasMovedAfterPressedDown()) {
                        sendCancelEvent();//通知子view不在处理事件
                        return true;
                    }
                    return defaultDispatchTouchEvent(event);
                } else {
                    return defaultDispatchTouchEvent(event);
                }

            case MotionEvent.ACTION_DOWN:
                mHasSendCancelEvent = false;
                //记录按下的位置
                mHTViewHolderTracker.onPressDown(event.getX(), event.getY());
                //如果正在滚动,则立即终止
                mScrollJob.abortIfWorking();
                defaultDispatchTouchEvent(event);
                return true;

            case MotionEvent.ACTION_MOVE:
                mLastMoveEvent = event; //记录事件,以方便模拟事件
                mHTViewHolderTracker.onMove(event.getX(), event.getY());
                Boolean handled = handleMoveAction(event);
                if (handled != null) return handled;
        }
        return defaultDispatchTouchEvent(event);
    }

    protected void onViewRelease() {
        tryToPerformRefresh();
        if (mRefreshStatus == RefreshStatus.REFRESHING) {
            if (mHTViewHolderTracker.isOverRefreshViewSize()) { //触发刷新后,需要保持刷新视图,将刷新视图滚动到对应的刷新位置
                mScrollJob.tryToScrollTo(mHTViewHolderTracker.getRefreshViewSize(), mHTViewHolder.getAnimationTime(), 0);
            }
        } else {
            if (mRefreshStatus == RefreshStatus.COMPLETE) {
                notifyRefreshComplete();
            } else {
                tryScrollBackToOriginal();
            }
        }
    }

    protected void tryToPerformRefresh() {
        if (mRefreshStatus != RefreshStatus.REFRESH_PREPARE) {
            return;
        }
        if ((mHTViewHolderTracker.isOverRefreshViewSize() && isAutoRefresh()) || mHTViewHolderTracker.isOverOffsetToRefresh()) {
            mRefreshStatus = RefreshStatus.REFRESHING;
            performRefresh();
        }
    }

    protected void performRefresh() {
        if (mRefreshUIChangeListener != null) {
            mRefreshUIChangeListener.onRefreshing();
            mRefreshDelegate.onRefresh();
        }
    }

    protected void tryScrollBackToOriginal() {
        if (!mHTViewHolderTracker.isUnderTouch()) {
            mScrollJob.tryToScrollTo(HTViewHolderTracker.POSITION_IDLE, mHTViewHolder.getAnimationTime(), 0);
        }
    }

    protected void notifyRefreshComplete() {
        mRefreshUIChangeListener.onRefreshComplete();
        mHTViewHolderTracker.onUIRefreshComplete();
        tryScrollBackToOriginal();
        reset();
    }

    protected boolean reset() {
        if ((mRefreshStatus == RefreshStatus.COMPLETE || mRefreshStatus == RefreshStatus.REFRESH_PREPARE) && mHTViewHolderTracker.isIdlePosition()) {
            mHTViewHolder.onReset();
            mRefreshStatus = RefreshStatus.IDLE;
            mAutoRefresh = false;
            return true;
        }
        return false;
    }

    protected void sendCancelEvent() {
        // The ScrollJob will update position and lead to send cancel event when mLastMoveEvent is null.
        if (mLastMoveEvent == null) {
            return;
        }
        MotionEvent last = mLastMoveEvent;
        MotionEvent e = MotionEvent.obtain(last.getDownTime(), last.getEventTime() + ViewConfiguration.getLongPressTimeout(), MotionEvent.ACTION_CANCEL, last.getX(), last.getY(), last.getMetaState());
        defaultDispatchTouchEvent(e);
    }

    protected void sendDownEvent() {
        final MotionEvent last = mLastMoveEvent;
        MotionEvent e = MotionEvent.obtain(last.getDownTime(), last.getEventTime(), MotionEvent.ACTION_DOWN, last.getX(), last.getY(), last.getMetaState());
        defaultDispatchTouchEvent(e);
    }

    protected void onViewHolderScrollFinish() {
        if (mHTViewHolderTracker.hasLeftIdlePosition() && isAutoRefresh()) {
            onViewRelease();
        }
    }

    protected void onViewHolderScrollAbort() {
        if (mHTViewHolderTracker.hasLeftIdlePosition() && isAutoRefresh()) {
            onViewRelease();
        }
    }

    public boolean isAutoRefresh() {
        return mAutoRefresh;
    }

    /**
     * 刷新视图位置移动处理
     *
     * @param offset 偏移量
     */
    protected void updatePos(float offset) {
        if ((offset < 0 && mHTViewHolderTracker.isIdlePosition())) {
            return;
        }
        int to = mHTViewHolderTracker.getCurrentPos() + (int) offset;
        if (mHTViewHolderTracker.isScrollOver(to)) {
            to = HTViewHolderTracker.POSITION_IDLE;
        }

        mHTViewHolderTracker.setCurrentPos(to);
        int change = to - mHTViewHolderTracker.getLastPos();
        if (change == 0) {
            return;
        }

        boolean isUnderTouch = mHTViewHolderTracker.isUnderTouch();
        if (isUnderTouch && !mHasSendCancelEvent && mHTViewHolderTracker.hasMovedAfterPressedDown()) {
            mHasSendCancelEvent = true;
            sendCancelEvent();
        }

        if ((mHTViewHolderTracker.hasJustLeftIdlePosition() && mRefreshStatus == RefreshStatus.IDLE) /*||
                (mHTViewHolderTracker.isOverCompletePos() && mRefreshStatus == RefreshStatus.COMPLETE)*/) {
            mRefreshStatus = RefreshStatus.REFRESH_PREPARE;
            mRefreshUIChangeListener.onRefreshPrepare();
            if (mRecyclerViewDragListener != null) {
                mRecyclerViewDragListener.onRefreshViewPrepareToMove();
            }
        }

        // 回到初始位置
        if (mHTViewHolderTracker.hasJustBackToIdlePosition()) {
            reset();
            if (isUnderTouch) {
                sendDownEvent();
            }
        }
        if (mRefreshStatus == RefreshStatus.REFRESH_PREPARE) {
            //处理自动刷新
            if (mHTViewHolderTracker.hasJustReachedRefreshSizeFromIdle() && isAutoRefresh()) {
                tryToPerformRefresh();
            }
        }

        performUpdateViewPosition(change);//更新界面视图
        mRefreshUIChangeListener.onRefreshPositionChange(mHTViewHolderTracker.getCurrentPercent(), mHTViewHolderTracker.getCurrentPos(), mRefreshStatus, mHTViewHolderTracker);
    }

    protected abstract void performUpdateViewPosition(int change);

    @Override
    protected void initLoadMoreSupported() {
        mLoadMoreViewHolderListener = new HTWrapperAdapter.LoadMoreViewHolderListener() {
            @Override
            public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
                stopLoadMoreAnimation();
                mScreenFilled = isCurrentItemSizeOver(false);
                hideLoadMoreView(!mScreenFilled);
                mStartPosition = 0;
                mItemCount = 0;
            }

            @Override
            public void onBindData(RecyclerView.ViewHolder holder, int position) {
            }

            public void onBindData(RecyclerView.ViewHolder holder, int position, List<Object> payloads) {

            }

            @Override
            public void onViewDetachedFromWindow(RecyclerView.ViewHolder holder) {
            }

            @Override
            public void onItemRemoved(int positionStart, int itemCount) {
                mStartPosition = positionStart;//处理动画删除item时的loadMore的显示问题
                mItemCount = itemCount;
            }
        };
        if (mHTWrapperAdapter != null) {
            mHTWrapperAdapter.setLoadMoreViewHolderListener(mLoadMoreViewHolderListener);
        }
    }

    @Override
    protected void performLoadMore() {
        if (mLoadMoreStatus != LoadMoreStatus.LOADING && mLoadMoreDelegate != null && mHTViewHolder != null) {
            if (mHasMore) {
                mLoadMoreStatus = LoadMoreStatus.LOADING;
                processLoadMoreStatusChanged();
                mLoadMoreDelegate.onLoadMore();
                showLoadingMoreView();
            }
        }
    }

    @Override
    protected void endRefresh() {
        if (mRefreshStatus == RefreshStatus.REFRESHING && mRefreshDelegate != null && mHTViewHolder != null) {
            mRefreshStatus = RefreshStatus.COMPLETE;
            if (mScrollJob.isScrollRunning() && isAutoRefresh()) {
                return;
            }
            notifyRefreshComplete();
        }
    }

    @Override
    protected void endLoadMore() {
        if (mLoadMoreStatus == LoadMoreStatus.LOADING && mLoadMoreDelegate != null && mHTViewHolder != null) {
            mLoadMoreStatus = LoadMoreStatus.IDLE;
            processLoadMoreStatusChanged();
            if (mLoadMoreViewDisplay) {//一直显示没有更多提示
                if (mScreenFilled) {
                    if (mHasMore) {//还有更多数据的时候,满一屏动画隐藏,否则直接隐藏
                        changeLoadMoreViewPositionWithAnimation(-mLoadMoreViewSize, null);
                    } else {
                        hideLoadMoreView(false);
                    }
                } else {
                    hideLoadMoreView(true);
                }
            } else {
                if (mScreenFilled) {
                    changeLoadMoreViewPositionWithAnimation(-mLoadMoreViewSize, null);
                } else {
                    hideLoadMoreView(true);
                }
            }

        }

    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        if (mScrollJob != null) {
            mScrollJob.destroy();
        }
    }

    protected void stopLoadMoreAnimation() {
        if (mLoadMoreAnimator != null && mLoadMoreAnimator.isRunning()) {
            mLoadMoreAnimator.cancel();
        }
    }

    @Override
    public void setRefreshCompleted(boolean hasMore) {
        this.mHasMore = hasMore;
        if (mLoadMoreStatus == LoadMoreStatus.IDLE) {//非加载更多数据时,数据变化需要重置加载更多视图
            processLoadMoreStatusChanged();
        }
        endLoadMore();
        endRefresh();

    }

    @Override
    public void startAutoRefresh() {
        if (mRecyclerView != null && mHTViewHolder != null && mHTViewHolder.getRefreshContainerView() != null) {
            if (mRefreshStatus != RefreshStatus.IDLE || mLoadMoreStatus != LoadMoreStatus.IDLE || mRefreshDelegate == null) {
                return;
            }
            if (mScrollJob.isScrollRunning() || mLoadMoreAnimator != null && mLoadMoreAnimator.isRunning()) {
                return;
            }
            RecyclerView.LayoutManager layoutManager = mRecyclerView.getLayoutManager();
            if (layoutManager != null) {
                int pos = Utils.getFirstItemPosition(layoutManager, true);
                layoutManager.scrollToPosition(0);
                mScrollJob.tryToScrollTo(mHTViewHolderTracker.getOffsetToRefresh(), mHTViewHolder.getAnimationTime(), 10 * pos);
                mAutoRefresh = true;
            }
        }
    }

    @Override
    public void startAutoLoadMore() {
        if (mRecyclerView != null && mHTViewHolder != null && mHTWrapperAdapter != null && mHTWrapperAdapter.hasLoadMoreView()) {
            if (mRefreshStatus != RefreshStatus.IDLE || mLoadMoreStatus != LoadMoreStatus.IDLE) {
                return;
            }
            if (mScrollJob.isScrollRunning() || mLoadMoreAnimator != null && mLoadMoreAnimator.isRunning()) {
                return;
            }
            RecyclerView.LayoutManager layoutManager = mRecyclerView.getLayoutManager();
            if (layoutManager != null && layoutManager.getItemCount() > 0) {
                layoutManager.smoothScrollToPosition(mRecyclerView, null, layoutManager.getItemCount() - 1);
                performLoadMore();
            }
        }
    }

    private void showLoadingMoreView() {
        if (!mScreenFilled) {
            hideLoadMoreView(false);
        }
        if (mRecyclerView != null) {
            RecyclerView.LayoutManager layoutManager = mRecyclerView.getLayoutManager();
            if (layoutManager != null && layoutManager.getItemCount() > 0) {
                layoutManager.smoothScrollToPosition(mRecyclerView, null, layoutManager.getItemCount() - 1);
            }
        }
    }

    private int calculateChildrenSize(boolean includeLoadMore) {// TODO: 2017/8/8 高度计算有问题
        RecyclerView.LayoutManager layoutManager;
        if (mRecyclerView == null || (layoutManager = mRecyclerView.getLayoutManager()) == null)
            return 0;
        int childCount = layoutManager.getChildCount();
        if (childCount == 0) return 0;
        int columns = 1;//列数
        int rows;//行数
        if (layoutManager instanceof GridLayoutManager) {
            columns = ((GridLayoutManager) layoutManager).getSpanCount();
        } else if (layoutManager instanceof StaggeredGridLayoutManager) {
            columns = ((StaggeredGridLayoutManager) layoutManager).getSpanCount();
        }
        rows = childCount / columns + (childCount % columns == 0 ? 0 : 1);//计算行数
        int[] columnSizes = new int[columns];
        Arrays.fill(columnSizes, 0);
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < columns; j++) {
                int index = i * columns + j;
                View child = layoutManager.getChildAt(index);
                if (child != null && (includeLoadMore || child != mLoadMoreContainerView)) {
                    int position = layoutManager.getPosition(child);
                    if (position > -1 && position >= mStartPosition && position < mStartPosition + mItemCount) {
                        continue;//删除item时,因为pre-layout的原因,需要排除被删除的view
                    }
                    RecyclerView.LayoutParams lp = (RecyclerView.LayoutParams) child.getLayoutParams();
                    columnSizes[j] += checkOrientationVertical() ?
                            layoutManager.getDecoratedMeasuredHeight(child) + lp.bottomMargin + lp.topMargin :
                            layoutManager.getDecoratedMeasuredWidth(child) + lp.leftMargin + lp.rightMargin;
                }
            }
        }
        Arrays.sort(columnSizes);//找出高度或者宽度的最大值
        return columnSizes[0];
    }

    /**
     * 在加载更多视图被attachToWindow之前,判断当前显示的内容是否达到显示加载更多的条件
     */
    public boolean isCurrentItemSizeOver(boolean includeLoadMore) {
        int currentSize = checkOrientationVertical() ? mRecyclerView.getMeasuredHeight() : mRecyclerView.getMeasuredWidth();
        boolean canScroll = calculateChildrenSize(includeLoadMore) >= currentSize;
        return mLoadMoreDelegate != null && mRefreshStatus != HTBaseRecyclerView.RefreshStatus.REFRESHING && canScroll;
    }

    /**
     * 隐藏刷新空间带动画
     */
    protected void changeLoadMoreViewPositionWithAnimation(int targetPosition, @Nullable Animator.AnimatorListener animatorListener) {
        int startValue = 0;
        switch (mHTOrientation) {
            case HTOrientation.VERTICAL_DOWN:
                startValue = mLoadMoreContainerView.getPaddingBottom();
                break;
            case HTOrientation.VERTICAL_UP:
                startValue = mLoadMoreContainerView.getPaddingTop();
                break;
            case HTOrientation.HORIZONTAL_LEFT:
                startValue = mLoadMoreContainerView.getPaddingLeft();
                break;
            case HTOrientation.HORIZONTAL_RIGHT:
                startValue = mLoadMoreContainerView.getPaddingRight();
                break;
        }
        if (startValue <= -mLoadMoreViewSize) return;
        if (mLoadMoreAnimator != null && mLoadMoreAnimator.isRunning()) {
            mLoadMoreAnimator.end();
        }
        mLoadMoreAnimator = ValueAnimator.ofInt(startValue, targetPosition);
        mLoadMoreAnimator.setDuration(mHTViewHolder.getAnimationTime());
        mLoadMoreAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                int padding = (int) animation.getAnimatedValue();
                mLoadMoreContainerView.setPadding(
                        mHTOrientation == HTOrientation.HORIZONTAL_LEFT ? padding : 0,
                        mHTOrientation == HTOrientation.VERTICAL_UP ? padding : 0,
                        mHTOrientation == HTOrientation.HORIZONTAL_RIGHT ? padding : 0,
                        mHTOrientation == HTOrientation.VERTICAL_DOWN ? padding : 0);
            }
        });
        if (animatorListener != null) {
            mLoadMoreAnimator.addListener(animatorListener);
        }
        post(new Runnable() {
            public void run() {
                mLoadMoreAnimator.start();
            }
        });
    }

    abstract class ScrollJob implements Runnable {

        int mLastFlingXY;
        Scroller mScroller;
        boolean mScrollRunning = false;
        int mStartPos;
        int mTargetPos;

        public ScrollJob() {
            mScroller = new Scroller(getContext());
        }

        public void run() {
            boolean finish = !mScroller.computeScrollOffset() || mScroller.isFinished();
            handleScroll(finish);
        }

        abstract void handleScroll(boolean isFinish);

        void finish() {
            reset();
            onViewHolderScrollFinish();
        }

        void reset() {
            mScrollRunning = false;
            mLastFlingXY = 0;
            removeCallbacks(this);
        }

        void destroy() {
            reset();
            if (!mScroller.isFinished()) {
                mScroller.forceFinished(true);
            }
        }

        boolean isScrollRunning() {
            return mScrollRunning;
        }

        void abortIfWorking() {
            if (mScrollRunning) {
                if (!mScroller.isFinished()) {
                    mScroller.forceFinished(true);
                }
                onViewHolderScrollAbort();
                reset();
            }
        }

        abstract void tryToScrollTo(int to, int duration, long delayMillis);
    }

}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace CrudDatastore
{
    public interface IDataStoreRegistry
    {
        void Register<T>(IDataStore<T> dataStore) where T : EntityBase;
        bool IsRegistered<T>() where T : EntityBase;
    }

    public abstract class DataStoreContextBase : DataQueryContextBase, IDataStoreRegistry
    {
        private bool _disposed;
        private bool _propDataStoreAdded;

        private readonly IDictionary<Type, IDataStore> _dataStores = new Dictionary<Type, IDataStore>();

        public virtual void Add<T>(T entity) where T : EntityBase
        {
            GetDataStore<T>().Add(entity);
        }

        public virtual void Update<T>(T entity) where T : EntityBase
        {
            GetDataStore<T>().Update(entity);
        }

        public virtual void Delete<T>(T entity) where T : EntityBase
        {
            GetDataStore<T>().Delete(entity);
        }

        protected virtual void Register<T>(IDataStore<T> dataStore) where T : EntityBase
        {
            base.Register(dataStore);

            _dataStores.Add(typeof(T), dataStore);
        }

        protected virtual IDataStore<T> GetDataStore<T>() where T : EntityBase
        {
            if (!_propDataStoreAdded)
            {
                _propDataStoreAdded = true;
                foreach (var prop in this.GetType()
                    .GetProperties(BindingFlags.Public | BindingFlags.Instance)
                    .Where(p =>
                        (p.PropertyType.IsGenericType && p.PropertyType.GetGenericTypeDefinition().IsAssignableFrom(typeof(IDataStore<>))) ||
                        (p.PropertyType.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition().IsAssignableFrom(typeof(IDataStore<>)))))
                    .ToList())
                {
                    var t = prop.PropertyType.GetGenericArguments()[0];
                    if (_dataStores.ContainsKey(t))
                    {
                        var dataStore = prop.GetValue(this);
                        _dataStores.Add(t, (IDataStore)dataStore);
                    }
                }
            }

            var type = typeof(T);
            if (_dataStores.ContainsKey(type))
                return (IDataStore<T>)_dataStores[type];

            return null;
        }

        void IDataStoreRegistry.Register<T>(IDataStore<T> dataStore)
        {
            Register<T>(dataStore);
        }

        bool IDataStoreRegistry.IsRegistered<T>()
        {
            return _dataStores.ContainsKey(typeof(T));
        }

        protected override void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    // Free other state (managed objects)
                }

                _dataStores.Clear();

                //
                _disposed = true;
            }

            base.Dispose(disposing);
        }

        ~DataStoreContextBase()
        {
            Dispose(false);
        }
    }
}


text:
import { User } from './User'

export class Lobby {
  private users: any

  public constructor () {
    this.users = {}

    this.addUser = this.addUser.bind(this)
    this.removeUser = this.removeUser.bind(this)
  }

  public addUser (userId: any, userName: string, client: any): void {
    this.users[userId] = new User(userId, userName, client)
  }

  public removeUser (userId: number): void {
    let user = this.users[userId]
    if (user) {
      delete this.users[userId]
    }
  }
}


text:
require 'fileutils'

require 'vagrant/action/general/package'

module VagrantPlugins
  module Parallels
    module Action
      class Package < Vagrant::Action::General::Package
        # Doing this so that we can test that the parent is properly
        # called in the unit tests.
        alias_method :general_call, :call
        def call(env)
          # Setup the temporary directory
          @temp_dir = env[:tmp_path].join(Time.now.to_i.to_s)
          env['export.temp_dir'] = @temp_dir
          FileUtils.mkpath(env['export.temp_dir'])

          # Just match up a couple environmental variables so that
          # the superclass will do the right thing. Then, call the
          # superclass
          env['package.directory'] = env['export.temp_dir']

          general_call(env)

          # Always call recover to clean up the temp dir
          clean_temp_dir
        end

        def recover(env)
          clean_temp_dir
          super
        end

        protected

        def clean_temp_dir
          if @temp_dir && File.exist?(@temp_dir)
            FileUtils.rm_rf(@temp_dir)
          end
        end
      end
    end
  end
end


text:
(function(mod) {
  if (typeof exports == "object" && typeof module == "object") {
    mod(require("./codemirror"));
  }
  else if (typeof define == "function" && define.amd) // AMD
    define(["../../lib/codemirror"], mod);
  else // Plain browser env
    mod(CodeMirror);
})(function(CodeMirror) {
"use strict";

CodeMirror.defineMode("sass", function(config) {
  function tokenRegexp(words) {
    return new RegExp("^" + words.join("|"));
  }

  var keywords = ["true", "false", "null", "auto"];
  var keywordsRegexp = new RegExp("^" + keywords.join("|"));

  var operators = ["\\(", "\\)", "=", ">", "<", "==", ">=", "<=", "\\+", "-", "\\!=", "/", "\\*", "%", "and", "or", "not"];
  var opRegexp = tokenRegexp(operators);

  var pseudoElementsRegexp = /^::?[\w\-]+/;

  function urlTokens(stream, state) {
    var ch = stream.peek();

    if (ch === ")") {
      stream.next();
      state.tokenizer = tokenBase;
      return "operator";
    } else if (ch === "(") {
      stream.next();
      stream.eatSpace();

      return "operator";
    } else if (ch === "'" || ch === '"') {
      state.tokenizer = buildStringTokenizer(stream.next());
      return "string";
    } else {
      state.tokenizer = buildStringTokenizer(")", false);
      return "string";
    }
  }
  function comment(indentation, multiLine) {
    return function(stream, state) {
      if (stream.sol() && stream.indentation() <= indentation) {
        state.tokenizer = tokenBase;
        return tokenBase(stream, state);
      }

      if (multiLine && stream.skipTo("*/")) {
        stream.next();
        stream.next();
        state.tokenizer = tokenBase;
      } else {
        stream.next();
      }

      return "comment";
    };
  }

  function buildStringTokenizer(quote, greedy) {
    if(greedy == null) { greedy = true; }

    function stringTokenizer(stream, state) {
      var nextChar = stream.next();
      var peekChar = stream.peek();
      var previousChar = stream.string.charAt(stream.pos-2);

      var endingString = ((nextChar !== "\\" && peekChar === quote) || (nextChar === quote && previousChar !== "\\"));

      if (endingString) {
        if (nextChar !== quote && greedy) { stream.next(); }
        state.tokenizer = tokenBase;
        return "string";
      } else if (nextChar === "#" && peekChar === "{") {
        state.tokenizer = buildInterpolationTokenizer(stringTokenizer);
        stream.next();
        return "operator";
      } else {
        return "string";
      }
    }

    return stringTokenizer;
  }

  function buildInterpolationTokenizer(currentTokenizer) {
    return function(stream, state) {
      if (stream.peek() === "}") {
        stream.next();
        state.tokenizer = currentTokenizer;
        return "operator";
      } else {
        return tokenBase(stream, state);
      }
    };
  }

  function indent(state) {
    if (state.indentCount == 0) {
      state.indentCount++;
      var lastScopeOffset = state.scopes[0].offset;
      var currentOffset = lastScopeOffset + config.indentUnit;
      state.scopes.unshift({ offset:currentOffset });
    }
  }

  function dedent(state) {
    if (state.scopes.length == 1) return;

    state.scopes.shift();
  }

  function tokenBase(stream, state) {
    var ch = stream.peek();

    // Comment
    if (stream.match("/*")) {
      state.tokenizer = comment(stream.indentation(), true);
      return state.tokenizer(stream, state);
    }
    if (stream.match("//")) {
      state.tokenizer = comment(stream.indentation(), false);
      return state.tokenizer(stream, state);
    }

    // Interpolation
    if (stream.match("#{")) {
      state.tokenizer = buildInterpolationTokenizer(tokenBase);
      return "operator";
    }

    if (ch === ".") {
      stream.next();

      // Match class selectors
      if (stream.match(/^[\w-]+/)) {
        indent(state);
        return "atom";
      } else if (stream.peek() === "#") {
        indent(state);
        return "atom";
      } else {
        return "operator";
      }
    }

    if (ch === "#") {
      stream.next();

      // Hex numbers
      if (stream.match(/[0-9a-fA-F]{6}|[0-9a-fA-F]{3}/))
        return "number";

      // ID selectors
      if (stream.match(/^[\w-]+/)) {
        indent(state);
        return "atom";
      }

      if (stream.peek() === "#") {
        indent(state);
        return "atom";
      }
    }

    // Numbers
    if (stream.match(/^-?[0-9\.]+/))
      return "number";

    // Units
    if (stream.match(/^(px|em|in)\b/))
      return "unit";

    if (stream.match(keywordsRegexp))
      return "keyword";

    if (stream.match(/^url/) && stream.peek() === "(") {
      state.tokenizer = urlTokens;
      return "atom";
    }

    // Variables
    if (ch === "$") {
      stream.next();
      stream.eatWhile(/[\w-]/);

      if (stream.peek() === ":") {
        stream.next();
        return "variable-2";
      } else {
        return "variable-3";
      }
    }

    if (ch === "!") {
      stream.next();
      return stream.match(/^[\w]+/) ? "keyword": "operator";
    }

    if (ch === "=") {
      stream.next();

      // Match shortcut mixin definition
      if (stream.match(/^[\w-]+/)) {
        indent(state);
        return "meta";
      } else {
        return "operator";
      }
    }

    if (ch === "+") {
      stream.next();

      // Match shortcut mixin definition
      if (stream.match(/^[\w-]+/))
        return "variable-3";
      else
        return "operator";
    }

    // Indent Directives
    if (stream.match(/^@(else if|if|media|else|for|each|while|mixin|function)/)) {
      indent(state);
      return "meta";
    }

    // Other Directives
    if (ch === "@") {
      stream.next();
      stream.eatWhile(/[\w-]/);
      return "meta";
    }

    // Strings
    if (ch === '"' || ch === "'") {
      stream.next();
      state.tokenizer = buildStringTokenizer(ch);
      return "string";
    }

    // Pseudo element selectors
    if (ch == ":" && stream.match(pseudoElementsRegexp))
      return "keyword";

    // atoms
    if (stream.eatWhile(/[\w-&]/)) {
      // matches a property definition
      if (stream.peek() === ":" && !stream.match(pseudoElementsRegexp, false))
        return "property";
      else
        return "atom";
    }

    if (stream.match(opRegexp))
      return "operator";

    // If we haven't returned by now, we move 1 character
    // and return an error
    stream.next();
    return null;
  }

  function tokenLexer(stream, state) {
    if (stream.sol()) state.indentCount = 0;
    var style = state.tokenizer(stream, state);
    var current = stream.current();

    if (current === "@return")
      dedent(state);

    if (style === "atom")
      indent(state);

    if (style !== null) {
      var startOfToken = stream.pos - current.length;
      var withCurrentIndent = startOfToken + (config.indentUnit * state.indentCount);

      var newScopes = [];

      for (var i = 0; i < state.scopes.length; i++) {
        var scope = state.scopes[i];

        if (scope.offset <= withCurrentIndent)
          newScopes.push(scope);
      }

      state.scopes = newScopes;
    }

    return style;
  }

  return {
    startState: function() {
      return {
        tokenizer: tokenBase,
        scopes: [{offset: 0, type: "sass"}],
        indentCount: 0,
        definedVars: [],
        definedMixins: []
      };
    },
    token: function(stream, state) {
      var style = tokenLexer(stream, state);

      state.lastToken = { style: style, content: stream.current() };

      return style;
    },

    indent: function(state) {
      return state.scopes[0].offset;
    }
  };
});

CodeMirror.defineMIME("text/x-sass", "sass");

});


text:
layout: post
title: Android Jetpack Navigation
categories: Blog
description:  Android Jetpack Navigation
keywords:      Android Jetpack Navigation

---

# Android Jetpack Navigation

搬运一篇好文章备用,[参见](http://www.loongwind.com/archives/366.htmlœ)

在刚刚结束的谷歌IO大会上,谷歌推出了Android Jetpack架构组件,里面包含了Navigation组件,这篇文章我们就来看看这个Navigation的使用。

## 1、安装Android Studio 3.2

目前最新版本是3.2 CANARY 15,前往<https://androidstudio.googleblog.com/>下载最新版本。

## 2、添加项目依赖

- repositories添加google仓库 和classpath

  ```
  buildscript {
      repositories {
          google()
      }
      dependencies {
          classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha01"
      }
  }

  ```

- 添加navigation库的依赖

  ```
  dependencies {
      def nav_version = "1.0.0-alpha01"

      implementation "android.arch.navigation:navigation-fragment:$nav_version" // use -ktx for Kotlin
      implementation "android.arch.navigation:navigation-ui:$nav_version" // use -ktx for Kotlin

      // optional - Test helpers
      androidTestImplementation "android.arch.navigation:navigation-testing:$nav_version" // use -ktx for Kotlin
  }

  ```

## 3、创建Navigation

新建一个项目android项目

- 在res目录右键`New`->`New Resource File`,弹出`New Resource File`的对话框
- 填写`File name`比如:nav_graph
- `Resource type`选择`Navigation`
- 点击OK

然后会在res下生成一个navigation的目录,里面有我们刚才创建的nav_graph.xml文件,文件内容如下:

```
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android">

</navigation>

```

是一个navigation的空节点。
打开nav_graph.xml有一个Design和Text的选项卡,跟我们的布局文件很相似

## 4、使用Navigation

- 新建两个fragment:FragmentA、FragmentB对应布局为fragment_a.xml、fragment_b.xml

- 打开nav_graph.xml,底部选择Design选项卡,点击

  ![Alt text](http://www.loongwind.com/images/366_1.png)

  在弹出框中选择刚才建立的fragment_a和fragment_b。或者直接选择

  ![Alt text](http://www.loongwind.com/images/366_2.png)

  新建fragment,然后会出现如图的界面:

  ![Alt text](http://www.loongwind.com/images/366_3.png)

  切换到Text下内容如下:

  ```
  <?xml version="1.0" encoding="utf-8"?>
  <navigation xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      xmlns:tools="http://schemas.android.com/tools"
      app:startDestination="@id/fragmentA">

      <fragment
          android:id="@+id/fragmentA"
          android:name="com.halove.jetpackdmeo.FragmentA"
          android:label="fragment_a"
          tools:layout="@layout/fragment_a" >
      </fragment>
      <fragment
          android:id="@+id/fragmentB"
          android:name="com.halove.jetpackdmeo.FragmentB"
          android:label="fragment_b"
          tools:layout="@layout/fragment_b" />
  </navigation>

  ```

在navigation节点里添加了两个fragment,name分别对应我们创建的FragmentA和FragmentB,并添加对应的id

- 在Activity布局里添加NavHostFragment:

  ```
  <?xml version="1.0" encoding="utf-8"?>
  <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".MainActivity">

      <fragment
          android:id="@+id/my_nav_host_fragment"
          android:name="androidx.navigation.fragment.NavHostFragment"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          app:defaultNavHost="true"
          app:navGraph="@navigation/nav_graph" />

  </android.support.constraint.ConstraintLayout>

  ```

`app:defaultNavHost="true"`是拦截返回键,即将返回交给NavHostFragment处理。`app:navGraph="@navigation/nav_graph"`将NavHostFragment跟我们刚才创建的navigation关联。
然后重新打开nav_graph.xml会发现在HOST下面就会显示我们关联的activity:[![Alt text](http://www.loongwind.com/images/366_4.png)](http://www.loongwind.com/images/366_4.png)

- 添加导航连接

  ![Alt text](http://www.loongwind.com/images/366_5.png)

  左键按住fragment右侧中间的圆圈然后拖动到要导航的fragment然后松手

  切换到Text下,发现在fragment标签里添加了一个action节点:

  ```
  <?xml version="1.0" encoding="utf-8"?>
  <navigation xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      xmlns:tools="http://schemas.android.com/tools"
      app:startDestination="@id/fragmentA">

      <fragment
          android:id="@+id/fragmentA"
          android:name="com.halove.jetpackdmeo.FragmentA"
          android:label="fragment_a"
          tools:layout="@layout/fragment_a" >
          <action
              android:id="@+id/action_fragmentA_to_fragmentB"
              app:destination="@id/fragmentB" />
      </fragment>
      <fragment
          android:id="@+id/fragmentB"
          android:name="com.halove.jetpackdmeo.FragmentB"
          android:label="fragment_b"
          tools:layout="@layout/fragment_b" />
  </navigation>

  ```

action添加了一个id和destination,destination就是我们要导航到的fragment。

activity中不需要做任何操作,只需要设置布局即可:

```
class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.main_activity)
    }
}

```

在FragmentA中布局中添加一个button,点击跳转到FragmentB:

```
override fun onActivityCreated(savedInstanceState: Bundle?) {
    super.onActivityCreated(savedInstanceState)

    toBPageBtn.setOnClickListener {
        Navigation.findNavController(it).navigate(R.id.action_fragmentA_to_fragmentB)
    }
	//或者
	toBPageBtn.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.action_fragmentA_to_fragmentB))
}

```

使用很简单,调用Navigation的findNavController方法找到NavController,findNavController还有其他参数的方法大家可以自己试试,然后调用navigate方法,参数就是nav_graph.xml里action的id。或者直接使用`createNavigateOnClickListener`
效果如图:
[![img](http://www.loongwind.com/images/366_6.gif)](http://www.loongwind.com/images/366_6.gif)
按返回键会回退到上一个fragment,也可以调用NavController的popBackStack进行回退

接下来看看怎么传递参数。
navigate有好几个方法,如下:
[![Alt text](http://www.loongwind.com/images/366_7.png)](http://www.loongwind.com/images/366_7.png)
有个带bundle参数的,可以用这个传递参数:

```
val bundle = Bundle()
bundle.putString("text","aaaaaa")
Navigation.findNavController(it).navigate(R.id.action_fragmentA_to_fragmentB, bundle)

```

也可以在navigation的xml的fragment的action里添加argument标签,然后使用生成的对应的Agrs或者Directions来传递参数,需要在build.gradle中添加`apply plugin: 'androidx.navigation.safeargs'`

```
<fragment
    android:id="@+id/fragmentB"
    android:name="com.halove.jetpackdmeo.FragmentB"
    android:label="fragment_b"
    tools:layout="@layout/fragment_b" >
    <argument android:name="text" android:defaultValue="Hello" app:type="string"/>
</fragment>

```

使用:

```
//使用FragmentBArgs
val bundle = FragmentBArgs.Builder().setText("Hello World").build().toBundle()
Navigation.findNavController(it).navigate(R.id.action_fragmentA_to_fragmentB, bundle)

//使用FragmentADirections
val direction = FragmentADirections.action_fragmentA_to_fragmentB().setText("Hello World")
Navigation.findNavController(it).navigate(direction)

//接收参数
val text = FragmentBArgs.fromBundle(arguments).text

```

FragmentBArgs和FragmentADirections都是自动生成的,FragmentBArgs是根据fragment节点下的argument节点生成的,FragmentADirections是根据action生成的

- 转场动画

  可以在action上添加转场动画,如下:

  ```
  <?xml version="1.0" encoding="utf-8"?>
  <navigation xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      app:startDestination="@id/fragmentA">

      <fragment
          android:id="@+id/fragmentA"
          android:name="com.halove.jetpackdmeo.FragmentA"
          android:label="fragment_a"
          tools:layout="@layout/fragment_a" >
          <action
              android:id="@+id/action_fragmentA_to_fragmentB"
              app:destination="@id/fragmentB"
              app:enterAnim="@anim/slide_in_right"
              app:exitAnim="@anim/slide_out_left"
              app:popEnterAnim="@anim/slide_in_left"
              app:popExitAnim="@anim/slide_out_right"/>
      </fragment>
      <fragment
          android:id="@+id/fragmentB"
          android:name="com.halove.jetpackdmeo.FragmentB"
          android:label="fragment_b"
          tools:layout="@layout/fragment_b" >
          <argument android:name="text" android:defaultValue="Hello" app:type="string"/>
      </fragment>
  </navigation>

  ```

动画的代码写法跟原来activity的动画是一样的,这里就不多说了。

- 深层链接 deep-link

  使用 deep-link可以创建深层链接,类似activity的自定义URL使用Scheme方式来跳转,可以直接跳转到指定Fragment

  ```
  <?xml version="1.0" encoding="utf-8"?>
  <navigation xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      app:startDestination="@id/fragmentA">

      <fragment
          android:id="@+id/fragmentA"
          android:name="com.halove.jetpackdmeo.FragmentA"
          android:label="fragment_a"
          tools:layout="@layout/fragment_a" >
          <action
              android:id="@+id/action_fragmentA_to_fragmentB"
              app:destination="@id/fragmentB"
              app:enterAnim="@anim/slide_in_right"
              app:exitAnim="@anim/slide_out_left"
              app:popEnterAnim="@anim/slide_in_left"
              app:popExitAnim="@anim/slide_out_right"/>
      </fragment>
      <fragment
          android:id="@+id/fragmentB"
          android:name="com.halove.jetpackdmeo.FragmentB"
          android:label="fragment_b"
          tools:layout="@layout/fragment_b" >
          <argument android:name="text" android:defaultValue="Hello" app:type="string"/>
          <deepLink app:uri="www.loongwind.com/test"/>
      </fragment>
  </navigation>

  ```

上面我们给FragmentB添加了一个deepLink,然后在manifest给activity添加nav-graph:

```
<activity android:name=".MainActivity">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <nav-graph android:value="@navigation/nav_graph" />
</activity>

```

Android Studio 3.2及以上可以直接添加nav-graph节点,value就是我们的navigation,3.2以下的得自己写intent-filter,如下:

```
<intent-filter>
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
    <data android:scheme="https"/>
    <data android:scheme="http"/>
    <data android:host="www.loongwind.com"/>
    <data android:pathPrefix="/test"/>
</intent-filter>

```

代码里跳转:

```
val data = Uri.parse("http://www.loongwind.com/test")
val intent = Intent(Intent.ACTION_VIEW, data)
startActivity(intent)

```

这样跳转到我们的Activity就会直接显示FragmentB界面。

好了到此我们的Navigation初探就到此结束了,更多请参考Google官方文档:[Implement navigation](https://developer.android.com/topic/libraries/architecture/navigation/navigation-implementing)


text:
angular.module('NodeWebBase')
		.config(function ($routeProvider) {
			$routeProvider
			.otherwise({templateUrl: '/views/app/aminoMain'})
		})
		.controller('indexController', function ($scope) {

		});