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

64 lines
2.6 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;
public LocationLoadingCell(Context context) {
super(context);
2017-03-31 01:58:05 +02:00
progressBar = new RadialProgressView(context);
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);
2020-06-25 17:12:58 +02:00
imageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(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);
2019-12-31 14:08:08 +01:00
textView.setTextColor(Theme.getColor(Theme.key_dialogEmptyText));
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);
}
}