cz.msebera.android.httpclient.util.TextUtils Java Examples

The following examples show how to use cz.msebera.android.httpclient.util.TextUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FeedFragment.java    From Instagram-Profile-Downloader with MIT License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_feed, container, false);
    recyclerView = view.findViewById(R.id.recycler_view);
    storiesRecyclerView = view.findViewById(R.id.storiesRecyclerView);
    noDataText = view.findViewById(R.id.noDataText);

    feedAdapter = new FeedAdapter(getActivity(),recyclerView);
    RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getContext());
    recyclerView.setLayoutManager(mLayoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setAdapter(feedAdapter);
    if (edgeList != null && edgeList.size() > 0)
        feedAdapter.setEdges(edgeList);


    if (!TextUtils.isEmpty(username)) {
        showLoading();
        new RequestInstagramAPI(ApiUtils.getUsernameUrl(username)).execute();
    } else {
        noDataText.setVisibility(View.VISIBLE);
    }
    return view;
}
 
Example #2
Source File: HtmlUnitDomainHandler.java    From HtmlUnit-Android with Apache License 2.0 6 votes vote down vote up
@Override
public void parse(final SetCookie cookie, final String value)
        throws MalformedCookieException {
    Args.notNull(cookie, HttpHeader.COOKIE);
    if (TextUtils.isBlank(value)) {
        throw new MalformedCookieException("Blank or null value for domain attribute");
    }
    // Ignore domain attributes ending with '.' per RFC 6265, 4.1.2.3
    if (value.endsWith(".")) {
        return;
    }
    String domain = value;
    domain = domain.toLowerCase(Locale.ROOT);

    final int dotIndex = domain.indexOf('.');
    if (browserVersion_.hasFeature(HTTP_COOKIE_REMOVE_DOT_FROM_ROOT_DOMAINS)
            && dotIndex == 0 && domain.length() > 1 && domain.indexOf('.', 1) == -1) {
        domain = domain.toLowerCase(Locale.ROOT);
        domain = domain.substring(1);
    }
    if (dotIndex > 0) {
        domain = '.' + domain;
    }

    cookie.setDomain(domain);
}
 
Example #3
Source File: ProfileFragment.java    From Instagram-Profile-Downloader with MIT License 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_profile, container, false);
    recyclerView = view.findViewById(R.id.recycler_view);
    noDataText = view.findViewById(R.id.noDataText);
    fullNameText = view.findViewById(R.id.fullName);
    profileImageView = view.findViewById(R.id.profileImageView);

    bioText = view.findViewById(R.id.bio);
    posts = view.findViewById(R.id.posts);
    followedBy = view.findViewById(R.id.followedBy);
    followsText = view.findViewById(R.id.follows);
    if (!TextUtils.isEmpty(fullName))
        fullNameText.setText(fullName);

    if (!TextUtils.isEmpty(bio))
        bioText.setText(bio);

    if (!TextUtils.isEmpty(String.valueOf(media)))
        posts.setText(String.valueOf(media));

    if (!TextUtils.isEmpty(String.valueOf(followed_by)))
        followedBy.setText(String.valueOf(followed_by));

    if (!TextUtils.isEmpty(String.valueOf(follows)))
        followsText.setText(String.valueOf(follows));

    if (!TextUtils.isEmpty(String.valueOf(profile_image)))
        Glide.with(context).load(profile_image).into(profileImageView);

    userProfileAdapter = new UserProfileAdapter(getContext(),recyclerView);
    recyclerView.setLayoutManager(new GridLayoutManager(context, 3));
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setAdapter(userProfileAdapter);
    if (edgeList != null && edgeList.size() > 0)
        userProfileAdapter.setEdges(edgeList);


    if (!TextUtils.isEmpty(username)) {
        showLoading();
        new RequestInstagramAPI(ApiUtils.getUsernameUrl(username)).execute();
    } else {
        noDataText.setVisibility(View.VISIBLE);
    }
    adContainer = view.findViewById(R.id.adContainer);
    showBannerAd();
    return view;
}
 
Example #4
Source File: DownloadProfileImageActivity.java    From Instagram-Profile-Downloader with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = this;
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_download_profile_image);
    username = findViewById(R.id.username);
    search = findViewById(R.id.search);
    progress_bar = findViewById(R.id.progress_bar);
    back = findViewById(R.id.back);
    adContainer = findViewById(R.id.adContainer);


    toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setTitle(getString(R.string.lbl_how_to_use));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(getString(R.string.lbl_download_profile_image));

    loadFullscreenAd();
    loadFbFullscreenAd();
    showBannerAd();
    openInstagram = findViewById(R.id.openInstagram);
    information = findViewById(R.id.information);
    history = findViewById(R.id.history);
    history.setOnClickListener(v -> {
        startActivity(new Intent(DownloadProfileImageActivity.this, DownloadHistoryActivity.class));
    });
    information.setOnClickListener(v -> {
        startActivity(new Intent(DownloadProfileImageActivity.this, HowToUseActivity.class));
    });

    search.setOnClickListener(v -> {
        if (TextUtils.isEmpty(username.getText().toString()))
            ToastUtils.ErrorToast(context, "Username field can't be empty");
        else if (username.getText().toString().contains(" "))
            ToastUtils.ErrorToast(context, "Invalid Username");
        else {
            usernameText = username.getText().toString();
            progress_bar.setVisibility(View.VISIBLE);
            new RequestInstagramAPI(ApiUtils.getUsernameUrl(usernameText)).execute();
        }

    });


    openInstagram.setOnClickListener(v -> {
        String _username = username.getText().toString();
        if (TextUtils.isEmpty(_username)) {
            ToastUtils.ErrorToast(context, "Username field can't be empty");
        } else {
            final String appLink = "http://instagram.com/_u/" + _username;
            final String webLink = "http://instagram.com/" + _username;

            Uri uri = Uri.parse(appLink);
            Intent insta = new Intent(Intent.ACTION_VIEW, uri);
            insta.setPackage("com.instagram.android");

            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(webLink)));

        }
    });

    back.setOnClickListener(v -> {
        onBackPressed();
    });
}
 
Example #5
Source File: HttpWebConnection.java    From HtmlUnit-Android with Apache License 2.0 4 votes vote down vote up
private static String[] split(final String s) {
    if (TextUtils.isBlank(s)) {
        return null;
    }
    return s.split(" *, *");
}
 
Example #6
Source File: InfinityPlModule.java    From Overchan-Android with GNU General Public License v3.0 4 votes vote down vote up
@Override
public String sendPost(SendPostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    if (task != null && task.isCancelled()) throw new InterruptedException("interrupted");
    String url = getUsingUrl() + "post.php";
    ExtendedMultipartBuilder postEntityBuilder = ExtendedMultipartBuilder.create().setDelegates(listener, task).
            addString("name", model.name).
            addString("email", model.sage ? "sage" : model.email).
            addString("subject", model.subject).
            addString("body", model.comment).
            addString("post", model.threadNumber == null ? "New Topic" : "New Reply").
            addString("board", model.boardName);
    if (model.threadNumber != null) postEntityBuilder.addString("thread", model.threadNumber);
    if (model.custommark) postEntityBuilder.addString("spoiler", "on");
    postEntityBuilder.addString("password", TextUtils.isEmpty(model.password) ? getDefaultPassword() : model.password).
            addString("message", "").
            addString("json_response", "1");
    if (model.attachments != null) {
        String[] images = new String[] { "file", "file2", "file3", "file4", "file5" };
        for (int i=0; i<model.attachments.length; ++i) {
            postEntityBuilder.addFile(images[i], model.attachments[i], model.randomHash);
        }
    }
    
    UrlPageModel refererPage = new UrlPageModel();
    refererPage.chanName = getChanName();
    refererPage.boardName = model.boardName;
    if (model.threadNumber == null) {
        refererPage.type = UrlPageModel.TYPE_BOARDPAGE;
        refererPage.boardPage = UrlPageModel.DEFAULT_FIRST_PAGE;
    } else {
        refererPage.type = UrlPageModel.TYPE_THREADPAGE;
        refererPage.threadNumber = model.threadNumber;
    }
    Header[] customHeaders = new Header[] { new BasicHeader(HttpHeaders.REFERER, buildUrl(refererPage)) };
    HttpRequestModel request =
            HttpRequestModel.builder().setPOST(postEntityBuilder.build()).setCustomHeaders(customHeaders).setNoRedirect(true).build();
    JSONObject json = HttpStreamer.getInstance().getJSONObjectFromUrl(url, request, httpClient, listener, task, false);
    if (json.has("error")) {
        String error = json.getString("error");
        if (error.contains("To post on 8chan over Tor, you must use the hidden service for security reasons."))
            throw new Exception("To post on 8chan over Tor, you must use the onion domain.");
        throw new Exception(error);
    } else {
        String redirect = json.optString("redirect", "");
        if (redirect.length() > 0) return fixRelativeUrl(redirect);
        return null;
    }
}