添加 SuperToast
This commit is contained in:
1 parent
416d080eb4
commit
27cb0aa260
4 files changed
+130
-2
No files matched your search
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2014 Hippo Seven
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="60.0dp"
|
||||
android:minWidth="200.0dp"
|
||||
android:background="@android:color/holo_blue_dark" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingLeft="16dip"
|
||||
android:paddingStart="16dip" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/message"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="16dip"
|
||||
android:paddingStart="16dip"
|
||||
android:paddingRight="16dip"
|
||||
android:paddingEnd="16dip"
|
||||
android:singleLine="true"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -57,14 +57,15 @@ import com.hippo.ehviewer.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.ehclient.EhClient;
|
||||
import com.hippo.ehviewer.service.DownloadService;
|
||||
import com.hippo.ehviewer.service.DownloadServiceConnection;
|
||||
import com.hippo.ehviewer.ui.ActionableToastBar.ActionClickedListener;
|
||||
import com.hippo.ehviewer.util.Cache;
|
||||
import com.hippo.ehviewer.util.Log;
|
||||
import com.hippo.ehviewer.util.Ui;
|
||||
import com.hippo.ehviewer.widget.ActionableToastBar;
|
||||
import com.hippo.ehviewer.widget.DialogBuilder;
|
||||
import com.hippo.ehviewer.widget.FswView;
|
||||
import com.hippo.ehviewer.widget.LoadImageView;
|
||||
import com.hippo.ehviewer.widget.OnFitSystemWindowsListener;
|
||||
import com.hippo.ehviewer.widget.ActionableToastBar.ActionClickedListener;
|
||||
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
|
||||
|
||||
public class FavouriteActivity extends AbstractGalleryActivity
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
* limitations under the License
|
||||
*/
|
||||
|
||||
package com.hippo.ehviewer.ui;
|
||||
package com.hippo.ehviewer.widget;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.ehviewer.widget;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class SuperToast extends Toast {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private LinearLayout mMainView;
|
||||
private ImageView mIcon;
|
||||
private TextView mMessage;
|
||||
|
||||
public SuperToast(Context context) {
|
||||
super(context);
|
||||
|
||||
mContext = context;
|
||||
|
||||
LayoutInflater inflate = (LayoutInflater)
|
||||
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
mMainView = (LinearLayout)inflate.inflate(R.layout.super_toast, null);
|
||||
mIcon = (ImageView)mMainView.findViewById(R.id.icon);
|
||||
mMessage = (TextView)mMainView.findViewById(R.id.message);
|
||||
|
||||
mIcon.setVisibility(View.GONE);
|
||||
|
||||
setDuration(Toast.LENGTH_SHORT);
|
||||
setView(mMainView);
|
||||
}
|
||||
|
||||
public SuperToast setIcon(int resId) {
|
||||
return setIcon(mContext.getResources().getDrawable(resId));
|
||||
}
|
||||
|
||||
public SuperToast setIcon(Drawable drawable) {
|
||||
mIcon.setVisibility(View.VISIBLE);
|
||||
mIcon.setImageDrawable(drawable);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SuperToast setMessage(int resId) {
|
||||
return setMessage(mContext.getResources().getString(resId));
|
||||
}
|
||||
|
||||
public SuperToast setMessage(CharSequence text) {
|
||||
mMessage.setText(text);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user