mirror of https://github.com/NekoX-Dev/NekoX.git
71 lines
3.0 KiB
Java
71 lines
3.0 KiB
Java
/*
|
|
* 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).
|
|
*
|
|
* Copyright Nikolai Kudashov, 2013-2018.
|
|
*/
|
|
|
|
package org.telegram.ui.Cells;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.PorterDuff;
|
|
import android.graphics.PorterDuffColorFilter;
|
|
import android.util.TypedValue;
|
|
import android.view.Gravity;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.ImageView;
|
|
import android.widget.TextView;
|
|
|
|
import org.telegram.messenger.AndroidUtilities;
|
|
import org.telegram.messenger.LocaleController;
|
|
import org.telegram.messenger.R;
|
|
import org.telegram.ui.ActionBar.Theme;
|
|
import org.telegram.ui.Components.LayoutHelper;
|
|
import org.telegram.ui.Components.RadialProgressView;
|
|
|
|
public class LocationLoadingCell extends FrameLayout {
|
|
|
|
private RadialProgressView progressBar;
|
|
private TextView textView;
|
|
private ImageView imageView;
|
|
private final Theme.ResourcesProvider resourcesProvider;
|
|
|
|
public LocationLoadingCell(Context context, Theme.ResourcesProvider resourcesProvider) {
|
|
super(context);
|
|
this.resourcesProvider = resourcesProvider;
|
|
|
|
progressBar = new RadialProgressView(context, resourcesProvider);
|
|
addView(progressBar, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
|
|
|
|
imageView = new ImageView(context);
|
|
imageView.setImageResource(R.drawable.location_empty);
|
|
imageView.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_dialogEmptyImage), PorterDuff.Mode.SRC_IN));
|
|
addView(imageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 0, 0, 0, 24));
|
|
|
|
textView = new TextView(context);
|
|
textView.setTextColor(getThemedColor(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) {
|
|
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);
|
|
imageView.setVisibility(value ? INVISIBLE : VISIBLE);
|
|
}
|
|
|
|
private int getThemedColor(String key) {
|
|
Integer color = resourcesProvider != null ? resourcesProvider.getColor(key) : null;
|
|
return color != null ? color : Theme.getColor(key);
|
|
}
|
|
}
|