Releasing 0.4.0

This commit is contained in:
ChronosX88 2019-02-19 20:11:30 +04:00
commit 44cb60762a
No known key found for this signature in database
GPG Key ID: 8F92E090A87804AA
11 changed files with 229 additions and 36 deletions

Binary file not shown.

View File

@ -34,4 +34,5 @@ dependencies {
implementation 'com.squareup.retrofit2:converter-gson:2.4.0' implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.android.support:recyclerview-v7:27.1.1' implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.squareup.picasso:picasso:2.71828' implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.github.chrisbanes:PhotoView:2.1.4'
} }

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="ru.volgorobot.vrcatalog"> package="ru.volgorobot.vrcatalog">
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
@ -23,6 +24,9 @@
</activity> </activity>
<activity android:name=".view.SettingsActivity" /> <activity android:name=".view.SettingsActivity" />
<activity android:name=".view.AboutActivity" /> <activity android:name=".view.AboutActivity" />
<activity
android:name=".view.FullScreenImageActivity"
android:theme="@style/AppTheme.Fullscreen"/>
<activity <activity
android:name=".view.DetailActivity" android:name=".view.DetailActivity"
android:theme="@style/ItemActivityTheme"/> android:theme="@style/ItemActivityTheme"/>

View File

@ -0,0 +1,98 @@
package ru.volgorobot.vrcatalog.additional;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v4.view.PagerAdapter;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.widget.ImageView;
import com.github.chrisbanes.photoview.OnPhotoTapListener;
import com.github.chrisbanes.photoview.PhotoView;
import com.squareup.picasso.Picasso;
public class FullscreenImagePagerAdapter extends PagerAdapter {
/**
* This class is designed to control the ViewPager (images of item) in the activity of viewing details of items (DetailActivity).
*/
private Context context;
private String[] imageUris;
private Toolbar mToolbar;
private boolean mIsFullScreen;
public FullscreenImagePagerAdapter(Context context, String[] imageUris, Toolbar toolbar, boolean isFullScreen) {
this.context = context;
this.imageUris = imageUris;
this.mToolbar = toolbar;
this.mIsFullScreen = isFullScreen;
}
@Override
public int getCount() {
return imageUris.length;
}
@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
return view == object;
}
/**
* This function initializes a new image from a URI.
* @return ImageView
*/
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
PhotoView photoView = new PhotoView(context);
Picasso.get()
.load(imageUris[position])
.into(photoView);
photoView.setOnPhotoTapListener(new PhotoTapListener());
container.addView(photoView);
return photoView;
}
@Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
container.removeView((View) object);
}
private class PhotoTapListener implements OnPhotoTapListener, View.OnSystemUiVisibilityChangeListener {
@Override
public void onPhotoTap(ImageView view, float x, float y) {
updateView();
}
public void updateView() {
mIsFullScreen = !mIsFullScreen;
if (mIsFullScreen) {
hideSystemUI();
} else {
showSystemUI();
}
}
private void hideSystemUI() {
mToolbar.animate().translationY(-mToolbar.getHeight()).setInterpolator(new AccelerateInterpolator(2)).start();
}
private void showSystemUI() {
mToolbar.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start();
}
@Override
public void onSystemUiVisibilityChange(int visibility) {
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
mIsFullScreen = false;
}
updateView();
}
}
}

View File

@ -1,6 +1,7 @@
package ru.volgorobot.vrcatalog.additional; package ru.volgorobot.vrcatalog.additional;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.net.Uri; import android.net.Uri;
import android.provider.MediaStore; import android.provider.MediaStore;
@ -16,6 +17,8 @@ import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import ru.volgorobot.vrcatalog.R; import ru.volgorobot.vrcatalog.R;
import ru.volgorobot.vrcatalog.view.DetailActivity;
import ru.volgorobot.vrcatalog.view.FullScreenImageActivity;
public class ImagePagerAdapter extends PagerAdapter { public class ImagePagerAdapter extends PagerAdapter {
/** /**
@ -60,6 +63,14 @@ public class ImagePagerAdapter extends PagerAdapter {
.resize(0, 313) .resize(0, 313)
.centerCrop() .centerCrop()
.into(imageView); .into(imageView);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(context, FullScreenImageActivity.class);
intent.putExtra("uris", imageUris);
context.startActivity(intent);
}
});
container.addView(imageView); container.addView(imageView);
return imageView; return imageView;

View File

@ -139,7 +139,7 @@ public class DetailActivity extends AppCompatActivity implements MainContract.It
@Override @Override
public void setViewPagerContent(String[] uris) { public void setViewPagerContent(String[] uris) {
imagePagerAdapter = new ImagePagerAdapter(DetailActivity.this, uris); imagePagerAdapter = new ImagePagerAdapter(DetailActivity.this, uris);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabDots); TabLayout tabLayout = findViewById(R.id.tabDots);
viewPager.setAdapter(imagePagerAdapter); viewPager.setAdapter(imagePagerAdapter);
setViewPagerScrollListener(); setViewPagerScrollListener();
tabLayout.setupWithViewPager(viewPager); tabLayout.setupWithViewPager(viewPager);
@ -203,37 +203,4 @@ public class DetailActivity extends AppCompatActivity implements MainContract.It
}; };
viewPager.setOnPageChangeListener(listener); viewPager.setOnPageChangeListener(listener);
} }
public static boolean setListViewHeightBasedOnItems(ListView listView) {
ListAdapter listAdapter = listView.getAdapter();
if (listAdapter != null) {
int numberOfItems = listAdapter.getCount();
// Get total height of all items.
int totalItemsHeight = 0;
for (int itemPos = 0; itemPos < numberOfItems; itemPos++) {
View item = listAdapter.getView(itemPos, null, listView);
item.measure(0, 0);
totalItemsHeight += item.getMeasuredHeight();
}
// Get total height of all item dividers.
int totalDividersHeight = listView.getDividerHeight() *
(numberOfItems - 1);
// Set list height.
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalItemsHeight + totalDividersHeight;
listView.setLayoutParams(params);
listView.requestLayout();
return true;
} else {
return false;
}
}
} }

View File

@ -0,0 +1,72 @@
package ru.volgorobot.vrcatalog.view;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import ru.volgorobot.vrcatalog.R;
import ru.volgorobot.vrcatalog.additional.FullscreenImagePagerAdapter;
public class FullScreenImageActivity extends AppCompatActivity {
private Toolbar mToolbar;
private ViewPager fullscreenViewPager;
private boolean mIsFullScreen;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fullscreenimage);
mToolbar = findViewById(R.id.toolbar);
mToolbar.setTitle("");
if (mToolbar != null) {
setSupportActionBar(mToolbar);
}
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
final Drawable upArrow = ContextCompat.getDrawable(this, R.drawable.abc_ic_ab_back_material);
upArrow.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
getSupportActionBar().setHomeAsUpIndicator(upArrow);
mToolbar.bringToFront();
mIsFullScreen = true;
Window window = getWindow();
WindowManager.LayoutParams winParams = window.getAttributes();
winParams.flags &= ~WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
window.setAttributes(winParams);
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
fullscreenViewPager = findViewById(R.id.fullscreen_mode_viewpager);
FullscreenImagePagerAdapter adapter = new FullscreenImagePagerAdapter(FullScreenImageActivity.this, getIntent().getExtras().getStringArray("uris"), mToolbar, mIsFullScreen);
fullscreenViewPager.setAdapter(adapter);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
}

View File

@ -0,0 +1,27 @@
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="ru.volgorobot.vrcatalog.view.FullScreenImageActivity"
android:background="@android:color/black">
<android.support.v4.view.ViewPager
android:id="@+id/fullscreen_mode_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentTop="true"
android:background="#33000000"
android:fitsSystemWindows="true"
android:theme="@style/TransparentActionBar"
android:popupTheme="@style/AppTheme.AppBarOverlay" />
</RelativeLayout>

View File

@ -5,12 +5,19 @@
<item name="windowNoTitle">true</item> <item name="windowNoTitle">true</item>
<item name="android:statusBarColor">@android:color/transparent</item> <item name="android:statusBarColor">@android:color/transparent</item>
</style> </style>
<style name="AppTheme.Fullscreen">
<item name="android:windowFullscreen">true</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
<style name="ItemActivityTheme" parent="AppTheme"> <style name="ItemActivityTheme" parent="AppTheme">
<item name="android:windowTranslucentStatus">true</item> <item name="android:windowTranslucentStatus">true</item>
<item name="windowActionBar">false</item> <item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item> <item name="windowNoTitle">true</item>
</style> </style>
<style name="MyActionBar" parent="Widget.AppCompat.ActionBar.Solid"> <style name="TransparentActionBar" parent="Widget.AppCompat.ActionBar.Solid">
<item name="android:background">@android:color/transparent</item> <item name="android:background">@android:color/transparent</item>
<item name="background">@android:color/transparent</item> <item name="background">@android:color/transparent</item>
</style> </style>

View File

@ -20,5 +20,10 @@
<style name="ItemActivityTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <style name="ItemActivityTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowTranslucentStatus">true</item> <item name="android:windowTranslucentStatus">true</item>
</style> </style>
<style name="AppTheme.Fullscreen">
<item name="android:windowFullscreen">true</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
</resources> </resources>

View File

@ -21,6 +21,7 @@ allprojects {
google() google()
jcenter() jcenter()
mavenCentral() mavenCentral()
maven { url "https://jitpack.io" }
} }
} }