Example usage for android.widget LinearLayout setPadding

List of usage examples for android.widget LinearLayout setPadding

Introduction

In this page you can find the example usage for android.widget LinearLayout setPadding.

Prototype

public void setPadding(int left, int top, int right, int bottom) 

Source Link

Document

Sets the padding.

Usage

From source file:com.citrus.sample.WalletPaymentFragment.java

private void showCashoutPrompt() {
    final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    String message = "Please enter account details.";
    String positiveButtonText = "Withdraw";

    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    final TextView labelAmount = new TextView(getActivity());
    final EditText editAmount = new EditText(getActivity());
    final TextView labelAccountNo = new TextView(getActivity());
    final EditText editAccountNo = new EditText(getActivity());
    editAccountNo.setSingleLine(true);/*from  ww  w . j a  va  2  s  .  c  o  m*/
    final TextView labelAccountHolderName = new TextView(getActivity());
    final EditText editAccountHolderName = new EditText(getActivity());
    editAccountHolderName.setSingleLine(true);
    final TextView labelIfscCode = new TextView(getActivity());
    final EditText editIfscCode = new EditText(getActivity());
    editIfscCode.setSingleLine(true);

    labelAmount.setText("Withdrawal Amount");
    labelAccountNo.setText("Account Number");
    labelAccountHolderName.setText("Account Holder Name");
    labelIfscCode.setText("IFSC Code");

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    labelAmount.setLayoutParams(layoutParams);
    labelAccountNo.setLayoutParams(layoutParams);
    labelAccountHolderName.setLayoutParams(layoutParams);
    labelIfscCode.setLayoutParams(layoutParams);
    editAmount.setLayoutParams(layoutParams);
    editAccountNo.setLayoutParams(layoutParams);
    editAccountHolderName.setLayoutParams(layoutParams);
    editIfscCode.setLayoutParams(layoutParams);

    linearLayout.addView(labelAmount);
    linearLayout.addView(editAmount);
    linearLayout.addView(labelAccountNo);
    linearLayout.addView(editAccountNo);
    linearLayout.addView(labelAccountHolderName);
    linearLayout.addView(editAccountHolderName);
    linearLayout.addView(labelIfscCode);
    linearLayout.addView(editIfscCode);

    int paddingPx = Utils.getSizeInPx(getActivity(), 32);
    linearLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx);

    editAmount.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);

    alert.setTitle("Withdraw Money To Your Account");
    alert.setMessage(message);

    alert.setView(linearLayout);
    alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            String amount = editAmount.getText().toString();
            String accontNo = editAccountNo.getText().toString();
            String accountHolderName = editAccountHolderName.getText().toString();
            String ifsc = editIfscCode.getText().toString();

            CashoutInfo cashoutInfo = new CashoutInfo(new Amount(amount), accontNo, accountHolderName, ifsc);
            mListener.onCashoutSelected(cashoutInfo);

            // Hide the keyboard.
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(editAmount.getWindowToken(), 0);
        }
    });

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
        }
    });

    editAmount.requestFocus();
    alert.show();
}

From source file:pro.dbro.bart.TheActivity.java

public void displayRouteResponse(routeResponse routeResponse) {
    // Log.d("displayRouteResponse","Is this real?: "+routeResponse.toString());
    // Previously, if the device's locale wasn't in Pacific Standard Time
    // Responses with all expired routes could present, causing a looping refresh cycle
    // This is now remedied by coercing response dates into PST
    boolean expiredResponse = false;
    if (routeResponse.routes.size() == 0) {
        Log.d("displayRouteResponse", "no routes to display");
        expiredResponse = true;/*from  www  . j av  a 2 s  . co m*/
    }

    if (timer != null)
        timer.cancel(); // cancel previous timer
    timerViews = new ArrayList(); // release old ETA text views
    maxTimer = 0;
    try {
        tableLayout.removeAllViews();
        //Log.v("DATE",new Date().toString());
        long now = new Date().getTime();

        if (!expiredResponse) {
            fareTv.setVisibility(0);
            fareTv.setText("$" + routeResponse.routes.get(0).fare);
            for (int x = 0; x < routeResponse.routes.size(); x++) {
                route thisRoute = routeResponse.routes.get(x);

                TableRow tr = (TableRow) View.inflate(c, R.layout.tablerow, null);
                tr.setPadding(0, 20, 0, 0);
                LinearLayout legLayout = (LinearLayout) View.inflate(c, R.layout.routelinearlayout, null);

                for (int y = 0; y < thisRoute.legs.size(); y++) {
                    TextView trainTv = (TextView) View.inflate(c, R.layout.tabletext, null);
                    trainTv.setPadding(0, 0, 0, 0);
                    trainTv.setTextSize(20);
                    trainTv.setGravity(3); // set left gravity
                    // If route has multiple legs, generate "Transfer At [station name]" and "To [train name] " rows for each leg after the first
                    if (y > 0) {
                        trainTv.setText("transfer at " + BART.REVERSE_STATION_MAP
                                .get(((leg) thisRoute.legs.get(y - 1)).disembarkStation.toLowerCase()));
                        trainTv.setPadding(0, 0, 0, 0);
                        legLayout.addView(trainTv);
                        trainTv.setTextSize(14);
                        trainTv = (TextView) View.inflate(c, R.layout.tabletext, null);
                        trainTv.setPadding(0, 0, 0, 0);
                        trainTv.setTextSize(20);
                        trainTv.setGravity(3); // set left gravity
                        trainTv.setText("to " + BART.REVERSE_STATION_MAP
                                .get(((leg) thisRoute.legs.get(y)).trainHeadStation.toLowerCase()));
                    } else {
                        // For first route leg, display "Take [train name]" row
                        trainTv.setText("take "
                                + BART.REVERSE_STATION_MAP.get(((leg) thisRoute.legs.get(y)).trainHeadStation));
                    }

                    legLayout.addView(trainTv);

                }

                if (thisRoute.legs.size() == 1) {
                    legLayout.setPadding(0, 10, 0, 0); // Address detination train and ETA not aligning 
                }

                tr.addView(legLayout);

                // Prepare ETA TextView
                TextView arrivalTimeTv = (TextView) View.inflate(c, R.layout.tabletext, null);
                arrivalTimeTv.setPadding(10, 0, 0, 0);

                //Log.v("DEPART_DATE",thisRoute.departureDate.toString());

                // Don't report a train that may JUST be leaving with a negative ETA
                long eta;
                if (thisRoute.departureDate.getTime() - now <= 0) {
                    eta = 0;
                } else {
                    eta = thisRoute.departureDate.getTime() - now;
                }

                if (eta > maxTimer) {
                    maxTimer = eta;
                }
                // Set timeTv Tag to departure date for interpretation by ViewCountDownTimer
                arrivalTimeTv.setTag(thisRoute.departureDate.getTime());

                // Print arrival as time, not eta if greater than BART.ETA_THRESHOLD_MS
                if (thisRoute.departureDate.getTime() - now > BART.ETA_IN_MINUTES_THRESHOLD_MS) {
                    SimpleDateFormat sdf = new SimpleDateFormat("h:mm a");
                    arrivalTimeTv.setText(sdf.format(thisRoute.departureDate));
                    arrivalTimeTv.setTextSize(20);
                }
                // Display ETA as minutes until arrival
                else {
                    arrivalTimeTv.setTextSize(36);
                    // Display eta less than 1m as "<1"
                    if (eta < 60 * 1000)
                        arrivalTimeTv.setText("<1"); // TODO - remove this? Does countdown tick on start
                    else
                        arrivalTimeTv.setText(String.valueOf(eta / (1000 * 60))); // TODO - remove this? Does countdown tick on start
                    // Add the timerView to the list of views to be passed to the ViewCountDownTimer
                    timerViews.add(arrivalTimeTv);
                }

                //new ViewCountDownTimer(arrivalTimeTv, eta, 60*1000).start();
                tr.addView(arrivalTimeTv);
                // Set the Row View (containing train names and times) Tag to the route it represents
                tr.setTag(thisRoute);
                tableLayout.addView(tr);
                tr.setOnLongClickListener(new OnLongClickListener() {

                    @Override
                    public boolean onLongClick(View arg0) {
                        Log.d("RouteViewTag", ((route) arg0.getTag()).toString());
                        usherRoute = (route) arg0.getTag();
                        TextView guidanceTv = (TextView) View.inflate(c, R.layout.tabletext, null);
                        guidanceTv.setText(Html.fromHtml(getString(R.string.service_prompt)));
                        guidanceTv.setTextSize(18);
                        guidanceTv.setPadding(0, 0, 0, 0);
                        new AlertDialog.Builder(c).setTitle("Route Guidance").setIcon(R.drawable.ic_launcher)
                                .setView(guidanceTv).setPositiveButton(R.string.service_start_button,
                                        new DialogInterface.OnClickListener() {

                                            public void onClick(DialogInterface dialog, int which) {
                                                Intent i = new Intent(c, UsherService.class);
                                                //i.putExtra("departure", ((leg)usherRoute.legs.get(0)).boardStation);
                                                //Log.v("SERVICE","Starting");
                                                if (usherServiceIsRunning()) {
                                                    stopService(i);
                                                }
                                                startService(i);
                                            }

                                        })
                                .setNeutralButton("Cancel", null).show();
                        return true; // consumed the long click
                    }

                });
                tr.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View arg0) {
                        int index = tableLayout.indexOfChild(arg0); // index of clicked view. Expanded view will always be +1
                        route thisRoute = (route) arg0.getTag();
                        if (!thisRoute.isExpanded) { // if route not expanded
                            thisRoute.isExpanded = true;
                            LinearLayout routeDetail = (LinearLayout) View.inflate(c, R.layout.routedetail,
                                    null);
                            TextView arrivalTv = (TextView) View.inflate(c, R.layout.tabletext, null);
                            SimpleDateFormat curFormater = new SimpleDateFormat("h:mm a");
                            //arrivalTv.setTextColor(0xFFC9C7C8);
                            arrivalTv.setText("arrives " + curFormater.format(thisRoute.arrivalDate));
                            arrivalTv.setTextSize(20);
                            routeDetail.addView(arrivalTv);
                            ImageView bikeIv = (ImageView) View.inflate(c, R.layout.bikeimage, null);

                            if (!thisRoute.bikes) {
                                bikeIv.setImageResource(R.drawable.no_bicycle);
                            }
                            routeDetail.addView(bikeIv);
                            tableLayout.addView(routeDetail, index + 1);
                        } else {
                            thisRoute.isExpanded = false;
                            tableLayout.removeViewAt(index + 1);
                        }

                    }
                });
            } // end route iteration
        } // end expiredResponse check
          // expiredResponse == True
          // If a late-night routeResponse includes the next morning's routes, they will be
          // presented with HH:MM ETAs, instead of minutes
          // Else if a late-night routeResponse includes routes from earlier in the evening
          // We will display "This route has stopped for tonight"
        else {
            String message = "This route has stopped for tonight";
            TextView specialScheduleTextView = (TextView) View.inflate(c, R.layout.tabletext, null);
            specialScheduleTextView.setText(message);
            specialScheduleTextView.setPadding(0, 0, 0, 0);
            tableLayout.addView(specialScheduleTextView);
        }
        if (routeResponse.specialSchedule != null) {
            ImageView specialSchedule = (ImageView) View.inflate(c, R.layout.specialschedulelayout, null);
            specialSchedule.setTag(routeResponse.specialSchedule);
            specialSchedule.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View arg0) {
                    TextView specialScheduleTv = (TextView) View.inflate(c, R.layout.tabletext, null);
                    specialScheduleTv.setPadding(0, 0, 0, 0);
                    specialScheduleTv.setText(Html.fromHtml(arg0.getTag().toString()));
                    specialScheduleTv.setTextSize(16);
                    specialScheduleTv.setMovementMethod(LinkMovementMethod.getInstance());
                    new AlertDialog.Builder(c).setTitle("Route Alerts").setIcon(R.drawable.warning)
                            .setView(specialScheduleTv).setPositiveButton("Okay!", null).show();

                }

            });
            tableLayout.addView(specialSchedule);
        }
        // Don't set timer if response is expired
        if (!expiredResponse) {
            timer = new ViewCountDownTimer(timerViews, "route", maxTimer, 30 * 1000);
            timer.start();
        }
    } catch (Throwable t) {
        Log.d("displayRouteResponseError", t.getStackTrace().toString());
    }
}

From source file:com.mishiranu.dashchan.ui.navigator.DrawerForm.java

private View makeView(boolean icon, boolean watcher, boolean closeable, float density) {
    int size = (int) (48f * density);
    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    linearLayout.setGravity(Gravity.CENTER_VERTICAL);
    ImageView iconView = null;//from www .  j a  va2  s. c om
    if (icon) {
        iconView = new ImageView(context);
        iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        linearLayout.addView(iconView, (int) (24f * density), size);
    }
    TextView textView = makeCommonTextView(false);
    linearLayout.addView(textView, new LinearLayout.LayoutParams(0, size, 1));
    WatcherView watcherView = null;
    if (watcher) {
        watcherView = new WatcherView(context);
        linearLayout.addView(watcherView, size, size);
    }
    ImageView closeView = null;
    if (!watcher && closeable) {
        closeView = new ImageView(context);
        closeView.setScaleType(ImageView.ScaleType.CENTER);
        closeView.setImageResource(ResourceUtils.getResourceId(context, R.attr.buttonCancel, 0));
        closeView.setBackgroundResource(ResourceUtils.getResourceId(context,
                android.R.attr.borderlessButtonStyle, android.R.attr.background, 0));
        linearLayout.addView(closeView, size, size);
        closeView.setOnClickListener(closeButtonListener);
    }
    ViewHolder holder = new ViewHolder();
    holder.icon = iconView;
    holder.text = textView;
    holder.extra = watcherView != null ? watcherView : closeView;
    linearLayout.setTag(holder);
    int layoutLeftDp = 0;
    int layoutRightDp = 0;
    int textLeftDp;
    int textRightDp;
    if (C.API_LOLLIPOP) {
        textLeftDp = 16;
        textRightDp = 16;
        if (icon) {
            layoutLeftDp = 16;
            textLeftDp = 32;
        }
        if (watcher || closeable) {
            layoutRightDp = 4;
            textRightDp = 8;
        }
    } else {
        textLeftDp = 8;
        textRightDp = 8;
        if (icon) {
            layoutLeftDp = 8;
            textLeftDp = 6;
            textView.setAllCaps(true);
        }
        if (watcher || closeable) {
            layoutRightDp = 0;
            textRightDp = 0;
        }
    }
    linearLayout.setPadding((int) (layoutLeftDp * density), 0, (int) (layoutRightDp * density), 0);
    textView.setPadding((int) (textLeftDp * density), 0, (int) (textRightDp * density), 0);
    return linearLayout;
}

From source file:cm.aptoide.pt.MainActivity.java

private void loadRecommended() {

    if (Login.isLoggedIn(mContext)) {
        ((TextView) featuredView.findViewById(R.id.recommended_text)).setVisibility(View.GONE);
    } else {//  w ww  . j a  v  a  2  s  . c  om
        ((TextView) featuredView.findViewById(R.id.recommended_text)).setVisibility(View.VISIBLE);
    }

    new Thread(new Runnable() {

        private ArrayList<HashMap<String, String>> valuesRecommended;

        public void run() {
            loadUIRecommendedApps();
            File f = null;
            try {
                SAXParserFactory spf = SAXParserFactory.newInstance();
                SAXParser sp = spf.newSAXParser();
                NetworkUtils utils = new NetworkUtils();
                BufferedInputStream bis = new BufferedInputStream(
                        utils.getInputStream("http://webservices.aptoide.com/webservices/listUserBasedApks/"
                                + Login.getToken(mContext) + "/10/xml", null, null, mContext),
                        8 * 1024);
                f = File.createTempFile("abc", "abc");
                OutputStream out = new FileOutputStream(f);
                byte buf[] = new byte[1024];
                int len;
                while ((len = bis.read(buf)) > 0)
                    out.write(buf, 0, len);
                out.close();
                bis.close();
                String hash = Md5Handler.md5Calc(f);
                ViewApk parent_apk = new ViewApk();
                parent_apk.setApkid("recommended");
                if (!hash.equals(db.getItemBasedApksHash(parent_apk.getApkid()))) {
                    // Database.database.beginTransaction();
                    db.deleteItemBasedApks(parent_apk);
                    sp.parse(f, new HandlerItemBased(parent_apk));
                    db.insertItemBasedApkHash(hash, parent_apk.getApkid());
                    // Database.database.setTransactionSuccessful();
                    // Database.database.endTransaction();
                    loadUIRecommendedApps();
                }

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

            if (f != null)
                f.delete();

        }

        private void loadUIRecommendedApps() {

            valuesRecommended = db.getItemBasedApksRecommended("recommended");

            runOnUiThread(new Runnable() {

                public void run() {

                    LinearLayout ll = (LinearLayout) featuredView.findViewById(R.id.recommended_container);
                    ll.removeAllViews();
                    LinearLayout llAlso = new LinearLayout(MainActivity.this);
                    llAlso.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                            LinearLayout.LayoutParams.WRAP_CONTENT));
                    llAlso.setOrientation(LinearLayout.HORIZONTAL);
                    if (valuesRecommended.isEmpty()) {
                        if (Login.isLoggedIn(mContext)) {
                            TextView tv = new TextView(mContext);
                            tv.setText(R.string.no_recommended_apps);
                            tv.setTextAppearance(mContext, android.R.attr.textAppearanceMedium);
                            tv.setPadding(10, 10, 10, 10);
                            ll.addView(tv);
                        }
                    } else {

                        for (int i = 0; i != valuesRecommended.size(); i++) {
                            LinearLayout txtSamItem = (LinearLayout) getLayoutInflater()
                                    .inflate(R.layout.row_grid_item, null);
                            ((TextView) txtSamItem.findViewById(R.id.name))
                                    .setText(valuesRecommended.get(i).get("name"));
                            ImageLoader.getInstance().displayImage(valuesRecommended.get(i).get("icon"),
                                    (ImageView) txtSamItem.findViewById(R.id.icon));
                            float stars = 0f;
                            try {
                                stars = Float.parseFloat(valuesRecommended.get(i).get("rating"));
                            } catch (Exception e) {
                                stars = 0f;
                            }
                            ((RatingBar) txtSamItem.findViewById(R.id.rating)).setIsIndicator(true);
                            ((RatingBar) txtSamItem.findViewById(R.id.rating)).setRating(stars);
                            txtSamItem.setPadding(10, 0, 0, 0);
                            // ((TextView)
                            // txtSamItem.findViewById(R.id.version))
                            // .setText(getString(R.string.version) +" "+
                            // valuesRecommended.get(i).get("vername"));
                            ((TextView) txtSamItem.findViewById(R.id.downloads))
                                    .setText("(" + valuesRecommended.get(i).get("downloads") + " "
                                            + getString(R.string.downloads) + ")");
                            txtSamItem.setTag(valuesRecommended.get(i).get("_id"));
                            txtSamItem.setLayoutParams(new LinearLayout.LayoutParams(
                                    LinearLayout.LayoutParams.MATCH_PARENT, 100, 1));
                            // txtSamItem.setOnClickListener(featuredListener);
                            txtSamItem.setOnClickListener(new OnClickListener() {

                                @Override
                                public void onClick(View arg0) {
                                    Intent i = new Intent(MainActivity.this, ApkInfo.class);
                                    long id = Long.parseLong((String) arg0.getTag());
                                    i.putExtra("_id", id);
                                    i.putExtra("top", true);
                                    i.putExtra("category", Category.ITEMBASED.ordinal());
                                    startActivity(i);
                                }
                            });

                            txtSamItem.measure(0, 0);

                            if (i % 2 == 0) {
                                ll.addView(llAlso);

                                llAlso = new LinearLayout(MainActivity.this);
                                llAlso.setLayoutParams(new LinearLayout.LayoutParams(
                                        LinearLayout.LayoutParams.MATCH_PARENT, 100));
                                llAlso.setOrientation(LinearLayout.HORIZONTAL);
                                llAlso.addView(txtSamItem);
                            } else {
                                llAlso.addView(txtSamItem);
                            }
                        }

                        ll.addView(llAlso);
                    }
                }
            });
        }
    }).start();

}

From source file:com.infigent.stocksense.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    startService(new Intent(this, BackGround.class));
    // setSlidingActionBarEnabled(true);
    Intent n = getIntent();/* ww w .j  a va  2 s .c  o  m*/
    if (getIntent() != null) {
        Bundle bundle = n.getExtras();
        if (bundle != null) {
            Log.e("ARG", "EXIST");
            if (bundle.containsKey("eq")) {
                Log.e("EQ", "EXIST");
                if (bundle.getBoolean("eq")) {
                    Log.e("eq", "true");
                    Bundle data = new Bundle();
                    Fragment4 eq = new Fragment4();
                    mContent = eq;
                    data.putString("q", bundle.getString("q"));
                    data.putString("type", bundle.getString("type"));
                    data.putString("name", bundle.getString("name"));
                    data.putString("f", gId());
                    eq.setArguments(data);
                    switchContent(eq);
                }
            }
        }
    }

    if (savedInstanceState != null)
        mContent = getSupportFragmentManager().getFragment(savedInstanceState, "mContent");
    if (mContent == null)
        mContent = new Fragment1();

    ScrollView scrollView = new ScrollView(this);
    LinearLayout l = new LinearLayout(this);
    TextView one = new TextView(this);
    one.setText(getResources().getString(R.string.intro));
    one.setPadding(0, 0, 0, 20);
    TextView two = new TextView(this);
    two.setText("Limited License");
    two.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium);
    TextView three = new TextView(this);
    three.setText(getResources().getString(R.string.l1));
    TextView four = new TextView(this);
    four.setText(getResources().getString(R.string.l2));
    four.setPadding(0, 0, 0, 20);
    TextView five = new TextView(this);
    five.setText("Disclaimer");
    five.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium);
    TextView six = new TextView(this);
    six.setText(getResources().getString(R.string.disclaimer1));
    TextView seven = new TextView(this);
    seven.setText(getResources().getString(R.string.disclaimer2));
    TextView eight = new TextView(this);
    eight.setText(getResources().getString(R.string.disclaimer3));
    eight.setPadding(0, 0, 0, 20);
    TextView nine = new TextView(this);
    nine.setText("Liability For Our Services");
    nine.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium);
    TextView ten = new TextView(this);
    ten.setText(getResources().getString(R.string.liability1));
    TextView eleven = new TextView(this);
    eleven.setText(getResources().getString(R.string.liability2));
    eleven.setPadding(0, 0, 0, 20);
    TextView twelve = new TextView(this);
    twelve.setText("Maintenance And Support");
    twelve.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium);
    TextView thirteen = new TextView(this);
    thirteen.setText(getResources().getString(R.string.ms));
    thirteen.setPadding(0, 0, 0, 20);
    TextView fourteen = new TextView(this);
    fourteen.setText("Links To Third Party Website");
    fourteen.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_DeviceDefault_Medium);
    TextView fifteen = new TextView(this);
    fifteen.setText(getResources().getString(R.string.p3));
    l.addView(one);
    l.addView(two);
    l.addView(three);
    l.addView(four);
    l.addView(five);
    l.addView(six);
    l.addView(seven);
    l.addView(eight);
    l.addView(nine);
    l.addView(ten);
    l.addView(eleven);
    l.addView(twelve);
    l.addView(thirteen);
    l.addView(fourteen);
    l.addView(fifteen);
    one.setTextColor(getResources().getColor(R.color.White));
    two.setTextColor(getResources().getColor(R.color.White));
    three.setTextColor(getResources().getColor(R.color.White));
    four.setTextColor(getResources().getColor(R.color.White));
    five.setTextColor(getResources().getColor(R.color.White));
    six.setTextColor(getResources().getColor(R.color.White));
    seven.setTextColor(getResources().getColor(R.color.White));
    eight.setTextColor(getResources().getColor(R.color.White));
    nine.setTextColor(getResources().getColor(R.color.White));
    ten.setTextColor(getResources().getColor(R.color.White));
    eleven.setTextColor(getResources().getColor(R.color.White));
    twelve.setTextColor(getResources().getColor(R.color.White));
    thirteen.setTextColor(getResources().getColor(R.color.White));
    fourteen.setTextColor(getResources().getColor(R.color.White));
    fifteen.setTextColor(getResources().getColor(R.color.White));
    l.setOrientation(LinearLayout.VERTICAL);
    l.setBackgroundColor(getResources().getColor(R.color.bg));
    l.setPadding(10, 10, 10, 10);
    scrollView.addView(l);
    boolean firstboot = getSharedPreferences("BOOT_PREF", MODE_PRIVATE).getBoolean("firstboot", true);
    if (firstboot) {

        LayoutInflater inflater = getLayoutInflater();
        View vvv = inflater.inflate(R.layout.alerttitle, null);
        AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle("Terms of Service")
                .setView(scrollView).setCustomTitle(vvv)
                .setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.dismiss();

                        getSharedPreferences("BOOT_PREF", MODE_PRIVATE).edit().putBoolean("firstboot", false)
                                .commit();
                    }
                }).setNegativeButton(android.R.string.cancel, new Dialog.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        // Close the activity as they have declined the EULA
                        MainActivity.this.finish();
                    }

                }).setCancelable(false);
        builder.create().show();
    }
    ime = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    ActionBar actionBar = getSupportActionBar();
    getSupportActionBar().setCustomView(R.layout.search);
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    actionBar.setDisplayUseLogoEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);
    sb = (ImageButton) actionBar.getCustomView().findViewById(R.id.sb);
    title = (TextView) actionBar.getCustomView().findViewById(R.id.title);
    sb.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            // only will trigger it if no physical keyboard is open
            search.setVisibility(View.VISIBLE);
            search.requestFocus();
            ime.showSoftInput(search, InputMethodManager.SHOW_IMPLICIT);
            search.setSelection(search.getText().length());
            sb.setVisibility(View.GONE);
            title.setVisibility(View.GONE);

        }
    });

    search = (AutoCompleteTextView) actionBar.getCustomView().findViewById(R.id.et);
    search.setThreshold(2);
    search.setAdapter(new SuggestionsAdapter(this, search.getText().toString()));
    search.setSelectAllOnFocus(true);
    search.clearFocus();

    search.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View arg1, int pos, long id) {
            String term = parent.getItemAtPosition(pos).toString();
            String[] lines = term.split("\\r?\\n");
            String name = lines[0];
            String code = lines[1].substring(lines[1].indexOf(":") + 1, lines[1].length()).trim();
            String type = lines[1].substring(0, lines[1].indexOf(":"));
            Log.d("DATA", name + " " + type + ":" + code);
            search.setText("");
            if (isNetworkAvailable()) {
                if (term.replace(" ", "") != null) {
                    Bundle data = new Bundle();
                    data.putString("q", code);
                    data.putString("type", type);
                    data.putString("name", name);
                    data.putString("f", gId());
                    Fragment4 eq = new Fragment4();
                    eq.setArguments(data);
                    Log.d("C", gId() + " frag");
                    mContent = eq;
                    getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, eq).commit();
                    getSlidingMenu().showContent();
                    search.setVisibility(View.GONE);
                    sb.setVisibility(View.VISIBLE);
                    title.setVisibility(View.VISIBLE);
                    ime.hideSoftInputFromWindow(search.getApplicationWindowToken(), 0);
                } else {
                    Toast.makeText(getApplicationContext(), "Enter a search term!", Toast.LENGTH_LONG).show();
                }
            } else
                Toast.makeText(getApplicationContext(), "Internet not available", Toast.LENGTH_LONG).show();
        }
    });

    search.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

            return false;
        }
    });

    // set the Above View
    setContentView(R.layout.content_frame);
    getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit();
    AdView mAdView;
    mAdView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);
    // set the Behind View
    setBehindContentView(R.layout.menu_frame);
    getSupportFragmentManager().beginTransaction().replace(R.id.menu_frame, new SampleListFragment()).commit();
}

From source file:com.citrus.sample.WalletPaymentFragment.java

void showTokenizedPrompt() {
    final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    final String message = "Auto Load Money with Saved Card";
    String positiveButtonText = "Auto Load";

    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    final TextView labelamt = new TextView(getActivity());
    final EditText editAmount = new EditText(getActivity());
    final TextView labelAmount = new TextView(getActivity());
    final EditText editLoadAmount = new EditText(getActivity());
    final TextView labelMobileNo = new TextView(getActivity());
    final EditText editThresholdAmount = new EditText(getActivity());
    final Button btnSelectSavedCards = new Button(getActivity());
    btnSelectSavedCards.setText("Select Saved Card");

    editLoadAmount.setSingleLine(true);//w w  w .j  ava 2 s.com
    editThresholdAmount.setSingleLine(true);

    editAmount.setSingleLine(true);
    labelamt.setText("Load Amount");
    labelAmount.setText("Auto Load Amount");
    labelMobileNo.setText("Threshold Amount");

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    labelamt.setLayoutParams(layoutParams);
    editAmount.setLayoutParams(layoutParams);
    labelAmount.setLayoutParams(layoutParams);
    labelMobileNo.setLayoutParams(layoutParams);
    editLoadAmount.setLayoutParams(layoutParams);
    editThresholdAmount.setLayoutParams(layoutParams);
    btnSelectSavedCards.setLayoutParams(layoutParams);

    btnSelectSavedCards.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mCitrusClient.getWallet(new Callback<List<PaymentOption>>() {
                @Override
                public void success(List<PaymentOption> paymentOptions) {
                    walletList.clear();
                    for (PaymentOption paymentOption : paymentOptions) {
                        if (paymentOption instanceof CreditCardOption) {
                            if (Arrays.asList(AUTO_LOAD_CARD_SCHEMS)
                                    .contains(((CardOption) paymentOption).getCardScheme().toString()))
                                walletList.add(paymentOption); //only available for Master and Visa Credit Card....
                        }
                    }
                    savedOptionsAdapter = new SavedOptionsAdapter(getActivity(), walletList);
                    showSavedAccountsDialog();
                }

                @Override
                public void error(CitrusError error) {
                    Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_SHORT).show();
                }
            });
        }
    });

    linearLayout.addView(labelamt);
    linearLayout.addView(editAmount);
    linearLayout.addView(labelAmount);
    linearLayout.addView(editLoadAmount);
    linearLayout.addView(labelMobileNo);
    linearLayout.addView(editThresholdAmount);
    linearLayout.addView(btnSelectSavedCards);

    int paddingPx = Utils.getSizeInPx(getActivity(), 32);
    linearLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx);

    editLoadAmount.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
    editThresholdAmount.setInputType(InputType.TYPE_CLASS_NUMBER);
    alert.setTitle("Auto Load Money with Saved Card");
    alert.setMessage(message);

    alert.setView(linearLayout);
    alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            final String amount = editAmount.getText().toString();
            final String loadAmount = editLoadAmount.getText().toString();
            final String thresHoldAmount = editThresholdAmount.getText().toString();
            // Hide the keyboard.
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(editAmount.getWindowToken(), 0);

            if (TextUtils.isEmpty(amount)) {
                Toast.makeText(getActivity(), "Amount cant be blank", Toast.LENGTH_SHORT).show();
                return;
            }

            if (TextUtils.isEmpty(loadAmount)) {
                Toast.makeText(getActivity(), "Load Amount cant be blank", Toast.LENGTH_SHORT).show();
                return;
            }

            if (TextUtils.isEmpty(thresHoldAmount)) {
                Toast.makeText(getActivity(), "thresHoldAmount cant be blank", Toast.LENGTH_SHORT).show();
                return;
            }

            if (Double.valueOf(thresHoldAmount) < new Double("500")) {
                Toast.makeText(getActivity(), "thresHoldAmount  should not be less than 500",
                        Toast.LENGTH_SHORT).show();
                return;
            }

            if (Double.valueOf(loadAmount) < new Double(thresHoldAmount)) {
                Toast.makeText(getActivity(), "Load Amount should not be less than thresHoldAmount",
                        Toast.LENGTH_SHORT).show();
                return;
            }

            if (otherPaymentOption == null) {
                Toast.makeText(getActivity(), "Saved Card Option is null.", Toast.LENGTH_SHORT).show();
            }

            try {
                PaymentType paymentType = new PaymentType.LoadMoney(new Amount(amount), otherPaymentOption);
                mCitrusClient.autoLoadMoney((PaymentType.LoadMoney) paymentType, new Amount(thresHoldAmount),
                        new Amount(loadAmount), new Callback<SubscriptionResponse>() {
                            @Override
                            public void success(SubscriptionResponse subscriptionResponse) {
                                Logger.d("AUTO LOAD RESPONSE ***"
                                        + subscriptionResponse.getSubscriptionResponseMessage());
                                Toast.makeText(getActivity(),
                                        subscriptionResponse.getSubscriptionResponseMessage(),
                                        Toast.LENGTH_SHORT).show();
                            }

                            @Override
                            public void error(CitrusError error) {
                                Logger.d("AUTO LOAD ERROR ***" + error.getMessage());
                                Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_SHORT).show();
                            }
                        });
            } catch (CitrusException e) {
                e.printStackTrace();
            }
        }
    });

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
        }
    });

    editLoadAmount.requestFocus();
    alert.show();
}

From source file:cm.aptoide.pt.MainActivity.java

private void loadUItopapps() {
    ((ToggleButton) featuredView.findViewById(R.id.toggleButton1)).setOnCheckedChangeListener(null);
    Cursor c = db.getFeaturedTopApps();

    values = new ArrayList<HashMap<String, String>>();
    for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
        HashMap<String, String> item = new HashMap<String, String>();
        item.put("name", c.getString(1));
        item.put("icon", db.getIconsPath(0, Category.TOPFEATURED) + c.getString(4));
        item.put("rating", c.getString(5));
        item.put("id", c.getString(0));
        item.put("apkid", c.getString(7));
        item.put("vercode", c.getString(8));
        item.put("vername", c.getString(2));
        item.put("downloads", c.getString(6));
        if (values.size() == 26) {
            break;
        }/*from  w ww .j a v  a2  s  .  c o  m*/
        values.add(item);
    }
    c.close();

    runOnUiThread(new Runnable() {

        public void run() {

            LinearLayout ll = (LinearLayout) featuredView.findViewById(R.id.container);
            ll.removeAllViews();
            LinearLayout llAlso = new LinearLayout(MainActivity.this);
            llAlso.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT));
            llAlso.setOrientation(LinearLayout.HORIZONTAL);
            for (int i = 0; i != values.size(); i++) {
                LinearLayout txtSamItem = (LinearLayout) getLayoutInflater().inflate(R.layout.row_grid_item,
                        null);
                ((TextView) txtSamItem.findViewById(R.id.name)).setText(values.get(i).get("name"));
                // ((TextView) txtSamItem.findViewById(R.id.version))
                // .setText(getString(R.string.version) +" "+
                // values.get(i).get("vername"));
                ((TextView) txtSamItem.findViewById(R.id.downloads)).setText(
                        "(" + values.get(i).get("downloads") + " " + getString(R.string.downloads) + ")");
                String hashCode = (values.get(i).get("apkid") + "|" + values.get(i).get("vercode")) + "";
                cm.aptoide.com.nostra13.universalimageloader.core.ImageLoader.getInstance().displayImage(
                        values.get(i).get("icon"), (ImageView) txtSamItem.findViewById(R.id.icon), hashCode);

                // imageLoader.DisplayImage(-1, values.get(i).get("icon"),
                // (ImageView) txtSamItem.findViewById(R.id.icon),
                // mContext);
                float stars = 0f;
                try {
                    stars = Float.parseFloat(values.get(i).get("rating"));
                } catch (Exception e) {
                    stars = 0f;
                }
                ((RatingBar) txtSamItem.findViewById(R.id.rating)).setRating(stars);
                ((RatingBar) txtSamItem.findViewById(R.id.rating)).setIsIndicator(true);
                txtSamItem.setPadding(10, 0, 0, 0);
                txtSamItem.setTag(values.get(i).get("id"));
                txtSamItem.setLayoutParams(
                        new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 100, 1));
                // txtSamItem.setOnClickListener(featuredListener);
                txtSamItem.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View arg0) {
                        Intent i = new Intent(MainActivity.this, ApkInfo.class);
                        long id = Long.parseLong((String) arg0.getTag());
                        i.putExtra("_id", id);
                        i.putExtra("top", true);
                        i.putExtra("category", Category.TOPFEATURED.ordinal());
                        startActivity(i);
                    }
                });

                txtSamItem.measure(0, 0);

                if (i % 2 == 0) {
                    ll.addView(llAlso);

                    llAlso = new LinearLayout(MainActivity.this);
                    llAlso.setLayoutParams(
                            new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 100));
                    llAlso.setOrientation(LinearLayout.HORIZONTAL);
                    llAlso.addView(txtSamItem);
                } else {
                    llAlso.addView(txtSamItem);
                }
            }

            ll.addView(llAlso);
            SharedPreferences sPref = PreferenceManager.getDefaultSharedPreferences(mContext);
            // System.out.println(sPref.getString("app_rating",
            // "All").equals(
            // "Mature"));
            ((ToggleButton) featuredView.findViewById(R.id.toggleButton1))
                    .setChecked(!sPref.getBoolean("matureChkBox", false));
            ((ToggleButton) featuredView.findViewById(R.id.toggleButton1))
                    .setOnCheckedChangeListener(adultCheckedListener);
        }
    });
}

From source file:com.android.launcher3.Launcher.java

@Override
public boolean onLongClick(View v) {
    if (!isDraggingEnabled())
        return false;
    if (isWorkspaceLocked())
        return false;
    if (mState != State.WORKSPACE)
        return false;

    if (creation != null)
        creation.clearAllLayout();/*from  w ww  .j a  v a 2  s.  c o  m*/

    if ((FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP && v instanceof PageIndicator)
            || (v == mAllAppsButton && mAllAppsButton != null)) {
        onLongClickAllAppsButton(v);
        return true;
    }

    if (v instanceof Workspace) {
        if (!mWorkspace.isInOverviewMode()) {
            if (!mWorkspace.isTouchActive()) {
                showOverviewMode(true);
                mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
                        HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }

    CellLayout.CellInfo longClickCellInfo = null;
    View itemUnderLongClick = null;
    if (v.getTag() instanceof ItemInfo) {
        ItemInfo info = (ItemInfo) v.getTag();
        longClickCellInfo = new CellLayout.CellInfo(v, info);
        itemUnderLongClick = longClickCellInfo.cell;
        mPendingRequestArgs = null;
    }

    // The hotseat touch handling does not go through Workspace, and we always allow long press
    // on hotseat items.
    if (!mDragController.isDragging()) {
        if (itemUnderLongClick == null) {
            // User long pressed on empty space
            mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
                    HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
            if (mWorkspace.isInOverviewMode()) {
                mWorkspace.startReordering(v);
            } else {
                showOverviewMode(true);
            }
        } else {
            final boolean isAllAppsButton = !FeatureFlags.NO_ALL_APPS_ICON && isHotseatLayout(v)
                    && mDeviceProfile.inv.isAllAppsButtonRank(
                            mHotseat.getOrderInHotseat(longClickCellInfo.cellX, longClickCellInfo.cellY));
            if (!(itemUnderLongClick instanceof Folder || isAllAppsButton)) {
                // User long pressed on an item
                DragOptions dragOptions = new DragOptions();
                if (itemUnderLongClick instanceof BubbleTextView) {
                    BubbleTextView icon = (BubbleTextView) itemUnderLongClick;
                    if (icon.hasDeepShortcuts()) {
                        DeepShortcutsContainer dsc = DeepShortcutsContainer.showForIcon(icon);
                        if (dsc != null) {
                            dragOptions.deferDragCondition = dsc.createDeferDragCondition(null);
                        }
                    }
                }

                int positionInGrid = mHotseat.getOrderInHotseat(longClickCellInfo.cellX,
                        longClickCellInfo.cellY);

                List<Shortcuts> shortcutses = new ArrayList<Shortcuts>();

                if (creation != null)
                    creation.clearAllLayout();

                mWorkspace.startDrag(longClickCellInfo, dragOptions);

                //Get selected app info
                final Object tag = v.getTag();
                final ShortcutInfo shortcut;
                try {
                    shortcut = (ShortcutInfo) tag;
                    Drawable icon;
                    if (Utilities.loadBitmapPref(Launcher.getLauncherActivity(),
                            shortcut.getTargetComponent().getPackageName()) != null) {
                        icon = new BitmapDrawable(activity.getResources(), Utilities.loadBitmapPref(activity,
                                shortcut.getTargetComponent().getPackageName()));
                    } else {
                        icon = new BitmapDrawable(activity.getResources(),
                                shortcut.getIcon(new IconCache(Launcher.this, getDeviceProfile().inv)));
                    }

                    shortcutses = ShortcutsManager.getShortcutsBasedOnTag(Launcher.this.getApplicationContext(),
                            Launcher.this, shortcut, icon);
                    ShortcutsBuilder builder = new ShortcutsBuilder.Builder(this, masterLayout)
                            .launcher3Shortcuts(gridSize, positionInGrid, (int) v.getY(), v.getBottom(),
                                    Hotseat.isHotseatTouched,
                                    Utilities.getDockSizeDefaultValue(getApplicationContext()))
                            .setOptionLayoutStyle(StyleOption.NONE).setPackageImage(icon)
                            .setShortcutsList(shortcutses).build();

                    creation = new ShortcutsCreation(builder);

                    creation.init();

                    Hotseat.isHotseatTouched = false;

                } catch (ClassCastException e) {
                    Log.e(TAG, "Clicked on Folder/Widget!");
                    positionInGrid = mHotseat.getOrderInHotseat(longClickCellInfo.cellX,
                            longClickCellInfo.cellY);
                    try {
                        //Get selected folder info
                        final View f = v;
                        final Object tagF = v.getTag();
                        final FolderInfo folder;
                        folder = (FolderInfo) tagF;

                        shortcutses = new ArrayList<Shortcuts>();
                        shortcutses.add(new Shortcuts(R.drawable.ic_folder_open_black_24dp,
                                getString(R.string.folder_open), new OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        if (f instanceof FolderIcon) {
                                            onClickFolderIcon(f);
                                            creation.clearAllLayout();
                                        }
                                    }
                                }));
                        shortcutses.add(new Shortcuts(R.drawable.ic_title_black_24dp,
                                getString(R.string.folder_rename), new OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        if (f instanceof FolderIcon) {
                                            AlertDialog.Builder alert = new AlertDialog.Builder(
                                                    new ContextThemeWrapper(Launcher.this,
                                                            R.style.AlertDialogCustom));
                                            LinearLayout layout = new LinearLayout(getApplicationContext());
                                            layout.setOrientation(LinearLayout.VERTICAL);
                                            layout.setPadding(100, 50, 100, 100);

                                            final EditText titleBox = new EditText(Launcher.this);

                                            titleBox.getBackground().mutate()
                                                    .setColorFilter(
                                                            ContextCompat.getColor(getApplicationContext(),
                                                                    R.color.colorPrimary),
                                                            PorterDuff.Mode.SRC_ATOP);
                                            alert.setMessage(getString(R.string.folder_title));
                                            alert.setTitle(getString(R.string.folder_enter_title));

                                            layout.addView(titleBox);
                                            alert.setView(layout);

                                            alert.setPositiveButton(getString(R.string.ok),
                                                    new DialogInterface.OnClickListener() {
                                                        public void onClick(DialogInterface dialog,
                                                                int whichButton) {
                                                            folder.setTitle(titleBox.getText().toString());
                                                            LauncherModel.updateItemInDatabase(
                                                                    Launcher.getLauncherActivity(), folder);
                                                        }
                                                    });

                                            alert.setNegativeButton(getString(R.string.cancel),
                                                    new DialogInterface.OnClickListener() {
                                                        public void onClick(DialogInterface dialog,
                                                                int whichButton) {
                                                            creation.clearAllLayout();
                                                        }
                                                    });
                                            alert.show();
                                            creation.clearAllLayout();
                                        }
                                    }
                                }));

                        ShortcutsBuilder builder = new ShortcutsBuilder.Builder(this, masterLayout)
                                .launcher3Shortcuts(gridSize, positionInGrid, (int) v.getY(), v.getBottom(),
                                        Hotseat.isHotseatTouched,
                                        Utilities.getDockSizeDefaultValue(getApplicationContext()))
                                .setOptionLayoutStyle(0)
                                .setPackageImage(
                                        ContextCompat.getDrawable(Launcher.this, R.mipmap.ic_launcher_home))
                                .setShortcutsList(shortcutses).build();

                        creation = new ShortcutsCreation(builder);

                        creation.init();
                    } catch (ClassCastException ee) {
                    }
                }
            }
        }
    }
    return true;
}