Search in sources :

Example 6 with RequestFactory

use of com.huetoyou.chatexchange.net.RequestFactory in project ChatExchange by HueToYou.

the class ChatFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    view = inflater.inflate(R.layout.fragment_chat, container, false);
    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
    mRequestFactory = new RequestFactory("t=NETipskrs%2bbmhDM1HqswLwfyvDthu2SS");
    messageToSend = view.findViewById(R.id.messageToSend);
    pingSuggestionsScrollView = view.findViewById(R.id.pingSuggestionsScrollView);
    mFragmentManager = getFragmentManager();
    mSlidingMenu = ((MainActivity) getActivity()).getCurrentUsers_SlidingMenu();
    mRefreshLayout = mSlidingMenu.findViewById(R.id.users_refresh_view);
    mRefreshLayout.setScrollContainer(true);
    mRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            doUserParse();
        }
    });
    messageToSend.setOnFocusChangeListener(new View.OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                pingSuggestionsScrollView.setVisibility(View.VISIBLE);
            }
        }
    });
    Bundle args = getArguments();
    mChatUrl = args.getString("chatUrl", "ERROR");
    mChatTitle = args.getString("chatTitle", "ERROR");
    mChatId = args.getInt("chatId", -1);
    mAppBarColor = args.getInt("chatColor", -1);
    showThatFam();
    addChatButtons(mChatUrl);
    mRequestFactory.get(mChatUrl, true, new RequestFactory.Listener() {

        @Override
        public void onSucceeded(URL url, String data) {
            GetDesc getDesc = GetDesc.newInstance(new DescGotten() {

                @Override
                public void onSuccess(String desc) {
                    mChatDesc = Html.fromHtml("<b>Desc: </b>" + desc);
                }

                @Override
                public void onFail(String message) {
                }
            });
            getDesc.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, data);
            GetTags getTags = GetTags.newInstance(new TagsGotten() {

                @Override
                public void onSuccess(ArrayList<String> tabList) {
                    mChatTags = tabList;
                    new Thread(new Runnable() {

                        @Override
                        public void run() {
                            String tags = "";
                            if (mChatTags != null) {
                                tags = mChatTags.toString();
                                tags = tags.replace("[", "").replace("]", "");
                            }
                            mChatTagsSpanned = Html.fromHtml("<b>Tags: </b>" + tags);
                        }
                    }).start();
                }

                @Override
                public void onFail(String message) {
                }
            });
            getTags.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, data);
        }

        @Override
        public void onFailed(String message) {
        }
    });
    doUserParse();
    getActivity().setTitle(mChatTitle);
    setupMessagePingList();
    setupMessages();
    mChatDomain = mSharedPreferences.getString(CHAT_HOST_DOMAIN.concat(mChatUrl), null);
    if (mChatDomain == null || mChatDomain.isEmpty()) {
        if (mChatUrl.contains("overflow")) {
            mChatDomain = "stackoverflow.com";
        } else {
            mRequestFactory.get(mChatUrl, true, new RequestFactory.Listener() {

                @Override
                public void onSucceeded(URL url, String data) {
                    GetHostDomainFromHtml.newInstance(new DomainFoundListener() {

                        @Override
                        public void onSuccess(String text) {
                            mSharedPreferences.edit().putString(CHAT_HOST_DOMAIN.concat(mChatUrl), text).apply();
                            mChatDomain = text;
                        }

                        @Override
                        public void onFail(String text) {
                            mChatDomain = text;
                        }
                    }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, data);
                }

                @Override
                public void onFailed(String message) {
                    Log.e("WHOOPS", message);
                    mChatDomain = "Not Found";
                }
            });
        }
    }
    oncreateHasBeenCalled = true;
    TutorialStuff.chatFragTutorial(getActivity(), view, mAppBarColor);
    return view;
}
Also used : Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) HorizontalScrollView(android.widget.HorizontalScrollView) View(android.view.View) TextView(android.widget.TextView) URL(java.net.URL) RequestFactory(com.huetoyou.chatexchange.net.RequestFactory)

Example 7 with RequestFactory

use of com.huetoyou.chatexchange.net.RequestFactory in project ChatExchange by HueToYou.

the class ChatroomsExplorationActivity method normalOnCreate.

private void normalOnCreate() {
    hueNetworkStatusChanged = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
                new RequestFactory().get("http://www.google.com/", true, new RequestFactory.Listener() {

                    @Override
                    public void onSucceeded(URL url, String data) {
                    }

                    @Override
                    public void onFailed(String message) {
                        Intent hueIntent = new Intent(ChatroomsExplorationActivity.this, OfflineActivity.class);
                        startActivity(hueIntent);
                        finish();
                    }
                });
            }
        }
    };
    this.registerReceiver(hueNetworkStatusChanged, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
    setContentView(R.layout.activity_chatrooms_exploration);
    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());
    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    // Set up the action bar.
    final android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(android.support.v7.app.ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayHomeAsUpEnabled(true);
    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });
    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by
        // the adapter. Also specify this Activity object, which implements
        // the TabListener interface, as the callback (listener) for when
        // this tab is selected.
        actionBar.addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
    ActionBarHue.setActionBarColorToSharedPrefsValue(this);
    ActionBarHue.setTabBarColorToSharedPrefsValue(this);
    ViewGroup viewGroup = (ViewGroup) getWindow().getDecorView();
    LinearLayout testb = (LinearLayout) viewGroup.getChildAt(0);
    FrameLayout testc = (FrameLayout) testb.getChildAt(1);
    ActionBarOverlayLayout testd = (ActionBarOverlayLayout) testc.getChildAt(0);
    ActionBarContainer teste = (ActionBarContainer) testd.getChildAt(1);
    LinearLayoutCompat testg;
    if (getResources().getConfiguration().orientation == ORIENTATION_PORTRAIT) {
        ScrollingTabContainerView testf = (ScrollingTabContainerView) teste.getChildAt(2);
        testg = (LinearLayoutCompat) testf.getChildAt(0);
    } else // Landscape
    {
        Toolbar teste2 = (Toolbar) teste.getChildAt(0);
        ScrollingTabContainerView testf = (ScrollingTabContainerView) teste2.getChildAt(0);
        testg = (LinearLayoutCompat) testf.getChildAt(0);
    }
    testg.setId(android.R.id.tabcontent);
    // String IdAsString = testg.getResources().getResourceName(testg.getId());
    // Log.e("TestG", IdAsString);
    TutorialStuff.chatsExplorationTutorial(this, testg);
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) ActionBarContainer(android.support.v7.widget.ActionBarContainer) ViewGroup(android.view.ViewGroup) Intent(android.content.Intent) ActionBarOverlayLayout(android.support.v7.widget.ActionBarOverlayLayout) BroadcastReceiver(android.content.BroadcastReceiver) ViewPager(android.support.v4.view.ViewPager) URL(java.net.URL) LinearLayoutCompat(android.support.v7.widget.LinearLayoutCompat) RequestFactory(com.huetoyou.chatexchange.net.RequestFactory) FrameLayout(android.widget.FrameLayout) ScrollingTabContainerView(android.support.v7.widget.ScrollingTabContainerView) LinearLayout(android.widget.LinearLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 8 with RequestFactory

use of com.huetoyou.chatexchange.net.RequestFactory in project ChatExchange by HueToYou.

the class ChatroomsExplorationActivity method onResume.

@Override
protected void onResume() {
    super.onResume();
    new RequestFactory().get("http://www.google.com/", true, new RequestFactory.Listener() {

        @Override
        public void onSucceeded(URL url, String data) {
            registerReceiver(hueNetworkStatusChanged, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
        }

        @Override
        public void onFailed(String message) {
            Intent intent = new Intent(ChatroomsExplorationActivity.this, OfflineActivity.class);
            startActivity(intent);
            finish();
        }
    });
}
Also used : IntentFilter(android.content.IntentFilter) RequestFactory(com.huetoyou.chatexchange.net.RequestFactory) Intent(android.content.Intent) URL(java.net.URL)

Aggregations

RequestFactory (com.huetoyou.chatexchange.net.RequestFactory)8 Intent (android.content.Intent)5 URL (java.net.URL)5 IntentFilter (android.content.IntentFilter)2 Bundle (android.os.Bundle)2 View (android.view.View)2 AccountManagerCallback (android.accounts.AccountManagerCallback)1 AccountManagerFuture (android.accounts.AccountManagerFuture)1 ObjectAnimator (android.animation.ObjectAnimator)1 BroadcastReceiver (android.content.BroadcastReceiver)1 Context (android.content.Context)1 ViewPager (android.support.v4.view.ViewPager)1 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 ActionBarContainer (android.support.v7.widget.ActionBarContainer)1 ActionBarOverlayLayout (android.support.v7.widget.ActionBarOverlayLayout)1 ActionMenuView (android.support.v7.widget.ActionMenuView)1 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)1 LinearLayoutCompat (android.support.v7.widget.LinearLayoutCompat)1 RecyclerView (android.support.v7.widget.RecyclerView)1 ScrollingTabContainerView (android.support.v7.widget.ScrollingTabContainerView)1