Java Code Examples for android.widget.LinearLayout#postDelayed()

The following examples show how to use android.widget.LinearLayout#postDelayed() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VoIPActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void showDebugAlert() {
      if(VoIPService.getSharedInstance()==null)
          return;
VoIPService.getSharedInstance().forceRating();
final LinearLayout debugOverlay=new LinearLayout(this);
      debugOverlay.setOrientation(LinearLayout.VERTICAL);
      debugOverlay.setBackgroundColor(0xCC000000);
      int pad=AndroidUtilities.dp(16);
      debugOverlay.setPadding(pad, pad*2, pad, pad*2);

      TextView title=new TextView(this);
      title.setTextColor(0xFFFFFFFF);
      title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
      title.setTypeface(Typeface.DEFAULT_BOLD);
      title.setGravity(Gravity.CENTER);
      title.setText("libtgvoip v"+VoIPController.getVersion());
      debugOverlay.addView(title, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 0, 0, 16));

      ScrollView scroll=new ScrollView(this);
      final TextView debugText=new TextView(this);
      debugText.setTypeface(Typeface.MONOSPACE);
      debugText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
      debugText.setMaxWidth(AndroidUtilities.dp(350));
      debugText.setTextColor(0xFFFFFFFF);
      debugText.setText(getFormattedDebugString());
      scroll.addView(debugText);
      debugOverlay.addView(scroll, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 1f));

      TextView closeBtn=new TextView(this);
      closeBtn.setBackgroundColor(0xFFFFFFFF);
      closeBtn.setTextColor(0xFF000000);
      closeBtn.setPadding(pad, pad, pad, pad);
      closeBtn.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
      closeBtn.setText(LocaleController.getString("Close", R.string.Close));
      debugOverlay.addView(closeBtn, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL, 0, 16, 0, 0));

      final WindowManager wm=(WindowManager) getSystemService(WINDOW_SERVICE);
      wm.addView(debugOverlay, new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_APPLICATION_PANEL, 0, PixelFormat.TRANSLUCENT));

      closeBtn.setOnClickListener(new View.OnClickListener(){
          @Override
          public void onClick(View v){
              wm.removeView(debugOverlay);
          }
      });

      final Runnable r = new Runnable() {
          @Override
          public void run() {
              if (isFinishing() || VoIPService.getSharedInstance() == null) {
                  return;
              }
              debugText.setText(getFormattedDebugString());
              debugOverlay.postDelayed(this, 500);
          }
      };
      debugOverlay.postDelayed(r, 500);
  }
 
Example 2
Source File: VoIPActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void showDebugAlert() {
      if(VoIPService.getSharedInstance()==null)
          return;
VoIPService.getSharedInstance().forceRating();
final LinearLayout debugOverlay=new LinearLayout(this);
      debugOverlay.setOrientation(LinearLayout.VERTICAL);
      debugOverlay.setBackgroundColor(0xCC000000);
      int pad=AndroidUtilities.dp(16);
      debugOverlay.setPadding(pad, pad*2, pad, pad*2);

      TextView title=new TextView(this);
      title.setTextColor(0xFFFFFFFF);
      title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
      title.setTypeface(Typeface.DEFAULT_BOLD);
      title.setGravity(Gravity.CENTER);
      title.setText("libtgvoip v"+VoIPController.getVersion());
      debugOverlay.addView(title, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 0, 0, 16));

      ScrollView scroll=new ScrollView(this);
      final TextView debugText=new TextView(this);
      debugText.setTypeface(Typeface.MONOSPACE);
      debugText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
      debugText.setMaxWidth(AndroidUtilities.dp(350));
      debugText.setTextColor(0xFFFFFFFF);
      debugText.setText(getFormattedDebugString());
      scroll.addView(debugText);
      debugOverlay.addView(scroll, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 1f));

      TextView closeBtn=new TextView(this);
      closeBtn.setBackgroundColor(0xFFFFFFFF);
      closeBtn.setTextColor(0xFF000000);
      closeBtn.setPadding(pad, pad, pad, pad);
      closeBtn.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
      closeBtn.setText(LocaleController.getString("Close", R.string.Close));
      debugOverlay.addView(closeBtn, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL, 0, 16, 0, 0));

      final WindowManager wm=(WindowManager) getSystemService(WINDOW_SERVICE);
      wm.addView(debugOverlay, new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_APPLICATION_PANEL, 0, PixelFormat.TRANSLUCENT));

      closeBtn.setOnClickListener(new View.OnClickListener(){
          @Override
          public void onClick(View v){
              wm.removeView(debugOverlay);
          }
      });

      final Runnable r = new Runnable() {
          @Override
          public void run() {
              if (isFinishing() || VoIPService.getSharedInstance() == null) {
                  return;
              }
              debugText.setText(getFormattedDebugString());
              debugOverlay.postDelayed(this, 500);
          }
      };
      debugOverlay.postDelayed(r, 500);
  }
 
Example 3
Source File: VoIPActivity.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
private void showDebugAlert() {
    if (VoIPService.getSharedInstance() == null)
        return;
    VoIPService.getSharedInstance().forceRating();
    final LinearLayout debugOverlay = new LinearLayout(this);
    debugOverlay.setOrientation(LinearLayout.VERTICAL);
    debugOverlay.setBackgroundColor(0xCC000000);
    int pad = AndroidUtilities.dp(16);
    debugOverlay.setPadding(pad, pad * 2, pad, pad * 2);

    TextView title = new TextView(this);
    title.setTextColor(0xFFFFFFFF);
    title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    title.setTypeface(Typeface.DEFAULT_BOLD);
    title.setGravity(Gravity.CENTER);
    title.setText(getDebugTitle());
    debugOverlay.addView(title, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 0, 0, 16));

    ScrollView scroll = new ScrollView(this);
    final TextView debugText = new TextView(this);
    debugText.setTypeface(Typeface.MONOSPACE);
    debugText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
    debugText.setMaxWidth(AndroidUtilities.dp(350));
    debugText.setTextColor(0xFFFFFFFF);
    debugText.setText(getFormattedDebugString());
    scroll.addView(debugText);
    debugOverlay.addView(scroll, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 1f));

    TextView closeBtn = new TextView(this);
    closeBtn.setBackgroundColor(0xFFFFFFFF);
    closeBtn.setTextColor(0xFF000000);
    closeBtn.setPadding(pad, pad, pad, pad);
    closeBtn.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    closeBtn.setText(LocaleController.getString("Close", R.string.Close));
    debugOverlay.addView(closeBtn, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL, 0, 16, 0, 0));

    final WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
    wm.addView(debugOverlay, new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_APPLICATION_PANEL, 0, PixelFormat.TRANSLUCENT));

    closeBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            wm.removeView(debugOverlay);
        }
    });

    final Runnable r = new Runnable() {
        @Override
        public void run() {
            if (isFinishing() || VoIPService.getSharedInstance() == null) {
                return;
            }
            title.setText(getDebugTitle());
            debugText.setText(getFormattedDebugString());
            debugOverlay.postDelayed(this, 500);
        }
    };
    debugOverlay.postDelayed(r, 500);
}
 
Example 4
Source File: VoIPActivity.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private void showDebugAlert() {
    if (VoIPService.getSharedInstance() == null)
        return;
    VoIPService.getSharedInstance().forceRating();
    final LinearLayout debugOverlay = new LinearLayout(this);
    debugOverlay.setOrientation(LinearLayout.VERTICAL);
    debugOverlay.setBackgroundColor(0xCC000000);
    int pad = AndroidUtilities.dp(16);
    debugOverlay.setPadding(pad, pad * 2, pad, pad * 2);

    TextView title = new TextView(this);
    title.setTextColor(0xFFFFFFFF);
    title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    title.setTypeface(Typeface.DEFAULT_BOLD);
    title.setGravity(Gravity.CENTER);
    title.setText(getDebugTitle());
    debugOverlay.addView(title, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 0, 0, 16));

    ScrollView scroll = new ScrollView(this);
    final TextView debugText = new TextView(this);
    debugText.setTypeface(Typeface.MONOSPACE);
    debugText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
    debugText.setMaxWidth(AndroidUtilities.dp(350));
    debugText.setTextColor(0xFFFFFFFF);
    debugText.setText(getFormattedDebugString());
    scroll.addView(debugText);
    debugOverlay.addView(scroll, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 1f));

    TextView closeBtn = new TextView(this);
    closeBtn.setBackgroundColor(0xFFFFFFFF);
    closeBtn.setTextColor(0xFF000000);
    closeBtn.setPadding(pad, pad, pad, pad);
    closeBtn.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    closeBtn.setText(LocaleController.getString("Close", R.string.Close));
    debugOverlay.addView(closeBtn, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL, 0, 16, 0, 0));

    final WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
    wm.addView(debugOverlay, new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_APPLICATION_PANEL, 0, PixelFormat.TRANSLUCENT));

    closeBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            wm.removeView(debugOverlay);
        }
    });

    final Runnable r = new Runnable() {
        @Override
        public void run() {
            if (isFinishing() || VoIPService.getSharedInstance() == null) {
                return;
            }
            title.setText(getDebugTitle());
            debugText.setText(getFormattedDebugString());
            debugOverlay.postDelayed(this, 500);
        }
    };
    debugOverlay.postDelayed(r, 500);
}