-
Notifications
You must be signed in to change notification settings - Fork 0
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
144f80f
commit ba311d3
Showing
54 changed files
with
1,694 additions
and
17 deletions.
There are no files selected for viewing
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,11 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="meet.mobile.tv"> | ||
package="meet.mobile" > | ||
|
||
<application android:allowBackup="true" | ||
android:label="@string/app_name" | ||
android:icon="@mipmap/ic_launcher" | ||
android:theme="@style/AppTheme"> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" /> | ||
|
||
</application> | ||
<application | ||
android:name=".application.AdvancedRecyclerViewApplication" | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme" > | ||
<activity | ||
android:name=".activity.MainActivity" | ||
android:label="@string/app_name" > | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,41 @@ | ||
package meet.mobile.activity; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
|
||
import com.nostra13.universalimageloader.core.DisplayImageOptions; | ||
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; | ||
|
||
import javax.inject.Inject; | ||
|
||
import meet.mobile.application.AdvancedRecyclerViewApplication; | ||
import meet.mobile.dagger.componentes.ApplicationComponent; | ||
import meet.mobile.dagger.modules.ActivityModule; | ||
|
||
|
||
/** | ||
* Created by Filip Zymek on 2015-06-19. | ||
*/ | ||
public abstract class BaseActivity extends AppCompatActivity { | ||
|
||
@Inject | ||
protected DisplayImageOptions options; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
getApplicationComponent().inject(this); | ||
} | ||
|
||
public DisplayImageOptions getDisplayImageOptions() { | ||
return options; | ||
} | ||
|
||
protected ApplicationComponent getApplicationComponent() { | ||
return ((AdvancedRecyclerViewApplication)getApplication()).getApplicationComponent(); | ||
} | ||
|
||
protected ActivityModule getActivityModule() { | ||
return new ActivityModule(this); | ||
} | ||
} |
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,62 @@ | ||
package meet.mobile.activity; | ||
|
||
import android.os.Bundle; | ||
import android.preference.PreferenceManager; | ||
import android.util.Log; | ||
import android.view.MenuItem; | ||
|
||
import meet.mobile.R; | ||
import meet.mobile.fragment.MainFragment; | ||
|
||
|
||
public class MainActivity extends BaseActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
setupPreferences(); | ||
|
||
if (savedInstanceState == null) { | ||
Log.d("main", "attaching fragment"); | ||
MainFragment f = MainFragment.newInstance(); | ||
getFragmentManager().beginTransaction() | ||
.replace(R.id.content_frame, f, "main") | ||
.commit(); | ||
} else { | ||
Log.d("main", "no fragment"); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public void onBackPressed() { | ||
if (getFragmentManager().getBackStackEntryCount() > 0) { | ||
getFragmentManager().popBackStack(); | ||
} else { | ||
super.onBackPressed(); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
// Handle action bar item clicks here. The action bar will | ||
// automatically handle clicks on the Home/Up button, so long | ||
// as you specify a parent activity in AndroidManifest.xml. | ||
int id = item.getItemId(); | ||
|
||
switch (id) { | ||
case android.R.id.home: | ||
onBackPressed(); | ||
return true; | ||
|
||
} | ||
return super.onOptionsItemSelected(item); | ||
} | ||
|
||
|
||
private void setupPreferences() { | ||
PreferenceManager.setDefaultValues(this, R.xml.settings, false); | ||
} | ||
|
||
} |
151 changes: 151 additions & 0 deletions
151
app/src/main/java/meet/mobile/adapter/ImagesAdapter.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,151 @@ | ||
package meet.mobile.adapter; | ||
|
||
import android.animation.TimeInterpolator; | ||
import android.content.Context; | ||
import android.graphics.Point; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.util.SparseBooleanArray; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.view.WindowManager; | ||
import android.view.animation.DecelerateInterpolator; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import com.nostra13.universalimageloader.core.DisplayImageOptions; | ||
import com.nostra13.universalimageloader.core.ImageLoader; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import butterknife.ButterKnife; | ||
import butterknife.InjectView; | ||
import meet.mobile.R; | ||
import meet.mobile.model.Image; | ||
|
||
import static meet.mobile.utils.Utils.isLandscape; | ||
|
||
|
||
/** | ||
* Created by Filip Zymek on 2015-06-22. | ||
*/ | ||
public class ImagesAdapter extends RecyclerView.Adapter<ImagesAdapter.ImageCard> { | ||
|
||
final List<Image> images = new ArrayList<>(); | ||
final TimeInterpolator interpolator = new DecelerateInterpolator(2); | ||
final SparseBooleanArray animatedPositions = new SparseBooleanArray(); | ||
final Point windowSize = new Point(); | ||
final DisplayImageOptions options; | ||
|
||
Context context; | ||
int lastPosition = 0; | ||
|
||
public ImagesAdapter(Context context, DisplayImageOptions options) { | ||
this.context = context; | ||
this.options = options; | ||
|
||
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); | ||
wm.getDefaultDisplay().getSize(windowSize); | ||
|
||
} | ||
|
||
@Override | ||
public ImageCard onCreateViewHolder(ViewGroup parent, int viewType) { | ||
View v = LayoutInflater.from(this.context).inflate(R.layout.image_card, parent, false); | ||
return new ImageCard(v); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(final ImageCard holder, int position) { | ||
holder.artist.setText(getItem(position).getArtist()); | ||
holder.title.setText(getItem(position).getTitle()); | ||
ImageLoader.getInstance().cancelDisplayTask(holder.image); | ||
ImageLoader.getInstance().displayImage(getItem(position).getDisplayByType(Image.DisplaySizeType.PREVIEW).getUri(), holder.image, options); | ||
|
||
if (position > lastPosition && !animatedPositions.get(position)) { | ||
lastPosition = position; | ||
animatedPositions.put(position, true); | ||
startItemAnimation(holder, position); | ||
} | ||
} | ||
|
||
private void startItemAnimation(ImageCard holder, int position) { | ||
setupCommonItemProperties(holder); | ||
|
||
if (isLandscape(context)) { | ||
setupHorizontalItemProperties(holder, position); | ||
} else { | ||
setupVerticalItemProperties(holder); | ||
} | ||
|
||
holder.itemView.animate().translationX(0) | ||
.translationY(0) | ||
.rotationX(0) | ||
.rotationY(0) | ||
.scaleX(1) | ||
.scaleY(1) | ||
.alpha(1) | ||
.setDuration(500) | ||
.setInterpolator(interpolator) | ||
.setStartDelay(0) | ||
.start(); | ||
} | ||
|
||
private Image getItem(int position) { | ||
return images.get(position); | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return images.size(); | ||
} | ||
|
||
public void setImages(List<Image> images) { | ||
this.images.clear(); | ||
this.images.addAll(images); | ||
notifyDataSetChanged(); | ||
} | ||
|
||
public void clear() { | ||
this.images.clear(); | ||
lastPosition = 0; | ||
animatedPositions.clear(); | ||
notifyDataSetChanged(); | ||
} | ||
|
||
private void setupCommonItemProperties(ImageCard holder) { | ||
holder.itemView.setTranslationX(0); | ||
holder.itemView.setTranslationY(windowSize.y); | ||
holder.itemView.setScaleX(0.6f); | ||
holder.itemView.setScaleY(0.6f); | ||
holder.itemView.setAlpha(0); | ||
} | ||
|
||
private void setupHorizontalItemProperties(ImageCard holder, int position) { | ||
if (position % 2 == 0) { | ||
holder.itemView.setRotationY(45.0f); | ||
} else { | ||
holder.itemView.setRotationY(-45.0f); | ||
} | ||
} | ||
|
||
private void setupVerticalItemProperties(ImageCard holder) { | ||
holder.itemView.setRotationX(45.0f); | ||
} | ||
|
||
protected static class ImageCard extends RecyclerView.ViewHolder { | ||
|
||
@InjectView(R.id.image) | ||
ImageView image; | ||
@InjectView(R.id.artist) | ||
TextView artist; | ||
@InjectView(R.id.title) | ||
TextView title; | ||
|
||
public ImageCard(View itemView) { | ||
super(itemView); | ||
ButterKnife.inject(this, itemView); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
app/src/main/java/meet/mobile/application/AdvancedRecyclerViewApplication.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,29 @@ | ||
package meet.mobile.application; | ||
|
||
import android.app.Application; | ||
|
||
import meet.mobile.dagger.componentes.ApplicationComponent; | ||
import meet.mobile.dagger.componentes.DaggerApplicationComponent; | ||
import meet.mobile.dagger.modules.ApplicationModule; | ||
|
||
|
||
/** | ||
* Created by Filip Zymek on 2015-06-19. | ||
*/ | ||
public class AdvancedRecyclerViewApplication extends Application { | ||
|
||
private ApplicationComponent applicationComponent; | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
|
||
this.applicationComponent = DaggerApplicationComponent.builder() | ||
.applicationModule(new ApplicationModule(this)) | ||
.build(); | ||
} | ||
|
||
public ApplicationComponent getApplicationComponent() { | ||
return applicationComponent; | ||
} | ||
} |
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,12 @@ | ||
package meet.mobile.config; | ||
|
||
/** | ||
* Created by Filip Zymek on 2015-06-08. | ||
*/ | ||
public class API { | ||
|
||
//gettyimages secrets | ||
public static final String CONSUMER_KEY = "66tk2kux2g9fygcuj8eemmtf"; | ||
public static final String GETTY_IMAGES_SEARCH_ENDPOINT = "https://api.gettyimages.com/v3"; | ||
|
||
} |
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,10 @@ | ||
package meet.mobile.config; | ||
|
||
/** | ||
* Created by Filip Zymek on 2015-06-09. | ||
*/ | ||
public interface Config { | ||
String KEY_PREF_FAV_ANIMAL = "fav_animal"; | ||
String PREF_FAV_ANIMAL_DEFAULT = "1"; | ||
String KEY_PREF_USE_STAGGERED_GRID = "use_staggered_grid"; | ||
} |
Oops, something went wrong.