Inline items
This commit is contained in:
@@ -0,0 +1,28 @@
|
|||||||
|
package eu.konggdev.strikemaps.ui.element.item;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import eu.konggdev.strikemaps.R;
|
||||||
|
import eu.konggdev.strikemaps.ui.UIComponent;
|
||||||
|
|
||||||
|
public class InlineItem implements UIItem {
|
||||||
|
public String text;
|
||||||
|
public Runnable onClick;
|
||||||
|
|
||||||
|
public InlineItem(String refText) {
|
||||||
|
this.text = refText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InlineItem(String refText, Runnable onClick) {
|
||||||
|
this.text = refText;
|
||||||
|
this.onClick = onClick;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View makeView(UIComponent spawner) {
|
||||||
|
View view = spawner.inflateUi(R.layout.item_inline);
|
||||||
|
((TextView) view.findViewById(R.id.inline)).setText(text);
|
||||||
|
if(onClick != null) view.findViewById(R.id.inline).setOnClickListener(click(onClick));
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-2
@@ -3,6 +3,7 @@ package eu.konggdev.strikemaps.ui.fragment.layout.content.main;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.Toast;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import eu.konggdev.strikemaps.R;
|
import eu.konggdev.strikemaps.R;
|
||||||
@@ -11,6 +12,7 @@ import eu.konggdev.strikemaps.data.helper.FileHelper;
|
|||||||
import eu.konggdev.strikemaps.map.source.MapSource;
|
import eu.konggdev.strikemaps.map.source.MapSource;
|
||||||
import eu.konggdev.strikemaps.map.style.MapStyle;
|
import eu.konggdev.strikemaps.map.style.MapStyle;
|
||||||
import eu.konggdev.strikemaps.ui.element.item.GenericItem;
|
import eu.konggdev.strikemaps.ui.element.item.GenericItem;
|
||||||
|
import eu.konggdev.strikemaps.ui.element.item.InlineItem;
|
||||||
import eu.konggdev.strikemaps.ui.element.item.PreviewItem;
|
import eu.konggdev.strikemaps.ui.element.item.PreviewItem;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -50,9 +52,9 @@ public class FragmentLayoutContentOfflineMaps extends Fragment implements MainCo
|
|||||||
LinearLayout sourcesLayout = view.findViewById(R.id.llDownloadContainer);
|
LinearLayout sourcesLayout = view.findViewById(R.id.llDownloadContainer);
|
||||||
for (MapSource source : sources) {
|
for (MapSource source : sources) {
|
||||||
if (!Objects.equals(source.type, "raster"))
|
if (!Objects.equals(source.type, "raster"))
|
||||||
sourcesLayout.addView(new PreviewItem(source.url, "").makeView(app.getUi()));
|
sourcesLayout.addView(new InlineItem(source.url, () -> Toast.makeText(app.getActivity(), "Work in progress", Toast.LENGTH_SHORT).show()).makeView(app.getUi()));
|
||||||
else
|
else
|
||||||
sourcesLayout.addView(new PreviewItem(source.tiles.toString(), "").makeView(app.getUi()));
|
sourcesLayout.addView(new InlineItem(source.tiles.toString(), () -> Toast.makeText(app.getActivity(), "Work in progress", Toast.LENGTH_SHORT).show()).makeView(app.getUi()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="#000000"
|
||||||
|
android:foregroundTint="#FFFFFF">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/inline"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="24dp"
|
||||||
|
android:paddingVertical="12dp"
|
||||||
|
android:text=""
|
||||||
|
android:textColor="#FFFFFF"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:drawableEnd="@drawable/ic_arrow_forward"
|
||||||
|
android:drawablePadding="8dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"/>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
Reference in New Issue
Block a user