Java Code Examples for android.support.v4.app.FragmentActivity

The following are top voted examples for showing how to use android.support.v4.app.FragmentActivity. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Orin   File: SongsMenuHelper.java   View source code 6 votes vote down vote up
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;
}
 
Example 2
Project: eggs-android   File: DaggerAndroidInjector.java   View source code 6 votes vote down vote up
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);
    }
}
 
Example 3
Project: GitHub   File: ViewGroupMvpDelegateImplTest.java   View source code 6 votes vote down vote up
@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);
}
 
Example 4
Project: aos-Video   File: ArchosMiniPlayer.java   View source code 6 votes vote down vote up
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);
}
 
Example 5
Project: MDWechat   File: SlidingTabLayout.java   View source code 6 votes vote down vote up
/**
     * 关联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();
    }
 
Example 6
Project: GitHub   File: SlidingTabLayout.java   View source code 6 votes vote down vote up
/** 关联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();
}
 
Example 7
Project: GmArchMvvm   File: ActivityLifecycle.java   View source code 6 votes vote down vote up
/**
 * 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);
        }
    }
}
 
Example 8
Project: mvvm-template   File: TestAppInjector.java   View source code 6 votes vote down vote up
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);
    }
}
 
Example 9
Project: Programmers   File: Presenter.java   View source code 6 votes vote down vote up
@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();
}
 
Example 10
Project: letv   File: HalfPlaySharePopwindow.java   View source code 6 votes vote down vote up
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);
    }
}
 
Example 11
Project: pvdisplay   File: DailyFragment.java   View source code 6 votes vote down vote up
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;
    }
}
 
Example 12
Project: social-app-android   File: GoogleApiHelper.java   View source code 6 votes vote down vote up
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();
}
 
Example 13
Project: chat-sdk-android-push-firebase   File: ChatSDKIntentClickListener.java   View source code 6 votes vote down vote up
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);
        }
    };
}
 
Example 14
Project: recyclerview-android   File: ActionModeCompat.java   View source code 6 votes vote down vote up
@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.");
    }
}
 
Example 15
Project: XinFramework   File: SwipeBackLayout.java   View source code 6 votes vote down vote up
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);
}
 
Example 16
Project: AppChooser   File: ViewAction.java   View source code 6 votes vote down vote up
public void load() {
    FragmentActivity activity = mAppChooser.getActivity();
    if (activity == null) {
        return;
    }
    Fragment fragment = mAppChooser.getFragment();
    if (fragment != null) {
        mActionConfig.fromActivity = false;
        ViewFragment.newInstance(mActionConfig).show(fragment.getFragmentManager(),
                FRAGMENT_TAG);
    } else {
        mActionConfig.fromActivity = true;
        ViewFragment.newInstance(mActionConfig).show(activity.getSupportFragmentManager(),
                FRAGMENT_TAG);
    }
}
 
Example 17
Project: xlight_android_native   File: EZ.java   View source code 6 votes vote down vote up
/**
 * Return the callbacks for a fragment or throw an exception.
 * <p/>
 * Inspired by: https://gist.github.com/keyboardr/5455206
 */
@SuppressWarnings("unchecked")
public static <T> T getCallbacksOrThrow(Fragment frag, Class<T> callbacks) {
    Fragment parent = frag.getParentFragment();

    if (parent != null && callbacks.isInstance(parent)) {
        return (T) parent;

    } else {
        FragmentActivity activity = frag.getActivity();
        if (activity != null && callbacks.isInstance(activity)) {
            return (T) activity;
        }
    }

    // We haven't actually failed a class cast thanks to the checks above, but that's the
    // idiomatic approach for this pattern with fragments.
    throw new ClassCastException("This fragment's activity or parent fragment must implement "
            + callbacks.getCanonicalName());
}
 
Example 18
Project: MoligyMvpArms   File: ActivityLifecycle.java   View source code 6 votes vote down vote up
/**
 * 给每个 Activity 的所有 Fragment 设置监听其生命周期, Activity 可以通过 {@link IActivity#useFragment()}
 * 设置是否使用监听,如果这个 Activity 返回 false 的话,这个 Activity 下面的所有 Fragment 将不能使用 {@link FragmentDelegate}
 * 意味着 {@link BaseFragment} 也不能使用
 *
 * @param activity
 */
private void registerFragmentCallbacks(Activity activity) {
    boolean useFragment = activity instanceof IActivity ? ((IActivity) activity).useFragment() : true;
    if (activity instanceof FragmentActivity && useFragment) {

        if (mFragmentLifecycle == null) {
            mFragmentLifecycle = new FragmentLifecycle();
        }

        ((FragmentActivity) activity).getSupportFragmentManager().registerFragmentLifecycleCallbacks(mFragmentLifecycle, true);

        if (mFragmentLifecycles == null && mExtras.containsKey(ConfigModule.class.getName())) {
            mFragmentLifecycles = new ArrayList<>();
            List<ConfigModule> modules = (List<ConfigModule>) mExtras.get(ConfigModule.class.getName());
            for (ConfigModule module : modules) {
                module.injectFragmentLifecycle(mApplication, mFragmentLifecycles);
            }
            mExtras.remove(ConfigModule.class.getName());
        }

        for (FragmentManager.FragmentLifecycleCallbacks fragmentLifecycle : mFragmentLifecycles) {
            ((FragmentActivity) activity).getSupportFragmentManager().registerFragmentLifecycleCallbacks(fragmentLifecycle, true);
        }
    }
}
 
Example 19
Project: HeroVideo-master   File: RxLazyFragment.java   View source code 5 votes vote down vote up
@Override
public void onAttach(Activity activity)
{

    super.onAttach(activity);
    this.activity = (FragmentActivity) activity;
}
 
Example 20
Project: android-architecture-components   File: EspressoTestUtil.java   View source code 5 votes vote down vote up
/**
 * Disables progress bar animations for the views of the given activity rule
 *
 * @param activityTestRule The activity rule whose views will be checked
 */
public static void disableProgressBarAnimations(
        ActivityTestRule<? extends FragmentActivity> activityTestRule) {
    activityTestRule.getActivity().getSupportFragmentManager()
            .registerFragmentLifecycleCallbacks(
            new FragmentManager.FragmentLifecycleCallbacks() {
                @Override
                public void onFragmentViewCreated(FragmentManager fm, Fragment f, View v,
                        Bundle savedInstanceState) {
                    // traverse all views, if any is a progress bar, replace its animation
                    traverseViews(v);
                }
            }, true);
}
 
Example 21
Project: orgzly-android   File: ReposFragment.java   View source code 5 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG, savedInstanceState);
    super.onActivityCreated(savedInstanceState);

    /* Delay to avoid brief displaying of no-repos view. */
    new android.os.Handler().postDelayed(() -> {
        FragmentActivity activity = getActivity();
        if (activity != null) {
            activity.getSupportLoaderManager()
                    .initLoader(Loaders.REPOS_FRAGMENT, null, ReposFragment.this);
        }

    }, 100);
}
 
Example 22
Project: GitHub   File: RequestManagerRetriever.java   View source code 5 votes vote down vote up
public RequestManager get(FragmentActivity activity) {
  if (Util.isOnBackgroundThread()) {
    return get(activity.getApplicationContext());
  } else {
    assertNotDestroyed(activity);
    FragmentManager fm = activity.getSupportFragmentManager();
    return supportFragmentGet(activity, fm, null /*parentHint*/);
  }
}
 
Example 23
Project: GitHub   File: RequestManagerRetrieverTest.java   View source code 5 votes vote down vote up
@Test
public void testSupportCanGetRequestManagerFromFragment() {
  FragmentActivity activity =
      Robolectric.buildActivity(FragmentActivity.class).create().start().resume().get();
  Fragment fragment = new Fragment();
  activity.getSupportFragmentManager().beginTransaction().add(fragment, PARENT_TAG).commit();
  activity.getSupportFragmentManager().executePendingTransactions();

  RequestManager manager = retriever.get(fragment);
  assertEquals(manager, retriever.get(fragment));
}
 
Example 24
Project: RNLearn_Project1   File: ReactActivityDelegate.java   View source code 5 votes vote down vote up
public ReactActivityDelegate(
  FragmentActivity fragmentActivity,
  @Nullable String mainComponentName) {
  mFragmentActivity = fragmentActivity;
  mMainComponentName = mainComponentName;
  mActivity = null;
}
 
Example 25
Project: Stalker   File: PlaceFragment.java   View source code 5 votes vote down vote up
@Override
public void onDestroyView() {
    super.onDestroyView();
    placeApiClient.stopAutoManage((FragmentActivity) getActivity());
    placeApiClient.disconnect();

}
 
Example 26
Project: Watermark   File: BaseFragment.java   View source code 5 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    printFragmentLife("onViewCreated");

    Bundle argsBundle = getArguments();

    if (savedInstanceState != null) {
        mConfiguration = savedInstanceState.getParcelable(EXTRA_CONFIGURATION);
    }
    if (mConfiguration == null && argsBundle != null) {
        mConfiguration = argsBundle.getParcelable(EXTRA_CONFIGURATION);
    }

    if (mConfiguration != null) {
        if (argsBundle == null) {
            argsBundle = savedInstanceState;
        }
        onViewCreatedOk(view, argsBundle);
        setTheme();
    } else {
        FragmentActivity activity = getActivity();
        if (activity != null && !activity.isFinishing()) {
            activity.finish();
        }
    }
}
 
Example 27
Project: OSchina_resources_android   File: BaseFragment.java   View source code 5 votes vote down vote up
protected ProgressDialog showWaitDialog(int resid) {
    FragmentActivity activity = getActivity();
    if (activity instanceof DialogControl) {
        return ((DialogControl) activity).showWaitDialog(resid);
    }
    return null;
}
 
Example 28
Project: android-architecture-components   File: EspressoTestUtil.java   View source code 5 votes vote down vote up
/**
 * Disables progress bar animations for the views of the given activity rule
 *
 * @param activityTestRule The activity rule whose views will be checked
 */
public static void disableAnimations(
        ActivityTestRule<? extends FragmentActivity> activityTestRule) {
    activityTestRule.getActivity().getSupportFragmentManager()
            .registerFragmentLifecycleCallbacks(
                    new FragmentManager.FragmentLifecycleCallbacks() {
                        @Override
                        public void onFragmentViewCreated(FragmentManager fm, Fragment f, View v,
                                Bundle savedInstanceState) {
                            // traverse all views, if any is a progress bar, replace its animation
                            traverseViews(v);
                        }
                    }, true);
}
 
Example 29
Project: LQRWeChat-master   File: RedPacketUtil.java   View source code 5 votes vote down vote up
/**
 * 拆红包方法
 *
 * @param activity      FragmentActivity(由于使用了DialogFragment,这个参数类型必须为FragmentActivity)
 * @param chatType      聊天类型
 * @param redPacketId   红包id
 * @param redPacketType 红包类型
 * @param receiverId    接收者id
 * @param messageDirect 消息的方向
 */
public static void openRedPacket(final FragmentActivity activity, final int chatType, String redPacketId, String redPacketType, String receiverId, String messageDirect) {
    final ProgressDialog progressDialog = new ProgressDialog(activity);
    progressDialog.setCanceledOnTouchOutside(false);
    RedPacketInfo redPacketInfo = new RedPacketInfo();
    redPacketInfo.redPacketId = redPacketId;
    redPacketInfo.messageDirect = messageDirect;
    redPacketInfo.chatType = chatType;
    RPRedPacketUtil.getInstance().openRedPacket(redPacketInfo, activity, new RPRedPacketUtil.RPOpenPacketCallback() {
        @Override
        public void onSuccess(String senderId, String senderNickname, String myAmount) {
            //领取红包成功 发送回执消息到聊天窗口
            Toast.makeText(activity, "拆红包成功,红包金额" + myAmount + "元", Toast.LENGTH_LONG).show();
        }

        @Override
        public void showLoading() {
            progressDialog.show();
        }

        @Override
        public void hideLoading() {
            progressDialog.dismiss();
        }

        @Override
        public void onError(String code, String message) {
            Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
        }
    });
}
 
Example 30
Project: SecretTalk   File: BluetoothChatFragment.java   View source code 5 votes vote down vote up
/**
 * Updates the status on the action bar.
 *
 * @param resId a string resource ID
 */
private void setStatus(int resId) {
    FragmentActivity activity = getActivity();
    if (null == activity) {
        return;
    }
    final ActionBar actionBar = activity.getActionBar();
    if (null == actionBar) {
        return;
    }
    actionBar.setSubtitle(resId);
}
 
Example 31
Project: firebase-ui-quickstart-android   File: Utility.java   View source code 5 votes vote down vote up
public static void signOut(FragmentActivity fragmentActivity, final SignOutDelegate delegate) {
    AuthUI.getInstance()
          .signOut(fragmentActivity)
          .addOnCompleteListener(new OnCompleteListener<Void>() {
              public void onComplete(@NonNull Task<Void> task) {
                  delegate.onSignOut();
              }
          });
}
 
Example 32
Project: dab-iot   File: BluetoothChatFragment.java   View source code 5 votes vote down vote up
/**
 * Updates the status on the action bar.
 *
 * @param subTitle status
 */
private void setStatus(CharSequence subTitle) {
    FragmentActivity activity = getActivity();
    if (null == activity) {
        return;
    }
    final ActionBar actionBar = activity.getActionBar();
    if (null == actionBar) {
        return;
    }
    actionBar.setSubtitle(subTitle);
}
 
Example 33
Project: Goalie_Android   File: FriendsListRecycler.java   View source code 5 votes vote down vote up
public FriendsListRecycler(FragmentActivity context) {
    this.mContext = context;

    // remove self and display all others
    TreeMap<String, User> tempHashMap = new TreeMap<>(UserHelper.getInstance().getAllContacts());
    tempHashMap.remove(UserHelper.getInstance().getOwnerProfile().username);
    mUserList = new ArrayList<>(tempHashMap.values());
}
 
Example 34
Project: Goalie_Android   File: FeedsRecycler.java   View source code 5 votes vote down vote up
public FeedsRecycler(FragmentActivity context) {
    this.mContext = context;
    this.mGoalFeedList = GoalHelper.getInstance().getFeeds();
    this.mProgressDialog = new DelayedProgressDialog();

    if (mHasVoted == null)
        mHasVoted = new HashSet<>();
    if (mCachedImages == null)
        mCachedImages = new HashMap<>();
}
 
Example 35
Project: instamaterial   File: ActivityServiceLocator.java   View source code 5 votes vote down vote up
@Override public MainPresenter mainPresenter(FragmentActivity activity) {
  if (mainPresenter == null) {
    mainPresenter =
        new MainPresenter(getLoggedUser(), getFeedItem(), getFeedItems(), likePhoto());
  }
  return mainPresenter;
}
 
Example 36
Project: SaveImage2SystemAlbum   File: SaveImageDialogFragment.java   View source code 5 votes vote down vote up
public static void show(FragmentActivity context, String imageUrl) {
    SaveImageDialogFragment fragment = new SaveImageDialogFragment();
    fragment.context = context;
    Bundle bundle = new Bundle();
    bundle.putString("data", imageUrl);
    fragment.setArguments(bundle);
    fragment.show(fragment.context.getSupportFragmentManager(), "dialog");
}
 
Example 37
Project: GitHub   File: FragmentMvpViewStateDelegateImplTest.java   View source code 5 votes vote down vote up
@Before public void initComponents() {
  view = new MvpView() {
  };

  viewState = Mockito.mock(ViewState.class);

  presenter = Mockito.mock(MvpPresenter.class);
  callback = Mockito.spy(PartialMvpViewStateDelegateCallbackImpl.class);
  Mockito.doCallRealMethod().when(callback).setPresenter(presenter);
  Mockito.doCallRealMethod().when(callback).getPresenter();
  Mockito.doCallRealMethod().when(callback).setViewState(viewState);
  Mockito.doCallRealMethod().when(callback).getViewState();

  fragment = PowerMockito.mock(Fragment.class);
  activity = Mockito.mock(FragmentActivity.class);
  application = Mockito.mock(Application.class);

  Mockito.when(callback.getMvpView()).thenReturn(view);
  Mockito.when(fragment.getActivity()).thenReturn(activity);

  Mockito.when(activity.getApplication()).thenReturn(application);

  Mockito.when(callback.createPresenter()).thenReturn(presenter);
  Mockito.when(callback.createViewState()).thenReturn(viewState);

  delegate = new FragmentMvpViewStateDelegateImpl<>(fragment, callback, true, true);
}
 
Example 38
Project: SecretTalk   File: BluetoothChatFragment.java   View source code 5 votes vote down vote up
/**
 * Updates the status on the action bar.
 *
 * @param subTitle status
 */
private void setStatus(CharSequence subTitle) {
    FragmentActivity activity = getActivity();
    if (null == activity) {
        return;
    }
    final ActionBar actionBar = activity.getActionBar();
    if (null == actionBar) {
        return;
    }
    actionBar.setSubtitle(subTitle);
}
 
Example 39
Project: Perfect-Day   File: Utils.java   View source code 5 votes vote down vote up
public static void editItem(FragmentActivity activity, int id, String inputText, int color) {
    Uri uri = TaskItemsContract.TaskItemsColumns.CONTENT_URI;
    ContentValues contentValues = new ContentValues();
    contentValues.put(TaskItemsContract.TaskItemsColumns.COLUMN_NAME_COLOR, color);
    contentValues.put(TaskItemsContract.TaskItemsColumns.COLUMN_NAME_DESCRIPTION, inputText);
    uri = uri.buildUpon().appendPath(String.valueOf(id)).build();
    activity.getContentResolver().update(uri, contentValues, null, null);
}
 
Example 40
Project: mapbox-navigation-android   File: NavigationView.java   View source code 5 votes vote down vote up
private void initViewModels() {
  try {
    locationViewModel = ViewModelProviders.of((FragmentActivity) getContext()).get(LocationViewModel.class);
    routeViewModel = ViewModelProviders.of((FragmentActivity) getContext()).get(RouteViewModel.class);
    navigationViewModel = ViewModelProviders.of((FragmentActivity) getContext()).get(NavigationViewModel.class);
  } catch (ClassCastException exception) {
    throw new ClassCastException("Please ensure that the provided Context is a valid FragmentActivity");
  }
}