Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b0c94da
commit 9e822bb
Showing
13 changed files
with
286 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,4 +40,4 @@ dependencies { | |
} | ||
|
||
|
||
apply plugin: 'com.google.gms.google-services' | ||
apply plugin: 'com.google.gms.google-services' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
app/src/main/java/net/simplifiedcoding/wallpaperhub/activities/WallpapersActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package net.simplifiedcoding.wallpaperhub.activities; | ||
|
||
import android.content.Intent; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.support.v7.widget.LinearLayoutManager; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.support.v7.widget.Toolbar; | ||
import android.view.View; | ||
import android.widget.ProgressBar; | ||
|
||
import com.google.firebase.database.DataSnapshot; | ||
import com.google.firebase.database.DatabaseError; | ||
import com.google.firebase.database.DatabaseReference; | ||
import com.google.firebase.database.FirebaseDatabase; | ||
import com.google.firebase.database.ValueEventListener; | ||
|
||
import net.simplifiedcoding.wallpaperhub.R; | ||
import net.simplifiedcoding.wallpaperhub.adapters.WallpapersAdapter; | ||
import net.simplifiedcoding.wallpaperhub.models.Wallpaper; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class WallpapersActivity extends AppCompatActivity { | ||
|
||
List<Wallpaper> wallpaperList; | ||
RecyclerView recyclerView; | ||
WallpapersAdapter adapter; | ||
|
||
DatabaseReference dbWallpapers; | ||
ProgressBar progressBar; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_wallpapers); | ||
|
||
wallpaperList = new ArrayList<>(); | ||
recyclerView = findViewById(R.id.recycler_view); | ||
recyclerView.setHasFixedSize(true); | ||
recyclerView.setLayoutManager(new LinearLayoutManager(this)); | ||
adapter = new WallpapersAdapter(this, wallpaperList); | ||
|
||
recyclerView.setAdapter(adapter); | ||
|
||
progressBar = findViewById(R.id.progressbar); | ||
|
||
|
||
Intent intent = getIntent(); | ||
String category = intent.getStringExtra("category"); | ||
|
||
Toolbar toolbar = findViewById(R.id.toolbar); | ||
toolbar.setTitle(category); | ||
setSupportActionBar(toolbar); | ||
|
||
dbWallpapers = FirebaseDatabase.getInstance().getReference("images") | ||
.child(category); | ||
|
||
progressBar.setVisibility(View.VISIBLE); | ||
dbWallpapers.addListenerForSingleValueEvent(new ValueEventListener() { | ||
@Override | ||
public void onDataChange(DataSnapshot dataSnapshot) { | ||
progressBar.setVisibility(View.GONE); | ||
if(dataSnapshot.exists()){ | ||
for(DataSnapshot wallpaperSnapshot: dataSnapshot.getChildren()){ | ||
Wallpaper w = wallpaperSnapshot.getValue(Wallpaper.class); | ||
wallpaperList.add(w); | ||
} | ||
adapter.notifyDataSetChanged(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onCancelled(DatabaseError databaseError) { | ||
|
||
} | ||
}); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
app/src/main/java/net/simplifiedcoding/wallpaperhub/adapters/WallpapersAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package net.simplifiedcoding.wallpaperhub.adapters; | ||
|
||
import android.content.Context; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import com.bumptech.glide.Glide; | ||
|
||
import net.simplifiedcoding.wallpaperhub.R; | ||
import net.simplifiedcoding.wallpaperhub.models.Category; | ||
import net.simplifiedcoding.wallpaperhub.models.Wallpaper; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by Belal on 4/21/2018. | ||
*/ | ||
|
||
public class WallpapersAdapter extends RecyclerView.Adapter<WallpapersAdapter.CategoryViewHolder> { | ||
|
||
private Context mCtx; | ||
private List<Wallpaper> wallpaperList; | ||
|
||
public WallpapersAdapter(Context mCtx, List<Wallpaper> wallpaperList) { | ||
this.mCtx = mCtx; | ||
this.wallpaperList = wallpaperList; | ||
} | ||
|
||
@Override | ||
public CategoryViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||
View view = LayoutInflater.from(mCtx).inflate(R.layout.recyclerview_wallpapers, parent, false); | ||
return new CategoryViewHolder(view); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(CategoryViewHolder holder, int position) { | ||
Wallpaper w = wallpaperList.get(position); | ||
holder.textView.setText(w.title); | ||
Glide.with(mCtx) | ||
.load(w.url) | ||
.into(holder.imageView); | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return wallpaperList.size(); | ||
} | ||
|
||
class CategoryViewHolder extends RecyclerView.ViewHolder { | ||
|
||
TextView textView; | ||
ImageView imageView; | ||
|
||
public CategoryViewHolder(View itemView) { | ||
super(itemView); | ||
|
||
textView = itemView.findViewById(R.id.text_view_title); | ||
imageView = itemView.findViewById(R.id.image_view); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
app/src/main/java/net/simplifiedcoding/wallpaperhub/models/Wallpaper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package net.simplifiedcoding.wallpaperhub.models; | ||
|
||
public class Wallpaper { | ||
|
||
public String title, desc, url; | ||
|
||
public Wallpaper(){ | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".activities.WallpapersActivity"> | ||
|
||
<android.support.design.widget.AppBarLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:background="@color/colorPrimary"> | ||
|
||
<android.support.v7.widget.Toolbar | ||
android:id="@+id/toolbar" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
app:layout_scrollFlags="scroll|enterAlways" | ||
app:title="@string/app_name" | ||
app:titleTextColor="@color/colorTitle" /> | ||
|
||
</android.support.design.widget.AppBarLayout> | ||
|
||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<android.support.v7.widget.RecyclerView | ||
android:id="@+id/recycler_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" /> | ||
|
||
<ProgressBar | ||
android:id="@+id/progressbar" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_centerHorizontal="true" | ||
android:layout_centerVertical="true" | ||
android:visibility="gone" /> | ||
|
||
</RelativeLayout> | ||
|
||
</android.support.design.widget.CoordinatorLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="270dp"> | ||
|
||
<RelativeLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<ImageView | ||
android:scaleType="fitXY" | ||
android:id="@+id/image_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" /> | ||
|
||
<TextView | ||
android:text="Marvel" | ||
android:background="@color/colorCategoryBackground" | ||
android:textColor="@color/colorWhite" | ||
android:textAlignment="center" | ||
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium" | ||
android:layout_alignParentBottom="true" | ||
android:id="@+id/text_view_title" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" /> | ||
|
||
</RelativeLayout> | ||
|
||
</android.support.v7.widget.CardView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Mon Apr 16 23:17:33 IST 2018 | ||
#Fri Apr 27 11:21:06 IST 2018 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip |