Example usage for android.widget FrameLayout setBackgroundDrawable

List of usage examples for android.widget FrameLayout setBackgroundDrawable

Introduction

In this page you can find the example usage for android.widget FrameLayout setBackgroundDrawable.

Prototype

@Deprecated
public void setBackgroundDrawable(Drawable background) 

Source Link

Usage

From source file:com.andrew.apollo.ui.activities.SearchActivity.java

/**
 * {@inheritDoc}//from  w  w  w.j  a  va 2s .c  o m
 */
@SuppressWarnings("deprecation")
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Title bar shows up in gingerbread, I'm too tired to figure out why.
    if (!ApolloUtils.hasHoneycomb()) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
    }
    // Initialze the theme resources
    mResources = new ThemeUtils(this);
    // Set the overflow style
    mResources.setOverflowStyle(this);

    // Fade it in
    overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);

    // Control the media volume
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    // Bind Apollo's service
    mToken = MusicUtils.bindToService(this, this);

    // Theme the action bar
    final ActionBar actionBar = getSupportActionBar();
    mResources.themeActionBar(actionBar, getString(R.string.app_name));
    actionBar.setDisplayHomeAsUpEnabled(true);

    // Set the layout
    setContentView(R.layout.grid_base);

    // Give the background a little UI
    final FrameLayout background = (FrameLayout) findViewById(R.id.grid_base_container);
    background.setBackgroundDrawable(getResources().getDrawable(R.drawable.pager_background));

    // Get the query
    final String query = getIntent().getStringExtra(SearchManager.QUERY);
    mFilterString = !TextUtils.isEmpty(query) ? query : null;

    // Action bar subtitle
    mResources.setSubtitle("\"" + mFilterString + "\"");

    // Initialize the adapter
    mAdapter = new SearchAdapter(this);
    // Set the prefix
    mAdapter.setPrefix(mFilterString);
    // Initialze the list
    mGridView = (GridView) findViewById(R.id.grid_base);
    // Bind the data
    mGridView.setAdapter(mAdapter);
    // Recycle the data
    mGridView.setRecyclerListener(new RecycleHolder());
    // Seepd up scrolling
    mGridView.setOnScrollListener(this);
    mGridView.setOnItemClickListener(this);
    if (ApolloUtils.isLandscape(this)) {
        mGridView.setNumColumns(TWO);
    } else {
        mGridView.setNumColumns(ONE);
    }
    // Prepare the loader. Either re-connect with an existing one,
    // or start a new one.
    getSupportLoaderManager().initLoader(0, null, this);
}

From source file:com.ksharkapps.musicnow.ui.activities.SearchActivity.java

/**
 * {@inheritDoc}/*from  www. jav  a  2  s . co  m*/
 */
@SuppressWarnings("deprecation")
@Override
protected void onCreate(final Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    actionBar = getSupportActionBar();
    // Fade it in
    overridePendingTransition(R.anim.swipeback_stack_right_in, R.anim.swipeback_stack_to_back);
    // Control the media volume
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    // Bind Apollo's service
    mToken = MusicUtils.bindToService(this, this);

    // Theme the action bar
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    // Set the layout
    setContentView(R.layout.grid_base);

    // Give the background a little UI
    final FrameLayout background = (FrameLayout) findViewById(R.id.grid_base_container);
    background.setBackgroundDrawable(getResources().getDrawable(R.drawable.pager_background));

    // Get the query
    final String query = getIntent().getStringExtra(SearchManager.QUERY);
    mFilterString = !TextUtils.isEmpty(query) ? query : null;

    // Action bar subtitle
    actionBar.setSubtitle("\"" + mFilterString + "\"");

    // Initialize the adapter
    mAdapter = new SearchAdapter(this);
    // Set the prefix
    mAdapter.setPrefix(mFilterString);
    // Initialze the list
    mGridView = (GridView) findViewById(R.id.grid_base);
    // Bind the data
    mGridView.setAdapter(mAdapter);
    // Recycle the data
    mGridView.setRecyclerListener(new RecycleHolder());
    // Seepd up scrolling
    mGridView.setOnScrollListener(this);
    mGridView.setOnItemClickListener(this);
    if (ApolloUtils.isLandscape(this)) {
        mGridView.setNumColumns(TWO);
    } else {
        mGridView.setNumColumns(ONE);
    }
    // Prepare the loader. Either re-connect with an existing one,
    // or start a new one.
    getLoaderManager().initLoader(0, null, this);
}

From source file:io.nuclei.cyto.ui.view.BottomSheetView.java

private void init(Context context) {
    ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
    mMinFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity();
    mTouchSlop = viewConfiguration.getScaledTouchSlop();

    setClickable(true);//from   w w w.  j  ava  2 s . c om

    mBackground = new View(context);
    mBackground.setBackgroundColor(mBackgroundColor = DEFAULT_BACKGROUND_COLOR);
    mBackground.setLayoutParams(
            new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    mBackground.setVisibility(GONE);
    mBackground.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if ((mState & STATE_MOVING) != STATE_MOVING) {
                if ((mState & STATE_LOCKED) == STATE_LOCKED)
                    removeState(STATE_LOCKED);
                setState(STATE_CLOSED);
            }
        }
    });
    addView(mBackground);

    FrameLayout content = new FrameLayout(context);
    content.setLayoutParams(
            new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    content.setMinimumHeight(1);
    content.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
    content.setClickable(true);
    addView(content);
    mContent = content;
    mOffsetHelper = new ViewOffsetHelper(mContent);

    onPrepare();
}

From source file:org.namelessrom.devicecontrol.MainActivity.java

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

    // setup action bar
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//w  w w.  ja va  2  s  .  co m
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mSubFragmentTitle == -1) {
                sSlidingMenu.toggle(true);
            } else {
                onCustomBackPressed(true);
            }
        }
    });

    // setup material menu icon
    sMaterialMenu = new MaterialMenuIconToolbar(this, Color.WHITE, MaterialMenuDrawable.Stroke.THIN) {
        @Override
        public int getToolbarViewId() {
            return R.id.toolbar;
        }
    };
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        sMaterialMenu.setNeverDrawTouch(true);
    }

    Utils.setupDirectories();

    final FrameLayout container = (FrameLayout) findViewById(R.id.container);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        container.setBackground(null);
    } else {
        //noinspection deprecation
        container.setBackgroundDrawable(null);
    }

    final View v = getLayoutInflater().inflate(R.layout.menu_list, container, false);
    final ListView menuList = (ListView) v.findViewById(R.id.navbarlist);
    final LinearLayout menuContainer = (LinearLayout) v.findViewById(R.id.menu_container);
    // setup our static items
    menuContainer.findViewById(R.id.menu_prefs).setOnClickListener(this);
    menuContainer.findViewById(R.id.menu_about).setOnClickListener(this);

    sSlidingMenu = new SlidingMenu(this);
    sSlidingMenu.setMode(SlidingMenu.LEFT);
    sSlidingMenu.setShadowWidthRes(R.dimen.shadow_width);
    sSlidingMenu.setShadowDrawable(R.drawable.shadow_left);
    sSlidingMenu.setBehindWidthRes(R.dimen.slidingmenu_offset);
    sSlidingMenu.setFadeEnabled(true);
    sSlidingMenu.setFadeDegree(0.45f);
    sSlidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
    sSlidingMenu.setMenu(v);

    // setup touch mode
    MainActivity.setSwipeOnContent(DeviceConfiguration.get(this).swipeOnContent);

    // setup menu list
    setupMenuLists();
    final MenuListArrayAdapter mAdapter = new MenuListArrayAdapter(this, R.layout.menu_main_list_item,
            mMenuEntries, mMenuIcons);
    menuList.setAdapter(mAdapter);
    menuList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    menuList.setOnItemClickListener(this);

    loadFragmentPrivate(DeviceConstants.ID_ABOUT, false);
    getSupportFragmentManager().executePendingTransactions();

    Utils.startTaskerService();

    final String downgradePath = getFilesDir() + DeviceConstants.DC_DOWNGRADE;
    if (Utils.fileExists(downgradePath)) {
        if (!new File(downgradePath).delete()) {
            Logger.wtf(this, "Could not delete downgrade indicator file!");
        }
        Toast.makeText(this, R.string.downgraded, Toast.LENGTH_LONG).show();
    }

    if (DeviceConfiguration.get(this).dcFirstStart) {
        DeviceConfiguration.get(this).dcFirstStart = false;
        DeviceConfiguration.get(this).saveConfiguration(this);
    }
}

From source file:activities.Activity_Main.java

/** Called when the activity is first created. */
@Override//w  w w  .j  a  v a 2 s.  c o m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    myself = this;
    setContentView(R.layout.activity_home);

    SP_params = PreferenceManager.getDefaultSharedPreferences(this);
    SP_prefEditor = SP_params.edit();
    Tracer = tracerengine.getInstance(SP_params);

    //Added by Doume
    File storage = new File(Environment.getExternalStorageDirectory() + "/domodroid/.conf/");
    if (!storage.exists())
        storage.mkdirs();
    //Configure Tracer tool initial state
    File logpath = new File(Environment.getExternalStorageDirectory() + "/domodroid/.log/");
    if (!logpath.exists())
        logpath.mkdirs();

    String currlogpath = SP_params.getString("LOGNAME", "");
    if (currlogpath.equals("")) {
        //Not yet existing prefs : Configure debugging by default, to configure Tracer
        currlogpath = Environment.getExternalStorageDirectory() + "/domodroid/.log/";
        SP_prefEditor.putString("LOGPATH", currlogpath);
        SP_prefEditor.putString("LOGNAME", "Domodroid.txt");
        SP_prefEditor.putBoolean("SYSTEMLOG", false);
        SP_prefEditor.putBoolean("TEXTLOG", false);
        SP_prefEditor.putBoolean("SCREENLOG", false);
        SP_prefEditor.putBoolean("LOGCHANGED", true);
        SP_prefEditor.putBoolean("LOGAPPEND", false);
    } else {
        SP_prefEditor.putBoolean("LOGCHANGED", true); //To force Tracer to consider current settings
    }
    //prefEditor.putBoolean("SYSTEMLOG", false);      // For tests : no system logs....
    SP_prefEditor.putBoolean("SYSTEMLOG", true); // For tests : with system logs....

    SP_prefEditor.commit();

    Tracer.set_profile(SP_params);
    // Create .nomedia file, that will prevent Android image gallery from showing domodroid file
    String nomedia = Environment.getExternalStorageDirectory() + "/domodroid/.nomedia";
    try {
        if (!(new File(nomedia).exists())) {
            new FileOutputStream(nomedia).close();
        }
    } catch (Exception e) {
    }

    appname = (ImageView) findViewById(R.id.app_name);

    LoadSelections();

    // Prepare a listener to know when a sync dialog is closed...
    if (sync_listener == null) {
        sync_listener = new DialogInterface.OnDismissListener() {

            public void onDismiss(DialogInterface dialog) {

                Tracer.d(mytag, "sync dialog has been closed !");

                // Is it success or fail ?
                if (((Dialog_Synchronize) dialog).need_refresh) {
                    // Sync has been successful : Force to refresh current main view
                    Tracer.d(mytag, "sync dialog requires a refresh !");
                    reload = true; // Sync being done, consider shared prefs are OK
                    VG_parent.removeAllViews();
                    if (WU_widgetUpdate != null) {
                        WU_widgetUpdate.resync();
                    } else {
                        Tracer.i(mytag + ".onCreate", "WidgetUpdate is null startCacheengine!");
                        startCacheEngine();
                    }
                    Bundle b = new Bundle();
                    //Notify sync complete to parent Dialog
                    b.putInt("id", 0);
                    b.putString("type", "root");
                    Message msg = new Message();
                    msg.setData(b);
                    if (widgetHandler != null)
                        widgetHandler.sendMessage(msg); // That should force to refresh Views
                    /* */
                    if (WU_widgetUpdate != null) {
                        WU_widgetUpdate.Disconnect(0); //That should disconnect all opened widgets from cache engine
                        //widgetUpdate.dump_cache();   //For debug
                        dont_kill = true; // to avoid engines kill when onDestroy()
                    }
                    onResume();
                } else {
                    Tracer.d(mytag, "sync dialog end with no refresh !");

                }
                ((Dialog_Synchronize) dialog).need_refresh = false;
            }
        };
    }

    //update thread
    sbanim = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            if (msg.what == 0) {
                appname.setImageDrawable(getResources().getDrawable(R.drawable.app_name2));
            } else if (msg.what == 1) {
                appname.setImageDrawable(getResources().getDrawable(R.drawable.app_name3));
            } else if (msg.what == 2) {
                appname.setImageDrawable(getResources().getDrawable(R.drawable.app_name1));
            } else if (msg.what == 3) {
                appname.setImageDrawable(getResources().getDrawable(R.drawable.app_name4));
            } else if (msg.what == 8000) {
                Tracer.e(mytag, "Request to display message : 8000");
                /*
                if(dialog_message == null) {
                   Create_message_box();
                }
                dialog_message.setMessage("Starting cache engine...");
                dialog_message.show();
                        
                */
            } else if (msg.what == 8999) {
                //Cache engine is ready for use....
                if (Tracer != null)
                    Tracer.e(mytag, "Cache engine has notified it's ready !");
                cache_ready = true;
                if (end_of_init_requested)
                    end_of_init();
                PG_dialog_message.dismiss();
            }
        }
    };

    //power management
    final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    this.PM_WakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "");
    this.PM_WakeLock.acquire();

    //titlebar
    final FrameLayout titlebar = (FrameLayout) findViewById(R.id.TitleBar);
    titlebar.setBackgroundDrawable(Gradients_Manager.LoadDrawable("title", 40));

    //Parent view
    VG_parent = (ViewGroup) findViewById(R.id.home_container);

    LL_house_map = new LinearLayout(this);
    LL_house_map
            .setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    LL_house_map.setOrientation(LinearLayout.HORIZONTAL);
    LL_house_map.setPadding(5, 5, 5, 5);

    house = new Basic_Graphical_zone(getApplicationContext(), 0, Graphics_Manager.Names_Agent(this, "House"),
            "", "house", 0, "", null);
    house.setPadding(0, 0, 5, 0);
    map = new Basic_Graphical_zone(getApplicationContext(), 0, Graphics_Manager.Names_Agent(this, "Map"), "",
            "map", 0, "", null);
    map.setPadding(5, 0, 0, 0);

    LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.FILL_PARENT, 1.0f);

    house.setLayoutParams(param);
    house.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (SP_params.getBoolean("SYNC", false)) {
                loadWigets(0, "root");
                historyPosition++;
                history.add(historyPosition, new String[] { "0", "root" });
            } else {
                if (AD_notSyncAlert == null)
                    createAlert();
                AD_notSyncAlert.show();
            }
        }
    });

    map.setLayoutParams(param);
    map.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (SP_params.getBoolean("SYNC", false)) {
                //dont_freeze=true;      //To avoid WidgetUpdate engine freeze
                Tracer.w(mytag, "Before call to Map, Disconnect widgets from engine !");
                if (WU_widgetUpdate != null) {
                    WU_widgetUpdate.Disconnect(0); //That should disconnect all opened widgets from cache engine
                    //widgetUpdate.dump_cache();   //For debug
                    dont_kill = true; // to avoid engines kill when onDestroy()
                }
                INTENT_map = new Intent(Activity_Main.this, Activity_Map.class);
                Tracer.d(mytag, "Call to Map, run it now !");
                Tracer.Map_as_main = false;
                startActivity(INTENT_map);
            } else {
                if (AD_notSyncAlert == null)
                    createAlert();
                AD_notSyncAlert.show();
            }
        }
    });

    LL_house_map.addView(house);
    LL_house_map.addView(map);

    init_done = false;
    // Detect if it's the 1st use after installation...
    if (!SP_params.getBoolean("SPLASH", false)) {
        // Yes, 1st use !
        init_done = false;
        reload = false;
        if (backupprefs.exists()) {
            // A backup exists : Ask if reload it
            Tracer.v(mytag, "settings backup found after a fresh install...");

            DialogInterface.OnClickListener reload_listener = new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    Tracer.e(mytag, "Reload dialog returns : " + which);
                    if (which == dialog.BUTTON_POSITIVE) {
                        reload = true;
                    } else if (which == dialog.BUTTON_NEGATIVE) {
                        reload = false;
                    }
                    check_answer();
                    dialog.dismiss();
                }
            };
            dialog_reload = new AlertDialog.Builder(this);
            dialog_reload.setMessage(getText(R.string.home_reload));
            dialog_reload.setTitle(getText(R.string.reload_title));
            dialog_reload.setPositiveButton(getText(R.string.reloadOK), reload_listener);
            dialog_reload.setNegativeButton(getText(R.string.reloadNO), reload_listener);
            dialog_reload.show();
            init_done = false; //A choice is pending : Rest of init has to be completed...
        } else {
            //No settings backup found
            Tracer.v(mytag, "no settings backup found after fresh install...");
            end_of_init_requested = true;
            // open server config view
            Intent helpI = new Intent(Activity_Main.this, Preference.class);
            startActivity(helpI);
        }
    } else {
        // It's not the 1st use after fresh install
        // This method will be followed by 'onResume()'
        end_of_init_requested = true;
    }
    if (SP_params.getBoolean("SYNC", false)) {
        //A config exists and a sync as been done by past.
        if (WU_widgetUpdate == null) {
            Tracer.i(mytag + ".onCreate", "Params splach is false and WidgetUpdate is null startCacheengine!");
            startCacheEngine();
        }

    }

    Tracer.e(mytag, "OnCreate() complete !");
    // End of onCreate (UIThread)
}

From source file:com.trailbehind.android.iburn.map.MapActivity.java

/**
 * Setup views.//from   w w  w. j  a v a 2s  . co m
 */
private void setupViews() {
    setContentView(R.layout.map);
    final FrameLayout contentView = (FrameLayout) findViewById(android.R.id.content);
    if (contentView != null) {
        contentView.setBackgroundDrawable(null);
        contentView.setForeground(null);
    }

    // setup top panel
    setupHeaderPanel();

    // setup map component
    setupMapComponent();

    // create map view now
    setupMapView();

    // setup loc source
    mActivityHandler.sendMessageDelayed(
            mActivityHandler.obtainMessage(ActivityHandler.MESSAGE_INIT_LOCATION_SOURCE_N_MAP_LISTENER), 1000);

    // create zoom controls
    setupZoomControls();
}

From source file:org.pouyadr.ui.LocationActivity.java

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    if (AndroidUtilities.isTablet()) {
        actionBar.setOccupyStatusBar(false);
    }/* w  ww.j a  va  2s  . c o m*/
    actionBar.setAddToContainer(messageObject != null);

    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == map_list_menu_map) {
                if (googleMap != null) {
                    googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
                }
            } else if (id == map_list_menu_satellite) {
                if (googleMap != null) {
                    googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
                }
            } else if (id == map_list_menu_hybrid) {
                if (googleMap != null) {
                    googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
                }
            } else if (id == share) {
                try {
                    double lat = messageObject.messageOwner.media.geo.lat;
                    double lon = messageObject.messageOwner.media.geo._long;
                    getParentActivity().startActivity(new Intent(android.content.Intent.ACTION_VIEW,
                            Uri.parse("geo:" + lat + "," + lon + "?q=" + lat + "," + lon)));
                } catch (Exception e) {
                    FileLog.e("tmessages", e);
                }
            }
        }
    });

    ActionBarMenu menu = actionBar.createMenu();
    if (messageObject != null) {
        if (messageObject.messageOwner.media.title != null
                && messageObject.messageOwner.media.title.length() > 0) {
            actionBar.setTitle(messageObject.messageOwner.media.title);
            if (messageObject.messageOwner.media.address != null
                    && messageObject.messageOwner.media.address.length() > 0) {
                actionBar.setSubtitle(messageObject.messageOwner.media.address);
            }
        } else {
            actionBar.setTitle(LocaleController.getString("ChatLocation", R.string.ChatLocation));
        }
        menu.addItem(share, R.drawable.share);
    } else {
        actionBar.setTitle(LocaleController.getString("ShareLocation", R.string.ShareLocation));

        ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true)
                .setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
                    @Override
                    public void onSearchExpand() {
                        searching = true;
                        listView.setVisibility(View.GONE);
                        mapViewClip.setVisibility(View.GONE);
                        searchListView.setVisibility(View.VISIBLE);
                        searchListView.setEmptyView(emptyTextLayout);
                    }

                    @Override
                    public void onSearchCollapse() {
                        searching = false;
                        searchWas = false;
                        searchListView.setEmptyView(null);
                        listView.setVisibility(View.VISIBLE);
                        mapViewClip.setVisibility(View.VISIBLE);
                        searchListView.setVisibility(View.GONE);
                        emptyTextLayout.setVisibility(View.GONE);
                        searchAdapter.searchDelayed(null, null);
                    }

                    @Override
                    public void onTextChanged(EditText editText) {
                        if (searchAdapter == null) {
                            return;
                        }
                        String text = editText.getText().toString();
                        if (text.length() != 0) {
                            searchWas = true;
                        }
                        searchAdapter.searchDelayed(text, userLocation);
                    }
                });
        item.getSearchField().setHint(LocaleController.getString("Search", R.string.Search));
    }

    ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other);
    item.addSubItem(map_list_menu_map, LocaleController.getString("Map", R.string.Map), 0);
    item.addSubItem(map_list_menu_satellite, LocaleController.getString("Satellite", R.string.Satellite), 0);
    item.addSubItem(map_list_menu_hybrid, LocaleController.getString("Hybrid", R.string.Hybrid), 0);
    fragmentView = new FrameLayout(context) {
        private boolean first = true;

        @Override
        protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
            super.onLayout(changed, left, top, right, bottom);

            if (changed) {
                fixLayoutInternal(first);
                first = false;
            }
        }
    };
    FrameLayout frameLayout = (FrameLayout) fragmentView;

    locationButton = new ImageView(context);
    locationButton.setBackgroundResource(R.drawable.floating_user_states);
    locationButton.setImageResource(R.drawable.myloc_on);
    locationButton.setScaleType(ImageView.ScaleType.CENTER);
    if (Build.VERSION.SDK_INT >= 21) {
        StateListAnimator animator = new StateListAnimator();
        animator.addState(new int[] { android.R.attr.state_pressed },
                ObjectAnimator
                        .ofFloat(locationButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4))
                        .setDuration(200));
        animator.addState(new int[] {},
                ObjectAnimator
                        .ofFloat(locationButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2))
                        .setDuration(200));
        locationButton.setStateListAnimator(animator);
        locationButton.setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56));
            }
        });
    }

    if (messageObject != null) {
        mapView = new MapView(context);
        frameLayout.setBackgroundDrawable(new MapPlaceholderDrawable());
        mapView.onCreate(null);
        try {
            MapsInitializer.initialize(context);
            //                googleMap = mapView.getMap();
        } catch (Exception e) {
            FileLog.e("tmessages", e);
        }

        FrameLayout bottomView = new FrameLayout(context);
        bottomView.setBackgroundResource(R.drawable.location_panel);
        frameLayout.addView(bottomView,
                LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 60, Gravity.LEFT | Gravity.BOTTOM));
        bottomView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (userLocation != null) {
                    LatLng latLng = new LatLng(userLocation.getLatitude(), userLocation.getLongitude());
                    if (googleMap != null) {
                        CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng,
                                googleMap.getMaxZoomLevel() - 4);
                        googleMap.animateCamera(position);
                    }
                }
            }
        });

        avatarImageView = new BackupImageView(context);
        avatarImageView.setRoundRadius(AndroidUtilities.dp(20));
        bottomView.addView(avatarImageView,
                LayoutHelper.createFrame(40, 40,
                        Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT),
                        LocaleController.isRTL ? 0 : 12, 12, LocaleController.isRTL ? 12 : 0, 0));

        nameTextView = new TextView(context);
        nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
        nameTextView.setTextColor(0xff212121);
        nameTextView.setMaxLines(1);
        nameTextView.setTypeface(AndroidUtilities.getTypeface(org.pouyadr.finalsoft.Fonts.CurrentFont()));
        nameTextView.setEllipsize(TextUtils.TruncateAt.END);
        nameTextView.setSingleLine(true);
        nameTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
        bottomView.addView(nameTextView,
                LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT,
                        Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT),
                        LocaleController.isRTL ? 12 : 72, 10, LocaleController.isRTL ? 72 : 12, 0));

        distanceTextView = new TextView(context);
        distanceTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
        distanceTextView.setTextColor(0xff2f8cc9);
        distanceTextView.setMaxLines(1);
        distanceTextView.setEllipsize(TextUtils.TruncateAt.END);
        distanceTextView.setSingleLine(true);
        distanceTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
        bottomView.addView(distanceTextView,
                LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT,
                        Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT),
                        LocaleController.isRTL ? 12 : 72, 33, LocaleController.isRTL ? 72 : 12, 0));

        userLocation = new Location("network");
        userLocation.setLatitude(messageObject.messageOwner.media.geo.lat);
        userLocation.setLongitude(messageObject.messageOwner.media.geo._long);
        if (googleMap != null) {
            LatLng latLng = new LatLng(userLocation.getLatitude(), userLocation.getLongitude());
            try {
                googleMap.addMarker(new MarkerOptions().position(latLng)
                        .icon(BitmapDescriptorFactory.fromResource(R.drawable.map_pin)));
            } catch (Exception e) {
                FileLog.e("tmessages", e);
            }
            CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 4);
            googleMap.moveCamera(position);
        }

        ImageView routeButton = new ImageView(context);
        routeButton.setBackgroundResource(R.drawable.floating_states);
        routeButton.setImageResource(R.drawable.navigate);
        routeButton.setScaleType(ImageView.ScaleType.CENTER);
        if (Build.VERSION.SDK_INT >= 21) {
            StateListAnimator animator = new StateListAnimator();
            animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator
                    .ofFloat(routeButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4))
                    .setDuration(200));
            animator.addState(new int[] {}, ObjectAnimator
                    .ofFloat(routeButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2))
                    .setDuration(200));
            routeButton.setStateListAnimator(animator);
            routeButton.setOutlineProvider(new ViewOutlineProvider() {
                @Override
                public void getOutline(View view, Outline outline) {
                    outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56));
                }
            });
        }
        frameLayout.addView(routeButton,
                LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT,
                        (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM,
                        LocaleController.isRTL ? 14 : 0, 0, LocaleController.isRTL ? 0 : 14, 28));
        routeButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (Build.VERSION.SDK_INT >= 23) {
                    Activity activity = getParentActivity();
                    if (activity != null) {
                        if (activity.checkSelfPermission(
                                Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                            showPermissionAlert(true);
                            return;
                        }
                    }
                }
                if (myLocation != null) {
                    try {
                        Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
                                Uri.parse(String.format(Locale.US,
                                        "http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f",
                                        myLocation.getLatitude(), myLocation.getLongitude(),
                                        messageObject.messageOwner.media.geo.lat,
                                        messageObject.messageOwner.media.geo._long)));
                        getParentActivity().startActivity(intent);
                    } catch (Exception e) {
                        FileLog.e("tmessages", e);
                    }
                }
            }
        });

        frameLayout.addView(locationButton,
                LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT,
                        (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM,
                        LocaleController.isRTL ? 14 : 0, 0, LocaleController.isRTL ? 0 : 14, 100));
        locationButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (Build.VERSION.SDK_INT >= 23) {
                    Activity activity = getParentActivity();
                    if (activity != null) {
                        if (activity.checkSelfPermission(
                                Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                            showPermissionAlert(true);
                            return;
                        }
                    }
                }
                if (myLocation != null && googleMap != null) {
                    googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
                            new LatLng(myLocation.getLatitude(), myLocation.getLongitude()),
                            googleMap.getMaxZoomLevel() - 4));
                }
            }
        });
    } else {
        searchWas = false;
        searching = false;
        mapViewClip = new FrameLayout(context);
        mapViewClip.setBackgroundDrawable(new MapPlaceholderDrawable());
        if (adapter != null) {
            adapter.destroy();
        }
        if (searchAdapter != null) {
            searchAdapter.destroy();
        }

        listView = new ListView(context);
        listView.setAdapter(adapter = new LocationActivityAdapter(context));
        listView.setVerticalScrollBarEnabled(false);
        listView.setDividerHeight(0);
        listView.setDivider(null);
        frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
                LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP));
        listView.setOnScrollListener(new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {

            }

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
                    int totalItemCount) {
                if (totalItemCount == 0) {
                    return;
                }
                updateClipView(firstVisibleItem);
            }
        });
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (position == 1) {
                    if (delegate != null && userLocation != null) {
                        TLRPC.TL_messageMediaGeo location = new TLRPC.TL_messageMediaGeo();
                        location.geo = new TLRPC.TL_geoPoint();
                        location.geo.lat = userLocation.getLatitude();
                        location.geo._long = userLocation.getLongitude();
                        delegate.didSelectLocation(location);
                    }
                    finishFragment();
                } else {
                    TLRPC.TL_messageMediaVenue object = adapter.getItem(position);
                    if (object != null && delegate != null) {
                        delegate.didSelectLocation(object);
                    }
                    finishFragment();
                }
            }
        });
        adapter.setDelegate(new BaseLocationAdapter.BaseLocationAdapterDelegate() {
            @Override
            public void didLoadedSearchResult(ArrayList<TLRPC.TL_messageMediaVenue> places) {
                if (!wasResults && !places.isEmpty()) {
                    wasResults = true;
                }
            }
        });
        adapter.setOverScrollHeight(overScrollHeight);

        frameLayout.addView(mapViewClip, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
                LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP));

        mapView = new MapView(context) {
            @Override
            public boolean onInterceptTouchEvent(MotionEvent ev) {
                if (Build.VERSION.SDK_INT >= 11) {
                    if (ev.getAction() == MotionEvent.ACTION_DOWN) {
                        if (animatorSet != null) {
                            animatorSet.cancel();
                        }
                        animatorSet = new AnimatorSet();
                        animatorSet.setDuration(200);
                        animatorSet.playTogether(
                                ObjectAnimator.ofFloat(markerImageView, "translationY",
                                        markerTop + -AndroidUtilities.dp(10)),
                                ObjectAnimator.ofFloat(markerXImageView, "alpha", 1.0f));
                        animatorSet.start();
                    } else if (ev.getAction() == MotionEvent.ACTION_UP) {
                        if (animatorSet != null) {
                            animatorSet.cancel();
                        }
                        animatorSet = new AnimatorSet();
                        animatorSet.setDuration(200);
                        animatorSet.playTogether(
                                ObjectAnimator.ofFloat(markerImageView, "translationY", markerTop),
                                ObjectAnimator.ofFloat(markerXImageView, "alpha", 0.0f));
                        animatorSet.start();
                    }
                }
                if (ev.getAction() == MotionEvent.ACTION_MOVE) {
                    if (!userLocationMoved) {
                        if (Build.VERSION.SDK_INT >= 11) {
                            AnimatorSet animatorSet = new AnimatorSet();
                            animatorSet.setDuration(200);
                            animatorSet.play(ObjectAnimator.ofFloat(locationButton, "alpha", 1.0f));
                            animatorSet.start();
                        } else {
                            locationButton.setVisibility(VISIBLE);
                        }
                        userLocationMoved = true;
                    }
                    if (googleMap != null && userLocation != null) {
                        userLocation.setLatitude(googleMap.getCameraPosition().target.latitude);
                        userLocation.setLongitude(googleMap.getCameraPosition().target.longitude);
                    }
                    adapter.setCustomLocation(userLocation);
                }
                return super.onInterceptTouchEvent(ev);
            }
        };
        try {
            mapView.onCreate(null);
        } catch (Exception e) {
            FileLog.e("tmessages", e);
        }
        try {
            MapsInitializer.initialize(context);
            //                googleMap = mapView.getMap();
        } catch (Exception e) {
            FileLog.e("tmessages", e);
        }

        View shadow = new View(context);
        shadow.setBackgroundResource(R.drawable.header_shadow_reverse);
        mapViewClip.addView(shadow,
                LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 3, Gravity.LEFT | Gravity.BOTTOM));

        markerImageView = new ImageView(context);
        markerImageView.setImageResource(R.drawable.map_pin);
        mapViewClip.addView(markerImageView,
                LayoutHelper.createFrame(24, 42, Gravity.TOP | Gravity.CENTER_HORIZONTAL));

        if (Build.VERSION.SDK_INT >= 11) {
            markerXImageView = new ImageView(context);
            markerXImageView.setAlpha(0.0f);
            markerXImageView.setImageResource(R.drawable.place_x);
            mapViewClip.addView(markerXImageView,
                    LayoutHelper.createFrame(14, 14, Gravity.TOP | Gravity.CENTER_HORIZONTAL));
        }

        mapViewClip.addView(locationButton,
                LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 56 : 60,
                        Build.VERSION.SDK_INT >= 21 ? 56 : 60,
                        (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM,
                        LocaleController.isRTL ? 14 : 0, 0, LocaleController.isRTL ? 0 : 14, 14));
        locationButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (Build.VERSION.SDK_INT >= 23) {
                    Activity activity = getParentActivity();
                    if (activity != null) {
                        if (activity.checkSelfPermission(
                                Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                            showPermissionAlert(false);
                            return;
                        }
                    }
                }
                if (myLocation != null && googleMap != null) {
                    if (Build.VERSION.SDK_INT >= 11) {
                        AnimatorSet animatorSet = new AnimatorSet();
                        animatorSet.setDuration(200);
                        animatorSet.play(ObjectAnimator.ofFloat(locationButton, "alpha", 0.0f));
                        animatorSet.start();
                    } else {
                        locationButton.setVisibility(View.INVISIBLE);
                    }
                    adapter.setCustomLocation(null);
                    userLocationMoved = false;
                    googleMap.animateCamera(CameraUpdateFactory
                            .newLatLng(new LatLng(myLocation.getLatitude(), myLocation.getLongitude())));
                }
            }
        });
        if (Build.VERSION.SDK_INT >= 11) {
            locationButton.setAlpha(0.0f);
        } else {
            locationButton.setVisibility(View.INVISIBLE);
        }

        emptyTextLayout = new LinearLayout(context);
        emptyTextLayout.setVisibility(View.GONE);
        emptyTextLayout.setOrientation(LinearLayout.VERTICAL);
        frameLayout.addView(emptyTextLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
                LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 100, 0, 0));
        emptyTextLayout.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                return true;
            }
        });

        TextView emptyTextView = new TextView(context);
        emptyTextView.setTextColor(0xff808080);
        emptyTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
        emptyTextView.setGravity(Gravity.CENTER);
        emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult));
        emptyTextLayout.addView(emptyTextView,
                LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0.5f));

        FrameLayout frameLayoutEmpty = new FrameLayout(context);
        emptyTextLayout.addView(frameLayoutEmpty,
                LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0.5f));

        searchListView = new ListView(context);
        searchListView.setVisibility(View.GONE);
        searchListView.setDividerHeight(0);
        searchListView.setDivider(null);
        searchListView.setAdapter(searchAdapter = new LocationActivitySearchAdapter(context));
        frameLayout.addView(searchListView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
                LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP));
        searchListView.setOnScrollListener(new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {
                if (scrollState == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
                    AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
                }
            }

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
                    int totalItemCount) {

            }
        });
        searchListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                TLRPC.TL_messageMediaVenue object = searchAdapter.getItem(position);
                if (object != null && delegate != null) {
                    delegate.didSelectLocation(object);
                }
                finishFragment();
            }
        });

        if (googleMap != null) {
            userLocation = new Location("network");
            userLocation.setLatitude(20.659322);
            userLocation.setLongitude(-11.406250);
        }

        frameLayout.addView(actionBar);
    }

    if (googleMap != null) {
        try {
            googleMap.setMyLocationEnabled(true);
        } catch (Exception e) {
            FileLog.e("tmessages", e);
        }
        googleMap.getUiSettings().setMyLocationButtonEnabled(false);
        googleMap.getUiSettings().setZoomControlsEnabled(false);
        googleMap.getUiSettings().setCompassEnabled(false);
        googleMap.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener() {
            @Override
            public void onMyLocationChange(Location location) {
                positionMarker(location);
            }
        });
        positionMarker(myLocation = getLastLocation());
    }

    return fragmentView;
}