-
Notifications
You must be signed in to change notification settings - Fork 44
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
Showing
17 changed files
with
281 additions
and
97 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
49 changes: 49 additions & 0 deletions
49
app/src/main/java/com/ebr163/bifacialview/CustomPagerAdapter.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,49 @@ | ||
package com.ebr163.bifacialview; | ||
|
||
import android.content.Context; | ||
import android.support.v4.view.PagerAdapter; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
/** | ||
* Created by ergashev on 29.04.17. | ||
*/ | ||
|
||
public class CustomPagerAdapter extends PagerAdapter { | ||
|
||
private Context mContext; | ||
|
||
public CustomPagerAdapter(Context context) { | ||
mContext = context; | ||
} | ||
|
||
@Override | ||
public Object instantiateItem(ViewGroup collection, int position) { | ||
LayoutInflater inflater = LayoutInflater.from(mContext); | ||
ViewGroup layout = (ViewGroup) inflater.inflate(R.layout.page, collection, false); | ||
collection.addView(layout); | ||
return layout; | ||
} | ||
|
||
@Override | ||
public void destroyItem(ViewGroup collection, int position, Object view) { | ||
collection.removeView((View) view); | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
return 3; | ||
} | ||
|
||
@Override | ||
public boolean isViewFromObject(View view, Object object) { | ||
return view == object; | ||
} | ||
|
||
@Override | ||
public CharSequence getPageTitle(int position) { | ||
return "Title"; | ||
} | ||
|
||
} |
46 changes: 11 additions & 35 deletions
46
app/src/main/java/com/ebr163/bifacialview/MainActivity.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 |
---|---|---|
@@ -1,49 +1,25 @@ | ||
package com.ebr163.bifacialview; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.View; | ||
|
||
import com.bumptech.glide.Glide; | ||
import com.bumptech.glide.load.resource.drawable.GlideDrawable; | ||
import com.bumptech.glide.request.RequestListener; | ||
import com.bumptech.glide.request.target.Target; | ||
import com.ebr163.bifacialview.view.BifacialView; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
public class MainActivity extends AppCompatActivity implements View.OnClickListener { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
final BifacialView view = (BifacialView) findViewById(R.id.view); | ||
Glide.with(this) | ||
.load("https://files4.adme.ru/files/news/part_149/1494765/29530665-262592-3-0-1491487588-1491487592-650-bf845cd25e-1491558012.jpg") | ||
.listener(new RequestListener<String, GlideDrawable>() { | ||
@Override | ||
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { | ||
view.setDrawableLeft(resource); | ||
return false; | ||
} | ||
}).preload(); | ||
|
||
Glide.with(this) | ||
.load("https://files3.adme.ru/files/news/part_149/1494765/29530265-262592-33-0-1491489159-1491489163-650-8edb1df01d-1491558012.jpg") | ||
.listener(new RequestListener<String, GlideDrawable>() { | ||
@Override | ||
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { | ||
return false; | ||
} | ||
} | ||
|
||
@Override | ||
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { | ||
view.setDrawableRight(resource); | ||
return false; | ||
} | ||
}).preload(); | ||
@Override | ||
public void onClick(View v) { | ||
if (v.getId() == R.id.simple_screen) { | ||
startActivity(new Intent(this, SimpleActivity.class)); | ||
} else { | ||
startActivity(new Intent(this, ViewPagerActivity.class)); | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
app/src/main/java/com/ebr163/bifacialview/SimpleActivity.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,49 @@ | ||
package com.ebr163.bifacialview; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
|
||
import com.bumptech.glide.Glide; | ||
import com.bumptech.glide.load.resource.drawable.GlideDrawable; | ||
import com.bumptech.glide.request.RequestListener; | ||
import com.bumptech.glide.request.target.Target; | ||
import com.ebr163.bifacialview.view.BifacialView; | ||
|
||
public class SimpleActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_simple); | ||
final BifacialView view = (BifacialView) findViewById(R.id.view); | ||
Glide.with(this) | ||
.load("https://files4.adme.ru/files/news/part_149/1494765/29530665-262592-3-0-1491487588-1491487592-650-bf845cd25e-1491558012.jpg") | ||
.listener(new RequestListener<String, GlideDrawable>() { | ||
@Override | ||
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { | ||
view.setDrawableRight(resource); | ||
return false; | ||
} | ||
}).preload(); | ||
|
||
Glide.with(this) | ||
.load("https://files3.adme.ru/files/news/part_149/1494765/29530265-262592-33-0-1491489159-1491489163-650-8edb1df01d-1491558012.jpg") | ||
.listener(new RequestListener<String, GlideDrawable>() { | ||
@Override | ||
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { | ||
view.setDrawableLeft(resource); | ||
return false; | ||
} | ||
}).preload(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/ebr163/bifacialview/ViewPagerActivity.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,20 @@ | ||
package com.ebr163.bifacialview; | ||
|
||
import android.os.Bundle; | ||
import android.support.v4.view.ViewPager; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.Toolbar; | ||
|
||
public class ViewPagerActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_view_pager); | ||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | ||
setSupportActionBar(toolbar); | ||
ViewPager view = (ViewPager) findViewById(R.id.viewpager); | ||
view.setAdapter(new CustomPagerAdapter(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 |
---|---|---|
@@ -1,22 +1,22 @@ | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:background="@android:color/black" | ||
android:layout_height="match_parent" | ||
xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
android:orientation="vertical"> | ||
|
||
<com.ebr163.bifacialview.view.BifacialView | ||
android:id="@+id/view" | ||
android:layout_centerInParent="true" | ||
android:layout_width="match_parent" | ||
android:layout_height="226dp" | ||
app:drawableLeft="@drawable/left" | ||
app:drawableRight="@drawable/right" | ||
app:arrowVisibility="true" | ||
app:leftText="before" | ||
app:rightText="after" | ||
app:textSize="20sp" | ||
app:delimiterColor="@android:color/white" | ||
app:arrowColor="@android:color/holo_orange_light" | ||
app:textColor="@android:color/holo_orange_light" /> | ||
<Button | ||
android:id="@+id/simple_screen" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center_horizontal" | ||
android:onClick="onClick" | ||
android:text="Simple" /> | ||
|
||
</RelativeLayout> | ||
<Button | ||
android:id="@+id/vp_screen" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center_horizontal" | ||
android:onClick="onClick" | ||
android:text="ViewPager" /> | ||
|
||
</LinearLayout> |
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,24 @@ | ||
<?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" | ||
tools:context="com.ebr163.bifacialview.SimpleActivity"> | ||
|
||
<com.ebr163.bifacialview.view.BifacialView | ||
android:id="@+id/view" | ||
android:layout_width="match_parent" | ||
android:layout_height="256dp" | ||
android:layout_centerInParent="true" | ||
app:arrowColor="@color/colorAccent" | ||
app:arrowVisibility="true" | ||
app:drawableLeft="@drawable/left" | ||
app:drawableRight="@drawable/right" | ||
app:leftText="before" | ||
app:rightText="after" | ||
app:textColor="@color/colorPrimary" | ||
app:textSize="20sp" /> | ||
|
||
|
||
</RelativeLayout> |
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,25 @@ | ||
<?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="com.ebr163.bifacialview.ViewPagerActivity"> | ||
|
||
<android.support.design.widget.AppBarLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:theme="@style/AppTheme.AppBarOverlay"> | ||
|
||
<android.support.v7.widget.Toolbar | ||
android:id="@+id/toolbar" | ||
android:layout_width="match_parent" | ||
android:layout_height="?attr/actionBarSize" | ||
android:background="?attr/colorPrimary" | ||
app:popupTheme="@style/AppTheme.PopupOverlay" /> | ||
|
||
</android.support.design.widget.AppBarLayout> | ||
|
||
<include layout="@layout/content_view_pager" /> | ||
|
||
</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,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@+id/viewpager" | ||
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" | ||
app:layout_behavior="@string/appbar_scrolling_view_behavior" | ||
tools:context="com.ebr163.bifacialview.ViewPagerActivity" | ||
tools:showIn="@layout/activity_view_pager" /> |
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,24 @@ | ||
<?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" | ||
tools:context="com.ebr163.bifacialview.SimpleActivity"> | ||
|
||
<com.ebr163.bifacialview.view.BifacialView | ||
android:id="@+id/view" | ||
android:layout_width="match_parent" | ||
android:layout_height="256dp" | ||
android:layout_centerInParent="true" | ||
app:arrowColor="@color/colorAccent" | ||
app:arrowVisibility="true" | ||
app:drawableLeft="@drawable/left" | ||
app:drawableRight="@drawable/right" | ||
app:leftText="before" | ||
app:rightText="after" | ||
app:touchMode="delimiter" | ||
app:textColor="@color/colorPrimary" | ||
app:textSize="20sp" /> | ||
|
||
</RelativeLayout> |
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,3 @@ | ||
<resources> | ||
<dimen name="fab_margin">16dp</dimen> | ||
</resources> |
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,3 +1,4 @@ | ||
<resources> | ||
<string name="app_name">BifacialView</string> | ||
<string name="title_activity_view_pager">ViewPagerActivity</string> | ||
</resources> |
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
Oops, something went wrong.