-
Notifications
You must be signed in to change notification settings - Fork 27
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
Showing
16 changed files
with
354 additions
and
45 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.
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
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
39 changes: 39 additions & 0 deletions
39
example/src/main/java/com/dyhdyh/loadingbar/example/MutiFragmentActivity.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,39 @@ | ||
package com.dyhdyh.loadingbar.example; | ||
|
||
import android.os.Bundle; | ||
import android.support.annotation.Nullable; | ||
import android.support.v4.app.Fragment; | ||
import android.support.v4.app.FragmentActivity; | ||
import android.support.v4.app.FragmentTransaction; | ||
|
||
import com.dyhdyh.loadingbar.example.fragment.ContentFragment; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* author dengyuhan | ||
* created 2016/8/16 9:41 | ||
*/ | ||
public class MutiFragmentActivity extends FragmentActivity{ | ||
private String[] title= new String[]{"新闻", "图片", "视频"}; | ||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_muti); | ||
|
||
List<Fragment> fragments=new ArrayList<>(); | ||
for (int i = 0; i <title.length ; i++) { | ||
Fragment fragment=new ContentFragment(); | ||
Bundle bundle = new Bundle(); | ||
bundle.putString("title",title[i]); | ||
fragment.setArguments(bundle); | ||
fragments.add(fragment); | ||
} | ||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); | ||
transaction.replace(R.id.fragment1,fragments.get(0)); | ||
transaction.replace(R.id.fragment2,fragments.get(1)); | ||
transaction.replace(R.id.fragment3,fragments.get(2)); | ||
transaction.commit(); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
example/src/main/java/com/dyhdyh/loadingbar/example/fragment/ContentFragment.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,57 @@ | ||
package com.dyhdyh.loadingbar.example.fragment; | ||
|
||
import android.graphics.Color; | ||
import android.os.Bundle; | ||
import android.os.Handler; | ||
import android.support.annotation.Nullable; | ||
import android.support.v4.app.Fragment; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.TextView; | ||
|
||
import com.dyhdyh.loadingbar.example.R; | ||
import com.dyhdyh.widget.loadingbar.LoadingBar; | ||
|
||
import java.util.Random; | ||
|
||
/** | ||
* author dengyuhan | ||
* created 2016/8/16 9:44 | ||
*/ | ||
public class ContentFragment extends Fragment{ | ||
private Handler handler=new Handler(); | ||
@Nullable | ||
@Override | ||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | ||
String title=getArguments().getString("title"); | ||
View layout = inflater.inflate(R.layout.fragment_content, null); | ||
TextView tv= (TextView) layout.findViewById(R.id.tv); | ||
tv.setText(title); | ||
Random random=new Random(); | ||
layout.setBackgroundColor(Color.rgb(random.nextInt(255),random.nextInt(255),random.nextInt(255))); | ||
return layout; | ||
} | ||
|
||
@Override | ||
public void onActivityCreated(@Nullable Bundle savedInstanceState) { | ||
super.onActivityCreated(savedInstanceState); | ||
|
||
request(); | ||
} | ||
|
||
/** | ||
* 模拟请求 | ||
*/ | ||
public void request(){ | ||
final LoadingBar loadingBar = LoadingBar.show(getView()); | ||
Random random=new Random(); | ||
int nextInt = random.nextInt(3000); | ||
handler.postDelayed(new Runnable() { | ||
@Override | ||
public void run() { | ||
loadingBar.cancel(); | ||
} | ||
},nextInt); | ||
} | ||
} |
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
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,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<FrameLayout | ||
android:id="@+id/fragment1" | ||
android:layout_weight="1" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
</FrameLayout> | ||
<FrameLayout | ||
android:id="@+id/fragment2" | ||
android:layout_weight="1" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
</FrameLayout> | ||
<FrameLayout | ||
android:id="@+id/fragment3" | ||
android:layout_weight="1" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
</FrameLayout> | ||
|
||
</LinearLayout> |
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,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<TextView | ||
android:textColor="@android:color/white" | ||
android:id="@+id/tv" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_centerInParent="true" /> | ||
</RelativeLayout> |
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
Oops, something went wrong.