本文整理汇总了Java中android.support.v4.app.FragmentActivity类的典型用法代码示例。如果您正苦于以下问题:Java FragmentActivity类的具体用法?Java FragmentActivity怎么用?Java FragmentActivity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FragmentActivity类属于android.support.v4.app包,在下文中一共展示了FragmentActivity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleMenuClick
import android.support.v4.app.FragmentActivity; //导入依赖的package包/类
public static boolean handleMenuClick(@NonNull FragmentActivity activity, @NonNull ArrayList<Song> songs, int menuItemId) {
switch (menuItemId) {
case R.id.action_play_next:
MusicPlayerRemote.playNext(songs);
return true;
case R.id.action_add_to_current_playing:
MusicPlayerRemote.enqueue(songs);
return true;
case R.id.action_add_to_playlist:
AddToPlaylistDialog.create(songs).show(activity.getSupportFragmentManager(), "ADD_PLAYLIST");
return true;
case R.id.action_delete_from_device:
DeleteSongsDialog.create(songs).show(activity.getSupportFragmentManager(), "DELETE_SONGS");
return true;
}
return false;
}
示例2: handleActivity
import android.support.v4.app.FragmentActivity; //导入依赖的package包/类
private static void handleActivity(Activity activity) {
if (activity instanceof DaggerInjectable) {
AndroidInjection.inject(activity);
}
if (activity instanceof FragmentActivity) {
((FragmentActivity) activity).getSupportFragmentManager()
.registerFragmentLifecycleCallbacks(
new FragmentManager.FragmentLifecycleCallbacks() {
@Override
public void onFragmentCreated(FragmentManager fm, Fragment f,
Bundle savedInstanceState) {
if (f instanceof DaggerInjectable) {
AndroidSupportInjection.inject(f);
}
}
}, true);
}
}
示例3: initComponents
import android.support.v4.app.FragmentActivity; //导入依赖的package包/类
@Before public void initComponents() {
view = new MvpView() {
};
presenter = Mockito.mock(MvpPresenter.class);
callback = Mockito.mock(PartialViewGroupMvpDelegateCallbackImpl.class);
Mockito.doCallRealMethod().when(callback).setPresenter(presenter);
Mockito.doCallRealMethod().when(callback).getPresenter();
activity = Mockito.mock(FragmentActivity.class);
application = Mockito.mock(Application.class);
androidView = Mockito.mock(View.class);
Mockito.when(callback.getMvpView()).thenReturn(view);
Mockito.when(callback.getContext()).thenReturn(activity);
Mockito.when(activity.getApplication()).thenReturn(application);
Mockito.when(androidView.isInEditMode()).thenReturn(false);
delegate = new ViewGroupMvpDelegateImpl<>(androidView, callback, true);
}
示例4: showTracksChooserDialog
import android.support.v4.app.FragmentActivity; //导入依赖的package包/类
private void showTracksChooserDialog()
throws TransientNetworkDisconnectionException, NoConnectionException {
if(!(getContext() instanceof FragmentActivity))
throw new IllegalStateException("Activity needs to be FragmentActivity");
FragmentTransaction transaction = ((FragmentActivity)getContext()).getSupportFragmentManager().beginTransaction();
Fragment prev = ((FragmentActivity)getContext()).getSupportFragmentManager().findFragmentByTag(DIALOG_TAG);
if (prev != null) {
transaction.remove(prev);
}
transaction.addToBackStack(null);
// Create and show the dialog.
/* <--archos changes> */
ArchosTracksChooserDialog dialogFragment = ArchosTracksChooserDialog
.newInstance(ArchosVideoCastManager.getInstance().getMediaInfo());
/* <!--archos changes> */
dialogFragment.show(transaction, DIALOG_TAG);
}
示例5: setViewPager
import android.support.v4.app.FragmentActivity; //导入依赖的package包/类
/**
* 关联ViewPager,用于连适配器都不想自己实例化的情况
*/
public void setViewPager(ViewPager vp, String[] titles, FragmentActivity fa, ArrayList<Fragment> fragments) {
if (vp == null) {
throw new IllegalStateException("ViewPager can not be NULL !");
}
if (titles == null || titles.length == 0) {
throw new IllegalStateException("Titles can not be EMPTY !");
}
this.mViewPager = vp;
this.mViewPager.setAdapter(new InnerPagerAdapter(fa.getSupportFragmentManager(), fragments, titles));
// this.mViewPager.removeOnPageChangeListener(this);
this.mViewPager.setOnPageChangeListener(this);
notifyDataSetChanged();
}
示例6: setViewPager
import android.support.v4.app.FragmentActivity; //导入依赖的package包/类
/** 关联ViewPager,用于连适配器都不想自己实例化的情况 */
public void setViewPager(ViewPager vp, String[] titles, FragmentActivity fa, ArrayList<Fragment> fragments) {
if (vp == null) {
throw new IllegalStateException("ViewPager can not be NULL !");
}
if (titles == null || titles.length == 0) {
throw new IllegalStateException("Titles can not be EMPTY !");
}
this.mViewPager = vp;
this.mViewPager.setAdapter(new InnerPagerAdapter(fa.getSupportFragmentManager(), fragments, titles));
this.mViewPager.removeOnPageChangeListener(this);
this.mViewPager.addOnPageChangeListener(this);
notifyDataSetChanged();
}
示例7: registerFragmentCallbacks
import android.support.v4.app.FragmentActivity; //导入依赖的package包/类
/**
* To set the lifecycle of all Fragments settings for each Activity, the Activity can be accessed through {@link IActivity # useFragment ()}
* Set whether to use the monitor, if the Activity returns false, then the activities of all the following Fragment will not be able to use {@link FragmentDelegate}
*
* @param activity: Activity
*/
private void registerFragmentCallbacks(Activity activity) {
boolean useFragment = !(activity instanceof IActivity) || ((IActivity) activity).useFragment();
if (activity instanceof FragmentActivity && useFragment) {
if (mFragmentLifecycle == null) {
mFragmentLifecycle = new FragmentLifecycle();
}
((FragmentActivity) activity).getSupportFragmentManager().registerFragmentLifecycleCallbacks(mFragmentLifecycle, true);
if (mFragmentLifecycles == null && mExtras.containsKey(ConfigLifecycle.class.getName())) {
mFragmentLifecycles = new ArrayList<>();
List<ConfigLifecycle> lifecycles = (List<ConfigLifecycle>) mExtras.get(ConfigLifecycle.class.getName());
for (ConfigLifecycle lifecycle : lifecycles) {
lifecycle.injectFragmentLifecycle(mApplication, mFragmentLifecycles);
}
mExtras.remove(ConfigLifecycle.class.getName());
}
for (FragmentManager.FragmentLifecycleCallbacks fragmentLifecycle : mFragmentLifecycles) {
((FragmentActivity) activity).getSupportFragmentManager()
.registerFragmentLifecycleCallbacks(fragmentLifecycle, true);
}
}
}
示例8: handleActivity
import android.support.v4.app.FragmentActivity; //导入依赖的package包/类
private static void handleActivity(Activity activity) {
if (activity instanceof HasSupportFragmentInjector || activity instanceof Injectable) {
AndroidInjection.inject(activity);
}
if (activity instanceof FragmentActivity) {
((FragmentActivity) activity).getSupportFragmentManager()
.registerFragmentLifecycleCallbacks(
new FragmentManager.FragmentLifecycleCallbacks() {
@Override
public void onFragmentCreated(FragmentManager fm, Fragment f,
Bundle savedInstanceState) {
if (f instanceof Injectable) {
AndroidSupportInjection.inject(f);
}
}
}, true);
}
}
示例9: configGoogleSigin
import android.support.v4.app.FragmentActivity; //导入依赖的package包/类
@Override
public void configGoogleSigin() {
// Configure Google Sign In
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getContext().getString(R.string.default_google_web_client_id))
.requestEmail()
.build();
//GoogleApiClient -> GOOGLE
googleApiClient = new GoogleApiClient.Builder(getContext().getApplicationContext())
.enableAutoManage(((FragmentActivity) view), new GoogleApiClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
showLog("GOOGLE SIGN_IN ERROR: " + connectionResult);
// view.showToast(getContext().getString(R.string.something_was_wrong));
}
})
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
}
示例10: onShareTencent
import android.support.v4.app.FragmentActivity; //导入依赖的package包/类
public void onShareTencent() {
if (this.mShareFrom == 3) {
letvTencentShare.getInstance(this.mContext).gotoSharePage((FragmentActivity) this.mContext, this.playLiveController.getShareProgramName(), ShareUtils.getAnalysisLiveShareUrl(getShareMode(), this.mLiveType, this.mLiveId, 6, 0), this.mLiveImgUrl, getShareMode(), this.secondShareDesc, PageIdConstant.halpPlayPage, "s10");
StatisticsUtils.staticticsInfoPost(this.mContext, "4", "h223", "5005", 5, null, PageIdConstant.halpPlayPage, this.cid, this.pid, this.vid, NetworkUtils.DELIMITER_LINE, NetworkUtils.DELIMITER_LINE);
} else if (this.mShareFrom == 4) {
letvTencentShare.getInstance(this.mContext).gotoSharePage((FragmentActivity) this.mContext, this.album, this.mVideoShotShareInfoBean, this.album.order, this.album.Share_vid, 4, this.mVideoShotShareInfoBean.mRandText, PageIdConstant.pictureSharePage, "sh21");
StatisticsUtils.staticticsInfoPost(this.mContext, "4", "sh20", "5005", 5, null, PageIdConstant.pictureSharePage, this.cid, this.pid, this.vid, NetworkUtils.DELIMITER_LINE, NetworkUtils.DELIMITER_LINE);
} else if (this.mShareFrom == 5) {
letvTencentShare.getInstance(this.mContext).gotoSharePage((FragmentActivity) this.mContext, this.album, null, this.album.order, this.album.Share_vid, 5, getCommentDesc(4), PageIdConstant.halpPlayPage, "sh23");
StatisticsUtils.staticticsInfoPost(this.mContext, "4", "sh22", "5005", 5, null, PageIdConstant.halpPlayPage, this.cid, this.pid, this.vid, NetworkUtils.DELIMITER_LINE, NetworkUtils.DELIMITER_LINE);
} else if (this.mShareFrom == 1) {
letvTencentShare.getInstance(this.mContext).gotoSharePage((FragmentActivity) this.mContext, this.album, null, this.album.order, this.album.Share_vid, 1, this.secondShareDesc, PageIdConstant.halpPlayPage, "s10");
StatisticsUtils.staticticsInfoPost(this.mContext, "4", "h223", "5005", 5, null, PageIdConstant.halpPlayPage, this.cid, this.pid, this.vid, NetworkUtils.DELIMITER_LINE, NetworkUtils.DELIMITER_LINE);
} else if (this.mShareFrom == 11) {
LogInfo.log("fornia", "share-SHARE_FROM_RED_PACKET_SPRING shareQ");
letvTencentShare.getInstance(this.mContext).gotoSharePage((FragmentActivity) this.mContext, this.mActivityTitle, this.mActivityUrl, this.mPhotoUrl, this.mAwardUrl, 22, this.mGiftContent, PageIdConstant.halpPlayPage, "s10");
StatisticsUtils.staticticsInfoPost(this.mContext, "4", "h223", "5005", 5, null, PageIdConstant.halpPlayPage, this.cid, this.pid, this.vid, NetworkUtils.DELIMITER_LINE, NetworkUtils.DELIMITER_LINE);
} else {
letvTencentShare.getInstance(this.mContext).gotoSharePage((FragmentActivity) this.mContext, this.album, null, this.album.order, this.album.Share_vid, 1, this.secondShareDesc, PageIdConstant.halpPlayPage, "s10");
StatisticsUtils.staticticsInfoPost(this.mContext, "4", "h223", "5005", 5, null, PageIdConstant.halpPlayPage, this.cid, this.pid, this.vid, NetworkUtils.DELIMITER_LINE, NetworkUtils.DELIMITER_LINE);
}
}
示例11: getDrawable
import android.support.v4.app.FragmentActivity; //导入依赖的package包/类
private Drawable getDrawable(String condition) {
final FragmentActivity activity = getActivity();
if (activity != null) {
switch (condition) {
case "Cloudy":
return ContextCompat.getDrawable(activity, R.drawable.ic_cloudy);
case "Fine":
return ContextCompat.getDrawable(activity, R.drawable.ic_fine);
case "Mostly Cloudy":
return ContextCompat.getDrawable(activity, R.drawable.ic_mostly_cloudy);
case "Partly Cloudy":
return ContextCompat.getDrawable(activity, R.drawable.ic_partly_cloudy);
case "Showers":
return ContextCompat.getDrawable(activity, R.drawable.ic_showers);
case "Snow":
return ContextCompat.getDrawable(activity, R.drawable.ic_snow);
default:
return ContextCompat.getDrawable(activity, R.drawable.ic_help_black_48dp);
}
} else {
return null;
}
}
示例12: createGoogleApiClient
import android.support.v4.app.FragmentActivity; //导入依赖的package包/类
public static GoogleApiClient createGoogleApiClient(FragmentActivity fragmentActivity) {
GoogleApiClient.OnConnectionFailedListener failedListener;
if (fragmentActivity instanceof GoogleApiClient.OnConnectionFailedListener) {
failedListener = (GoogleApiClient.OnConnectionFailedListener) fragmentActivity;
} else {
throw new IllegalArgumentException(fragmentActivity.getClass().getSimpleName() + " should implement OnConnectionFailedListener");
}
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(fragmentActivity.getResources().getString(R.string.google_web_client_id))
.requestEmail()
.build();
return new GoogleApiClient.Builder(fragmentActivity)
.enableAutoManage(fragmentActivity, failedListener)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
}
示例13: getPickImageClickListener
import android.support.v4.app.FragmentActivity; //导入依赖的package包/类
public static View.OnClickListener getPickImageClickListener(final FragmentActivity activity,final Fragment fragment, final int requestCode){
return new View.OnClickListener() {
@Override
public void onClick(View v) {
pickIntent();
}
private void pickIntent(){
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
activity.startActivityFromFragment(fragment, Intent.createChooser(intent,
"Complete action using"), requestCode);
}
};
}
示例14: startActionMode
import android.support.v4.app.FragmentActivity; //导入依赖的package包/类
@Nullable
@Override
public ActionMode startActionMode(@NonNull final ActionMode.Callback callback) {
final FragmentActivity activity = mFragment.getActivity();
if (activity instanceof AppCompatActivity) {
final AppCompatActivity appCompatActivity = (AppCompatActivity) activity;
return appCompatActivity.startSupportActionMode(callback);
} else {
throw new IllegalStateException("Your activity should extend AppCompatActivity.");
}
}
示例15: attachToActivity
import android.support.v4.app.FragmentActivity; //导入依赖的package包/类
public void attachToActivity(FragmentActivity activity) {
mActivity = activity;
TypedArray a = activity.getTheme().obtainStyledAttributes(new int[]{
android.R.attr.windowBackground
});
int background = a.getResourceId(0, 0);
a.recycle();
ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView();
ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
decorChild.setBackgroundResource(background);
decor.removeView(decorChild);
addView(decorChild);
setContentView(decorChild);
decor.addView(this);
}