NekoX/TMessagesProj/src/main/java/org/telegram/ui/Cells/LocationLoadingCell.java

71 lines
3.0 KiB
Java
Raw Normal View History

/*
2019-01-23 18:03:33 +01:00
* This is the source code of Telegram for Android v. 5.x.x
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
2019-01-23 18:03:33 +01:00
* Copyright Nikolai Kudashov, 2013-2018.
*/
package org.telegram.ui.Cells;
import android.content.Context;
2019-12-31 14:08:08 +01:00
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.util.TypedValue;
import android.view.Gravity;
import android.widget.FrameLayout;
2019-12-31 14:08:08 +01:00
import android.widget.ImageView;
import android.widget.TextView;
2015-09-24 22:52:02 +02:00
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.R;
2017-03-31 01:58:05 +02:00
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Components.LayoutHelper;
2017-03-31 01:58:05 +02:00
import org.telegram.ui.Components.RadialProgressView;
public class LocationLoadingCell extends FrameLayout {
2017-03-31 01:58:05 +02:00
private RadialProgressView progressBar;
private TextView textView;
2019-12-31 14:08:08 +01:00
private ImageView imageView;
2021-09-20 00:10:42 +02:00
private final Theme.ResourcesProvider resourcesProvider;
2021-09-20 00:10:42 +02:00
public LocationLoadingCell(Context context, Theme.ResourcesProvider resourcesProvider) {
super(context);
2021-09-20 00:10:42 +02:00
this.resourcesProvider = resourcesProvider;
2021-09-20 00:10:42 +02:00
progressBar = new RadialProgressView(context, resourcesProvider);
addView(progressBar, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
2019-12-31 14:08:08 +01:00
imageView = new ImageView(context);
imageView.setImageResource(R.drawable.location_empty);
2021-09-20 11:14:20 +02:00
imageView.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_dialogEmptyImage), PorterDuff.Mode.SRC_IN));
2019-12-31 14:08:08 +01:00
addView(imageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 0, 0, 0, 24));
textView = new TextView(context);
2021-09-20 00:10:42 +02:00
textView.setTextColor(getThemedColor(Theme.key_dialogEmptyText));
2019-12-31 14:08:08 +01:00
textView.setGravity(Gravity.CENTER);
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);
textView.setText(LocaleController.getString("NoPlacesFound", R.string.NoPlacesFound));
addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 0, 34, 0, 0));
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
2017-03-31 01:58:05 +02:00
super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec((int) (AndroidUtilities.dp(56) * 2.5f), MeasureSpec.EXACTLY));
}
public void setLoading(boolean value) {
progressBar.setVisibility(value ? VISIBLE : INVISIBLE);
textView.setVisibility(value ? INVISIBLE : VISIBLE);
2019-12-31 14:08:08 +01:00
imageView.setVisibility(value ? INVISIBLE : VISIBLE);
}
2021-09-20 00:10:42 +02:00
private int getThemedColor(String key) {
Integer color = resourcesProvider != null ? resourcesProvider.getColor(key) : null;
return color != null ? color : Theme.getColor(key);
}
}