-
Notifications
You must be signed in to change notification settings - Fork 31
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
liamcli
committed
Mar 24, 2023
1 parent
b9beb9b
commit 37e3448
Showing
25 changed files
with
550 additions
and
51 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
4 changes: 2 additions & 2 deletions
4
...src/androidTest/java/com/tencent/libpag/sample/libpag_sample/ExampleInstrumentedTest.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
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
86 changes: 86 additions & 0 deletions
86
sample/app/src/main/java/com/tencent/libpag/sample/libpag_sample/CustomAdapter.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,86 @@ | ||
package com.tencent.libpag.sample.libpag_sample; | ||
|
||
import android.util.Log; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.TextView; | ||
|
||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import org.libpag.PAGImageView; | ||
|
||
/** | ||
* Provide views to RecyclerView with data from mDataSet. | ||
*/ | ||
public class CustomAdapter extends RecyclerView.Adapter<CustomAdapter.ViewHolder> { | ||
private static final String TAG = "CustomAdapter"; | ||
|
||
private String[] mDataSet; | ||
|
||
// BEGIN_INCLUDE(recyclerViewSampleViewHolder) | ||
/** | ||
* Provide a reference to the type of views that you are using (custom ViewHolder) | ||
*/ | ||
public static class ViewHolder extends RecyclerView.ViewHolder { | ||
private final PAGImageView pagImageView; | ||
|
||
public ViewHolder(View v) { | ||
super(v); | ||
// Define click listener for the ViewHolder's View. | ||
v.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Log.d(TAG, "Element " + getAdapterPosition() + " clicked."); | ||
} | ||
}); | ||
pagImageView = (PAGImageView) v.findViewById(R.id.pagView); | ||
} | ||
|
||
public PAGImageView getView() { | ||
return pagImageView; | ||
} | ||
} | ||
// END_INCLUDE(recyclerViewSampleViewHolder) | ||
|
||
/** | ||
* Initialize the dataset of the Adapter. | ||
* | ||
* @param dataSet String[] containing the data to populate views to be used by RecyclerView. | ||
*/ | ||
public CustomAdapter(String[] dataSet) { | ||
mDataSet = dataSet; | ||
} | ||
|
||
// BEGIN_INCLUDE(recyclerViewOnCreateViewHolder) | ||
// Create new views (invoked by the layout manager) | ||
@Override | ||
public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { | ||
// Create a new view. | ||
View v = LayoutInflater.from(viewGroup.getContext()) | ||
.inflate(R.layout.text_row_item, viewGroup, false); | ||
|
||
return new ViewHolder(v); | ||
} | ||
// END_INCLUDE(recyclerViewOnCreateViewHolder) | ||
|
||
// BEGIN_INCLUDE(recyclerViewOnBindViewHolder) | ||
// Replace the contents of a view (invoked by the layout manager) | ||
@Override | ||
public void onBindViewHolder(ViewHolder viewHolder, final int position) { | ||
Log.d(TAG, "Element " + position + " set."); | ||
|
||
// Get element from your dataset at this position and replace the contents of the view | ||
// with that element | ||
viewHolder.getView().setPath(mDataSet[position]); | ||
viewHolder.getView().setRepeatCount(-1); | ||
viewHolder.getView().play(); | ||
} | ||
// END_INCLUDE(recyclerViewOnBindViewHolder) | ||
|
||
// Return the size of your dataset (invoked by the layout manager) | ||
@Override | ||
public int getItemCount() { | ||
return mDataSet.length; | ||
} | ||
} |
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
36 changes: 36 additions & 0 deletions
36
...p/src/main/java/com/tencent/libpag/sample/libpag_sample/MultiplePAGImageViewActivity.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,36 @@ | ||
package com.tencent.libpag.sample.libpag_sample; | ||
|
||
import android.os.Bundle; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import android.view.MotionEvent; | ||
|
||
import org.libpag.PAGImageView; | ||
|
||
public class MultiplePAGImageViewActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_multiple_pagimageview); | ||
callFire(); | ||
} | ||
|
||
void fireImageView(int id, String path) { | ||
PAGImageView view = findViewById(id); | ||
view.setPath(path); | ||
view.setRepeatCount(-1); | ||
view.play(); | ||
} | ||
|
||
void callFire() { | ||
int ids[] = {R.id.pagView1, R.id.pagView2, R.id.pagView3, R.id.pagView4, R.id.pagView5, | ||
R.id.pagView6, R.id.pagView7, R.id.pagView8, R.id.pagView9, R.id.pagView10, | ||
R.id.pagView11, R.id.pagView12, R.id.pagView13, R.id.pagView14, R.id.pagView15, | ||
R.id.pagView16, R.id.pagView17, R.id.pagView18, R.id.pagView19, R.id.pagView20, | ||
R.id.pagView21, R.id.pagView22}; | ||
for (int i = 0; i < ids.length; i++) { | ||
fireImageView(ids[i], "assets://" + (i + 1) + ".pag"); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...e/app/src/main/java/com/tencent/libpag/sample/libpag_sample/PAGImageViewListActivity.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,26 @@ | ||
package com.tencent.libpag.sample.libpag_sample; | ||
|
||
import androidx.fragment.app.FragmentActivity; | ||
import androidx.fragment.app.FragmentTransaction; | ||
|
||
import android.os.Bundle; | ||
|
||
import androidx.annotation.Nullable; | ||
import androidx.fragment.app.FragmentManager; | ||
|
||
public class PAGImageViewListActivity extends FragmentActivity { | ||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
FragmentManager fm = getSupportFragmentManager(); | ||
FragmentTransaction transaction = fm.beginTransaction(); | ||
PAGImageViewRecyclerViewFragment fragment = new PAGImageViewRecyclerViewFragment(); | ||
String[] path = new String[22]; | ||
for (int i = 0; i < 22; i++) { | ||
path[i] = "assets://" + (i + 1) + ".pag"; | ||
} | ||
fragment.setPaths(path); | ||
transaction.add(android.R.id.content, fragment); | ||
transaction.commit(); | ||
} | ||
} |
Oops, something went wrong.