Kate Mobile v109.1版本的 MD5 值为:fcd76ded5f363ecbfac46035a4ed2a23
以下内容为反编译后的 ExtraProfileFragment.java 源代码,内容仅作参考
package com.perm.kate;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import com.perm.kate.api.Api;
import com.perm.kate.api.Relative;
import com.perm.kate.api.User;
import com.perm.kate.session.Callback;
import com.perm.utils.Linkify;
import java.util.ArrayList;
import java.util.Iterator;
public class ExtraProfileFragment extends BaseFragment {
private LinearLayout children_container;
private LinearLayout connections_container;
private LinearLayout contacts_container;
private LinearLayout grandchildren_container;
private LinearLayout grandparents_container;
private LinearLayout parents_container;
private LinearLayout siblings_container;
private TextView tv_profile_about;
private TextView tv_profile_about_title;
private TextView tv_profile_activities;
private TextView tv_profile_activities_title;
private TextView tv_profile_books;
private TextView tv_profile_books_title;
private TextView tv_profile_children_title;
private TextView tv_profile_connections_title;
private TextView tv_profile_contacts_title;
private TextView tv_profile_games;
private TextView tv_profile_games_title;
private TextView tv_profile_grandchildren_title;
private TextView tv_profile_grandparents_title;
private TextView tv_profile_interests;
private TextView tv_profile_interests_title;
private TextView tv_profile_movies;
private TextView tv_profile_movies_title;
private TextView tv_profile_music;
private TextView tv_profile_music_title;
private TextView tv_profile_parents_title;
private TextView tv_profile_quotes;
private TextView tv_profile_quotes_title;
private TextView tv_profile_siblings_title;
private TextView tv_profile_tv;
private TextView tv_profile_tv_title;
private long uid;
private User user;
private final Callback callback_profile = new Callback(getActivity()) {
@Override
public void error(Throwable th) {
super.error(th);
ExtraProfileFragment.this.showProgressBar(false);
ExtraProfileFragment.this.hideLoadingTextInUIThread();
}
@Override
public void ready(Object obj) {
ExtraProfileFragment.this.showProgressBar(false);
ExtraProfileFragment.this.hideLoadingTextInUIThread();
ArrayList arrayList = (ArrayList) obj;
if (arrayList == null || arrayList.size() == 0) {
return;
}
ExtraProfileFragment.this.user = (User) arrayList.get(0);
if (ExtraProfileFragment.this.user.relatives != null && ExtraProfileFragment.this.user.relatives.size() > 0) {
ArrayList arrayList2 = new ArrayList();
Iterator<Relative> it = ExtraProfileFragment.this.user.relatives.iterator();
while (it.hasNext()) {
long j = it.next().id;
if (j > 0) {
arrayList2.add(Long.valueOf(j));
}
}
KApplication.getMissingUsers(arrayList2);
}
ExtraProfileFragment.this.displayUserInfoOnUiThread();
}
};
private final View.OnClickListener textClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
TextView textView = (TextView) view;
if (textView != null) {
Helper.createCopyTextContextMenu(textView.getText().toString(), ExtraProfileFragment.this.getActivity());
}
}
};
private final View.OnClickListener userClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
String str = (String) view.getTag();
if (str != null) {
Helper.ShowProfile(str, ExtraProfileFragment.this.getActivity());
}
}
};
private final View.OnClickListener connectionClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
final String str = (String) view.getTag();
final int intValue = ((Integer) view.getTag(R.id.tv_value)).intValue();
AlertDialog create = new AlertDialog.Builder(ExtraProfileFragment.this.getActivity()).setTitle((String) view.getTag(R.id.tv_label)).setItems(new CharSequence[]{ExtraProfileFragment.this.getText(R.string.open), ExtraProfileFragment.this.getText(R.string.label_copy)}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (i == 0) {
ExtraProfileFragment.this.onConnectionsSelect(str, intValue);
} else {
Helper.copyText(str, ExtraProfileFragment.this.getActivity());
}
}
}).create();
create.setCanceledOnTouchOutside(true);
create.show();
}
};
public void displayUserInfo() {
String str;
View connectionView;
String str2;
View connectionView2;
String str3;
View connectionView3;
String str4;
View connectionView4;
String str5;
View connectionView5;
String str6;
View connectionView6;
String str7;
View connectionView7;
User user = this.user;
if (user == null) {
return;
}
String str8 = user.activities;
if (str8 != null && str8.length() > 0) {
this.tv_profile_activities_title.setVisibility(0);
this.tv_profile_activities.setVisibility(0);
this.tv_profile_activities.setText(this.user.activities);
this.tv_profile_activities.setOnClickListener(this.textClickListener);
}
String str9 = this.user.interests;
if (str9 != null && str9.length() > 0) {
this.tv_profile_interests_title.setVisibility(0);
this.tv_profile_interests.setVisibility(0);
this.tv_profile_interests.setText(this.user.interests);
this.tv_profile_interests.setOnClickListener(this.textClickListener);
}
String str10 = this.user.music;
if (str10 != null && str10.length() > 0) {
this.tv_profile_music_title.setVisibility(0);
this.tv_profile_music.setVisibility(0);
this.tv_profile_music.setText(this.user.music);
this.tv_profile_music.setOnClickListener(this.textClickListener);
}
String str11 = this.user.movies;
if (str11 != null && str11.length() > 0) {
this.tv_profile_movies_title.setVisibility(0);
this.tv_profile_movies.setVisibility(0);
this.tv_profile_movies.setText(this.user.movies);
this.tv_profile_movies.setOnClickListener(this.textClickListener);
}
String str12 = this.user.tv;
if (str12 != null && str12.length() > 0) {
this.tv_profile_tv_title.setVisibility(0);
this.tv_profile_tv.setVisibility(0);
this.tv_profile_tv.setText(this.user.tv);
this.tv_profile_tv.setOnClickListener(this.textClickListener);
}
String str13 = this.user.books;
if (str13 != null && str13.length() > 0) {
this.tv_profile_books_title.setVisibility(0);
this.tv_profile_books.setVisibility(0);
this.tv_profile_books.setText(this.user.books);
this.tv_profile_books.setOnClickListener(this.textClickListener);
}
String str14 = this.user.games;
if (str14 != null && str14.length() > 0) {
this.tv_profile_games_title.setVisibility(0);
this.tv_profile_games.setVisibility(0);
this.tv_profile_games.setText(this.user.games);
this.tv_profile_games.setOnClickListener(this.textClickListener);
}
String str15 = this.user.quotes;
if (str15 != null && str15.length() > 0) {
this.tv_profile_quotes_title.setVisibility(0);
this.tv_profile_quotes.setVisibility(0);
this.tv_profile_quotes.setText(this.user.quotes);
this.tv_profile_quotes.setOnClickListener(this.textClickListener);
}
String str16 = this.user.about;
if (str16 != null && str16.length() > 0) {
this.tv_profile_about_title.setVisibility(0);
this.tv_profile_about.setVisibility(0);
this.tv_profile_about.setText(this.user.about);
this.tv_profile_about.setOnClickListener(this.textClickListener);
}
if (this.user.relatives != null) {
ArrayList arrayList = new ArrayList();
ArrayList arrayList2 = new ArrayList();
ArrayList arrayList3 = new ArrayList();
ArrayList arrayList4 = new ArrayList();
ArrayList arrayList5 = new ArrayList();
Iterator<Relative> it = this.user.relatives.iterator();
while (it.hasNext()) {
Relative next = it.next();
if ("grandparent".equals(next.type)) {
arrayList.add(next);
}
if ("parent".equals(next.type)) {
arrayList2.add(next);
}
if ("sibling".equals(next.type)) {
arrayList3.add(next);
}
if ("child".equals(next.type)) {
arrayList4.add(next);
}
if ("grandchild".equals(next.type)) {
arrayList5.add(next);
}
}
if (arrayList.size() > 0) {
this.tv_profile_grandparents_title.setVisibility(0);
this.grandparents_container.setVisibility(0);
fillRelativesContainer(this.grandparents_container, arrayList);
}
if (arrayList2.size() > 0) {
this.tv_profile_parents_title.setVisibility(0);
this.parents_container.setVisibility(0);
fillRelativesContainer(this.parents_container, arrayList2);
}
if (arrayList3.size() > 0) {
this.tv_profile_siblings_title.setVisibility(0);
this.siblings_container.setVisibility(0);
fillRelativesContainer(this.siblings_container, arrayList3);
}
if (arrayList4.size() > 0) {
this.tv_profile_children_title.setVisibility(0);
this.children_container.setVisibility(0);
fillRelativesContainer(this.children_container, arrayList4);
}
if (arrayList5.size() > 0) {
this.tv_profile_grandchildren_title.setVisibility(0);
this.grandchildren_container.setVisibility(0);
fillRelativesContainer(this.grandchildren_container, arrayList5);
}
}
if (!TextUtils.isEmpty(this.user.twitter) || !TextUtils.isEmpty(this.user.facebook) || !TextUtils.isEmpty(this.user.skype) || !TextUtils.isEmpty(this.user.livejournal) || !TextUtils.isEmpty(this.user.instagram) || !TextUtils.isEmpty(this.user.site)) {
this.tv_profile_connections_title.setVisibility(0);
this.connections_container.setVisibility(0);
this.connections_container.removeAllViews();
if (!TextUtils.isEmpty(this.user.twitter) && (connectionView5 = getConnectionView((str5 = this.user.twitter), str5, "Twitter", 0)) != null) {
this.connections_container.addView(connectionView5, getUserLayoutParams());
}
if (!TextUtils.isEmpty(this.user.facebook)) {
User user2 = this.user;
View connectionView8 = getConnectionView(user2.facebook, user2.facebook_name, "Facebook", 1);
if (connectionView8 != null) {
this.connections_container.addView(connectionView8, getUserLayoutParams());
}
}
if (!TextUtils.isEmpty(this.user.skype) && (connectionView4 = getConnectionView((str4 = this.user.skype), str4, "Skype", 2)) != null) {
this.connections_container.addView(connectionView4, getUserLayoutParams());
}
if (!TextUtils.isEmpty(this.user.livejournal) && (connectionView3 = getConnectionView((str3 = this.user.livejournal), str3, "Livejournal", 3)) != null) {
this.connections_container.addView(connectionView3, getUserLayoutParams());
}
if (!TextUtils.isEmpty(this.user.instagram) && (connectionView2 = getConnectionView((str2 = this.user.instagram), str2, "Instagram", 4)) != null) {
this.connections_container.addView(connectionView2, getUserLayoutParams());
}
if (!TextUtils.isEmpty(this.user.site) && (connectionView = getConnectionView((str = this.user.site), str, getString(R.string.website), 5)) != null) {
this.connections_container.addView(connectionView, getUserLayoutParams());
}
}
if (TextUtils.isEmpty(this.user.home_phone) && TextUtils.isEmpty(this.user.mobile_phone)) {
return;
}
this.tv_profile_contacts_title.setVisibility(0);
this.contacts_container.setVisibility(0);
this.contacts_container.removeAllViews();
if (!TextUtils.isEmpty(this.user.mobile_phone) && (connectionView7 = getConnectionView((str7 = this.user.mobile_phone), str7, getString(R.string.title_mobile_phone), 6)) != null) {
this.contacts_container.addView(connectionView7, getUserLayoutParams());
}
if (TextUtils.isEmpty(this.user.home_phone) || (connectionView6 = getConnectionView((str6 = this.user.home_phone), str6, getString(R.string.title_home_phone), 6)) == null) {
return;
}
this.contacts_container.addView(connectionView6, getUserLayoutParams());
}
public void displayUserInfoOnUiThread() {
if (getActivity() == null || getActivity().isFinishing()) {
return;
}
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
ExtraProfileFragment.this.displayUserInfo();
}
});
}
private void fillRelativesContainer(LinearLayout linearLayout, ArrayList arrayList) {
linearLayout.removeAllViews();
Iterator it = arrayList.iterator();
while (it.hasNext()) {
View userView = getUserView((Relative) it.next());
if (userView != null) {
linearLayout.addView(userView, getUserLayoutParams());
}
}
}
private View getConnectionView(String str, String str2, String str3, int i) {
View inflate = LayoutInflater.from(getActivity()).inflate(R.layout.user_connection_item, (ViewGroup) null, false);
((TextView) inflate.findViewById(R.id.tv_label)).setText(str3);
TextView textView = (TextView) inflate.findViewById(R.id.tv_value);
textView.setText(str2);
inflate.setOnClickListener(this.connectionClickListener);
inflate.setTag(str);
inflate.setTag(R.id.tv_label, str3);
inflate.setTag(R.id.tv_value, Integer.valueOf(i));
if (i == 5) {
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(str2);
Linkify.addWebLinks(spannableStringBuilder);
NewsCursorAdapter.spannableLink(spannableStringBuilder, getActivity(), true);
textView.setText(spannableStringBuilder);
textView.setMovementMethod(LinkMovementMethod.getInstance());
}
return inflate;
}
private LinearLayout.LayoutParams getUserLayoutParams() {
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -2);
layoutParams.setMargins(0, 0, 0, 0);
return layoutParams;
}
private View getUserView(Relative relative) {
View inflate = LayoutInflater.from(getActivity()).inflate(R.layout.user_relatives_item, (ViewGroup) null, false);
long j = relative.id;
User fetchUser = j > 0 ? KApplication.db.fetchUser(j) : null;
TextView textView = (TextView) inflate.findViewById(R.id.tv_user_name);
ImageView imageView = (ImageView) inflate.findViewById(R.id.img_user_photo);
if (fetchUser != null) {
textView.setText(fetchUser.first_name + " " + fetchUser.last_name);
KApplication.getImageLoader().DisplayImage(fetchUser.photo_medium_rec, imageView, true, 90, Helper.getAvaStubId(), true);
inflate.setOnClickListener(this.userClickListener);
inflate.setTag(String.valueOf(fetchUser.uid));
} else {
textView.setText(relative.name);
imageView.setImageResource(Helper.getAvaStubId());
}
return inflate;
}
public void hideLoadingTextInUIThread() {
if (getActivity() == null || getActivity().isFinishing()) {
return;
}
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
ExtraProfileFragment.this.getView().findViewById(R.id.tv_loading_data).setVisibility(8);
}
});
}
public void onConnectionsSelect(String str, int i) {
switch (i) {
case 0:
str = "https://www.twitter.com/" + str;
break;
case 1:
str = "http://www.facebook.com/" + str;
break;
case 2:
try {
Intent intent = new Intent("android.intent.action.VIEW");
intent.setData(Uri.parse("skype:" + str));
getActivity().startActivity(intent);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
Toast.makeText(getActivity(), "Ошибка. Приложение Skype не установлено.", 0).show();
}
str = null;
break;
case 3:
str = "http://" + str + ".livejournal.com/";
break;
case 4:
str = "http://instagram.com/_u/" + str;
break;
case 5:
ArrayList extractUrl = Helper.extractUrl(this.user.site, false);
if (extractUrl.size() > 1) {
str = (String) extractUrl.get(0);
break;
}
break;
case 6:
Helper.onDial(getActivity(), str);
str = null;
break;
default:
str = null;
break;
}
if (str != null) {
Helper.openUrlInBrowser(str, getActivity());
}
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
long j = getArguments().getLong("com.perm.kate.user_id");
this.uid = j;
this.user = KApplication.db.fetchUser(j);
if (bundle == null) {
refreshInThread();
}
}
@Override
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
View inflate = layoutInflater.inflate(R.layout.extra_profile_activity, viewGroup, false);
this.tv_profile_activities_title = (TextView) inflate.findViewById(R.id.tv_profile_activities_title);
this.tv_profile_activities = (TextView) inflate.findViewById(R.id.tv_profile_activities);
this.tv_profile_interests_title = (TextView) inflate.findViewById(R.id.tv_profile_interests_title);
this.tv_profile_interests = (TextView) inflate.findViewById(R.id.tv_profile_interests);
this.tv_profile_music_title = (TextView) inflate.findViewById(R.id.tv_profile_music_title);
this.tv_profile_music = (TextView) inflate.findViewById(R.id.tv_profile_music);
this.tv_profile_movies_title = (TextView) inflate.findViewById(R.id.tv_profile_movies_title);
this.tv_profile_movies = (TextView) inflate.findViewById(R.id.tv_profile_movies);
this.tv_profile_tv_title = (TextView) inflate.findViewById(R.id.tv_profile_tv_title);
this.tv_profile_tv = (TextView) inflate.findViewById(R.id.tv_profile_tv);
this.tv_profile_books_title = (TextView) inflate.findViewById(R.id.tv_profile_books_title);
this.tv_profile_books = (TextView) inflate.findViewById(R.id.tv_profile_books);
this.tv_profile_games_title = (TextView) inflate.findViewById(R.id.tv_profile_games_title);
this.tv_profile_games = (TextView) inflate.findViewById(R.id.tv_profile_games);
this.tv_profile_quotes_title = (TextView) inflate.findViewById(R.id.tv_profile_quotes_title);
this.tv_profile_quotes = (TextView) inflate.findViewById(R.id.tv_profile_quotes);
this.tv_profile_about_title = (TextView) inflate.findViewById(R.id.tv_profile_about_title);
this.tv_profile_about = (TextView) inflate.findViewById(R.id.tv_profile_about);
this.tv_profile_grandparents_title = (TextView) inflate.findViewById(R.id.tv_profile_grandparents_title);
this.grandparents_container = (LinearLayout) inflate.findViewById(R.id.grandparents_container);
this.tv_profile_parents_title = (TextView) inflate.findViewById(R.id.tv_profile_parents_title);
this.parents_container = (LinearLayout) inflate.findViewById(R.id.parents_container);
this.tv_profile_siblings_title = (TextView) inflate.findViewById(R.id.tv_profile_siblings_title);
this.siblings_container = (LinearLayout) inflate.findViewById(R.id.siblings_container);
this.tv_profile_children_title = (TextView) inflate.findViewById(R.id.tv_profile_children_title);
this.children_container = (LinearLayout) inflate.findViewById(R.id.children_container);
this.tv_profile_grandchildren_title = (TextView) inflate.findViewById(R.id.tv_profile_grandchildren_title);
this.grandchildren_container = (LinearLayout) inflate.findViewById(R.id.grandchildren_container);
this.tv_profile_connections_title = (TextView) inflate.findViewById(R.id.tv_profile_connections_title);
this.connections_container = (LinearLayout) inflate.findViewById(R.id.connections_container);
this.tv_profile_contacts_title = (TextView) inflate.findViewById(R.id.tv_profile_contacts_title);
this.contacts_container = (LinearLayout) inflate.findViewById(R.id.contacts_container);
displayUserInfo();
return inflate;
}
@Override
public void onRefreshButton() {
refreshInThread();
}
void refreshInThread() {
showProgressBar(true);
new Thread() {
@Override
public void run() {
try {
ArrayList arrayList = new ArrayList();
arrayList.add(Long.valueOf(ExtraProfileFragment.this.uid));
Api.tag = "ExPrFr";
KApplication.session.getProfiles(arrayList, null, "activities,interests,music,movies,tv,books,games,quotes,about,relatives,connections,site,contacts", "nom", ExtraProfileFragment.this.callback_profile, ExtraProfileFragment.this.getActivity());
} catch (Throwable th) {
Helper.reportError(th);
th.printStackTrace();
}
}
}.start();
}
}