小编Tha*_*nan的帖子

Canvas对象在Angular JS/iONIC中说未定义的getContext()方法?

我一直在研究离子框架来开发混合应用程序.该应用程序需要Signature插件,我见过JSignatureSiganturePad有很好的实现.但是它们都是通过jQuery support.mine实现的,完全支持Angular JS.

从上面的选择我决定在我的应用程序中使用SignaturePad实现.我使用$ ionicModal服务填充SignaturePad html .我在这里添加了代码.

Signature.html

<ion-modal-view> 
    <div id="signature-pad" class="m-signature-pad">
    <div class="m-signature-pad--body">
      <canvas></canvas>
    </div>
    <div class="m-signature-pad--footer">
      <div class="description">Sign above</div>
      <button class="button clear" data-action="clear" ng-click="doSave()">Clear</button>
      <button class="button save" data-action="save">Save</button>
    </div>
  </div>  
 </ion-modal-view>
Run Code Online (Sandbox Code Playgroud)

Js在这里

$ionicModal.fromTemplateUrl('templates/signature.html', {
    scope: $scope,
    animation: 'slide-in-up'
  }).then(function(modal) {
    $scope.modal = modal;
  });
  $scope.openModal = function() {
    $scope.modal.show();
    $scope.wrapper = angular.element(document.getElementById("signature-pad"));
    var  canvas = angular.element($scope.wrapper.find('.canvas')); 

    SignaturePad(canvas);   
  };
  $scope.closeModal = function() {
    $scope.modal.hide();
  };
  //Cleanup the modal when we're done with it! …
Run Code Online (Sandbox Code Playgroud)

jquery jquery-mobile angularjs cordova ionic-framework

3
推荐指数
1
解决办法
6137
查看次数

如何为alertDialog Box创建一个公共类

如何创建一个类alertDialogBox,应该为每个人调用它Activity.我Activity按下关闭按钮时每次都使用一个关闭按钮,警报框应该杀死我的应用程序中的所有活动.

android android-alertdialog android-activity

2
推荐指数
1
解决办法
2940
查看次数

如何在Android分页库中为列表、过滤和搜索维护相同的数据源

我有显示项目列表的活动,还有过滤器和搜索选项。我正在使用 android 分页库显示项目。第一次加载项目列表时,当我滚动到底部加载下一组项目时,它的工作正常。但我也想过滤项目并搜索项目。在过滤或搜索项目上,我使现有源无效。如果不使数据源无效,则过滤器和搜索 api 不会触发。我想使用数据源根据我的过滤器和搜索键加载新项目列表。

executor = Executors.newFixedThreadPool(5);
    celebrityDataFactory = new CelebrityDataFactory(apicallInterface,         mFansismParam);
    networkState =  Transformations.switchMap(celebrityDataFactory.getCelebrityData(),
            dataSource -> dataSource.getNetworkState());

    PagedList.Config pagedListConfig =
            (new PagedList.Config.Builder())
                    .setEnablePlaceholders(false)
                    .setPrefetchDistance(8)
                    .setInitialLoadSizeHint(10)
                    .setPageSize(20).build();
    if (!mFansismParam.getCategoryId().isEmpty()) {
        celebrityDetails = new LivePagedListBuilder(celebrityDataFactory, pagedListConfig)
                .setFetchExecutor(executor)
                .build();
    } else(!mFansismParam.getProfessionId().isEmpty()) {
        celebrityDetails = new LivePagedListBuilder(celebrityDataFactory, pagedListConfig)
                .setFetchExecutor(executor)
                .build();
    }
Run Code Online (Sandbox Code Playgroud)

数据工厂创建数据源

@Override
public DataSource create() {
    celebrityDataSource = new CelebrityDataSource(apicallInterface,   params);
    celebrityData.postValue(celebrityDataSource);
    return celebrityDataSource;
}
Run Code Online (Sandbox Code Playgroud)

改造 API 调用:

 Call<CelebrityList> getCelebrityList(@Query("categoryId") String categoryId,
                                     @Query("professionId") String professionId,
                                     @Query("page") String pageNumber,
                                     @Query("name") String searchKey); …
Run Code Online (Sandbox Code Playgroud)

android android-search retrofit2 android-paging android-paging-library

2
推荐指数
1
解决办法
2408
查看次数

整场比赛期间播放背景音乐

我正在开发一种记忆游戏,我想在开始游戏时播放背景音乐.

我使用了声音池类并成功执行了它,但我在播放时遇到了问题.我添加.mp3了两分钟的音频文件,但它只播放了15秒钟.

谁能说我有什么问题?这是我的声音类文件:

public class Soundclass {
    private SoundPool soundpool;
    private HashMap<Integer, Integer> soundpoolmap;
    private AudioManager audiomanager;
    private Context context;

    public void initSounds(Context thecontext) {
        context = thecontext;
        soundpool = new SoundPool(4, AudioManager.STREAM_MUSIC, 100);
        soundpoolmap = new HashMap<Integer, Integer>();
        audiomanager = (AudioManager) context
                .getSystemService(Context.AUDIO_SERVICE);
    }

    public Soundclass() {

    }

    public void addSound(int Index, int soundID) {
        soundpoolmap.put(Index, soundpool.load(context, soundID, 1));
    }

    public void playSound(int Index) {
        float streamVolume = audiomanager
                .getStreamVolume(AudioManager.STREAM_MUSIC);
        streamVolume = streamVolume
                / audiomanager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
        soundpool.play(soundpoolmap.get(Index), streamVolume, …
Run Code Online (Sandbox Code Playgroud)

android

0
推荐指数
1
解决办法
1831
查看次数