Example usage for android.view Gravity BOTTOM

List of usage examples for android.view Gravity BOTTOM

Introduction

In this page you can find the example usage for android.view Gravity BOTTOM.

Prototype

int BOTTOM

To view the source code for android.view Gravity BOTTOM.

Click Source Link

Document

Push object to the bottom of its container, not changing its size.

Usage

From source file:br.unicamp.busfinder.ServerOperations.java

public static void Point2Point(GeoPoint touchedpoint, MapView map, final Context c, Calendar now) {

    // now.setTime(new Time(12, 40, 00)); // remove this
    String time = pad(now.getTime().getHours()) + ":" + pad(now.getTime().getMinutes()) + ":"
            + pad(now.getTime().getSeconds());
    // time = "";

    TouchOverlay.pathlist.clearPath(map);

    String req = String.format(
            BusFinderActivity.SERVER + "Point2Point?s_lat=%f;s_lon=%f;d_lat=%f;d_lon=%f;time=%s;limit=%d",
            (double) BusFinderActivity.myPoint.getLatitudeE6() / 1E6,
            (double) BusFinderActivity.myPoint.getLongitudeE6() / 1E6,
            (double) touchedpoint.getLatitudeE6() / 1e6, (double) touchedpoint.getLongitudeE6() / 1e6, time, 5);
    JSONArray path = getJSON(req);//from w w w. j av a2s  .  c  o  m
    if (path == null)
        Log.d("No response", "null");
    JSONObject obj = null;
    try {
        obj = path.getJSONObject(0);

        int source = Integer.parseInt(obj.getString("source"));
        int dest = Integer.parseInt(obj.getString("dest"));
        String departure = obj.getString("departure");
        String arrival = obj.getString("arrival");
        String circular = obj.getString("circular");
        int timeleft = obj.getInt("time");
        int distSource = obj.getInt("dist_source");
        int distDest = obj.getInt("dist_dest");
        String finalTime = obj.getString("final_time");
        String action = obj.getString("action").replaceAll("_", "");

        req = BusFinderActivity.SERVER + "getStopPosition?stopid=";

        JSONArray jar = getJSON(req + source);

        GeoPoint sourcePoint = geoFromJSON(jar.getJSONObject(0), "lat", "lon", "name");

        TouchOverlay.DrawPath(BusFinderActivity.myPoint, sourcePoint, Color.GREEN, map, true);

        String source_ = jar.getJSONObject(0).getString("name");
        if (source_ == null)
            source_ = "Point" + source;

        jar = getJSON(req + dest);

        GeoPoint destPoint = geoFromJSON(jar.getJSONObject(0), "lat", "lon", "name");

        TouchOverlay.DrawPath(destPoint, touchedpoint, Color.BLUE, map, false);

        /* EDIT HERE */
        String site = String.format(BusFinderActivity.SERVER + "getBusPath?line=%d&via=%d&start=%d&end=%d",
                (int) Integer.parseInt(obj.getString("line")), (int) Integer.parseInt(obj.getString("via")),
                (int) Integer.parseInt(obj.getString("source")), (int) Integer.parseInt(obj.getString("dest")));
        JSONArray sitePoints = getJSON(site);
        GeoPoint[] points = new GeoPoint[sitePoints.length()];
        for (int i = 0; i < sitePoints.length(); i++) {
            points[i] = ServerOperations.geoFromJSON(sitePoints.getJSONObject(i), "lat", "lon", "name");
        }
        TouchOverlay.DrawPathList(points, Color.RED, map, false);
        Log.d("xxx", "URL=" + site.toString());
        // get the kml (XML) doc. And parse it to get the coordinates(direction
        // route).
        /* END EDIT
        PathOverlay pO = new PathOverlay(sourcePoint, destPoint, 2,
              Color.RED);
        TouchOverlay.pathlist.addItem(pO, map);*/

        String dest_ = jar.getJSONObject(0).getString("name");
        if (dest_ == null)
            dest_ = "Point" + dest;

        Log.d("TOAST", "Take " + circular + " from " + source_ + " at " + departure + " and arrive at " + dest_
                + " at " + arrival + "----YOU HAVE " + timeleft + " seconds");

        BusFinderActivity.toast = Toast.makeText(c, "teste", Toast.LENGTH_SHORT);
        BusFinderActivity.toast.setGravity(Gravity.BOTTOM, 0, 0);
        //BusFinderActivity.toast.show();

        BusFinderActivity.timer = new CountDownTimer(timeleft * 1000, 1000) {

            public void onTick(long millisUntilFinished) {
                //BusFinderActivity.toast.setText("Bus Leaves\n in: "
                //   + millisUntilFinished / 1000 + " s");
                //BusFinderActivity.toast.show();
                BusFinderActivity.countdown.setText("Bus leaves in:" + millisUntilFinished / 1000 + " s");
            }

            public void onFinish() {
                BusFinderActivity.toast.setText("Times up!");
                BusFinderActivity.toast.show();
                BusFinderActivity.countdown.setText("0:00");
            }
        };

        BusFinderActivity.timer.start();

        BusFinderActivity.dialog = new AlertDialog.Builder(c).create();
        BusFinderActivity.dialog.setMessage(String.format(
                "%s to %s (%d m)" + "\n\n Take %s at %s" + "\n\n Arrive at %s at %s"
                        + "\n\n Go to your final destination (%d m) ~%s" + "",
                action, source + "_" + source_, distSource, circular, departure, dest + "_" + dest_, arrival,
                distDest, finalTime));

        BusFinderActivity.dialog.setCanceledOnTouchOutside(true);
        BusFinderActivity.dialog.show();
        BusFinderActivity.dialog.setTitle("Instructions");

        return;

    } catch (JSONException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }

    Toast.makeText(c, "Sorry No Path Found or Connection down...", Toast.LENGTH_LONG).show();

}

From source file:com.geomoby.geodeals.DemoService.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.geomoby_main);
    mContext = this;

    mToggle = (CompoundButton) findViewById(R.id.togglebutton);

    spref = getSharedPreferences(PREF_NAME, MODE_PRIVATE);
    isCheckedStatus = spref.getBoolean("check", false); //default is false

    /*/*from   w w w. j a  va  2  s.c  o  m*/
     * Set up toggle status
     */
    if (!isCheckedStatus)
        mToggle.setChecked(false);
    else
        mToggle.setChecked(true);

    /*
     *  Save the tags in the GeoMoby shared preferences in private mode for the user. These tags will be used
     *  to segment your audience when creating your proximity alerts. Please make sure that they match with
     *  the ones configured in your dashboard when you create an alert.
     *  Ex: 'test' is the default tag so make sure that it is set up in your Account page
     */
    SharedPreferences mySharedPreferences = getSharedPreferences(PREF, MODE_PRIVATE);

    // Build the string of tags - empty for testing. Make sure that you create your first geofences with no tags in your dashboard.
    // Add your own logic here: "male,vip,monday"...
    String tags = "";

    // Commit the string
    SharedPreferences.Editor prefEditor = mySharedPreferences.edit();
    prefEditor.putString(SETTING_TAGS, tags);
    prefEditor.commit();

    /*
     *  Monitor the toggle - Our SDK will ensure that all services are running/stopping properly
     */
    mToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

            if (isChecked == false) {

                mToggle.setPressed(false);

                // Stop the GeoMoby tracking service
                startService(new Intent(DemoService.this, GeomobyStopService.class));

                SharedPreferences.Editor editor = spref.edit();
                editor.putBoolean("check", false);
                editor.commit();

            } else {

                mToggle.setPressed(true);

                // Start the GeoMoby tracking service
                startService(new Intent(DemoService.this, GeomobyStartService.class));

                SharedPreferences.Editor editor = spref.edit();
                editor.putBoolean("check", true);
                editor.commit();

                LayoutInflater inflater = getLayoutInflater();
                // Inflate the Layout
                View layout = inflater.inflate(R.layout.geomoby_toast,
                        (ViewGroup) findViewById(R.id.custom_toast_layout));

                // Set the Text to show in TextView
                TextView text = (TextView) layout.findViewById(R.id.textToShow);
                text.setText("GREAT! YOU ARE READY TO RECEIVE REAL-TIME NOTIFICATIONS!");
                Typeface face;
                face = Typeface.createFromAsset(getAssets(), "Bitter-Bold.otf");
                text.setTypeface(face);

                Toast toast = new Toast(getApplicationContext());
                toast.setGravity(Gravity.BOTTOM, 0, 50);
                toast.setDuration(Toast.LENGTH_LONG);
                toast.setView(layout);
                toast.show();
            }
        }
    });

    // Initialise GeoMoby Notification Listener
    GeomobyNotificationsReceiver receiver = new GeomobyNotificationsReceiver();
    receiver.setNotificationListener(this);
}

From source file:android.support.transition.Slide.java

public Slide(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, Styleable.SLIDE);
    int edge = TypedArrayUtils.getNamedInt(a, (XmlPullParser) attrs, "slideEdge", Styleable.Slide.SLIDE_EDGE,
            Gravity.BOTTOM);
    a.recycle();//from w  ww .ja  v a  2  s . c  o m
    //noinspection WrongConstant
    setSlideEdge(edge);
}

From source file:com.b44t.ui.Components.PasscodeView.java

public PasscodeView(final Context context) {
    super(context);

    setWillNotDraw(false);/*  w  w w . j  a v  a2 s.  c o m*/
    setVisibility(GONE);

    backgroundFrameLayout = new FrameLayout(context);
    addView(backgroundFrameLayout);
    LayoutParams layoutParams = (LayoutParams) backgroundFrameLayout.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    backgroundFrameLayout.setLayoutParams(layoutParams);

    passwordFrameLayout = new FrameLayout(context);
    addView(passwordFrameLayout);
    layoutParams = (LayoutParams) passwordFrameLayout.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    passwordFrameLayout.setLayoutParams(layoutParams);

    ImageView imageView = new ImageView(context);
    imageView.setScaleType(ImageView.ScaleType.FIT_XY);
    imageView.setImageResource(R.drawable.ic_launcher /* EDIT BY MR -- was: passcode_logo */);
    passwordFrameLayout.addView(imageView);
    layoutParams = (LayoutParams) imageView.getLayoutParams();
    if (AndroidUtilities.density < 1) {
        layoutParams.width = AndroidUtilities.dp(30);
        layoutParams.height = AndroidUtilities.dp(30);
    } else {
        layoutParams.width = AndroidUtilities.dp(40);
        layoutParams.height = AndroidUtilities.dp(40);
    }
    layoutParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
    layoutParams.bottomMargin = AndroidUtilities.dp(100);
    imageView.setLayoutParams(layoutParams);

    passcodeTextView = new TextView(context);
    passcodeTextView.setTextColor(0xffffffff);
    passcodeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    passcodeTextView.setGravity(Gravity.CENTER_HORIZONTAL);
    passwordFrameLayout.addView(passcodeTextView);
    layoutParams = (LayoutParams) passcodeTextView.getLayoutParams();
    layoutParams.width = LayoutHelper.WRAP_CONTENT;
    layoutParams.height = LayoutHelper.WRAP_CONTENT;
    layoutParams.bottomMargin = AndroidUtilities.dp(62);
    layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
    passcodeTextView.setLayoutParams(layoutParams);

    passwordEditText = new EditText(context);
    passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36);
    passwordEditText.setTextColor(0xffffffff);
    passwordEditText.setMaxLines(1);
    passwordEditText.setLines(1);
    passwordEditText.setGravity(Gravity.CENTER_HORIZONTAL);
    passwordEditText.setSingleLine(true);
    passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
    passwordEditText.setTypeface(Typeface.DEFAULT);
    passwordEditText.setBackgroundDrawable(null);
    AndroidUtilities.clearCursorDrawable(passwordEditText);
    passwordFrameLayout.addView(passwordEditText);
    layoutParams = (FrameLayout.LayoutParams) passwordEditText.getLayoutParams();
    layoutParams.height = LayoutHelper.WRAP_CONTENT;
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.leftMargin = AndroidUtilities.dp(70);
    layoutParams.rightMargin = AndroidUtilities.dp(70);
    layoutParams.bottomMargin = AndroidUtilities.dp(6);
    layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
    passwordEditText.setLayoutParams(layoutParams);
    passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_DONE) {
                processDone(false);
                return true;
            }
            return false;
        }
    });
    passwordEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

        }

        @Override
        public void afterTextChanged(Editable s) {
            if (passwordEditText.length() == 4 && UserConfig.passcodeType == 0) {
                processDone(false);
            }
        }
    });
    passwordEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        public void onDestroyActionMode(ActionMode mode) {
        }

        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            return false;
        }
    });

    checkImage = new ImageView(context);
    checkImage.setImageResource(R.drawable.passcode_check);
    checkImage.setScaleType(ImageView.ScaleType.CENTER);
    checkImage.setBackgroundResource(R.drawable.bar_selector_lock);
    passwordFrameLayout.addView(checkImage);
    layoutParams = (LayoutParams) checkImage.getLayoutParams();
    layoutParams.width = AndroidUtilities.dp(60);
    layoutParams.height = AndroidUtilities.dp(60);
    layoutParams.bottomMargin = AndroidUtilities.dp(4);
    layoutParams.rightMargin = AndroidUtilities.dp(10);
    layoutParams.gravity = Gravity.BOTTOM | Gravity.RIGHT;
    checkImage.setLayoutParams(layoutParams);
    checkImage.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            processDone(false);
        }
    });

    FrameLayout lineFrameLayout = new FrameLayout(context);
    lineFrameLayout.setBackgroundColor(0x26ffffff);
    passwordFrameLayout.addView(lineFrameLayout);
    layoutParams = (LayoutParams) lineFrameLayout.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = AndroidUtilities.dp(1);
    layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT;
    layoutParams.leftMargin = AndroidUtilities.dp(20);
    layoutParams.rightMargin = AndroidUtilities.dp(20);
    lineFrameLayout.setLayoutParams(layoutParams);

    numbersFrameLayout = new FrameLayout(context);
    addView(numbersFrameLayout);
    layoutParams = (LayoutParams) numbersFrameLayout.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    numbersFrameLayout.setLayoutParams(layoutParams);

    lettersTextViews = new ArrayList<>(10);
    numberTextViews = new ArrayList<>(10);
    numberFrameLayouts = new ArrayList<>(10);
    for (int a = 0; a < 10; a++) {
        TextView textView = new TextView(context);
        textView.setTextColor(0xffffffff);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36);
        textView.setGravity(Gravity.CENTER);
        textView.setText(String.format(Locale.US, "%d", a));
        numbersFrameLayout.addView(textView);
        layoutParams = (LayoutParams) textView.getLayoutParams();
        layoutParams.width = AndroidUtilities.dp(50);
        layoutParams.height = AndroidUtilities.dp(50);
        layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
        textView.setLayoutParams(layoutParams);
        numberTextViews.add(textView);

        textView = new TextView(context);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
        textView.setTextColor(0x7fffffff);
        textView.setGravity(Gravity.CENTER);
        numbersFrameLayout.addView(textView);
        layoutParams = (LayoutParams) textView.getLayoutParams();
        layoutParams.width = AndroidUtilities.dp(50);
        layoutParams.height = AndroidUtilities.dp(20);
        layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
        textView.setLayoutParams(layoutParams);
        switch (a) {
        case 0:
            textView.setText("+");
            break;
        case 2:
            textView.setText("ABC");
            break;
        case 3:
            textView.setText("DEF");
            break;
        case 4:
            textView.setText("GHI");
            break;
        case 5:
            textView.setText("JKL");
            break;
        case 6:
            textView.setText("MNO");
            break;
        case 7:
            textView.setText("PQRS");
            break;
        case 8:
            textView.setText("TUV");
            break;
        case 9:
            textView.setText("WXYZ");
            break;
        default:
            break;
        }
        lettersTextViews.add(textView);
    }
    eraseView = new ImageView(context);
    eraseView.setScaleType(ImageView.ScaleType.CENTER);
    eraseView.setImageResource(R.drawable.passcode_delete);
    numbersFrameLayout.addView(eraseView);
    layoutParams = (LayoutParams) eraseView.getLayoutParams();
    layoutParams.width = AndroidUtilities.dp(50);
    layoutParams.height = AndroidUtilities.dp(50);
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    eraseView.setLayoutParams(layoutParams);
    for (int a = 0; a < 11; a++) {
        FrameLayout frameLayout = new FrameLayout(context);
        frameLayout.setBackgroundResource(R.drawable.bar_selector_lock);
        frameLayout.setTag(a);
        if (a == 10) {
            frameLayout.setOnLongClickListener(new OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    passwordEditText.setText("");
                    return true;
                }
            });
        }
        frameLayout.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                int tag = (Integer) v.getTag();
                switch (tag) {
                case 0:
                    appendCharacter("0");
                    break;
                case 1:
                    appendCharacter("1");
                    break;
                case 2:
                    appendCharacter("2");
                    break;
                case 3:
                    appendCharacter("3");
                    break;
                case 4:
                    appendCharacter("4");
                    break;
                case 5:
                    appendCharacter("5");
                    break;
                case 6:
                    appendCharacter("6");
                    break;
                case 7:
                    appendCharacter("7");
                    break;
                case 8:
                    appendCharacter("8");
                    break;
                case 9:
                    appendCharacter("9");
                    break;
                case 10:
                    String text = passwordEditText.getText().toString();
                    if (text.length() > 0) {
                        passwordEditText.setText(text.substring(0, text.length() - 1));
                    }
                    break;
                }
                if (passwordEditText.getText().toString().length() == 4) {
                    processDone(false);
                }
            }
        });
        numberFrameLayouts.add(frameLayout);
    }
    for (int a = 10; a >= 0; a--) {
        FrameLayout frameLayout = numberFrameLayouts.get(a);
        numbersFrameLayout.addView(frameLayout);
        layoutParams = (LayoutParams) frameLayout.getLayoutParams();
        layoutParams.width = AndroidUtilities.dp(100);
        layoutParams.height = AndroidUtilities.dp(100);
        layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
        frameLayout.setLayoutParams(layoutParams);
    }
}

From source file:android.support.transition.SidePropagation.java

private int distance(View sceneRoot, int viewX, int viewY, int epicenterX, int epicenterY, int left, int top,
        int right, int bottom) {
    final int side;
    if (mSide == Gravity.START) {
        final boolean isRtl = ViewCompat.getLayoutDirection(sceneRoot) == ViewCompat.LAYOUT_DIRECTION_RTL;
        side = isRtl ? Gravity.RIGHT : Gravity.LEFT;
    } else if (mSide == Gravity.END) {
        final boolean isRtl = ViewCompat.getLayoutDirection(sceneRoot) == ViewCompat.LAYOUT_DIRECTION_RTL;
        side = isRtl ? Gravity.LEFT : Gravity.RIGHT;
    } else {/*from  w  w  w . j  av  a 2 s  . c  o  m*/
        side = mSide;
    }
    int distance = 0;
    switch (side) {
    case Gravity.LEFT:
        distance = right - viewX + Math.abs(epicenterY - viewY);
        break;
    case Gravity.TOP:
        distance = bottom - viewY + Math.abs(epicenterX - viewX);
        break;
    case Gravity.RIGHT:
        distance = viewX - left + Math.abs(epicenterY - viewY);
        break;
    case Gravity.BOTTOM:
        distance = viewY - top + Math.abs(epicenterX - viewX);
        break;
    }
    return distance;
}

From source file:com.android.adcnx.adlib.plugin.AdConnectLibrary.java

private int getGravity(String gravity) {
    if (gravity.equalsIgnoreCase("bottom")) {
        return Gravity.BOTTOM;
    }//from   w w w .  j av a2s . com

    return Gravity.NO_GRAVITY;
}

From source file:com.itraing.views.ActionSheet.java

private View createView() {
    FrameLayout parent = new FrameLayout(getActivity());
    parent.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    mBg = new View(getActivity());
    mBg.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    mBg.setBackgroundColor(Color.argb(136, 0, 0, 0));
    mBg.setId(ActionSheet.BG_VIEW_ID);/* w  ww. j ava  2 s  .  c o  m*/
    mBg.setOnClickListener(this);

    mPanel = new LinearLayout(getActivity());
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.BOTTOM;
    mPanel.setLayoutParams(params);
    mPanel.setOrientation(LinearLayout.VERTICAL);

    parent.addView(mBg);
    parent.addView(mPanel);
    return parent;
}

From source file:com.apptentive.android.sdk.module.engagement.interaction.fragment.SurveyFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (interaction == null) {
        getActivity().finish();/*from ww w . j  av  a 2 s  .  c o  m*/
    }

    List<Question> questions = interaction.getQuestions();
    answers = new LinkedHashMap<String, Object>(questions.size());

    View v = inflater.inflate(R.layout.apptentive_survey, container, false);

    TextView description = (TextView) v.findViewById(R.id.description);
    description.setText(interaction.getDescription());

    final Button send = (Button) v.findViewById(R.id.send);

    String sendText = interaction.getSubmitText();
    if (!TextUtils.isEmpty(sendText)) {
        send.setText(sendText);
    }
    send.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Util.hideSoftKeyboard(getActivity(), view);
            boolean valid = validateAndUpdateState();
            if (valid) {
                if (interaction.isShowSuccessMessage() && !TextUtils.isEmpty(interaction.getSuccessMessage())) {
                    Toast toast = new Toast(getContext());
                    toast.setGravity(Gravity.FILL, 0, 0);
                    toast.setDuration(Toast.LENGTH_SHORT);
                    View toastView = inflater.inflate(R.layout.apptentive_survey_sent_toast,
                            (LinearLayout) getView().findViewById(R.id.survey_sent_toast_root));
                    toast.setView(toastView);
                    TextView actionTV = ((TextView) toastView.findViewById(R.id.survey_sent_action_text));
                    actionTV.setText(interaction.getSuccessMessage());
                    int actionColor = Util.getThemeColor(getContext(),
                            R.attr.apptentiveSurveySentToastActionColor);
                    if (actionColor != 0) {
                        actionTV.setTextColor(actionColor);
                        ImageView actionIcon = (ImageView) toastView.findViewById(R.id.survey_sent_action_icon);
                        actionIcon.setColorFilter(actionColor);
                    }
                    toast.show();
                }
                getActivity().finish();

                EngagementModule.engageInternal(getActivity(), interaction, EVENT_SUBMIT);

                ApptentiveInternal.getInstance().getApptentiveTaskManager()
                        .addPayload(new SurveyResponse(interaction, answers));
                ApptentiveLog.d("Survey Submitted.");
                callListener(true);
            } else {
                Toast toast = new Toast(getContext());
                toast.setGravity(Gravity.FILL_HORIZONTAL | Gravity.BOTTOM, 0, 0);
                toast.setDuration(Toast.LENGTH_SHORT);
                View toastView = inflater.inflate(R.layout.apptentive_survey_invalid_toast,
                        (LinearLayout) getView().findViewById(R.id.survey_invalid_toast_root));
                toast.setView(toastView);
                String validationText = interaction.getValidationError();
                if (!TextUtils.isEmpty(validationText)) {
                    ((TextView) toastView.findViewById(R.id.survey_invalid_toast_text)).setText(validationText);
                }
                toast.show();
            }
        }
    });

    questionsContainer = (LinearLayout) v.findViewById(R.id.questions);
    if (savedInstanceState == null) {
        questionsContainer.removeAllViews();

        // Then render all the questions
        for (int i = 0; i < questions.size(); i++) {
            Question question = questions.get(i);
            BaseSurveyQuestionView surveyQuestionView;
            if (question.getType() == Question.QUESTION_TYPE_SINGLELINE) {
                surveyQuestionView = TextSurveyQuestionView.newInstance((SinglelineQuestion) question);
            } else if (question.getType() == Question.QUESTION_TYPE_MULTICHOICE) {
                surveyQuestionView = MultichoiceSurveyQuestionView.newInstance((MultichoiceQuestion) question);

            } else if (question.getType() == Question.QUESTION_TYPE_MULTISELECT) {
                surveyQuestionView = MultiselectSurveyQuestionView.newInstance((MultiselectQuestion) question);
            } else if (question.getType() == Question.QUESTION_TYPE_RANGE) {
                surveyQuestionView = RangeSurveyQuestionView.newInstance((RangeQuestion) question);
            } else {
                surveyQuestionView = null;
            }
            if (surveyQuestionView != null) {
                surveyQuestionView.setOnSurveyQuestionAnsweredListener(this);
                getRetainedChildFragmentManager().beginTransaction()
                        .add(R.id.questions, surveyQuestionView, Integer.toString(i)).commit();
            }
        }
    } else {
        List<Fragment> fragments = getRetainedChildFragmentManager().getFragments();
        for (Fragment fragment : fragments) {
            BaseSurveyQuestionView questionFragment = (BaseSurveyQuestionView) fragment;
            questionFragment.setOnSurveyQuestionAnsweredListener(this);

        }
    }
    return v;
}

From source file:com.mci.firstidol.view.ActionSheet.java

@SuppressWarnings("deprecation")
private View createView() {
    FrameLayout parent = new FrameLayout(getActivity());
    parent.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    mBg = new View(getActivity());
    mBg.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    mBg.setBackgroundColor(Color.argb(136, 0, 0, 0));
    mBg.setId(ActionSheet.BG_VIEW_ID);//from w ww.  j  av a 2s. co  m
    mBg.setOnClickListener(this);

    mPanel = new LinearLayout(getActivity());
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.BOTTOM;
    mPanel.setLayoutParams(params);
    mPanel.setOrientation(LinearLayout.VERTICAL);

    TextView titleView = new TextView(getActivity());
    titleView.setText(TextUtils.isEmpty(getTitle()) ? "" : getTitle());
    titleView.setGravity(Gravity.CENTER);
    titleView.setTextColor(Color.GRAY);
    titleView.setBackgroundDrawable(mAttrs.actionSheetTitleBackground);
    mPanel.addView(titleView);

    parent.addView(mBg);
    parent.addView(mPanel);
    return parent;
}

From source file:com.qs.qswlw.view.Mypager.UltraViewPagerIndicator.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    if (viewPager == null || viewPager.getAdapter() == null)
        return;/*  ww w  .j av a  2s .co m*/

    final int count = ((UltraViewPagerAdapter) viewPager.getAdapter()).getRealCount();
    if (count == 0)
        return;

    int longSize;
    int shortSize;

    int longPaddingBefore;
    int longPaddingAfter;
    int shortPaddingBefore;
    int shortPaddingAfter;
    if (orientation == UltraViewPager.Orientation.HORIZONTAL) {
        longSize = viewPager.getWidth();
        shortSize = viewPager.getHeight();
        longPaddingBefore = (int) (getItemWidth() + getPaddingLeft() + marginLeft);
        longPaddingAfter = getPaddingRight() + marginRight;
        shortPaddingBefore = (int) (getItemWidth() + getPaddingTop() + marginTop);
        shortPaddingAfter = (int) paintStroke.getStrokeWidth() + getPaddingBottom() + marginBottom;
    } else {
        longSize = viewPager.getHeight();
        shortSize = viewPager.getWidth();
        longPaddingBefore = (int) (getItemWidth() + getPaddingTop() + marginTop);
        longPaddingAfter = (int) paintStroke.getStrokeWidth() + getPaddingBottom() + marginBottom;
        shortPaddingBefore = (int) (getItemWidth() + getPaddingLeft() + marginLeft);
        shortPaddingAfter = getPaddingRight() + marginRight;
    }

    final float itemWidth = getItemWidth();
    final int widthRatio = isDrawResIndicator() ? 1 : 2; //bitmap resource X1 : circle  X2
    if (indicatorPadding == 0) {
        indicatorPadding = (int) itemWidth;
    }

    float shortOffset = shortPaddingBefore;
    float longOffset = longPaddingBefore;

    final float indicatorLength = count * itemWidth * widthRatio + (count - 1) * indicatorPadding;

    final int horizontalGravityMask = gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
    final int verticalGravityMask = gravity & Gravity.VERTICAL_GRAVITY_MASK;
    switch (horizontalGravityMask) {
    case Gravity.CENTER_HORIZONTAL:
        longOffset = (longSize - longPaddingBefore - longPaddingAfter - indicatorLength) / 2.0f;
        break;
    case Gravity.RIGHT:
        if (orientation == UltraViewPager.Orientation.HORIZONTAL) {
            longOffset = longSize - longPaddingAfter - indicatorLength;
        }
        if (orientation == UltraViewPager.Orientation.VERTICAL) {
            shortOffset = shortSize - shortPaddingAfter - itemWidth;
        }
        break;
    case Gravity.LEFT:
    default:
        break;
    }

    switch (verticalGravityMask) {
    case Gravity.CENTER_VERTICAL:
        shortOffset = (shortSize - shortPaddingAfter - shortPaddingBefore - itemWidth) / 2;
        break;
    case Gravity.BOTTOM:
        if (orientation == UltraViewPager.Orientation.HORIZONTAL) {
            shortOffset = shortSize - shortPaddingAfter - getItemHeight();
        }
        if (orientation == UltraViewPager.Orientation.VERTICAL) {
            longOffset = longSize - longPaddingAfter - indicatorLength;
        }
        break;
    case Gravity.TOP:
    default:
        break;
    }

    if (horizontalGravityMask == Gravity.CENTER_HORIZONTAL && verticalGravityMask == Gravity.CENTER_VERTICAL) {
        shortOffset = (shortSize - shortPaddingAfter - shortPaddingBefore - itemWidth) / 2;
    }

    float dX;
    float dY;

    float pageFillRadius = radius;
    if (paintStroke.getStrokeWidth() > 0) {
        pageFillRadius -= paintStroke.getStrokeWidth() / 2.0f; //TODO may not/2
    }

    //Draw stroked circles
    for (int iLoop = 0; iLoop < count; iLoop++) {
        float drawLong = longOffset + (iLoop * (itemWidth * widthRatio + indicatorPadding));
        if (orientation == UltraViewPager.Orientation.HORIZONTAL) {
            dX = drawLong;
            dY = shortOffset;
        } else {
            dX = shortOffset;
            dY = drawLong;
        }

        if (isDrawResIndicator()) {
            if (iLoop == viewPager.getCurrentItem())
                continue;
            canvas.drawBitmap(normalBitmap, dX, dY, paintFill);
        } else {
            // Only paint fill if not completely transparent
            if (paintFill.getAlpha() > 0) {
                paintFill.setColor(normalColor);
                canvas.drawCircle(dX, dY, pageFillRadius, paintFill);
            }

            // Only paint stroke if a stroke width was non-zero
            if (pageFillRadius != radius) {
                canvas.drawCircle(dX, dY, radius, paintStroke);
            }
        }
    }

    //Draw the filled circle according to the current scroll
    float cx = (viewPager.getCurrentItem()) * (itemWidth * widthRatio + indicatorPadding);
    if (animateIndicator)
        cx += pageOffset * itemWidth;
    if (orientation == UltraViewPager.Orientation.HORIZONTAL) {
        dX = longOffset + cx;
        dY = shortOffset;
    } else {
        dX = shortOffset;
        dY = longOffset + cx;
    }

    if (isDrawResIndicator()) {
        canvas.drawBitmap(focusBitmap, dX, dY, paintStroke);
    } else {
        paintFill.setColor(focusColor);
        canvas.drawCircle(dX, dY, radius, paintFill);
    }
}