当前位置: 首页>>代码示例>>Java>>正文


Java UpdateFrom类代码示例

本文整理汇总了Java中com.github.javiersantos.appupdater.enums.UpdateFrom的典型用法代码示例。如果您正苦于以下问题:Java UpdateFrom类的具体用法?Java UpdateFrom怎么用?Java UpdateFrom使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UpdateFrom类属于com.github.javiersantos.appupdater.enums包,在下文中一共展示了UpdateFrom类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import com.github.javiersantos.appupdater.enums.UpdateFrom; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.settings);

    Preference prefCheckForUpdates = findPreference("prefCheckForUpdates");

    prefCheckForUpdates.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            new AppUpdater(SettingsActivity.this)
                    //.setUpdateFrom(UpdateFrom.GITHUB)
                    //.setGitHubUserAndRepo("javiersantos", "AppUpdater")
                    .setUpdateFrom(UpdateFrom.XML)
                    .setUpdateXML("https://raw.githubusercontent.com/javiersantos/AppUpdater/master/app/update-changelog.xml")
                    .setDisplay(Display.DIALOG)
                    .showAppUpdated(true)
                    .start();
            return true;
        }
    });

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:SettingsActivity.java

示例2: showUpdateAvailableSnackbar

import com.github.javiersantos.appupdater.enums.UpdateFrom; //导入依赖的package包/类
static Snackbar showUpdateAvailableSnackbar(final Context context, String content, Boolean indefinite, final UpdateFrom updateFrom, final URL apk) {
    Activity activity = (Activity) context;
    int snackbarTime = indefinite ? Snackbar.LENGTH_INDEFINITE : Snackbar.LENGTH_LONG;

    /*if (indefinite) {
        snackbarTime = Snackbar.LENGTH_INDEFINITE;
    } else {
        snackbarTime = Snackbar.LENGTH_LONG;
    }*/

    Snackbar snackbar = Snackbar.make(activity.findViewById(android.R.id.content), content, snackbarTime);
    snackbar.setAction(context.getResources().getString(R.string.appupdater_btn_update), new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            UtilsLibrary.goToUpdate(context, updateFrom, apk);
        }
    });
    return snackbar;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:UtilsDisplay.java

示例3: showUpdateAvailableNotification

import com.github.javiersantos.appupdater.enums.UpdateFrom; //导入依赖的package包/类
static void showUpdateAvailableNotification(Context context, String title, String content, UpdateFrom updateFrom, URL apk, int smallIconResourceId) {
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, context.getPackageManager().getLaunchIntentForPackage(UtilsLibrary.getAppPackageName(context)), PendingIntent.FLAG_CANCEL_CURRENT);
    PendingIntent pendingIntentUpdate = PendingIntent.getActivity(context, 0, UtilsLibrary.intentToUpdate(context, updateFrom, apk), PendingIntent.FLAG_CANCEL_CURRENT);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setContentIntent(contentIntent)
            .setContentTitle(title)
            .setContentText(content)
            .setStyle(new NotificationCompat.BigTextStyle().bigText(content))
            .setSmallIcon(smallIconResourceId)
            .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
            .setOnlyAlertOnce(true)
            .setAutoCancel(true)
            .addAction(R.drawable.ic_system_update_white_24dp, context.getResources().getString(R.string.appupdater_btn_update), pendingIntentUpdate);

    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(0, builder.build());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:UtilsDisplay.java

示例4: AppUpdater

import com.github.javiersantos.appupdater.enums.UpdateFrom; //导入依赖的package包/类
public AppUpdater(Context context) {
    this.context = context;
    this.libraryPreferences = new LibraryPreferences(context);
    this.display = Display.DIALOG;
    this.updateFrom = UpdateFrom.GOOGLE_PLAY;
    this.duration = Duration.NORMAL;
    this.showEvery = 1;
    this.showAppUpdated = false;
    this.iconResId = R.drawable.ic_stat_name;

    // Dialog
    this.titleUpdate = context.getResources().getString(R.string.appupdater_update_available);
    this.titleNoUpdate = context.getResources().getString(R.string.appupdater_update_not_available);
    this.btnUpdate = context.getResources().getString(R.string.appupdater_btn_update);
    this.btnDismiss = context.getResources().getString(R.string.appupdater_btn_dismiss);
    this.btnDisable = context.getResources().getString(R.string.appupdater_btn_disable);
    this.isDialogCancelable = true;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:AppUpdater.java

示例5: getUpdateURL

import com.github.javiersantos.appupdater.enums.UpdateFrom; //导入依赖的package包/类
static URL getUpdateURL(Context context, UpdateFrom updateFrom, GitHub gitHub) {
    String res;

    switch (updateFrom) {
        default:
            res = String.format(Config.PLAY_STORE_URL, getAppPackageName(context), Locale.getDefault().getLanguage());
            break;
        case GITHUB:
            res = Config.GITHUB_URL + gitHub.getGitHubUser() + "/" + gitHub.getGitHubRepo() + "/releases";
            break;
        case AMAZON:
            res = Config.AMAZON_URL + getAppPackageName(context);
            break;
        case FDROID:
            res = Config.FDROID_URL + getAppPackageName(context);
            break;
    }

    try {
        return new URL(res);
    } catch (MalformedURLException e) {
        throw new RuntimeException(e);
    }

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:UtilsLibrary.java

示例6: getRecentChanges

import com.github.javiersantos.appupdater.enums.UpdateFrom; //导入依赖的package包/类
private static String getRecentChanges(UpdateFrom updateFrom, Boolean isAvailable, String source) {
    String recentChanges = "";
    if (isAvailable) {
        switch (updateFrom) {
            default:
                String[] splitPlayStore = source.split(Config.PLAY_STORE_TAG_CHANGES);
                StringBuilder sb = new StringBuilder();
                for (int i = 1; i < splitPlayStore.length; i++) {
                    sb.append(splitPlayStore[i].split("(<)")[0]).append("\n");
                }
                recentChanges = sb.toString();
                break;
            case GITHUB:
                break;
            case AMAZON:
                break;
            case FDROID:
                break;
        }
    }
    return recentChanges;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:UtilsLibrary.java

示例7: doInBackground

import com.github.javiersantos.appupdater.enums.UpdateFrom; //导入依赖的package包/类
@Override
protected Update doInBackground(Void... voids) {
    if (updateFrom == UpdateFrom.XML || updateFrom == UpdateFrom.JSON) {
        Update update = UtilsLibrary.getLatestAppVersion(updateFrom, xmlOrJsonUrl);
        if (update != null) {
            return update;
        } else {
            AppUpdaterError error = updateFrom == UpdateFrom.XML ? AppUpdaterError.XML_ERROR
                    : AppUpdaterError.JSON_ERROR;

            if (listener != null) {
                listener.onFailed(error);
            }
            cancel(true);
            return null;
        }
    } else {
        Context context = contextRef.get();
        if (context != null) {
            return UtilsLibrary.getLatestAppVersionHttp(context, updateFrom, gitHub);
        } else {
            cancel(true);
            return null;
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:UtilsAsync.java

示例8: checkForUpdate

import com.github.javiersantos.appupdater.enums.UpdateFrom; //导入依赖的package包/类
public void checkForUpdate() {
    //Check for update
    new AppUpdater(this)
            .setUpdateFrom(UpdateFrom.XML)
            .setUpdateXML("https://raw.githubusercontent.com/Bella-Assistant/Bella-Android/alpha/update-changelog.xml")
            .setTitleOnUpdateNotAvailable("Update not available")
            .setContentOnUpdateNotAvailable("No update available. Check for updates again later!")
            .setDisplay(com.github.javiersantos.appupdater.enums.Display.DIALOG)
            .showAppUpdated(true)
            .start();
}
 
开发者ID:NullPointersInc,项目名称:Bella-Android,代码行数:12,代码来源:MainActivity.java

示例9: updateAvailable_Basic_JSON

import com.github.javiersantos.appupdater.enums.UpdateFrom; //导入依赖的package包/类
@Test
public void updateAvailable_Basic_JSON() throws Throwable {
    final CountDownLatch signal = new CountDownLatch(1);

    uiThreadTestRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            new AppUpdaterUtils(InstrumentationRegistry.getTargetContext())
                    .setUpdateFrom(UpdateFrom.JSON)
                    .setUpdateJSON("https://raw.githubusercontent.com/javiersantos/AppUpdater/master/app/src/androidTest/java/com/github/javiersantos/appupdater/files/update-available-basic.json")
                    .withListener(new AppUpdaterUtils.UpdateListener() {
                        @Override
                        public void onSuccess(Update update, Boolean isUpdateAvailable) {
                            assertTrue(isUpdateAvailable);
                            signal.countDown();
                        }

                        @Override
                        public void onFailed(AppUpdaterError error) {
                            assertNotNull(error);
                            signal.countDown();
                        }
                    })
                    .start();
        }
    });

    signal.await(30, TimeUnit.SECONDS);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:UpdateAvailableTest.java

示例10: updateAvailable_VersionCode_JSON

import com.github.javiersantos.appupdater.enums.UpdateFrom; //导入依赖的package包/类
@Test
public void updateAvailable_VersionCode_JSON() throws Throwable {
    final CountDownLatch signal = new CountDownLatch(1);

    uiThreadTestRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            new AppUpdaterUtils(InstrumentationRegistry.getTargetContext())
                    .setUpdateFrom(UpdateFrom.JSON)
                    .setUpdateJSON("https://raw.githubusercontent.com/javiersantos/AppUpdater/master/app/src/androidTest/java/com/github/javiersantos/appupdater/files/update-available-versionCode.json")
                    .withListener(new AppUpdaterUtils.UpdateListener() {
                        @Override
                        public void onSuccess(Update update, Boolean isUpdateAvailable) {
                            assertTrue(isUpdateAvailable);
                            signal.countDown();
                        }

                        @Override
                        public void onFailed(AppUpdaterError error) {
                            assertNotNull(error);
                            signal.countDown();
                        }
                    })
                    .start();
        }
    });

    signal.await(30, TimeUnit.SECONDS);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:UpdateAvailableTest.java

示例11: updateAvailable_Basic_XML

import com.github.javiersantos.appupdater.enums.UpdateFrom; //导入依赖的package包/类
@Test
public void updateAvailable_Basic_XML() throws Throwable {
    final CountDownLatch signal = new CountDownLatch(1);

    uiThreadTestRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            new AppUpdaterUtils(InstrumentationRegistry.getTargetContext())
                    .setUpdateFrom(UpdateFrom.XML)
                    .setUpdateJSON("https://raw.githubusercontent.com/javiersantos/AppUpdater/master/app/src/androidTest/java/com/github/javiersantos/appupdater/files/update-available-basic.xml")
                    .withListener(new AppUpdaterUtils.UpdateListener() {
                        @Override
                        public void onSuccess(Update update, Boolean isUpdateAvailable) {
                            assertTrue(isUpdateAvailable);
                            signal.countDown();
                        }

                        @Override
                        public void onFailed(AppUpdaterError error) {
                            assertNotNull(error);
                            signal.countDown();
                        }
                    })
                    .start();
        }
    });

    signal.await(30, TimeUnit.SECONDS);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:UpdateAvailableTest.java

示例12: updateAvailable_VersionCode_XML

import com.github.javiersantos.appupdater.enums.UpdateFrom; //导入依赖的package包/类
@Test
public void updateAvailable_VersionCode_XML() throws Throwable {
    final CountDownLatch signal = new CountDownLatch(1);

    uiThreadTestRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            new AppUpdaterUtils(InstrumentationRegistry.getTargetContext())
                    .setUpdateFrom(UpdateFrom.XML)
                    .setUpdateJSON("https://raw.githubusercontent.com/javiersantos/AppUpdater/master/app/src/androidTest/java/com/github/javiersantos/appupdater/files/update-available-versionCode.xml")
                    .withListener(new AppUpdaterUtils.UpdateListener() {
                        @Override
                        public void onSuccess(Update update, Boolean isUpdateAvailable) {
                            assertTrue(isUpdateAvailable);
                            signal.countDown();
                        }

                        @Override
                        public void onFailed(AppUpdaterError error) {
                            assertNotNull(error);
                            signal.countDown();
                        }
                    })
                    .start();
        }
    });

    signal.await(30, TimeUnit.SECONDS);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:UpdateAvailableTest.java

示例13: updateAvailable_GOOGLEPLAY

import com.github.javiersantos.appupdater.enums.UpdateFrom; //导入依赖的package包/类
@Test
public void updateAvailable_GOOGLEPLAY() throws Throwable {
    final CountDownLatch signal = new CountDownLatch(1);

    uiThreadTestRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            new AppUpdaterUtils(InstrumentationRegistry.getTargetContext())
                    .setUpdateFrom(UpdateFrom.GOOGLE_PLAY)
                    .withListener(new AppUpdaterUtils.UpdateListener() {
                        @Override
                        public void onSuccess(Update update, Boolean isUpdateAvailable) {
                            assertTrue(isUpdateAvailable);
                            signal.countDown();
                        }

                        @Override
                        public void onFailed(AppUpdaterError error) {
                            assertNotNull(error);
                            signal.countDown();
                        }
                    })
                    .start();
        }
    });

    signal.await(30, TimeUnit.SECONDS);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:UpdateAvailableTest.java

示例14: updateAvailable_Basic_JSON

import com.github.javiersantos.appupdater.enums.UpdateFrom; //导入依赖的package包/类
@Test
public void updateAvailable_Basic_JSON() throws Throwable {
    final CountDownLatch signal = new CountDownLatch(1);

    uiThreadTestRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            new AppUpdaterUtils(InstrumentationRegistry.getTargetContext())
                    .setUpdateFrom(UpdateFrom.JSON)
                    .setUpdateJSON("https://raw.githubusercontent.com/javiersantos/AppUpdater/master/app/src/androidTest/java/com/github/javiersantos/appupdater/files/no-update-available-basic.json")
                    .withListener(new AppUpdaterUtils.UpdateListener() {
                        @Override
                        public void onSuccess(Update update, Boolean isUpdateAvailable) {
                            assertFalse(isUpdateAvailable);
                            signal.countDown();
                        }

                        @Override
                        public void onFailed(AppUpdaterError error) {
                            assertNotNull(error);
                            signal.countDown();
                        }
                    })
                    .start();
        }
    });

    signal.await(30, TimeUnit.SECONDS);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:NoUpdateAvailableTest.java

示例15: updateAvailable_VersionCode_JSON

import com.github.javiersantos.appupdater.enums.UpdateFrom; //导入依赖的package包/类
@Test
public void updateAvailable_VersionCode_JSON() throws Throwable {
    final CountDownLatch signal = new CountDownLatch(1);

    uiThreadTestRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            new AppUpdaterUtils(InstrumentationRegistry.getTargetContext())
                    .setUpdateFrom(UpdateFrom.JSON)
                    .setUpdateJSON("https://raw.githubusercontent.com/javiersantos/AppUpdater/master/app/src/androidTest/java/com/github/javiersantos/appupdater/files/no-update-available-versionCode.json")
                    .withListener(new AppUpdaterUtils.UpdateListener() {
                        @Override
                        public void onSuccess(Update update, Boolean isUpdateAvailable) {
                            assertFalse(isUpdateAvailable);
                            signal.countDown();
                        }

                        @Override
                        public void onFailed(AppUpdaterError error) {
                            assertNotNull(error);
                            signal.countDown();
                        }
                    })
                    .start();
        }
    });

    signal.await(30, TimeUnit.SECONDS);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:NoUpdateAvailableTest.java


注:本文中的com.github.javiersantos.appupdater.enums.UpdateFrom类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。