Skip to content

Commit

Permalink
add example activity for combine view
Browse files Browse the repository at this point in the history
  • Loading branch information
eriffanani committed Jun 21, 2022
1 parent 7dea576 commit c630ce1
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
android:supportsRtl="true"
android:theme="@style/Theme.ContentLoader"
tools:targetApi="31">
<activity
android:name=".example.ActivityCombine"
android:exported="false" />
<activity
android:name=".example.ActivityFrame"
android:exported="false" />
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/erif/contentloader/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import androidx.appcompat.app.AppCompatActivity;

import com.erif.contentloader.example.ActivityCombine;
import com.erif.contentloader.example.ActivityFrame;
import com.erif.contentloader.example.ActivityGrid;
import com.erif.contentloader.example.ActivityHorizontal;
Expand All @@ -25,6 +26,7 @@ protected void onCreate(Bundle savedInstanceState) {
onClick(R.id.btnHorizontal, ActivityHorizontal.class);
onClick(R.id.btnGrid, ActivityGrid.class);
onClick(R.id.btnNonList, ActivityFrame.class);
onClick(R.id.btnCombine, ActivityCombine.class);

}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package com.erif.contentloader.example;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.view.MenuItem;
import android.widget.RelativeLayout;
import android.widget.Toast;

import com.erif.contentloader.ContentLoaderFrameLayout;
import com.erif.contentloader.R;
import com.erif.contentloader.helper.DataAdapterVertical;
import com.erif.contentloader.helper.DelayTimer;

import java.util.ArrayList;
import java.util.List;

public class ActivityCombine extends AppCompatActivity {

private final DataAdapterVertical adapter = new DataAdapterVertical();
private final List<Integer> list = new ArrayList<>();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_combine);
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle("Combine Loader");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
Toast.makeText(this, "Loading simulation...", Toast.LENGTH_SHORT).show();

ContentLoaderFrameLayout loader = findViewById(R.id.act_combine_loader);
RelativeLayout image = findViewById(R.id.act_combine_layoutImage);
loader.startAndHideContent(image, true);

RecyclerView recyclerView = findViewById(R.id.act_combine_recyclerView);
setupList(recyclerView);

ContentLoaderFrameLayout loaderVertical = findViewById(R.id.content_combine_vertical);
loaderVertical.startAndHideContent(recyclerView, true);

new DelayTimer(2, () -> {
loader.stopAndShowContent(image, true);
}).start();

new DelayTimer(3, () -> {
adapter.setList(list);
loaderVertical.stopAndShowContent(recyclerView, true);
}).start();

}

private void setupList(RecyclerView recyclerView) {
recyclerView.setAdapter(adapter);
LinearLayoutManager manager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(manager);
for (int i=0; i<20; i++) {
list.add(i);
}
}

@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (item.getItemId() == android.R.id.home) {
finish();
return true;
}
return super.onOptionsItemSelected(item);
}

}
103 changes: 103 additions & 0 deletions app/src/main/res/layout/activity_combine.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.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=".example.ActivityCombine">

<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<com.erif.contentloader.ContentLoaderFrameLayout
android:id="@+id/act_combine_loader"
style="@style/ContentLoader.Match.AutoStart"
android:layout_height="150dp">

<com.erif.contentloader.ContentLoaderViewBanner
android:layout_width="match_parent"
android:layout_height="match_parent"
app:bannerPeep="leftAndRight"
android:padding="12dp"
app:peepPaddingVertical="18dp"/>

</com.erif.contentloader.ContentLoaderFrameLayout>

<RelativeLayout
android:id="@+id/act_combine_layoutImage"
android:layout_width="match_parent"
android:layout_height="150dp"
android:visibility="gone">

<ImageView
android:id="@+id/act_frame_imgLeft"
android:layout_width="15dp"
android:layout_height="match_parent"
android:src="@drawable/ic_launcher_background"
android:scaleType="fitXY"
android:layout_marginTop="18dp"
android:layout_marginBottom="18dp"
tools:ignore="ContentDescription" />

<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@mipmap/ic_launcher"
android:scaleType="centerCrop"
android:layout_margin="12dp"
android:layout_toEndOf="@id/act_frame_imgLeft"
android:layout_toStartOf="@id/act_frame_imgRight"
tools:ignore="ContentDescription" />

<ImageView
android:id="@+id/act_frame_imgRight"
android:layout_width="15dp"
android:layout_height="match_parent"
android:src="@drawable/ic_launcher_background"
android:layout_alignParentEnd="true"
android:scaleType="fitXY"
android:layout_marginTop="18dp"
android:layout_marginBottom="18dp"
tools:ignore="ContentDescription" />

</RelativeLayout>

</RelativeLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<com.erif.contentloader.ContentLoaderFrameLayout
android:id="@+id/content_combine_vertical"
style="@style/ContentLoader.AutoStart">

<include layout="@layout/content_loader_vertical"/>

</com.erif.contentloader.ContentLoaderFrameLayout>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/act_combine_recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:itemCount="10"
tools:listitem="@layout/item_data_vertical"/>

</RelativeLayout>

</LinearLayout>

</androidx.core.widget.NestedScrollView>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
6 changes: 6 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,10 @@
android:layout_height="wrap_content"
android:text="Non List"/>

<Button
android:id="@+id/btnCombine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Combine"/>

</LinearLayout>

0 comments on commit c630ce1

Please sign in to comment.