Search in sources :

Example 1 with VISIBLE

use of android.view.View.VISIBLE in project twicalico by moko256.

the class ShowTweetActivity method updateView.

private void updateView(Status item) {
    TextView tweetIsReply = findViewById(R.id.tweet_show_is_reply_text);
    long replyTweetId = item.getInReplyToStatusId();
    if (replyTweetId != -1) {
        tweetIsReply.setVisibility(VISIBLE);
        tweetIsReply.setOnClickListener(v -> startActivity(getIntent(this, replyTweetId)));
    } else {
        tweetIsReply.setVisibility(GONE);
    }
    StatusView statusView = new StatusView(this);
    statusView.setStatus(item);
    ViewGroup cview = (ViewGroup) statusView.getChildAt(0);
    ViewGroup sview = (ViewGroup) cview.getChildAt(0);
    cview.removeView(sview);
    FrameLayout statusViewFrame = findViewById(R.id.tweet_show_tweet);
    statusViewFrame.removeAllViews();
    statusViewFrame.addView(sview);
    ((TextView) findViewById(R.id.tweet_show_timestamp)).setText(DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(item.getCreatedAt()));
    TextView viaText = findViewById(R.id.tweet_show_via);
    viaText.setText(TwitterStringUtils.convertUrlSpanToCustomTabs(Html.fromHtml("via:" + item.getSource()), this));
    viaText.setMovementMethod(new LinkMovementMethod());
    AppCompatEditText replyText = findViewById(R.id.tweet_show_tweet_reply_text);
    AppCompatButton replyButton = findViewById(R.id.tweet_show_tweet_reply_button);
    UserMentionEntity[] users = item.getUserMentionEntities();
    replyText.setText(TwitterStringUtils.convertToReplyTopString(GlobalApplication.userCache.get(GlobalApplication.userId).getScreenName(), item.getUser().getScreenName(), users));
    replyButton.setOnClickListener(v -> {
        replyButton.setEnabled(false);
        PostTweetModel model = PostTweetModelCreator.getInstance(GlobalApplication.twitter, getContentResolver());
        model.setTweetText(replyText.getText().toString());
        model.setInReplyToStatusId(item.getId());
        subscriptions.add(model.postTweet().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(it -> {
            replyText.setText(TwitterStringUtils.convertToReplyTopString(GlobalApplication.userCache.get(GlobalApplication.userId).getScreenName(), item.getUser().getScreenName(), users));
            replyButton.setEnabled(true);
            Toast.makeText(ShowTweetActivity.this, R.string.succeeded, Toast.LENGTH_SHORT).show();
        }, e -> {
            e.printStackTrace();
            Toast.makeText(ShowTweetActivity.this, R.string.error_occurred, Toast.LENGTH_SHORT).show();
            replyButton.setEnabled(true);
        }));
    });
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) PostTweetModel(com.github.moko256.twicalico.model.base.PostTweetModel) FrameLayout(android.widget.FrameLayout) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) Intent(android.content.Intent) LinkMovementMethod(android.text.method.LinkMovementMethod) TwitterStringUtils(com.github.moko256.twicalico.text.TwitterStringUtils) UserMentionEntity(twitter4j.UserMentionEntity) MenuItem(android.view.MenuItem) AppCompatButton(android.support.v7.widget.AppCompatButton) Single(rx.Single) AppCustomTabsKt(com.github.moko256.twicalico.intent.AppCustomTabsKt) Toast(android.widget.Toast) Menu(android.view.Menu) Schedulers(rx.schedulers.Schedulers) TwitterException(twitter4j.TwitterException) VISIBLE(android.view.View.VISIBLE) ActionBar(android.support.v7.app.ActionBar) DateFormat(java.text.DateFormat) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) StatusCacheMap(com.github.moko256.twicalico.cacheMap.StatusCacheMap) AppCompatActivity(android.support.v7.app.AppCompatActivity) ViewGroup(android.view.ViewGroup) CompositeSubscription(rx.subscriptions.CompositeSubscription) TextView(android.widget.TextView) GONE(android.view.View.GONE) Html(android.text.Html) Status(twitter4j.Status) PostTweetModelCreator(com.github.moko256.twicalico.model.impl.PostTweetModelCreator) AppCompatEditText(android.support.v7.widget.AppCompatEditText) AppCompatEditText(android.support.v7.widget.AppCompatEditText) UserMentionEntity(twitter4j.UserMentionEntity) ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) LinkMovementMethod(android.text.method.LinkMovementMethod) TextView(android.widget.TextView) PostTweetModel(com.github.moko256.twicalico.model.base.PostTweetModel) AppCompatButton(android.support.v7.widget.AppCompatButton)

Aggregations

Context (android.content.Context)1 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 ActionBar (android.support.v7.app.ActionBar)1 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 AppCompatButton (android.support.v7.widget.AppCompatButton)1 AppCompatEditText (android.support.v7.widget.AppCompatEditText)1 Html (android.text.Html)1 LinkMovementMethod (android.text.method.LinkMovementMethod)1 Menu (android.view.Menu)1 MenuItem (android.view.MenuItem)1 GONE (android.view.View.GONE)1 VISIBLE (android.view.View.VISIBLE)1 ViewGroup (android.view.ViewGroup)1 FrameLayout (android.widget.FrameLayout)1 TextView (android.widget.TextView)1 Toast (android.widget.Toast)1 StatusCacheMap (com.github.moko256.twicalico.cacheMap.StatusCacheMap)1 AppCustomTabsKt (com.github.moko256.twicalico.intent.AppCustomTabsKt)1