-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
弃用datachannel,使用Container(UUID + HashMap)作为传值中间件
- Loading branch information
Showing
21 changed files
with
874 additions
and
126 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
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,67 @@ | ||
package ceui.lisa.activities; | ||
|
||
import android.os.Bundle; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.fragment.app.Fragment; | ||
import androidx.fragment.app.FragmentStatePagerAdapter; | ||
|
||
|
||
import ceui.lisa.R; | ||
import ceui.lisa.core.PageData; | ||
import ceui.lisa.databinding.ActivityViewPagerBinding; | ||
import ceui.lisa.fragments.FragmentIllust; | ||
import ceui.lisa.core.Container; | ||
import ceui.lisa.fragments.FragmentSingleIllust2; | ||
import ceui.lisa.utils.Params; | ||
|
||
public class VActivity extends BaseActivity<ActivityViewPagerBinding> { | ||
|
||
private String pageUUID = ""; | ||
private int index = 0; | ||
|
||
@Override | ||
protected void initBundle(Bundle bundle) { | ||
pageUUID = bundle.getString(Params.PAGE_UUID); | ||
index = bundle.getInt(Params.POSITION); | ||
} | ||
|
||
@Override | ||
protected int initLayout() { | ||
return R.layout.activity_view_pager; | ||
} | ||
|
||
@Override | ||
protected void initView() { | ||
PageData pageData = Container.get().getPage(pageUUID); | ||
if (pageData != null) { | ||
final int pageSize = pageData.getIllustList() == null ? 0 : pageData.getIllustList().size(); | ||
baseBind.viewPager.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager(), 0) { | ||
@NonNull | ||
@Override | ||
public Fragment getItem(int position) { | ||
// return FragmentIllust.newInstance(pageData.getIllustList().get(position)); | ||
return FragmentSingleIllust2.newInstance(pageData.getIllustList().get(position)); | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
return pageSize; | ||
} | ||
}); | ||
if (index < pageSize) { | ||
baseBind.viewPager.setCurrentItem(index); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
protected void initData() { | ||
|
||
} | ||
|
||
@Override | ||
public boolean hideStatusBar() { | ||
return true; | ||
} | ||
} |
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
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,63 @@ | ||
package ceui.lisa.core; | ||
|
||
import android.text.TextUtils; | ||
|
||
import java.util.HashMap; | ||
|
||
import ceui.lisa.utils.Common; | ||
|
||
public class Container { | ||
|
||
private HashMap<String, PageData> pages = new HashMap<>(); | ||
|
||
public void addPage(PageData pageData) { | ||
if (pageData == null) { | ||
return; | ||
} | ||
|
||
if (TextUtils.isEmpty(pageData.getUuid())) { | ||
return; | ||
} | ||
|
||
if (pages == null) { | ||
pages = new HashMap<>(); | ||
} | ||
|
||
pages.put(pageData.getUuid(), pageData); | ||
Common.showLog("Container addPage " + pageData.getUuid()); | ||
} | ||
|
||
public PageData getPage(String uuid) { | ||
Common.showLog("Container getPage " + uuid); | ||
if (TextUtils.isEmpty(uuid)) { | ||
return null; | ||
} | ||
|
||
if (pages == null || pages.size() == 0) { | ||
return null; | ||
} | ||
|
||
return pages.get(uuid); | ||
} | ||
|
||
public void clear() { | ||
Common.showLog("Container clear "); | ||
if (pages == null) { | ||
pages = new HashMap<>(); | ||
return; | ||
} | ||
if (pages.size() != 0) { | ||
pages.clear(); | ||
} | ||
} | ||
|
||
private Container(){} | ||
|
||
private static class SingleTonHolder{ | ||
private static Container INSTANCE = new Container(); | ||
} | ||
|
||
public static Container get(){ | ||
return SingleTonHolder.INSTANCE; | ||
} | ||
} |
Oops, something went wrong.