Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app-catalog/androidres/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#Exclude everything
*

!README.md
!.gitignore
!build.gradle
!src/main/res/placeholder
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

> 本地带着复制来的 res 参与编译可能会失败,删除即可。

[回到主页](../../../README.md)
[回到主页](../../README.md)
4 changes: 4 additions & 0 deletions app-catalog/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,7 @@
-dontwarn org.joda.time.format.DateTimeFormat
-dontwarn org.joda.time.format.DateTimeFormatter
-dontwarn springfox.documentation.spring.web.json.Json

-dontwarn com.squareup.okhttp.Cache
-dontwarn com.squareup.okhttp.OkHttpClient
-dontwarn com.squareup.okhttp.OkUrlFactory
3 changes: 0 additions & 3 deletions app-catalog/samples/androidres/src/main/.gitignore

This file was deleted.

6 changes: 3 additions & 3 deletions app-catalog/samples/wBasis/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ dependencies {
implementation libs.androidx.lifecycle.runtime.ktx
implementation libs.androidx.ui.graphics
implementation libs.compose.ui.tooling.preview
androidTestImplementation libs.compose.ui.test.junit4
debugImplementation libs.compose.ui.tooling
debugImplementation libs.compose.ui.test.manifest
implementation libs.glide

implementation 'com.squareup.picasso:picasso:2.4.0'
}
36 changes: 25 additions & 11 deletions app-catalog/samples/wBasis/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
android:label="title_activity_main2"
android:theme="@style/Theme.Android_Kickoff" />

<!-- callnotification START -->
<!-- call notification START -->
<activity
android:name=".telephony.callnotification.CallNotificationSample"
android:exported="true"
Expand All @@ -48,21 +48,21 @@
android:name=".telephony.callnotification.CallNotificationSample$NotificationReceiver"
android:exported="false"
tools:targetApi="28" />
<!-- callnotification END-->
<!-- call notification END-->

<!-- networkConnectivity START-->
<!-- network connectivity START-->
<activity
android:name=".telephony.networkconnectivity.NetworkConnActivity"
android:exported="true"
android:theme="@style/Theme.AppCompat.DayNight" />
<!-- networkConnectivity END-->
<!-- network connectivity END-->

<!-- recyclerview START-->
<!-- recycler view START-->
<activity
android:name=".ui.recyclerview.RecyclerViewActivity"
android:exported="true"
android:theme="@style/Theme.AppCompat.DayNight" />
<!-- recyclerview END-->
<!-- recycler view END-->

<!-- gesture detect START-->
<activity
Expand All @@ -71,12 +71,12 @@
android:theme="@style/Theme.AppCompat.DayNight" />
<!-- gesture detect END-->

<!-- slidingpanelayout START-->
<!-- sliding panel layout START-->
<activity
android:name=".ui.layout.slidingpanelayout.SlidingPaneLayoutMain"
android:exported="true"
android:theme="@style/Theme.AppCompat.DayNight"></activity>
<!-- slidingpanelayout END-->
android:theme="@style/Theme.AppCompat.DayNight" />
<!-- sliding panel layout END-->

<activity
android:name=".PlaceHolderActivity"
Expand Down Expand Up @@ -235,10 +235,8 @@
android:exported="true"
android:theme="@style/Theme.AppCompat.DayNight">
<intent-filter>

<!-- <action android:name="android.intent.action.VIEW"/> -->
<action android:name="test_action" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Expand Down Expand Up @@ -356,6 +354,7 @@
android:name=".aidl.PeopleRemoteService"
android:enabled="true"
android:exported="true"
android:permission="TODO"
android:process=":remote" />

<activity
Expand All @@ -377,6 +376,21 @@
android:name=".transition.CustomTransitionActivity"
android:exported="true"
android:theme="@style/Theme.AppCompat.DayNight" />

<activity
android:name=".transition.SceneTransitionBasicMainActivity"
android:exported="true"
android:theme="@style/Scene_Activity_AppTheme" />

<activity
android:name=".transition.SceneTransitionBasicDetailActivity"
android:exported="true"
android:theme="@style/Scene_Activity_AppTheme" />

<activity
android:name=".transition.GridToPagerMainActivity"
android:exported="true"
android:theme="@style/GridToPager_Activity_Theme" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*
* Copyright 2023-2025 wintmain
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.wintmain.wBasis.transition;

import android.os.Bundle;
import android.transition.TransitionInflater;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnLayoutChangeListener;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.app.SharedElementCallback;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;
import com.wintmain.wBasis.R;
import com.wintmain.wBasis.transition.adapter.GridAdapter;

import java.util.List;
import java.util.Map;

/**
* A fragment for displaying a grid of images.
*/
public class GridToPagerFragment extends Fragment {

private RecyclerView recyclerView;

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
recyclerView = (RecyclerView) inflater.inflate(R.layout.fragment_grid_to_pager, container,
false);
recyclerView.setAdapter(new GridAdapter(this));

prepareTransitions();
postponeEnterTransition();

return recyclerView;
}

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
scrollToPosition();
}

/**
* Scrolls the recycler view to show the last viewed item in the grid. This is important when
* navigating back from the grid.
*/
private void scrollToPosition() {
recyclerView.addOnLayoutChangeListener(new OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v,
int left,
int top,
int right,
int bottom,
int oldLeft,
int oldTop,
int oldRight,
int oldBottom) {
recyclerView.removeOnLayoutChangeListener(this);
final RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
View viewAtPosition = layoutManager.findViewByPosition(
GridToPagerMainActivity.currentPosition);
// Scroll to position if the view for the current position is null (not currently
// part of
// layout manager children), or it's not completely visible.
if (viewAtPosition == null || layoutManager
.isViewPartiallyVisible(viewAtPosition, false, true)) {
recyclerView.post(() -> layoutManager.scrollToPosition(
GridToPagerMainActivity.currentPosition));
}
}
});
}

/**
* Prepares the shared element transition to the pager fragment, as well as the other
* transitions
* that affect the flow.
*/
private void prepareTransitions() {
setExitTransition(TransitionInflater.from(getContext())
.inflateTransition(R.transition.grid_exit_transition));

// A similar mapping is set at the ImagePagerFragment with a setEnterSharedElementCallback.
setExitSharedElementCallback(
new SharedElementCallback() {
@Override
public void onMapSharedElements(List<String> names,
Map<String, View> sharedElements) {
// Locate the ViewHolder for the clicked position.
RecyclerView.ViewHolder selectedViewHolder = recyclerView
.findViewHolderForAdapterPosition(
GridToPagerMainActivity.currentPosition);
if (selectedViewHolder == null) {
return;
}

// Map the first shared element name to the child ImageView.
sharedElements
.put(names.get(0),
selectedViewHolder.itemView.findViewById(R.id.card_image));
}
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright 2023-2025 wintmain
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.wintmain.wBasis.transition;

import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import com.google.android.catalog.framework.annotations.Sample;
import com.wintmain.wBasis.R;

/**
* Grid to pager app's main activity.
*/
@Sample(name = "Grid to pager",
description = "viewpager & glide 照片展示",
tags = {"android-samples", "animation-samples"}
)
public class GridToPagerMainActivity extends AppCompatActivity {

private static final String KEY_CURRENT_POSITION =
"com.wintmain.wBasis.gridtopager.key.currentPosition";
/**
* Holds the current image position to be shared between the grid and the pager fragments. This
* position updated when a grid item is clicked, or when paging the pager.
*
* In this demo app, the position always points to an image index at the {@link
* com.wintmain.wBasis.transition.util.ImageData} class.
*/
public static int currentPosition;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_grid_to_pager_main);
if (savedInstanceState != null) {
currentPosition = savedInstanceState.getInt(KEY_CURRENT_POSITION, 0);
// Return here to prevent adding additional GridFragments when changing orientation.
return;
}
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager
.beginTransaction()
.add(R.id.fragment_container, new GridToPagerFragment(),
GridToPagerFragment.class.getSimpleName())
.commit();
}

@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt(KEY_CURRENT_POSITION, currentPosition);
}

}
Loading
Loading