mirror of
https://github.com/whyorean/AuroraStore.git
synced 2026-06-19 13:08:59 -04:00
CommunityBasedApps Card modifications
This commit is contained in:
43
app/src/main/java/in/dragons/galaxy/adapters/CommunityBasedAppsAdapter.java
Normal file → Executable file
43
app/src/main/java/in/dragons/galaxy/adapters/CommunityBasedAppsAdapter.java
Normal file → Executable file
@@ -7,7 +7,6 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -20,12 +19,10 @@ import in.dragons.galaxy.activities.DetailsActivity;
|
||||
|
||||
public class CommunityBasedAppsAdapter extends RecyclerView.Adapter<CommunityBasedAppsAdapter.MyViewHolderInst> {
|
||||
|
||||
String pkg;
|
||||
private List<FeaturedHolder> FeaturedAppsH;
|
||||
private Context context;
|
||||
|
||||
class MyViewHolderInst extends RecyclerView.ViewHolder {
|
||||
TextView cbased_name, cbased_price;
|
||||
TextView cbased_name;
|
||||
ImageView cbased_image;
|
||||
RelativeLayout cbased_layout;
|
||||
|
||||
@@ -33,35 +30,34 @@ public class CommunityBasedAppsAdapter extends RecyclerView.Adapter<CommunityBas
|
||||
super(view);
|
||||
cbased_name = view.findViewById(R.id.cbased_name);
|
||||
cbased_image = view.findViewById(R.id.cbased_image);
|
||||
cbased_price = view.findViewById(R.id.cbased_price);
|
||||
cbased_layout = view.findViewById(R.id.cbased_layout);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public CommunityBasedAppsAdapter(List<FeaturedHolder> FeaturedAppsH, Context context) {
|
||||
public CommunityBasedAppsAdapter(List<FeaturedHolder> FeaturedAppsH) {
|
||||
this.FeaturedAppsH = FeaturedAppsH;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MyViewHolderInst onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View itemView = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.comunity_based_adapter, parent, false);
|
||||
.inflate(R.layout.community_based_item, parent, false);
|
||||
return new MyViewHolderInst(itemView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(final MyViewHolderInst holder, int position) {
|
||||
final FeaturedHolder featuredHolder = FeaturedAppsH.get(position);
|
||||
holder.cbased_name.setText(featuredHolder.cbased_name);
|
||||
Context context = holder.itemView.getContext();
|
||||
FeaturedHolder featuredHolder = FeaturedAppsH.get(position);
|
||||
holder.cbased_name.setText(featuredHolder.title);
|
||||
holder.cbased_layout.setOnClickListener(v -> {
|
||||
context.startActivity(DetailsActivity.getDetailsIntent(context, featuredHolder.cbased_packagename));
|
||||
context.startActivity(DetailsActivity.getDetailsIntent(context, featuredHolder.id));
|
||||
});
|
||||
Picasso.with(context)
|
||||
.load(featuredHolder.cbased_appicon)
|
||||
.placeholder(R.drawable.ic_placeholder)
|
||||
.load(featuredHolder.icon)
|
||||
.placeholder(android.R.color.transparent)
|
||||
.into(holder.cbased_image);
|
||||
}
|
||||
|
||||
@@ -71,14 +67,21 @@ public class CommunityBasedAppsAdapter extends RecyclerView.Adapter<CommunityBas
|
||||
}
|
||||
|
||||
public static class FeaturedHolder {
|
||||
String cbased_name;
|
||||
String cbased_packagename;
|
||||
String cbased_appicon;
|
||||
String title;
|
||||
String id;
|
||||
String developer;
|
||||
String icon;
|
||||
double rating;
|
||||
String price;
|
||||
|
||||
public FeaturedHolder(String name, String pkg, String app_icon) {
|
||||
this.cbased_name = name;
|
||||
this.cbased_packagename = pkg;
|
||||
this.cbased_appicon = app_icon;
|
||||
public FeaturedHolder(String title, String id, String developer, String icon,
|
||||
double rating, String price) {
|
||||
this.title = title;
|
||||
this.id = id;
|
||||
this.developer = developer;
|
||||
this.icon = icon;
|
||||
this.rating = rating;
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
28
app/src/main/java/in/dragons/galaxy/view/CommunityBasedApps.java
Normal file → Executable file
28
app/src/main/java/in/dragons/galaxy/view/CommunityBasedApps.java
Normal file → Executable file
@@ -5,6 +5,8 @@ import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.android.volley.RequestQueue;
|
||||
import com.android.volley.toolbox.JsonArrayRequest;
|
||||
@@ -16,9 +18,12 @@ import org.json.JSONObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import in.dragons.galaxy.R;
|
||||
import in.dragons.galaxy.adapters.CommunityBasedAppsAdapter;
|
||||
|
||||
public class CommunityBasedApps extends RecyclerView {
|
||||
public class CommunityBasedApps extends RelativeLayout {
|
||||
|
||||
private RecyclerView cbased_recycler;
|
||||
|
||||
public CommunityBasedApps(Context context) {
|
||||
super(context);
|
||||
@@ -36,26 +41,31 @@ public class CommunityBasedApps extends RecyclerView {
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
View view = inflate(context, R.layout.community_based_card, this);
|
||||
cbased_recycler = view.findViewById(R.id.cbased_recycler);
|
||||
JsonParser(context);
|
||||
}
|
||||
|
||||
private void JsonParser(Context context) {
|
||||
RequestQueue mRequestQueue = Volley.newRequestQueue(context);
|
||||
List<CommunityBasedAppsAdapter.FeaturedHolder> FeaturedAppsHolder = new ArrayList<>();
|
||||
RequestQueue mRequestQueue = Volley.newRequestQueue(context);
|
||||
String JSON_PATH = "https://raw.githubusercontent.com/GalaxyStore/MetaData/master/community_apps.json";
|
||||
JsonArrayRequest req = new JsonArrayRequest(JSON_PATH,
|
||||
response -> {
|
||||
try {
|
||||
for (int i = 0; i < response.length(); i++) {
|
||||
JSONObject inst = (JSONObject) response.get(i);
|
||||
CommunityBasedAppsAdapter adapter = new CommunityBasedAppsAdapter(FeaturedAppsHolder, context);
|
||||
CommunityBasedAppsAdapter adapter = new CommunityBasedAppsAdapter(FeaturedAppsHolder);
|
||||
CommunityBasedAppsAdapter.FeaturedHolder apps = new CommunityBasedAppsAdapter.FeaturedHolder(
|
||||
inst.getString("app_name"),
|
||||
inst.getString("app_packagename"),
|
||||
inst.getString("app_icon"));
|
||||
inst.getString("title"),
|
||||
inst.getString("id"),
|
||||
inst.getString("developer"),
|
||||
inst.getString("icon"),
|
||||
inst.getDouble("rating"),
|
||||
inst.getString("price"));
|
||||
FeaturedAppsHolder.add(apps);
|
||||
setAdapter(adapter);
|
||||
setLayoutManager(new GridLayoutManager(context, 3));
|
||||
cbased_recycler.setAdapter(adapter);
|
||||
cbased_recycler.setLayoutManager(new GridLayoutManager(context, 3));
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
@@ -64,6 +74,4 @@ public class CommunityBasedApps extends RecyclerView {
|
||||
}, error -> Log.w("JSON_ERROR", "Error: " + error.getMessage()));
|
||||
mRequestQueue.add(req);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
15
app/src/main/res/layout/community_based_card.xml
Executable file
15
app/src/main/res/layout/community_based_card.xml
Executable file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v7.widget.CardView 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:elevation="2dp"
|
||||
app:cardCornerRadius="5dp"
|
||||
app:cardUseCompatPadding="true">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/cbased_recycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:nestedScrollingEnabled="false" />
|
||||
</android.support.v7.widget.CardView>
|
||||
36
app/src/main/res/layout/community_based_item.xml
Executable file
36
app/src/main/res/layout/community_based_item.xml
Executable file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/cbased_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/cbased_image"
|
||||
android:layout_width="96dp"
|
||||
android:layout_height="96dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:padding="10dp"
|
||||
app:srcCompat="@drawable/ic_placeholder" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/cbased_name"
|
||||
android:layout_width="110dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/cbased_image"
|
||||
android:layout_margin="8dp"
|
||||
android:ellipsize="none"
|
||||
android:fontFamily="@font/google_sans"
|
||||
android:maxLines="2"
|
||||
android:scrollHorizontally="false"
|
||||
android:textAlignment="center"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="14sp" />
|
||||
</RelativeLayout>
|
||||
@@ -1,57 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:elevation="2dp"
|
||||
app:cardUseCompatPadding="true">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/cbased_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/cbased_image"
|
||||
android:layout_width="72dp"
|
||||
android:layout_height="72dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:cropToPadding="true"
|
||||
app:srcCompat="@drawable/ic_placeholder" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/cbased_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_below="@+id/cbased_image"
|
||||
android:layout_margin="8dp"
|
||||
android:fontFamily="@font/google_sans_bold"
|
||||
android:gravity="bottom"
|
||||
android:singleLine="true"
|
||||
android:textAlignment="center"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/cbased_price"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignEnd="@+id/cbased_name"
|
||||
android:layout_alignStart="@+id/cbased_name"
|
||||
android:layout_below="@+id/cbased_name"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:fontFamily="@font/google_sans"
|
||||
android:textAlignment="center"
|
||||
android:textSize="12sp"
|
||||
android:visibility="gone" />
|
||||
</RelativeLayout>
|
||||
</android.support.v7.widget.CardView>
|
||||
Reference in New Issue
Block a user