-
Notifications
You must be signed in to change notification settings - Fork 25
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
Viven
committed
Nov 28, 2016
1 parent
b7c192a
commit 7906b57
Showing
7 changed files
with
112 additions
and
2 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.
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
16 changes: 16 additions & 0 deletions
16
app/src/main/java/com/viven/imagezoom/sample/LaunchActivity.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,13 +1,29 @@ | ||
package com.viven.imagezoom.sample; | ||
|
||
import android.content.Intent; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
|
||
public class LaunchActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_launch); | ||
|
||
findViewById(R.id.btnBasic).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
startActivity(new Intent(LaunchActivity.this, MainActivity.class)); | ||
} | ||
}); | ||
|
||
findViewById(R.id.btnRecycler).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
startActivity(new Intent(LaunchActivity.this, RecyclerViewActivity.class)); | ||
} | ||
}); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
app/src/main/java/com/viven/imagezoom/sample/RecyclerViewActivity.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,13 +1,73 @@ | ||
package com.viven.imagezoom.sample; | ||
|
||
import android.os.Handler; | ||
import android.support.v4.widget.SwipeRefreshLayout; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.support.v7.widget.GridLayoutManager; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.MotionEvent; | ||
import android.view.ViewGroup; | ||
import android.widget.ImageView; | ||
|
||
import com.viven.imagezoom.ImageZoomHelper; | ||
|
||
public class RecyclerViewActivity extends AppCompatActivity { | ||
|
||
RecyclerView recyclerView; | ||
SwipeRefreshLayout swipeRefreshLayout; | ||
|
||
ImageZoomHelper imageZoomHelper; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_recycler_view); | ||
|
||
recyclerView = (RecyclerView) findViewById(R.id.list); | ||
recyclerView.setLayoutManager(new GridLayoutManager(this, 2, RecyclerView.VERTICAL, | ||
false)); | ||
recyclerView.setAdapter(new RecyclerView.Adapter() { | ||
@Override | ||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||
ImageView imageView = new ImageView(RecyclerViewActivity.this); | ||
imageView.setImageResource(R.mipmap.ic_launcher); | ||
ImageZoomHelper.setViewZoomable(imageView); | ||
imageView.setMinimumHeight(400); | ||
return new RecyclerView.ViewHolder(imageView) {}; | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { | ||
|
||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return 20; | ||
} | ||
}); | ||
|
||
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeLayout); | ||
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { | ||
@Override | ||
public void onRefresh() { | ||
ImageZoomHelper.setZoom(swipeRefreshLayout, false); | ||
new Handler().postDelayed(new Runnable() { | ||
@Override | ||
public void run() { | ||
swipeRefreshLayout.setRefreshing(false); | ||
ImageZoomHelper.setZoom(swipeRefreshLayout, true); | ||
} | ||
}, 2000); | ||
} | ||
}); | ||
|
||
imageZoomHelper = new ImageZoomHelper(this); | ||
} | ||
|
||
@Override | ||
public boolean dispatchTouchEvent(MotionEvent ev) { | ||
return imageZoomHelper.onDispatchTouchEvent(ev) || super.dispatchTouchEvent(ev); | ||
} | ||
} |
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