Skip to content

Commit

Permalink
使用自己的UpdateFun作为更新库
Browse files Browse the repository at this point in the history
  • Loading branch information
hugeterry committed Jul 30, 2016
1 parent 7ec8705 commit 5bd7f16
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 389 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- `Bitmap`
- `RecyclerView`
- [imgly](https://github.com/imgly/imgly-sdk-android-demo)滤镜处理
- [updatefun](https://github.com/hugeterry/UpdateDemo)自己开源的fir.im更新库

##制作团队
- 星空学生创新中心Android方向
Expand Down
6 changes: 4 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "us.xingkong.xingpostcard"
minSdkVersion 15
targetSdkVersion 23
versionCode 5
versionName "1.3"
versionCode 7
versionName "1.5"
renderscriptTargetApi 20
renderscriptSupportModeEnabled true
}
Expand All @@ -29,4 +29,6 @@ dependencies {

compile 'ly.img.android:photo-editor-sdk:1.0.8'

compile 'cn.hugeterry.updatefun:updatefun:1.3.2'

}
10 changes: 0 additions & 10 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<protected-broadcast android:name="android.intent.action.MEDIA_MOUNTED" />

Expand Down Expand Up @@ -39,14 +38,5 @@
<activity android:name=".Activity.ResultActivity" />
<activity android:name=".Activity.AboutActivity" />

<activity
android:name=".update.DownLoadDialog"
android:theme="@style/MyDialogStyle" />
<activity
android:name=".update.UpdateDialog"
android:theme="@style/MyDialogStyle" />
</application>
<meta-data
android:name="wandoujia"
android:value="Channel ID" />
</manifest>
100 changes: 17 additions & 83 deletions app/src/main/java/us/xingkong/xingpostcard/Activity/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,90 +13,35 @@
import android.view.WindowManager;
import android.widget.AdapterView;

import cn.hugeterry.updatefun.UpdateFunGO;

import cn.hugeterry.updatefun.config.UpdateKey;
import us.xingkong.xingpostcard.Adapter.CoverFlow;
import us.xingkong.xingpostcard.Adapter.CoverFlowSampleAdapter;
import us.xingkong.xingpostcard.BuildConfig;
import us.xingkong.xingpostcard.Key;
import us.xingkong.xingpostcard.R;
import us.xingkong.xingpostcard.update.DownLoadDialog;
import us.xingkong.xingpostcard.update.Update;
import us.xingkong.xingpostcard.update.UpdateDialog;

public class MainActivity extends AppCompatActivity {

private Toolbar toolbar;
private CoverFlow fancyCoverFlow;
private SharedPreferences sh_update;

private String version = BuildConfig.VERSION_NAME;

private String apkUrl = "";

Handler up_handler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.arg1) {
case 1:
// 弹出提示更新对话框
showNoticeDialog();
break;
default:
break;
}

}
};


class MyRunnable_update implements Runnable {

@Override
public void run() {
// 检测更新
Update update = new Update();
update.start();

Message msg = new Message();
try {
update.join();
} catch (InterruptedException e) {
e.printStackTrace();
}

sh_update = getSharedPreferences("sh_update", MODE_APPEND);
SharedPreferences.Editor up = sh_update.edit();
up.putString("sh_update_url", update.up_url);
up.putString("sh_update_changelog", update.changelog);
up.commit();

System.out.println("apkUrl: " + apkUrl);
if (update.version == null) {
System.out.println("无联网,不更新");
msg.arg1 = 2;
up_handler.sendMessage(msg);
} else if (!update.version.equals(version)) {
System.out.println("需更新版本");
msg.arg1 = 1;
up_handler.sendMessage(msg);
} else {
System.out.println("版本已是最新");
msg.arg1 = 2;
up_handler.sendMessage(msg);
}
}

}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

initToolbar();
fancyCoverFlowSetting();
UpdateModel();

Thread thread_update = new Thread(new MyRunnable_update());
thread_update.start();
}

private void UpdateModel() {
UpdateKey.API_TOKEN = "";
UpdateKey.RELEASE_ID = "573ecefa748aac36f4000007";
UpdateFunGO.init(this);
}

private void initToolbar() {
Expand Down Expand Up @@ -155,27 +100,16 @@ public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}

private void showNoticeDialog() {
Intent intent = new Intent();
intent.setClass(MainActivity.this, UpdateDialog.class);
startActivityForResult(intent, 100);
}

private void showDownloadDialog() {
Intent intent = new Intent();
intent.setClass(MainActivity.this, DownLoadDialog.class);
System.out.println(apkUrl);
startActivityForResult(intent, 0);
@Override
protected void onResume() {
super.onResume();
UpdateFunGO.onResume(this);
}

// 获取对话框的返回值
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (resultCode) {
case 2:
showDownloadDialog();
break;
default:
break;
}
@Override
protected void onStop() {
super.onStop();
UpdateFunGO.onStop(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import us.xingkong.xingpostcard.R;


public class CoverFlow extends Gallery {
public class CoverFlow extends Gallery {

// =============================================================================
// Constants
Expand Down
169 changes: 0 additions & 169 deletions app/src/main/java/us/xingkong/xingpostcard/update/DownLoadDialog.java

This file was deleted.

Loading

0 comments on commit 5bd7f16

Please sign in to comment.