Search in sources :

Example 1 with GONE

use of android.view.View.GONE 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)

Example 2 with GONE

use of android.view.View.GONE in project zype-android by zype.

the class VideosAdapter method updatePopupMenu.

private void updatePopupMenu(final ViewHolder holder) {
    final ArrayList<VideosMenuItem> items = new ArrayList<>(getPopupMenuItems(holder));
    View.OnClickListener listener = view -> {
        holder.view.showContextMenu();
        final VideoMenuDialogFragment fragment = VideoMenuDialogFragment.newInstance(items);
        fragment.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Map<String, String> event;
                Tracker tracker = ZypeApp.getTracker();
                switch(fragment.getList().get(position).getId()) {
                    case ITEM_UNFAVORITE:
                        if (menuListener != null) {
                            menuListener.onMenuItemSelected(VideoActionsHelper.ACTION_UNFAVORITE, holder.item);
                        }
                        // VideoActionsHelper.onUnfavorite(holder.item, (Activity) holder.view.getContext(), null);
                        event = new HitBuilders.EventBuilder().setAction("Unfavorite").setLabel("id=" + holder.item.id).build();
                        break;
                    case ITEM_FAVORITE:
                        if (menuListener != null) {
                            menuListener.onMenuItemSelected(VideoActionsHelper.ACTION_FAVORITE, holder.item);
                        }
                        // VideoActionsHelper.onFavorite(holder.item, (Activity) holder.view.getContext(), null);
                        event = new HitBuilders.EventBuilder().setAction("Favorite").setLabel("id=" + holder.item.id).build();
                        break;
                    case ITEM_SHARE:
                        if (menuListener != null) {
                            menuListener.onMenuItemSelected(VideoActionsHelper.ACTION_SHARE, holder.item);
                        }
                        // videoActionListener.onShareVideo(holder.item.id);
                        event = new HitBuilders.EventBuilder().setAction("Share").setLabel("id=" + holder.item.id).build();
                        break;
                    case ITEM_DOWNLOAD_STOP:
                        DownloadHelper.stopDownload(holder.view.getContext().getContentResolver(), holder.item.id);
                        event = new HitBuilders.EventBuilder().setAction("Stop Download").setLabel("id=" + holder.item.id).build();
                        break;
                    // break;
                    case ITEM_DELETE_AUDIO:
                        FileUtils.deleteAudioFile(holder.item.id, holder.view.getContext());
                        DataHelper.setAudioDeleted(holder.view.getContext().getContentResolver(), holder.item.id);
                        event = new HitBuilders.EventBuilder().setAction("Delete Downloaded Audio").setLabel("id=" + holder.item.id).build();
                        break;
                    case ITEM_DELETE_VIDEO:
                        FileUtils.deleteVideoFile(holder.item.id, holder.view.getContext());
                        DataHelper.setVideoDeleted(holder.view.getContext().getContentResolver(), holder.item.id);
                        event = new HitBuilders.EventBuilder().setAction("Delete Downloaded VideoList").setLabel("id=" + holder.item.id).build();
                        break;
                    default:
                        throw new IllegalStateException("unknown id=" + fragment.getList().get(position).getId());
                }
                fragment.dismiss();
                if (tracker != null) {
                    tracker.send(event);
                }
            }
        });
        fragment.show(((Activity) holder.view.getContext()).getFragmentManager(), "menu");
    // }
    };
    if (items.isEmpty()) {
        holder.imagePopup.setVisibility(GONE);
    } else {
        holder.imagePopup.setVisibility(View.VISIBLE);
        holder.imagePopup.setOnClickListener(listener);
    }
}
Also used : ZypeConfiguration(com.zype.android.ZypeConfiguration) Thumbnail(com.zype.android.webapi.model.video.Thumbnail) ProgressBar(android.widget.ProgressBar) VideoHelper(com.zype.android.core.provider.helpers.VideoHelper) Tracker(com.google.android.gms.analytics.Tracker) ImageView(android.widget.ImageView) VideosMenuItem(com.zype.android.ui.main.fragments.videos.VideosMenuItem) ArrayList(java.util.ArrayList) Map(java.util.Map) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) AdapterView(android.widget.AdapterView) DataHelper(com.zype.android.core.provider.DataHelper) ContextCompat(androidx.core.content.ContextCompat) HitBuilders(com.google.android.gms.analytics.HitBuilders) LayoutInflater(android.view.LayoutInflater) VideoMenuDialogFragment(com.zype.android.ui.dialog.VideoMenuDialogFragment) ZypeSettings(com.zype.android.ZypeSettings) TextUtils(android.text.TextUtils) AuthHelper(com.zype.android.Auth.AuthHelper) Image(com.zype.android.webapi.model.video.Image) UiUtils(com.zype.android.utils.UiUtils) ViewGroup(android.view.ViewGroup) DownloaderService(com.zype.android.service.DownloaderService) List(java.util.List) TextView(android.widget.TextView) FileUtils(com.zype.android.utils.FileUtils) GONE(android.view.View.GONE) R(com.zype.android.R) ZypeApp(com.zype.android.ZypeApp) DownloadHelper(com.zype.android.service.DownloadHelper) Activity(android.app.Activity) Video(com.zype.android.Db.Entity.Video) Tracker(com.google.android.gms.analytics.Tracker) VideosMenuItem(com.zype.android.ui.main.fragments.videos.VideosMenuItem) ArrayList(java.util.ArrayList) Activity(android.app.Activity) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) VideoMenuDialogFragment(com.zype.android.ui.dialog.VideoMenuDialogFragment) AdapterView(android.widget.AdapterView)

Example 3 with GONE

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

the class ShowTweetActivity method onCreate.

@SuppressLint("WrongConstant")
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_show_tweet);
    statusId = getIntent().getLongExtra("statusId", -1);
    client = GlobalApplicationKt.getClient(this);
    requestManager = Glide.with(this);
    statusActionModel = new StatusActionModelImpl(client.getApiClient(), client.getPostCache());
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeAsUpIndicator(R.drawable.ic_back_white_24dp);
    tweetIsReply = findViewById(R.id.tweet_show_is_reply_text);
    statusViewBinder = new StatusViewBinder(findViewById(R.id.tweet_show_tweet));
    timestampText = findViewById(R.id.tweet_show_timestamp);
    viaText = findViewById(R.id.tweet_show_via);
    replyFab = findViewById(R.id.tweet_show_fab);
    SwipeRefreshLayout swipeRefreshLayout = findViewById(R.id.tweet_show_swipe_refresh);
    swipeRefreshLayout.setColorSchemeResources(R.color.color_primary);
    swipeRefreshLayout.setOnRefreshListener(() -> statusActionModel.updateStatus(statusId));
    disposables.addAll(statusActionModel.getStatusObservable().subscribe(id -> {
        Post post = client.getPostCache().getPost(statusId);
        if (post != null) {
            if (!isVisible) {
                isVisible = true;
                swipeRefreshLayout.getChildAt(0).setVisibility(VISIBLE);
            }
            updateView(post);
        }
        swipeRefreshLayout.setRefreshing(false);
    }), statusActionModel.getDidActionObservable().subscribe(it -> Toast.makeText(this, TwitterStringUtils.getDidActionStringRes(client.getAccessToken().getClientType(), it), Toast.LENGTH_SHORT).show()), statusActionModel.getErrorObservable().subscribe(error -> {
        error.printStackTrace();
        Toast.makeText(this, error.getMessage(), Toast.LENGTH_LONG).show();
        swipeRefreshLayout.setRefreshing(false);
        if (client.getPostCache().getPost(statusId) == null) {
            finish();
        }
    }));
    Post status = client.getPostCache().getPost(statusId);
    if (status != null) {
        updateView(status);
    } else {
        swipeRefreshLayout.setRefreshing(true);
        isVisible = false;
        swipeRefreshLayout.getChildAt(0).setVisibility(GONE);
        statusActionModel.updateStatus(statusId);
    }
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) StatusActionModel(com.github.moko256.twitlatte.model.base.StatusActionModel) Intent(android.content.Intent) LinkMovementMethod(android.text.method.LinkMovementMethod) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) AppCustomTabsKt(com.github.moko256.twitlatte.intent.AppCustomTabsKt) MenuItem(android.view.MenuItem) ClipData(android.content.ClipData) ActionBar(androidx.appcompat.app.ActionBar) SuppressLint(android.annotation.SuppressLint) ActivityOptionsCompat(androidx.core.app.ActivityOptionsCompat) RequestManager(com.bumptech.glide.RequestManager) TwitterStringUtils(com.github.moko256.twitlatte.text.TwitterStringUtils) Toast(android.widget.Toast) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) Menu(android.view.Menu) ClipboardManager(android.content.ClipboardManager) View(android.view.View) Button(android.widget.Button) VISIBLE(android.view.View.VISIBLE) StatusActionModelImpl(com.github.moko256.twitlatte.model.impl.StatusActionModelImpl) DateFormat(java.text.DateFormat) Post(com.github.moko256.latte.client.base.entity.Post) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) Client(com.github.moko256.twitlatte.entity.Client) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Unit(kotlin.Unit) TextView(android.widget.TextView) Glide(com.bumptech.glide.Glide) GONE(android.view.View.GONE) StatusActionModelImpl(com.github.moko256.twitlatte.model.impl.StatusActionModelImpl) Post(com.github.moko256.latte.client.base.entity.Post) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) ActionBar(androidx.appcompat.app.ActionBar) SuppressLint(android.annotation.SuppressLint)

Example 4 with GONE

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

the class ShowTweetActivity method updateView.

private void updateView(Post item) {
    shareUrl = item.getStatus().getUrl();
    long replyTweetId = item.getStatus().getInReplyToStatusId();
    if (replyTweetId != -1) {
        tweetIsReply.setVisibility(VISIBLE);
        tweetIsReply.setOnClickListener(v -> startActivity(GlobalApplicationKt.setAccountKeyForActivity(getIntent(this, replyTweetId), this)));
    } else {
        tweetIsReply.setVisibility(GONE);
    }
    statusViewBinder.getTweetSpoilerText().setOnLongClickListener(v -> {
        Toast.makeText(this, R.string.did_copy, Toast.LENGTH_SHORT).show();
        ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
        clipboard.setPrimaryClip(ClipData.newPlainText("spoiler_text", item.getStatus().getSpoilerText()));
        return true;
    });
    statusViewBinder.getTweetContext().setOnLongClickListener(v -> {
        Toast.makeText(this, R.string.did_copy, Toast.LENGTH_SHORT).show();
        ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
        clipboard.setPrimaryClip(ClipData.newPlainText("post_context", item.getStatus().getText()));
        return true;
    });
    statusViewBinder.getUserImage().setOnClickListener(v -> {
        ActivityOptionsCompat animation = ActivityOptionsCompat.makeSceneTransitionAnimation(this, v, "icon_image");
        startActivity(GlobalApplicationKt.setAccountKeyForActivity(ShowUserActivity.getIntent(this, item.getUser().getId()), this), animation.toBundle());
    });
    statusViewBinder.setOnQuotedStatusClicked(v -> startActivity(GlobalApplicationKt.setAccountKeyForActivity(ShowTweetActivity.getIntent(this, item.getQuotedRepeatingStatus().getId()), this)));
    statusViewBinder.setOnCardClicked(v -> AppCustomTabsKt.launchChromeCustomTabs(this, item.getStatus().getCard().getUrl(), false));
    statusViewBinder.getLikeButton().setOnCheckedChangeListener((compoundButton, b) -> {
        if (b) {
            statusActionModel.createFavorite(item.getId());
        } else {
            statusActionModel.removeFavorite(item.getId());
        }
        return Unit.INSTANCE;
    });
    statusViewBinder.getRepeatButton().setOnCheckedChangeListener((compoundButton, b) -> {
        if (b) {
            statusActionModel.createRepeat(item.getId());
        } else {
            statusActionModel.removeRepeat(item.getId());
        }
        return Unit.INSTANCE;
    });
    View.OnClickListener replyOnClickListener = v -> startActivity(PostActivity.getIntent(this, item.getStatus().getId(), TwitterStringUtils.convertToReplyTopString(client.getUserCache().get(client.getAccessToken().getUserId()).getScreenName(), item.getUser().getScreenName(), item.getStatus().getMentions()).toString()));
    statusViewBinder.getReplyButton().setOnClickListener(replyOnClickListener);
    replyFab.setOnClickListener(replyOnClickListener);
    statusViewBinder.setStatus(client, requestManager, item.getRepeatedUser(), item.getRepeat(), item.getUser(), item.getStatus(), item.getQuotedRepeatingUser(), item.getQuotedRepeatingStatus());
    statusViewBinder.getSendVote().setOnClickListener(v -> statusActionModel.sendVote(statusId, item.getStatus().getPoll().getId(), statusViewBinder.getPollAdapter().getSelections()));
    timestampText.setText(DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(item.getStatus().getCreatedAt()));
    if (item.getStatus().getSourceName() != null) {
        viaText.setText(TwitterStringUtils.appendLinkAtViaText(item.getStatus().getSourceName(), item.getStatus().getSourceWebsite()));
        viaText.setMovementMethod(new LinkMovementMethod());
    } else {
        viaText.setVisibility(GONE);
    }
}
Also used : ClipboardManager(android.content.ClipboardManager) Context(android.content.Context) Bundle(android.os.Bundle) StatusActionModel(com.github.moko256.twitlatte.model.base.StatusActionModel) Intent(android.content.Intent) LinkMovementMethod(android.text.method.LinkMovementMethod) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) AppCustomTabsKt(com.github.moko256.twitlatte.intent.AppCustomTabsKt) MenuItem(android.view.MenuItem) ClipData(android.content.ClipData) ActionBar(androidx.appcompat.app.ActionBar) SuppressLint(android.annotation.SuppressLint) ActivityOptionsCompat(androidx.core.app.ActivityOptionsCompat) RequestManager(com.bumptech.glide.RequestManager) TwitterStringUtils(com.github.moko256.twitlatte.text.TwitterStringUtils) Toast(android.widget.Toast) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) Menu(android.view.Menu) ClipboardManager(android.content.ClipboardManager) View(android.view.View) Button(android.widget.Button) VISIBLE(android.view.View.VISIBLE) StatusActionModelImpl(com.github.moko256.twitlatte.model.impl.StatusActionModelImpl) DateFormat(java.text.DateFormat) Post(com.github.moko256.latte.client.base.entity.Post) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) Client(com.github.moko256.twitlatte.entity.Client) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Unit(kotlin.Unit) TextView(android.widget.TextView) Glide(com.bumptech.glide.Glide) GONE(android.view.View.GONE) LinkMovementMethod(android.text.method.LinkMovementMethod) ActivityOptionsCompat(androidx.core.app.ActivityOptionsCompat) View(android.view.View) TextView(android.widget.TextView)

Aggregations

GONE (android.view.View.GONE)4 TextView (android.widget.TextView)4 Context (android.content.Context)3 Intent (android.content.Intent)3 Bundle (android.os.Bundle)3 LinkMovementMethod (android.text.method.LinkMovementMethod)3 Menu (android.view.Menu)3 MenuItem (android.view.MenuItem)3 View (android.view.View)3 VISIBLE (android.view.View.VISIBLE)3 Toast (android.widget.Toast)3 DateFormat (java.text.DateFormat)3 SuppressLint (android.annotation.SuppressLint)2 ClipData (android.content.ClipData)2 ClipboardManager (android.content.ClipboardManager)2 ViewGroup (android.view.ViewGroup)2 Button (android.widget.Button)2 ActionBar (androidx.appcompat.app.ActionBar)2 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)2 ActivityOptionsCompat (androidx.core.app.ActivityOptionsCompat)2