Example usage for java.lang Float NaN

List of usage examples for java.lang Float NaN

Introduction

In this page you can find the example usage for java.lang Float NaN.

Prototype

float NaN

To view the source code for java.lang Float NaN.

Click Source Link

Document

A constant holding a Not-a-Number (NaN) value of type float .

Usage

From source file:uk.ac.diamond.scisoft.analysis.dataset.FloatDataset.java

private void allocateArray(final int... nshape) {
    if (data == null) {
        throw new IllegalStateException("Data buffer in dataset is null");
    }//www.j  av  a2 s  .c o m

    if (dataShape != null) {
        // see if reserved space is sufficient
        if (isShapeInDataShape(nshape)) {
            shape = nshape;
            size = calcSize(shape);
            if (Arrays.equals(shape, dataShape)) {
                dataShape = null; // no reserved space
            }
            return;
        }
    }

    final IndexIterator iter = getIterator();

    // not enough room so need to expand the allocated memory
    if (dataShape == null)
        dataShape = shape.clone();
    expandDataShape(nshape);
    dataSize = calcSize(dataShape);

    final float[] ndata = createArray(dataSize); // PRIM_TYPE
    final int[] oshape = shape;

    // now this object has the new dimensions so specify them correctly
    shape = nshape;
    size = calcSize(nshape);

    // make sure that all the data is set to NaN, minimum value or false
    Arrays.fill(ndata, Float.NaN); // CLASS_TYPE // DEFAULT_VAL

    // now copy the data back to the correct positions
    final IndexIterator niter = getSliceIterator(null, oshape, null);

    while (niter.hasNext() && iter.hasNext())
        ndata[niter.index] = data[iter.index];

    odata = data = ndata;

    // if fully expanded then reset the reserved space dimensions
    if (dataSize == size) {
        dataShape = null;
    }
}

From source file:com.example.android.supportv7.widget.vlayout.VLayoutActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity);

    mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container);
    mFirstText = (TextView) findViewById(R.id.first);
    mLastText = (TextView) findViewById(R.id.last);
    mCountText = (TextView) findViewById(R.id.count);
    mTotalOffsetText = (TextView) findViewById(R.id.total_offset);

    final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.main_view);

    findViewById(R.id.jump).setOnClickListener(new View.OnClickListener() {
        @Override//  w w  w.j  a  v a 2 s  . c  om
        public void onClick(View v) {
            EditText position = (EditText) findViewById(R.id.position);
            if (!TextUtils.isEmpty(position.getText())) {
                try {
                    int pos = Integer.parseInt(position.getText().toString());
                    recyclerView.scrollToPosition(pos);
                } catch (Exception e) {
                    Log.e("VlayoutActivity", e.getMessage(), e);
                }
            } else {
                recyclerView.requestLayout();
            }
        }
    });

    final VirtualLayoutManager layoutManager = new VirtualLayoutManager(this);

    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int scrollState) {

        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int i, int i2) {
            mFirstText.setText("First: " + layoutManager.findFirstVisibleItemPosition());
            mLastText.setText(
                    "Existing: " + MainViewHolder.existing + " Created: " + MainViewHolder.createdTimes);
            mCountText.setText("Count: " + recyclerView.getChildCount());
            mTotalOffsetText.setText("Total Offset: " + layoutManager.getOffsetToStart());
        }
    });

    //layoutManager.setRecycleOffset(300);

    recyclerView.setLayoutManager(layoutManager);

    // layoutManager.setReverseLayout(true);

    RecyclerView.ItemDecoration itemDecoration = new RecyclerView.ItemDecoration() {
        public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
            int position = ((LayoutParams) view.getLayoutParams()).getViewPosition();
            outRect.set(4, 4, 4, 4);
        }
    };

    final RecyclerView.RecycledViewPool viewPool = new RecyclerView.RecycledViewPool();

    recyclerView.setRecycledViewPool(viewPool);

    // recyclerView.addItemDecoration(itemDecoration);

    viewPool.setMaxRecycledViews(0, 20);

    final DelegateAdapter delegateAdapter = new DelegateAdapter(layoutManager, true);

    recyclerView.setAdapter(delegateAdapter);

    final List<DelegateAdapter.Adapter> adapters = new LinkedList<>();

    if (BANNER_LAYOUT) {
        adapters.add(new SubAdapter(this, new LinearLayoutHelper(), 1) {

            @Override
            public void onViewRecycled(MainViewHolder holder) {
                if (holder.itemView instanceof ViewPager) {
                    ((ViewPager) holder.itemView).setAdapter(null);
                }
            }

            @Override
            public MainViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                if (viewType == 1)
                    return new MainViewHolder(LayoutInflater.from(VLayoutActivity.this)
                            .inflate(R.layout.view_pager, parent, false));

                return super.onCreateViewHolder(parent, viewType);
            }

            @Override
            public int getItemViewType(int position) {
                return 1;
            }

            @Override
            protected void onBindViewHolderWithOffset(MainViewHolder holder, int position, int offsetTotal) {

            }

            @Override
            public void onBindViewHolder(MainViewHolder holder, int position) {
                if (holder.itemView instanceof ViewPager) {
                    ViewPager viewPager = (ViewPager) holder.itemView;

                    viewPager.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 200));

                    // from position to get adapter
                    viewPager.setAdapter(new PagerAdapter(this, viewPool));
                }
            }
        });
    }

    //{
    //    GridLayoutHelper helper = new GridLayoutHelper(10);
    //    helper.setAspectRatio(4f);
    //    helper.setGap(10);
    //    adapters.add(new SubAdapter(this, helper, 80));
    //}

    if (FLOAT_LAYOUT) {
        FloatLayoutHelper layoutHelper = new FloatLayoutHelper();
        layoutHelper.setAlignType(FixLayoutHelper.BOTTOM_RIGHT);
        layoutHelper.setDefaultLocation(100, 400);
        LayoutParams layoutParams = new LayoutParams(150, 150);
        adapters.add(new SubAdapter(this, layoutHelper, 1, layoutParams));
    }

    if (LINEAR_LAYOUT) {
        LinearLayoutHelper layoutHelper1 = new LinearLayoutHelper();
        layoutHelper1.setAspectRatio(2.0f);
        LinearLayoutHelper layoutHelper2 = new LinearLayoutHelper();
        layoutHelper2.setAspectRatio(4.0f);
        layoutHelper2.setDividerHeight(10);
        layoutHelper2.setMargin(10, 30, 10, 10);
        layoutHelper2.setPadding(10, 30, 10, 10);
        layoutHelper2.setBgColor(0xFFF5A623);
        adapters.add(new SubAdapter(this, layoutHelper1, 1));
        adapters.add(new SubAdapter(this, layoutHelper2, 6) {

            @Override
            public void onBindViewHolder(MainViewHolder holder, int position) {
                if (position % 2 == 0) {
                    LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300);
                    layoutParams.mAspectRatio = 5;
                    holder.itemView.setLayoutParams(layoutParams);
                }
            }
        });
    }

    {
        SingleLayoutHelper layoutHelper = new SingleLayoutHelper();
        layoutHelper.setBgColor(Color.BLUE);
        layoutHelper.setMargin(0, 30, 0, 200);
        adapters.add(new SubAdapter(this, layoutHelper, 1,
                new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 100)));
    }

    if (STICKY_LAYOUT) {
        StickyLayoutHelper layoutHelper = new StickyLayoutHelper();
        //layoutHelper.setOffset(100);
        layoutHelper.setAspectRatio(4);
        adapters.add(new SubAdapter(this, layoutHelper, 1,
                new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 100)));
    }

    {
        //final StaggeredGridLayoutHelper helper = new StaggeredGridLayoutHelper(3, 10);
        //helper.setBgColor(0xFF86345A);
        //adapters.add(new SubAdapter(this, helper, 4) {
        //    @Override
        //    public void onBindViewHolder(MainViewHolder holder, int position) {
        //        super.onBindViewHolder(holder, position);
        //        LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300);
        //        if (position % 2 == 0) {
        //            layoutParams.mAspectRatio = 1.0f;
        //        } else {
        //            layoutParams.height = 340 + position % 7 * 20;
        //        }
        //        holder.itemView.setLayoutParams(layoutParams);
        //    }
        //});

        final GridLayoutHelper helper = new GridLayoutHelper(3, 4);
        helper.setBgColor(0xFF86345A);
        adapters.add(new SubAdapter(this, helper, 4) {
            @Override
            public void onBindViewHolder(MainViewHolder holder, int position) {
                super.onBindViewHolder(holder, position);
                LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300);
                holder.itemView.setLayoutParams(layoutParams);
            }
        });
    }

    {
        RangeGridLayoutHelper layoutHelper = new RangeGridLayoutHelper(4);
        layoutHelper.setBgColor(Color.GREEN);
        layoutHelper.setWeights(new float[] { 20f, 26.665f });
        layoutHelper.setPadding(15, 15, 15, 15);
        layoutHelper.setMargin(15, 15, 15, 15);
        layoutHelper.setHGap(10);
        layoutHelper.setVGap(10);
        GridRangeStyle rangeStyle = new GridRangeStyle();
        rangeStyle.setBgColor(Color.RED);
        rangeStyle.setSpanCount(2);
        rangeStyle.setWeights(new float[] { 46.665f });
        rangeStyle.setPadding(15, 15, 15, 15);
        rangeStyle.setMargin(15, 15, 15, 15);
        rangeStyle.setHGap(5);
        rangeStyle.setVGap(5);
        layoutHelper.addRangeStyle(4, 7, rangeStyle);
        GridRangeStyle rangeStyle1 = new GridRangeStyle();
        rangeStyle1.setBgColor(Color.YELLOW);
        rangeStyle1.setSpanCount(2);
        rangeStyle1.setWeights(new float[] { 46.665f });
        rangeStyle1.setPadding(15, 15, 15, 15);
        rangeStyle1.setMargin(15, 15, 15, 15);
        rangeStyle1.setHGap(5);
        rangeStyle1.setVGap(5);
        layoutHelper.addRangeStyle(8, 11, rangeStyle1);
        adapters.add(new SubAdapter(this, layoutHelper, 16));

    }

    if (SINGLE_LAYOUT) {
        SingleLayoutHelper layoutHelper = new SingleLayoutHelper();
        layoutHelper.setBgColor(Color.rgb(135, 225, 90));
        layoutHelper.setAspectRatio(4);
        layoutHelper.setMargin(10, 20, 10, 20);
        layoutHelper.setPadding(10, 10, 10, 10);
        adapters.add(new SubAdapter(this, layoutHelper, 1,
                new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 100)));
    }

    if (COLUMN_LAYOUT) {
        ColumnLayoutHelper layoutHelper = new ColumnLayoutHelper();
        layoutHelper.setBgColor(0xff00f0f0);
        layoutHelper.setWeights(new float[] { 40.0f, Float.NaN, 40 });
        adapters.add(new SubAdapter(this, layoutHelper, 5) {

            @Override
            public void onBindViewHolder(MainViewHolder holder, int position) {
                if (position == 0) {
                    LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300);
                    layoutParams.mAspectRatio = 4;
                    holder.itemView.setLayoutParams(layoutParams);
                } else {
                    LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300);
                    layoutParams.mAspectRatio = Float.NaN;
                    holder.itemView.setLayoutParams(layoutParams);
                }
            }

        });
    }

    if (ONEN_LAYOUT) {
        OnePlusNLayoutHelper helper = new OnePlusNLayoutHelper();
        helper.setBgColor(0xff876384);
        helper.setAspectRatio(4.0f);
        helper.setColWeights(new float[] { 40f, 45f });
        helper.setMargin(10, 20, 10, 20);
        helper.setPadding(10, 10, 10, 10);
        adapters.add(new SubAdapter(this, helper, 2));
    }

    if (ONEN_LAYOUT) {
        OnePlusNLayoutHelper helper = new OnePlusNLayoutHelper();
        helper.setBgColor(0xffef8ba3);
        helper.setAspectRatio(2.0f);
        helper.setColWeights(new float[] { 40f });
        helper.setRowWeight(30f);
        helper.setMargin(10, 20, 10, 20);
        helper.setPadding(10, 10, 10, 10);
        adapters.add(new SubAdapter(this, helper, 4) {
            @Override
            public void onBindViewHolder(MainViewHolder holder, int position) {
                super.onBindViewHolder(holder, position);
                LayoutParams lp = (LayoutParams) holder.itemView.getLayoutParams();
                if (position == 0) {
                    lp.rightMargin = 1;
                } else if (position == 1) {

                } else if (position == 2) {
                    lp.topMargin = 1;
                    lp.rightMargin = 1;
                }
            }
        });
    }

    if (ONEN_LAYOUT) {
        adapters.add(new SubAdapter(this, new OnePlusNLayoutHelper(), 0));
        OnePlusNLayoutHelper helper = new OnePlusNLayoutHelper();
        helper.setBgColor(0xff87e543);
        helper.setAspectRatio(1.8f);
        helper.setColWeights(new float[] { 33.33f, 50f, 40f });
        helper.setMargin(10, 20, 10, 20);
        helper.setPadding(10, 10, 10, 10);
        LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT);
        adapters.add(new SubAdapter(this, helper, 3, lp) {
            @Override
            public void onBindViewHolder(MainViewHolder holder, int position) {
                super.onBindViewHolder(holder, position);
                LayoutParams lp = (LayoutParams) holder.itemView.getLayoutParams();
                if (position == 0) {
                    lp.rightMargin = 1;
                }
            }
        });
    }

    if (COLUMN_LAYOUT) {
        adapters.add(new SubAdapter(this, new ColumnLayoutHelper(), 0));
        adapters.add(new SubAdapter(this, new ColumnLayoutHelper(), 4));
    }

    if (FIX_LAYOUT) {
        FixLayoutHelper layoutHelper = new FixLayoutHelper(10, 10);
        adapters.add(new SubAdapter(this, layoutHelper, 0));

        layoutHelper = new FixLayoutHelper(FixLayoutHelper.TOP_RIGHT, 20, 20);

        adapters.add(new SubAdapter(this, layoutHelper, 1) {
            @Override
            public void onBindViewHolder(MainViewHolder holder, int position) {
                super.onBindViewHolder(holder, position);
                LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 200);
                holder.itemView.setLayoutParams(layoutParams);
            }
        });
    }

    //if (STICKY_LAYOUT) {
    //    StickyLayoutHelper layoutHelper = new StickyLayoutHelper(false);
    //    adapters.add(new SubAdapter(this, layoutHelper, 0));
    //    layoutHelper = new StickyLayoutHelper(false);
    //    layoutHelper.setOffset(100);
    //    adapters.add(new SubAdapter(this, layoutHelper, 1, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 100)));
    //}

    if (GRID_LAYOUT) {
        GridLayoutHelper layoutHelper = new GridLayoutHelper(2);
        layoutHelper.setMargin(7, 0, 7, 0);
        layoutHelper.setWeights(new float[] { 46.665f });
        layoutHelper.setHGap(3);
        adapters.add(new SubAdapter(this, layoutHelper, 2));

        layoutHelper = new GridLayoutHelper(4);
        layoutHelper.setWeights(new float[] { 20f, 26.665f });
        layoutHelper.setMargin(7, 0, 7, 0);
        layoutHelper.setHGap(3);
        adapters.add(new SubAdapter(this, layoutHelper, 8));
    }

    if (GRID_LAYOUT) {
        adapters.add(new SubAdapter(this, new GridLayoutHelper(4), 0));

        GridLayoutHelper helper = new GridLayoutHelper(4);
        helper.setAspectRatio(4f);
        //helper.setColWeights(new float[]{40, 20, 30, 30});
        // helper.setMargin(0, 10, 0, 10);
        helper.setGap(10);
        adapters.add(new SubAdapter(this, helper, 80) {
            @Override
            public void onBindViewHolder(MainViewHolder holder, int position) {
                super.onBindViewHolder(holder, position);
                LayoutParams lp = (LayoutParams) holder.itemView.getLayoutParams();
                // lp.bottomMargin = 1;
                // lp.rightMargin = 1;
            }
        });
    }

    if (FIX_LAYOUT) {
        adapters.add(new SubAdapter(this, new ScrollFixLayoutHelper(20, 20), 1) {
            @Override
            public void onBindViewHolder(MainViewHolder holder, int position) {
                super.onBindViewHolder(holder, position);
                LayoutParams layoutParams = new LayoutParams(200, 200);
                holder.itemView.setLayoutParams(layoutParams);
            }
        });
    }

    if (LINEAR_LAYOUT)
        adapters.add(new SubAdapter(this, new LinearLayoutHelper(), 10));

    if (GRID_LAYOUT) {
        GridLayoutHelper helper = new GridLayoutHelper(3);
        helper.setMargin(0, 10, 0, 10);
        adapters.add(new SubAdapter(this, helper, 3));
    }

    if (STAGGER_LAYOUT) {
        // adapters.add(new SubAdapter(this, new StaggeredGridLayoutHelper(2, 0), 0));
        final StaggeredGridLayoutHelper helper = new StaggeredGridLayoutHelper(2, 10);
        helper.setMargin(20, 10, 10, 10);
        helper.setPadding(10, 10, 20, 10);
        helper.setBgColor(0xFF86345A);
        adapters.add(new SubAdapter(this, helper, 27) {
            @Override
            public void onBindViewHolder(MainViewHolder holder, int position) {
                super.onBindViewHolder(holder, position);
                LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 200);
                if (position % 2 == 0) {
                    layoutParams.mAspectRatio = 1.0f;
                } else {
                    layoutParams.height = 340 + position % 7 * 20;
                }
                holder.itemView.setLayoutParams(layoutParams);
            }
        });
    }

    if (COLUMN_LAYOUT) {
        // adapters.add(new SubAdapter(this, new ColumnLayoutHelper(), 3));
    }

    if (GRID_LAYOUT) {
        // adapters.add(new SubAdapter(this, new GridLayoutHelper(4), 24));
    }

    delegateAdapter.setAdapters(adapters);

    final Handler mainHandler = new Handler(Looper.getMainLooper());

    trigger = new Runnable() {
        @Override
        public void run() {
            //recyclerView.scrollToPosition(22);
            //recyclerView.getAdapter().notifyDataSetChanged();
            //mainHandler.postDelayed(trigger, 1000);
            //List<DelegateAdapter.Adapter> newAdapters = new ArrayList<>();
            //newAdapters.add((new SubAdapter(VLayoutActivity.this, new ColumnLayoutHelper(), 3)));
            //newAdapters.add((new SubAdapter(VLayoutActivity.this, new GridLayoutHelper(4), 24)));
            //delegateAdapter.addAdapter(0, new SubAdapter(VLayoutActivity.this, new ColumnLayoutHelper(), 3));
            //delegateAdapter.addAdapter(1, new SubAdapter(VLayoutActivity.this, new GridLayoutHelper(4), 24));
            //delegateAdapter.notifyDataSetChanged();
        }
    };

    mainHandler.postDelayed(trigger, 1000);

    mSwipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
        @Override
        public void onRefresh() {
            mainHandler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mSwipeRefreshLayout.setRefreshing(false);
                }
            }, 2000L);
        }
    });
    setListenerToRootView();
}

From source file:org.bitpipeline.lib.owm.SampledWeatherData.java

public float getWindSpeed() {
    if (hasWind() && this.wind.hasSpeed())
        return this.wind.getSpeed();
    return Float.NaN;
}

From source file:org.bitpipeline.lib.owm.SampledWeatherData.java

public float getWindGust() {
    if (hasWind() && this.wind.hasGust())
        return this.wind.getGust();
    return Float.NaN;
}

From source file:com.opera.core.systems.scope.stp.services.ScopeEcmascriptService.java

/**
 * Parses a reply and returns the result of the script execution.  The result from EcmaScript is
 * converted based on the object types specified by Scope:
 *
 * <dl> <dt>undefined</dt> <dd> The undefined type, returned when no value was found or
 * "undefined" was references.  Will return null. </dd>
 *
 * <dt>true</dt> <dd>Boolean true value.</dd>
 *
 * <dt>false</dt> <dd>Boolean false value.</dd>
 *
 * <dt>NaN</dt> <dd> NaN value (not a number) which cannot be exported to JSON directly.  Will be
 * treated as a number, and returns a {@link Float#NaN} reference. </dd>
 *
 * <dt>Infinity</dt> <dd> Plus infinity value which cannot be exported to JSON directly.  Will be
 * treated as a number, and returns a {@link Float#POSITIVE_INFINITY} reference. </dd>
 *
 * <dt>-Infinity</dt> <dd> Negative infinity value which cannot be exported to JSON directly. Will
 * be treated as a number, and returns a {@link Float#NEGATIVE_INFINITY} reference. </dd>
 *
 * <dt>number</dt> <dd>A number, will return a long or double value depending on its value.</dd>
 *
 * <dt>string</dt> <dd>A string.</dd>
 *
 * <dt>object</dt> <dd> A non-primitive value in EcmaScript, typically a generic object.  This
 * includes functions and arrays. </dd> </dl>
 *
 * @param result the result of a script execution
 * @return the parsed result of a reply//from   w  w w. jav  a2  s.c o m
 */
private Object parseEvalReply(EvalResult result) {
    Status status = result.getStatus();

    switch (status) {
    case CANCELLED:
        return null;
    case EXCEPTION:
        throw new ScopeException("EcmaScript exception");
    case NO_MEMORY:
        //releaseObjects();
        throw new ScopeException("Out of memory");
    case FAILURE:
        throw new ScopeException("Could not execute script");
    }

    Value value = result.getValue();
    Type type = value.getType();

    switch (type) {
    case STRING:
        return value.getStr();
    case FALSE:
        return false;
    case TRUE:
        return true;
    case OBJECT:
        return value.getObject();
    case NUMBER:
        return parseNumber(String.valueOf(value.getNumber()));
    case NAN:
        return Float.NaN;
    case MINUS_INFINITY:
        return Float.NEGATIVE_INFINITY;
    case PLUS_INFINITY:
        return Float.POSITIVE_INFINITY;
    case UNDEFINED:
    case NULL:
    default:
        return null;
    }
}

From source file:org.getlantern.firetweet.activity.support.HomeActivity.java

/**
 * Called when the context is first created.
 *///from  ww  w . ja  va 2 s . c om
@Override
protected void onCreate(final Bundle savedInstanceState) {
    final Window window = getWindow();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }
    super.onCreate(savedInstanceState);
    if (!isDatabaseReady(this)) {
        Toast.makeText(this, R.string.preparing_database_toast, Toast.LENGTH_SHORT).show();
        finish();
        return;
    }

    ha = this;

    mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    mTwitterWrapper = getTwitterWrapper();
    mReadStateManager = FiretweetApplication.getInstance(this).getReadStateManager();
    mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    mMultiSelectHandler = new MultiSelectEventHandler(this);
    mHotKeyHandler = new HotKeyHandler(this);
    mMultiSelectHandler.dispatchOnCreate();
    final long[] accountIds = getAccountIds(this);
    if (accountIds.length == 0) {
        final Intent signInIntent = new Intent(INTENT_ACTION_TWITTER_LOGIN);
        signInIntent.setClass(this, SignInActivity.class);
        startActivity(signInIntent);
        finish();

        final Context context = this;
        Lantern.start(context);

        return;
    } else {
        notifyAccountsChanged();
    }
    final Intent intent = getIntent();
    if (openSettingsWizard()) {
        finish();
        return;
    }
    setContentView(R.layout.activity_home);
    setSupportActionBar(mActionBar);
    sendBroadcast(new Intent(BROADCAST_HOME_ACTIVITY_ONCREATE));
    final boolean refreshOnStart = mPreferences.getBoolean(KEY_REFRESH_ON_START, false);
    mTabDisplayOption = getTabDisplayOptionInt(this);

    final Context context = this;

    Lantern.start(context);

    mColorStatusFrameLayout.setOnFitSystemWindowsListener(this);
    ThemeUtils.applyBackground(mTabIndicator);
    mPagerAdapter = new SupportTabsAdapter(this, getSupportFragmentManager(), mTabIndicator, 1);
    mViewPager.setAdapter(mPagerAdapter);
    mViewPager.setOffscreenPageLimit(3);
    mTabIndicator.setViewPager(mViewPager);
    mTabIndicator.setOnPageChangeListener(this);
    if (mTabDisplayOption != 0) {
        mTabIndicator.setTabDisplayOption(mTabDisplayOption);
    } else {
        mTabIndicator.setTabDisplayOption(TabPagerIndicator.ICON);
    }
    mTabIndicator.setDisplayBadge(mPreferences.getBoolean(KEY_UNREAD_COUNT, true));
    mActionsButton.setOnClickListener(this);
    mActionsButton.setOnLongClickListener(this);
    mEmptyTabHint.setOnClickListener(this);

    setupSlidingMenu();
    setupBars();
    initUnreadCount();
    updateActionsButton();
    updateSmartBar();
    updateSlidingMenuTouchMode();

    if (savedInstanceState == null) {
        //if (refreshOnStart) {
        mTwitterWrapper.refreshAll();
        //}
        if (intent.getBooleanExtra(EXTRA_OPEN_ACCOUNTS_DRAWER, false)) {
            openAccountsDrawer();
        }
    }
    mPagerPosition = Float.NaN;
    setupHomeTabs();

    final int initialTabPosition = handleIntent(intent, savedInstanceState == null);
    setTabPosition(initialTabPosition);
}

From source file:com.yahoo.egads.models.tsmm.TestOlympicModel2.java

@Test
public void initializeIndices() throws Exception {
    final OlympicModel2 model = new OlympicModel2(config);
    TimeSeries ts = new TimeSeries();
    ts.append(1475452800, 10);/*ww w  .  ja va 2  s  . c  o  m*/
    ts.append(1475453100, 25);

    ts.append(1476057600, 20);
    ts.append(1476057900, 45);

    ts.append(1476662400, 30);
    ts.append(1476662700, 55);

    ts.append(1477267200, 40);
    ts.append(1477267500, 65);

    model.initializeIndices(ts.data, start);

    assertEquals(4, model.indices.length);
    assertEquals(0, model.indices[0]);
    assertEquals(2, model.indices[1]);
    assertEquals(4, model.indices[2]);
    assertEquals(6, model.indices[3]);

    assertEquals(4, model.windowTimes.length);
    assertEquals(1475452800, model.windowTimes[0].toEpochSecond());
    assertEquals(1476057600, model.windowTimes[1].toEpochSecond());
    assertEquals(1476662400, model.windowTimes[2].toEpochSecond());
    assertEquals(1477267200, model.windowTimes[3].toEpochSecond());

    // missing first point
    ts = new TimeSeries();
    //ts.append(1475452800, 10);
    ts.append(1475453100, 25);

    ts.append(1476057600, 20);
    ts.append(1476057900, 45);

    ts.append(1476662400, 30);
    ts.append(1476662700, 55);

    ts.append(1477267200, 40);
    ts.append(1477267500, 65);

    model.initializeIndices(ts.data, start);

    assertEquals(4, model.indices.length);
    assertEquals(0, model.indices[0]);
    assertEquals(1, model.indices[1]);
    assertEquals(3, model.indices[2]);
    assertEquals(5, model.indices[3]);

    assertEquals(4, model.windowTimes.length);
    assertEquals(1475452800, model.windowTimes[0].toEpochSecond());
    assertEquals(1476057600, model.windowTimes[1].toEpochSecond());
    assertEquals(1476662400, model.windowTimes[2].toEpochSecond());
    assertEquals(1477267200, model.windowTimes[3].toEpochSecond());

    // missing first window
    ts = new TimeSeries();
    //ts.append(1475452800, 10);
    //ts.append(1475453100, 25);

    ts.append(1476057600, 20);
    ts.append(1476057900, 45);

    ts.append(1476662400, 30);
    ts.append(1476662700, 55);

    ts.append(1477267200, 40);
    ts.append(1477267500, 65);

    model.initializeIndices(ts.data, start);

    assertEquals(4, model.indices.length);
    assertEquals(0, model.indices[0]);
    assertEquals(0, model.indices[1]);
    assertEquals(2, model.indices[2]);
    assertEquals(4, model.indices[3]);

    // missing last dp
    ts = new TimeSeries();
    ts.append(1475452800, 10);
    ts.append(1475453100, 25);

    ts.append(1476057600, 20);
    ts.append(1476057900, 45);

    ts.append(1476662400, 30);
    ts.append(1476662700, 55);

    ts.append(1477267200, 40);
    //ts.append(1477267500, 65);

    model.initializeIndices(ts.data, start);

    assertEquals(4, model.indices.length);
    assertEquals(0, model.indices[0]);
    assertEquals(2, model.indices[1]);
    assertEquals(4, model.indices[2]);
    assertEquals(6, model.indices[3]);

    // missing last window
    ts = new TimeSeries();
    ts.append(1475452800, 10);
    ts.append(1475453100, 25);

    ts.append(1476057600, 20);
    ts.append(1476057900, 45);

    ts.append(1476662400, 30);
    ts.append(1476662700, 55);

    //ts.append(1477267200, 40);
    //ts.append(1477267500, 65);

    model.initializeIndices(ts.data, start);

    assertEquals(4, model.indices.length);
    assertEquals(0, model.indices[0]);
    assertEquals(2, model.indices[1]);
    assertEquals(4, model.indices[2]);
    assertEquals(-1, model.indices[3]);

    // missing middle DP
    ts = new TimeSeries();
    ts.append(1475452800, 10);
    ts.append(1475453100, 25);

    ts.append(1476057600, 20);
    ts.append(1476057900, 45);

    //ts.append(1476662400, 30);
    ts.append(1476662700, 55);

    ts.append(1477267200, 40);
    ts.append(1477267500, 65);

    model.initializeIndices(ts.data, start);

    assertEquals(4, model.indices.length);
    assertEquals(0, model.indices[0]);
    assertEquals(2, model.indices[1]);
    assertEquals(4, model.indices[2]);
    assertEquals(5, model.indices[3]);

    // missing middle window
    ts = new TimeSeries();
    ts.append(1475452800, 10);
    ts.append(1475453100, 25);

    ts.append(1476057600, 20);
    ts.append(1476057900, 45);

    //ts.append(1476662400, 30);
    //ts.append(1476662700, 55);

    ts.append(1477267200, 40);
    ts.append(1477267500, 65);

    model.initializeIndices(ts.data, start);

    assertEquals(4, model.indices.length);
    assertEquals(0, model.indices[0]);
    assertEquals(2, model.indices[1]);
    assertEquals(4, model.indices[2]);
    assertEquals(4, model.indices[3]);

    // only one window
    ts = new TimeSeries();
    //ts.append(1475452800, 10);
    //ts.append(1475453100, 25);

    ts.append(1476057600, 20);
    ts.append(1476057900, 45);

    //ts.append(1476662400, 30);
    //ts.append(1476662700, 55);

    //ts.append(1477267200, 40);
    //ts.append(1477267500, 65);

    model.initializeIndices(ts.data, start);

    assertEquals(4, model.indices.length);
    assertEquals(0, model.indices[0]);
    assertEquals(0, model.indices[1]);
    assertEquals(-1, model.indices[2]);
    assertEquals(-1, model.indices[3]);

    // Off by a second
    ts = new TimeSeries();
    //ts.append(1475452800, 10);
    //ts.append(1475453100, 25);

    ts.append(1476057599, 20);
    ts.append(1476057900, 45);

    //ts.append(1476662400, 30);
    //ts.append(1476662700, 55);

    //ts.append(1477267200, 40);
    //ts.append(1477267500, 65);

    model.initializeIndices(ts.data, start);

    assertEquals(4, model.indices.length);
    assertEquals(0, model.indices[0]);
    assertEquals(1, model.indices[1]);
    assertEquals(-1, model.indices[2]);
    assertEquals(-1, model.indices[3]);

    // data earlier than the first window
    ts = new TimeSeries();
    ts.append(1474243200, 10);
    ts.append(1474243500, 25);

    ts.append(1474848000, 20);
    ts.append(1474848300, 45);

    model.initializeIndices(ts.data, start);

    assertEquals(4, model.indices.length);
    assertEquals(-1, model.indices[0]);
    assertEquals(-1, model.indices[1]);
    assertEquals(-1, model.indices[2]);
    assertEquals(-1, model.indices[3]);

    // data later than the first window
    ts = new TimeSeries();
    ts.append(1477872000, 10);
    ts.append(1477872300, 25);

    ts.append(1478476800, 20);
    ts.append(1478477000, 45);

    model.initializeIndices(ts.data, start);

    assertEquals(4, model.indices.length);
    assertEquals(0, model.indices[0]);
    assertEquals(0, model.indices[1]);
    assertEquals(0, model.indices[2]);
    assertEquals(0, model.indices[3]);

    // NaNs
    ts = new TimeSeries();
    ts.append(1475452800, Float.NaN);
    ts.append(1475453100, 25);

    ts.append(1476057600, Float.NaN);
    ts.append(1476057900, 45);

    ts.append(1476662400, Float.NaN);
    ts.append(1476662700, 55);

    ts.append(1477267200, Float.NaN);
    ts.append(1477267500, 65);

    model.initializeIndices(ts.data, start);

    assertEquals(4, model.indices.length);
    assertEquals(0, model.indices[0]);
    assertEquals(2, model.indices[1]);
    assertEquals(4, model.indices[2]);
    assertEquals(6, model.indices[3]);

    assertEquals(4, model.windowTimes.length);
    assertEquals(1475452800, model.windowTimes[0].toEpochSecond());
    assertEquals(1476057600, model.windowTimes[1].toEpochSecond());
    assertEquals(1476662400, model.windowTimes[2].toEpochSecond());
    assertEquals(1477267200, model.windowTimes[3].toEpochSecond());
}

From source file:org.caleydo.view.bicluster.elem.GLRootElement.java

/**
 *
 * @param isDimensionThresholds// www  .j ava  2s  .  c o m
 * @param thresholds
 *            bicluster id x threshold
 */
public void setThresholds(EDimension dimension, Map<Integer, Float> thresholds) {
    float thresh = Float.NEGATIVE_INFINITY;
    for (NormalClusterElement elem : allNormalClusters()) {
        int number = elem.getBiClusterNumber();
        if (thresholds.containsKey(number)) {
            float t = thresholds.get(number);
            if (Float.isInfinite(thresh))
                thresh = t;
            if (t != thresh)
                thresh = Float.NaN;
            elem.setThreshold(dimension, t, MyUnboundSpinner.UNBOUND, EThresholdMode.ABS);
        }
    }
    if (!Float.isNaN(thresh) && !Float.isInfinite(thresh)) { // all the same set that in the parameter toolbar
        this.toolbarParam.setThreshold(dimension, thresh);
    }
    updateAllEdges();
}

From source file:com.cognitect.transit.TransitTest.java

public void testSpecialNumbers() throws Exception {
    assertEquals(scalar("\"~zNaN\""), writeJson(Double.NaN));
    assertEquals(scalar("\"~zINF\""), writeJson(Double.POSITIVE_INFINITY));
    assertEquals(scalar("\"~z-INF\""), writeJson(Double.NEGATIVE_INFINITY));

    assertEquals(scalar("\"~zNaN\""), writeJson(Float.NaN));
    assertEquals(scalar("\"~zINF\""), writeJson(Float.POSITIVE_INFINITY));
    assertEquals(scalar("\"~z-INF\""), writeJson(Float.NEGATIVE_INFINITY));

    assertEquals(scalarVerbose("\"~zNaN\""), writeJsonVerbose(Double.NaN));
    assertEquals(scalarVerbose("\"~zINF\""), writeJsonVerbose(Double.POSITIVE_INFINITY));
    assertEquals(scalarVerbose("\"~z-INF\""), writeJsonVerbose(Double.NEGATIVE_INFINITY));

    assertEquals(scalarVerbose("\"~zNaN\""), writeJsonVerbose(Float.NaN));
    assertEquals(scalarVerbose("\"~zINF\""), writeJsonVerbose(Float.POSITIVE_INFINITY));
    assertEquals(scalarVerbose("\"~z-INF\""), writeJsonVerbose(Float.NEGATIVE_INFINITY));
}

From source file:org.apache.lucene.search.TopScoreDocCollector.java

@Override
protected TopDocs newTopDocs(ScoreDoc[] results, int start) {
    if (results == null) {
        return EMPTY_TOPDOCS;
    }//w w w  .jav  a2s .c  o  m

    // We need to compute maxScore in order to set it in TopDocs. If start == 0,
    // it means the largest element is already in results, use its score as
    // maxScore. Otherwise pop everything else, until the largest element is
    // extracted and use its score as maxScore.
    float maxScore = Float.NaN;
    if (start == 0) {
        maxScore = results[0].score;
    } else {
        for (int i = pq.size(); i > 1; i--) {
            pq.pop();
        }
        maxScore = pq.pop().score;
    }

    return new TopDocs(totalHits, results, maxScore);
}