Example usage for android.graphics Color GRAY

List of usage examples for android.graphics Color GRAY

Introduction

In this page you can find the example usage for android.graphics Color GRAY.

Prototype

int GRAY

To view the source code for android.graphics Color GRAY.

Click Source Link

Usage

From source file:me.hoen.geofencing.MainActivity.java

@Override
protected void onResume() {
    super.onResume();
    // Register the broadcast receiver to receive status updates
    LocalBroadcastManager.getInstance(this).registerReceiver(mBroadcastReceiver, mIntentFilter);
    /*//  ww  w  .ja va  2  s  . c om
     * Get existing geofences from the latitude, longitude, and radius
     * values stored in SharedPreferences. If no values exist, null is
     * returned.
     */

    for (SimpleGeofence sg : this.simpleGeofences) {
        SimpleGeofence mUIGeofence = mPrefs.getGeofence(sg.getId());
        if (mUIGeofence != null) {
            CircleOptions circleOptions1 = new CircleOptions()
                    .center(new LatLng(mUIGeofence.getLatitude(), mUIGeofence.getLongitude()))
                    .radius(mUIGeofence.getRadius()).strokeColor(Color.GRAY).strokeWidth(2)
                    .fillColor(Color.RED);
            map.addCircle(circleOptions1);
        }
    }

}

From source file:com.artemchep.horario.ui.fragments.master.LessonsFragment.java

@Override
protected void setupToolbar() {
    super.setupToolbar();
    CustomAppBar appBar = getMainActivity().mAppBar;
    appBar.setTitle(getString(R.string.nav_lessons));

    Toolbar toolbar = appBar.getToolbarSpecific();
    toolbar.inflateMenu(R.menu.master_lessons_week);
    toolbar.setOnMenuItemClickListener(this);

    // Load week icon
    TypedArray a = getActivity().getTheme()
            .obtainStyledAttributes(new int[] { R.attr.icon_calendar_empty_grey, R.attr.is_dark_theme });
    int iconDrawableRes = a.getResourceId(0, 0);
    boolean isDarkTheme = a.getBoolean(1, false);
    a.recycle();//from   ww  w  .  ja va2  s .  co m

    float density = getResources().getDisplayMetrics().density;
    mWeekDrawable = new TextDrawable();
    mWeekDrawable.setTranslationY(density * 2);
    mWeekDrawable.setTextSize(density * 10);
    mWeekDrawable.setColor(isDarkTheme ? Color.WHITE : Color.GRAY);
    mWeekCompositeDrawable = new LayerDrawable(
            new Drawable[] { ContextCompat.getDrawable(getContext(), iconDrawableRes), mWeekDrawable });

    Menu menu = toolbar.getMenu();
    mWeekMenuItem = menu.findItem(R.id.action_switch_week);
    mWeekMenuItem.setIcon(mWeekCompositeDrawable);
    mWeekMenuItem.setVisible(mWeekCycle > 1);
    updateWeekNumberMenuItemText();
}

From source file:co.ceryle.radiorealbutton.library.RadioRealButtonGroup.java

private void getAttributes(AttributeSet attrs) {
    TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.RadioRealButtonGroup);

    bottomLineColor = ta.getColor(R.styleable.RadioRealButtonGroup_rrbg_bottomLineColor, Color.GRAY);
    bottomLineSize = ta.getDimensionPixelSize(R.styleable.RadioRealButtonGroup_rrbg_bottomLineSize, 0);
    bottomLineBringToFront = ta.getBoolean(R.styleable.RadioRealButtonGroup_rrbg_bottomLineBringToFront, false);
    bottomLineRadius = ta.getDimensionPixelSize(R.styleable.RadioRealButtonGroup_rrbg_bottomLineRadius, 0);

    selectorColor = ta.getColor(R.styleable.RadioRealButtonGroup_rrbg_selectorColor, Color.GRAY);
    selectorBringToFront = ta.getBoolean(R.styleable.RadioRealButtonGroup_rrbg_selectorBringToFront, false);
    selectorAboveOfBottomLine = ta.getBoolean(R.styleable.RadioRealButtonGroup_rrbg_selectorAboveOfBottomLine,
            false);/*from   ww  w  .  j  av  a2 s.  c  o  m*/
    selectorSize = ta.getDimensionPixelSize(R.styleable.RadioRealButtonGroup_rrbg_selectorSize, 12);
    selectorRadius = ta.getDimensionPixelSize(R.styleable.RadioRealButtonGroup_rrbg_selectorRadius, 0);

    animateSelector = ta.getInt(R.styleable.RadioRealButtonGroup_rrbg_animateSelector, 0);
    animateSelectorDuration = ta.getInt(R.styleable.RadioRealButtonGroup_rrbg_animateSelector_duration, 500);
    animateSelectorDelay = ta.getInt(R.styleable.RadioRealButtonGroup_rrbg_animateSelector_delay, 0);

    dividerSize = ta.getDimensionPixelSize(R.styleable.RadioRealButtonGroup_rrbg_dividerSize, 0);
    boolean hasDividerSize = ta.hasValue(R.styleable.RadioRealButtonGroup_rrbg_dividerSize);
    dividerRadius = ta.getDimensionPixelSize(R.styleable.RadioRealButtonGroup_rrbg_dividerRadius, 0);
    dividerPadding = ta.getDimensionPixelSize(R.styleable.RadioRealButtonGroup_rrbg_dividerPadding, 30);
    dividerColor = ta.getColor(R.styleable.RadioRealButtonGroup_rrbg_dividerColor, Color.TRANSPARENT);
    dividerBackgroundColor = ta.getColor(R.styleable.RadioRealButtonGroup_rrbg_dividerBackgroundColor,
            Color.WHITE);
    hasDividerBackgroundColor = ta.hasValue(R.styleable.RadioRealButtonGroup_rrbg_dividerBackgroundColor);

    selectorDividerSize = ta.getDimensionPixelSize(R.styleable.RadioRealButtonGroup_rrbg_selectorDividerSize,
            dividerSize);
    if (!hasDividerSize) {
        dividerSize = selectorDividerSize;
    }
    selectorDividerRadius = ta
            .getDimensionPixelSize(R.styleable.RadioRealButtonGroup_rrbg_selectorDividerRadius, 0);
    selectorDividerPadding = ta
            .getDimensionPixelSize(R.styleable.RadioRealButtonGroup_rrbg_selectorDividerPadding, 0);
    selectorDividerColor = ta.getColor(R.styleable.RadioRealButtonGroup_rrbg_selectorDividerColor,
            Color.TRANSPARENT);

    radius = ta.getDimension(R.styleable.RadioRealButtonGroup_rrbg_radius, 0);

    animateImages = ta.getInt(R.styleable.RadioRealButtonGroup_rrbg_animateDrawables_enter, 0);
    hasAnimateImages = ta.hasValue(R.styleable.RadioRealButtonGroup_rrbg_animateDrawables_enter);
    animateImagesExit = ta.getInt(R.styleable.RadioRealButtonGroup_rrbg_animateDrawables_exit, 0);
    animateImagesDuration = ta.getInt(R.styleable.RadioRealButtonGroup_rrbg_animateDrawables_enterDuration,
            500);
    animateImagesExitDuration = ta.getInt(R.styleable.RadioRealButtonGroup_rrbg_animateDrawables_exitDuration,
            100);
    animateImagesScale = ta.getFloat(R.styleable.RadioRealButtonGroup_rrbg_animateDrawables_scale, 1.2f);

    animateTexts = ta.getInt(R.styleable.RadioRealButtonGroup_rrbg_animateTexts_enter, 0);
    hasAnimateTexts = ta.hasValue(R.styleable.RadioRealButtonGroup_rrbg_animateTexts_enter);
    animateTextsExit = ta.getInt(R.styleable.RadioRealButtonGroup_rrbg_animateTexts_exit, 0);
    animateTextsDuration = ta.getInt(R.styleable.RadioRealButtonGroup_rrbg_animateTexts_enterDuration, 500);
    animateTextsExitDuration = ta.getInt(R.styleable.RadioRealButtonGroup_rrbg_animateTexts_exitDuration, 100);
    animateTextsScale = ta.getFloat(R.styleable.RadioRealButtonGroup_rrbg_animateTexts_scale, 1.2f);

    lastPosition = initialPosition = ta.getInt(R.styleable.RadioRealButtonGroup_rrbg_checkedPosition, -1);
    checkedButtonId = ta.getResourceId(R.styleable.RadioRealButtonGroup_rrbg_checkedButton, NO_ID);

    buttonPadding = ta.getDimensionPixelSize(R.styleable.RadioRealButtonGroup_rrbg_buttonsPadding, 0);
    buttonPaddingLeft = ta.getDimensionPixelSize(R.styleable.RadioRealButtonGroup_rrbg_buttonsPaddingLeft, 0);
    buttonPaddingRight = ta.getDimensionPixelSize(R.styleable.RadioRealButtonGroup_rrbg_buttonsPaddingRight, 0);
    buttonPaddingTop = ta.getDimensionPixelSize(R.styleable.RadioRealButtonGroup_rrbg_buttonsPaddingTop, 0);
    buttonPaddingBottom = ta.getDimensionPixelSize(R.styleable.RadioRealButtonGroup_rrbg_buttonsPaddingBottom,
            0);

    hasPadding = ta.hasValue(R.styleable.RadioRealButtonGroup_rrbg_buttonsPadding);
    hasPaddingLeft = ta.hasValue(R.styleable.RadioRealButtonGroup_rrbg_buttonsPaddingLeft);
    hasPaddingRight = ta.hasValue(R.styleable.RadioRealButtonGroup_rrbg_buttonsPaddingRight);
    hasPaddingTop = ta.hasValue(R.styleable.RadioRealButtonGroup_rrbg_buttonsPaddingTop);
    hasPaddingBottom = ta.hasValue(R.styleable.RadioRealButtonGroup_rrbg_buttonsPaddingBottom);

    groupBackgroundColor = ta.getColor(R.styleable.RadioRealButtonGroup_rrbg_backgroundColor, Color.WHITE);

    selectorTop = ta.getBoolean(R.styleable.RadioRealButtonGroup_rrbg_selectorTop, false);
    selectorBottom = ta.getBoolean(R.styleable.RadioRealButtonGroup_rrbg_selectorBottom, true);

    borderSize = ta.getDimensionPixelSize(R.styleable.RadioRealButtonGroup_rrbg_borderSize,
            ConversionHelper.dpToPx(getContext(), 1));
    borderColor = ta.getColor(R.styleable.RadioRealButtonGroup_rrbg_borderColor, Color.BLACK);

    boolean hasBorderSize = ta.hasValue(R.styleable.RadioRealButtonGroup_rrbg_borderSize);
    boolean hasBorderColor = ta.hasValue(R.styleable.RadioRealButtonGroup_rrbg_borderColor);
    hasBorder = hasBorderColor || hasBorderSize;

    clickable = ta.getBoolean(R.styleable.RadioRealButtonGroup_android_clickable, true);
    hasClickable = ta.hasValue(R.styleable.RadioRealButtonGroup_android_clickable);
    enabled = ta.getBoolean(R.styleable.RadioRealButtonGroup_android_enabled, true);
    hasEnabled = ta.hasValue(R.styleable.RadioRealButtonGroup_android_enabled);

    animationType = ta.getInt(R.styleable.RadioRealButtonGroup_rrbg_selectorAnimationType, 0);
    enableDeselection = ta.getBoolean(R.styleable.RadioRealButtonGroup_rrbg_enableDeselection, false);

    hasAnimation = ta.getBoolean(R.styleable.RadioRealButtonGroup_rrbg_animate, true);

    selectorFullSize = ta.getBoolean(R.styleable.RadioRealButtonGroup_rrbg_selectorFullSize, false);

    ta.recycle();
}

From source file:com.example.michaelg.myapplication.Item.discreteseekbar.DiscreteSeekBar.java

public DiscreteSeekBar(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    setFocusable(true);/*w ww.  ja v  a2s  .co m*/
    setWillNotDraw(false);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    float density = context.getResources().getDisplayMetrics().density;

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DiscreteSeekBar, defStyleAttr,
            R.style.Widget_DiscreteSeekBar);

    int max = 100;
    int min = 0;
    int value = 0;
    mMirrorForRtl = a.getBoolean(R.styleable.DiscreteSeekBar_dsb_mirrorForRtl, mMirrorForRtl);
    mAllowTrackClick = a.getBoolean(R.styleable.DiscreteSeekBar_dsb_allowTrackClickToDrag, mAllowTrackClick);
    mIndicatorPopupEnabled = a.getBoolean(R.styleable.DiscreteSeekBar_dsb_indicatorPopupEnabled,
            mIndicatorPopupEnabled);
    mTrackHeight = a.getDimensionPixelSize(R.styleable.DiscreteSeekBar_dsb_trackHeight, (int) (1 * density));
    mScrubberHeight = a.getDimensionPixelSize(R.styleable.DiscreteSeekBar_dsb_scrubberHeight,
            (int) (4 * density));
    int thumbSize = a.getDimensionPixelSize(R.styleable.DiscreteSeekBar_dsb_thumbSize,
            (int) (density * ThumbDrawable.DEFAULT_SIZE_DP));
    int separation = a.getDimensionPixelSize(R.styleable.DiscreteSeekBar_dsb_indicatorSeparation,
            (int) (SEPARATION_DP * density));

    //Extra pixels for a minimum touch area of 32dp
    int touchBounds = (int) (density * 32);
    mAddedTouchBounds = Math.max(0, (touchBounds - thumbSize) / 2);

    int indexMax = R.styleable.DiscreteSeekBar_dsb_max;
    int indexMin = R.styleable.DiscreteSeekBar_dsb_min;
    int indexValue = R.styleable.DiscreteSeekBar_dsb_value;
    final TypedValue out = new TypedValue();
    //Not sure why, but we wanted to be able to use dimensions here...
    if (a.getValue(indexMax, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            max = a.getDimensionPixelSize(indexMax, max);
        } else {
            max = a.getInteger(indexMax, max);
        }
    }
    if (a.getValue(indexMin, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            min = a.getDimensionPixelSize(indexMin, min);
        } else {
            min = a.getInteger(indexMin, min);
        }
    }
    if (a.getValue(indexValue, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            value = a.getDimensionPixelSize(indexValue, value);
        } else {
            value = a.getInteger(indexValue, value);
        }
    }

    mMin = min;
    mMax = Math.max(min + 1, max);
    mValue = Math.max(min, Math.min(max, value));
    updateKeyboardRange();

    mIndicatorFormatter = a.getString(R.styleable.DiscreteSeekBar_dsb_indicatorFormatter);

    ColorStateList trackColor = a.getColorStateList(R.styleable.DiscreteSeekBar_dsb_trackColor);
    ColorStateList progressColor = a.getColorStateList(R.styleable.DiscreteSeekBar_dsb_progressColor);
    ColorStateList rippleColor = a.getColorStateList(R.styleable.DiscreteSeekBar_dsb_rippleColor);
    boolean editMode = isInEditMode();
    if (editMode || rippleColor == null) {
        rippleColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { Color.DKGRAY });
    }
    if (editMode || trackColor == null) {
        trackColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { Color.GRAY });
    }
    if (editMode || progressColor == null) {
        progressColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { DEFAULT_THUMB_COLOR });
    }

    mRipple = SeekBarCompat.getRipple(rippleColor);
    if (isLollipopOrGreater) {
        SeekBarCompat.setBackground(this, mRipple);
    } else {
        mRipple.setCallback(this);
    }

    TrackRectDrawable shapeDrawable = new TrackRectDrawable(trackColor);
    mTrack = shapeDrawable;
    mTrack.setCallback(this);

    shapeDrawable = new TrackRectDrawable(progressColor);
    mScrubber = shapeDrawable;
    mScrubber.setCallback(this);

    mThumb = new ThumbDrawable(progressColor, thumbSize);
    mThumb.setCallback(this);
    mThumb.setBounds(0, 0, mThumb.getIntrinsicWidth(), mThumb.getIntrinsicHeight());

    if (!editMode) {
        mIndicator = new PopupIndicator(context, attrs, defStyleAttr, convertValueToMessage(mMax), thumbSize,
                thumbSize + mAddedTouchBounds + separation);
        mIndicator.setListener(mFloaterListener);
    }
    a.recycle();

    setNumericTransformer(new DefaultNumericTransformer());

}

From source file:cn.longchou.wholesale.activity.VehicleDetailActivity.java

@Override
 public void initData() {
     mTitle.setText("");
     ///*from  ww w . ja  va 2 s  .  com*/
     mOldMoney.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);

     cars = (Cars) getIntent().getExtras().getSerializable("cars");

     //??
     setAttention();

     //??
     setCartCat();

     mTvCarId.setText("ID:" + cars.carID);

     mCarDescrip.setText(cars.carName);
     boolean isCertified = PreferUtils.getBoolean(getApplicationContext(), "isCertified", false);
     if (isCertified) {
         if ("".equals(cars.carPrice)) {
             mMoney.setTextColor(Color.GRAY);
             mMoney.setTextSize(12);
             mMoney_Wan.setVisibility(View.GONE);
         } else {

             mMoney_Wan.setVisibility(View.VISIBLE);
         }
         //?
         mMoney.setText(cars.carPrice + "");
         //?
         mEarnestText.setVisibility(View.VISIBLE);
         mEarnest.setText(cars.carSubscription + "");
     } else {
         //??????
         mMoney.setText("??");
         mMoney.setTextSize(14);
         mMoney_Wan.setVisibility(View.GONE);

         //??
         mEarnestText.setVisibility(View.INVISIBLE);

     }

     mMark.setImageResource(R.drawable.miao);

     //
     getSerVerCarVisitData();

     getServerData(cars);

     mScrollView.fullScroll(ScrollView.FOCUS_UP);
     handler.sendEmptyMessage(1);

     getCarMaintenanceData();
 }

From source file:opensourceproject.kanjisteps.Practice_slides.java

public int quizByLevelMeaning() {
    enableButtons();/*from w ww .  j a  v a 2s.c  o  m*/
    KanjiToStudyAdapter dbAdapter = new KanjiToStudyAdapter(this);
    Cursor cursor = dbAdapter.getItemsByLevelRandom(level_marker, 1);
    TextView txt = (TextView) findViewById(R.id.textToDisplay);
    TextView txtDblTap = (TextView) findViewById(R.id.textDoubleTap);
    txtDblTap.setOnClickListener(this);
    txtDblTap.setOnTouchListener(gestureListener);
    txtDblTap.setVisibility(View.INVISIBLE);
    String temp = "";
    if (cursor.moveToNext()) {
        int indexOfKanji = cursor.getColumnIndex(dbAdapter.myKanjiDb.COLUMN_KANJI);
        temp = cursor.getString(indexOfKanji);

        txt.setText(temp);
        txt.setTextSize(50);
        txt.setTextColor(Color.GRAY);
        txt.setTag("1"); //1 means ENGLISH meaning
        populateButtonChoicesMeaning(cursor, dbAdapter);
        return 0;
    } else {
        /*
        txt.setText("You don't have any items to review yet! Check back later.");
        txt.setTextSize(20);
        txt.setTextColor(Color.GRAY);
                
        resetButtons();
        */
        return 1; //display notice that there is nothing to review yet.
    }

}

From source file:com.mZone.epro.common.view.SlidingTabLayout.java

private void changeTabWidgetView(int tabIndex) {
    if (mTabViewLayoutId != 0) {
        for (int i = 0; i < tabViewArray.size(); i++) {
            View tabView = tabViewArray.get(i);
            TextView tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
            if (mTabViewLayoutId == R.layout.launch_home_fragment_tabhost_tabwidget) {
                ImageView iconView = (ImageView) tabView.findViewById(R.id.tabwidget_imageview);
                if (i == tabIndex) {
                    iconView.setImageResource(mCustomTabDelegate.getIconId(i, 1));
                    tabTitleView.setTextColor(mTabStrip.getCustomTabColorizer().getIndicatorColor(i));
                } else {
                    iconView.setImageResource(mCustomTabDelegate.getIconId(i, 0));
                    tabTitleView.setTextColor(Color.GRAY);
                }/*from w w w.  j a  va  2 s  .  c o m*/
            }
        }
    }
}

From source file:flex.android.magiccube.activity.ActivityBattleMode.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.mode_battle);
    btMoveBack = (ImageButton) findViewById(R.id.bt_battle_moveback);
    btMoveForward = (ImageButton) findViewById(R.id.bt_battle_moveforward);
    btStartOb = (ImageButton) findViewById(R.id.bt_battle_startob);

    clock = (ImageView) findViewById(R.id.img_battle_clock);
    txtTime = (TextView) findViewById(R.id.txt_battle_time);
    txtNStep = (TextView) findViewById(R.id.txt_battle_nStep);
    img_nstep = (ImageView) findViewById(R.id.img_battle_nstep);
    progress = (SeekBar) findViewById(R.id.sbar_battle_timer);

    /*//  w w  w .  j a  v a2 s  .c om
     * clock.setVisibility(View.VISIBLE);
     * btMoveForward.setVisibility(View.VISIBLE);
     * btMoveBack.setVisibility(View.VISIBLE);
     */

    glView = (ViewBattleMode) findViewById(R.id.game_view_battle);
    glView.SetOnTimerListener(this);
    // glView.setOnStateListener(this);
    glView.SetOnStepListener(this);
    glView.SetMessageSender(this);
    glView.SetDrawCube(false);
    glView.setOnStateListener(this);

    glView2 = (ViewBattleMode) findViewById(R.id.game_view_battle2);
    glView2.SetCanMove(false);

    btMoveBack.setOnClickListener(buttonListener);
    btMoveForward.setOnClickListener(buttonListener);
    btStartOb.setOnClickListener(buttonListener);

    float fontsize = 25.f;
    Typeface typeFace = Typeface.createFromAsset(getAssets(), "fonts/Angies New House.ttf");
    txtTime.setTypeface(typeFace);
    txtTime.setTextColor(Color.GRAY);
    txtTime.setTextSize(fontsize);

    txtNStep.setTypeface(typeFace);
    txtNStep.setTextColor(Color.GRAY);
    txtNStep.setTextSize(fontsize);

    State = OnStateListener.NONE;

    BgVolume = MagiccubePreference.GetPreference(MagiccubePreference.BgVolume, this);
    LinearBgVolume = MusicPlayThread.GetLinearVolume(BgVolume);

    GamingbgmPlayer = MediaPlayer.create(this, R.raw.bg2);
    ObservingbgmPlayer = MediaPlayer.create(this, R.raw.bg);
    FinishbgmPlayer = MediaPlayer.create(this, R.raw.finish);

    GamingbgmPlayer.setVolume(LinearBgVolume, LinearBgVolume);
    ObservingbgmPlayer.setVolume(LinearBgVolume, LinearBgVolume);
    FinishbgmPlayer.setVolume(LinearBgVolume, LinearBgVolume);

    Init();

    // Get local Bluetooth adapter
    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    // If the adapter is null, then Bluetooth is not supported
    if (mBluetoothAdapter == null) {
        Toast.makeText(this, "...", Toast.LENGTH_LONG).show();
        finish();
        return;
    }

    WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);

    width = wm.getDefaultDisplay().getWidth();
    height = wm.getDefaultDisplay().getHeight();

    layout_moveforward = (LinearLayout) findViewById(R.id.layout_battle_moveforward);
    layout_moveback = (LinearLayout) findViewById(R.id.layout_battle_moveback);

    int buttonwidth = width / 5;
    int buttonheight = height / 13;

    LinearLayout.LayoutParams parms = new LinearLayout.LayoutParams(buttonwidth, buttonheight);

    btMoveForward.setLayoutParams(parms);
    btMoveBack.setLayoutParams(parms);

    layout_moveforward.setPadding(width / 2 - buttonwidth / 2, height - buttonheight, 0, 0);
    layout_moveback.setPadding(width / 15, height - buttonheight, 0, 0);

}

From source file:self.philbrown.droidQuery.Example.ExampleActivity.java

/**
 * Refreshes the list of cells containing App.net messages. This <em>ListView</em> is actually
 * a <em>scrollable LinearLayout</em>, and is assembled in much the same way a layout would be
 * made using <em>JavaScript</em>, with the <em>CSS3</em> attribute <em>overscroll-y: scroll</em>.
 * <br>//w  w  w  . jav a  2 s.  c  o  m
 * For this example, the public stream is retrieved using <em>ajax</em>, and for each message
 * received, a new cell is created. For each cell, a new <em>ajax</em> request is started to
 * retrieve the thumbnail image for the user. As all these events occur on a background thread, the
 * main ScrollView is populated with cells and displayed to the user.
 * <br>
 * The stream <em>JSON</em> request is performed in a <em>global ajax</em> request, which will
 * trigger the global start and stop events (which show a progress indicator, using a droidQuery
 * extension). The image get requests are not global, so they will not trigger global events.
 */
public void refresh() {
    $.ajax(new AjaxOptions().url("https://alpha-api.app.net/stream/0/posts/stream/global").dataType("json")
            .type("GET").error(new Function() {
                @Override
                public void invoke($ droidQuery, Object... params) {
                    //Object error, int status, String reason
                    Object error = params[0];
                    int status = (Integer) params[1];
                    String reason = (String) params[2];
                    Log.w("app.net Client", "Could not complete request: " + reason);
                }
            }).success(new Function() {
                @Override
                public void invoke($ droidQuery, Object... params) {
                    //Object, reason
                    JSONObject json = (JSONObject) params[0];
                    String reason = (String) params[1];
                    try {
                        Map<String, ?> map = $.map(json);
                        JSONArray datas = (JSONArray) map.get("data");

                        if (datas.length() != 0) {
                            //clear old subviews in layout
                            $.with(ExampleActivity.this, R.id.example_layout).selectChildren().remove();

                            //get each message infos and create a cell
                            for (int i = 0; i < datas.length(); i++) {
                                JSONObject jdata = (JSONObject) datas.get(i);
                                Map<String, ?> data = $.map(jdata);

                                String text = data.get("text").toString();

                                Map<String, ?> user = $.map((JSONObject) data.get("user"));

                                String username = user.get("username").toString();
                                String avatarURL = ((JSONObject) user.get("avatar_image")).getString("url");

                                //get Avatar image in a new task (but go ahead and create the cell for now)
                                LinearLayout cell = new LinearLayout(ExampleActivity.this);
                                LinearLayout.LayoutParams cell_params = new LinearLayout.LayoutParams(
                                        LinearLayout.LayoutParams.MATCH_PARENT,
                                        LinearLayout.LayoutParams.WRAP_CONTENT);
                                cell_params.bottomMargin = 5;
                                cell.setLayoutParams(cell_params);
                                cell.setOrientation(LinearLayout.HORIZONTAL);
                                cell.setWeightSum(8);
                                cell.setPadding(5, 5, 5, 5);
                                cell.setBackgroundColor(Color.parseColor("#333333"));
                                final LinearLayout fcell = cell;

                                //contains the image location
                                ImageView image = new ImageView(ExampleActivity.this);
                                image.setId(99);
                                LinearLayout.LayoutParams ip_params = new LinearLayout.LayoutParams(0,
                                        LinearLayout.LayoutParams.WRAP_CONTENT);
                                ip_params.weight = 2;
                                image.setLayoutParams(ip_params);
                                image.setPadding(0, 0, 5, 0);
                                $.with(image).attr("alpha", 0.0f);
                                cell.addView(image);
                                final ImageView fimage = image;

                                //the text location in the cell
                                LinearLayout body = new LinearLayout(ExampleActivity.this);
                                LinearLayout.LayoutParams body_params = new LinearLayout.LayoutParams(0,
                                        LinearLayout.LayoutParams.WRAP_CONTENT);
                                body_params.weight = 5;
                                body.setLayoutParams(body_params);
                                body.setOrientation(LinearLayout.VERTICAL);
                                body.setGravity(Gravity.CENTER_VERTICAL);
                                cell.addView(body);

                                //the username
                                TextView name = new TextView(ExampleActivity.this);
                                LinearLayout.LayoutParams name_params = new LinearLayout.LayoutParams(
                                        LinearLayout.LayoutParams.WRAP_CONTENT,
                                        LinearLayout.LayoutParams.WRAP_CONTENT);
                                name.setLayoutParams(name_params);
                                name.setTextColor(Color.GRAY);
                                name.setText(username);
                                body.addView(name);

                                //the message
                                TextView message = new TextView(ExampleActivity.this);
                                LinearLayout.LayoutParams msg_params = new LinearLayout.LayoutParams(
                                        LinearLayout.LayoutParams.WRAP_CONTENT,
                                        LinearLayout.LayoutParams.WRAP_CONTENT);
                                message.setLayoutParams(msg_params);
                                message.setTextColor(Color.WHITE);
                                message.setTextSize(18);
                                message.setText(text);
                                body.addView(message);

                                CheckBox checkbox = new CheckBox(ExampleActivity.this);
                                LinearLayout.LayoutParams box_params = new LinearLayout.LayoutParams(0,
                                        LinearLayout.LayoutParams.WRAP_CONTENT);
                                box_params.weight = 1;
                                checkbox.setLayoutParams(box_params);

                                cell.addView(checkbox);

                                $.with(ExampleActivity.this, R.id.example_layout).add(cell);
                                //$.with(fimage).image(avatarURL, 200, 200, $.noop());
                                $.ajax(new AjaxOptions(avatarURL).type("GET").dataType("image").imageHeight(200)
                                        .imageWidth(200).global(false).success(new Function() {
                                            @Override
                                            public void invoke($ droidQuery, Object... params) {
                                                //Object, reason
                                                Bitmap src = (Bitmap) params[0];
                                                String reason = (String) params[1];
                                                $.with(fimage).val(src);
                                                try {
                                                    $.with(fimage)
                                                            .fadeIn(new AnimationOptions("{ duration: 400 }"));
                                                } catch (Throwable e) {
                                                    e.printStackTrace();
                                                }
                                                LinearLayout.LayoutParams lparams = (LinearLayout.LayoutParams) fcell
                                                        .getLayoutParams();
                                                try {
                                                    lparams.height = Math.min(src.getWidth(),
                                                            fimage.getWidth());
                                                } catch (Throwable t) {
                                                    //ignore NPE
                                                }

                                                fcell.setLayoutParams(lparams);
                                            }
                                        }).error(new Function() {
                                            @Override
                                            public void invoke($ droidQuery, Object... params) {
                                                //Object error, int status, String reason
                                                Object error = params[0];
                                                int status = (Integer) params[1];
                                                String reason = (String) params[2];
                                                Log.w("app.net Client",
                                                        "Could not complete image request: " + reason);
                                            }
                                        }));

                            }
                        } else {
                            Log.w("app.net client", "could not update data");
                        }
                    } catch (Throwable t) {
                        t.printStackTrace();
                    }
                }
            }));
}

From source file:org.croudtrip.fragments.join.JoinResultsFragment.java

private void startBackgroundSearch(Bundle bundle) {
    Timber.d("BG Search started");
    final SharedPreferences prefs = getActivity().getSharedPreferences(Constants.SHARED_PREF_FILE_PREFERENCES,
            Context.MODE_PRIVATE);

    double currentLocationLat = bundle.getDouble(JoinDispatchFragment.KEY_CURRENT_LOCATION_LATITUDE);
    double currentLocationLon = bundle.getDouble(JoinDispatchFragment.KEY_CURRENT_LOCATION_LONGITUDE);
    double destinationLat = bundle.getDouble(JoinDispatchFragment.KEY_DESTINATION_LATITUDE);
    double destinationLon = bundle.getDouble(JoinDispatchFragment.KEY_DESTINATION_LONGITUDE);
    int maxWaitingTime = bundle.getInt(JoinDispatchFragment.KEY_MAX_WAITING_TIME);

    // Ask the server for matches
    TripQueryDescription tripQueryDescription = new TripQueryDescription(
            new RouteLocation(currentLocationLat, currentLocationLon),
            new RouteLocation(destinationLat, destinationLon), maxWaitingTime);

    Subscription subscription = tripsResource.queryOffers(tripQueryDescription)
            .compose(new DefaultTransformer<TripQueryResult>()).subscribe(new Action1<TripQueryResult>() {
                // SUCCESS

                @Override/*  w w w.j a  v  a  2s. c  o  m*/
                public void call(TripQueryResult result) {

                    List<SuperTripReservation> reservations = result.getReservations();

                    // Update the caption text
                    int numMatches = reservations.size();
                    if (numMatches != 0) {
                        Timber.d("BG Search found results");

                        SharedPreferences.Editor editor = prefs.edit();
                        editor.putBoolean(Constants.SHARED_PREF_KEY_SEARCHING, false);
                        editor.apply();

                        //Set the notificationText in the navigationDrawer
                        ((MaterialNavigationDrawer) getActivity()).getCurrentSection()
                                .setNotifications(numMatches);

                        //Switch out the view
                        waitingView.setVisibility(View.GONE);
                        resultView.setVisibility(View.VISIBLE);

                        caption.setText(getResources().getQuantityString(R.plurals.join_trip_results,
                                numMatches, numMatches));

                        // Fill the results list
                        adapter.addElements(reservations);

                        if (!(AccountManager.isUserLoggedIn(getActivity()))) {
                            recyclerView.setBackgroundColor(Color.GRAY);
                            drawRegisterDialog();
                        }
                    } else if (result.getRunningQuery() != null) {
                        Timber.d("BG Search did not find any results");
                        SharedPreferences.Editor editor = prefs.edit();
                        editor.putLong(Constants.SHARED_PREF_KEY_QUERY_ID, result.getRunningQuery().getId());
                        editor.apply();
                    }
                }

            }, new CrashCallback(this.getActivity(), "failed to join trip", new Action1<Throwable>() {
                @Override
                public void call(Throwable throwable) {
                    Timber.e("Error when trying to join a trip: " + throwable.getMessage());

                    SharedPreferences.Editor editor = prefs.edit();
                    editor.putBoolean(Constants.SHARED_PREF_KEY_SEARCHING, false);
                    editor.apply();

                    Toast.makeText(getActivity().getApplicationContext(),
                            getResources().getString(R.string.error), Toast.LENGTH_LONG).show();

                    Intent startingIntent = new Intent(Constants.EVENT_CHANGE_JOIN_UI);
                    LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(startingIntent);
                }
            }));

    subscriptions.add(subscription);
}