Skip to content

Commit

Permalink
1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
skhanbeiki committed Nov 7, 2020
1 parent 7098c1b commit 33df66a
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 42 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions SuperViewpager/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
versionCode 2
versionName "1.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,65 +1,68 @@
package ir.khanbeiki.superviewpager.sample;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;



import ir.khanbeiki.superviewpager.SuperViewPagerListener;

public class FrgDashboard extends Fragment implements SuperViewPagerListener {

private View rootView;
private Context context;
private Activity activity;

private ProgressBar prgCommandDo;
private ProgressBar prgAlwaysDo;
private TextView txtTitle;
private String name;
@Override
public void onFragmentCommandDo() {
runView();
total = 0;
updateProgressBar(prgCommandDo);
}

@Override
public void onFragmentAlwaysDo() {
alwaysRunView();
total = 0;
updateProgressBar(prgAlwaysDo);
}

@Override
public void onAttach(Context context) {
super.onAttach(context);
this.context = context;
this.activity = getActivity();
public FrgDashboard(String name) {
this.name = name;
}

@Override
public void onDetach() {
super.onDetach();
context = null;
activity = null;
}

private void alwaysRunView() {

}
private void runView() {

private int total;
private Handler handler;
private void updateProgressBar(final ProgressBar progressBar) {
if (total < 100) {
handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
progressBar.setProgress(total++);
updateProgressBar(progressBar);
}
}, 100);
}
}

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

prgCommandDo = view.findViewById(R.id.prgCommandDo);
prgAlwaysDo = view.findViewById(R.id.prgAlwaysDo);
txtTitle = view.findViewById(R.id.txtTitle);
txtTitle.setText(name);
}


public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.frg_dashboard, container, false);
}
}

}
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package ir.khanbeiki.superviewpager.sample;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;

import android.os.Bundle;

import ir.khanbeiki.superviewpager.TabAdapter;
import me.majiajie.pagerbottomtabstrip.NavigationController;
import me.majiajie.pagerbottomtabstrip.PageNavigationView;
import me.majiajie.pagerbottomtabstrip.item.BaseTabItem;

public class MainActivity extends AppCompatActivity {

private PageNavigationView pageNavigationView;
private PageNavigationView pageNavigationView;
private NavigationController navigationControllerOne;
private ViewPager viewPager;

Expand All @@ -25,10 +25,10 @@ protected void onCreate(Bundle savedInstanceState) {
viewPager = findViewById(R.id.viewPager);

TabAdapter adapter = new TabAdapter(getSupportFragmentManager(), 0);
adapter.addFragment(0, true, new FrgDashboard(), "0");
adapter.addFragment(1, true, new FrgDashboard(), "1");
adapter.addFragment(2, true, new FrgDashboard(), "2");
adapter.addFragment(3, true, new FrgDashboard(), "3");
adapter.addFragment(0, true, new FrgDashboard("Dashboard"), "0");
adapter.addFragment(1, false, new FrgDashboard("LessonMap"), "1");
adapter.addFragment(2, 1, new FrgDashboard("LeaderBoard"), "2");
adapter.addFragment(3, 5, new FrgDashboard("Analyze"), "3");

viewPager.setAdapter(adapter);
viewPager.setOffscreenPageLimit(4);
Expand All @@ -43,6 +43,7 @@ protected void onCreate(Bundle savedInstanceState) {
navigationControllerOne.setupWithViewPager(viewPager);
adapter.setViewPager(viewPager);
}

private BaseTabItem newItem(int drawable, int checkedDrawable, String title) {
OnlyIconItemView mainTab = new OnlyIconItemView(this);
mainTab.initialize(drawable, checkedDrawable);
Expand Down
40 changes: 37 additions & 3 deletions app/src/main/res/layout/frg_dashboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,46 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
android:paddingLeft="32dp"
android:paddingRight="32dp"
android:gravity="center"
android:orientation="vertical">

<TextView
android:id="@+id/txtTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="SuperViewPager"
android:textSize="30sp" />
android:layout_marginBottom="64dp"
android:textStyle="bold"
android:textSize="18sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|left"
android:text="onFragmentCommandDo"
android:textSize="18sp" />

<ProgressBar
android:id="@+id/prgCommandDo"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:gravity="center|left"
android:text="onFragmentAlwaysDo"
android:textSize="18sp" />

<ProgressBar
android:id="@+id/prgAlwaysDo"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100" />

</LinearLayout>

0 comments on commit 33df66a

Please sign in to comment.