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);
}));
});
}
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);
}
}
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);
}
}
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);
}
}
Aggregations