Example usage for android.view LayoutInflater from

List of usage examples for android.view LayoutInflater from

Introduction

In this page you can find the example usage for android.view LayoutInflater from.

Prototype

public static LayoutInflater from(Context context) 

Source Link

Document

Obtains the LayoutInflater from the given context.

Usage

From source file:li.barter.fragments.SelectPreferredLocationFragment.java

/**
 * Show the overlay for this screen/*from   w  w  w  .  j a va  2  s.  c  o m*/
 */
private void showOverlay() {

    if (mOverlayView == null) {
        mOverlayView = LayoutInflater.from(getActivity())
                .inflate(R.layout.layout_overlay_about_prefered_location, null);
    }

    final Activity activity = getActivity();

    if (activity instanceof SelectPreferredLocationActivity) {
        mOverlayView.setOnClickListener(this);
        mIsOverlayShown = true;
        ((SelectPreferredLocationActivity) activity).showOverlayView(mOverlayView);
    }
}

From source file:com.intel.xdk.base.Base.java

public void showSplashScreen() {
    cordova.getActivity().runOnUiThread(new Runnable() {
        public void run() {
            //treat displays larger than 6" as tablets
            DisplayMetrics dm = new DisplayMetrics();
            cordova.getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
            double x = Math.pow(dm.widthPixels / dm.xdpi, 2);
            double y = Math.pow(dm.heightPixels / dm.ydpi, 2);
            double screenInches = Math.sqrt(x + y);
            if (screenInches > 6) {
                isTablet = true;// ww w.  ja va2  s . c om
            }

            //used for calculating status bar height
            int deviceWidth = dm.widthPixels;
            int deviceHeight = dm.heightPixels;
            if (deviceWidth > deviceHeight) {
                deviceWidth = dm.heightPixels;
                deviceHeight = dm.widthPixels;
            }

            //get the splash screen image from asssets
            Bitmap bm = null;
            try {
                if (isTablet) {
                    bm = getBitmapFromAsset("www/intel.xdk.base/android/splash_screen_tablet.jpg");
                } else {
                    bm = getBitmapFromAsset("www/intel.xdk.base/android/splash_screen.jpg");
                }
            } catch (IOException ioe) {
            }

            //if the splash screen assets are missing, don't try to show the splash screen
            if (bm == null) {
                return;
            }

            if (Debug.isDebuggerConnected())
                Log.i("[intel.xdk]", "splash");

            ActivityInfo ai = null;
            int splashViewId = 0;
            try {
                ai = cordova.getActivity().getPackageManager().getActivityInfo(
                        cordova.getActivity().getComponentName(),
                        PackageManager.GET_ACTIVITIES | PackageManager.GET_META_DATA);

                if (isTablet) {
                    if (ai.screenOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
                        splashViewId = cordova.getActivity().getResources().getIdentifier("splash_tablet_ls",
                                "layout", cordova.getActivity().getPackageName());
                    } else {
                        splashViewId = cordova.getActivity().getResources().getIdentifier("splash_tablet",
                                "layout", cordova.getActivity().getPackageName());
                    }
                } else {
                    if (ai.screenOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
                        splashViewId = cordova.getActivity().getResources().getIdentifier("splash_ls", "layout",
                                cordova.getActivity().getPackageName());
                    } else {
                        splashViewId = cordova.getActivity().getResources().getIdentifier("splash", "layout",
                                cordova.getActivity().getPackageName());
                    }
                }
                LayoutInflater inflater = LayoutInflater.from(cordova.getActivity());
                splashView = inflater.inflate(splashViewId, null);

                //set the splash screen image
                //http://stackoverflow.com/questions/7776445/in-android-can-i-use-image-from-assets-in-layout-xml
                ImageView backgroundImage = (ImageView) splashView
                        .findViewById(cordova.getActivity().getResources().getIdentifier("background", "id",
                                cordova.getActivity().getPackageName()));
                backgroundImage.setImageBitmap(bm);
                ((ViewGroup) root.getParent()).addView(splashView);
                splashView.bringToFront();

                //hack to fix splash screen size when it is smaller than screen            
                ImageView splashImage = (ImageView) cordova.getActivity()
                        .findViewById(cordova.getActivity().getResources().getIdentifier("background", "id",
                                cordova.getActivity().getPackageName()));
                LayoutParams params = splashImage.getLayoutParams();
                Rect imgBounds = splashImage.getDrawable().getBounds();
                int splashHeight = params.height;
                int splashWidth = params.width;

                //make copies in case we have to switch for landscape - not sure if needed, this is a last minute hack
                int deviceWidthCopy, deviceHeightCopy;
                deviceWidthCopy = deviceWidth;
                deviceHeightCopy = deviceHeight;
                if (ai.screenOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
                    int temp = deviceWidthCopy;
                    deviceWidthCopy = deviceHeightCopy;
                    deviceHeightCopy = temp;
                }
                if (splashHeight < deviceHeightCopy || splashWidth < deviceWidthCopy) {
                    float scaleH = (float) deviceHeightCopy / splashHeight;
                    float scaleW = (float) deviceWidthCopy / splashWidth;
                    float scale = Math.max(scaleH, scaleW);
                    params.height *= scale;
                    params.width *= scale;
                    splashImage.setLayoutParams(params);
                }

                cordova.getActivity().setProgressBarIndeterminateVisibility(true);

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

}

From source file:be.virtualsushi.gaz.view.ActivityChooserView.java

/**
 * Create a new instance./*from   w  w  w. j ava  2s.  co  m*/
 * 
 * @param context
 *            The application environment.
 * @param attrs
 *            A collection of attributes.
 * @param defStyle
 *            The default style to apply to this view.
 */
public ActivityChooserView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray attributesArray = context.obtainStyledAttributes(attrs, R.styleable.ActivityChooserView,
            defStyle, 0);

    mInitialActivityCount = attributesArray.getInt(R.styleable.ActivityChooserView_initialActivityCount,
            ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_DEFAULT);

    Drawable expandActivityOverflowButtonDrawable = attributesArray
            .getDrawable(R.styleable.ActivityChooserView_expandActivityOverflowButtonDrawable);

    attributesArray.recycle();

    LayoutInflater inflater = LayoutInflater.from(getContext());
    inflater.inflate(R.layout.abc_activity_chooser_view, this, true);

    mCallbacks = new Callbacks();

    mActivityChooserContent = (LinearLayout) findViewById(R.id.activity_chooser_view_content);
    mActivityChooserContent.setBackgroundDrawable(null);
    findViewById(R.id.default_activity_button).setVisibility(GONE);

    mExpandActivityOverflowButton = (FrameLayout) findViewById(R.id.expand_activities_button);
    mExpandActivityOverflowButton.setOnClickListener(mCallbacks);
    mExpandActivityOverflowButtonImage = (ImageView) mExpandActivityOverflowButton.findViewById(R.id.image);
    mExpandActivityOverflowButtonImage.setImageDrawable(expandActivityOverflowButtonDrawable);

    mAdapter = new ActivityChooserViewAdapter();
    mAdapter.registerDataSetObserver(new DataSetObserver() {
        @Override
        public void onChanged() {
            super.onChanged();
            updateAppearance();
        }
    });

    Resources resources = context.getResources();
    mListPopupMaxWidth = Math.max(resources.getDisplayMetrics().widthPixels / 2,
            resources.getDimensionPixelSize(R.dimen.abc_config_prefDialogWidth));
}

From source file:com.example.zf_android.trade.ApplyDetailActivity.java

private void initViews() {
    mInflater = LayoutInflater.from(this);

    mTab = (MyTabWidget) findViewById(R.id.apply_detail_tab);

    tv_support_type_name = (TextView) findViewById(R.id.tv_support_type_name);
    mPosBrand = (TextView) findViewById(R.id.apply_detail_brand);
    mPosModel = (TextView) findViewById(R.id.apply_detail_model);
    mSerialNum = (TextView) findViewById(R.id.apply_detail_serial);
    mPayChannel = (TextView) findViewById(R.id.apply_detail_channel);

    mContainer = (LinearLayout) findViewById(R.id.apply_detail_container);
    mMerchantContainer = (LinearLayout) findViewById(R.id.apply_detail_merchant_container);
    mCustomerContainer = (LinearLayout) findViewById(R.id.apply_detail_customer_container);
    mMaterialContainer = (LinearLayout) findViewById(R.id.apply_detail_material_container);
    mApplySubmit = (Button) findViewById(R.id.apply_submit);

    mApplySubmit.setOnClickListener(new View.OnClickListener() {
        @Override//from  w ww  .  j a va2s.c o m
        public void onClick(View view) {
            doSubmit();
        }
    });
}

From source file:com.mci.firstidol.activity.MainActivity.java

@Override
protected void initView() {
    initMainHint();/*from ww  w . j a  va  2  s .  c o m*/

    tabHost = (TabHost) findViewById(android.R.id.tabhost);

    view_myStar = LayoutInflater.from(context).inflate(R.layout.my_gridview, null);
    star_gridView = (MyGridView) view_myStar.findViewById(R.id.myGridView);

    // fragment
    squareFragment = new SquareFragment();
    starFragment = new StarFragment();
    starFragment.setSatrSelected(this);
    shoppingFragment = new ShoppingFragment();
    personalFragment = new PersonalFragment();
    //isMasterRequest();
    initTab();
    getStar();
}

From source file:ar.uba.fi.splitapp.ChatRoomActivity.java

private void addResponse(int layoutId, String username, String userId, String message) {
    LayoutInflater inflater = LayoutInflater.from(this);
    View layout = inflater.inflate(layoutId, null);

    CircularImageView imageView = (CircularImageView) layout.findViewById(R.id.chat_user_img);
    FacebookManager.fillWithUserPic(userId, imageView, getApplicationContext());

    TextView nameTextView = (TextView) layout.findViewById(R.id.chat_user_name);
    nameTextView.setText(username + "");

    TextView msgTextView = (TextView) layout.findViewById(R.id.chat_user_msg);
    msgTextView.setText(message);//from ww w  .  j a  v  a2  s.  c  o m

    runOnUiThread(() -> mMessagesLayout.addView(layout));
    runOnUiThread(this::scrollToLast);
}

From source file:com.df.app.procedures.CarRecogniseLayout.java

private void init(final Context context) {
    rootView = LayoutInflater.from(context).inflate(R.layout.car_recognise_layout, this);

    deleteLastLicensePhoto();//  www. j  av  a2 s.  c om

    mCarSettings = CarSettings.getInstance();

    licenseRecognise = new LicenseRecognise(context, AppCommon.licensePhotoPath);

    licenseImageView = (ImageView) findViewById(R.id.licenseImage);
    licenseImageView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            licenseRecognise.takePhoto();
        }
    });

    // 
    recogniseButton = (Button) rootView.findViewById(R.id.recognise_button);
    recogniseButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            // ???
            if (!mCarSettings.getBrandString().equals("")) {
                reRecognise(R.string.reRecognise1);
            } else if (!getEditViewText(rootView, R.id.plateNumber_edit).equals("")) {
                reRecognise(R.string.reRecognise);
            } else {
                //fillInDummyData();
                if (licensePhotoExist())
                    recogniseLicense();
                else
                    Toast.makeText(context, "???", Toast.LENGTH_SHORT).show();
            }
        }
    });

    // vin
    Button vinConfirmButton = (Button) rootView.findViewById(R.id.vinConfirm_button);
    vinConfirmButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            // VIN??
            if (getEditViewText(rootView, R.id.vin_edit).equals("")) {
                Toast.makeText(rootView.getContext(), "VIN?", Toast.LENGTH_SHORT).show();
            } else {
                checkVinAndGetCarSettings();
            }
        }
    });

    // ?
    Button brandSelectButton = (Button) rootView.findViewById(R.id.brand_select_button);
    brandSelectButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            selectCarManually();
        }
    });

    vehicleTypeEdit = (EditText) rootView.findViewById(R.id.vehicleType_edit);
    vehicleTypeEdit.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            switch (motionEvent.getAction()) {
            case MotionEvent.ACTION_UP:
                choose(R.array.vehicleType_items, R.id.vehicleType_edit);
                break;
            }
            return false;
        }
    });

    useCharacterEdit = (EditText) rootView.findViewById(R.id.useCharacter_edit);
    useCharacterEdit.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            switch (motionEvent.getAction()) {
            case MotionEvent.ACTION_UP:
                choose(R.array.useCharacter_items, R.id.useCharacter_edit);
                break;
            }
            return false;
        }
    });

    // vin???
    InputFilter alphaNumericFilter = new InputFilter() {
        @Override
        public CharSequence filter(CharSequence arg0, int arg1, int arg2, Spanned arg3, int arg4, int arg5) {
            for (int k = arg1; k < arg2; k++) {
                if (!Character.isLetterOrDigit(arg0.charAt(k))) {
                    return "";
                }
            }
            return null;
        }
    };

    EditText vin_edit = (EditText) findViewById(R.id.vin_edit);
    vin_edit.setFilters(new InputFilter[] { alphaNumericFilter, new InputFilter.AllCaps(),
            new InputFilter.LengthFilter(17) });

    EditText plateNumberEdit = (EditText) findViewById(R.id.plateNumber_edit);
    plateNumberEdit
            .setFilters(new InputFilter[] { new InputFilter.AllCaps(), new InputFilter.LengthFilter(10) });

    EditText licenseModelEdit = (EditText) findViewById(R.id.licenseModel_edit);
    licenseModelEdit
            .setFilters(new InputFilter[] { new InputFilter.AllCaps(), new InputFilter.LengthFilter(22) });

    EditText engineSerialEdit = (EditText) findViewById(R.id.engineSerial_edit);
    engineSerialEdit
            .setFilters(new InputFilter[] { new InputFilter.AllCaps(), new InputFilter.LengthFilter(17) });

    vehicleModel = MainActivity.vehicleModel;
}

From source file:andrewnguy.com.freefoodfinder.SlidingTabLayout.java

private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final View.OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;//from   w  w  w  . j  a va 2  s  . c o m
        TextView tabTitleView = null;

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }

        if (mDistributeEvenly) {
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
            lp.width = 0;
            lp.weight = 1;
        }

        tabTitleView.setText(adapter.getPageTitle(i));

        tabTitleView.setTextColor(getResources().getColor(R.color.tab_text_color));
        tabView.setOnClickListener(tabClickListener);
        String desc = mContentDescriptions.get(i, null);
        if (desc != null) {
            tabView.setContentDescription(desc);
        }

        mTabStrip.addView(tabView);
        if (i == mViewPager.getCurrentItem()) {
            tabView.setSelected(true);
        }
    }
}

From source file:net.evecom.androidecssp.gps.EventItemizedOverlayActivity.java

/**
 * //from   w ww  .  ja  v  a  2 s . c  om
 *  
 * 
 * @author Mars zhang
 * @created 2015-12-8 2:48:19
 */
private void initAroundDialog() {
    View dialogView = LayoutInflater.from(EventItemizedOverlayActivity.this).inflate(R.layout.base_wheel_view,
            null);
    dialogNameEd = (EditText) dialogView.findViewById(R.id.base_wheel_view_name_ed);
    //
    WheelView wheelView = (WheelView) dialogView.findViewById(R.id.country);
    wheelView.setVisibleItems(1);
    wheelView.setViewAdapter(new CountryAdapter(EventItemizedOverlayActivity.this, aroundNum));
    wheelView.addScrollingListener(new OnWheelScrollListener() {
        public void onScrollingStarted(WheelView wheel) {
        }

        public void onScrollingFinished(WheelView wheel) {
            aroundChouseValue = aroundNum[tempindex];
        }
    });
    wheelView.addChangingListener(new OnWheelChangedListener() {
        public void onChanged(WheelView wheel, int oldValue, int newValue) {
            tempindex = newValue;
        }
    });
    wheelView.setCurrentItem(3);
    aroundChouseValue = aroundNum[3];
    tempindex = 3;
    //
    resourceType = resourceTypehashmap.keySet().toArray(new String[resourceTypehashmap.size()]);
    WheelView resourceWheelView = (WheelView) dialogView.findViewById(R.id.country_resource_type);
    resourceWheelView.setVisibleItems(1);
    resourceWheelView.setViewAdapter(new CountryAdapter(EventItemizedOverlayActivity.this, resourceType));
    resourceWheelView.addScrollingListener(new OnWheelScrollListener() {
        public void onScrollingStarted(WheelView wheel) {
        }

        public void onScrollingFinished(WheelView wheel) {
            resourceTypeChouseValue = resourceType[resourceTypetempindex];
        }
    });
    resourceWheelView.addChangingListener(new OnWheelChangedListener() {
        public void onChanged(WheelView wheel, int oldValue, int newValue) {
            resourceTypetempindex = newValue;
        }
    });
    if (resourceType.length > 1) {
        resourceWheelView.setCurrentItem(0);
        resourceTypeChouseValue = resourceType[0];
        resourceTypetempindex = 0;
    }
    delDia = new AlertDialog.Builder(EventItemizedOverlayActivity.this)
            .setIcon(R.drawable.qq_dialog_default_icon).setTitle("").setView(dialogView)
            .setPositiveButton("", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dia, int which) {
                    toast("" + aroundChouseValue + "", 1);
                    if (null != resourceRelativeLayout) {
                        resourceRelativeLayout.setVisibility(View.VISIBLE);
                    }
                    final Message message = new Message();
                    new Thread(new Runnable() {
                        @Override
                        public void run() {
                            if (null == eventGpsPoints || eventGpsPoints.getGisy() < 1) {
                                return;
                            }
                            HashMap<String, String> mEntityMap = new HashMap<String, String>();
                            int maround = Integer.parseInt(aroundChouseValue);
                            double longdiffer = GpsUtil.getLongDifferFromMeters(mMapView, maround,
                                    EventItemizedOverlayActivity.this,
                                    new GeoPoint((int) (eventGpsPoints.getGisy() * 1E6),
                                            (int) (eventGpsPoints.getGisx() * 1E6)));
                            double latdiffer = GpsUtil.getLatDifferFromMeters(mMapView, maround,
                                    EventItemizedOverlayActivity.this,
                                    new GeoPoint((int) (eventGpsPoints.getGisy() * 1E6),
                                            (int) (eventGpsPoints.getGisx() * 1E6)));
                            mEntityMap.put("longdiffer", longdiffer + "");
                            mEntityMap.put("latdiffer", latdiffer + "");
                            mEntityMap.put("centergisy", eventGpsPoints.getGisy() + "");
                            mEntityMap.put("centergisx", eventGpsPoints.getGisx() + "");
                            mEntityMap.put("pagesize", HttpUtil.getPageSize(instance));
                            mEntityMap.put("resourcename", ifnull(dialogNameEd.getText().toString(), ""));
                            mEntityMap.put("resourcetype",
                                    ifnull(resourceTypehashmap.get(resourceTypeChouseValue), ""));
                            try {
                                String mResult = connServerForResultPost(
                                        "jfs/ecssp/mobile/eventCtr/searchResourceAround", mEntityMap);
                                resourceModels = getObjsInfo(mResult);
                                message.what = MESSAGETYPE_01;
                            } catch (ClientProtocolException e) {
                                message.what = MESSAGETYPE_02;
                            } catch (IOException e) {
                                message.what = MESSAGETYPE_02;
                            } catch (JSONException e) {
                                message.what = MESSAGETYPE_02;
                            }
                            pubhandler.sendMessage(message);
                        }
                    }).start();
                    dia.dismiss();
                }
            }).setNegativeButton("", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dia, int which) {
                    dia.dismiss();
                }
            }).create();
}

From source file:com.fsa.en.dron.activity.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    RateThisApp.Config config = new RateThisApp.Config(5, 10);
    config.setTitle(R.string.my_own_title);
    config.setMessage(R.string.my_own_message);
    config.setYesButtonText(R.string.my_own_rate);
    config.setNoButtonText(R.string.my_own_thanks);
    config.setCancelButtonText(R.string.my_own_cancel);
    RateThisApp.init(config);/*from   w w w.j  a v a  2 s  .co  m*/
    RateThisApp.setCallback(new RateThisApp.Callback() {
        @Override
        public void onYesClicked() {
            final String appPackageName = getPackageName(); // getPackageName() from Context or Activity  object
            try {
                startActivity(
                        new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
            } catch (android.content.ActivityNotFoundException anfe) {
                startActivity(new Intent(Intent.ACTION_VIEW,
                        Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName)));
            }
        }

        @Override
        public void onNoClicked() {
            TastyToast.makeText(getApplicationContext(), "Vuelve pronto!", TastyToast.LENGTH_LONG,
                    TastyToast.INFO);
        }

        @Override
        public void onCancelClicked() {
            TastyToast.makeText(getApplicationContext(), "Prometo tomar mejores fotografias!",
                    TastyToast.LENGTH_LONG, TastyToast.ERROR);
        }
    });
    button = (Button) findViewById(R.id.button);
    button.setVisibility(View.INVISIBLE);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            checkConnection();
        }
    });
    BottomNavigationBar bottomNavigationBar = (BottomNavigationBar) findViewById(R.id.bottom_navigation_bar);
    bottomNavigationBar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_RIPPLE);
    bottomNavigationBar.setMode(BottomNavigationBar.MODE_FIXED);
    bottomNavigationBar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_STATIC);
    bottomNavigationBar.setBarBackgroundColor(R.color.material_light_blue_800);
    bottomNavigationBar.setActiveColor(R.color.material_grey_900);
    bottomNavigationBar.setInActiveColor(R.color.material_blue_grey_200);
    bottomNavigationBar.addItem(new BottomNavigationItem(R.drawable.compose, "Mensaje"))
            .addItem(new BottomNavigationItem(R.drawable.sociales, "Sociales"))
            .addItem(new BottomNavigationItem(R.drawable.share, "Cuntale a un amigo")).initialise();
    bottomNavigationBar.setTabSelectedListener(new BottomNavigationBar.OnTabSelectedListener() {
        @Override
        public void onTabSelected(int position) {
            switch (position) {
            case 0:
                Intent email = new Intent(Intent.ACTION_SEND);
                email.putExtra(Intent.EXTRA_EMAIL, new String[] { "marceloespinoza00@gmail.com" });
                email.putExtra(Intent.EXTRA_SUBJECT, "Formosa en dron");
                email.putExtra(Intent.EXTRA_TEXT, "Dej tu mensaje");
                email.setType("message/rfc822");
                startActivity(Intent.createChooser(email, "Elige un cliente :"));
                break;
            case 1:
                Intent intent = new Intent(getApplication(), FacebookActivity.class);
                startActivity(intent);
                break;
            case 2:

                Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
                sharingIntent.setType("text/plain");
                sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Formosa en dron");
                sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT,
                        "https://play.google.com/store/apps/details?id=com.fsa.en.dron");
                startActivity(Intent.createChooser(sharingIntent, "Compartir via"));
                break;

            }

        }

        @Override
        public void onTabUnselected(int position) {

        }

        @Override
        public void onTabReselected(int position) {
            switch (position) {
            case 0:

                break;
            case 1:
                Intent intent = new Intent(getApplication(), FacebookActivity.class);
                startActivity(intent);
                break;
            case 2:

                break;

            }
        }
    });
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    LayoutInflater inflator = LayoutInflater.from(this);
    View v = inflator.inflate(R.layout.toolbar_title, null);
    Typeface budget = Typeface.createFromAsset(getAssets(), "fonts/Budget.otf");
    Typeface typographica = Typeface.createFromAsset(getAssets(), "fonts/TypoGraphica.otf");
    TextView mToolbarCustomTitle = (TextView) v.findViewById(R.id.title);
    TextView mToolbarCustomSubTitle = (TextView) v.findViewById(R.id.subtitle);
    mToolbarCustomTitle.setText("Formosa");
    mToolbarCustomSubTitle.setText("en dron");
    mToolbarCustomTitle.setTypeface(typographica);
    mToolbarCustomSubTitle.setTypeface(budget);
    getSupportActionBar().setCustomView(v);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    getSupportActionBar().setDisplayShowCustomEnabled(true);
    toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            int id = item.getItemId();
            if (id == R.id.recargar) {
                checkConnection();
            }
            if (id == R.id.info) {
                showDialog();
            }
            return false;
        }
    });
    recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    recyclerView.addOnItemTouchListener(new GalleryAdapter.RecyclerTouchListener(getApplicationContext(),
            recyclerView, new GalleryAdapter.ClickListener() {
                @Override
                public void onClick(View view, int position) {
                    Bundle bundle = new Bundle();
                    bundle.putSerializable("images", images);
                    bundle.putInt("position", position);

                    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
                    SlideshowDialogFragment newFragment = SlideshowDialogFragment.newInstance();
                    newFragment.setArguments(bundle);
                    newFragment.show(ft, "slideshow");
                }

                @Override
                public void onLongClick(View view, int position) {

                }
            }));
    pDialog = new ProgressDialog(this);
    images = new ArrayList<>();
    mAdapter = new GalleryAdapter(getApplicationContext(), images);
    RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(getApplicationContext(), 2);
    recyclerView.setLayoutManager(mLayoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setAdapter(mAdapter);

}