Example usage for android.view View SCROLLBARS_OUTSIDE_OVERLAY

List of usage examples for android.view View SCROLLBARS_OUTSIDE_OVERLAY

Introduction

In this page you can find the example usage for android.view View SCROLLBARS_OUTSIDE_OVERLAY.

Prototype

int SCROLLBARS_OUTSIDE_OVERLAY

To view the source code for android.view View SCROLLBARS_OUTSIDE_OVERLAY.

Click Source Link

Document

The scrollbar style to display the scrollbars at the edge of the view, without increasing the padding.

Usage

From source file:org.qeo.deviceregistration.ui.WebviewFragment.java

@SuppressWarnings("deprecation")
@SuppressLint("SetJavaScriptEnabled")
private void initWebview() {
    LOG.fine("initWebview");

    mWebView.getSettings().setSupportZoom(true);
    mWebView.getSettings().setBuiltInZoomControls(true);
    mWebView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
    mWebView.setScrollbarFadingEnabled(true);
    mWebView.getSettings().setLoadsImagesAutomatically(true);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setAllowFileAccess(false);

    // don't save passwords or form data
    mWebView.getSettings().setSaveFormData(false);
    mWebView.getSettings().setSavePassword(false);

    // Load the URLs inside the mWebView, not in the external web browser
    mWebView.setWebViewClient(new OpenIdWebviewClient());
}

From source file:com.github.shareme.gwsmaterialuikit.library.material.app.SimpleDialog.java

@SuppressWarnings("WrongConstant")
private void initScrollView() {
    mScrollView = new InternalScrollView(getContext());
    mScrollView.setPadding(0, 0, 0, mContentPadding - mActionPadding);
    mScrollView.setClipToPadding(false);
    mScrollView.setFillViewport(true);/*  w w w  .  ja  va  2 s.c  o  m*/
    mScrollView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
    ViewCompat.setLayoutDirection(mScrollView, ViewCompat.LAYOUT_DIRECTION_INHERIT);
}

From source file:gov.whitehouse.ui.fragments.app.ArticleListFragment.java

@Override
public void onStart() {
    super.onStart();

    if (mFeedType == ARTICLE_TYPE_FAVORITES) {
        getLoaderManager().restartLoader(mFeedType, null, this);
    } else {/*from  ww w . ja  v a 2 s .  co m*/
        /*
         * Register the broadcast receiver with the parent activity
         */
        if (mArticleFeedReceiver == null) {
            mArticleFeedReceiver = new ArticleFeedReceiver();
        }

        IntentFilter refreshFilter = new IntentFilter(FeedService.REFRESH_FEED_UI_INTENT);
        getSherlockActivity().registerReceiver(mArticleFeedReceiver, refreshFilter);

        final Intent startService = new Intent(getSherlockActivity(), FeedService.class);
        startService.putExtra(FeedService.ARG_FEED_TITLE, mFeedTitle);
        startService.putExtra(FeedService.ARG_FEED_URL, mFeedURL);
        startService.setAction(FeedService.GET_FEED_DATA_INTENT);
        getSherlockActivity().startService(startService);
    }

    final int padding = (int) (applyDimension(COMPLEX_UNIT_DIP, 6.0f, getResources().getDisplayMetrics())
            + 0.5f);
    getListView().setPadding(padding, padding, padding, padding);
    getListView().setDividerHeight(0);
    getListView().setSelector(android.R.color.transparent);

    // show the scroll indicator on the outside...
    getListView().setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
}

From source file:com.juick.android.MessagesFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    LayoutInflater li = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    viewLoading = li.inflate(R.layout.listitem_loading, null);
    if (!messagesSource.canNext()) {
        viewLoading.findViewById(R.id.loadingg).setVisibility(View.GONE);
        viewLoading.findViewById(R.id.end_of_messages).setVisibility(View.VISIBLE);
        viewLoading.findViewById(R.id.progress_bar).setVisibility(View.GONE);
        viewLoading.findViewById(R.id.progress_loading_more).setVisibility(View.GONE);
    }/*from ww w. ja v  a  2s . com*/

    mRefreshView = (RelativeLayout) li.inflate(R.layout.pull_to_refresh_header, null);
    mRefreshViewText = (TextView) mRefreshView.findViewById(R.id.pull_to_refresh_text);
    mRefreshViewImage = (ImageView) mRefreshView.findViewById(R.id.pull_to_refresh_image);
    mRefreshViewProgress = (ProgressBar) mRefreshView.findViewById(R.id.pull_to_refresh_progress);
    mRefreshViewImage.setMinimumHeight(50);
    mRefreshView.setOnClickListener(this);
    mRefreshOriginalTopPadding = mRefreshView.getPaddingTop();
    mRefreshState = TAP_TO_REFRESH;

    final ListView listView = getListView();
    listView.setBackgroundDrawable(null);
    listView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
    installDividerColor(listView);
    MainActivity.restyleChildrenOrWidget(listView);

    listAdapter = new JuickMessagesAdapter(getActivity(), this, JuickMessagesAdapter.TYPE_MESSAGES,
            allMessages ? JuickMessagesAdapter.SUBTYPE_ALL : JuickMessagesAdapter.SUBTYPE_OTHER);

    listAdapter.setOnForgetListener(new Utils.Function<Void, JuickMessage>() {
        @Override
        public Void apply(final JuickMessage jm) {
            Network.executeJAHTTPS(
                    getActivity(), null, JA_API_URL + "/pending?command=ignore&mid="
                            + ((JuickMessageID) jm.getMID()).getMid() + "&rid=" + jm.getRID(),
                    new Utils.Function<Void, RESTResponse>() {
                        @Override
                        public Void apply(final RESTResponse response) {
                            final Activity activity = getActivity();
                            if (activity == null)
                                return null; // gone.
                            if (response.getErrorText() != null) {
                                activity.runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        Toast.makeText(activity, response.getErrorText(), Toast.LENGTH_SHORT)
                                                .show();
                                    }
                                });
                            } else {
                                activity.runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        listAdapter.remove(jm);
                                        //To change body of implemented methods use File | Settings | File Templates.
                                        if (listAdapter.getCount() == 0) {
                                            if ((activity instanceof MainActivity)) {
                                                ((MainActivity) activity).doReload();
                                            }
                                        }
                                    }
                                });
                            }
                            return null;
                        }
                    });
            return null;
        }
    });
    listView.setOnTouchListener(this);
    listView.setOnScrollListener(this);
    listView.setOnItemClickListener(this);

    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(final AdapterView<?> parent, final View view, final int position,
                final long id) {
            if (view instanceof ImageGallery) {
                return false; // no need that! (possibly, make this condition work only if not scrolled meanwhile)
            }
            final Object itemAtPosition = parent.getItemAtPosition(position);
            if (itemAtPosition instanceof JuickMessage) {
                doOnClickActualTime = System.currentTimeMillis();
                doOnClick = new Runnable() {
                    @Override
                    public void run() {
                        JuickMessage msg = (JuickMessage) itemAtPosition;
                        MessageMenu messageMenu = MainActivity.getMicroBlog(msg).getMessageMenu(getActivity(),
                                messagesSource, listView, listAdapter);
                        if (messageMenu != null) {
                            messageMenu.onItemLongClick(parent, view, position, id);
                        } else {
                            Toast.makeText(getActivity(), "Not implemented ;-(", Toast.LENGTH_LONG).show();
                        }
                    }
                };
                if (alternativeLongClick) {
                    listView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
                } else {
                    doOnClick.run();
                    doOnClick = null;
                    return true;
                }
            }
            return false;
        }
    });
    listView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            System.out.println();
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
            System.out.println();
        }
    });
    init(false);
    if (parent != null) {
        parent.onFragmentCreated();
    }
}

From source file:com.github.shareme.gwsmaterialuikit.library.material.app.SimpleDialog.java

private void initListView() {
    mListView = new InternalListView(getContext());
    mListView.setDividerHeight(0);//  w w  w .  j av  a2s. c o  m
    mListView.setCacheColorHint(0x00000000);
    mListView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
    mListView.setClipToPadding(false);
    mListView.setSelector(BlankDrawable.getInstance());
    mListView.setPadding(0, 0, 0, mContentPadding - mActionPadding);
    mListView.setVerticalFadingEdgeEnabled(false);
    mListView.setOverScrollMode(ListView.OVER_SCROLL_NEVER);
    ViewCompat.setLayoutDirection(mListView, ViewCompat.LAYOUT_DIRECTION_INHERIT);

    mAdapter = new InternalAdapter();
    mListView.setAdapter(mAdapter);
}

From source file:android.webkit.cts.WebViewTest.java

@UiThreadTest
public void testSetScrollBarStyle() {
    if (!NullWebViewUtils.isWebViewAvailable()) {
        return;//from w ww.j a  v a2s .  c o  m
    }

    mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET);
    assertFalse(mWebView.overlayHorizontalScrollbar());
    assertFalse(mWebView.overlayVerticalScrollbar());

    mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    assertTrue(mWebView.overlayHorizontalScrollbar());
    assertTrue(mWebView.overlayVerticalScrollbar());

    mWebView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_INSET);
    assertFalse(mWebView.overlayHorizontalScrollbar());
    assertFalse(mWebView.overlayVerticalScrollbar());

    mWebView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
    assertTrue(mWebView.overlayHorizontalScrollbar());
    assertTrue(mWebView.overlayVerticalScrollbar());
}

From source file:org.mortbay.ijetty.IJetty.java

License:asdf

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    this.requestWindowFeature(Window.FEATURE_NO_TITLE);//?
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);//??

    MainApplication.getInstance().setAppHandler(mHandler);

    instance = this;
    mWebView = new HTML5WebView(this);
    mWebView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
    mWebView.setHorizontalScrollBarEnabled(false);//?
    mWebView.setVerticalScrollBarEnabled(false); //?

    mPropertiesUtil = new PropertiesUtils();

    //?/*from   w w w. ja  v  a 2  s  . c  om*/
    Intent autoStarIntent = new Intent("com.mortbay.ijetty.IJetty");
    autoStarIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    autoStarIntent.addFlags(32);
    sendBroadcast(autoStarIntent);

    //??
    //DisplayMetrics dm = new DisplayMetrics();
    //getWindowManager().getDefaultDisplay().getMetrics(dm);
    AppConstants.RESOLUTION = getDisplayScreenSize(); //String.valueOf(dm.widthPixels) + "*" + String.valueOf(getDisplayScreenHeight());    //dm.widthPixels,dm.heightPixels

    //??
    File clientProps = new File(IJetty.__JETTY_DIR + "/" + IJetty.__ETC_DIR + "/properties.xml");
    try {
        if (clientProps.exists() && clientProps.length() != 0) {
            //?assets??
            mPropertiesUtil.readPropertiesFileFromXML(
                    IJetty.getInstance().getBaseContext().getAssets().open("properties.xml"));
            //String propVersion = mPropertiesUtil.getVersion();
            Log.w("smallstar-defaultPropVersion", mPropertiesUtil.getVersion());
            int defaultPropVersion = Integer.parseInt(mPropertiesUtil.getVersion());
            mPropertiesUtil.readPropertiesFileFromXML(clientProps.getAbsolutePath());
            Log.w("smallstar-curPropVersion", mPropertiesUtil.getVersion());
            int curPropVersion = Integer.parseInt(mPropertiesUtil.getVersion());
            if (defaultPropVersion > curPropVersion) {
                //????????
                //TODO???
                mPropertiesUtil.readPropertiesFileFromXML(
                        IJetty.getInstance().getBaseContext().getAssets().open("properties.xml"));
                mPropertiesUtil.writePropertiesFileToXML(clientProps.getAbsolutePath());
                //?console.war
                Log.w(TAG, "copy console.warSD??");
                InputStream is = IJetty.getInstance().getBaseContext().getAssets().open("console.war");
                FileOutputStream fos = new FileOutputStream(AppConstants.getMediaSdFolder() + "/console.war");
                byte[] buffer = new byte[1024];
                int count = 0;
                while ((count = is.read(buffer)) > 0) {
                    fos.write(buffer, 0, count);
                }
                fos.close();
                is.close();
            }
            Log.w(TAG, "===========================================================");
            AppConstants.CLIENT_CUR_PLAYURL = mPropertiesUtil.getPlayUrl();
            Log.w(TAG, AppConstants.CLIENT_CUR_PLAYURL);
            Log.w(TAG, "===========================================================");
            //                Toast.makeText(IJetty.getInstance().getApplicationContext(), AppConstants.CLIENT_CUR_PLAYURL,
            //                        Toast.LENGTH_SHORT).show();

            PlayListUtil.playListVersion = mPropertiesUtil.getPlayListVersion();
            ApkUtils.apkPushVersion = mPropertiesUtil.getApkPushVersion();
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        Log.w("smallstar------>", "!clientProps.exists() error!!!!!!");
        e.printStackTrace();
    }

    //??:(?)
    startService(new Intent(this, DaemonService.class));

    //js?
    ProxyBridge jsBridge = new ProxyBridge(this);
    mWebView.addJavascriptInterface(jsBridge, "ia");

    mWebView.setHorizontalScrollBarEnabled(false);

    setContentView(R.layout.jetty_controller);

    startButton = (Button) findViewById(R.id.start);
    startButton.setVisibility(View.GONE);//??
    stopButton = (Button) findViewById(R.id.stop);
    stopButton.setVisibility(View.GONE);//??
    configButton = (Button) findViewById(R.id.config);
    configButton.setVisibility(View.GONE);//??
    final Button downloadButton = (Button) findViewById(R.id.download);
    downloadButton.setVisibility(View.GONE);//??

    IntentFilter filter = new IntentFilter();
    filter.addAction(__START_ACTION);
    filter.addAction(__STOP_ACTION);
    filter.addAction(__START_MOVIE_ACTION);
    filter.addCategory("default");

    bcastReceiver = new BroadcastReceiver() {
        public void onReceive(Context context, Intent intent) {
            if (__START_ACTION.equalsIgnoreCase(intent.getAction())) {
                startButton.setEnabled(false);
                configButton.setEnabled(false);
                stopButton.setEnabled(true);
                consolePrint("<br/>Started Jetty at %s", new Date());
                String[] connectors = intent.getExtras().getStringArray("connectors");
                if (null != connectors) {
                    for (int i = 0; i < connectors.length; i++)
                        consolePrint(connectors[i]);
                }

                printNetworkInterfaces();

                if (AndroidInfo.isOnEmulator(IJetty.this))
                    consolePrint("Set up port forwarding to see i-jetty outside of the emulator.");

                //warFile = new File("file:///android_asset/console.war");
                File file = new File(IJetty.__JETTY_DIR + "/" + IJetty.__WEBAPP_DIR + "/"
                        + "console/settings/basicsettings.html");
                if (file.exists()) {
                    if (file.length() > 0) {
                        //Not empty, do something here.
                        //i-jetty???web?
                        setContentView(mWebView.getLayout());
                        //TODO?????
                        int onlineTimeout = 0;
                        do {
                            if (onlineTimeout > 10)
                                break;
                            SystemClock.sleep(1000);
                            onlineTimeout++;
                        } while (!AppConstants.ONLINE_STATUS);

                        if (AppConstants.ONLINE_STATUS)//
                        {
                            mWebView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
                            //mWebView.getSettings().setCacheMode( WebSettings.LOAD_NO_CACHE);
                            mWebView.clearHistory();
                            mWebView.clearFormData();
                            mWebView.clearCache(true);
                            mWebView.loadUrl(AppConstants.CLIENT_CUR_PLAYURL);
                        } else
                            mWebView.loadUrl("http://localhost:8080/console/settings/basicsettings.html");
                    }
                }
            } else if (__STOP_ACTION.equalsIgnoreCase(intent.getAction())) {
                startButton.setEnabled(true);
                configButton.setEnabled(true);
                stopButton.setEnabled(false);
                consolePrint("<br/> Jetty stopped at %s", new Date());
            } else if (__START_MOVIE_ACTION.equalsIgnoreCase(intent.getAction())) {
                //service?onCreate()?onStartCommand().
                Log.i(TAG, "onReceive() get Broadcast org.mortbay.ijetty.movie.start");
                Intent mIntent = new Intent("createUI");
                mIntent.setClass(context, MediaPlaybackService.class);
                context.startService(mIntent);
            }
        }

    };

    registerReceiver(bcastReceiver, filter);

    // Watch for button clicks.
    startButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (isUpdateNeeded())
                IJettyToast.showQuickToast(IJetty.this, R.string.loading);
            else {
                //TODO get these values from editable UI elements
                Intent intent = new Intent(IJetty.this, IJettyService.class);
                intent.putExtra(__PORT, __PORT_DEFAULT);
                intent.putExtra(__NIO, __NIO_DEFAULT);
                intent.putExtra(__SSL, __SSL_DEFAULT);
                intent.putExtra(__CONSOLE_PWD, __CONSOLE_PWD_DEFAULT);
                startService(intent);
            }
        }
    });

    stopButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            stopService(new Intent(IJetty.this, IJettyService.class));
        }
    });

    configButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            IJettyEditor.show(IJetty.this);
        }
    });

    downloadButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            IJettyDownloader.show(IJetty.this);
        }
    });

    info = (TextView) findViewById(R.id.info);
    info.setVisibility(View.GONE);
    footer = (TextView) findViewById(R.id.footer);
    footer.setVisibility(View.GONE);
    console = (TextView) findViewById(R.id.console);
    console.setVisibility(View.GONE);
    consoleScroller = (ScrollView) findViewById(R.id.consoleScroller);
    consoleScroller.setVisibility(View.GONE);

    StringBuilder infoBuffer = new StringBuilder();
    try {
        PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0);
        infoBuffer.append(formatJettyInfoLine("i-jetty version %s (%s)", pi.versionName, pi.versionCode));
    } catch (NameNotFoundException e) {
        infoBuffer.append(formatJettyInfoLine("i-jetty version unknown"));
    }
    infoBuffer.append(formatJettyInfoLine("On %s using Android version %s", AndroidInfo.getDeviceModel(),
            AndroidInfo.getOSVersion()));
    info.setText(Html.fromHtml(infoBuffer.toString()));

    StringBuilder footerBuffer = new StringBuilder();
    footerBuffer.append(
            "<b>Project:</b> <a href=\"http://code.google.com/p/i-jetty\">http://code.google.com/p/i-jetty</a> <br/>");
    footerBuffer.append("<b>Server:</b> http://www.eclipse.org/jetty <br/>");
    footerBuffer.append("<b>Support:</b> http://www.intalio.com/jetty/services <br/>");
    footer.setText(Html.fromHtml(footerBuffer.toString()));

    //??WEB?
    Intent intent = new Intent(IJetty.this, IJettyService.class);
    intent.putExtra(__PORT, __PORT_DEFAULT);
    intent.putExtra(__NIO, __NIO_DEFAULT);
    intent.putExtra(__SSL, __SSL_DEFAULT);
    intent.putExtra(__CONSOLE_PWD, __CONSOLE_PWD_DEFAULT);
    startService(intent);
}

From source file:kr.wdream.ui.DialogsActivity.java

public void initView() {

    RelativeLayout relativeLayout = new RelativeLayout(context);
    fragmentView = relativeLayout;//ww w  .  ja  va  2  s .  c om

    LinearLayout lytTab = new LinearLayout(context);
    lytTab.setId(kr.wdream.storyshop.R.id.lytTab);

    tabParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT, 1);
    tabParams.setMargins(0, 0, 0, 5);

    tab1 = new LinearLayout(context);
    tab1.setGravity(Gravity.CENTER);
    imgTab1 = new ImageView(context);
    imgTab1.setImageResource(R.drawable.m_i_main_flist_n);
    tab1.addView(imgTab1, LayoutHelper.createLinear(21, 20));
    tab1.setOnClickListener(this);

    tab2 = new LinearLayout(context);
    tab2.setGravity(Gravity.CENTER);
    imgTab2 = new ImageView(context);
    imgTab2.setImageResource(R.drawable.m_i_main_clist_n);
    tab2.addView(imgTab2, LayoutHelper.createLinear(21, 20));
    tab2.setOnClickListener(this);

    tab3 = new LinearLayout(context);
    tab3.setGravity(Gravity.CENTER);
    imgTab3 = new ImageView(context);
    imgTab3.setImageResource(R.drawable.m_i_main_content_n);
    tab3.addView(imgTab3, LayoutHelper.createLinear(21, 20));
    tab3.setOnClickListener(this);

    tab4 = new LinearLayout(context);
    tab4.setGravity(Gravity.CENTER);
    imgTab4 = new ImageView(context);
    imgTab4.setImageResource(R.drawable.m_i_main_setting_n);
    tab4.addView(imgTab4, LayoutHelper.createLinear(21, 20));
    tab4.setOnClickListener(this);

    lytDialogs = new RelativeLayout(context);
    RelativeLayout.LayoutParams lytDialogsParams = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    lytDialogsParams.addRule(RelativeLayout.BELOW, lytTab.getId());
    lytDialogs.setLayoutParams(lytDialogsParams);
    lytDialogs.setVisibility(View.GONE);
    listView = new RecyclerListView(context);
    listView.setVerticalScrollBarEnabled(true);
    listView.setItemAnimator(null);
    listView.setInstantClick(true);
    listView.setLayoutAnimation(null);
    listView.setTag(4);
    listView.setVisibility(View.GONE);

    layoutManager = new LinearLayoutManager(context) {
        @Override
        public boolean supportsPredictiveItemAnimations() {
            return false;
        }
    };

    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    listView.setLayoutManager(layoutManager);
    listView.setVerticalScrollbarPosition(
            LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
    listView.setVerticalScrollBarEnabled(false);
    listView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
    listView.setVerticalScrollbarPosition(
            LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
    listView.setOnItemClickListener(new RecyclerListView.OnItemClickListener() {
        @Override
        public void onItemClick(View view, int position) {
            if (listView == null || listView.getAdapter() == null) {
                return;
            }
            long dialog_id = 0;
            int message_id = 0;
            RecyclerView.Adapter adapter = listView.getAdapter();
            if (adapter == dialogsAdapter) {
                TLRPC.TL_dialog dialog = dialogsAdapter.getItem(position);
                if (dialog == null) {
                    return;
                }
                dialog_id = dialog.id;
            } else if (adapter == dialogsSearchAdapter) {
                Object obj = dialogsSearchAdapter.getItem(position);
                if (obj instanceof TLRPC.User) {
                    dialog_id = ((TLRPC.User) obj).id;
                    if (dialogsSearchAdapter.isGlobalSearch(position)) {
                        ArrayList<TLRPC.User> users = new ArrayList<>();
                        users.add((TLRPC.User) obj);
                        MessagesController.getInstance().putUsers(users, false);
                        MessagesStorage.getInstance().putUsersAndChats(users, null, false, true);
                    }
                    if (!onlySelect) {
                        dialogsSearchAdapter.putRecentSearch(dialog_id, (TLRPC.User) obj);
                    }
                } else if (obj instanceof TLRPC.Chat) {
                    if (dialogsSearchAdapter.isGlobalSearch(position)) {
                        ArrayList<TLRPC.Chat> chats = new ArrayList<>();
                        chats.add((TLRPC.Chat) obj);
                        MessagesController.getInstance().putChats(chats, false);
                        MessagesStorage.getInstance().putUsersAndChats(null, chats, false, true);
                    }
                    if (((TLRPC.Chat) obj).id > 0) {
                        dialog_id = -((TLRPC.Chat) obj).id;
                    } else {
                        dialog_id = AndroidUtilities.makeBroadcastId(((TLRPC.Chat) obj).id);
                    }
                    if (!onlySelect) {
                        dialogsSearchAdapter.putRecentSearch(dialog_id, (TLRPC.Chat) obj);
                    }
                } else if (obj instanceof TLRPC.EncryptedChat) {
                    dialog_id = ((long) ((TLRPC.EncryptedChat) obj).id) << 32;
                    if (!onlySelect) {
                        dialogsSearchAdapter.putRecentSearch(dialog_id, (TLRPC.EncryptedChat) obj);
                    }
                } else if (obj instanceof MessageObject) {
                    MessageObject messageObject = (MessageObject) obj;
                    dialog_id = messageObject.getDialogId();
                    message_id = messageObject.getId();
                    dialogsSearchAdapter.addHashtagsFromMessage(dialogsSearchAdapter.getLastSearchString());
                } else if (obj instanceof String) {
                    Log.d(LOG_TAG, "obj String : openSearchField");
                    actionBar.openSearchField((String) obj);
                }
            }

            if (dialog_id == 0) {
                return;
            }

            if (onlySelect) {
                didSelectResult(dialog_id, true, false);
            } else {
                Bundle args = new Bundle();
                int lower_part = (int) dialog_id;
                int high_id = (int) (dialog_id >> 32);
                if (lower_part != 0) {
                    if (high_id == 1) {
                        args.putInt("chat_id", lower_part);
                    } else {
                        if (lower_part > 0) {
                            args.putInt("user_id", lower_part);
                        } else if (lower_part < 0) {
                            if (message_id != 0) {
                                TLRPC.Chat chat = MessagesController.getInstance().getChat(-lower_part);
                                if (chat != null && chat.migrated_to != null) {
                                    args.putInt("migrated_to", lower_part);
                                    lower_part = -chat.migrated_to.channel_id;
                                }
                            }
                            args.putInt("chat_id", -lower_part);
                        }
                    }
                } else {
                    args.putInt("enc_id", high_id);
                }
                if (message_id != 0) {
                    args.putInt("message_id", message_id);
                } else {
                    if (actionBar != null) {
                        actionBar.closeSearchField();
                    }
                }
                if (AndroidUtilities.isTablet()) {
                    if (openedDialogId == dialog_id && adapter != dialogsSearchAdapter) {
                        return;
                    }
                    if (dialogsAdapter != null) {
                        dialogsAdapter.setOpenedDialogId(openedDialogId = dialog_id);
                        updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG);
                    }
                }
                if (searchString != null) {
                    if (MessagesController.checkCanOpenChat(args, DialogsActivity.this)) {
                        NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
                        presentFragment(new ChatActivity(args));
                    }
                } else {
                    if (MessagesController.checkCanOpenChat(args, DialogsActivity.this)) {
                        presentFragment(new ChatActivity(args));
                    }
                }
            }
        }
    });
    listView.setOnItemLongClickListener(new RecyclerListView.OnItemLongClickListener() {
        @Override
        public boolean onItemClick(View view, int position) {
            if (onlySelect || searching && searchWas || getParentActivity() == null) {
                if (searchWas && searching || dialogsSearchAdapter.isRecentSearchDisplayed()) {
                    RecyclerView.Adapter adapter = listView.getAdapter();
                    if (adapter == dialogsSearchAdapter) {
                        Object item = dialogsSearchAdapter.getItem(position);
                        if (item instanceof String || dialogsSearchAdapter.isRecentSearchDisplayed()) {
                            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                            builder.setTitle(LocaleController.getString("AppName",
                                    kr.wdream.storyshop.R.string.AppName));
                            builder.setMessage(LocaleController.getString("ClearSearch",
                                    kr.wdream.storyshop.R.string.ClearSearch));
                            builder.setPositiveButton(LocaleController
                                    .getString("ClearButton", kr.wdream.storyshop.R.string.ClearButton)
                                    .toUpperCase(), new DialogInterface.OnClickListener() {
                                        @Override
                                        public void onClick(DialogInterface dialogInterface, int i) {
                                            if (dialogsSearchAdapter.isRecentSearchDisplayed()) {
                                                dialogsSearchAdapter.clearRecentSearch();
                                            } else {
                                                dialogsSearchAdapter.clearRecentHashtags();
                                            }
                                        }
                                    });
                            builder.setNegativeButton(
                                    LocaleController.getString("Cancel", kr.wdream.storyshop.R.string.Cancel),
                                    null);
                            showDialog(builder.create());
                            return true;
                        }
                    }
                }
                return false;
            }
            TLRPC.TL_dialog dialog;
            ArrayList<TLRPC.TL_dialog> dialogs = getDialogsArray();
            if (position < 0 || position >= dialogs.size()) {
                return false;
            }
            dialog = dialogs.get(position);
            selectedDialog = dialog.id;

            BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity());
            int lower_id = (int) selectedDialog;
            int high_id = (int) (selectedDialog >> 32);

            if (DialogObject.isChannel(dialog)) {
                final TLRPC.Chat chat = MessagesController.getInstance().getChat(-lower_id);
                CharSequence items[];
                if (chat != null && chat.megagroup) {
                    items = new CharSequence[] {
                            LocaleController.getString("ClearHistoryCache",
                                    kr.wdream.storyshop.R.string.ClearHistoryCache),
                            chat == null || !chat.creator
                                    ? LocaleController.getString("LeaveMegaMenu",
                                            kr.wdream.storyshop.R.string.LeaveMegaMenu)
                                    : LocaleController.getString("DeleteMegaMenu",
                                            kr.wdream.storyshop.R.string.DeleteMegaMenu) };
                } else {
                    items = new CharSequence[] {
                            LocaleController.getString("ClearHistoryCache",
                                    kr.wdream.storyshop.R.string.ClearHistoryCache),
                            chat == null || !chat.creator
                                    ? LocaleController.getString("LeaveChannelMenu",
                                            kr.wdream.storyshop.R.string.LeaveChannelMenu)
                                    : LocaleController.getString("ChannelDeleteMenu",
                                            kr.wdream.storyshop.R.string.ChannelDeleteMenu) };
                }
                builder.setItems(items, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, final int which) {
                        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                        builder.setTitle(
                                LocaleController.getString("AppName", kr.wdream.storyshop.R.string.AppName));
                        if (which == 0) {
                            if (chat != null && chat.megagroup) {
                                builder.setMessage(LocaleController.getString("AreYouSureClearHistorySuper",
                                        kr.wdream.storyshop.R.string.AreYouSureClearHistorySuper));
                            } else {
                                builder.setMessage(LocaleController.getString("AreYouSureClearHistoryChannel",
                                        kr.wdream.storyshop.R.string.AreYouSureClearHistoryChannel));
                            }
                            builder.setPositiveButton(
                                    LocaleController.getString("OK", kr.wdream.storyshop.R.string.OK),
                                    new DialogInterface.OnClickListener() {
                                        @Override
                                        public void onClick(DialogInterface dialogInterface, int i) {
                                            MessagesController.getInstance().deleteDialog(selectedDialog, 2);
                                        }
                                    });
                        } else {
                            if (chat != null && chat.megagroup) {
                                if (!chat.creator) {
                                    builder.setMessage(LocaleController.getString("MegaLeaveAlert",
                                            kr.wdream.storyshop.R.string.MegaLeaveAlert));
                                } else {
                                    builder.setMessage(LocaleController.getString("MegaDeleteAlert",
                                            kr.wdream.storyshop.R.string.MegaDeleteAlert));
                                }
                            } else {
                                if (chat == null || !chat.creator) {
                                    builder.setMessage(LocaleController.getString("ChannelLeaveAlert",
                                            kr.wdream.storyshop.R.string.ChannelLeaveAlert));
                                } else {
                                    builder.setMessage(LocaleController.getString("ChannelDeleteAlert",
                                            kr.wdream.storyshop.R.string.ChannelDeleteAlert));
                                }
                            }
                            builder.setPositiveButton(
                                    LocaleController.getString("OK", kr.wdream.storyshop.R.string.OK),
                                    new DialogInterface.OnClickListener() {
                                        @Override
                                        public void onClick(DialogInterface dialogInterface, int i) {
                                            MessagesController.getInstance().deleteUserFromChat(
                                                    (int) -selectedDialog, UserConfig.getCurrentUser(), null);
                                            if (AndroidUtilities.isTablet()) {
                                                NotificationCenter.getInstance().postNotificationName(
                                                        NotificationCenter.closeChats, selectedDialog);
                                            }
                                        }
                                    });
                        }
                        builder.setNegativeButton(
                                LocaleController.getString("Cancel", kr.wdream.storyshop.R.string.Cancel),
                                null);
                        showDialog(builder.create());
                    }
                });
                showDialog(builder.create());
            } else {
                final boolean isChat = lower_id < 0 && high_id != 1;
                TLRPC.User user = null;
                if (!isChat && lower_id > 0 && high_id != 1) {
                    user = MessagesController.getInstance().getUser(lower_id);
                }
                final boolean isBot = user != null && user.bot;
                builder.setItems(
                        new CharSequence[] {
                                LocaleController.getString("ClearHistory",
                                        kr.wdream.storyshop.R.string.ClearHistory),
                                isChat ? LocaleController.getString("DeleteChat",
                                        kr.wdream.storyshop.R.string.DeleteChat)
                                        : isBot ? LocaleController.getString("DeleteAndStop",
                                                kr.wdream.storyshop.R.string.DeleteAndStop)
                                                : LocaleController.getString("Delete",
                                                        kr.wdream.storyshop.R.string.Delete) },
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, final int which) {
                                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                                builder.setTitle(LocaleController.getString("AppName",
                                        kr.wdream.storyshop.R.string.AppName));
                                if (which == 0) {
                                    builder.setMessage(LocaleController.getString("AreYouSureClearHistory",
                                            kr.wdream.storyshop.R.string.AreYouSureClearHistory));
                                } else {
                                    if (isChat) {
                                        builder.setMessage(LocaleController.getString("AreYouSureDeleteAndExit",
                                                kr.wdream.storyshop.R.string.AreYouSureDeleteAndExit));
                                    } else {
                                        builder.setMessage(
                                                LocaleController.getString("AreYouSureDeleteThisChat",
                                                        kr.wdream.storyshop.R.string.AreYouSureDeleteThisChat));
                                    }
                                }
                                builder.setPositiveButton(
                                        LocaleController.getString("OK", kr.wdream.storyshop.R.string.OK),
                                        new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialogInterface, int i) {
                                                if (which != 0) {
                                                    if (isChat) {
                                                        TLRPC.Chat currentChat = MessagesController
                                                                .getInstance().getChat((int) -selectedDialog);
                                                        if (currentChat != null
                                                                && ChatObject.isNotInChat(currentChat)) {
                                                            MessagesController.getInstance()
                                                                    .deleteDialog(selectedDialog, 0);
                                                        } else {
                                                            MessagesController.getInstance().deleteUserFromChat(
                                                                    (int) -selectedDialog,
                                                                    MessagesController.getInstance().getUser(
                                                                            UserConfig.getClientUserId()),
                                                                    null);
                                                        }
                                                    } else {
                                                        MessagesController.getInstance()
                                                                .deleteDialog(selectedDialog, 0);
                                                    }
                                                    if (isBot) {
                                                        MessagesController.getInstance()
                                                                .blockUser((int) selectedDialog);
                                                    }
                                                    if (AndroidUtilities.isTablet()) {
                                                        NotificationCenter.getInstance().postNotificationName(
                                                                NotificationCenter.closeChats, selectedDialog);
                                                    }
                                                } else {
                                                    MessagesController.getInstance()
                                                            .deleteDialog(selectedDialog, 1);
                                                }
                                            }
                                        });
                                builder.setNegativeButton(LocaleController.getString("Cancel",
                                        kr.wdream.storyshop.R.string.Cancel), null);
                                showDialog(builder.create());
                            }
                        });
                showDialog(builder.create());
            }
            return true;
        }
    });

    listContacts = new LetterSectionsListView(context);
    RelativeLayout.LayoutParams contactParams = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

    contactParams.addRule(RelativeLayout.BELOW, lytTab.getId());
    listContacts.setLayoutParams(contactParams);

    Log.d(LOG_TAG, "contactsAdapter : " + LaunchActivity.contactsAdapter.getItem(0));

    listContacts.setAdapter(LaunchActivity.contactsAdapter);

    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            Log.d(LOG_TAG, "postDelayed Start");
            handler.sendEmptyMessage(0);
        }
    }, 1500);

    listContacts.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            int section = LaunchActivity.contactsAdapter.getSectionForPosition(position);
            int row = LaunchActivity.contactsAdapter.getPositionInSectionForPosition(position);

            Object item = LaunchActivity.contactsAdapter.getItem(section, row);

            if (0 == position) {
                Intent intent = new Intent(Intent.ACTION_SEND);
                intent.setType("text/plain");
                intent.putExtra(Intent.EXTRA_TEXT, ContactsController.getInstance().getInviteText());
                getParentActivity().startActivityForResult(Intent.createChooser(intent, LocaleController
                        .getString("InviteFriends", kr.wdream.storyshop.R.string.InviteFriends)), 500);
            } else if (item instanceof ContactsController.Contact) {
                ContactsController.Contact contact = (ContactsController.Contact) item;
                String usePhone = null;
                if (!contact.phones.isEmpty()) {
                    usePhone = contact.phones.get(0);
                }
                if (usePhone == null || getParentActivity() == null) {
                    return;
                }
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setMessage(
                        LocaleController.getString("InviteUser", kr.wdream.storyshop.R.string.InviteUser));
                builder.setTitle(LocaleController.getString("AppName", kr.wdream.storyshop.R.string.AppName));
                final String arg1 = usePhone;
                builder.setPositiveButton(LocaleController.getString("OK", kr.wdream.storyshop.R.string.OK),
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                                try {
                                    Intent intent = new Intent(Intent.ACTION_VIEW,
                                            Uri.fromParts("sms", arg1, null));
                                    intent.putExtra("sms_body", LocaleController.getString("InviteText",
                                            kr.wdream.storyshop.R.string.InviteText));
                                    getParentActivity().startActivityForResult(intent, 500);
                                } catch (Exception e) {
                                    FileLog.e("tmessages", e);
                                }
                            }
                        });
                builder.setNegativeButton(
                        LocaleController.getString("Cancel", kr.wdream.storyshop.R.string.Cancel), null);
                showDialog(builder.create());
            } else {
                TLRPC.User user = (TLRPC.User) LaunchActivity.contactsAdapter.getItem(position);

                if (user == null)
                    return;
                Bundle args = new Bundle();
                args.putInt("user_id", user.id);

                if (MessagesController.checkCanOpenChat(args, DialogsActivity.this)) {
                    presentFragment(new ChatActivity(args), false);
                }

            }
        }
    });

    contentLayout = new LinearLayout(context);
    contentLayout.setOrientation(LinearLayout.VERTICAL);
    contentLayout.setVisibility(View.GONE);

    RelativeLayout.LayoutParams contentParams = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    contentParams.addRule(RelativeLayout.BELOW, lytTab.getId());

    // Contents Layout ?
    GridView gridContents = new GridView(context);
    gridContents.setNumColumns(GridView.AUTO_FIT);
    gridContents.setGravity(Gravity.CENTER);

    ContentsAdapter contentsAdapter = new ContentsAdapter(context);
    gridContents.setAdapter(contentsAdapter);

    contentLayout.addView(gridContents,
            LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    gridContents.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
            case 0:

                Log.d("??", "grid0");
                Intent intent = new Intent(context, ShoppingMainActivity.class);
                context.startActivity(intent);
                break;

            case 1:
                Log.d("??", "grid1");
                break;

            case 2:
                Log.d("??", "grid2");
                break;

            case 3:
                Log.d("??", "grid3");
                break;
            }
        }
    });

    // Setting Layout ?
    settingLayout = new LinearLayout(context);
    settingLayout.setOrientation(LinearLayout.VERTICAL);
    settingLayout.setVisibility(View.GONE);

    settingLayout.setBackgroundColor(Color.parseColor("#EEEEEE"));

    createSettingLayout();

    // TabBar 
    lytTab.addView(tab1, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 1));
    lytTab.addView(tab2, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 1));
    lytTab.addView(tab3, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 1));
    lytTab.addView(tab4, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 1));

    relativeLayout.addView(lytTab, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 50));

    RelativeLayout.LayoutParams listParams = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

    lytDialogs.addView(listView, listParams);
    relativeLayout.addView(lytDialogs, lytDialogsParams);
    relativeLayout.addView(listContacts, contactParams);
    relativeLayout.addView(contentLayout, contentParams);
    relativeLayout.addView(settingLayout, contentParams);

    searchEmptyView = new EmptyTextProgressView(context);
    searchEmptyView.setVisibility(View.GONE);
    searchEmptyView.setShowAtCenter(true);
    searchEmptyView.setText(LocaleController.getString("NoResult", kr.wdream.storyshop.R.string.NoResult));
    relativeLayout.addView(searchEmptyView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    emptyView = new LinearLayout(context);
    emptyView.setOrientation(LinearLayout.VERTICAL);
    emptyView.setVisibility(View.GONE);
    emptyView.setGravity(Gravity.CENTER);
    //        relativeLayout.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    emptyView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    TextView textView = new TextView(context);
    textView.setText(LocaleController.getString("NoChats", kr.wdream.storyshop.R.string.NoChats));
    textView.setTextColor(0xff959595);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
    emptyView.addView(textView,
            LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));

    textView = new TextView(context);
    String help = LocaleController.getString("NoChatsHelp", kr.wdream.storyshop.R.string.NoChatsHelp);
    if (AndroidUtilities.isTablet() && !AndroidUtilities.isSmallTablet()) {
        help = help.replace('\n', ' ');
    }
    textView.setText(help);
    textView.setTextColor(0xff959595);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    textView.setGravity(Gravity.CENTER);
    textView.setPadding(AndroidUtilities.dp(8), AndroidUtilities.dp(6), AndroidUtilities.dp(8), 0);
    textView.setLineSpacing(AndroidUtilities.dp(2), 1);
    emptyView.addView(textView,
            LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));

    progressView = new ProgressBar(context);
    progressView.setVisibility(View.GONE);

    RelativeLayout.LayoutParams progParams = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    progParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    progressView.setLayoutParams(progParams);
    //        relativeLayout.addView(progressView);
    //        relativeLayout.addView(progressView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));

    floatingButton = new ImageView(context);
    floatingButton.setVisibility(onlySelect ? View.GONE : View.VISIBLE);
    floatingButton.setScaleType(ImageView.ScaleType.CENTER);
    floatingButton.setBackgroundResource(kr.wdream.storyshop.R.drawable.floating_states);
    floatingButton.setImageResource(kr.wdream.storyshop.R.drawable.floating_pencil);
    Log.d(LOG_TAG, "setVisibility.VISIBLE_floating : " + floatingButton.getVisibility());
    floatingButton.setVisibility(View.GONE);
    Log.d(LOG_TAG, "setVisibility.GONE_floating : " + floatingButton.getVisibility());

    if (Build.VERSION.SDK_INT >= 21) {
        StateListAnimator animator = new StateListAnimator();
        animator.addState(new int[] { android.R.attr.state_pressed },
                ObjectAnimator
                        .ofFloat(floatingButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4))
                        .setDuration(200));
        animator.addState(new int[] {},
                ObjectAnimator
                        .ofFloat(floatingButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2))
                        .setDuration(200));
        floatingButton.setStateListAnimator(animator);
        floatingButton.setOutlineProvider(new ViewOutlineProvider() {
            @SuppressLint("NewApi")
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56));
            }
        });
    }
    RelativeLayout.LayoutParams floatingParams = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    floatingParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    floatingParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    //        relativeLayout.addView(floatingButton, 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, 14));
    relativeLayout.addView(floatingButton, floatingParams);
    floatingButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Bundle args = new Bundle();
            args.putBoolean("destroyAfterSelect", true);
            presentFragment(new ContactsActivity(args));
        }
    });

    listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (newState == RecyclerView.SCROLL_STATE_DRAGGING && searching && searchWas) {
                AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
            }
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            int firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
            int visibleItemCount = Math.abs(layoutManager.findLastVisibleItemPosition() - firstVisibleItem) + 1;
            int totalItemCount = recyclerView.getAdapter().getItemCount();

            if (searching && searchWas) {
                if (visibleItemCount > 0 && layoutManager.findLastVisibleItemPosition() == totalItemCount - 1
                        && !dialogsSearchAdapter.isMessagesSearchEndReached()) {
                    dialogsSearchAdapter.loadMoreSearchMessages();
                }
                return;
            }
            if (visibleItemCount > 0) {
                if (layoutManager.findLastVisibleItemPosition() >= getDialogsArray().size() - 10) {
                    MessagesController.getInstance().loadDialogs(-1, 100,
                            !MessagesController.getInstance().dialogsEndReached);
                }
            }

            if (floatingButton.getVisibility() != View.GONE) {
                final View topChild = recyclerView.getChildAt(0);
                int firstViewTop = 0;
                if (topChild != null) {
                    firstViewTop = topChild.getTop();
                }
                boolean goingDown;
                boolean changed = true;
                if (prevPosition == firstVisibleItem) {
                    final int topDelta = prevTop - firstViewTop;
                    goingDown = firstViewTop < prevTop;
                    changed = Math.abs(topDelta) > 1;
                } else {
                    goingDown = firstVisibleItem > prevPosition;
                }
                if (changed && scrollUpdated) {
                    hideFloatingButton(goingDown);
                }
                prevPosition = firstVisibleItem;
                prevTop = firstViewTop;
                scrollUpdated = true;
            }
        }
    });

    if (searchString == null) {
        dialogsAdapter = new DialogsAdapter(context, dialogsType);
        Log.d("Dialog", "dialogsSize : " + dialogsAdapter.getItemCount());

        if (AndroidUtilities.isTablet() && openedDialogId != 0) {
            dialogsAdapter.setOpenedDialogId(openedDialogId);
        }
        listView.setAdapter(dialogsAdapter);
    }
    int type = 0;
    if (searchString != null) {
        type = 2;
    } else if (!onlySelect) {
        type = 1;
    }
    dialogsSearchAdapter = new DialogsSearchAdapter(context, type, dialogsType);
    dialogsSearchAdapter.setDelegate(new DialogsSearchAdapter.DialogsSearchAdapterDelegate() {
        @Override
        public void searchStateChanged(boolean search) {
            if (searching && searchWas && searchEmptyView != null) {
                if (search) {
                    searchEmptyView.showProgress();
                } else {
                    searchEmptyView.showTextView();
                }
            }
        }

        @Override
        public void didPressedOnSubDialog(int did) {
            if (onlySelect) {
                didSelectResult(did, true, false);
            } else {
                Bundle args = new Bundle();
                if (did > 0) {
                    args.putInt("user_id", did);
                } else {
                    args.putInt("chat_id", -did);
                }
                if (actionBar != null) {
                    actionBar.closeSearchField();
                }
                if (AndroidUtilities.isTablet()) {
                    if (dialogsAdapter != null) {
                        dialogsAdapter.setOpenedDialogId(openedDialogId = did);
                        updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG);
                    }
                }
                if (searchString != null) {
                    if (MessagesController.checkCanOpenChat(args, DialogsActivity.this)) {
                        NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
                        presentFragment(new ChatActivity(args));
                    }
                } else {
                    if (MessagesController.checkCanOpenChat(args, DialogsActivity.this)) {
                        presentFragment(new ChatActivity(args));
                    }
                }
            }
        }

        @Override
        public void needRemoveHint(final int did) {
            if (getParentActivity() == null) {
                return;
            }
            TLRPC.User user = MessagesController.getInstance().getUser(did);
            if (user == null) {
                return;
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
            builder.setTitle(LocaleController.getString("AppName", kr.wdream.storyshop.R.string.AppName));
            builder.setMessage(LocaleController.formatString("ChatHintsDelete",
                    kr.wdream.storyshop.R.string.ChatHintsDelete,
                    ContactsController.formatName(user.first_name, user.last_name)));
            builder.setPositiveButton(LocaleController.getString("OK", kr.wdream.storyshop.R.string.OK),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            SearchQuery.removePeer(did);
                        }
                    });
            builder.setNegativeButton(LocaleController.getString("Cancel", kr.wdream.storyshop.R.string.Cancel),
                    null);
            showDialog(builder.create());
        }
    });

    if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) {
        searchEmptyView.setVisibility(View.GONE);
        emptyView.setVisibility(View.GONE);
        listView.setEmptyView(progressView);
    } else {
        searchEmptyView.setVisibility(View.GONE);
        progressView.setVisibility(View.GONE);
        listView.setEmptyView(emptyView);
    }
    if (searchString != null) {
        actionBar.openSearchField(searchString);
    }

    if (!onlySelect && dialogsType == 0) {
        relativeLayout.addView(new PlayerView(context, this), LayoutHelper
                .createFrame(LayoutHelper.MATCH_PARENT, 39, Gravity.TOP | Gravity.LEFT, 0, -36, 0, 0));
    }

    tab1.performClick();
}

From source file:org.telegram.ui.ChannelCreateActivity.java

@Override
public View createView(Context context) {
    searching = false;//from  w ww . j  a  v  a2s.c  o  m
    searchWas = false;

    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);

    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == done_button) {
                if (currentStep == 0) {
                    if (donePressed) {
                        return;
                    }
                    if (nameTextView.length() == 0) {
                        Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
                        if (v != null) {
                            v.vibrate(200);
                        }
                        AndroidUtilities.shakeView(nameTextView, 2, 0);
                        return;
                    }
                    donePressed = true;
                    if (avatarUpdater.uploadingAvatar != null) {
                        createAfterUpload = true;
                        progressDialog = new ProgressDialog(getParentActivity());
                        progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
                        progressDialog.setCanceledOnTouchOutside(false);
                        progressDialog.setCancelable(false);
                        progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE,
                                LocaleController.getString("Cancel", R.string.Cancel),
                                new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        createAfterUpload = false;
                                        progressDialog = null;
                                        donePressed = false;
                                        try {
                                            dialog.dismiss();
                                        } catch (Exception e) {
                                            FileLog.e("tmessages", e);
                                        }
                                    }
                                });
                        progressDialog.show();
                        return;
                    }
                    final int reqId = MessagesController.getInstance().createChat(
                            nameTextView.getText().toString(), new ArrayList<Integer>(),
                            descriptionTextView.getText().toString(), ChatObject.CHAT_TYPE_CHANNEL,
                            ChannelCreateActivity.this);
                    progressDialog = new ProgressDialog(getParentActivity());
                    progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
                    progressDialog.setCanceledOnTouchOutside(false);
                    progressDialog.setCancelable(false);
                    progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE,
                            LocaleController.getString("Cancel", R.string.Cancel),
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    ConnectionsManager.getInstance().cancelRequest(reqId, true);
                                    donePressed = false;
                                    try {
                                        dialog.dismiss();
                                    } catch (Exception e) {
                                        FileLog.e("tmessages", e);
                                    }
                                }
                            });
                    progressDialog.show();
                } else if (currentStep == 1) {
                    if (!isPrivate) {
                        if (nameTextView.length() == 0) {
                            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                            builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
                            builder.setMessage(LocaleController.getString("ChannelPublicEmptyUsername",
                                    R.string.ChannelPublicEmptyUsername));
                            builder.setPositiveButton(LocaleController.getString("Close", R.string.Close),
                                    null);
                            showDialog(builder.create());
                            return;
                        } else {
                            if (!lastNameAvailable) {
                                Vibrator v = (Vibrator) getParentActivity()
                                        .getSystemService(Context.VIBRATOR_SERVICE);
                                if (v != null) {
                                    v.vibrate(200);
                                }
                                AndroidUtilities.shakeView(checkTextView, 2, 0);
                                return;
                            } else {
                                MessagesController.getInstance().updateChannelUserName(chatId, lastCheckName);
                            }
                        }
                    }
                    Bundle args = new Bundle();
                    args.putInt("step", 2);
                    args.putInt("chat_id", chatId);
                    presentFragment(new ChannelCreateActivity(args), true);
                } else {
                    ArrayList<TLRPC.InputUser> result = new ArrayList<>();
                    for (Integer uid : selectedContacts.keySet()) {
                        TLRPC.InputUser user = MessagesController
                                .getInputUser(MessagesController.getInstance().getUser(uid));
                        if (user != null) {
                            result.add(user);
                        }
                    }
                    MessagesController.getInstance().addUsersToChannel(chatId, result, null);
                    NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
                    Bundle args2 = new Bundle();
                    args2.putInt("chat_id", chatId);
                    presentFragment(new ChatActivity(args2), true);
                }
            }
        }
    });

    ActionBarMenu menu = actionBar.createMenu();
    doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));

    if (currentStep != 2) {
        fragmentView = new ScrollView(context);
        ScrollView scrollView = (ScrollView) fragmentView;
        scrollView.setFillViewport(true);
        linearLayout = new LinearLayout(context);
        scrollView.addView(linearLayout, new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
    } else {
        fragmentView = new LinearLayout(context);
        fragmentView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                return true;
            }
        });
        linearLayout = (LinearLayout) fragmentView;
    }
    linearLayout.setOrientation(LinearLayout.VERTICAL);

    if (currentStep == 0) {
        actionBar.setTitle(LocaleController.getString("NewChannel", R.string.NewChannel));
        fragmentView.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background));
        FrameLayout frameLayout = new FrameLayout(context);
        linearLayout.addView(frameLayout,
                LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

        avatarImage = new BackupImageView(context);
        avatarImage.setRoundRadius(AndroidUtilities.dp(32));
        avatarDrawable.setInfo(5, null, null, false);
        avatarDrawable.setDrawPhoto(true);
        avatarImage.setImageDrawable(avatarDrawable);
        frameLayout.addView(avatarImage,
                LayoutHelper.createFrame(64, 64,
                        Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT),
                        LocaleController.isRTL ? 0 : 16, 12, LocaleController.isRTL ? 16 : 0, 12));
        avatarImage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (getParentActivity() == null) {
                    return;
                }
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());

                CharSequence[] items;

                if (avatar != null) {
                    items = new CharSequence[] { LocaleController.getString("FromCamera", R.string.FromCamera),
                            LocaleController.getString("FromGalley", R.string.FromGalley),
                            LocaleController.getString("DeletePhoto", R.string.DeletePhoto) };
                } else {
                    items = new CharSequence[] { LocaleController.getString("FromCamera", R.string.FromCamera),
                            LocaleController.getString("FromGalley", R.string.FromGalley) };
                }

                builder.setItems(items, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        if (i == 0) {
                            avatarUpdater.openCamera();
                        } else if (i == 1) {
                            avatarUpdater.openGallery();
                        } else if (i == 2) {
                            avatar = null;
                            uploadedAvatar = null;
                            avatarImage.setImage(avatar, "50_50", avatarDrawable);
                        }
                    }
                });
                showDialog(builder.create());
            }
        });

        nameTextView = new EditText(context);
        nameTextView.setHint(LocaleController.getString("EnterChannelName", R.string.EnterChannelName));
        if (nameToSet != null) {
            nameTextView.setText(nameToSet);
            nameToSet = null;
        }
        nameTextView.setMaxLines(4);
        nameTextView
                .setGravity(Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
        nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
        //nameTextView.setHintTextColor(0xff979797);
        nameTextView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
        nameTextView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
        InputFilter[] inputFilters = new InputFilter[1];
        inputFilters[0] = new InputFilter.LengthFilter(100);
        nameTextView.setFilters(inputFilters);
        nameTextView.setPadding(0, 0, 0, AndroidUtilities.dp(8));
        AndroidUtilities.clearCursorDrawable(nameTextView);
        nameTextView.setTextColor(ContextCompat.getColor(context, R.color.primary_text));
        frameLayout.addView(nameTextView,
                LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT,
                        Gravity.CENTER_VERTICAL, LocaleController.isRTL ? 16 : 96, 0,
                        LocaleController.isRTL ? 96 : 16, 0));
        nameTextView.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

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

            }

            @Override
            public void afterTextChanged(Editable s) {
                avatarDrawable.setInfo(5, nameTextView.length() > 0 ? nameTextView.getText().toString() : null,
                        null, false);
                avatarImage.invalidate();
            }
        });

        descriptionTextView = new EditText(context);
        descriptionTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
        //descriptionTextView.setHintTextColor(0xff979797);
        descriptionTextView.setTextColor(ContextCompat.getColor(context, R.color.primary_text));
        descriptionTextView.setPadding(0, 0, 0, AndroidUtilities.dp(6));
        descriptionTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
        descriptionTextView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
                | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
        descriptionTextView.setImeOptions(EditorInfo.IME_ACTION_DONE);
        inputFilters = new InputFilter[1];
        inputFilters[0] = new InputFilter.LengthFilter(120);
        descriptionTextView.setFilters(inputFilters);
        descriptionTextView
                .setHint(LocaleController.getString("DescriptionPlaceholder", R.string.DescriptionPlaceholder));
        AndroidUtilities.clearCursorDrawable(descriptionTextView);
        linearLayout.addView(descriptionTextView,
                LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 24, 18, 24, 0));
        descriptionTextView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
                if (i == EditorInfo.IME_ACTION_DONE && doneButton != null) {
                    doneButton.performClick();
                    return true;
                }
                return false;
            }
        });
        descriptionTextView.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {

            }

            @Override
            public void afterTextChanged(Editable editable) {

            }
        });

        TextView helpTextView = new TextView(context);
        helpTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
        //helpTextView.setTextColor(0xff6d6d72);
        helpTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
        helpTextView.setText(LocaleController.getString("DescriptionInfo", R.string.DescriptionInfo));
        linearLayout.addView(helpTextView,
                LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT,
                        LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 24, 10, 24, 20));
    } else if (currentStep == 1) {
        actionBar.setTitle(LocaleController.getString("ChannelSettings", R.string.ChannelSettings));
        fragmentView.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background));

        LinearLayout linearLayout2 = new LinearLayout(context);
        linearLayout2.setOrientation(LinearLayout.VERTICAL);
        linearLayout2.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background));
        linearLayout2.setElevation(AndroidUtilities.dp(2));
        linearLayout.addView(linearLayout2,
                LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

        radioButtonCell1 = new RadioButtonCell(context);
        radioButtonCell1.setElevation(0);
        radioButtonCell1.setForeground(R.drawable.list_selector);
        radioButtonCell1.setTextAndValue(LocaleController.getString("ChannelPublic", R.string.ChannelPublic),
                LocaleController.getString("ChannelPublicInfo", R.string.ChannelPublicInfo), !isPrivate, false);
        linearLayout2.addView(radioButtonCell1,
                LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
        radioButtonCell1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!isPrivate) {
                    return;
                }
                isPrivate = false;
                updatePrivatePublic();
            }
        });

        radioButtonCell2 = new RadioButtonCell(context);
        radioButtonCell2.setElevation(0);
        radioButtonCell2.setForeground(R.drawable.list_selector);
        radioButtonCell2.setTextAndValue(LocaleController.getString("ChannelPrivate", R.string.ChannelPrivate),
                LocaleController.getString("ChannelPrivateInfo", R.string.ChannelPrivateInfo), isPrivate,
                false);
        linearLayout2.addView(radioButtonCell2,
                LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
        radioButtonCell2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (isPrivate) {
                    return;
                }
                isPrivate = true;
                updatePrivatePublic();
            }
        });

        sectionCell = new ShadowSectionCell(context);
        linearLayout.addView(sectionCell,
                LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

        linkContainer = new LinearLayout(context);
        linkContainer.setOrientation(LinearLayout.VERTICAL);
        linkContainer.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background));
        linkContainer.setElevation(AndroidUtilities.dp(2));
        linearLayout.addView(linkContainer,
                LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

        headerCell = new HeaderCell(context);
        linkContainer.addView(headerCell);

        publicContainer = new LinearLayout(context);
        publicContainer.setOrientation(LinearLayout.HORIZONTAL);
        linkContainer.addView(publicContainer,
                LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 17, 7, 17, 0));

        EditText editText = new EditText(context);
        editText.setText("telegram.me/");
        editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
        //editText.setHintTextColor(0xff979797);
        editText.setTextColor(ContextCompat.getColor(context, R.color.primary_text));
        editText.setMaxLines(1);
        editText.setLines(1);
        editText.setEnabled(false);
        editText.setBackgroundDrawable(null);
        editText.setPadding(0, 0, 0, 0);
        editText.setSingleLine(true);
        editText.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
        editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
        publicContainer.addView(editText, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 36));

        nameTextView = new EditText(context);
        nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
        //nameTextView.setHintTextColor(0xff979797);
        nameTextView.setTextColor(ContextCompat.getColor(context, R.color.primary_text));
        nameTextView.setMaxLines(1);
        nameTextView.setLines(1);
        nameTextView.setBackgroundDrawable(null);
        nameTextView.setPadding(0, 0, 0, 0);
        nameTextView.setSingleLine(true);
        nameTextView.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
                | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
        nameTextView.setImeOptions(EditorInfo.IME_ACTION_DONE);
        nameTextView.setHint(
                LocaleController.getString("ChannelUsernamePlaceholder", R.string.ChannelUsernamePlaceholder));
        AndroidUtilities.clearCursorDrawable(nameTextView);
        publicContainer.addView(nameTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36));
        nameTextView.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
                checkUserName(nameTextView.getText().toString());
            }

            @Override
            public void afterTextChanged(Editable editable) {

            }
        });

        privateContainer = new TextBlockCell(context);
        privateContainer.setForeground(R.drawable.list_selector);
        privateContainer.setElevation(0);
        linkContainer.addView(privateContainer);
        privateContainer.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (invite == null) {
                    return;
                }
                try {
                    android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext
                            .getSystemService(Context.CLIPBOARD_SERVICE);
                    android.content.ClipData clip = android.content.ClipData.newPlainText("label", invite.link);
                    clipboard.setPrimaryClip(clip);
                    Toast.makeText(getParentActivity(),
                            LocaleController.getString("LinkCopied", R.string.LinkCopied), Toast.LENGTH_SHORT)
                            .show();
                } catch (Exception e) {
                    FileLog.e("tmessages", e);
                }
            }
        });

        checkTextView = new TextView(context);
        checkTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
        checkTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
        checkTextView.setVisibility(View.GONE);
        linkContainer.addView(checkTextView,
                LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT,
                        LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 17, 3, 17, 7));

        typeInfoCell = new TextInfoPrivacyCell(context);
        //typeInfoCell.setBackgroundResource(R.drawable.greydivider_bottom);
        linearLayout.addView(typeInfoCell,
                LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

        loadingAdminedCell = new LoadingCell(context);
        linearLayout.addView(loadingAdminedCell,
                LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

        adminedInfoCell = new TextInfoPrivacyCell(context);
        //adminedInfoCell.setBackgroundResource(R.drawable.greydivider_bottom);
        linearLayout.addView(adminedInfoCell,
                LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

        updatePrivatePublic();
    } else if (currentStep == 2) {
        actionBar.setTitle(LocaleController.getString("ChannelAddMembers", R.string.ChannelAddMembers));
        actionBar.setSubtitle(LocaleController.formatPluralString("Members", selectedContacts.size()));

        searchListViewAdapter = new SearchAdapter(context, null, false, false, false, false);
        searchListViewAdapter.setCheckedMap(selectedContacts);
        searchListViewAdapter.setUseUserCell(true);
        listViewAdapter = new ContactsAdapter(context, 1, false, null, false);
        listViewAdapter.setCheckedMap(selectedContacts);

        FrameLayout frameLayout = new FrameLayout(context);
        frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.chat_list_background));

        linearLayout.addView(frameLayout,
                LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

        nameTextView = new EditText(context);
        nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
        //nameTextView.setHintTextColor(0xff979797);
        nameTextView.setTextColor(ContextCompat.getColor(context, R.color.primary_text));
        nameTextView.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
                | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
        nameTextView.setMinimumHeight(AndroidUtilities.dp(54));
        nameTextView.setSingleLine(false);
        nameTextView.setLines(2);
        nameTextView.setMaxLines(2);
        nameTextView.setVerticalScrollBarEnabled(true);
        nameTextView.setHorizontalScrollBarEnabled(false);
        nameTextView.setPadding(0, 0, 0, 0);
        nameTextView.setHint(LocaleController.getString("AddMutual", R.string.AddMutual));
        nameTextView.setTextIsSelectable(false);
        nameTextView.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
        nameTextView
                .setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
        AndroidUtilities.clearCursorDrawable(nameTextView);
        frameLayout.addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
                LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 10, 0, 10, 0));

        nameTextView.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int start, int count, int after) {
                if (!ignoreChange) {
                    beforeChangeIndex = nameTextView.getSelectionStart();
                    changeString = new SpannableString(charSequence);
                }
            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {

            }

            @Override
            public void afterTextChanged(Editable editable) {
                if (!ignoreChange) {
                    boolean search = false;
                    int afterChangeIndex = nameTextView.getSelectionEnd();
                    if (editable.toString().length() < changeString.toString().length()) {
                        String deletedString = "";
                        try {
                            deletedString = changeString.toString().substring(afterChangeIndex,
                                    beforeChangeIndex);
                        } catch (Exception e) {
                            FileLog.e("tmessages", e);
                        }
                        if (deletedString.length() > 0) {
                            if (searching && searchWas) {
                                search = true;
                            }
                            Spannable span = nameTextView.getText();
                            for (int a = 0; a < allSpans.size(); a++) {
                                ChipSpan sp = allSpans.get(a);
                                if (span.getSpanStart(sp) == -1) {
                                    allSpans.remove(sp);
                                    selectedContacts.remove(sp.uid);
                                }
                            }
                            actionBar.setSubtitle(
                                    LocaleController.formatPluralString("Members", selectedContacts.size()));
                            listView.invalidateViews();
                        } else {
                            search = true;
                        }
                    } else {
                        search = true;
                    }
                    if (search) {
                        String text = nameTextView.getText().toString().replace("<", "");
                        if (text.length() != 0) {
                            searching = true;
                            searchWas = true;
                            if (listView != null) {
                                listView.setAdapter(searchListViewAdapter);
                                searchListViewAdapter.notifyDataSetChanged();
                                listView.setFastScrollAlwaysVisible(false);
                                listView.setFastScrollEnabled(false);
                                listView.setVerticalScrollBarEnabled(true);
                            }
                            if (emptyTextView != null) {
                                emptyTextView
                                        .setText(LocaleController.getString("NoResult", R.string.NoResult));
                            }
                            searchListViewAdapter.searchDialogs(text);
                        } else {
                            searchListViewAdapter.searchDialogs(null);
                            searching = false;
                            searchWas = false;
                            listView.setAdapter(listViewAdapter);
                            listViewAdapter.notifyDataSetChanged();
                            listView.setFastScrollAlwaysVisible(true);
                            listView.setFastScrollEnabled(true);
                            listView.setVerticalScrollBarEnabled(false);
                            emptyTextView
                                    .setText(LocaleController.getString("NoContacts", R.string.NoContacts));
                        }
                    }
                }
            }
        });

        LinearLayout emptyTextLayout = new LinearLayout(context);
        emptyTextLayout.setVisibility(View.INVISIBLE);
        emptyTextLayout.setOrientation(LinearLayout.VERTICAL);
        linearLayout.addView(emptyTextLayout,
                LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
        emptyTextLayout.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                return true;
            }
        });

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

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

        listView = new LetterSectionsListView(context);
        listView.setEmptyView(emptyTextLayout);
        listView.setVerticalScrollBarEnabled(false);
        listView.setDivider(null);
        listView.setDividerHeight(0);
        listView.setFastScrollEnabled(true);
        listView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
        listView.setAdapter(listViewAdapter);
        listView.setFastScrollAlwaysVisible(true);
        listView.setVerticalScrollbarPosition(
                LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
        linearLayout.addView(listView,
                LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                TLRPC.User user;
                if (searching && searchWas) {
                    user = (TLRPC.User) searchListViewAdapter.getItem(i);
                } else {
                    int section = listViewAdapter.getSectionForPosition(i);
                    int row = listViewAdapter.getPositionInSectionForPosition(i);
                    if (row < 0 || section < 0) {
                        return;
                    }
                    user = (TLRPC.User) listViewAdapter.getItem(section, row);
                }
                if (user == null) {
                    return;
                }

                boolean check = true;
                if (selectedContacts.containsKey(user.id)) {
                    check = false;
                    try {
                        ChipSpan span = selectedContacts.get(user.id);
                        selectedContacts.remove(user.id);
                        SpannableStringBuilder text = new SpannableStringBuilder(nameTextView.getText());
                        text.delete(text.getSpanStart(span), text.getSpanEnd(span));
                        allSpans.remove(span);
                        ignoreChange = true;
                        nameTextView.setText(text);
                        nameTextView.setSelection(text.length());
                        ignoreChange = false;
                    } catch (Exception e) {
                        FileLog.e("tmessages", e);
                    }
                } else {
                    ignoreChange = true;
                    ChipSpan span = createAndPutChipForUser(user);
                    if (span != null) {
                        span.uid = user.id;
                    }
                    ignoreChange = false;
                    if (span == null) {
                        return;
                    }
                }
                actionBar.setSubtitle(LocaleController.formatPluralString("Members", selectedContacts.size()));
                if (searching || searchWas) {
                    ignoreChange = true;
                    SpannableStringBuilder ssb = new SpannableStringBuilder("");
                    for (ImageSpan sp : allSpans) {
                        ssb.append("<<");
                        ssb.setSpan(sp, ssb.length() - 2, ssb.length(),
                                SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
                    }
                    nameTextView.setText(ssb);
                    nameTextView.setSelection(ssb.length());
                    ignoreChange = false;

                    searchListViewAdapter.searchDialogs(null);
                    searching = false;
                    searchWas = false;
                    listView.setAdapter(listViewAdapter);
                    listViewAdapter.notifyDataSetChanged();
                    listView.setFastScrollAlwaysVisible(true);
                    listView.setFastScrollEnabled(true);
                    listView.setVerticalScrollBarEnabled(false);
                    emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
                } else {
                    if (view instanceof UserCell) {
                        ((UserCell) view).setChecked(check, true);
                    }
                }
            }
        });
        listView.setOnScrollListener(new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView absListView, int i) {
                if (i == SCROLL_STATE_TOUCH_SCROLL) {
                    AndroidUtilities.hideKeyboard(nameTextView);
                }
                if (listViewAdapter != null) {
                    listViewAdapter.setIsScrolling(i != SCROLL_STATE_IDLE);
                }
            }

            @Override
            public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount,
                    int totalItemCount) {
                if (absListView.isFastScrollEnabled()) {
                    AndroidUtilities.clearDrawableAnimation(absListView);
                }
            }
        });
    }

    return fragmentView;
}