Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
package com.twitter.sdk.android.tweetui;
import com.twitter.sdk.android.core.Callback;
import com.twitter.sdk.android.core.models.Tweet;
/* loaded from: classes.dex */
class BaseTweetAction {
protected Callback<Tweet> a;
BaseTweetAction(Callback<Tweet> callback) {
this.a = callback;
}
Callback<Tweet> a() {
return this.a;
}
}

View File

@@ -0,0 +1,120 @@
package com.twitter.sdk.android.tweetui;
import android.app.Activity;
import android.os.Bundle;
import androidx.viewpager.widget.ViewPager;
import com.twitter.sdk.android.core.internal.scribe.ScribeItem;
import com.twitter.sdk.android.core.models.MediaEntity;
import com.twitter.sdk.android.tweetui.internal.SwipeToDismissTouchListener;
import java.io.Serializable;
import java.util.Collections;
import java.util.List;
/* loaded from: classes.dex */
public class GalleryActivity extends Activity {
GalleryItem a;
final GalleryScribeClient b = new GalleryScribeClientImpl(TweetUi.s());
public static class GalleryItem implements Serializable {
public final List<MediaEntity> mediaEntities;
public final int mediaEntityIndex;
public final long tweetId;
public GalleryItem(int i, List<MediaEntity> list) {
this(0L, i, list);
}
public GalleryItem(long j, int i, List<MediaEntity> list) {
this.tweetId = j;
this.mediaEntityIndex = i;
this.mediaEntities = list;
}
}
GalleryItem a() {
MediaEntity mediaEntity = (MediaEntity) getIntent().getSerializableExtra("MEDIA_ENTITY");
return mediaEntity != null ? new GalleryItem(0, Collections.singletonList(mediaEntity)) : (GalleryItem) getIntent().getSerializableExtra("GALLERY_ITEM");
}
ViewPager.OnPageChangeListener b() {
return new ViewPager.OnPageChangeListener() { // from class: com.twitter.sdk.android.tweetui.GalleryActivity.1
int a = -1;
@Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
public void onPageScrollStateChanged(int i) {
}
@Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
public void onPageScrolled(int i, float f, int i2) {
if (this.a == -1 && i == 0 && f == 0.0d) {
GalleryActivity.this.a(i);
this.a++;
}
}
@Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
public void onPageSelected(int i) {
if (this.a >= 0) {
GalleryActivity.this.e();
}
this.a++;
GalleryActivity.this.a(i);
}
};
}
SwipeToDismissTouchListener.Callback c() {
return new SwipeToDismissTouchListener.Callback() { // from class: com.twitter.sdk.android.tweetui.GalleryActivity.2
@Override // com.twitter.sdk.android.tweetui.internal.SwipeToDismissTouchListener.Callback
public void a(float f) {
}
@Override // com.twitter.sdk.android.tweetui.internal.SwipeToDismissTouchListener.Callback
public void onDismiss() {
GalleryActivity.this.d();
GalleryActivity.this.finish();
GalleryActivity.this.overridePendingTransition(0, R$anim.tw__slide_out);
}
};
}
void d() {
this.b.dismiss();
}
void e() {
this.b.b();
}
void f() {
this.b.a();
}
@Override // android.app.Activity
public void onBackPressed() {
d();
super.onBackPressed();
overridePendingTransition(0, R$anim.tw__slide_out);
}
@Override // android.app.Activity
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R$layout.tw__gallery_activity);
this.a = a();
if (bundle == null) {
f();
}
GalleryAdapter galleryAdapter = new GalleryAdapter(this, c());
galleryAdapter.a(this.a.mediaEntities);
ViewPager viewPager = (ViewPager) findViewById(R$id.tw__view_pager);
viewPager.setPageMargin(getResources().getDimensionPixelSize(R$dimen.tw__gallery_page_margin));
viewPager.a(b());
viewPager.setAdapter(galleryAdapter);
viewPager.setCurrentItem(this.a.mediaEntityIndex);
}
void a(int i) {
this.b.a(ScribeItem.fromMediaEntity(this.a.tweetId, this.a.mediaEntities.get(i)));
}
}

View File

@@ -0,0 +1,53 @@
package com.twitter.sdk.android.tweetui;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import androidx.viewpager.widget.PagerAdapter;
import com.squareup.picasso.Picasso;
import com.twitter.sdk.android.core.models.MediaEntity;
import com.twitter.sdk.android.tweetui.internal.GalleryImageView;
import com.twitter.sdk.android.tweetui.internal.SwipeToDismissTouchListener;
import java.util.ArrayList;
import java.util.List;
/* loaded from: classes.dex */
class GalleryAdapter extends PagerAdapter {
final List<MediaEntity> a = new ArrayList();
final Context b;
final SwipeToDismissTouchListener.Callback c;
GalleryAdapter(Context context, SwipeToDismissTouchListener.Callback callback) {
this.b = context;
this.c = callback;
}
void a(List<MediaEntity> list) {
this.a.addAll(list);
notifyDataSetChanged();
}
@Override // androidx.viewpager.widget.PagerAdapter
public void destroyItem(ViewGroup viewGroup, int i, Object obj) {
viewGroup.removeView((View) obj);
}
@Override // androidx.viewpager.widget.PagerAdapter
public int getCount() {
return this.a.size();
}
@Override // androidx.viewpager.widget.PagerAdapter
public Object instantiateItem(ViewGroup viewGroup, int i) {
GalleryImageView galleryImageView = new GalleryImageView(this.b);
galleryImageView.setSwipeToDismissCallback(this.c);
viewGroup.addView(galleryImageView);
Picasso.a(this.b).a(this.a.get(i).mediaUrlHttps).a(galleryImageView);
return galleryImageView;
}
@Override // androidx.viewpager.widget.PagerAdapter
public boolean isViewFromObject(View view, Object obj) {
return view == obj;
}
}

View File

@@ -0,0 +1,14 @@
package com.twitter.sdk.android.tweetui;
import com.twitter.sdk.android.core.internal.scribe.ScribeItem;
/* loaded from: classes.dex */
public interface GalleryScribeClient {
void a();
void a(ScribeItem scribeItem);
void b();
void dismiss();
}

View File

@@ -0,0 +1,73 @@
package com.twitter.sdk.android.tweetui;
import com.twitter.sdk.android.core.internal.scribe.EventNamespace;
import com.twitter.sdk.android.core.internal.scribe.ScribeItem;
import com.ubt.jimu.transport.model.TransportFile;
import java.util.ArrayList;
/* loaded from: classes.dex */
public class GalleryScribeClientImpl implements GalleryScribeClient {
final TweetUi a;
public GalleryScribeClientImpl(TweetUi tweetUi) {
this.a = tweetUi;
}
static EventNamespace c() {
EventNamespace.Builder builder = new EventNamespace.Builder();
builder.b("tfw");
builder.e("android");
builder.f("gallery");
builder.a("dismiss");
return builder.a();
}
static EventNamespace d() {
EventNamespace.Builder builder = new EventNamespace.Builder();
builder.b("tfw");
builder.e("android");
builder.f("gallery");
builder.a("impression");
return builder.a();
}
static EventNamespace e() {
EventNamespace.Builder builder = new EventNamespace.Builder();
builder.b("tfw");
builder.e("android");
builder.f("gallery");
builder.a("navigate");
return builder.a();
}
static EventNamespace f() {
EventNamespace.Builder builder = new EventNamespace.Builder();
builder.b("tfw");
builder.e("android");
builder.f("gallery");
builder.a(TransportFile.TYPE_DIY_SHOW);
return builder.a();
}
@Override // com.twitter.sdk.android.tweetui.GalleryScribeClient
public void a() {
this.a.a(f());
}
@Override // com.twitter.sdk.android.tweetui.GalleryScribeClient
public void b() {
this.a.a(e());
}
@Override // com.twitter.sdk.android.tweetui.GalleryScribeClient
public void dismiss() {
this.a.a(c());
}
@Override // com.twitter.sdk.android.tweetui.GalleryScribeClient
public void a(ScribeItem scribeItem) {
ArrayList arrayList = new ArrayList();
arrayList.add(scribeItem);
this.a.a(d(), arrayList);
}
}

View File

@@ -0,0 +1,96 @@
package com.twitter.sdk.android.tweetui;
import android.view.View;
import com.twitter.sdk.android.core.Callback;
import com.twitter.sdk.android.core.Result;
import com.twitter.sdk.android.core.TwitterApiException;
import com.twitter.sdk.android.core.TwitterException;
import com.twitter.sdk.android.core.models.Tweet;
import com.twitter.sdk.android.core.models.TweetBuilder;
/* loaded from: classes.dex */
class LikeTweetAction extends BaseTweetAction implements View.OnClickListener {
final Tweet b;
final TweetRepository c;
final TweetScribeClient d;
static class LikeCallback extends Callback<Tweet> {
ToggleImageButton a;
Tweet b;
Callback<Tweet> c;
LikeCallback(ToggleImageButton toggleImageButton, Tweet tweet, Callback<Tweet> callback) {
this.a = toggleImageButton;
this.b = tweet;
this.c = callback;
}
@Override // com.twitter.sdk.android.core.Callback
public void a(Result<Tweet> result) {
this.c.a(result);
}
@Override // com.twitter.sdk.android.core.Callback
public void a(TwitterException twitterException) {
if (!(twitterException instanceof TwitterApiException)) {
this.a.setToggledOn(this.b.g);
this.c.a(twitterException);
return;
}
int errorCode = ((TwitterApiException) twitterException).getErrorCode();
if (errorCode == 139) {
TweetBuilder tweetBuilder = new TweetBuilder();
tweetBuilder.a(this.b);
tweetBuilder.a(true);
this.c.a(new Result<>(tweetBuilder.a(), null));
return;
}
if (errorCode != 144) {
this.a.setToggledOn(this.b.g);
this.c.a(twitterException);
return;
}
TweetBuilder tweetBuilder2 = new TweetBuilder();
tweetBuilder2.a(this.b);
tweetBuilder2.a(false);
this.c.a(new Result<>(tweetBuilder2.a(), null));
}
}
LikeTweetAction(Tweet tweet, TweetUi tweetUi, Callback<Tweet> callback) {
this(tweet, tweetUi, callback, new TweetScribeClientImpl(tweetUi));
}
void b() {
this.d.a(this.b);
}
void c() {
this.d.b(this.b);
}
@Override // android.view.View.OnClickListener
public void onClick(View view) {
if (view instanceof ToggleImageButton) {
ToggleImageButton toggleImageButton = (ToggleImageButton) view;
if (this.b.g) {
c();
TweetRepository tweetRepository = this.c;
Tweet tweet = this.b;
tweetRepository.b(tweet.i, new LikeCallback(toggleImageButton, tweet, a()));
return;
}
b();
TweetRepository tweetRepository2 = this.c;
Tweet tweet2 = this.b;
tweetRepository2.a(tweet2.i, new LikeCallback(toggleImageButton, tweet2, a()));
}
}
LikeTweetAction(Tweet tweet, TweetUi tweetUi, Callback<Tweet> callback, TweetScribeClient tweetScribeClient) {
super(callback);
this.b = tweet;
this.d = tweetScribeClient;
this.c = tweetUi.q();
}
}

View File

@@ -0,0 +1,25 @@
package com.twitter.sdk.android.tweetui;
import com.twitter.sdk.android.core.Callback;
import com.twitter.sdk.android.core.TwitterException;
import io.fabric.sdk.android.Logger;
/* loaded from: classes.dex */
abstract class LoggingCallback<T> extends Callback<T> {
private final Callback a;
private final Logger b;
LoggingCallback(Callback callback, Logger logger) {
this.a = callback;
this.b = logger;
}
@Override // com.twitter.sdk.android.core.Callback
public void a(TwitterException twitterException) {
this.b.b("TweetUi", twitterException.getMessage(), twitterException);
Callback callback = this.a;
if (callback != null) {
callback.a(twitterException);
}
}
}

View File

@@ -0,0 +1,96 @@
package com.twitter.sdk.android.tweetui;
import android.R;
import android.app.Activity;
import android.os.Bundle;
import com.twitter.sdk.android.core.internal.scribe.ScribeItem;
import com.twitter.sdk.android.tweetui.internal.SwipeToDismissTouchListener;
import java.io.Serializable;
/* loaded from: classes.dex */
public class PlayerActivity extends Activity {
static final VideoScribeClient b = new VideoScribeClientImpl(TweetUi.s());
PlayerController a;
private void a(ScribeItem scribeItem) {
b.a(scribeItem);
}
@Override // android.app.Activity
public void onBackPressed() {
super.onBackPressed();
overridePendingTransition(0, R$anim.tw__slide_out);
}
@Override // android.app.Activity
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R$layout.tw__player_activity);
PlayerItem playerItem = (PlayerItem) getIntent().getSerializableExtra("PLAYER_ITEM");
this.a = new PlayerController(findViewById(R.id.content), new SwipeToDismissTouchListener.Callback() { // from class: com.twitter.sdk.android.tweetui.PlayerActivity.1
@Override // com.twitter.sdk.android.tweetui.internal.SwipeToDismissTouchListener.Callback
public void a(float f) {
}
@Override // com.twitter.sdk.android.tweetui.internal.SwipeToDismissTouchListener.Callback
public void onDismiss() {
PlayerActivity.this.finish();
PlayerActivity.this.overridePendingTransition(0, R$anim.tw__slide_out);
}
});
this.a.a(playerItem);
a((ScribeItem) getIntent().getSerializableExtra("SCRIBE_ITEM"));
}
@Override // android.app.Activity
public void onDestroy() {
this.a.a();
super.onDestroy();
}
@Override // android.app.Activity
protected void onPause() {
this.a.b();
super.onPause();
}
@Override // android.app.Activity
protected void onResume() {
super.onResume();
this.a.c();
}
public static class PlayerItem implements Serializable {
public final String callToActionText;
public final String callToActionUrl;
public final boolean looping;
public final boolean showVideoControls;
public final String url;
@Deprecated
public PlayerItem(String str, boolean z) {
this.url = str;
this.looping = z;
this.showVideoControls = false;
this.callToActionUrl = null;
this.callToActionText = null;
}
@Deprecated
public PlayerItem(String str, boolean z, String str2, String str3) {
this.url = str;
this.looping = z;
this.showVideoControls = false;
this.callToActionText = str2;
this.callToActionUrl = str3;
}
public PlayerItem(String str, boolean z, boolean z2, String str2, String str3) {
this.url = str;
this.looping = z;
this.showVideoControls = z2;
this.callToActionText = str2;
this.callToActionUrl = str3;
}
}
}

View File

@@ -0,0 +1,146 @@
package com.twitter.sdk.android.tweetui;
import android.content.Intent;
import android.media.MediaPlayer;
import android.net.Uri;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.twitter.sdk.android.core.IntentUtils;
import com.twitter.sdk.android.tweetui.PlayerActivity;
import com.twitter.sdk.android.tweetui.internal.SwipeToDismissTouchListener;
import com.twitter.sdk.android.tweetui.internal.VideoControlView;
import com.twitter.sdk.android.tweetui.internal.VideoView;
import io.fabric.sdk.android.Fabric;
/* loaded from: classes.dex */
class PlayerController {
final VideoView a;
final VideoControlView b;
final ProgressBar c;
final TextView d;
View e;
int f = 0;
boolean g = true;
final SwipeToDismissTouchListener.Callback h;
PlayerController(View view, SwipeToDismissTouchListener.Callback callback) {
this.e = view;
this.a = (VideoView) view.findViewById(R$id.video_view);
this.b = (VideoControlView) view.findViewById(R$id.video_control_view);
this.c = (ProgressBar) view.findViewById(R$id.video_progress_view);
this.d = (TextView) view.findViewById(R$id.call_to_action_view);
this.h = callback;
}
void a(PlayerActivity.PlayerItem playerItem) {
try {
b(playerItem);
a(playerItem.looping, playerItem.showVideoControls);
this.a.setOnTouchListener(SwipeToDismissTouchListener.a(this.a, this.h));
this.a.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { // from class: com.twitter.sdk.android.tweetui.PlayerController.1
@Override // android.media.MediaPlayer.OnPreparedListener
public void onPrepared(MediaPlayer mediaPlayer) {
PlayerController.this.c.setVisibility(8);
}
});
this.a.setOnInfoListener(new MediaPlayer.OnInfoListener() { // from class: com.twitter.sdk.android.tweetui.PlayerController.2
@Override // android.media.MediaPlayer.OnInfoListener
public boolean onInfo(MediaPlayer mediaPlayer, int i, int i2) {
if (i == 702) {
PlayerController.this.c.setVisibility(8);
return true;
}
if (i != 701) {
return false;
}
PlayerController.this.c.setVisibility(0);
return true;
}
});
this.a.a(Uri.parse(playerItem.url), playerItem.looping);
this.a.requestFocus();
} catch (Exception e) {
Fabric.g().b("PlayerController", "Error occurred during video playback", e);
}
}
void b() {
this.g = this.a.isPlaying();
this.f = this.a.getCurrentPosition();
this.a.pause();
}
void c() {
int i = this.f;
if (i != 0) {
this.a.seekTo(i);
}
if (this.g) {
this.a.start();
this.b.j();
}
}
void d() {
this.b.setVisibility(4);
this.a.setOnClickListener(new View.OnClickListener() { // from class: com.twitter.sdk.android.tweetui.PlayerController.3
@Override // android.view.View.OnClickListener
public void onClick(View view) {
if (PlayerController.this.a.isPlaying()) {
PlayerController.this.a.pause();
} else {
PlayerController.this.a.start();
}
}
});
}
void e() {
this.a.setMediaController(this.b);
}
void f() {
this.e.setOnClickListener(new View.OnClickListener() { // from class: com.twitter.sdk.android.tweetui.PlayerController.5
@Override // android.view.View.OnClickListener
public void onClick(View view) {
if (PlayerController.this.d.getVisibility() == 0) {
PlayerController.this.d.setVisibility(8);
} else {
PlayerController.this.d.setVisibility(0);
}
}
});
}
void b(PlayerActivity.PlayerItem playerItem) {
if (playerItem.callToActionText == null || playerItem.callToActionUrl == null) {
return;
}
this.d.setVisibility(0);
this.d.setText(playerItem.callToActionText);
a(playerItem.callToActionUrl);
f();
}
void a() {
this.a.a();
}
void a(boolean z, boolean z2) {
if (z && !z2) {
d();
} else {
e();
}
}
void a(final String str) {
this.d.setOnClickListener(new View.OnClickListener() { // from class: com.twitter.sdk.android.tweetui.PlayerController.4
@Override // android.view.View.OnClickListener
public void onClick(View view) {
IntentUtils.b(PlayerController.this.d.getContext(), new Intent("android.intent.action.VIEW", Uri.parse(str)));
}
});
}
}

View File

@@ -0,0 +1,7 @@
package com.twitter.sdk.android.tweetui;
/* loaded from: classes.dex */
public final class R$anim {
public static final int tw__accelerate_cubic = 2130772005;
public static final int tw__slide_out = 2130772006;
}

View File

@@ -0,0 +1,19 @@
package com.twitter.sdk.android.tweetui;
/* loaded from: classes.dex */
public final class R$attr {
public static final int contentDescriptionOff = 2130968758;
public static final int contentDescriptionOn = 2130968759;
public static final int state_toggled_on = 2130969099;
public static final int toggleOnClick = 2130969197;
public static final int tw__action_color = 2130969209;
public static final int tw__action_highlight_color = 2130969210;
public static final int tw__container_bg_color = 2130969211;
public static final int tw__frame_layout_aspect_ratio = 2130969212;
public static final int tw__frame_layout_dimension_to_adjust = 2130969213;
public static final int tw__image_aspect_ratio = 2130969214;
public static final int tw__image_dimension_to_adjust = 2130969215;
public static final int tw__primary_text_color = 2130969216;
public static final int tw__tweet_actions_enabled = 2130969217;
public static final int tw__tweet_id = 2130969218;
}

View File

@@ -0,0 +1,98 @@
package com.twitter.sdk.android.tweetui;
/* loaded from: classes.dex */
public final class R$dimen {
public static final int tw__badge_padding = 2131172303;
public static final int tw__btn_bar_margin_left = 2131172304;
public static final int tw__btn_bar_margin_right = 2131172305;
public static final int tw__compact_tweet_action_bar_offset_left = 2131172314;
public static final int tw__compact_tweet_attribution_line_margin_right = 2131172315;
public static final int tw__compact_tweet_avatar_margin_left = 2131172316;
public static final int tw__compact_tweet_avatar_margin_right = 2131172317;
public static final int tw__compact_tweet_avatar_margin_top = 2131172318;
public static final int tw__compact_tweet_container_bottom_separator = 2131172319;
public static final int tw__compact_tweet_container_padding_top = 2131172320;
public static final int tw__compact_tweet_full_name_margin_right = 2131172321;
public static final int tw__compact_tweet_full_name_margin_top = 2131172322;
public static final int tw__compact_tweet_logo_margin_right = 2131172323;
public static final int tw__compact_tweet_logo_margin_top = 2131172324;
public static final int tw__compact_tweet_media_margin_bottom = 2131172325;
public static final int tw__compact_tweet_media_margin_right = 2131172326;
public static final int tw__compact_tweet_media_margin_top = 2131172327;
public static final int tw__compact_tweet_quote_tweet_margin_left = 2131172328;
public static final int tw__compact_tweet_quote_tweet_margin_right = 2131172329;
public static final int tw__compact_tweet_retweeted_by_drawable_padding = 2131172330;
public static final int tw__compact_tweet_retweeted_by_margin_bottom = 2131172331;
public static final int tw__compact_tweet_retweeted_by_margin_left = 2131172332;
public static final int tw__compact_tweet_retweeted_by_margin_top = 2131172333;
public static final int tw__compact_tweet_screen_name_layout_width = 2131172334;
public static final int tw__compact_tweet_screen_name_margin_bottom = 2131172335;
public static final int tw__compact_tweet_screen_name_margin_top = 2131172336;
public static final int tw__compact_tweet_screen_name_padding_left = 2131172337;
public static final int tw__compact_tweet_text_margin_left = 2131172338;
public static final int tw__compact_tweet_text_margin_right = 2131172339;
public static final int tw__compact_tweet_text_margin_top = 2131172340;
public static final int tw__compact_tweet_timestamp_margin_top = 2131172341;
public static final int tw__cta_border_size = 2131172354;
public static final int tw__cta_margin_top = 2131172355;
public static final int tw__cta_padding = 2131172356;
public static final int tw__cta_radius = 2131172357;
public static final int tw__gallery_page_margin = 2131172358;
public static final int tw__login_btn_drawable_padding = 2131172359;
public static final int tw__login_btn_height = 2131172360;
public static final int tw__login_btn_left_padding = 2131172361;
public static final int tw__login_btn_radius = 2131172362;
public static final int tw__login_btn_right_padding = 2131172363;
public static final int tw__login_btn_text_size = 2131172364;
public static final int tw__media_view_divider_size = 2131172365;
public static final int tw__media_view_radius = 2131172366;
public static final int tw__padding_permission_horizontal_container = 2131172367;
public static final int tw__padding_permission_vertical_container = 2131172368;
public static final int tw__permission_description_text_size = 2131172369;
public static final int tw__permission_title_text_size = 2131172370;
public static final int tw__quote_tweet_attribution_text_margin_horizontal = 2131172371;
public static final int tw__quote_tweet_attribution_text_margin_top = 2131172372;
public static final int tw__quote_tweet_border_width = 2131172373;
public static final int tw__quote_tweet_media_margin_bottom = 2131172374;
public static final int tw__quote_tweet_media_margin_horizontal = 2131172375;
public static final int tw__quote_tweet_text_margin_bottom = 2131172376;
public static final int tw__quote_tweet_text_margin_horizontal = 2131172377;
public static final int tw__seekbar_thumb_inner_padding = 2131172378;
public static final int tw__seekbar_thumb_outer_padding = 2131172379;
public static final int tw__seekbar_thumb_size = 2131172380;
public static final int tw__text_size_large = 2131172381;
public static final int tw__text_size_medium = 2131172382;
public static final int tw__text_size_small = 2131172383;
public static final int tw__tweet_action_bar_offset_bottom = 2131172384;
public static final int tw__tweet_action_bar_offset_left = 2131172385;
public static final int tw__tweet_action_button_margin_top = 2131172386;
public static final int tw__tweet_action_button_spacing = 2131172387;
public static final int tw__tweet_action_heart_size = 2131172388;
public static final int tw__tweet_action_share_padding = 2131172389;
public static final int tw__tweet_avatar_margin_left = 2131172390;
public static final int tw__tweet_avatar_margin_right = 2131172391;
public static final int tw__tweet_avatar_margin_top = 2131172392;
public static final int tw__tweet_avatar_size = 2131172393;
public static final int tw__tweet_container_bottom_separator = 2131172394;
public static final int tw__tweet_full_name_drawable_padding = 2131172395;
public static final int tw__tweet_full_name_margin_right = 2131172396;
public static final int tw__tweet_full_name_margin_top = 2131172397;
public static final int tw__tweet_logo_margin_right = 2131172398;
public static final int tw__tweet_logo_margin_top = 2131172399;
public static final int tw__tweet_media_badge_margin = 2131172400;
public static final int tw__tweet_quote_tweet_margin_horizontal = 2131172401;
public static final int tw__tweet_quote_tweet_margin_top = 2131172402;
public static final int tw__tweet_retweeted_by_drawable_padding = 2131172403;
public static final int tw__tweet_retweeted_by_margin_bottom = 2131172404;
public static final int tw__tweet_retweeted_by_margin_left = 2131172405;
public static final int tw__tweet_retweeted_by_margin_top = 2131172406;
public static final int tw__tweet_screen_name_margin_bottom = 2131172407;
public static final int tw__tweet_screen_name_margin_top = 2131172408;
public static final int tw__tweet_text_margin_left = 2131172409;
public static final int tw__tweet_text_margin_right = 2131172410;
public static final int tw__tweet_text_margin_top = 2131172411;
public static final int tw__tweet_timestamp_margin_top = 2131172412;
public static final int tw__tweet_timestamp_padding_left = 2131172413;
public static final int tw__video_control_height = 2131172414;
public static final int tw__video_control_text_size = 2131172415;
}

View File

@@ -0,0 +1,112 @@
package com.twitter.sdk.android.tweetui;
/* loaded from: classes.dex */
public final class R$drawable {
public static final int tw__action_heart_off_default = 2131231826;
public static final int tw__action_heart_on_default = 2131231827;
public static final int tw__bg_media_badge = 2131231829;
public static final int tw__call_to_action = 2131231831;
public static final int tw__gif_badge = 2131231835;
public static final int tw__heart_animation_detail_60fps_00000 = 2131231836;
public static final int tw__heart_animation_detail_60fps_00001 = 2131231837;
public static final int tw__heart_animation_detail_60fps_00002 = 2131231838;
public static final int tw__heart_animation_detail_60fps_00003 = 2131231839;
public static final int tw__heart_animation_detail_60fps_00004 = 2131231840;
public static final int tw__heart_animation_detail_60fps_00005 = 2131231841;
public static final int tw__heart_animation_detail_60fps_00006 = 2131231842;
public static final int tw__heart_animation_detail_60fps_00007 = 2131231843;
public static final int tw__heart_animation_detail_60fps_00008 = 2131231844;
public static final int tw__heart_animation_detail_60fps_00009 = 2131231845;
public static final int tw__heart_animation_detail_60fps_00010 = 2131231846;
public static final int tw__heart_animation_detail_60fps_00011 = 2131231847;
public static final int tw__heart_animation_detail_60fps_00012 = 2131231848;
public static final int tw__heart_animation_detail_60fps_00013 = 2131231849;
public static final int tw__heart_animation_detail_60fps_00014 = 2131231850;
public static final int tw__heart_animation_detail_60fps_00015 = 2131231851;
public static final int tw__heart_animation_detail_60fps_00016 = 2131231852;
public static final int tw__heart_animation_detail_60fps_00017 = 2131231853;
public static final int tw__heart_animation_detail_60fps_00018 = 2131231854;
public static final int tw__heart_animation_detail_60fps_00019 = 2131231855;
public static final int tw__heart_animation_detail_60fps_00020 = 2131231856;
public static final int tw__heart_animation_detail_60fps_00021 = 2131231857;
public static final int tw__heart_animation_detail_60fps_00022 = 2131231858;
public static final int tw__heart_animation_detail_60fps_00023 = 2131231859;
public static final int tw__heart_animation_detail_60fps_00024 = 2131231860;
public static final int tw__heart_animation_detail_60fps_00025 = 2131231861;
public static final int tw__heart_animation_detail_60fps_00026 = 2131231862;
public static final int tw__heart_animation_detail_60fps_00027 = 2131231863;
public static final int tw__heart_animation_detail_60fps_00028 = 2131231864;
public static final int tw__heart_animation_detail_60fps_00029 = 2131231865;
public static final int tw__heart_animation_detail_60fps_00030 = 2131231866;
public static final int tw__heart_animation_detail_60fps_00031 = 2131231867;
public static final int tw__heart_animation_detail_60fps_00032 = 2131231868;
public static final int tw__heart_animation_detail_60fps_00033 = 2131231869;
public static final int tw__heart_animation_detail_60fps_00034 = 2131231870;
public static final int tw__heart_animation_detail_60fps_00035 = 2131231871;
public static final int tw__heart_animation_detail_60fps_00036 = 2131231872;
public static final int tw__heart_animation_detail_60fps_00037 = 2131231873;
public static final int tw__heart_animation_detail_60fps_00038 = 2131231874;
public static final int tw__heart_animation_detail_60fps_00039 = 2131231875;
public static final int tw__heart_animation_detail_60fps_00040 = 2131231876;
public static final int tw__heart_animation_detail_60fps_00041 = 2131231877;
public static final int tw__heart_animation_detail_60fps_00042 = 2131231878;
public static final int tw__heart_animation_detail_60fps_00043 = 2131231879;
public static final int tw__heart_animation_detail_60fps_00044 = 2131231880;
public static final int tw__heart_animation_detail_60fps_00045 = 2131231881;
public static final int tw__heart_animation_detail_60fps_00046 = 2131231882;
public static final int tw__heart_animation_detail_60fps_00047 = 2131231883;
public static final int tw__heart_animation_detail_60fps_00048 = 2131231884;
public static final int tw__heart_animation_detail_60fps_00049 = 2131231885;
public static final int tw__heart_animation_detail_60fps_00050 = 2131231886;
public static final int tw__heart_animation_detail_60fps_00051 = 2131231887;
public static final int tw__heart_animation_detail_60fps_00052 = 2131231888;
public static final int tw__heart_animation_detail_60fps_00053 = 2131231889;
public static final int tw__heart_animation_detail_60fps_00054 = 2131231890;
public static final int tw__heart_animation_detail_60fps_00055 = 2131231891;
public static final int tw__heart_animation_detail_60fps_00056 = 2131231892;
public static final int tw__heart_animation_detail_60fps_00057 = 2131231893;
public static final int tw__heart_animation_detail_60fps_00058 = 2131231894;
public static final int tw__heart_animation_detail_60fps_00059 = 2131231895;
public static final int tw__ic_gif_badge = 2131231896;
public static final int tw__ic_inline_share = 2131231897;
public static final int tw__ic_logo_blue = 2131231898;
public static final int tw__ic_logo_default = 2131231899;
public static final int tw__ic_logo_white = 2131231900;
public static final int tw__ic_play_default = 2131231901;
public static final int tw__ic_play_pressed = 2131231902;
public static final int tw__ic_retweet_dark = 2131231903;
public static final int tw__ic_retweet_light = 2131231904;
public static final int tw__ic_seekbar_bg = 2131231905;
public static final int tw__ic_seekbar_progress_bg = 2131231906;
public static final int tw__ic_seekbar_secondary_bg = 2131231907;
public static final int tw__ic_tweet_photo_error_dark = 2131231908;
public static final int tw__ic_tweet_photo_error_light = 2131231909;
public static final int tw__ic_tweet_verified = 2131231910;
public static final int tw__ic_video_pause = 2131231911;
public static final int tw__ic_video_pause_pressed = 2131231912;
public static final int tw__ic_video_play = 2131231913;
public static final int tw__ic_video_play_pressed = 2131231914;
public static final int tw__ic_video_replay = 2131231915;
public static final int tw__ic_video_replay_pressed = 2131231916;
public static final int tw__ic_vine_badge = 2131231917;
public static final int tw__like_action = 2131231919;
public static final int tw__login_btn = 2131231920;
public static final int tw__login_btn_default = 2131231921;
public static final int tw__login_btn_default_light = 2131231922;
public static final int tw__login_btn_disabled = 2131231923;
public static final int tw__login_btn_light = 2131231924;
public static final int tw__login_btn_pressed = 2131231925;
public static final int tw__login_btn_pressed_light = 2131231926;
public static final int tw__login_btn_text_color_light = 2131231927;
public static final int tw__player_overlay = 2131231928;
public static final int tw__quote_tweet_border = 2131231929;
public static final int tw__seekbar_thumb = 2131231930;
public static final int tw__share_action = 2131231931;
public static final int tw__share_email_header = 2131231932;
public static final int tw__transparent = 2131231933;
public static final int tw__video_pause_btn = 2131231934;
public static final int tw__video_play_btn = 2131231935;
public static final int tw__video_replay_btn = 2131231936;
public static final int tw__video_seekbar = 2131231937;
public static final int tw__vine_badge = 2131231938;
}

View File

@@ -0,0 +1,43 @@
package com.twitter.sdk.android.tweetui;
/* loaded from: classes.dex */
public final class R$id {
public static final int bottom_separator = 2131296352;
public static final int call_to_action_view = 2131296400;
public static final int heart_off = 2131296690;
public static final int heart_on = 2131296691;
public static final int height = 2131296692;
public static final int imageView = 2131296818;
public static final int quote_tweet_holder = 2131297283;
public static final int tw__allow_btn = 2131297842;
public static final int tw__aspect_ratio_media_container = 2131297848;
public static final int tw__author_attribution = 2131297849;
public static final int tw__current_time = 2131297860;
public static final int tw__duration = 2131297861;
public static final int tw__entity_index = 2131297863;
public static final int tw__gif_badge = 2131297864;
public static final int tw__not_now_btn = 2131297865;
public static final int tw__progress = 2131297867;
public static final int tw__share_email_desc = 2131297868;
public static final int tw__spinner = 2131297869;
public static final int tw__state_control = 2131297870;
public static final int tw__tweet_action_bar = 2131297871;
public static final int tw__tweet_author_avatar = 2131297872;
public static final int tw__tweet_author_full_name = 2131297873;
public static final int tw__tweet_author_screen_name = 2131297874;
public static final int tw__tweet_like_button = 2131297875;
public static final int tw__tweet_media_badge = 2131297876;
public static final int tw__tweet_retweeted_by = 2131297877;
public static final int tw__tweet_share_button = 2131297878;
public static final int tw__tweet_text = 2131297879;
public static final int tw__tweet_timestamp = 2131297880;
public static final int tw__twitter_logo = 2131297881;
public static final int tw__video_duration = 2131297882;
public static final int tw__view_pager = 2131297883;
public static final int tw__web_view = 2131297884;
public static final int tweet_media_view = 2131297885;
public static final int video_control_view = 2131297918;
public static final int video_progress_view = 2131297919;
public static final int video_view = 2131297920;
public static final int width = 2131297983;
}

View File

@@ -0,0 +1,15 @@
package com.twitter.sdk.android.tweetui;
/* loaded from: classes.dex */
public final class R$layout {
public static final int tw__action_bar = 2131493362;
public static final int tw__activity_oauth = 2131493364;
public static final int tw__activity_share_email = 2131493365;
public static final int tw__gallery_activity = 2131493368;
public static final int tw__media_badge = 2131493369;
public static final int tw__player_activity = 2131493370;
public static final int tw__tweet = 2131493371;
public static final int tw__tweet_compact = 2131493372;
public static final int tw__tweet_quote = 2131493373;
public static final int tw__video_control = 2131493374;
}

View File

@@ -0,0 +1,25 @@
package com.twitter.sdk.android.tweetui;
/* loaded from: classes.dex */
public final class R$string {
public static final int kit_name = 2131821184;
public static final int tw__allow_btn_txt = 2131821703;
public static final int tw__like_tweet = 2131821706;
public static final int tw__liked_tweet = 2131821707;
public static final int tw__loading_tweet = 2131821708;
public static final int tw__login_btn_txt = 2131821709;
public static final int tw__not_now_btn_txt = 2131821711;
public static final int tw__pause = 2131821712;
public static final int tw__play = 2131821713;
public static final int tw__relative_date_format_long = 2131821716;
public static final int tw__relative_date_format_short = 2131821717;
public static final int tw__replay = 2131821718;
public static final int tw__retweeted_by_format = 2131821719;
public static final int tw__share_content_format = 2131821720;
public static final int tw__share_email_desc = 2131821721;
public static final int tw__share_email_title = 2131821722;
public static final int tw__share_subject_format = 2131821723;
public static final int tw__share_tweet = 2131821724;
public static final int tw__tweet_content_description = 2131821725;
public static final int tw__tweet_media = 2131821726;
}

View File

@@ -0,0 +1,25 @@
package com.twitter.sdk.android.tweetui;
import com.ubt.jimu.R;
/* loaded from: classes.dex */
public final class R$styleable {
public static final int AspectRatioFrameLayout_tw__frame_layout_aspect_ratio = 0;
public static final int AspectRatioFrameLayout_tw__frame_layout_dimension_to_adjust = 1;
public static final int ToggleImageButton_contentDescriptionOff = 0;
public static final int ToggleImageButton_contentDescriptionOn = 1;
public static final int ToggleImageButton_state_toggled_on = 2;
public static final int ToggleImageButton_toggleOnClick = 3;
public static final int tw__AspectRatioImageView_tw__image_aspect_ratio = 0;
public static final int tw__AspectRatioImageView_tw__image_dimension_to_adjust = 1;
public static final int tw__TweetView_tw__action_color = 0;
public static final int tw__TweetView_tw__action_highlight_color = 1;
public static final int tw__TweetView_tw__container_bg_color = 2;
public static final int tw__TweetView_tw__primary_text_color = 3;
public static final int tw__TweetView_tw__tweet_actions_enabled = 4;
public static final int tw__TweetView_tw__tweet_id = 5;
public static final int[] AspectRatioFrameLayout = {R.attr.tw__frame_layout_aspect_ratio, R.attr.tw__frame_layout_dimension_to_adjust};
public static final int[] ToggleImageButton = {R.attr.contentDescriptionOff, R.attr.contentDescriptionOn, R.attr.state_toggled_on, R.attr.toggleOnClick};
public static final int[] tw__AspectRatioImageView = {R.attr.tw__image_aspect_ratio, R.attr.tw__image_dimension_to_adjust};
public static final int[] tw__TweetView = {R.attr.tw__action_color, R.attr.tw__action_highlight_color, R.attr.tw__container_bg_color, R.attr.tw__primary_text_color, R.attr.tw__tweet_actions_enabled, R.attr.tw__tweet_id};
}

View File

@@ -0,0 +1,15 @@
package com.twitter.sdk.android.tweetui;
/* loaded from: classes.dex */
public enum SearchTimeline$ResultType {
RECENT("recent"),
POPULAR("popular"),
MIXED("mixed"),
FILTERED("filtered");
final String type;
SearchTimeline$ResultType(String str) {
this.type = str;
}
}

View File

@@ -0,0 +1,71 @@
package com.twitter.sdk.android.tweetui;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.view.View;
import com.twitter.sdk.android.core.IntentUtils;
import com.twitter.sdk.android.core.models.Tweet;
import com.twitter.sdk.android.core.models.User;
import io.fabric.sdk.android.Fabric;
/* loaded from: classes.dex */
class ShareTweetAction implements View.OnClickListener {
final Tweet a;
final TweetScribeClient b;
ShareTweetAction(Tweet tweet, TweetUi tweetUi) {
this(tweet, tweetUi, new TweetScribeClientImpl(tweetUi));
}
void a() {
this.b.c(this.a);
}
String b(Resources resources) {
int i = R$string.tw__share_subject_format;
User user = this.a.D;
return resources.getString(i, user.name, user.screenName);
}
@Override // android.view.View.OnClickListener
public void onClick(View view) {
a(view.getContext(), view.getResources());
}
ShareTweetAction(Tweet tweet, TweetUi tweetUi, TweetScribeClient tweetScribeClient) {
this.a = tweet;
this.b = tweetScribeClient;
}
void a(Context context, Resources resources) {
Tweet tweet = this.a;
if (tweet == null || tweet.D == null) {
return;
}
a();
a(Intent.createChooser(a(b(resources), a(resources)), resources.getString(R$string.tw__share_tweet)), context);
}
String a(Resources resources) {
int i = R$string.tw__share_content_format;
Tweet tweet = this.a;
return resources.getString(i, tweet.D.screenName, Long.valueOf(tweet.i));
}
void a(Intent intent, Context context) {
if (IntentUtils.b(context, intent)) {
return;
}
Fabric.g().e("TweetUi", "Activity cannot be found to handle share intent");
}
Intent a(String str, String str2) {
Intent intent = new Intent();
intent.setAction("android.intent.action.SEND");
intent.putExtra("android.intent.extra.SUBJECT", str);
intent.putExtra("android.intent.extra.TEXT", str2);
intent.setType("text/plain");
return intent;
}
}

View File

@@ -0,0 +1,68 @@
package com.twitter.sdk.android.tweetui;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.ImageButton;
/* loaded from: classes.dex */
public class ToggleImageButton extends ImageButton {
private static final int[] e = {R$attr.state_toggled_on};
boolean a;
String b;
String c;
final boolean d;
public ToggleImageButton(Context context) {
this(context, null);
}
public void a() {
setToggledOn(!this.a);
}
@Override // android.widget.ImageView, android.view.View
public int[] onCreateDrawableState(int i) {
int[] onCreateDrawableState = super.onCreateDrawableState(i + 2);
if (this.a) {
ImageButton.mergeDrawableStates(onCreateDrawableState, e);
}
return onCreateDrawableState;
}
@Override // android.view.View
public boolean performClick() {
if (this.d) {
a();
}
return super.performClick();
}
public void setToggledOn(boolean z) {
this.a = z;
setContentDescription(z ? this.b : this.c);
refreshDrawableState();
}
public ToggleImageButton(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
public ToggleImageButton(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
TypedArray typedArray = null;
try {
typedArray = context.getTheme().obtainStyledAttributes(attributeSet, R$styleable.ToggleImageButton, i, 0);
String string = typedArray.getString(R$styleable.ToggleImageButton_contentDescriptionOn);
String string2 = typedArray.getString(R$styleable.ToggleImageButton_contentDescriptionOff);
this.b = string == null ? (String) getContentDescription() : string;
this.c = string2 == null ? (String) getContentDescription() : string2;
this.d = typedArray.getBoolean(R$styleable.ToggleImageButton_toggleOnClick, true);
setToggledOn(false);
} finally {
if (typedArray != null) {
typedArray.recycle();
}
}
}
}

View File

@@ -0,0 +1,73 @@
package com.twitter.sdk.android.tweetui;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import com.twitter.sdk.android.core.Callback;
import com.twitter.sdk.android.core.models.Tweet;
/* loaded from: classes.dex */
public class TweetActionBarView extends LinearLayout {
final DependencyProvider a;
ToggleImageButton b;
ImageButton c;
Callback<Tweet> d;
static class DependencyProvider {
DependencyProvider() {
}
TweetUi a() {
return TweetUi.s();
}
}
public TweetActionBarView(Context context) {
this(context, null, new DependencyProvider());
}
void a() {
this.b = (ToggleImageButton) findViewById(R$id.tw__tweet_like_button);
this.c = (ImageButton) findViewById(R$id.tw__tweet_share_button);
}
@Override // android.view.View
protected void onFinishInflate() {
super.onFinishInflate();
a();
}
void setLike(Tweet tweet) {
TweetUi a = this.a.a();
if (tweet != null) {
this.b.setToggledOn(tweet.g);
this.b.setOnClickListener(new LikeTweetAction(tweet, a, this.d));
}
}
void setOnActionCallback(Callback<Tweet> callback) {
this.d = callback;
}
void setShare(Tweet tweet) {
TweetUi a = this.a.a();
if (tweet != null) {
this.c.setOnClickListener(new ShareTweetAction(tweet, a));
}
}
void setTweet(Tweet tweet) {
setLike(tweet);
setShare(tweet);
}
public TweetActionBarView(Context context, AttributeSet attributeSet) {
this(context, attributeSet, new DependencyProvider());
}
TweetActionBarView(Context context, AttributeSet attributeSet, DependencyProvider dependencyProvider) {
super(context, attributeSet);
this.a = dependencyProvider;
}
}

View File

@@ -0,0 +1,9 @@
package com.twitter.sdk.android.tweetui;
import com.twitter.sdk.android.core.models.MediaEntity;
import com.twitter.sdk.android.core.models.Tweet;
/* loaded from: classes.dex */
public interface TweetMediaClickListener {
void a(Tweet tweet, MediaEntity mediaEntity);
}

View File

@@ -0,0 +1,56 @@
package com.twitter.sdk.android.tweetui;
import android.os.Handler;
import androidx.collection.LruCache;
import com.twitter.sdk.android.core.Callback;
import com.twitter.sdk.android.core.Result;
import com.twitter.sdk.android.core.SessionManager;
import com.twitter.sdk.android.core.TwitterAuthException;
import com.twitter.sdk.android.core.TwitterCore;
import com.twitter.sdk.android.core.TwitterSession;
import com.twitter.sdk.android.core.models.Tweet;
import io.fabric.sdk.android.Fabric;
/* loaded from: classes.dex */
class TweetRepository {
private final TwitterCore a;
private final SessionManager<TwitterSession> b;
TweetRepository(Handler handler, SessionManager<TwitterSession> sessionManager) {
this(handler, sessionManager, TwitterCore.z());
}
void b(final long j, final Callback<Tweet> callback) {
a(new LoggingCallback<TwitterSession>(callback, Fabric.g()) { // from class: com.twitter.sdk.android.tweetui.TweetRepository.3
@Override // com.twitter.sdk.android.core.Callback
public void a(Result<TwitterSession> result) {
TweetRepository.this.a.a(result.a).b().destroy(Long.valueOf(j), false).enqueue(callback);
}
});
}
TweetRepository(Handler handler, SessionManager<TwitterSession> sessionManager, TwitterCore twitterCore) {
this.a = twitterCore;
this.b = sessionManager;
new LruCache(20);
new LruCache(20);
}
void a(final long j, final Callback<Tweet> callback) {
a(new LoggingCallback<TwitterSession>(callback, Fabric.g()) { // from class: com.twitter.sdk.android.tweetui.TweetRepository.2
@Override // com.twitter.sdk.android.core.Callback
public void a(Result<TwitterSession> result) {
TweetRepository.this.a.a(result.a).b().create(Long.valueOf(j), false).enqueue(callback);
}
});
}
void a(Callback<TwitterSession> callback) {
TwitterSession b = this.b.b();
if (b == null) {
callback.a(new TwitterAuthException("User authorization required"));
} else {
callback.a(new Result<>(b, null));
}
}
}

View File

@@ -0,0 +1,12 @@
package com.twitter.sdk.android.tweetui;
import com.twitter.sdk.android.core.models.Tweet;
/* loaded from: classes.dex */
public interface TweetScribeClient {
void a(Tweet tweet);
void b(Tweet tweet);
void c(Tweet tweet);
}

View File

@@ -0,0 +1,66 @@
package com.twitter.sdk.android.tweetui;
import com.twitter.sdk.android.core.internal.scribe.EventNamespace;
import com.twitter.sdk.android.core.internal.scribe.ScribeItem;
import com.twitter.sdk.android.core.models.Tweet;
import java.util.ArrayList;
/* loaded from: classes.dex */
class TweetScribeClientImpl implements TweetScribeClient {
final TweetUi a;
TweetScribeClientImpl(TweetUi tweetUi) {
this.a = tweetUi;
}
@Override // com.twitter.sdk.android.tweetui.TweetScribeClient
public void a(Tweet tweet) {
ArrayList arrayList = new ArrayList();
arrayList.add(ScribeItem.fromTweet(tweet));
this.a.a(a(), arrayList);
}
@Override // com.twitter.sdk.android.tweetui.TweetScribeClient
public void b(Tweet tweet) {
ArrayList arrayList = new ArrayList();
arrayList.add(ScribeItem.fromTweet(tweet));
this.a.a(c(), arrayList);
}
@Override // com.twitter.sdk.android.tweetui.TweetScribeClient
public void c(Tweet tweet) {
ArrayList arrayList = new ArrayList();
arrayList.add(ScribeItem.fromTweet(tweet));
this.a.a(b(), arrayList);
}
static EventNamespace a() {
EventNamespace.Builder builder = new EventNamespace.Builder();
builder.b("tfw");
builder.e("android");
builder.f("tweet");
builder.d("actions");
builder.a("favorite");
return builder.a();
}
static EventNamespace b() {
EventNamespace.Builder builder = new EventNamespace.Builder();
builder.b("tfw");
builder.e("android");
builder.f("tweet");
builder.d("actions");
builder.a("share");
return builder.a();
}
static EventNamespace c() {
EventNamespace.Builder builder = new EventNamespace.Builder();
builder.b("tfw");
builder.e("android");
builder.f("tweet");
builder.d("actions");
builder.a("unfavorite");
return builder.a();
}
}

View File

@@ -0,0 +1,93 @@
package com.twitter.sdk.android.tweetui;
import com.squareup.picasso.Picasso;
import com.twitter.sdk.android.core.GuestSessionProvider;
import com.twitter.sdk.android.core.SessionManager;
import com.twitter.sdk.android.core.TwitterCore;
import com.twitter.sdk.android.core.TwitterSession;
import com.twitter.sdk.android.core.internal.scribe.DefaultScribeClient;
import com.twitter.sdk.android.core.internal.scribe.EventNamespace;
import com.twitter.sdk.android.core.internal.scribe.ScribeItem;
import io.fabric.sdk.android.Fabric;
import io.fabric.sdk.android.Kit;
import io.fabric.sdk.android.services.concurrency.DependsOn;
import java.util.List;
@DependsOn({TwitterCore.class})
/* loaded from: classes.dex */
public class TweetUi extends Kit<Boolean> {
SessionManager<TwitterSession> g;
GuestSessionProvider h;
DefaultScribeClient i;
private TweetRepository j;
private Picasso k;
private static void r() {
if (Fabric.a(TweetUi.class) == null) {
throw new IllegalStateException("Must start TweetUi Kit in Fabric.with().");
}
}
public static TweetUi s() {
r();
return (TweetUi) Fabric.a(TweetUi.class);
}
private void t() {
this.i = new DefaultScribeClient(this, "TweetUi", this.g, this.h, f());
}
void a(EventNamespace... eventNamespaceArr) {
if (this.i == null) {
return;
}
for (EventNamespace eventNamespace : eventNamespaceArr) {
this.i.a(eventNamespace);
}
}
@Override // io.fabric.sdk.android.Kit
public String g() {
return "com.twitter.sdk.android:tweet-ui";
}
@Override // io.fabric.sdk.android.Kit
public String i() {
return "2.3.2.171";
}
@Override // io.fabric.sdk.android.Kit
protected boolean o() {
super.o();
TwitterCore z = TwitterCore.z();
this.g = z.u();
this.h = z.s();
this.j = new TweetRepository(e().e(), z.u());
return true;
}
public Picasso p() {
return this.k;
}
TweetRepository q() {
return this.j;
}
/* JADX INFO: Access modifiers changed from: protected */
/* JADX WARN: Can't rename method to resolve collision */
@Override // io.fabric.sdk.android.Kit
public Boolean c() {
this.k = Picasso.a(d());
t();
return true;
}
void a(EventNamespace eventNamespace, List<ScribeItem> list) {
DefaultScribeClient defaultScribeClient = this.i;
if (defaultScribeClient == null) {
return;
}
defaultScribeClient.a(eventNamespace, list);
}
}

View File

@@ -0,0 +1,8 @@
package com.twitter.sdk.android.tweetui;
import com.twitter.sdk.android.core.internal.scribe.ScribeItem;
/* loaded from: classes.dex */
public interface VideoScribeClient {
void a(ScribeItem scribeItem);
}

View File

@@ -0,0 +1,30 @@
package com.twitter.sdk.android.tweetui;
import com.twitter.sdk.android.core.internal.scribe.EventNamespace;
import com.twitter.sdk.android.core.internal.scribe.ScribeItem;
import java.util.ArrayList;
/* loaded from: classes.dex */
class VideoScribeClientImpl implements VideoScribeClient {
final TweetUi a;
VideoScribeClientImpl(TweetUi tweetUi) {
this.a = tweetUi;
}
@Override // com.twitter.sdk.android.tweetui.VideoScribeClient
public void a(ScribeItem scribeItem) {
ArrayList arrayList = new ArrayList();
arrayList.add(scribeItem);
this.a.a(a(), arrayList);
}
static EventNamespace a() {
EventNamespace.Builder builder = new EventNamespace.Builder();
builder.b("tfw");
builder.e("android");
builder.f("video");
builder.a("play");
return builder.a();
}
}

View File

@@ -0,0 +1,36 @@
package com.twitter.sdk.android.tweetui.internal;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.view.View;
import android.view.ViewPropertyAnimator;
/* loaded from: classes.dex */
class AnimationUtils {
public static ViewPropertyAnimator a(View view, int i) {
if (view.getVisibility() != 0) {
view.setAlpha(0.0f);
view.setVisibility(0);
}
view.clearAnimation();
ViewPropertyAnimator animate = view.animate();
animate.alpha(1.0f).setDuration(i).setListener(null);
return animate;
}
public static ViewPropertyAnimator b(final View view, int i) {
if (view.getVisibility() != 0) {
return null;
}
view.clearAnimation();
ViewPropertyAnimator animate = view.animate();
animate.alpha(0.0f).setDuration(i).setListener(new AnimatorListenerAdapter() { // from class: com.twitter.sdk.android.tweetui.internal.AnimationUtils.1
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationEnd(Animator animator) {
view.setVisibility(4);
view.setAlpha(1.0f);
}
});
return animate;
}
}

View File

@@ -0,0 +1,71 @@
package com.twitter.sdk.android.tweetui.internal;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import com.twitter.sdk.android.tweetui.R$styleable;
/* loaded from: classes.dex */
public class AspectRatioFrameLayout extends FrameLayout {
protected double a;
private int b;
public AspectRatioFrameLayout(Context context) {
this(context, null);
}
private void a(int i) {
TypedArray obtainStyledAttributes = getContext().getTheme().obtainStyledAttributes(i, R$styleable.AspectRatioFrameLayout);
try {
this.a = obtainStyledAttributes.getFloat(R$styleable.AspectRatioFrameLayout_tw__frame_layout_aspect_ratio, 1.0f);
this.b = obtainStyledAttributes.getInt(R$styleable.AspectRatioFrameLayout_tw__frame_layout_dimension_to_adjust, 0);
} finally {
obtainStyledAttributes.recycle();
}
}
@Override // android.widget.FrameLayout, android.view.View
protected void onMeasure(int i, int i2) {
int measuredHeight;
int i3;
int i4;
int measuredWidth;
int paddingLeft = getPaddingLeft() + getPaddingRight();
int paddingBottom = getPaddingBottom() + getPaddingTop();
if (this.b == 0) {
if (View.MeasureSpec.getMode(i) == 1073741824) {
measuredWidth = View.MeasureSpec.getSize(i);
} else {
super.onMeasure(i, i2);
measuredWidth = getMeasuredWidth();
}
i4 = measuredWidth - paddingLeft;
i3 = (int) (i4 / this.a);
} else {
if (View.MeasureSpec.getMode(i2) == 1073741824) {
measuredHeight = View.MeasureSpec.getSize(i2);
} else {
super.onMeasure(i, i2);
measuredHeight = getMeasuredHeight();
}
i3 = measuredHeight - paddingBottom;
i4 = (int) (i3 * this.a);
}
super.onMeasure(View.MeasureSpec.makeMeasureSpec(i4 + paddingLeft, 1073741824), View.MeasureSpec.makeMeasureSpec(i3 + paddingBottom, 1073741824));
}
public void setAspectRatio(double d) {
this.a = d;
}
public AspectRatioFrameLayout(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
public AspectRatioFrameLayout(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
a(i);
}
}

View File

@@ -0,0 +1,51 @@
package com.twitter.sdk.android.tweetui.internal;
import android.R;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.widget.FrameLayout;
import android.widget.ProgressBar;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.Target;
import com.twitter.sdk.android.tweetui.internal.SwipeToDismissTouchListener;
/* loaded from: classes.dex */
public class GalleryImageView extends FrameLayout implements Target {
final MultiTouchImageView a;
final ProgressBar b;
public GalleryImageView(Context context) {
this(context, new MultiTouchImageView(context), new ProgressBar(context));
}
@Override // com.squareup.picasso.Target
public void a(Bitmap bitmap, Picasso.LoadedFrom loadedFrom) {
this.a.setImageBitmap(bitmap);
this.b.setVisibility(8);
}
@Override // com.squareup.picasso.Target
public void a(Drawable drawable) {
}
@Override // com.squareup.picasso.Target
public void b(Drawable drawable) {
this.a.setImageResource(R.color.transparent);
this.b.setVisibility(0);
}
public void setSwipeToDismissCallback(SwipeToDismissTouchListener.Callback callback) {
this.a.setOnTouchListener(SwipeToDismissTouchListener.a(this.a, callback));
}
GalleryImageView(Context context, MultiTouchImageView multiTouchImageView, ProgressBar progressBar) {
super(context);
this.a = multiTouchImageView;
this.b = progressBar;
progressBar.setLayoutParams(new FrameLayout.LayoutParams(-2, -2, 17));
addView(progressBar);
multiTouchImageView.setLayoutParams(new FrameLayout.LayoutParams(-1, -1, 17));
addView(multiTouchImageView);
}
}

View File

@@ -0,0 +1,80 @@
package com.twitter.sdk.android.tweetui.internal;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.twitter.sdk.android.core.internal.VineCardUtils;
import com.twitter.sdk.android.core.internal.scribe.ScribeItem;
import com.twitter.sdk.android.core.models.Card;
import com.twitter.sdk.android.core.models.MediaEntity;
import com.twitter.sdk.android.core.models.VideoInfo;
import com.twitter.sdk.android.tweetui.R$drawable;
import com.twitter.sdk.android.tweetui.R$id;
import com.twitter.sdk.android.tweetui.R$layout;
/* loaded from: classes.dex */
public class MediaBadgeView extends FrameLayout {
TextView a;
ImageView b;
public MediaBadgeView(Context context) {
this(context, null);
}
void a(Context context) {
View inflate = ((LayoutInflater) context.getSystemService("layout_inflater")).inflate(R$layout.tw__media_badge, (ViewGroup) this, true);
this.a = (TextView) inflate.findViewById(R$id.tw__video_duration);
this.b = (ImageView) inflate.findViewById(R$id.tw__gif_badge);
}
void setBadge(Drawable drawable) {
this.b.setVisibility(0);
this.a.setVisibility(8);
this.b.setImageDrawable(drawable);
}
public void setCard(Card card) {
if (VineCardUtils.d(card)) {
setBadge(getResources().getDrawable(R$drawable.tw__vine_badge));
} else {
a();
}
}
public void setMediaEntity(MediaEntity mediaEntity) {
if (ScribeItem.MediaDetails.GIF_TYPE.equals(mediaEntity.type)) {
setBadge(getResources().getDrawable(R$drawable.tw__gif_badge));
} else if (!"video".equals(mediaEntity.type)) {
a();
} else {
VideoInfo videoInfo = mediaEntity.videoInfo;
setText(videoInfo == null ? 0L : videoInfo.durationMillis);
}
}
void setText(long j) {
this.a.setVisibility(0);
this.b.setVisibility(8);
this.a.setText(MediaTimeUtils.a(j));
}
public MediaBadgeView(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
public MediaBadgeView(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
a(context);
}
void a() {
this.a.setVisibility(8);
this.b.setVisibility(8);
}
}

View File

@@ -0,0 +1,14 @@
package com.twitter.sdk.android.tweetui.internal;
import java.util.Locale;
/* loaded from: classes.dex */
final class MediaTimeUtils {
static String a(long j) {
int i = (int) (j / 1000);
int i2 = i % 60;
int i3 = (i / 60) % 60;
int i4 = i / 3600;
return i4 > 0 ? String.format(Locale.getDefault(), "%1$d:%2$02d:%3$02d", Integer.valueOf(i4), Integer.valueOf(i3), Integer.valueOf(i2)) : String.format(Locale.getDefault(), "%1$d:%2$02d", Integer.valueOf(i3), Integer.valueOf(i2));
}
}

View File

@@ -0,0 +1,275 @@
package com.twitter.sdk.android.tweetui.internal;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Matrix;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.ViewParent;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.ImageView;
import com.twitter.sdk.android.tweetui.internal.SwipeToDismissTouchListener;
/* loaded from: classes.dex */
public class MultiTouchImageView extends ImageView implements SwipeToDismissTouchListener.SwipeableViewProvider {
final ScaleGestureDetector a;
final GestureDetector b;
final Matrix c;
final Matrix d;
final Matrix e;
final RectF f;
final RectF g;
final float[] h;
boolean i;
public MultiTouchImageView(Context context) {
this(context, null);
}
void a(Drawable drawable) {
RectF rectF = new RectF(0.0f, 0.0f, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
this.d.reset();
this.d.setRectToRect(rectF, this.f, Matrix.ScaleToFit.CENTER);
}
void b() {
this.f.set(getPaddingLeft(), getPaddingTop(), getWidth() - getPaddingRight(), getHeight() - getPaddingBottom());
}
boolean c() {
Drawable drawable = getDrawable();
return drawable != null && drawable.getIntrinsicWidth() > 0;
}
void d() {
this.e.reset();
}
void e() {
f();
setScaleType(ImageView.ScaleType.MATRIX);
setImageMatrix(getDrawMatrix());
}
/* JADX WARN: Removed duplicated region for block: B:12:0x0069 */
/* JADX WARN: Removed duplicated region for block: B:7:0x0056 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
void f() {
/*
r7 = this;
android.graphics.Matrix r0 = r7.getDrawMatrix()
android.graphics.RectF r0 = r7.a(r0)
float r1 = r0.height()
android.graphics.RectF r2 = r7.f
float r2 = r2.height()
r3 = 1073741824(0x40000000, float:2.0)
r4 = 0
int r1 = (r1 > r2 ? 1 : (r1 == r2 ? 0 : -1))
if (r1 > 0) goto L29
android.graphics.RectF r1 = r7.f
float r1 = r1.height()
float r2 = r0.height()
float r1 = r1 - r2
float r1 = r1 / r3
float r2 = r0.top
L27:
float r1 = r1 - r2
goto L47
L29:
float r1 = r0.top
int r2 = (r1 > r4 ? 1 : (r1 == r4 ? 0 : -1))
if (r2 <= 0) goto L31
float r1 = -r1
goto L47
L31:
float r1 = r0.bottom
android.graphics.RectF r2 = r7.f
float r2 = r2.height()
int r1 = (r1 > r2 ? 1 : (r1 == r2 ? 0 : -1))
if (r1 >= 0) goto L46
android.graphics.RectF r1 = r7.f
float r1 = r1.height()
float r2 = r0.bottom
goto L27
L46:
r1 = 0
L47:
float r2 = r0.width()
android.graphics.RectF r5 = r7.f
float r5 = r5.width()
r6 = 1
int r2 = (r2 > r5 ? 1 : (r2 == r5 ? 0 : -1))
if (r2 > 0) goto L69
r7.i = r6
android.graphics.RectF r2 = r7.f
float r2 = r2.width()
float r4 = r0.width()
float r2 = r2 - r4
float r2 = r2 / r3
float r0 = r0.left
L66:
float r4 = r2 - r0
goto L8d
L69:
float r2 = r0.left
int r3 = (r2 > r4 ? 1 : (r2 == r4 ? 0 : -1))
if (r3 <= 0) goto L73
r7.i = r6
float r4 = -r2
goto L8d
L73:
float r2 = r0.right
android.graphics.RectF r3 = r7.f
float r3 = r3.width()
int r2 = (r2 > r3 ? 1 : (r2 == r3 ? 0 : -1))
if (r2 >= 0) goto L8a
r7.i = r6
android.graphics.RectF r2 = r7.f
float r2 = r2.width()
float r0 = r0.right
goto L66
L8a:
r0 = 0
r7.i = r0
L8d:
r7.a(r4, r1)
return
*/
throw new UnsupportedOperationException("Method not decompiled: com.twitter.sdk.android.tweetui.internal.MultiTouchImageView.f():void");
}
Matrix getDrawMatrix() {
this.c.set(this.d);
this.c.postConcat(this.e);
return this.c;
}
float getScale() {
this.e.getValues(this.h);
return this.h[0];
}
@Override // android.view.View
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
super.onLayout(z, i, i2, i3, i4);
if (c()) {
b();
a(getDrawable());
e();
}
}
@Override // android.view.View
public boolean onTouchEvent(MotionEvent motionEvent) {
if (!c()) {
return false;
}
a(true);
return (this.b.onTouchEvent(motionEvent) || this.a.onTouchEvent(motionEvent)) || super.onTouchEvent(motionEvent);
}
public MultiTouchImageView(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
public MultiTouchImageView(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.c = new Matrix();
this.d = new Matrix();
this.e = new Matrix();
this.f = new RectF();
this.g = new RectF();
this.h = new float[9];
this.i = false;
this.a = new ScaleGestureDetector(context, new ScaleGestureDetector.SimpleOnScaleGestureListener() { // from class: com.twitter.sdk.android.tweetui.internal.MultiTouchImageView.1
@Override // android.view.ScaleGestureDetector.SimpleOnScaleGestureListener, android.view.ScaleGestureDetector.OnScaleGestureListener
public boolean onScale(ScaleGestureDetector scaleGestureDetector) {
MultiTouchImageView.this.a(scaleGestureDetector.getScaleFactor(), scaleGestureDetector.getFocusX(), scaleGestureDetector.getFocusY());
MultiTouchImageView.this.e();
return true;
}
@Override // android.view.ScaleGestureDetector.SimpleOnScaleGestureListener, android.view.ScaleGestureDetector.OnScaleGestureListener
public void onScaleEnd(ScaleGestureDetector scaleGestureDetector) {
if (MultiTouchImageView.this.getScale() < 1.0f) {
MultiTouchImageView.this.d();
MultiTouchImageView.this.e();
}
}
});
this.b = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() { // from class: com.twitter.sdk.android.tweetui.internal.MultiTouchImageView.2
@Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnDoubleTapListener
public boolean onDoubleTap(MotionEvent motionEvent) {
if (MultiTouchImageView.this.getScale() > 1.0f) {
MultiTouchImageView multiTouchImageView = MultiTouchImageView.this;
multiTouchImageView.a(multiTouchImageView.getScale(), 1.0f, motionEvent.getX(), motionEvent.getY());
return true;
}
MultiTouchImageView multiTouchImageView2 = MultiTouchImageView.this;
multiTouchImageView2.a(multiTouchImageView2.getScale(), 2.0f, motionEvent.getX(), motionEvent.getY());
return true;
}
@Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnGestureListener
public boolean onScroll(MotionEvent motionEvent, MotionEvent motionEvent2, float f, float f2) {
MultiTouchImageView.this.a(-f, -f2);
MultiTouchImageView.this.e();
MultiTouchImageView multiTouchImageView = MultiTouchImageView.this;
if (!multiTouchImageView.i || multiTouchImageView.a.isInProgress()) {
return true;
}
MultiTouchImageView.this.a(false);
return true;
}
});
}
void a(boolean z) {
ViewParent parent = getParent();
if (parent != null) {
parent.requestDisallowInterceptTouchEvent(z);
}
}
void a(float f, float f2, float f3) {
this.e.postScale(f, f, f2, f3);
}
void a(float f, float f2) {
this.e.postTranslate(f, f2);
}
RectF a(Matrix matrix) {
if (getDrawable() != null) {
this.g.set(0.0f, 0.0f, r0.getIntrinsicWidth(), r0.getIntrinsicHeight());
matrix.mapRect(this.g);
}
return this.g;
}
void a(float f, float f2, final float f3, final float f4) {
ValueAnimator ofFloat = ValueAnimator.ofFloat(f, f2);
ofFloat.setDuration(300L);
ofFloat.setInterpolator(new AccelerateDecelerateInterpolator());
ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.twitter.sdk.android.tweetui.internal.MultiTouchImageView.3
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
public void onAnimationUpdate(ValueAnimator valueAnimator) {
MultiTouchImageView.this.a(((Float) valueAnimator.getAnimatedValue()).floatValue() / MultiTouchImageView.this.getScale(), f3, f4);
MultiTouchImageView.this.e();
}
});
ofFloat.start();
}
@Override // com.twitter.sdk.android.tweetui.internal.SwipeToDismissTouchListener.SwipeableViewProvider
public boolean a() {
return getScale() == 1.0f;
}
}

View File

@@ -0,0 +1,100 @@
package com.twitter.sdk.android.tweetui.internal;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;
/* loaded from: classes.dex */
public class OverlayImageView extends ImageView {
Overlay a;
public OverlayImageView(Context context) {
super(context);
this.a = new Overlay(null);
}
@Override // android.widget.ImageView, android.view.View
protected void drawableStateChanged() {
super.drawableStateChanged();
this.a.a(getDrawableState());
}
@Override // android.widget.ImageView, android.view.View, android.graphics.drawable.Drawable.Callback
public void invalidateDrawable(Drawable drawable) {
if (drawable == this.a.a) {
invalidate();
} else {
super.invalidateDrawable(drawable);
}
}
@Override // android.widget.ImageView, android.view.View
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
this.a.a(canvas);
}
@Override // android.widget.ImageView, android.view.View
protected void onMeasure(int i, int i2) {
super.onMeasure(i, i2);
this.a.a(getMeasuredWidth(), getMeasuredHeight());
}
@Override // android.view.View
protected void onSizeChanged(int i, int i2, int i3, int i4) {
super.onSizeChanged(i, i2, i3, i4);
this.a.a(i, i2);
}
public void setOverlayDrawable(Drawable drawable) {
Overlay overlay = this.a;
if (drawable != overlay.a) {
overlay.a(this);
if (drawable != null) {
drawable.setCallback(this);
}
this.a = new Overlay(drawable);
this.a.a(getDrawableState());
requestLayout();
}
}
protected static class Overlay {
final Drawable a;
Overlay(Drawable drawable) {
this.a = drawable;
}
protected void a(ImageView imageView) {
Drawable drawable = this.a;
if (drawable != null) {
drawable.setCallback(null);
imageView.unscheduleDrawable(this.a);
}
}
protected void a(int i, int i2) {
Drawable drawable = this.a;
if (drawable != null) {
drawable.setBounds(0, 0, i, i2);
}
}
protected void a(int[] iArr) {
Drawable drawable = this.a;
if (drawable == null || !drawable.isStateful()) {
return;
}
this.a.setState(iArr);
}
protected void a(Canvas canvas) {
Drawable drawable = this.a;
if (drawable != null) {
drawable.draw(canvas);
}
}
}
}

View File

@@ -0,0 +1,161 @@
package com.twitter.sdk.android.tweetui.internal;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.util.Property;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
/* loaded from: classes.dex */
public class SwipeToDismissTouchListener implements View.OnTouchListener {
private int a;
private float b;
private final float c;
private final float d;
private Callback e;
private float f;
private float g;
private int h;
private boolean i;
public interface Callback {
void a(float f);
void onDismiss();
}
public interface SwipeableViewProvider {
boolean a();
}
SwipeToDismissTouchListener(Callback callback, int i, float f) {
this(callback, i, f, 0.2f * f);
}
void b(View view) {
if (view.getTranslationY() != 0.0f) {
ObjectAnimator duration = ObjectAnimator.ofFloat(view, (Property<View, Float>) View.TRANSLATION_Y, 0.0f).setDuration(100L);
duration.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.twitter.sdk.android.tweetui.internal.SwipeToDismissTouchListener.1
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
public void onAnimationUpdate(ValueAnimator valueAnimator) {
float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
if (SwipeToDismissTouchListener.this.e != null) {
SwipeToDismissTouchListener.this.e.a(floatValue);
}
}
});
duration.start();
}
}
boolean c(float f) {
return Math.abs(f) > ((float) this.a);
}
/* JADX WARN: Multi-variable type inference failed */
@Override // android.view.View.OnTouchListener
@SuppressLint({"ClickableViewAccessibility"})
public boolean onTouch(View view, MotionEvent motionEvent) {
return ((!(view instanceof SwipeableViewProvider) || ((SwipeableViewProvider) view).a() || a()) ? a(view, motionEvent) : false) || view.onTouchEvent(motionEvent);
}
SwipeToDismissTouchListener(Callback callback, int i, float f, float f2) {
a(callback);
this.a = i;
this.c = f;
this.d = f2;
}
public static SwipeToDismissTouchListener a(View view, Callback callback) {
return new SwipeToDismissTouchListener(callback, ViewConfiguration.get(view.getContext()).getScaledTouchSlop(), view.getContext().getResources().getDisplayMetrics().heightPixels * 0.5f);
}
boolean a(View view, MotionEvent motionEvent) {
int actionMasked = motionEvent.getActionMasked();
if (actionMasked != 0) {
if (actionMasked != 1) {
if (actionMasked == 2) {
float rawX = motionEvent.getRawX();
float rawY = motionEvent.getRawY();
float f = rawY - this.b;
float f2 = rawX - this.f;
float f3 = rawY - this.g;
this.f = rawX;
this.g = rawY;
if (a(motionEvent) && (this.i || (c(f) && a(f2, f3)))) {
this.i = true;
a(view, f3);
}
} else if (actionMasked != 3) {
if (actionMasked == 5) {
b(view);
this.i = false;
this.h = -1;
}
}
}
boolean a = (a(motionEvent) && this.i) ? a(view) : false;
this.i = false;
return a;
}
this.f = motionEvent.getRawX();
float rawY2 = motionEvent.getRawY();
this.g = rawY2;
this.b = rawY2;
this.i = false;
this.h = motionEvent.getPointerId(motionEvent.getPointerCount() - 1);
return false;
}
double b(float f) {
return 1.0d - (Math.pow(Math.abs(f), 2.0d) / Math.pow(this.d * 2.0f, 2.0d));
}
boolean a(float f, float f2) {
return Math.abs(f2) > Math.abs(f);
}
boolean a() {
return this.i;
}
boolean a(MotionEvent motionEvent) {
return this.h >= 0 && motionEvent.getPointerCount() == 1;
}
boolean a(View view) {
float translationY = view.getTranslationY();
float f = this.d;
if (translationY <= f && translationY >= (-f)) {
b(view);
return false;
}
Callback callback = this.e;
if (callback == null) {
return true;
}
callback.onDismiss();
return true;
}
void a(View view, float f) {
float translationY = view.getTranslationY();
float a = a(translationY + ((float) (f * b(translationY))));
view.setTranslationY(a);
Callback callback = this.e;
if (callback != null) {
callback.a(a);
}
}
float a(float f) {
float f2 = this.c;
return f < (-f2) ? -f2 : f > f2 ? f2 : f;
}
public void a(Callback callback) {
this.e = callback;
}
}

View File

@@ -0,0 +1,38 @@
package com.twitter.sdk.android.tweetui.internal;
import android.os.Build;
import com.twitter.sdk.android.core.internal.scribe.ScribeItem;
import com.twitter.sdk.android.core.models.MediaEntity;
import com.twitter.sdk.android.core.models.VideoInfo;
/* loaded from: classes.dex */
public final class TweetMediaUtils {
public static VideoInfo.Variant a(MediaEntity mediaEntity) {
for (VideoInfo.Variant variant : mediaEntity.videoInfo.variants) {
if (a(variant)) {
return variant;
}
}
return null;
}
public static boolean b(MediaEntity mediaEntity) {
return ScribeItem.MediaDetails.GIF_TYPE.equals(mediaEntity.type) || ("video".endsWith(mediaEntity.type) && mediaEntity.videoInfo.durationMillis < 6500);
}
static boolean c(MediaEntity mediaEntity) {
return "photo".equals(mediaEntity.type);
}
static boolean d(MediaEntity mediaEntity) {
return "video".equals(mediaEntity.type) || ScribeItem.MediaDetails.GIF_TYPE.equals(mediaEntity.type);
}
public static boolean e(MediaEntity mediaEntity) {
return !ScribeItem.MediaDetails.GIF_TYPE.equals(mediaEntity.type);
}
static boolean a(VideoInfo.Variant variant) {
return (Build.VERSION.SDK_INT >= 21 && "application/x-mpegURL".equals(variant.contentType)) || "video/mp4".equals(variant.contentType);
}
}

View File

@@ -0,0 +1,357 @@
package com.twitter.sdk.android.tweetui.internal;
import android.R;
import android.content.Context;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.Path;
import android.graphics.RectF;
import android.os.Build;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.squareup.picasso.Callback;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.RequestCreator;
import com.twitter.sdk.android.core.IntentUtils;
import com.twitter.sdk.android.core.internal.VineCardUtils;
import com.twitter.sdk.android.core.internal.scribe.ScribeItem;
import com.twitter.sdk.android.core.models.Card;
import com.twitter.sdk.android.core.models.ImageValue;
import com.twitter.sdk.android.core.models.MediaEntity;
import com.twitter.sdk.android.core.models.Tweet;
import com.twitter.sdk.android.tweetui.GalleryActivity;
import com.twitter.sdk.android.tweetui.PlayerActivity;
import com.twitter.sdk.android.tweetui.R$dimen;
import com.twitter.sdk.android.tweetui.R$drawable;
import com.twitter.sdk.android.tweetui.R$id;
import com.twitter.sdk.android.tweetui.R$string;
import com.twitter.sdk.android.tweetui.TweetMediaClickListener;
import com.twitter.sdk.android.tweetui.TweetUi;
import java.lang.ref.WeakReference;
import java.util.Collections;
import java.util.List;
/* loaded from: classes.dex */
public class TweetMediaView extends ViewGroup implements View.OnClickListener {
private final OverlayImageView[] a;
private List<MediaEntity> b;
private final Path c;
private final RectF d;
private final int e;
private int f;
final float[] g;
int h;
int i;
final DependencyProvider j;
boolean k;
TweetMediaClickListener l;
Tweet m;
static class DependencyProvider {
DependencyProvider() {
}
Picasso a() {
return TweetUi.s().p();
}
}
static class PicassoCallback implements Callback {
final WeakReference<ImageView> a;
PicassoCallback(ImageView imageView) {
this.a = new WeakReference<>(imageView);
}
@Override // com.squareup.picasso.Callback
public void onError() {
}
@Override // com.squareup.picasso.Callback
public void onSuccess() {
ImageView imageView = this.a.get();
if (imageView != null) {
imageView.setBackgroundResource(R.color.transparent);
}
}
}
static class Size {
static final Size c = new Size();
final int a;
final int b;
private Size() {
this(0, 0);
}
static Size a(int i, int i2) {
int max = Math.max(i, 0);
int max2 = Math.max(i2, 0);
return (max == 0 && max2 == 0) ? c : new Size(max, max2);
}
private Size(int i, int i2) {
this.a = i;
this.b = i2;
}
}
public TweetMediaView(Context context) {
this(context, null);
}
public void a(MediaEntity mediaEntity) {
if (TweetMediaUtils.a(mediaEntity) != null) {
Intent intent = new Intent(getContext(), (Class<?>) PlayerActivity.class);
intent.putExtra("PLAYER_ITEM", new PlayerActivity.PlayerItem(TweetMediaUtils.a(mediaEntity).url, TweetMediaUtils.b(mediaEntity), TweetMediaUtils.e(mediaEntity), null, null));
IntentUtils.b(getContext(), intent);
}
}
public void b(int i) {
Intent intent = new Intent(getContext(), (Class<?>) GalleryActivity.class);
intent.putExtra("GALLERY_ITEM", new GalleryActivity.GalleryItem(this.m.i, i, this.b));
IntentUtils.b(getContext(), intent);
}
@Override // android.view.ViewGroup, android.view.View
protected void dispatchDraw(Canvas canvas) {
if (!this.k || Build.VERSION.SDK_INT < 18) {
super.dispatchDraw(canvas);
return;
}
int save = canvas.save();
canvas.clipPath(this.c);
super.dispatchDraw(canvas);
canvas.restoreToCount(save);
}
@Override // android.view.View.OnClickListener
public void onClick(View view) {
Integer num = (Integer) view.getTag(R$id.tw__entity_index);
if (this.l != null) {
this.l.a(this.m, !this.b.isEmpty() ? this.b.get(num.intValue()) : null);
return;
}
if (this.b.isEmpty()) {
a(this.m);
return;
}
MediaEntity mediaEntity = this.b.get(num.intValue());
if (TweetMediaUtils.d(mediaEntity)) {
a(mediaEntity);
} else if (TweetMediaUtils.c(mediaEntity)) {
b(num.intValue());
}
}
@Override // android.view.ViewGroup, android.view.View
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
if (this.f > 0) {
b();
}
}
@Override // android.view.View
protected void onMeasure(int i, int i2) {
Size a = this.f > 0 ? a(i, i2) : Size.c;
setMeasuredDimension(a.a, a.b);
}
@Override // android.view.View
protected void onSizeChanged(int i, int i2, int i3, int i4) {
super.onSizeChanged(i, i2, i3, i4);
this.c.reset();
this.d.set(0.0f, 0.0f, i, i2);
this.c.addRoundRect(this.d, this.g, Path.Direction.CW);
this.c.close();
}
public void setMediaBgColor(int i) {
this.h = i;
}
public void setPhotoErrorResId(int i) {
this.i = i;
}
public void setTweetMediaClickListener(TweetMediaClickListener tweetMediaClickListener) {
this.l = tweetMediaClickListener;
}
public void setVineCard(Tweet tweet) {
Card card;
if (tweet == null || (card = tweet.H) == null || !VineCardUtils.d(card)) {
return;
}
this.m = tweet;
this.b = Collections.emptyList();
a();
a(tweet.H);
this.k = false;
requestLayout();
}
public TweetMediaView(Context context, AttributeSet attributeSet) {
this(context, attributeSet, new DependencyProvider());
}
TweetMediaView(Context context, AttributeSet attributeSet, DependencyProvider dependencyProvider) {
super(context, attributeSet);
this.a = new OverlayImageView[4];
this.b = Collections.emptyList();
this.c = new Path();
this.d = new RectF();
this.g = new float[8];
this.h = -16777216;
this.j = dependencyProvider;
this.e = getResources().getDimensionPixelSize(R$dimen.tw__media_view_divider_size);
this.i = R$drawable.tw__ic_tweet_photo_error_dark;
}
void b() {
int measuredWidth = getMeasuredWidth();
int measuredHeight = getMeasuredHeight();
int i = this.e;
int i2 = (measuredWidth - i) / 2;
int i3 = (measuredHeight - i) / 2;
int i4 = i2 + i;
int i5 = this.f;
if (i5 == 1) {
a(0, 0, 0, measuredWidth, measuredHeight);
return;
}
if (i5 == 2) {
a(0, 0, 0, i2, measuredHeight);
a(1, i2 + this.e, 0, measuredWidth, measuredHeight);
return;
}
if (i5 == 3) {
a(0, 0, 0, i2, measuredHeight);
a(1, i4, 0, measuredWidth, i3);
a(2, i4, i3 + this.e, measuredWidth, measuredHeight);
} else {
if (i5 != 4) {
return;
}
a(0, 0, 0, i2, i3);
a(2, 0, i3 + this.e, i2, measuredHeight);
a(1, i4, 0, measuredWidth, i3);
a(3, i4, i3 + this.e, measuredWidth, measuredHeight);
}
}
public void a(Tweet tweet) {
Card card = tweet.H;
Intent intent = new Intent(getContext(), (Class<?>) PlayerActivity.class);
intent.putExtra("PLAYER_ITEM", new PlayerActivity.PlayerItem(VineCardUtils.c(card), true, false, null, null));
intent.putExtra("SCRIBE_ITEM", ScribeItem.fromTweetCard(tweet.i, card));
IntentUtils.b(getContext(), intent);
}
Size a(int i, int i2) {
int size = View.MeasureSpec.getSize(i);
int size2 = View.MeasureSpec.getSize(i2);
int i3 = this.e;
int i4 = (size - i3) / 2;
int i5 = (size2 - i3) / 2;
int i6 = this.f;
if (i6 == 1) {
a(0, size, size2);
} else if (i6 == 2) {
a(0, i4, size2);
a(1, i4, size2);
} else if (i6 == 3) {
a(0, i4, size2);
a(1, i4, i5);
a(2, i4, i5);
} else if (i6 == 4) {
a(0, i4, i5);
a(1, i4, i5);
a(2, i4, i5);
a(3, i4, i5);
}
return Size.a(size, size2);
}
void b(ImageView imageView, String str) {
Picasso a = this.j.a();
if (a == null) {
return;
}
RequestCreator a2 = a.a(str);
a2.b();
a2.a();
a2.a(this.i);
a2.a(imageView, new PicassoCallback(imageView));
}
void a(int i, int i2, int i3) {
this.a[i].measure(View.MeasureSpec.makeMeasureSpec(i2, 1073741824), View.MeasureSpec.makeMeasureSpec(i3, 1073741824));
}
void a(int i, int i2, int i3, int i4, int i5) {
OverlayImageView overlayImageView = this.a[i];
if (overlayImageView.getLeft() == i2 && overlayImageView.getTop() == i3 && overlayImageView.getRight() == i4 && overlayImageView.getBottom() == i5) {
return;
}
overlayImageView.layout(i2, i3, i4, i5);
}
void a() {
for (int i = 0; i < this.f; i++) {
OverlayImageView overlayImageView = this.a[i];
if (overlayImageView != null) {
overlayImageView.setVisibility(8);
}
}
this.f = 0;
}
void a(Card card) {
this.f = 1;
OverlayImageView a = a(0);
ImageValue a2 = VineCardUtils.a(card);
a(a, a2.b);
b(a, a2.a);
a(a, true);
}
OverlayImageView a(int i) {
OverlayImageView overlayImageView = this.a[i];
if (overlayImageView == null) {
overlayImageView = new OverlayImageView(getContext());
overlayImageView.setLayoutParams(generateDefaultLayoutParams());
overlayImageView.setOnClickListener(this);
this.a[i] = overlayImageView;
addView(overlayImageView, i);
} else {
a(i, 0, 0);
a(i, 0, 0, 0, 0);
}
overlayImageView.setVisibility(0);
overlayImageView.setBackgroundColor(this.h);
overlayImageView.setTag(R$id.tw__entity_index, Integer.valueOf(i));
return overlayImageView;
}
void a(ImageView imageView, String str) {
if (!TextUtils.isEmpty(str)) {
imageView.setContentDescription(str);
} else {
imageView.setContentDescription(getResources().getString(R$string.tw__tweet_media));
}
}
void a(OverlayImageView overlayImageView, boolean z) {
if (z) {
overlayImageView.setOverlayDrawable(getContext().getResources().getDrawable(R$drawable.tw__player_overlay));
} else {
overlayImageView.setOverlayDrawable(null);
}
}
}

View File

@@ -0,0 +1,231 @@
package com.twitter.sdk.android.tweetui.internal;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.SeekBar;
import android.widget.TextView;
import com.twitter.sdk.android.tweetui.R$drawable;
import com.twitter.sdk.android.tweetui.R$id;
import com.twitter.sdk.android.tweetui.R$layout;
import com.twitter.sdk.android.tweetui.R$string;
/* loaded from: classes.dex */
public class VideoControlView extends FrameLayout {
MediaPlayerControl a;
ImageButton b;
TextView c;
TextView d;
SeekBar e;
@SuppressLint({"HandlerLeak"})
private final Handler f;
public interface MediaPlayerControl {
int getBufferPercentage();
int getCurrentPosition();
int getDuration();
boolean isPlaying();
void pause();
void seekTo(int i);
void start();
}
public VideoControlView(Context context) {
super(context);
this.f = new Handler() { // from class: com.twitter.sdk.android.tweetui.internal.VideoControlView.1
@Override // android.os.Handler
public void handleMessage(Message message) {
if (message.what == 1001) {
VideoControlView videoControlView = VideoControlView.this;
if (videoControlView.a == null) {
return;
}
videoControlView.k();
VideoControlView.this.l();
if (VideoControlView.this.e() && VideoControlView.this.a.isPlaying()) {
sendMessageDelayed(obtainMessage(1001), 500L);
}
}
}
};
}
View.OnClickListener b() {
return new View.OnClickListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoControlView.2
@Override // android.view.View.OnClickListener
public void onClick(View view) {
if (VideoControlView.this.a.isPlaying()) {
VideoControlView.this.a.pause();
} else {
VideoControlView.this.a.start();
}
VideoControlView.this.i();
}
};
}
void c() {
this.f.removeMessages(1001);
AnimationUtils.b(this, 150);
}
void d() {
((LayoutInflater) getContext().getSystemService("layout_inflater")).inflate(R$layout.tw__video_control, this);
this.b = (ImageButton) findViewById(R$id.tw__state_control);
this.c = (TextView) findViewById(R$id.tw__current_time);
this.d = (TextView) findViewById(R$id.tw__duration);
this.e = (SeekBar) findViewById(R$id.tw__progress);
this.e.setMax(1000);
this.e.setOnSeekBarChangeListener(a());
this.b.setOnClickListener(b());
setDuration(0);
setCurrentTime(0);
a(0, 0, 0);
}
public boolean e() {
return getVisibility() == 0;
}
void f() {
this.b.setImageResource(R$drawable.tw__video_pause_btn);
this.b.setContentDescription(getContext().getString(R$string.tw__pause));
}
void g() {
this.b.setImageResource(R$drawable.tw__video_play_btn);
this.b.setContentDescription(getContext().getString(R$string.tw__play));
}
void h() {
this.b.setImageResource(R$drawable.tw__video_replay_btn);
this.b.setContentDescription(getContext().getString(R$string.tw__replay));
}
void i() {
this.f.sendEmptyMessage(1001);
AnimationUtils.a(this, 150);
}
public void j() {
this.f.sendEmptyMessage(1001);
}
void k() {
int duration = this.a.getDuration();
int currentPosition = this.a.getCurrentPosition();
int bufferPercentage = this.a.getBufferPercentage();
setDuration(duration);
setCurrentTime(currentPosition);
a(currentPosition, duration, bufferPercentage);
}
void l() {
if (this.a.isPlaying()) {
f();
} else if (this.a.getCurrentPosition() > Math.max(this.a.getDuration() - 500, 0)) {
h();
} else {
g();
}
}
@Override // android.view.View
protected void onFinishInflate() {
super.onFinishInflate();
d();
}
void setCurrentTime(int i) {
this.c.setText(MediaTimeUtils.a(i));
}
void setDuration(int i) {
this.d.setText(MediaTimeUtils.a(i));
}
public void setMediaPlayer(MediaPlayerControl mediaPlayerControl) {
this.a = mediaPlayerControl;
}
SeekBar.OnSeekBarChangeListener a() {
return new SeekBar.OnSeekBarChangeListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoControlView.3
@Override // android.widget.SeekBar.OnSeekBarChangeListener
public void onProgressChanged(SeekBar seekBar, int i, boolean z) {
if (z) {
int duration = (int) ((VideoControlView.this.a.getDuration() * i) / 1000);
VideoControlView.this.a.seekTo(duration);
VideoControlView.this.setCurrentTime(duration);
}
}
@Override // android.widget.SeekBar.OnSeekBarChangeListener
public void onStartTrackingTouch(SeekBar seekBar) {
VideoControlView.this.f.removeMessages(1001);
}
@Override // android.widget.SeekBar.OnSeekBarChangeListener
public void onStopTrackingTouch(SeekBar seekBar) {
VideoControlView.this.f.sendEmptyMessage(1001);
}
};
}
public VideoControlView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.f = new Handler() { // from class: com.twitter.sdk.android.tweetui.internal.VideoControlView.1
@Override // android.os.Handler
public void handleMessage(Message message) {
if (message.what == 1001) {
VideoControlView videoControlView = VideoControlView.this;
if (videoControlView.a == null) {
return;
}
videoControlView.k();
VideoControlView.this.l();
if (VideoControlView.this.e() && VideoControlView.this.a.isPlaying()) {
sendMessageDelayed(obtainMessage(1001), 500L);
}
}
}
};
}
void a(int i, int i2, int i3) {
this.e.setProgress((int) (i2 > 0 ? (i * 1000) / i2 : 0L));
this.e.setSecondaryProgress(i3 * 10);
}
public VideoControlView(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.f = new Handler() { // from class: com.twitter.sdk.android.tweetui.internal.VideoControlView.1
@Override // android.os.Handler
public void handleMessage(Message message) {
if (message.what == 1001) {
VideoControlView videoControlView = VideoControlView.this;
if (videoControlView.a == null) {
return;
}
videoControlView.k();
VideoControlView.this.l();
if (VideoControlView.this.e() && VideoControlView.this.a.isPlaying()) {
sendMessageDelayed(obtainMessage(1001), 500L);
}
}
}
};
}
}

View File

@@ -0,0 +1,628 @@
package com.twitter.sdk.android.tweetui.internal;
import android.content.Context;
import android.media.MediaPlayer;
import android.net.Uri;
import android.util.AttributeSet;
import android.util.Log;
import android.view.GestureDetector;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import com.twitter.sdk.android.tweetui.internal.VideoControlView;
/* loaded from: classes.dex */
public class VideoView extends SurfaceView implements VideoControlView.MediaPlayerControl {
private GestureDetector A;
SurfaceHolder.Callback B;
private String a;
private Uri b;
private int c;
private int d;
private SurfaceHolder e;
private MediaPlayer f;
private int g;
private int h;
private int i;
private int j;
private int k;
private VideoControlView l;
private MediaPlayer.OnCompletionListener m;
private MediaPlayer.OnPreparedListener n;
private int o;
private MediaPlayer.OnErrorListener p;
private MediaPlayer.OnInfoListener q;
private int r;
private boolean s;
MediaPlayer.OnVideoSizeChangedListener t;
MediaPlayer.OnPreparedListener u;
private MediaPlayer.OnCompletionListener v;
private MediaPlayer.OnInfoListener x;
private MediaPlayer.OnErrorListener y;
private MediaPlayer.OnBufferingUpdateListener z;
public VideoView(Context context) {
super(context);
this.a = "VideoView";
this.c = 0;
this.d = 0;
this.e = null;
this.f = null;
this.t = new MediaPlayer.OnVideoSizeChangedListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.1
@Override // android.media.MediaPlayer.OnVideoSizeChangedListener
public void onVideoSizeChanged(MediaPlayer mediaPlayer, int i, int i2) {
VideoView.this.h = mediaPlayer.getVideoWidth();
VideoView.this.i = mediaPlayer.getVideoHeight();
if (VideoView.this.h == 0 || VideoView.this.i == 0) {
return;
}
VideoView.this.getHolder().setFixedSize(VideoView.this.h, VideoView.this.i);
VideoView.this.requestLayout();
}
};
this.u = new MediaPlayer.OnPreparedListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.2
@Override // android.media.MediaPlayer.OnPreparedListener
public void onPrepared(MediaPlayer mediaPlayer) {
VideoView.this.c = 2;
if (VideoView.this.n != null) {
VideoView.this.n.onPrepared(VideoView.this.f);
}
if (VideoView.this.l != null) {
VideoView.this.l.setEnabled(true);
}
VideoView.this.h = mediaPlayer.getVideoWidth();
VideoView.this.i = mediaPlayer.getVideoHeight();
int i = VideoView.this.r;
if (i != 0) {
VideoView.this.seekTo(i);
}
if (VideoView.this.h == 0 || VideoView.this.i == 0) {
if (VideoView.this.d == 3) {
VideoView.this.start();
return;
}
return;
}
VideoView.this.getHolder().setFixedSize(VideoView.this.h, VideoView.this.i);
if (VideoView.this.j == VideoView.this.h && VideoView.this.k == VideoView.this.i) {
if (VideoView.this.d == 3) {
VideoView.this.start();
if (VideoView.this.l != null) {
VideoView.this.l.i();
return;
}
return;
}
if (VideoView.this.isPlaying()) {
return;
}
if ((i != 0 || VideoView.this.getCurrentPosition() > 0) && VideoView.this.l != null) {
VideoView.this.l.i();
}
}
}
};
this.v = new MediaPlayer.OnCompletionListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.3
@Override // android.media.MediaPlayer.OnCompletionListener
public void onCompletion(MediaPlayer mediaPlayer) {
VideoView.this.c = 5;
VideoView.this.d = 5;
if (VideoView.this.m != null) {
VideoView.this.m.onCompletion(VideoView.this.f);
}
}
};
this.x = new MediaPlayer.OnInfoListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.4
@Override // android.media.MediaPlayer.OnInfoListener
public boolean onInfo(MediaPlayer mediaPlayer, int i, int i2) {
if (VideoView.this.q == null) {
return true;
}
VideoView.this.q.onInfo(mediaPlayer, i, i2);
return true;
}
};
this.y = new MediaPlayer.OnErrorListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.5
@Override // android.media.MediaPlayer.OnErrorListener
public boolean onError(MediaPlayer mediaPlayer, int i, int i2) {
Log.d(VideoView.this.a, "Error: " + i + "," + i2);
VideoView.this.c = -1;
VideoView.this.d = -1;
if (VideoView.this.l != null) {
VideoView.this.l.c();
}
if (VideoView.this.p == null || VideoView.this.p.onError(VideoView.this.f, i, i2)) {
}
return true;
}
};
this.z = new MediaPlayer.OnBufferingUpdateListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.6
@Override // android.media.MediaPlayer.OnBufferingUpdateListener
public void onBufferingUpdate(MediaPlayer mediaPlayer, int i) {
VideoView.this.o = i;
}
};
this.A = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.7
@Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnGestureListener
public boolean onSingleTapUp(MotionEvent motionEvent) {
if (!VideoView.this.d() || VideoView.this.l == null) {
return false;
}
VideoView.this.f();
return false;
}
});
this.B = new SurfaceHolder.Callback() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.8
@Override // android.view.SurfaceHolder.Callback
public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i2, int i3) {
VideoView.this.j = i2;
VideoView.this.k = i3;
boolean z = VideoView.this.d == 3;
boolean z2 = VideoView.this.h == i2 && VideoView.this.i == i3;
if (VideoView.this.f != null && z && z2) {
if (VideoView.this.r != 0) {
VideoView videoView = VideoView.this;
videoView.seekTo(videoView.r);
}
VideoView.this.start();
if (VideoView.this.l != null) {
VideoView.this.l.i();
}
}
}
@Override // android.view.SurfaceHolder.Callback
public void surfaceCreated(SurfaceHolder surfaceHolder) {
VideoView.this.e = surfaceHolder;
VideoView.this.e();
}
@Override // android.view.SurfaceHolder.Callback
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
VideoView.this.e = null;
if (VideoView.this.l != null) {
VideoView.this.l.c();
}
VideoView.this.a(true);
}
};
c();
}
@Override // com.twitter.sdk.android.tweetui.internal.VideoControlView.MediaPlayerControl
public int getBufferPercentage() {
if (this.f != null) {
return this.o;
}
return 0;
}
@Override // com.twitter.sdk.android.tweetui.internal.VideoControlView.MediaPlayerControl
public int getCurrentPosition() {
if (d()) {
return this.f.getCurrentPosition();
}
return 0;
}
@Override // com.twitter.sdk.android.tweetui.internal.VideoControlView.MediaPlayerControl
public int getDuration() {
if (d()) {
return this.f.getDuration();
}
return -1;
}
@Override // com.twitter.sdk.android.tweetui.internal.VideoControlView.MediaPlayerControl
public boolean isPlaying() {
return d() && this.f.isPlaying();
}
@Override // android.view.View, android.view.KeyEvent.Callback
public boolean onKeyDown(int i, KeyEvent keyEvent) {
boolean z = (i == 4 || i == 24 || i == 25 || i == 82 || i == 5 || i == 6) ? false : true;
if (d() && z && this.l != null) {
if (i == 79 || i == 85) {
if (this.f.isPlaying()) {
pause();
this.l.i();
} else {
start();
this.l.c();
}
return true;
}
if (i == 126) {
if (!this.f.isPlaying()) {
start();
this.l.c();
}
return true;
}
if (i == 86 || i == 127) {
if (this.f.isPlaying()) {
pause();
this.l.i();
}
return true;
}
f();
}
return super.onKeyDown(i, keyEvent);
}
@Override // android.view.SurfaceView, android.view.View
protected void onMeasure(int i, int i2) {
int i3;
int defaultSize = SurfaceView.getDefaultSize(this.h, i);
int defaultSize2 = SurfaceView.getDefaultSize(this.i, i2);
if (this.h > 0 && this.i > 0) {
int mode = View.MeasureSpec.getMode(i);
i3 = View.MeasureSpec.getSize(i);
int mode2 = View.MeasureSpec.getMode(i2);
int size = View.MeasureSpec.getSize(i2);
if (mode == 1073741824 && mode2 == 1073741824) {
int i4 = this.h;
int i5 = i4 * size;
int i6 = this.i;
if (i5 < i3 * i6) {
defaultSize = (i4 * size) / i6;
defaultSize2 = size;
} else {
if (i4 * size > i3 * i6) {
defaultSize2 = (i6 * i3) / i4;
}
defaultSize2 = size;
}
} else if (mode == 1073741824) {
int i7 = (this.i * i3) / this.h;
if (mode2 != Integer.MIN_VALUE || i7 <= size) {
defaultSize2 = i7;
}
defaultSize2 = size;
} else if (mode2 == 1073741824) {
int i8 = (this.h * size) / this.i;
if (mode != Integer.MIN_VALUE || i8 <= i3) {
i3 = i8;
}
defaultSize2 = size;
} else {
int i9 = this.h;
int i10 = this.i;
if (mode2 != Integer.MIN_VALUE || i10 <= size) {
defaultSize2 = i10;
} else {
i9 = (i9 * size) / i10;
defaultSize2 = size;
}
if (mode != Integer.MIN_VALUE || i9 <= i3) {
i3 = i9;
} else {
defaultSize2 = (this.i * i3) / this.h;
}
}
setMeasuredDimension(i3, defaultSize2);
}
i3 = defaultSize;
setMeasuredDimension(i3, defaultSize2);
}
@Override // android.view.View
public boolean onTouchEvent(MotionEvent motionEvent) {
return this.A.onTouchEvent(motionEvent) || super.onTouchEvent(motionEvent);
}
@Override // com.twitter.sdk.android.tweetui.internal.VideoControlView.MediaPlayerControl
public void pause() {
if (d() && this.f.isPlaying()) {
this.f.pause();
this.c = 4;
}
this.d = 4;
}
@Override // com.twitter.sdk.android.tweetui.internal.VideoControlView.MediaPlayerControl
public void seekTo(int i) {
if (!d()) {
this.r = i;
} else {
this.f.seekTo(i);
this.r = 0;
}
}
public void setMediaController(VideoControlView videoControlView) {
VideoControlView videoControlView2 = this.l;
if (videoControlView2 != null) {
videoControlView2.c();
}
this.l = videoControlView;
b();
}
public void setOnCompletionListener(MediaPlayer.OnCompletionListener onCompletionListener) {
this.m = onCompletionListener;
}
public void setOnErrorListener(MediaPlayer.OnErrorListener onErrorListener) {
this.p = onErrorListener;
}
public void setOnInfoListener(MediaPlayer.OnInfoListener onInfoListener) {
this.q = onInfoListener;
}
public void setOnPreparedListener(MediaPlayer.OnPreparedListener onPreparedListener) {
this.n = onPreparedListener;
}
@Override // com.twitter.sdk.android.tweetui.internal.VideoControlView.MediaPlayerControl
public void start() {
if (d()) {
this.f.start();
this.c = 3;
}
this.d = 3;
}
private void b() {
VideoControlView videoControlView;
if (this.f == null || (videoControlView = this.l) == null) {
return;
}
videoControlView.setMediaPlayer(this);
this.l.setEnabled(d());
}
private void c() {
this.h = 0;
this.i = 0;
getHolder().addCallback(this.B);
getHolder().setType(3);
setFocusable(true);
setFocusableInTouchMode(true);
setClickable(true);
requestFocus();
this.c = 0;
this.d = 0;
}
/* JADX INFO: Access modifiers changed from: private */
public boolean d() {
int i;
return (this.f == null || (i = this.c) == -1 || i == 0 || i == 1) ? false : true;
}
/* JADX INFO: Access modifiers changed from: private */
public void e() {
if (this.b == null || this.e == null) {
return;
}
a(false);
try {
this.f = new MediaPlayer();
if (this.g != 0) {
this.f.setAudioSessionId(this.g);
} else {
this.g = this.f.getAudioSessionId();
}
this.f.setOnPreparedListener(this.u);
this.f.setOnVideoSizeChangedListener(this.t);
this.f.setOnCompletionListener(this.v);
this.f.setOnErrorListener(this.y);
this.f.setOnInfoListener(this.x);
this.f.setOnBufferingUpdateListener(this.z);
this.o = 0;
this.f.setLooping(this.s);
this.f.setDataSource(getContext(), this.b);
this.f.setDisplay(this.e);
this.f.setAudioStreamType(3);
this.f.setScreenOnWhilePlaying(true);
this.f.prepareAsync();
this.c = 1;
b();
} catch (Exception e) {
Log.w(this.a, "Unable to open content: " + this.b, e);
this.c = -1;
this.d = -1;
this.y.onError(this.f, 1, 0);
}
}
/* JADX INFO: Access modifiers changed from: private */
public void f() {
if (this.l.e()) {
this.l.c();
} else {
this.l.i();
}
}
public void a(Uri uri, boolean z) {
this.b = uri;
this.s = z;
this.r = 0;
e();
requestLayout();
invalidate();
}
public void a() {
MediaPlayer mediaPlayer = this.f;
if (mediaPlayer != null) {
mediaPlayer.stop();
this.f.release();
this.f = null;
this.c = 0;
this.d = 0;
}
}
public VideoView(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
public VideoView(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.a = "VideoView";
this.c = 0;
this.d = 0;
this.e = null;
this.f = null;
this.t = new MediaPlayer.OnVideoSizeChangedListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.1
@Override // android.media.MediaPlayer.OnVideoSizeChangedListener
public void onVideoSizeChanged(MediaPlayer mediaPlayer, int i2, int i22) {
VideoView.this.h = mediaPlayer.getVideoWidth();
VideoView.this.i = mediaPlayer.getVideoHeight();
if (VideoView.this.h == 0 || VideoView.this.i == 0) {
return;
}
VideoView.this.getHolder().setFixedSize(VideoView.this.h, VideoView.this.i);
VideoView.this.requestLayout();
}
};
this.u = new MediaPlayer.OnPreparedListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.2
@Override // android.media.MediaPlayer.OnPreparedListener
public void onPrepared(MediaPlayer mediaPlayer) {
VideoView.this.c = 2;
if (VideoView.this.n != null) {
VideoView.this.n.onPrepared(VideoView.this.f);
}
if (VideoView.this.l != null) {
VideoView.this.l.setEnabled(true);
}
VideoView.this.h = mediaPlayer.getVideoWidth();
VideoView.this.i = mediaPlayer.getVideoHeight();
int i2 = VideoView.this.r;
if (i2 != 0) {
VideoView.this.seekTo(i2);
}
if (VideoView.this.h == 0 || VideoView.this.i == 0) {
if (VideoView.this.d == 3) {
VideoView.this.start();
return;
}
return;
}
VideoView.this.getHolder().setFixedSize(VideoView.this.h, VideoView.this.i);
if (VideoView.this.j == VideoView.this.h && VideoView.this.k == VideoView.this.i) {
if (VideoView.this.d == 3) {
VideoView.this.start();
if (VideoView.this.l != null) {
VideoView.this.l.i();
return;
}
return;
}
if (VideoView.this.isPlaying()) {
return;
}
if ((i2 != 0 || VideoView.this.getCurrentPosition() > 0) && VideoView.this.l != null) {
VideoView.this.l.i();
}
}
}
};
this.v = new MediaPlayer.OnCompletionListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.3
@Override // android.media.MediaPlayer.OnCompletionListener
public void onCompletion(MediaPlayer mediaPlayer) {
VideoView.this.c = 5;
VideoView.this.d = 5;
if (VideoView.this.m != null) {
VideoView.this.m.onCompletion(VideoView.this.f);
}
}
};
this.x = new MediaPlayer.OnInfoListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.4
@Override // android.media.MediaPlayer.OnInfoListener
public boolean onInfo(MediaPlayer mediaPlayer, int i2, int i22) {
if (VideoView.this.q == null) {
return true;
}
VideoView.this.q.onInfo(mediaPlayer, i2, i22);
return true;
}
};
this.y = new MediaPlayer.OnErrorListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.5
@Override // android.media.MediaPlayer.OnErrorListener
public boolean onError(MediaPlayer mediaPlayer, int i2, int i22) {
Log.d(VideoView.this.a, "Error: " + i2 + "," + i22);
VideoView.this.c = -1;
VideoView.this.d = -1;
if (VideoView.this.l != null) {
VideoView.this.l.c();
}
if (VideoView.this.p == null || VideoView.this.p.onError(VideoView.this.f, i2, i22)) {
}
return true;
}
};
this.z = new MediaPlayer.OnBufferingUpdateListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.6
@Override // android.media.MediaPlayer.OnBufferingUpdateListener
public void onBufferingUpdate(MediaPlayer mediaPlayer, int i2) {
VideoView.this.o = i2;
}
};
this.A = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.7
@Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnGestureListener
public boolean onSingleTapUp(MotionEvent motionEvent) {
if (!VideoView.this.d() || VideoView.this.l == null) {
return false;
}
VideoView.this.f();
return false;
}
});
this.B = new SurfaceHolder.Callback() { // from class: com.twitter.sdk.android.tweetui.internal.VideoView.8
@Override // android.view.SurfaceHolder.Callback
public void surfaceChanged(SurfaceHolder surfaceHolder, int i2, int i22, int i3) {
VideoView.this.j = i22;
VideoView.this.k = i3;
boolean z = VideoView.this.d == 3;
boolean z2 = VideoView.this.h == i22 && VideoView.this.i == i3;
if (VideoView.this.f != null && z && z2) {
if (VideoView.this.r != 0) {
VideoView videoView = VideoView.this;
videoView.seekTo(videoView.r);
}
VideoView.this.start();
if (VideoView.this.l != null) {
VideoView.this.l.i();
}
}
}
@Override // android.view.SurfaceHolder.Callback
public void surfaceCreated(SurfaceHolder surfaceHolder) {
VideoView.this.e = surfaceHolder;
VideoView.this.e();
}
@Override // android.view.SurfaceHolder.Callback
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
VideoView.this.e = null;
if (VideoView.this.l != null) {
VideoView.this.l.c();
}
VideoView.this.a(true);
}
};
c();
}
/* JADX INFO: Access modifiers changed from: private */
public void a(boolean z) {
MediaPlayer mediaPlayer = this.f;
if (mediaPlayer != null) {
mediaPlayer.reset();
this.f.release();
this.f = null;
this.c = 0;
if (z) {
this.d = 0;
}
}
}
}