Java Code Examples for de.greenrobot.event.EventBus

The following examples show how to use de.greenrobot.event.EventBus. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Rumble   Source File: RumbleUnicastChannel.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void stopWorker() {
    if(!working)
        return;
    working = false;
    try {
        con.disconnect();
    } catch (LinkLayerConnectionException ignore) {
        //Log.d(TAG, "[-]"+ignore.getMessage());
    }
    finally {
        keepAlive.removeCallbacks(keepAliveFires);
        socketTimeout.removeCallbacks(socketTimeoutFires);
        if(EventBus.getDefault().isRegistered(this))
            EventBus.getDefault().unregister(this);
    }
}
 
Example 2
Source Project: nono-android   Source File: NoteController.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static long updateNoteLocal(final long sdfId, String groupName, final NoteDatabaseArray noteDatabaseArray, String oldUUid){
    noteDatabaseArray.uuid = oldUUid;
    final long newId;
    noteDatabaseArray.is_on_cloud = "false";
    newId = NoteDBHelper.getInstance().updateNote(sdfId,groupName,noteDatabaseArray);
    new Handler(Looper.getMainLooper()).post(new Runnable() {
        @Override
        public void run() {
            EventBus.getDefault().post(new NoteUpdateEvent(
                    newId,
                    noteDatabaseArray.content,
                    noteDatabaseArray,
                    sdfId,
                    noteDatabaseArray.uuid
            ));
        }
    });
    if(Looper.myLooper() == Looper.getMainLooper()){
        Toast.makeText(MyApp.getInstance().getApplicationContext(), "转储在本地喵~", Toast.LENGTH_SHORT).show();
    }
    return newId;
}
 
Example 3
Source Project: AndroidDatabaseLibraryComparison   Source File: OllieTester.java    License: MIT License 6 votes vote down vote up
public static void testAddressItems(Context context) {
	Delete.from(SimpleAddressItem.class).execute();

	final Collection<SimpleAddressItem> ollieModels =
			Generator.getAddresses(SimpleAddressItem.class, MainActivity.LOOP_COUNT);

	long startTime = System.currentTimeMillis();
	// Reuse method so we don't have to write
	TransactionManager.transact(Ollie.getDatabase(), new Runnable() {
		@Override
		public void run() {
			Saver.saveAll(ollieModels);
		}
	});
	EventBus.getDefault().post(new LogTestDataEvent(startTime, FRAMEWORK_NAME, MainActivity.SAVE_TIME));

	startTime = System.currentTimeMillis();
	Collection<SimpleAddressItem> activeAndroidModelLoad =
			Select.from(SimpleAddressItem.class).fetch();
	EventBus.getDefault().post(new LogTestDataEvent(startTime, FRAMEWORK_NAME, MainActivity.LOAD_TIME));

	Delete.from(SimpleAddressItem.class).execute();
}
 
Example 4
Source Project: sctalk   Source File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	logger.d("MainActivity#savedInstanceState:%s", savedInstanceState);
	//todo eric when crash, this will be called, why?
	if (savedInstanceState != null) {
		logger.w("MainActivity#crashed and restarted, just exit");
		jumpToLoginPage();
		finish();
	}

       // 在这个地方加可能会有问题吧
       EventBus.getDefault().register(this);
	imServiceConnector.connect(this);

	requestWindowFeature(Window.FEATURE_NO_TITLE);
	setContentView(R.layout.tt_activity_main);

	initTab();
	initFragment();
	setFragmentIndicator(0);
}
 
Example 5
/**
 * Get the event bus that's being used in the app.
 *
 * @return The event bus.
 * @throws AssumptionViolatedException If the default event bus can't be constructed because of
 * the Android framework not being loaded. This will stop the calling tests from being reported
 * as failures.
 */
@NonNull
private static EventBus getEventBus() {
    try {
        return EventBus.getDefault();
    } catch (RuntimeException e) {
        /* The event bus uses the Looper from the Android framework, so
         * initializing it would throw a runtime exception if the
         * framework is not loaded. Nor can RoboGuice be used to inject
         * a mocked instance to get around this issue, since customizing
         * RoboGuice injections requires a Context.
         *
         * Robolectric can't be used to solve this issue, because it
         * doesn't support parameterized testing. The only solution that
         * could work at the moment would be to make this an
         * instrumented test suite.
         *
         * TODO: Mock the event bus when RoboGuice is replaced with
         * another dependency injection framework, or when there is a
         * Robolectric test runner available that support parameterized
         * tests.
         */
        throw new AssumptionViolatedException(
                "Event bus requires Android framework", e, nullValue());
    }
}
 
Example 6
Source Project: Puff-Android   Source File: AuthorizeActivity.java    License: MIT License 6 votes vote down vote up
public void onEventMainThread(CryptoEvent event) {
    if (event.getField() == null ||!event.getField().equalsIgnoreCase("master")) {
        return;
    }
    if (event.getType() == AppConstants.TYPE_MASTER_OK) {
        dialog.dismiss();
        CryptoEvent result = new CryptoEvent(password, AppConstants.TYPE_MASTERPWD);
        EventBus.getDefault().post(result);
        this.setResult(RESULT_OK);
        finish();
    }
    if (event.getType() == AppConstants.TYPE_MASTER_NO) {
        mPasswordView.setError(getResources().getString(R.string.master_password_invalid));
        dialog.dismiss();
    }
    if (event.getType() == AppConstants.TYPE_SHTHPPN) {
        mPasswordView.setError(getResources().getString(R.string.master_password_invalid));
        dialog.dismiss();
    }


}
 
Example 7
Source Project: secrecy   Source File: FileImportActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    if (!EventBus.getDefault().isRegistered(this)) {
        EventBus.getDefault().register(this);
    }

    mToolbar = (Toolbar) findViewById(R.id.toolbar);

    setSupportActionBar(mToolbar);
    FileImportFragment fragment = new FileImportFragment();
    FragmentManager fragmentManager = getFragmentManager();
    fragmentManager.beginTransaction()
            .replace(R.id.drawer_layout, fragment, "mainactivitycontent")   //Replace the whole drawer layout
            .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
            .commit();
}
 
Example 8
Source Project: tinybus   Source File: TinyBusPerformanceTest.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
	super.setUp();
	
	mTinyBus = new TinyBus();
	mEventBus = EventBus.builder()
			.eventInheritance(false)
			.sendNoSubscriberEvent(false).build();
	mOttoBus = new com.squareup.otto.Bus(new com.squareup.otto.ThreadEnforcer() {
		public void enforce(com.squareup.otto.Bus bus) {}
	});
	
	mSubscriber1 = new Subsriber1();
	mSubscriber2 = new Subsriber2();
	mSubscriber3 = new Subsriber3();
}
 
Example 9
Source Project: AndroidDatabaseLibraryComparison   Source File: MainActivity.java    License: MIT License 6 votes vote down vote up
/**
 * runs simple benchmarks (onClick from R.id.simple)
 * @param v button view
 */
public void runSimpleTrial(View v) {
    setBusyUI(true, getResources().getString(R.string.simple));
    resetChart();
    runTestThread = new Thread(new Runnable() {
        @Override
        public void run() {
            runningTests = true;
            Context applicationContext = MainActivity.this.getApplicationContext();
            OrmLiteTester.testAddressItems(applicationContext);
            GreenDaoTester.testAddressItems(applicationContext);
            DBFlowTester.testAddressItems(applicationContext);
            OllieTester.testAddressItems(applicationContext);
            RealmTester.testAddressItems(applicationContext);
            //SprinklesTester.testAddressItems(applicationContext);
            //AATester.testAddressItems(applicationContext);
            //SugarTester.testAddressItems(applicationContext);
            EventBus.getDefault().post(new TrialCompletedEvent(getResources().getString(R.string.simple)));
        }
    });
    runTestThread.start();
}
 
Example 10
Source Project: Rumble   Source File: CacheManager.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void onEventAsync(UserDeleteStatus event) {
    if(event.status == null)
        return;
    if(DatabaseFactory.getPushStatusDatabase(RumbleApplication.getContext()).deleteStatus(event.status.getUuid())) {
        if(event.status.hasAttachedFile()) {
            // if filename starts with a '/' it means that the file is from another album
            // we do not delete the file in that case
            if(!event.status.getFileName().startsWith("/")) {
                try {
                    File attached = new File(FileUtil.getWritableAlbumStorageDir(), event.status.getFileName());
                    if (attached.exists() && attached.isFile()) {
                        attached.delete();
                    }
                } catch (IOException e) {
                }
            }
        }
        EventBus.getDefault().post(new StatusDeletedEvent(event.status.getUuid(), event.status.getdbId()));
    }
}
 
Example 11
Source Project: Rumble   Source File: WifiLinkLayerAdapter.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void linkStop() {
    if(!register)
        return;
    register = false;

    Log.d(TAG, "[-] Stopping Wifi");
    if(EventBus.getDefault().isRegistered(this))
        EventBus.getDefault().unregister(this);

    RumbleApplication.getContext().unregisterReceiver(mReceiver);
    linkDisconnected();

    wifiInf = null;
    wifiMan = null;
}
 
Example 12
Source Project: imsdk-android   Source File: PersonalInfoPresenter.java    License: MIT License 6 votes vote down vote up
@Override
    public void loadPersonalInfo() {
            String jid = personalInfoView.getJid();
            if (!TextUtils.isEmpty(jid)) {
                connectionUtil.getUserCard(jid, new IMLogicManager.NickCallBack() {
                    @Override
                    public void onNickCallBack(Nick nick) {
                        setPersonalInfo(nick);
                        if (personalInfoView != null) {
                            if(nick!=null&&!TextUtils.isEmpty(nick.getXmppId())){
                                //old
//                                ProfileUtils.displayGravatarByImageSrc(nick.getXmppId(),nick.getHeaderSrc(),personalInfoView.getImagetView());
                                //new
                                ProfileUtils.displayGravatarByImageSrc((Activity) personalInfoView.getContext(), nick.getHeaderSrc(), personalInfoView.getImagetView(), 0, 0);
                                EventBus.getDefault().post(
                                        new EventBusEvent.GravtarGot(nick.getHeaderSrc(), personalInfoView.getJid()));
                            }

//                            ProfileUtils.loadVCard4mNet(personalInfoView.getImagetView(), personalInfoView.getJid(), commentView, false);
                        }
                    }
                }, true, false);
            }
    }
 
Example 13
Source Project: Rumble   Source File: NeighbourManager.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void onEvent(ScannerNeighbourTimeout event) {
    if(event.neighbour.isLocal())
        return;
    NeighbourDetail detail;
    synchronized (managerLock) {
        detail = neighborhood.get(event.neighbour);
        if (detail == null)
            return;
        if (!detail.channels.isEmpty())
            return;
        neighborhood.remove(event.neighbour);
    }
    EventBus.getDefault().post(new NeighbourUnreachable(event.neighbour,
            detail.reachable_time_nano, System.nanoTime()));
    EventBus.getDefault().post(new NeighborhoodChanged());
}
 
Example 14
Source Project: imsdk-android   Source File: PersonalInfoMyActivity.java    License: MIT License 6 votes vote down vote up
@Override
public void setUpdateResult(final boolean result) {
    if (CommonConfig.isQtalk) {
        getHandler().post(new Runnable() {
            @Override
            public void run() {
                selGravatarPath = "";
                if (progressDialog != null && progressDialog.isShowing())
                    progressDialog.dismiss();
                if (result) {
                    personalInfoPresenter.loadGravatar(true);
                    EventBus.getDefault().post(new EventBusEvent.GravantarChanged());
                }
                Toast.makeText(PersonalInfoMyActivity.this, result ? getString(R.string.atom_ui_tip_gravantar_update_success) : getString(R.string.atom_ui_tip_gravantar_update_failure), Toast.LENGTH_LONG).show();
            }
        });
    }
}
 
Example 15
Source Project: imsdk-android   Source File: PbChatActivity.java    License: MIT License 6 votes vote down vote up
/**
     * 页面finish后释放相关资源
     */
    private void releaseResource() {
//        if (faceView != null) faceView.removeAllViews();
//        if (quickReplyLayout != null) quickReplyLayout.removeAllViews();
        if (pbChatViewAdapter != null) pbChatViewAdapter.releaseViews();
        if (mDialog != null && mDialog.isShowing()) {
            mDialog.dismiss();
        }
        getHandler().removeCallbacksAndMessages(null);
        if (encryptRequestCountTimer != null) encryptRequestCountTimer.cancel();
        if (chatingPresenter != null) {
            chatingPresenter.close();
        }
        if (waterMarkTextUtil != null) {
            waterMarkTextUtil.recyleBitmap();
        }
        EventBus.getDefault().unregister(handleChatEvent);
    }
 
Example 16
Source Project: Rumble   Source File: FirechatOverBluetooth.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void stopWorker() {
    if(!working)
        return;
    this.working = false;
    EventBus.getDefault().unregister(this);
    try {
        con.disconnect();
    } catch (LinkLayerConnectionException ignore) {
    }
}
 
Example 17
Source Project: MiBandDecompiled   Source File: DynamicFragment.java    License: Apache License 2.0 5 votes vote down vote up
public void onCreate(Bundle bundle)
{
    super.onCreate(bundle);
    p = false;
    b();
    EventBus.getDefault().register(this, "onGoalsSettingChanged", cn/com/smartdevices/bracelet/eventbus/EventGoalsUpdated, new Class[0]);
    EventBus.getDefault().registerSticky(this, "onBleStatusChanged", cn/com/smartdevices/bracelet/ui/BaseSCActivity$ConnStatus, new Class[0]);
    EventBus.getDefault().registerSticky(this, "onLoadDataComplete", cn/com/smartdevices/bracelet/eventbus/EventLoadDataComplete, new Class[0]);
    Resources resources = getActivity().getResources();
    j = resources.getColor(0x7f09000a);
    k = resources.getColor(0x7f09000b);
    l = resources.getColor(0x7f09000c);
}
 
Example 18
Source Project: MultiImagePicker   Source File: AlbumsFragment.java    License: MIT License 5 votes vote down vote up
@Override
public void onRequestSuccess(final ArrayList albumEntries) {

    if (hasLoadedSuccessfully(albumEntries)) {
        mAlbumList = albumEntries;

        final AlbumsAdapter albumsAdapter = new AlbumsAdapter(this, albumEntries, mAlbumsRecycler);
        mAlbumsRecycler.setAdapter(albumsAdapter);

        EventBus.getDefault().postSticky(new Events.OnAlbumsLoadedEvent(mAlbumList));


        if (!mShouldPerformClickOnCapturedAlbum) {
            return;
        }

        mAlbumsRecycler.postDelayed(new Runnable() {
            @Override
            public void run() {

                if (!mAlbumsRecycler.hasPendingAdapterUpdates()) {
                    pickLatestCapturedImage();
                    mShouldPerformClickOnCapturedAlbum = false;
                } else {
                    mAlbumsRecycler.postDelayed(this, 100);
                }

            }
        }, 100);
    }

}
 
Example 19
Source Project: sctalk   Source File: IMService.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
	logger.i("IMService onCreate");
	super.onCreate();
       EventBus.getDefault().register(this, SysConstant.SERVICE_EVENTBUS_PRIORITY);
	// make the service foreground, so stop "360 yi jian qingli"(a clean
	// tool) to stop our app
	// todo eric study wechat's mechanism, use a better solution
	startForeground((int) System.currentTimeMillis(), new Notification());
}
 
Example 20
Source Project: sctalk   Source File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onDestroy() {
	logger.d("mainactivity#onDestroy");
	EventBus.getDefault().unregister(this);
	imServiceConnector.disconnect(this);
       super.onDestroy();
}
 
Example 21
private void initView() {
    eventET = (EditText)findViewById(R.id.event_content);
    receivedEventTV = (TextView)findViewById(R.id.receive_event);
    sendBtn = (Button)findViewById(R.id.send_event);
    sendBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            receivedEventTV.setText("");
            EventBus.getDefault().postSticky(TextUtils.getHintIfTextIsNull(eventET));
            sendBtn.setClickable(false);
            receivedEventTV.setText("Send sticky event success, wait for register after " + WAIT_TIME / 1000
                    + "s\r\n\r\n");
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    // Register
                    receivedEventTV.setText(receivedEventTV.getText() + "Register sticky success\r\n\r\n");
                    EventBus.getDefault().registerSticky(this);
                }

                // Receive Event
                public void onEvent(String event) {
                    receivedEventTV.setText(receivedEventTV.getText() + "OnEvent success:" + event + "\r\n\r\n");
                    sendBtn.setClickable(true);
                    // Unregister
                    EventBus.getDefault().unregister(this);
                    receivedEventTV.setText(receivedEventTV.getText() + "Unregister success");
                }
            }, WAIT_TIME);
        }
    });
}
 
Example 22
Source Project: edx-app-android   Source File: MediaStatusReceiver.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void handleReceive(Context context, Intent intent) {
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
        return;
    }
    prefManager = new PrefManager(context, PrefManager.Pref.USER_PREF);
    final String username = loginPrefs.getUsername();
    final String hashedUsername = (username != null) ? Sha1Util.SHA1(username) : null;

    final String sdCardPath = intent.getDataString().replace("file://", "");
    final String action = intent.getAction();
    if (action != null) {
        boolean sdCardAvailable = false;
        switch (action) {
            case Intent.ACTION_MEDIA_REMOVED:
            case Intent.ACTION_MEDIA_UNMOUNTED:
                sdCardAvailable = false;
                handleSDCardUnmounted(hashedUsername, sdCardPath);
                break;
            case Intent.ACTION_MEDIA_MOUNTED:
                sdCardAvailable = true;
                handleSDCardMounted(context, hashedUsername);
                break;
        }
        EventBus.getDefault().postSticky(new MediaStatusChangeEvent(sdCardAvailable));
    }
}
 
Example 23
Source Project: arcusandroid   Source File: EvenDaysPopup.java    License: Apache License 2.0 5 votes vote down vote up
@Override public void doClose() {
    Calendar selected = Calendar.getInstance();
    selected.add(Calendar.DAY_OF_MONTH, -picker.getValue());
    selected.set(Calendar.HOUR_OF_DAY, 23);
    selected.set(Calendar.MINUTE, 59);
    selected.set(Calendar.SECOND, 59);
    logger.debug("Using: [{}]", DateFormat.getDateTimeInstance().format(selected.getTime()));
    EventBus.getDefault().post(new FloatingDayOrDeviceSelected(selected.getTimeInMillis()));
    if (callback != null) {
        callback.selected(selected.getTimeInMillis());
    }
}
 
Example 24
Source Project: Kore   Source File: AbstractCursorListFragment.java    License: Apache License 2.0 5 votes vote down vote up
@TargetApi(16)
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	View root = super.onCreateView(inflater, container, savedInstanceState);

	bus = EventBus.getDefault();

	if (savedInstanceState != null) {
		savedSearchFilter = savedInstanceState.getString(BUNDLE_KEY_SEARCH_QUERY);
	}
	searchFilter = savedSearchFilter;

	return root;
}
 
Example 25
Source Project: arcusandroid   Source File: EarlySmokeWarningFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();

    if (EventBus.getDefault().isRegistered(this)) {
        EventBus.getDefault().unregister(this);
    }

    Listeners.clear(listenerRegistration);

    Activity activity = getActivity();
    if (activity != null && (activity instanceof DashboardActivity)) {
        ((DashboardActivity) activity).setToPreviousToolbarColor();
    }
}
 
Example 26
Source Project: arcusandroid   Source File: CareAddEditBehaviorFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override public void onResume() {
    super.onResume();

    if (TextUtils.isEmpty(modelIDToEdit)) {
        return;
    }

    Activity activity = getActivity();
    String title = getTitle();
    if (!TextUtils.isEmpty(title) && activity != null) {
        activity.setTitle(title);
    }

    showProgressBar();
    listener = CareBehaviorController.instance().setCallback(this);
    saveListener = CareBehaviorController.instance().setSaveCallback(this);
    if (isEditMode) {
        CareBehaviorController.instance().editExistingBehaviorByID(modelIDToEdit);
    }
    else {
        CareBehaviorController.instance().addBehaviorByTemplateID(modelIDToEdit);
    }

    if (!EventBus.getDefault().isRegistered(this)) {
        EventBus.getDefault().register(this);
    }
}
 
Example 27
Source Project: Rumble   Source File: StatusRecyclerAdapter.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onClick(View v)
{
    PopupMenu popupMenu =  new PopupMenu(activity, v);
    popupMenu.getMenu().add(Menu.NONE, 1, Menu.NONE, R.string.status_more_option_like);
    popupMenu.getMenu().add(Menu.NONE, 2, Menu.NONE, R.string.status_more_option_save);
    popupMenu.getMenu().add(Menu.NONE, 3, Menu.NONE, R.string.status_more_option_delete);
    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            int pos = getAdapterPosition();
            switch (menuItem.getItemId()) {
                case 1:
                    EventBus.getDefault().post(new UserLikedStatus(statuses.get(pos)));
                    return true;
                case 2:
                    EventBus.getDefault().post(new UserSavedStatus(statuses.get(pos)));
                    return true;
                case 3:
                    EventBus.getDefault().post(new UserDeleteStatus(statuses.get(pos)));
                    return true;
                default:
                    return false;
            }
        }
    });
    popupMenu.show();
}
 
Example 28
Source Project: MultiImagePicker   Source File: ImagesPagerFragment.java    License: MIT License 5 votes vote down vote up
private void updateDisplayedImage(final int index) {
    EventBus.getDefault().post(new Events.OnChangingDisplayedImageEvent(mSelectedAlbum.imageList.get(index)));
    //Because index starts from 0
    final int realPosition = index + 1;
    final String actionbarTitle = getResources().getString(R.string.image_position_in_view_pager).replace("%", realPosition + "").replace("$", mSelectedAlbum.imageList.size() + "");
    ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(actionbarTitle);

}
 
Example 29
Source Project: edx-app-android   Source File: VideoDownloadHelper.java    License: Apache License 2.0 5 votes vote down vote up
private void showDownloadSizeExceedDialog(final ArrayList<DownloadEntry> de,
                                          final int noOfDownloads, final FragmentActivity activity, final DownloadManagerCallback callback) {
    Map<String, String> dialogMap = new HashMap<String, String>();
    dialogMap.put("title", activity.getString(R.string.download_exceed_title));
    dialogMap.put("message_1", activity.getString(R.string.download_exceed_message));
    downloadFragment = DownloadSizeExceedDialog.newInstance(dialogMap,
            new IDialogCallback() {
                @Override
                public void onPositiveClicked() {
                    if (!de.isEmpty()) {
                        startDownload(de, activity, callback);

                        final DownloadEntry downloadEntry = de.get(0);
                        analyticsRegistry.trackSubSectionBulkVideoDownload(downloadEntry.getSectionName(),
                                downloadEntry.getChapterName(), downloadEntry.getEnrollmentId(),
                                noOfDownloads);
                        EventBus.getDefault().post(new BulkVideosDownloadStartedEvent());
                    }
                }

                @Override
                public void onNegativeClicked() {
                    //  updateList();
                    downloadFragment.dismiss();
                    EventBus.getDefault().post(new BulkVideosDownloadCancelledEvent());
                }
            });
    downloadFragment.setStyle(DialogFragment.STYLE_NO_TITLE, 0);
    downloadFragment.show(activity.getSupportFragmentManager(), "dialog");
    downloadFragment.setCancelable(false);
}
 
Example 30
Source Project: imsdk-android   Source File: ImageClipActivity.java    License: MIT License 5 votes vote down vote up
void initViews() {
    QtNewActionBar qtNewActionBar = (QtNewActionBar)findViewById(R.id.my_action_bar);
    setNewActionBar(qtNewActionBar);
    setActionBarRightText(R.string.atom_ui_common_use);
    setActionBarRightTextClick(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent resultData = new Intent();
            if (enableClip) {
                Bitmap clipBitmap = getBitmap();
                File tempFile = new File(FileUtils.getExternalFilesDir(ImageClipActivity.this),
                        "temp_gravatar.jpeg");
                ImageUtils.saveBitmap(clipBitmap, tempFile);
                EventBus.getDefault().post(new EventBusEvent.GravanterSelected(tempFile));
                IMNotificaitonCenter.getInstance().postMainThreadNotificationName(QtalkEvent.GravanterSelected,tempFile);
            } else {
                if (!chk_use_origin.isChecked()) {
                    File target = new File(cameraPath.substring(0, cameraPath.lastIndexOf("."))
                            + "_cmp.jpeg");
                    target = ImageUtils.compressFile(selectedImg, target);
                    if (target.exists()) {
                        cameraPath = target.getAbsolutePath();
                    }
                }
                resultData.putExtra(KEY_CAMERA_PATH, cameraPath);
                setResult(RESULT_OK, resultData);
            }
            finish();
        }
    });
    if (!inited) {
        source_pic.setOnTouchListener(this);
        if (selectedImg != null) {
            initClipView();
        } else {
            startCamera();
        }
        inited = true;
    }
}