forked from warkiz/IndicatorSeekBar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
219 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
app/src/main/java/com/warkiz/indicatorseekbar/donation/AlipayUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.warkiz.indicatorseekbar.donation; | ||
|
||
import android.app.Activity; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.pm.PackageInfo; | ||
import android.content.pm.PackageManager; | ||
|
||
import java.net.URISyntaxException; | ||
|
||
/** | ||
* the donation utils , no impact libs | ||
*/ | ||
public class AlipayUtil { | ||
private static final String ALIPAY_PACKAGE_NAME = "com.eg.android.AlipayGphone"; | ||
private static final String PAY_PATH = "FKX03308HBXT5XSEPAKCBB"; | ||
|
||
private static final String INTENT_URL_FORMAT = "intent://platformapi/startapp?saId=10000007&" + | ||
"clientVersion=3.7.0.0718&qrcode=https%3A%2F%2Fqr.alipay.com%2F{urlCode}%3F_s" + | ||
"%3Dweb-other&_t=1472443966571#Intent;" + | ||
"scheme=alipayqr;package=com.eg.android.AlipayGphone;end"; | ||
|
||
public static boolean startAlipayClient(Activity activity, String urlCode) { | ||
return startIntentUrl(activity, INTENT_URL_FORMAT.replace("{urlCode}", urlCode)); | ||
} | ||
|
||
public static boolean startAlipayClient(Activity activity) { | ||
return startIntentUrl(activity, INTENT_URL_FORMAT.replace("{urlCode}", PAY_PATH)); | ||
} | ||
|
||
public static boolean startIntentUrl(Activity activity, String intentFullUrl) { | ||
try { | ||
Intent intent = Intent.parseUri( | ||
intentFullUrl, | ||
Intent.URI_INTENT_SCHEME | ||
); | ||
activity.startActivity(intent); | ||
return true; | ||
} catch (URISyntaxException e) { | ||
e.printStackTrace(); | ||
return false; | ||
} | ||
} | ||
|
||
public static boolean hasInstalledAlipayClient(Context context) { | ||
PackageManager pm = context.getPackageManager(); | ||
try { | ||
PackageInfo info = pm.getPackageInfo(ALIPAY_PACKAGE_NAME, 0); | ||
return info != null; | ||
} catch (PackageManager.NameNotFoundException e) { | ||
e.printStackTrace(); | ||
return false; | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
app/src/main/java/com/warkiz/indicatorseekbar/donation/BaseActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.warkiz.indicatorseekbar.donation; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
|
||
public abstract class BaseActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(getLayoutResId()); | ||
initCreate(); | ||
} | ||
|
||
protected void initCreate() { | ||
|
||
} | ||
|
||
public abstract int getLayoutResId(); | ||
|
||
|
||
} |
39 changes: 39 additions & 0 deletions
39
app/src/main/java/com/warkiz/indicatorseekbar/donation/DonationFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.warkiz.indicatorseekbar.donation; | ||
|
||
import android.view.View; | ||
import android.widget.Toast; | ||
|
||
import com.warkiz.indicatorseekbar.R; | ||
import com.warkiz.indicatorseekbar.fragment.BaseFragment; | ||
|
||
/** | ||
* the Fragment for donation, no impact libs | ||
*/ | ||
|
||
public class DonationFragment extends BaseFragment { | ||
|
||
@Override | ||
protected int getLayoutId() { | ||
return R.layout.buy_me_a_coffee; | ||
} | ||
|
||
@Override | ||
protected void initView(View root) { | ||
View alipay = root.findViewById(R.id.alipay_container); | ||
alipay.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
donation(); | ||
} | ||
}); | ||
} | ||
|
||
private void donation() { | ||
if (AlipayUtil.hasInstalledAlipayClient(getContext())) { | ||
AlipayUtil.startAlipayClient(getActivity()); | ||
} else { | ||
Toast.makeText(getContext(), "No found alipay on your phone!", Toast.LENGTH_LONG).show(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportHeight="1024" | ||
android:viewportWidth="1024"> | ||
<path | ||
android:fillColor="#FFFFFF" | ||
android:pathData="M512,158.72c42.42,0 76.8,35.89 76.8,80.16s-34.38,80.16 -76.8,80.16 -76.8,-35.89 -76.8,-80.16S469.58,158.72 512,158.72z" /> | ||
<path | ||
android:fillColor="#FFFFFF" | ||
android:pathData="M512,431.91c42.42,0 76.8,35.85 76.8,80.09 0,44.23 -34.38,80.09 -76.8,80.09S435.2,556.23 435.2,512C435.2,467.76 469.58,431.91 512,431.91z" /> | ||
<path | ||
android:fillColor="#FFFFFF" | ||
android:pathData="M512,704.96c42.42,0 76.8,35.89 76.8,80.16S554.42,865.28 512,865.28s-76.8,-35.89 -76.8,-80.16S469.58,704.96 512,704.96z" /> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context="com.warkiz.indicatorseekbar.MainActivity"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center_horizontal" | ||
android:layout_margin="16dp" | ||
android:text="Buy me a coffee by Alipay or WeChatPay" | ||
android:textColor="@color/color_blue" | ||
android:textSize="18sp" /> | ||
|
||
<LinearLayout | ||
android:id="@+id/alipay_container" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical" | ||
android:padding="40dp"> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center_horizontal" | ||
android:text="I am clickable! " | ||
android:textColor="@color/color_blue" /> | ||
|
||
<ImageView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center_horizontal" | ||
android:src="@mipmap/alipay" /> | ||
|
||
</LinearLayout> | ||
|
||
<ImageView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center_horizontal" | ||
android:padding="40dp" | ||
android:src="@mipmap/wechat_pay" /> | ||
|
||
</LinearLayout> | ||
|
||
</ScrollView> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.